@amazon-devices/react-navigation__routers 7.0.9000000000 → 8.0.9000000000-rn-83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/SystemBundles/b6cc62e27d70be8722b0e7aef9fd04a870d49127e6c724fe934d1f8ca4ff8177.bundle +1298 -0
  2. package/SystemBundles/b6cc62e27d70be8722b0e7aef9fd04a870d49127e6c724fe934d1f8ca4ff8177.map +373 -0
  3. package/SystemModules/amzn__react-navigation__routers-8.modules.txt +9 -0
  4. package/SystemModules/amzn__react-navigation__routers-8.private.modules.txt +1 -0
  5. package/SystemModules/keplerscript-system-bundle-config.json +4 -4
  6. package/kepler-compatibility.json +2 -2
  7. package/lib/module/BaseRouter.js +6 -4
  8. package/lib/module/BaseRouter.js.map +1 -1
  9. package/lib/module/CommonActions.js +48 -7
  10. package/lib/module/CommonActions.js.map +1 -1
  11. package/lib/module/DrawerRouter.js +6 -6
  12. package/lib/module/DrawerRouter.js.map +1 -1
  13. package/lib/module/StackRouter.js +261 -80
  14. package/lib/module/StackRouter.js.map +1 -1
  15. package/lib/module/TabRouter.js +117 -34
  16. package/lib/module/TabRouter.js.map +1 -1
  17. package/lib/module/createParamsFromAction.js +16 -0
  18. package/lib/module/createParamsFromAction.js.map +1 -0
  19. package/lib/module/createRouteFromAction.js +21 -0
  20. package/lib/module/createRouteFromAction.js.map +1 -0
  21. package/lib/module/index.js +8 -6
  22. package/lib/module/index.js.map +1 -1
  23. package/lib/module/package.json +1 -0
  24. package/lib/module/types.js +2 -0
  25. package/lib/module/types.js.map +1 -1
  26. package/lib/typescript/package.json +1 -0
  27. package/lib/typescript/src/BaseRouter.d.ts +23 -20
  28. package/lib/typescript/src/BaseRouter.d.ts.map +1 -1
  29. package/lib/typescript/src/CommonActions.d.ts +66 -18
  30. package/lib/typescript/src/CommonActions.d.ts.map +1 -1
  31. package/lib/typescript/src/DrawerRouter.d.ts +18 -6
  32. package/lib/typescript/src/DrawerRouter.d.ts.map +1 -1
  33. package/lib/typescript/src/StackRouter.d.ts +73 -11
  34. package/lib/typescript/src/StackRouter.d.ts.map +1 -1
  35. package/lib/typescript/src/TabRouter.d.ts +24 -4
  36. package/lib/typescript/src/TabRouter.d.ts.map +1 -1
  37. package/lib/typescript/src/createParamsFromAction.d.ts +13 -0
  38. package/lib/typescript/src/createParamsFromAction.d.ts.map +1 -0
  39. package/lib/typescript/src/createRouteFromAction.d.ts +17 -0
  40. package/lib/typescript/src/createRouteFromAction.d.ts.map +1 -0
  41. package/lib/typescript/src/index.d.ts +4 -4
  42. package/lib/typescript/src/index.d.ts.map +1 -1
  43. package/lib/typescript/src/types.d.ts +1 -2
  44. package/lib/typescript/src/types.d.ts.map +1 -1
  45. package/oss-attribution/attribution.txt +0 -0
  46. package/oss-attribution/licenseInfos.json +1 -0
  47. package/package.json +80 -1
  48. package/src/BaseRouter.tsx +11 -6
  49. package/src/CommonActions.tsx +147 -56
  50. package/src/DrawerRouter.tsx +15 -13
  51. package/src/StackRouter.tsx +437 -199
  52. package/src/TabRouter.tsx +192 -53
  53. package/src/createParamsFromAction.tsx +22 -0
  54. package/src/createRouteFromAction.tsx +24 -0
  55. package/src/index.tsx +4 -4
  56. package/src/types.tsx +5 -5
  57. package/SystemBundles/b274ab157641de9520fe27a8e8049450e176a8ce2fedd3283fcb46c038bc6247.bundle +0 -3497
  58. package/SystemBundles/b274ab157641de9520fe27a8e8049450e176a8ce2fedd3283fcb46c038bc6247.map +0 -987
  59. package/SystemModules/amzn__react-navigation__routers-7.modules.txt +0 -21
  60. package/SystemModules/amzn__react-navigation__routers-7.private.modules.txt +0 -12
  61. package/THIRD_PARTY_NOTICES.txt +0 -24
  62. package/lib/commonjs/BaseRouter.js +0 -61
  63. package/lib/commonjs/BaseRouter.js.map +0 -1
  64. package/lib/commonjs/CommonActions.js +0 -53
  65. package/lib/commonjs/CommonActions.js.map +0 -1
  66. package/lib/commonjs/DrawerRouter.js +0 -154
  67. package/lib/commonjs/DrawerRouter.js.map +0 -1
  68. package/lib/commonjs/StackRouter.js +0 -310
  69. package/lib/commonjs/StackRouter.js.map +0 -1
  70. package/lib/commonjs/TabRouter.js +0 -253
  71. package/lib/commonjs/TabRouter.js.map +0 -1
  72. package/lib/commonjs/index.js +0 -80
  73. package/lib/commonjs/index.js.map +0 -1
  74. package/lib/commonjs/types.js +0 -6
  75. package/lib/commonjs/types.js.map +0 -1
