type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ClassDeclaration
/** * Empty component with a router outlet which is needed because ios refuses to show the initial component otherwise, for some reason. */ @Component({ selector: 'trash-main-component', templateUrl: './main-component.component.html', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsu...
goubertbrent/oca-backend
embedded-apps/projects/trash-calendar/src/app/pages/main-component/main-component.component.ts
TypeScript
FunctionDeclaration
export function getSearchTerm(location: Location): string { const term = get( qs, querystring => querystring.parse(location.search.slice(1)).term, "" ) if (Array.isArray(term)) { return term[0] } return term }
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
({ children, containerProps }) => { return ( <AutosuggestWrapper width="100%" flexDirection={["column", "row"]} {...containerProps} > <ResultsWrapper width="100%" mt={0.5}> <Box width="100%"> <Flex flexDirection="column" width="100%"> {children} ...
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
data => Events.postEvent(data)
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
({ suggestion }) => { if (!suggestion) return const { node: { displayType: entityType, id: entityID }, } = suggestion if (entityType === "FirstItem") return this.setState({ entityType, entityID, }) }
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
(_props, _state, [query, hasResults]) => ({ action_type: hasResults ? Schema.ActionType.SearchedAutosuggestWithResults : Schema.ActionType.SearchedAutosuggestWithoutResults, query, })
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
({ value: term }) => { const { relay } = this.props const performanceStart = performance && performance.now() relay.refetch( { term, hasTerm: true, }, null, error => { if (error) { logger.error(error) return } else if (performance...
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
error => { if (error) { logger.error(error) return } else if (performanceStart && sd.VOLLEY_ENDPOINT) { this.reportPerformanceMeasurement(performanceStart) } const { viewer } = this.props const edges = get(viewer, v => v.searchConnection.edges, []) ...
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
v => v.searchConnection.edges
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
performanceStart => { const duration = performance.now() - performanceStart const deviceType = sd.IS_MOBILE ? "mobile" : "desktop" const metricPayload = { type: "timing", name: "autocomplete-search-response", timing: duration, tags: [`device-type:${deviceType}`, "design:rich"], ...
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
(_e, { newValue: term }) => { this.setState({ term }) }
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
event => { const isClickOnSearchIcon = event.relatedTarget && event.relatedTarget.form && event.relatedTarget.form === event.target.form if (isClickOnSearchIcon) { if (!isEmpty(event.target.value)) { this.userClickedOnDescendant = true } } else { this.setState({ ...
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
e => { // This event _also_ fires when a user clicks on a link in the preview pane // or the magnifying glass icon. If we initialize state when that happens, // the link will get removed from the DOM before the browser has a chance // to follow it. if (!this.userClickedOnDescendant) { this...
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
( _props, state: State, [ { suggestion: { node: { href, displayType, id }, }, suggestionIndex, }, ] ) => ({ action_type: Schema.ActionType.SelectedItemFromSearch, query: state.term, destination_path: display...
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
({ containerProps, children, query }) => { const noResults = get( this.props, p => p.viewer.searchConnection.edges.length === 0 ) const { focused } = this.state if (noResults || !focused || !query) { return null } const props = { children, containerProps, f...
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
p => p.viewer.searchConnection.edges.length === 0
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
({ node: { displayLabel } }) => { return displayLabel }
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
(edge, rest) => { const renderer = edge.node.isFirstItem ? this.renderFirstSuggestion : this.renderDefaultSuggestion const item = renderer(edge, rest) return item }
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
(edge, { query, isHighlighted }) => { const { displayLabel, displayType, href } = edge.node return ( <FirstSuggestionItem display={displayLabel} href={href} isHighlighted={isHighlighted} label={displayType} query={query} /> ) }
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
(edge, { query, isHighlighted }) => { const { displayLabel, displayType, href } = edge.node const newHref = displayType === "Artist" ? `${href}/works-for-sale` : href return ( <SuggestionItem display={displayLabel} href={newHref} isHighlighted={isHighlighted} label={d...
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
props => <SearchInputContainer {...props} /> renderAutosuggestComponent({ xs })
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
(event: React.KeyboardEvent<HTMLInputElement>) => { if ( event.keyCode === 13 && // Enter key press ... event.target && // with empty search query isEmpty((event.target as HTMLInputElement).value) ) { event.preventDefault() } // Clear input after...
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
() => { this.setState({ term: "", }) }
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
() => { const { relayEnvironment, searchQuery = "" } = useContext(SystemContext) const isMounted = useDidMount(typeof window !== "undefined") /** * Displays during SSR render, but once mounted is swapped out with * QueryRenderer below. */ const StaticSearchContainer = () => { return ( <> ...
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
() => { return ( <> <Box display={["block", "none"]}> <SearchInputContainer placeholder={searchQuery || PLACEHOLDER_XS} defaultValue={searchQuery} /> </Box> <Box display={["none", "block"]}> <SearchInputContainer placeh...
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
querystring => querystring.parse(location.search.slice(1)).term
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
InterfaceDeclaration
export interface Props extends SystemContextProps { relay: RelayRefetchProp router?: Router viewer: SearchBar_viewer }
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
InterfaceDeclaration
interface State { /* Holds current input */ term: string /* For preview generation of selected items */ entityID: string entityType: string focused: boolean }
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
MethodDeclaration
@track((_props, _state, [query, hasResults]) => ({ action_type: hasResults ? Schema.ActionType.SearchedAutosuggestWithResults : Schema.ActionType.SearchedAutosuggestWithoutResults, query, })) trackSearch(_term, _hasResults) { /* no-op */ }
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
MethodDeclaration
componentDidMount() { this.throttledFetch = throttle(this.throttledFetch, 500, { leading: true, }) this.throttledOnSuggestionHighlighted = throttle( this.throttledOnSuggestionHighlighted, 500, { leading: true } ) }
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
MethodDeclaration
@track({ action_type: Schema.ActionType.FocusedOnAutosuggestInput, }) onFocus() { this.setState({ focused: true }) }
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
MethodDeclaration
// Navigate to selected search item. @track( ( _props, state: State, [ { suggestion: { node: { href, displayType, id }, }, suggestionIndex, }, ] ) => ({ action_type: Schema.ActionType.SelectedItemFromSearch, query: sta...
erikdstock/force
src/v2/Components/Search/SearchBar.tsx
TypeScript
ArrowFunction
(state = initialWorkersState, action) => { switch (action.type) { case WorkersActionTypes.FETCH_REQUEST: return { ...state, loading: true }; case WorkersActionTypes.FETCH_SUCCESS: return { ...state, loading: false, data: action.payload.data, response: action.payload, errors: undefined }; case...
2005hithlj/alluxio
webui/master/src/store/workers/reducer.tsx
TypeScript
FunctionDeclaration
/* NOT USED at the moment, but might be valuable if we want to fix atomic block behaviour */ export default function ( editorState: EditorState, blockKey: string ): EditorState { let content = editorState.getCurrentContent(); const beforeKey = content.getKeyBefore(blockKey); const beforeBlock = content.getBl...
aeroyu/draft-js-plugins
packages/focus/src/modifiers/removeBlock.ts
TypeScript
ArrowFunction
() => { const editableNote = useSelector( (state: RootState) => state.notes.editableNote, ); const isEditable: boolean = editableNote ? true : false; const dispatch = useDispatch(); return ( <CSSTransition classNames="fade" in={isEditable} timeout={300} unmountOnExit > ...
one-think-0116/google-keeper
src/components/UI/Backdrop/Backdrop.tsx
TypeScript
ArrowFunction
(state: RootState) => state.notes.editableNote
one-think-0116/google-keeper
src/components/UI/Backdrop/Backdrop.tsx
TypeScript
ArrowFunction
() => dispatch(clearEditableNote())
one-think-0116/google-keeper
src/components/UI/Backdrop/Backdrop.tsx
TypeScript
ArrowFunction
() => { return instancesBuilder.buildExact(definition); }
robak86/hardwired
packages/core/src/strategies/SingletonStrategy.ts
TypeScript
ArrowFunction
() => { return instancesBuilder.buildExact(definition); }
robak86/hardwired
packages/core/src/strategies/SingletonStrategy.ts
TypeScript
ClassDeclaration
export class SingletonStrategy extends BuildStrategy { build( definition: InstanceDefinition<any, any>, instancesCache: InstancesStore, resolvers, instancesBuilder: InstancesBuilder, ) { const id = definition.id; if (resolvers.hasGlobalOverrideDefinition(id)) { return instancesCache....
robak86/hardwired
packages/core/src/strategies/SingletonStrategy.ts
TypeScript
MethodDeclaration
build( definition: InstanceDefinition<any, any>, instancesCache: InstancesStore, resolvers, instancesBuilder: InstancesBuilder, ) { const id = definition.id; if (resolvers.hasGlobalOverrideDefinition(id)) { return instancesCache.upsertGlobalOverrideScope(id, () => { return inst...
robak86/hardwired
packages/core/src/strategies/SingletonStrategy.ts
TypeScript
ArrowFunction
() => { // Simple sentence to test string building from stack const testString = "This is a sentence"; // Complex document to test every branch of the candidate term extraction function const cteText = "Cat. Cats. Americas. George Washington. John in the hat. This is minty gum. John of Smith. John Smi...
michaeljneely/fyp-dialogue-ake
test/semcluster.test.ts
TypeScript
ArrowFunction
() => { coreNLPStub.reset(); }
michaeljneely/fyp-dialogue-ake
test/semcluster.test.ts
TypeScript
ArrowFunction
async () => { expect.assertions(1); // Stub parseDocument const simpleSentence = await fs.readJSON(path.join(__dirname, "mocks/simple.json")); const simpleDocument = CoreNLP.simple.Document.fromJSON(simpleSentence); coreNLPStub.returns(simpleDocument); const document = a...
michaeljneely/fyp-dialogue-ake
test/semcluster.test.ts
TypeScript
ArrowFunction
(token) => { tokenStack.push(token); }
michaeljneely/fyp-dialogue-ake
test/semcluster.test.ts
TypeScript
ArrowFunction
async () => { expect.assertions(19); // Stub parseDocument const complexSentences = await fs.readJSON(path.join(__dirname, "mocks/complex.json")); const complexDocument = CoreNLP.simple.Document.fromJSON(complexSentences); coreNLPStub.returns(complexDocument); const docu...
michaeljneely/fyp-dialogue-ake
test/semcluster.test.ts
TypeScript
FunctionDeclaration
export function radioReducer(state: any, action: ActionPayload) { switch (action.type) { case RadioActions.GET: return Object.assign({}, state, { _loading: true, _error: false }); case RadioActions.GET_SUCCESS: return Object.assign...
vanhullc/onAir
src/app/store/radio/radio.reducer.ts
TypeScript
ArrowFunction
(input: string) => { const hash = sha256.create(); hash.update(input); return hash.hex(); }
goncaloMagalhaes/merkle-tree
src/utils/HashFunctions.ts
TypeScript
ClassDeclaration
export class Twinkle { pos: p5.Vector; rate: number; max: number; min: number; size: number; constructor(p: p5) { this.init(p); } init(p: p5) { this.pos = p.createVector(p.int(p.random(-p.width, p.width)), p.int(p.random(-p.height, p.height))); this.rate = p.random(0.25, 3); this.min =...
odedw/processing-sketches
web/src/sketches/Genuary2022/genuary-2022-03.sketch.ts/Twinkle.ts
TypeScript
MethodDeclaration
init(p: p5) { this.pos = p.createVector(p.int(p.random(-p.width, p.width)), p.int(p.random(-p.height, p.height))); this.rate = p.random(0.25, 3); this.min = 50; this.max = 200; this.size = p.random(0.2, 1.5); }
odedw/processing-sketches
web/src/sketches/Genuary2022/genuary-2022-03.sketch.ts/Twinkle.ts
TypeScript
MethodDeclaration
update(p: p5) {}
odedw/processing-sketches
web/src/sketches/Genuary2022/genuary-2022-03.sketch.ts/Twinkle.ts
TypeScript
MethodDeclaration
draw(p: p5) { const current = ((p.sin(p.frameCount * this.rate) + 1) / 2) * (this.max - this.min); p.noStroke(); p.fill(current + this.min); p.circle(this.pos.x, this.pos.y, this.size); }
odedw/processing-sketches
web/src/sketches/Genuary2022/genuary-2022-03.sketch.ts/Twinkle.ts
TypeScript
ArrowFunction
() => { it('should be defined', () => { expect(helpers).toBeDefined(); }); it('should expose all modules', () => { expect(helpers).toMatchSnapshot(); }); }
AlexZeDim/blizzapi
tests/lib/helpers/index.test.ts
TypeScript
ArrowFunction
() => { expect(helpers).toBeDefined(); }
AlexZeDim/blizzapi
tests/lib/helpers/index.test.ts
TypeScript
ArrowFunction
() => { expect(helpers).toMatchSnapshot(); }
AlexZeDim/blizzapi
tests/lib/helpers/index.test.ts
TypeScript
ClassDeclaration
export default class GenericClient extends ServiceClient { module: string = ''; constructor(params: GenericClientConstructorParams) { super(params); this.module = params.module; } public async callMethod(method: string, params: GenericClientParams): Promise<GenericClientResult> { ...
eapearson/kbase-ui-lib
src/comm/JSONRPC11/GenericClient.ts
TypeScript
InterfaceDeclaration
export interface GenericClientConstructorParams extends ServiceClientParams { module: string; }
eapearson/kbase-ui-lib
src/comm/JSONRPC11/GenericClient.ts
TypeScript
TypeAliasDeclaration
export type GenericClientParams = JSONArrayOf<JSONValue>;
eapearson/kbase-ui-lib
src/comm/JSONRPC11/GenericClient.ts
TypeScript
TypeAliasDeclaration
export type GenericClientResult = JSONArrayOf<JSONValue>;
eapearson/kbase-ui-lib
src/comm/JSONRPC11/GenericClient.ts
TypeScript
MethodDeclaration
public async callMethod(method: string, params: GenericClientParams): Promise<GenericClientResult> { return await this.callFunc<GenericClientParams, GenericClientResult>(method, params); }
eapearson/kbase-ui-lib
src/comm/JSONRPC11/GenericClient.ts
TypeScript
FunctionDeclaration
/** * Decoded, unzips and parses the ping payload into a JSON object. * * @param payload The payload to process. * @returns The processed payload. */ export function unzipPingPayload(payload: Uint8Array | string): JSONObject { let parsedBody: JSONObject; if (!isString(payload)) { const decoder = new TextDe...
scholtzan/glean.js
glean/tests/utils.ts
TypeScript
ArrowFunction
comp => this.entity.components.includes(comp.id)
proman21/FollyEngine
frontend/src/app/project-view/editors/entity-editor/entity-editor.component.ts
TypeScript
ArrowFunction
text => text.length > 2
proman21/FollyEngine
frontend/src/app/project-view/editors/entity-editor/entity-editor.component.ts
TypeScript
ArrowFunction
([n, d]) => { this.entityService.updateEntity({name: n, description: d}); }
proman21/FollyEngine
frontend/src/app/project-view/editors/entity-editor/entity-editor.component.ts
TypeScript
ArrowFunction
id => { this.entityService.addComponentToEntity(id); }
proman21/FollyEngine
frontend/src/app/project-view/editors/entity-editor/entity-editor.component.ts
TypeScript
ClassDeclaration
@Component({ selector: 'app-entity-editor', templateUrl: './entity-editor.component.html', styleUrls: ['./entity-editor.component.css'] }) export class EntityEditorComponent implements OnInit { get entity() { return this.entityQuery.getActive(); } get components() { return this.componentQuery.getAl...
proman21/FollyEngine
frontend/src/app/project-view/editors/entity-editor/entity-editor.component.ts
TypeScript
MethodDeclaration
ngOnInit() { combineLatest( this.name$.pipe( filter(text => text.length > 2), debounceTime(1000), distinctUntilChanged() ), this.description$.pipe( filter(text => text.length > 2), debounceTime(1000), distinctUntilChanged() ) ).pipe( ...
proman21/FollyEngine
frontend/src/app/project-view/editors/entity-editor/entity-editor.component.ts
TypeScript
MethodDeclaration
addComponent() { const dialogRef = this.dialog.open(GenericSelectDialogComponent, { width: '250px', data: { title: 'Choose DesignerComponent', description: 'Choose a component:', placeholder: 'DesignerComponent', elements: this.componentQuery.getAll() } }); ...
proman21/FollyEngine
frontend/src/app/project-view/editors/entity-editor/entity-editor.component.ts
TypeScript
MethodDeclaration
removeComponent([index, compId]: [number, string]) { this.entityService.removeComponentFromEntity(index, compId); }
proman21/FollyEngine
frontend/src/app/project-view/editors/entity-editor/entity-editor.component.ts
TypeScript
ArrowFunction
({ theme }) => `${theme.breakpoints.mobile}px`
pmaier983/Blog
components/pages/ScrollNavPage.tsx
TypeScript
ArrowFunction
({ theme }) => theme.colors.gitCommit0
pmaier983/Blog
components/pages/ScrollNavPage.tsx
TypeScript
ArrowFunction
({ children }) => { const theme = useContext(ThemeContext) const isMobile = useMediaQuery(theme.breakpoints.mobile) const [, dispatchAlert] = useAlertContext() const copyToClip = () => { copyToClipboard("pmaier983@gmail.com") dispatchAlert({ type: ALERT_ACTIONS.SHOW_ALERT, payload: <Clipbo...
pmaier983/Blog
components/pages/ScrollNavPage.tsx
TypeScript
ArrowFunction
() => { copyToClipboard("pmaier983@gmail.com") dispatchAlert({ type: ALERT_ACTIONS.SHOW_ALERT, payload: <ClipboardConfirmationAlert />, }) }
pmaier983/Blog
components/pages/ScrollNavPage.tsx
TypeScript
ArrowFunction
() => { const {sidebarOpen} = this.state; // check if the sidebar has been opened again before resetting activeIcon if (!sidebarOpen) { this.setState({activeIcon: undefined}); } }
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
ArrowFunction
(tab: string) => ({ display: activeIcon === tab ? 'block' : 'none', height: 'calc(100% - 1rem)', overflow: 'auto', padding: '0.5rem', })
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
ArrowFunction
(section, s) => <div key
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
ArrowFunction
(content, c) => { return typeof content === 'string' ? <p key={c} style={styles.contentItem}>{content}</p> : <div key={c}> <h4 style={styles.contentTitle}>{content.title}</h4> {content.content.map((item, i) => ...
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
ArrowFunction
(item, i) => <p key
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
ClassDeclaration
export class HelpSidebar extends React.Component<Props, State> { constructor(props: Props) { super(props); this.state = { activeIcon: undefined, sidebarOpen: false, searchTerm: undefined }; } onIconClick(icon: string) { const {activeIcon, sidebarOpen} = this.state; const ne...
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
ClassDeclaration
@Component({ selector: 'app-help-sidebar', template: '<div #root></div>', }) export class HelpSidebarComponent extends ReactWrapperBase { @Input('location') location: Props['location']; @Input('participant') participant: Props['participant']; @Input('setParticipant') setParticipant: Props['setParticipant']; ...
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
InterfaceDeclaration
interface Props { location: string; participant?: any; setParticipant?: Function; }
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
InterfaceDeclaration
interface State { activeIcon: string; sidebarOpen: boolean; searchTerm: string; }
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
MethodDeclaration
onIconClick(icon: string) { const {activeIcon, sidebarOpen} = this.state; const newSidebarOpen = !(icon === activeIcon && sidebarOpen); if (newSidebarOpen) { this.setState({activeIcon: icon, sidebarOpen: newSidebarOpen}); } else { this.hideSidebar(); } }
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
MethodDeclaration
hideSidebar() { this.setState({sidebarOpen: false}); // keep activeIcon set while the sidebar transition completes setTimeout(() => { const {sidebarOpen} = this.state; // check if the sidebar has been opened again before resetting activeIcon if (!sidebarOpen) { this.setState({acti...
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
MethodDeclaration
render() { const {location, participant, setParticipant} = this.props; const {activeIcon, sidebarOpen} = this.state; const contentStyle = (tab: string) => ({ display: activeIcon === tab ? 'block' : 'none', height: 'calc(100% - 1rem)', overflow: 'auto', padding: '0.5rem', }); ...
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
MethodDeclaration
contentStyle('help')
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
MethodDeclaration
contentStyle('annotations')
deflaux/workbench
ui/src/app/components/help-sidebar.tsx
TypeScript
InterfaceDeclaration
interface IAddresses { [key: number]: { [key: string]: string }; }
Diamond1020/NovaDAO-Dapp
src/constants.ts
TypeScript
TypeAliasDeclaration
type PackContext = { share?: boolean; editPack: () => void; showDetails: () => void; pack: { id: string; notes?: string | null; name?: string; private?: boolean; }; user?: { id: string; avatar_id: string | null; avatar_version: number | null; username: string; }; cat...
benhoneywill/hikerherd
app/apps/packs/contexts/pack-context.ts
TypeScript
FunctionDeclaration
export async function savePlant(plant: PlantProps): Promise<void> { try { const nextTime = new Date(plant.dateTimeNotification); const now = new Date(); const { times, repeat_every } = plant.frequency; if( repeat_every === 'week') { const interval = Math.trunc(7 / times); nextTime.s...
euclidesdry/PlantCare
src/libs/storage.ts
TypeScript
FunctionDeclaration
export async function loadPlant(): Promise<PlantProps[]> { try { const data = await AsyncStorage.getItem('@plantcare:plants'); const plants = data ? (JSON.parse(data) as StoragePlantProps) : {}; const plantsSorted = Object .keys(plants) .map((plant) => { return { ...plants[plant].d...
euclidesdry/PlantCare
src/libs/storage.ts
TypeScript
FunctionDeclaration
export async function removePlant(id: string): Promise<void> { const data = await AsyncStorage.getItem('@plantcare:plants'); const plants = data ? (JSON.parse(data) as StoragePlantProps) : {}; delete plants[id]; await AsyncStorage.setItem( '@plantcare:plants', JSON.stringify(plants) ); }
euclidesdry/PlantCare
src/libs/storage.ts
TypeScript
ArrowFunction
(plant) => { return { ...plants[plant].data, hour: format(new Date(plants[plant].data.dateTimeNotification), 'HH:mm') } }
euclidesdry/PlantCare
src/libs/storage.ts
TypeScript
ArrowFunction
(a, b) => Math.floor( new Date(a.dateTimeNotification).getTime() / 1000 - Math.floor(new Date(b.dateTimeNotification).getTime() / 1000) )
euclidesdry/PlantCare
src/libs/storage.ts
TypeScript
InterfaceDeclaration
export interface PlantProps { id: string; name: string; about: string; water_tips: string; photo: string; environments: [string]; frequency: { times: number, repeat_every: string }; hour: string; dateTimeNotification: Date; }
euclidesdry/PlantCare
src/libs/storage.ts
TypeScript
InterfaceDeclaration
export interface StoragePlantProps { [id: string]: { data: PlantProps; notificationId: string; } }
euclidesdry/PlantCare
src/libs/storage.ts
TypeScript
ArrowFunction
(ownerState: OwnerState) => { const { classes } = ownerState; const slots = { root: ['treeDataGroupingCell'], toggle: ['treeDataGroupingCellToggle'], }; return composeClasses(slots, getDataGridUtilityClass, classes); }
pkratz/mui-x
packages/grid/_modules_/grid/components/cell/GridTreeDataGroupingCell.tsx
TypeScript
ArrowFunction
(props: GridTreeDataGroupingCellProps) => { const { id, field, rowNode, hideDescendantCount } = props; const rootProps = useGridRootProps(); const apiRef = useGridApiContext<GridApiPro>(); const ownerState: OwnerState = { classes: rootProps.classes }; const classes = useUtilityClasses(ownerState); const f...
pkratz/mui-x
packages/grid/_modules_/grid/components/cell/GridTreeDataGroupingCell.tsx
TypeScript
ArrowFunction
(event) => { if (isSpaceKey(event.key)) { event.stopPropagation(); } if (isNavigationKey(event.key) && !event.shiftKey) { apiRef.current.publishEvent(GridEvents.cellNavigationKeyDown, props, event); } }
pkratz/mui-x
packages/grid/_modules_/grid/components/cell/GridTreeDataGroupingCell.tsx
TypeScript
ArrowFunction
(event) => { apiRef.current.setRowChildrenExpansion(id, !rowNode.childrenExpanded); apiRef.current.setCellFocus(id, field); event.stopPropagation(); }
pkratz/mui-x
packages/grid/_modules_/grid/components/cell/GridTreeDataGroupingCell.tsx
TypeScript