UNPKG

repoweaver

Version:

A GitHub App that skillfully weaves multiple templates together to create and update repositories with intelligent merge strategies

1 lines 14.4 kB
{"ast":null,"code":"\"use strict\";\n\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/objectWithoutPropertiesLoose\";\nconst _excluded = [\"defaultStatus\"];\nimport { nanoid } from 'nanoid/non-secure';\nimport { TabActions, TabRouter } from \"./TabRouter.js\";\nexport const DrawerActions = Object.assign({}, TabActions, {\n openDrawer() {\n return {\n type: 'OPEN_DRAWER'\n };\n },\n closeDrawer() {\n return {\n type: 'CLOSE_DRAWER'\n };\n },\n toggleDrawer() {\n return {\n type: 'TOGGLE_DRAWER'\n };\n }\n});\nexport function DrawerRouter(_ref) {\n let {\n defaultStatus = 'closed'\n } = _ref,\n rest = _objectWithoutPropertiesLoose(_ref, _excluded);\n const router = TabRouter(rest);\n const isDrawerInHistory = state => Boolean(state.history?.some(it => it.type === 'drawer'));\n const addDrawerToHistory = state => {\n if (isDrawerInHistory(state)) {\n return state;\n }\n return Object.assign({}, state, {\n history: [...state.history, {\n type: 'drawer',\n status: defaultStatus === 'open' ? 'closed' : 'open'\n }]\n });\n };\n const removeDrawerFromHistory = state => {\n if (!isDrawerInHistory(state)) {\n return state;\n }\n return Object.assign({}, state, {\n history: state.history.filter(it => it.type !== 'drawer')\n });\n };\n const openDrawer = state => {\n if (defaultStatus === 'open') {\n return removeDrawerFromHistory(state);\n }\n return addDrawerToHistory(state);\n };\n const closeDrawer = state => {\n if (defaultStatus === 'open') {\n return addDrawerToHistory(state);\n }\n return removeDrawerFromHistory(state);\n };\n return Object.assign({}, router, {\n type: 'drawer',\n getInitialState({\n routeNames,\n routeParamList,\n routeGetIdList\n }) {\n const state = router.getInitialState({\n routeNames,\n routeParamList,\n routeGetIdList\n });\n return Object.assign({}, state, {\n default: defaultStatus,\n stale: false,\n type: 'drawer',\n key: `drawer-${nanoid()}`\n });\n },\n getRehydratedState(partialState, {\n routeNames,\n routeParamList,\n routeGetIdList\n }) {\n if (partialState.stale === false) {\n return partialState;\n }\n let state = router.getRehydratedState(partialState, {\n routeNames,\n routeParamList,\n routeGetIdList\n });\n if (isDrawerInHistory(partialState)) {\n state = removeDrawerFromHistory(state);\n state = addDrawerToHistory(state);\n }\n return Object.assign({}, state, {\n default: defaultStatus,\n type: 'drawer',\n key: `drawer-${nanoid()}`\n });\n },\n getStateForRouteFocus(state, key) {\n const result = router.getStateForRouteFocus(state, key);\n return closeDrawer(result);\n },\n getStateForAction(state, action, options) {\n switch (action.type) {\n case 'OPEN_DRAWER':\n return openDrawer(state);\n case 'CLOSE_DRAWER':\n return closeDrawer(state);\n case 'TOGGLE_DRAWER':\n if (isDrawerInHistory(state)) {\n return removeDrawerFromHistory(state);\n }\n return addDrawerToHistory(state);\n case 'JUMP_TO':\n case 'NAVIGATE':\n case 'NAVIGATE_DEPRECATED':\n {\n const result = router.getStateForAction(state, action, options);\n if (result != null && result.index !== state.index) {\n return closeDrawer(result);\n }\n return result;\n }\n case 'GO_BACK':\n if (isDrawerInHistory(state)) {\n return removeDrawerFromHistory(state);\n }\n return router.getStateForAction(state, action, options);\n default:\n return router.getStateForAction(state, action, options);\n }\n },\n actionCreators: DrawerActions\n });\n}","map":{"version":3,"names":["nanoid","TabActions","TabRouter","DrawerActions","Object","assign","openDrawer","type","closeDrawer","toggleDrawer","DrawerRouter","_ref","defaultStatus","rest","_objectWithoutPropertiesLoose","_excluded","router","isDrawerInHistory","state","Boolean","history","some","it","addDrawerToHistory","status","removeDrawerFromHistory","filter","getInitialState","routeNames","routeParamList","routeGetIdList","default","stale","key","getRehydratedState","partialState","getStateForRouteFocus","result","getStateForAction","action","options","index","actionCreators"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/@react-navigation/routers/src/DrawerRouter.tsx"],"sourcesContent":["import { nanoid } from 'nanoid/non-secure';\n\nimport {\n type TabActionHelpers,\n TabActions,\n type TabActionType,\n type TabNavigationState,\n TabRouter,\n type TabRouterOptions,\n} from './TabRouter';\nimport type {\n CommonNavigationAction,\n ParamListBase,\n PartialState,\n Router,\n} from './types';\nexport type DrawerStatus = 'open' | 'closed';\n\nexport type DrawerActionType =\n | TabActionType\n | {\n type: 'OPEN_DRAWER' | 'CLOSE_DRAWER' | 'TOGGLE_DRAWER';\n source?: string;\n target?: string;\n };\n\nexport type DrawerRouterOptions = TabRouterOptions & {\n defaultStatus?: DrawerStatus;\n};\n\nexport type DrawerNavigationState<ParamList extends ParamListBase> = Omit<\n TabNavigationState<ParamList>,\n 'type' | 'history'\n> & {\n /**\n * Type of the router, in this case, it's drawer.\n */\n type: 'drawer';\n /**\n * Default status of the drawer.\n */\n default: DrawerStatus;\n /**\n * List of previously visited route keys and drawer open status.\n */\n history: (\n | { type: 'route'; key: string }\n | { type: 'drawer'; status: DrawerStatus }\n )[];\n};\n\nexport type DrawerActionHelpers<ParamList extends ParamListBase> =\n TabActionHelpers<ParamList> & {\n /**\n * Open the drawer sidebar.\n */\n openDrawer(): void;\n\n /**\n * Close the drawer sidebar.\n */\n closeDrawer(): void;\n\n /**\n * Open the drawer sidebar if closed, or close if opened.\n */\n toggleDrawer(): void;\n };\n\nexport const DrawerActions = {\n ...TabActions,\n openDrawer() {\n return { type: 'OPEN_DRAWER' } as const satisfies DrawerActionType;\n },\n closeDrawer() {\n return { type: 'CLOSE_DRAWER' } as const satisfies DrawerActionType;\n },\n toggleDrawer() {\n return { type: 'TOGGLE_DRAWER' } as const satisfies DrawerActionType;\n },\n};\n\nexport function DrawerRouter({\n defaultStatus = 'closed',\n ...rest\n}: DrawerRouterOptions): Router<\n DrawerNavigationState<ParamListBase>,\n DrawerActionType | CommonNavigationAction\n> {\n const router = TabRouter(rest) as unknown as Router<\n DrawerNavigationState<ParamListBase>,\n TabActionType | CommonNavigationAction\n >;\n\n const isDrawerInHistory = (\n state:\n | DrawerNavigationState<ParamListBase>\n | PartialState<DrawerNavigationState<ParamListBase>>\n ) => Boolean(state.history?.some((it) => it.type === 'drawer'));\n\n const addDrawerToHistory = (\n state: DrawerNavigationState<ParamListBase>\n ): DrawerNavigationState<ParamListBase> => {\n if (isDrawerInHistory(state)) {\n return state;\n }\n\n return {\n ...state,\n history: [\n ...state.history,\n {\n type: 'drawer',\n status: defaultStatus === 'open' ? 'closed' : 'open',\n },\n ],\n };\n };\n\n const removeDrawerFromHistory = (\n state: DrawerNavigationState<ParamListBase>\n ): DrawerNavigationState<ParamListBase> => {\n if (!isDrawerInHistory(state)) {\n return state;\n }\n\n return {\n ...state,\n history: state.history.filter((it) => it.type !== 'drawer'),\n };\n };\n\n const openDrawer = (\n state: DrawerNavigationState<ParamListBase>\n ): DrawerNavigationState<ParamListBase> => {\n if (defaultStatus === 'open') {\n return removeDrawerFromHistory(state);\n }\n\n return addDrawerToHistory(state);\n };\n\n const closeDrawer = (\n state: DrawerNavigationState<ParamListBase>\n ): DrawerNavigationState<ParamListBase> => {\n if (defaultStatus === 'open') {\n return addDrawerToHistory(state);\n }\n\n return removeDrawerFromHistory(state);\n };\n\n return {\n ...router,\n\n type: 'drawer',\n\n getInitialState({ routeNames, routeParamList, routeGetIdList }) {\n const state = router.getInitialState({\n routeNames,\n routeParamList,\n routeGetIdList,\n });\n\n return {\n ...state,\n default: defaultStatus,\n stale: false,\n type: 'drawer',\n key: `drawer-${nanoid()}`,\n };\n },\n\n getRehydratedState(\n partialState,\n { routeNames, routeParamList, routeGetIdList }\n ) {\n if (partialState.stale === false) {\n return partialState;\n }\n\n let state = router.getRehydratedState(partialState, {\n routeNames,\n routeParamList,\n routeGetIdList,\n });\n\n if (isDrawerInHistory(partialState)) {\n // Re-sync the drawer entry in history to correct it if it was wrong\n state = removeDrawerFromHistory(state);\n state = addDrawerToHistory(state);\n }\n\n return {\n ...state,\n default: defaultStatus,\n type: 'drawer',\n key: `drawer-${nanoid()}`,\n };\n },\n\n getStateForRouteFocus(state, key) {\n const result = router.getStateForRouteFocus(state, key);\n\n return closeDrawer(result);\n },\n\n getStateForAction(state, action, options) {\n switch (action.type) {\n case 'OPEN_DRAWER':\n return openDrawer(state);\n\n case 'CLOSE_DRAWER':\n return closeDrawer(state);\n\n case 'TOGGLE_DRAWER':\n if (isDrawerInHistory(state)) {\n return removeDrawerFromHistory(state);\n }\n\n return addDrawerToHistory(state);\n\n case 'JUMP_TO':\n case 'NAVIGATE':\n case 'NAVIGATE_DEPRECATED': {\n const result = router.getStateForAction(state, action, options);\n\n if (result != null && result.index !== state.index) {\n return closeDrawer(result as DrawerNavigationState<ParamListBase>);\n }\n\n return result;\n }\n\n case 'GO_BACK':\n if (isDrawerInHistory(state)) {\n return removeDrawerFromHistory(state);\n }\n\n return router.getStateForAction(state, action, options);\n\n default:\n return router.getStateForAction(state, action, options);\n }\n },\n\n actionCreators: DrawerActions,\n };\n}\n"],"mappings":";;;;AAAA,SAASA,MAAM,QAAQ,mBAAmB;AAE1C,SAEEC,UAAU,EAGVC,SAAS;AA8DX,OAAO,MAAMC,aAAa,GAAAC,MAAA,CAAAC,MAAA,KACrBJ,UAAU;EACbK,UAAUA,CAAA,EAAG;IACX,OAAO;MAAEC,IAAI,EAAE;IAAc,CAAC;EAChC,CAAC;EACDC,WAAWA,CAAA,EAAG;IACZ,OAAO;MAAED,IAAI,EAAE;IAAe,CAAC;EACjC,CAAC;EACDE,YAAYA,CAAA,EAAG;IACb,OAAO;MAAEF,IAAI,EAAE;IAAgB,CAAC;EAClC;AAAA,EACD;AAED,OAAO,SAASG,YAAYA,CAAAC,IAAA,EAM1B;EAAA,IAN2B;MAC3BC,aAAa,GAAG;IAEG,CAAC,GAAAD,IAAA;IADjBE,IAAA,GAAAC,6BAAA,CAAAH,IAAA,EAAAI,SAAA;EAKH,MAAMC,MAAM,GAAGd,SAAS,CAACW,IAAI,CAG5B;EAED,MAAMI,iBAAiB,GACrBC,KAEsD,IACnDC,OAAO,CAACD,KAAK,CAACE,OAAO,EAAEC,IAAI,CAAEC,EAAE,IAAKA,EAAE,CAACf,IAAI,KAAK,QAAQ,CAAC,CAAC;E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