@@ -1,21 +0,0 @@
1
- node_modules/@amzn/react-navigation__routers_7/lib/commonjs/BaseRouter.js:4e814a93075c75141026
2
- node_modules/@amzn/react-navigation__routers_7/lib/commonjs/CommonActions.js:6224880bf3a3483be0e5
3
- node_modules/@amzn/react-navigation__routers_7/lib/commonjs/DrawerRouter.js:fbd71b33b1fab08b6b66
4
- node_modules/@amzn/react-navigation__routers_7/lib/commonjs/TabRouter.js:c822e55e1302f6e881d8
5
- node_modules/@amzn/react-navigation__routers_7/lib/commonjs/StackRouter.js:536b900fdd2382601bd3
6
- node_modules/@amzn/react-navigation__routers_7/lib/commonjs/index.js:a0b9da8c3bf2cee70b92
7
- node_modules/@amzn/react-navigation__routers_7/lib/commonjs/types.js:76321e829a38224d0f30
8
- node_modules/@amzn/react-navigation__routers_7/lib/module/BaseRouter.js:b02ddfcf5d1b27936f8d
9
- node_modules/@amzn/react-navigation__routers_7/lib/module/CommonActions.js:6bfbc90eac4c2d2e67a4
10
- node_modules/@amzn/react-navigation__routers_7/lib/module/DrawerRouter.js:36b338faa6c2364d674f
11
- node_modules/@amzn/react-navigation__routers_7/lib/module/TabRouter.js:88d6ccdfe66b5db63cff
12
- node_modules/@amzn/react-navigation__routers_7/lib/module/StackRouter.js:1d666e2a5547a2fa33f1
13
- node_modules/@amzn/react-navigation__routers_7/lib/module/index.js:e045dec1c8244fccaf7b
14
- node_modules/@amzn/react-navigation__routers_7/lib/module/types.js:12c309785643d3823400
15
- node_modules/@amzn/react-navigation__routers_7/src/BaseRouter.tsx:cc50ab09498b013d1d6d
16
- node_modules/@amzn/react-navigation__routers_7/src/CommonActions.tsx:000944072e226c3923ad
17
- node_modules/@amzn/react-navigation__routers_7/src/DrawerRouter.tsx:a84ba97c7150cdcf5967
18
- node_modules/@amzn/react-navigation__routers_7/src/TabRouter.tsx:b409790239ad0cd46252
19
- node_modules/@amzn/react-navigation__routers_7/src/StackRouter.tsx:b83a4992ae2366e63a19
20
- node_modules/@amzn/react-navigation__routers_7/src/index.tsx:683d3e0e1152b4734793
21
- node_modules/@amzn/react-navigation__routers_7/src/types.tsx:2ad167c587979ba4fdb7
@@ -1,12 +0,0 @@
1
- node_modules/@react-native/js-polyfills_0.83.0/console.js:2d15cb9b42170067dfb8
2
- node_modules/@react-native/js-polyfills_0.83.0/error-guard.js:f1e83584808fa19b4c7a
3
- node_modules/nanoid_3.1.23/non-secure/index.js:e03db9aacb1ee503cd26
4
- node_modules/@babel/runtime_7.28.4/helpers/objectWithoutProperties.js:a2c8e692f78bae5b8b98
5
- node_modules/@babel/runtime_7.28.4/helpers/objectWithoutPropertiesLoose.js:5927789db7c756c318ed
6
- node_modules/@babel/runtime_7.28.4/helpers/toConsumableArray.js:838d7a057beeb5db50df
7
- node_modules/@babel/runtime_7.28.4/helpers/arrayWithoutHoles.js:a425fd4fe3cf47759e99
8
- node_modules/@babel/runtime_7.28.4/helpers/arrayLikeToArray.js:378be3062418cfac9327
9
- node_modules/@babel/runtime_7.28.4/helpers/iterableToArray.js:67d028b72bb61755baea
10
- node_modules/@babel/runtime_7.28.4/helpers/unsupportedIterableToArray.js:e7044bb724c5bd68e2cc
11
- node_modules/@babel/runtime_7.28.4/helpers/nonIterableSpread.js:b4810fa44dd496b7d9f5
12
- node_modules/@babel/runtime_7.28.4/helpers/interopRequireDefault.js:277a84013d7e1a1ace05
@@ -1,24 +0,0 @@
1
- License from LICENSE:
2
- ========================================
3
-
4
- MIT License
5
-
6
- Copyright (c) 2017 React Navigation Contributors
7
-
8
- Permission is hereby granted, free of charge, to any person obtaining a copy
9
- of this software and associated documentation files (the "Software"), to deal
10
- in the Software without restriction, including without limitation the rights
11
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
- copies of the Software, and to permit persons to whom the Software is
13
- furnished to do so, subject to the following conditions:
14
-
15
- The above copyright notice and this permission notice shall be included in all
16
- copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
- SOFTWARE.
@@ -1,61 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _nonSecure = require("nanoid/non-secure");
8
- /**
9
- * Base router object that can be used when writing custom routers.
10
- * This provides few helper methods to handle common actions such as `RESET`.
11
- */
12
- const BaseRouter = {
13
- getStateForAction(state, action) {
14
- switch (action.type) {
15
- case 'SET_PARAMS':
16
- {
17
- const index = action.source ? state.routes.findIndex(r => r.key === action.source) : state.index;
18
- if (index === -1) {
19
- return null;
20
- }
21
- return {
22
- ...state,
23
- routes: state.routes.map((r, i) => i === index ? {
24
- ...r,
25
- params: {
26
- ...r.params,
27
- ...action.payload.params
28
- }
29
- } : r)
30
- };
31
- }
32
- case 'RESET':
33
- {
34
- const nextState = action.payload;
35
- if (nextState.routes.length === 0 || nextState.routes.some(route => !state.routeNames.includes(route.name))) {
36
- return null;
37
- }
38
- if (nextState.stale === false) {
39
- if (state.routeNames.length !== nextState.routeNames.length || nextState.routeNames.some(name => !state.routeNames.includes(name))) {
40
- return null;
41
- }
42
- return {
43
- ...nextState,
44
- routes: nextState.routes.map(route => route.key ? route : {
45
- ...route,
46
- key: `${route.name}-${(0, _nonSecure.nanoid)()}`
47
- })
48
- };
49
- }
50
- return nextState;
51
- }
52
- default:
53
- return null;
54
- }
55
- },
56
- shouldActionChangeFocus(action) {
57
- return action.type === 'NAVIGATE';
58
- }
59
- };
60
- var _default = exports.default = BaseRouter;
61
- //# sourceMappingURL=BaseRouter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_nonSecure","require","BaseRouter","getStateForAction","state","action","type","index","source","routes","findIndex","r","key","map","i","params","payload","nextState","length","some","route","routeNames","includes","name","stale","nanoid","shouldActionChangeFocus","_default","exports","default"],"sourceRoot":"../../src","sources":["BaseRouter.tsx"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAQA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAG;EACjBC,iBAAiBA,CACfC,KAAY,EACZC,MAA8B,EACM;IACpC,QAAQA,MAAM,CAACC,IAAI;MACjB,KAAK,YAAY;QAAE;UACjB,MAAMC,KAAK,GAAGF,MAAM,CAACG,MAAM,GACvBJ,KAAK,CAACK,MAAM,CAACC,SAAS,CAAEC,CAAC,IAAKA,CAAC,CAACC,GAAG,KAAKP,MAAM,CAACG,MAAM,CAAC,GACtDJ,KAAK,CAACG,KAAK;UAEf,IAAIA,KAAK,KAAK,CAAC,CAAC,EAAE;YAChB,OAAO,IAAI;UACb;UAEA,OAAO;YACL,GAAGH,KAAK;YACRK,MAAM,EAAEL,KAAK,CAACK,MAAM,CAACI,GAAG,CAAC,CAACF,CAAC,EAAEG,CAAC,KAC5BA,CAAC,KAAKP,KAAK,GACP;cAAE,GAAGI,CAAC;cAAEI,MAAM,EAAE;gBAAE,GAAGJ,CAAC,CAACI,MAAM;gBAAE,GAAGV,MAAM,CAACW,OAAO,CAACD;cAAO;YAAE,CAAC,GAC3DJ,CACN;UACF,CAAC;QACH;MAEA,KAAK,OAAO;QAAE;UACZ,MAAMM,SAAS,GAAGZ,MAAM,CAACW,OAAsC;UAE/D,IACEC,SAAS,CAACR,MAAM,CAACS,MAAM,KAAK,CAAC,IAC7BD,SAAS,CAACR,MAAM,CAACU,IAAI,CAClBC,KAAuB,IAAK,CAAChB,KAAK,CAACiB,UAAU,CAACC,QAAQ,CAACF,KAAK,CAACG,IAAI,CACpE,CAAC,EACD;YACA,OAAO,IAAI;UACb;UAEA,IAAIN,SAAS,CAACO,KAAK,KAAK,KAAK,EAAE;YAC7B,IACEpB,KAAK,CAACiB,UAAU,CAACH,MAAM,KAAKD,SAAS,CAACI,UAAU,CAACH,MAAM,IACvDD,SAAS,CAACI,UAAU,CAACF,IAAI,CACtBI,IAAI,IAAK,CAACnB,KAAK,CAACiB,UAAU,CAACC,QAAQ,CAACC,IAAI,CAC3C,CAAC,EACD;cACA,OAAO,IAAI;YACb;YAEA,OAAO;cACL,GAAGN,SAAS;cACZR,MAAM,EAAEQ,SAAS,CAACR,MAAM,CAACI,GAAG,CAAEO,KAAK,IACjCA,KAAK,CAACR,GAAG,GAAGQ,KAAK,GAAG;gBAAE,GAAGA,KAAK;gBAAER,GAAG,EAAE,GAAGQ,KAAK,CAACG,IAAI,IAAI,IAAAE,iBAAM,EAAC,CAAC;cAAG,CACnE;YACF,CAAC;UACH;UAEA,OAAOR,SAAS;QAClB;MAEA;QACE,OAAO,IAAI;IACf;EACF,CAAC;EAEDS,uBAAuBA,CAACrB,MAA8B,EAAE;IACtD,OAAOA,MAAM,CAACC,IAAI,KAAK,UAAU;EACnC;AACF,CAAC;AAAC,IAAAqB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa3B,UAAU","ignoreList":[]}
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.goBack = goBack;
7
- exports.navigate = navigate;
8
- exports.reset = reset;
9
- exports.setParams = setParams;
10
- function goBack() {
11
- return {
12
- type: 'GO_BACK'
13
- };
14
- }
15
-
16
- // eslint-disable-next-line no-redeclare
17
-
18
- // eslint-disable-next-line no-redeclare
19
- function navigate(...args) {
20
- if (typeof args[0] === 'string') {
21
- return {
22
- type: 'NAVIGATE',
23
- payload: {
24
- name: args[0],
25
- params: args[1]
26
- }
27
- };
28
- } else {
29
- const payload = args[0] || {};
30
- if (!payload.hasOwnProperty('key') && !payload.hasOwnProperty('name')) {
31
- throw new Error('You need to specify name or key when calling navigate with an object as the argument. See https://reactnavigation.org/docs/navigation-actions#navigate for usage.');
32
- }
33
- return {
34
- type: 'NAVIGATE',
35
- payload
36
- };
37
- }
38
- }
39
- function reset(state) {
40
- return {
41
- type: 'RESET',
42
- payload: state
43
- };
44
- }
45
- function setParams(params) {
46
- return {
47
- type: 'SET_PARAMS',
48
- payload: {
49
- params
50
- }
51
- };
52
- }
53
- //# sourceMappingURL=CommonActions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["goBack","type","navigate","args","payload","name","params","hasOwnProperty","Error","reset","state","setParams"],"sourceRoot":"../../src","sources":["CommonActions.tsx"],"mappings":";;;;;;;;;AAgDO,SAASA,MAAMA,CAAA,EAAW;EAC/B,OAAO;IAAEC,IAAI,EAAE;EAAU,CAAC;AAC5B;;AAaA;;AAEA;AACO,SAASC,QAAQA,CAAC,GAAGC,IAAS,EAAU;EAC7C,IAAI,OAAOA,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;IAC/B,OAAO;MAAEF,IAAI,EAAE,UAAU;MAAEG,OAAO,EAAE;QAAEC,IAAI,EAAEF,IAAI,CAAC,CAAC,CAAC;QAAEG,MAAM,EAAEH,IAAI,CAAC,CAAC;MAAE;IAAE,CAAC;EAC1E,CAAC,MAAM;IACL,MAAMC,OAAO,GAAGD,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAE7B,IAAI,CAACC,OAAO,CAACG,cAAc,CAAC,KAAK,CAAC,IAAI,CAACH,OAAO,CAACG,cAAc,CAAC,MAAM,CAAC,EAAE;MACrE,MAAM,IAAIC,KAAK,CACb,mKACF,CAAC;IACH;IAEA,OAAO;MAAEP,IAAI,EAAE,UAAU;MAAEG;IAAQ,CAAC;EACtC;AACF;AAEO,SAASK,KAAKA,CAACC,KAA6B,EAAU;EAC3D,OAAO;IAAET,IAAI,EAAE,OAAO;IAAEG,OAAO,EAAEM;EAAM,CAAC;AAC1C;AAEO,SAASC,SAASA,CAACL,MAAc,EAAU;EAChD,OAAO;IAAEL,IAAI,EAAE,YAAY;IAAEG,OAAO,EAAE;MAAEE;IAAO;EAAE,CAAC;AACpD","ignoreList":[]}
@@ -1,154 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DrawerActions = void 0;
7
- exports.default = DrawerRouter;
8
- var _nonSecure = require("nanoid/non-secure");
9
- var _TabRouter = _interopRequireWildcard(require("./TabRouter"));
10
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
- const DrawerActions = exports.DrawerActions = {
13
- ..._TabRouter.TabActions,
14
- openDrawer() {
15
- return {
16
- type: 'OPEN_DRAWER'
17
- };
18
- },
19
- closeDrawer() {
20
- return {
21
- type: 'CLOSE_DRAWER'
22
- };
23
- },
24
- toggleDrawer() {
25
- return {
26
- type: 'TOGGLE_DRAWER'
27
- };
28
- }
29
- };
30
- function DrawerRouter({
31
- defaultStatus = 'closed',
32
- ...rest
33
- }) {
34
- const router = (0, _TabRouter.default)(rest);
35
- const isDrawerInHistory = state => {
36
- var _state$history;
37
- return Boolean((_state$history = state.history) === null || _state$history === void 0 ? void 0 : _state$history.some(it => it.type === 'drawer'));
38
- };
39
- const addDrawerToHistory = state => {
40
- if (isDrawerInHistory(state)) {
41
- return state;
42
- }
43
- return {
44
- ...state,
45
- history: [...state.history, {
46
- type: 'drawer',
47
- status: defaultStatus === 'open' ? 'closed' : 'open'
48
- }]
49
- };
50
- };
51
- const removeDrawerFromHistory = state => {
52
- if (!isDrawerInHistory(state)) {
53
- return state;
54
- }
55
- return {
56
- ...state,
57
- history: state.history.filter(it => it.type !== 'drawer')
58
- };
59
- };
60
- const openDrawer = state => {
61
- if (defaultStatus === 'open') {
62
- return removeDrawerFromHistory(state);
63
- }
64
- return addDrawerToHistory(state);
65
- };
66
- const closeDrawer = state => {
67
- if (defaultStatus === 'open') {
68
- return addDrawerToHistory(state);
69
- }
70
- return removeDrawerFromHistory(state);
71
- };
72
- return {
73
- ...router,
74
- type: 'drawer',
75
- getInitialState({
76
- routeNames,
77
- routeParamList,
78
- routeGetIdList
79
- }) {
80
- const state = router.getInitialState({
81
- routeNames,
82
- routeParamList,
83
- routeGetIdList
84
- });
85
- return {
86
- ...state,
87
- default: defaultStatus,
88
- stale: false,
89
- type: 'drawer',
90
- key: `drawer-${(0, _nonSecure.nanoid)()}`
91
- };
92
- },
93
- getRehydratedState(partialState, {
94
- routeNames,
95
- routeParamList,
96
- routeGetIdList
97
- }) {
98
- if (partialState.stale === false) {
99
- return partialState;
100
- }
101
- let state = router.getRehydratedState(partialState, {
102
- routeNames,
103
- routeParamList,
104
- routeGetIdList
105
- });
106
- if (isDrawerInHistory(partialState)) {
107
- // Re-sync the drawer entry in history to correct it if it was wrong
108
- state = removeDrawerFromHistory(state);
109
- state = addDrawerToHistory(state);
110
- }
111
- return {
112
- ...state,
113
- default: defaultStatus,
114
- type: 'drawer',
115
- key: `drawer-${(0, _nonSecure.nanoid)()}`
116
- };
117
- },
118
- getStateForRouteFocus(state, key) {
119
- const result = router.getStateForRouteFocus(state, key);
120
- return closeDrawer(result);
121
- },
122
- getStateForAction(state, action, options) {
123
- switch (action.type) {
124
- case 'OPEN_DRAWER':
125
- return openDrawer(state);
126
- case 'CLOSE_DRAWER':
127
- return closeDrawer(state);
128
- case 'TOGGLE_DRAWER':
129
- if (isDrawerInHistory(state)) {
130
- return removeDrawerFromHistory(state);
131
- }
132
- return addDrawerToHistory(state);
133
- case 'JUMP_TO':
134
- case 'NAVIGATE':
135
- {
136
- const result = router.getStateForAction(state, action, options);
137
- if (result != null && result.index !== state.index) {
138
- return closeDrawer(result);
139
- }
140
- return result;
141
- }
142
- case 'GO_BACK':
143
- if (isDrawerInHistory(state)) {
144
- return removeDrawerFromHistory(state);
145
- }
146
- return router.getStateForAction(state, action, options);
147
- default:
148
- return router.getStateForAction(state, action, options);
149
- }
150
- },
151
- actionCreators: DrawerActions
152
- };
153
- }
154
- //# sourceMappingURL=DrawerRouter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_nonSecure","require","_TabRouter","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DrawerActions","exports","TabActions","openDrawer","type","closeDrawer","toggleDrawer","DrawerRouter","defaultStatus","rest","router","TabRouter","isDrawerInHistory","state","_state$history","Boolean","history","some","it","addDrawerToHistory","status","removeDrawerFromHistory","filter","getInitialState","routeNames","routeParamList","routeGetIdList","stale","key","nanoid","getRehydratedState","partialState","getStateForRouteFocus","result","getStateForAction","action","options","index","actionCreators"],"sourceRoot":"../../src","sources":["DrawerRouter.tsx"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAC,uBAA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@ -1,310 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.StackActions = void 0;
7
- exports.default = StackRouter;
8
- var _nonSecure = require("nanoid/non-secure");
9
- var _BaseRouter = _interopRequireDefault(require("./BaseRouter"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- const StackActions = exports.StackActions = {
12
- replace(name, params) {
13
- return {
14
- type: 'REPLACE',
15
- payload: {
16
- name,
17
- params
18
- }
19
- };
20
- },
21
- push(name, params) {
22
- return {
23
- type: 'PUSH',
24
- payload: {
25
- name,
26
- params
27
- }
28
- };
29
- },
30
- pop(count = 1) {
31
- return {
32
- type: 'POP',
33
- payload: {
34
- count
35
- }
36
- };
37
- },
38
- popToTop() {
39
- return {
40
- type: 'POP_TO_TOP'
41
- };
42
- }
43
- };
44
- function StackRouter(options) {
45
- const router = {
46
- ..._BaseRouter.default,
47
- type: 'stack',
48
- getInitialState({
49
- routeNames,
50
- routeParamList
51
- }) {
52
- const initialRouteName = options.initialRouteName !== undefined && routeNames.includes(options.initialRouteName) ? options.initialRouteName : routeNames[0];
53
- return {
54
- stale: false,
55
- type: 'stack',
56
- key: `stack-${(0, _nonSecure.nanoid)()}`,
57
- index: 0,
58
- routeNames,
59
- routes: [{
60
- key: `${initialRouteName}-${(0, _nonSecure.nanoid)()}`,
61
- name: initialRouteName,
62
- params: routeParamList[initialRouteName]
63
- }]
64
- };
65
- },
66
- getRehydratedState(partialState, {
67
- routeNames,
68
- routeParamList
69
- }) {
70
- let state = partialState;
71
- if (state.stale === false) {
72
- return state;
73
- }
74
- const routes = state.routes.filter(route => routeNames.includes(route.name)).map(route => ({
75
- ...route,
76
- key: route.key || `${route.name}-${(0, _nonSecure.nanoid)()}`,
77
- params: routeParamList[route.name] !== undefined ? {
78
- ...routeParamList[route.name],
79
- ...route.params
80
- } : route.params
81
- }));
82
- if (routes.length === 0) {
83
- const initialRouteName = options.initialRouteName !== undefined ? options.initialRouteName : routeNames[0];
84
- routes.push({
85
- key: `${initialRouteName}-${(0, _nonSecure.nanoid)()}`,
86
- name: initialRouteName,
87
- params: routeParamList[initialRouteName]
88
- });
89
- }
90
- return {
91
- stale: false,
92
- type: 'stack',
93
- key: `stack-${(0, _nonSecure.nanoid)()}`,
94
- index: routes.length - 1,
95
- routeNames,
96
- routes
97
- };
98
- },
99
- getStateForRouteNamesChange(state, {
100
- routeNames,
101
- routeParamList,
102
- routeKeyChanges
103
- }) {
104
- const routes = state.routes.filter(route => routeNames.includes(route.name) && !routeKeyChanges.includes(route.name));
105
- if (routes.length === 0) {
106
- const initialRouteName = options.initialRouteName !== undefined && routeNames.includes(options.initialRouteName) ? options.initialRouteName : routeNames[0];
107
- routes.push({
108
- key: `${initialRouteName}-${(0, _nonSecure.nanoid)()}`,
109
- name: initialRouteName,
110
- params: routeParamList[initialRouteName]
111
- });
112
- }
113
- return {
114
- ...state,
115
- routeNames,
116
- routes,
117
- index: Math.min(state.index, routes.length - 1)
118
- };
119
- },
120
- getStateForRouteFocus(state, key) {
121
- const index = state.routes.findIndex(r => r.key === key);
122
- if (index === -1 || index === state.index) {
123
- return state;
124
- }
125
- return {
126
- ...state,
127
- index,
128
- routes: state.routes.slice(0, index + 1)
129
- };
130
- },
131
- getStateForAction(state, action, options) {
132
- const {
133
- routeParamList
134
- } = options;
135
- switch (action.type) {
136
- case 'REPLACE':
137
- {
138
- const index = action.target === state.key && action.source ? state.routes.findIndex(r => r.key === action.source) : state.index;
139
- if (index === -1) {
140
- return null;
141
- }
142
- const {
143
- name,
144
- key,
145
- params
146
- } = action.payload;
147
- if (!state.routeNames.includes(name)) {
148
- return null;
149
- }
150
- return {
151
- ...state,
152
- routes: state.routes.map((route, i) => i === index ? {
153
- key: key !== undefined ? key : `${name}-${(0, _nonSecure.nanoid)()}`,
154
- name,
155
- params: routeParamList[name] !== undefined ? {
156
- ...routeParamList[name],
157
- ...params
158
- } : params
159
- } : route)
160
- };
161
- }
162
- case 'PUSH':
163
- if (state.routeNames.includes(action.payload.name)) {
164
- const getId = options.routeGetIdList[action.payload.name];
165
- const id = getId === null || getId === void 0 ? void 0 : getId({
166
- params: action.payload.params
167
- });
168
- const route = id ? state.routes.find(route => route.name === action.payload.name && id === (getId === null || getId === void 0 ? void 0 : getId({
169
- params: route.params
170
- }))) : undefined;
171
- let routes;
172
- if (route) {
173
- routes = state.routes.filter(r => r.key !== route.key);
174
- routes.push({
175
- ...route,
176
- params: routeParamList[action.payload.name] !== undefined ? {
177
- ...routeParamList[action.payload.name],
178
- ...action.payload.params
179
- } : action.payload.params
180
- });
181
- } else {
182
- routes = [...state.routes, {
183
- key: `${action.payload.name}-${(0, _nonSecure.nanoid)()}`,
184
- name: action.payload.name,
185
- params: routeParamList[action.payload.name] !== undefined ? {
186
- ...routeParamList[action.payload.name],
187
- ...action.payload.params
188
- } : action.payload.params
189
- }];
190
- }
191
- return {
192
- ...state,
193
- index: routes.length - 1,
194
- routes
195
- };
196
- }
197
- return null;
198
- case 'POP':
199
- {
200
- const index = action.target === state.key && action.source ? state.routes.findIndex(r => r.key === action.source) : state.index;
201
- if (index > 0) {
202
- const count = Math.max(index - action.payload.count + 1, 1);
203
- const routes = state.routes.slice(0, count).concat(state.routes.slice(index + 1));
204
- return {
205
- ...state,
206
- index: routes.length - 1,
207
- routes
208
- };
209
- }
210
- return null;
211
- }
212
- case 'POP_TO_TOP':
213
- return router.getStateForAction(state, {
214
- type: 'POP',
215
- payload: {
216
- count: state.routes.length - 1
217
- }
218
- }, options);
219
- case 'NAVIGATE':
220
- if (action.payload.name !== undefined && !state.routeNames.includes(action.payload.name)) {
221
- return null;
222
- }
223
- if (action.payload.key || action.payload.name) {
224
- // If the route already exists, navigate to that
225
- let index = -1;
226
- const getId =
227
- // `getId` and `key` can't be used together
228
- action.payload.key === undefined && action.payload.name !== undefined ? options.routeGetIdList[action.payload.name] : undefined;
229
- const id = getId === null || getId === void 0 ? void 0 : getId({
230
- params: action.payload.params
231
- });
232
- if (id) {
233
- index = state.routes.findIndex(route => route.name === action.payload.name && id === (getId === null || getId === void 0 ? void 0 : getId({
234
- params: route.params
235
- })));
236
- } else if (state.routes[state.index].name === action.payload.name && action.payload.key === undefined || state.routes[state.index].key === action.payload.key) {
237
- index = state.index;
238
- } else {
239
- for (let i = state.routes.length - 1; i >= 0; i--) {
240
- if (state.routes[i].name === action.payload.name && action.payload.key === undefined || state.routes[i].key === action.payload.key) {
241
- index = i;
242
- break;
243
- }
244
- }
245
- }
246
- if (index === -1 && action.payload.key && action.payload.name === undefined) {
247
- return null;
248
- }
249
- if (index === -1 && action.payload.name !== undefined) {
250
- const routes = [...state.routes, {
251
- key: action.payload.key ?? `${action.payload.name}-${(0, _nonSecure.nanoid)()}`,
252
- name: action.payload.name,
253
- path: action.payload.path,
254
- params: routeParamList[action.payload.name] !== undefined ? {
255
- ...routeParamList[action.payload.name],
256
- ...action.payload.params
257
- } : action.payload.params
258
- }];
259
- return {
260
- ...state,
261
- routes,
262
- index: routes.length - 1
263
- };
264
- }
265
- const route = state.routes[index];
266
- let params;
267
- if (action.payload.merge) {
268
- params = action.payload.params !== undefined || routeParamList[route.name] !== undefined ? {
269
- ...routeParamList[route.name],
270
- ...route.params,
271
- ...action.payload.params
272
- } : route.params;
273
- } else {
274
- params = routeParamList[route.name] !== undefined ? {
275
- ...routeParamList[route.name],
276
- ...action.payload.params
277
- } : action.payload.params;
278
- }
279
- return {
280
- ...state,
281
- index,
282
- routes: [...state.routes.slice(0, index), params !== route.params || action.payload.path && action.payload.path !== route.path ? {
283
- ...route,
284
- path: action.payload.path ?? route.path,
285
- params
286
- } : state.routes[index]]
287
- };
288
- }
289
- return null;
290
- case 'GO_BACK':
291
- if (state.index > 0) {
292
- return router.getStateForAction(state, {
293
- type: 'POP',
294
- payload: {
295
- count: 1
296
- },
297
- target: action.target,
298
- source: action.source
299
- }, options);
300
- }
301
- return null;
302
- default:
303
- return _BaseRouter.default.getStateForAction(state, action);
304
- }
305
- },
306
- actionCreators: StackActions
307
- };
308
- return router;
309
- }
310
- //# sourceMappingURL=StackRouter.js.map