@g9tm/lynxcontrols 2.5.8 → 2.5.9

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.
@@ -1,4 +1,4 @@
1
- function g9ParsePath(href) {
1
+ function g9ParsePath(href, origin = '') {
2
2
  const at = href.indexOf('#');
3
3
  const hash = at >= 0 ? href.slice(at) : '';
4
4
  const beforeHash = at >= 0 ? href.slice(0, at) : href;
@@ -10,7 +10,8 @@ function g9ParsePath(href) {
10
10
  search,
11
11
  hash,
12
12
  href: `${pathname}${search}${hash}`,
13
- searchParams: new URLSearchParams(search)
13
+ searchParams: new URLSearchParams(search),
14
+ origin
14
15
  };
15
16
  }
16
17
  function g9CompilePattern(pattern) {
@@ -34,7 +35,7 @@ function g9CompilePattern(pattern) {
34
35
  };
35
36
  }
36
37
  function createG9PathRouter(options) {
37
- var _options_isWide, _options_history, _options_onChange;
38
+ var _options_isWide, _options_history, _options_onChange, _options_origin;
38
39
  const compiled = options.routes.map((def)=>({
39
40
  def,
40
41
  ...g9CompilePattern(def.pattern)
@@ -55,6 +56,7 @@ function createG9PathRouter(options) {
55
56
  version: 0,
56
57
  leaving: null
57
58
  };
59
+ let seeded = false;
58
60
  const set = (next)=>{
59
61
  state = {
60
62
  ...state,
@@ -68,8 +70,9 @@ function createG9PathRouter(options) {
68
70
  var _state_stack_;
69
71
  return null != (_state_stack_ = state.stack[state.stack.length - 1]) ? _state_stack_ : null;
70
72
  };
73
+ const origin = null != (_options_origin = options.origin) ? _options_origin : '';
71
74
  const match = (href)=>{
72
- const url = g9ParsePath(href);
75
+ const url = g9ParsePath(href, origin);
73
76
  for (const route of compiled){
74
77
  const found = route.regex.exec(url.pathname);
75
78
  if (!found) continue;
@@ -149,6 +152,27 @@ function createG9PathRouter(options) {
149
152
  url: next.url,
150
153
  params: next.params
151
154
  }, 'goto')) return false;
155
+ if (seeded) {
156
+ var _opts_state1;
157
+ seeded = false;
158
+ const first = top();
159
+ const entry = {
160
+ key: first.route === next.route ? 0 : ++entryKey,
161
+ url: next.url,
162
+ params: next.params,
163
+ route: next.route,
164
+ state: null != (_opts_state1 = opts.state) ? _opts_state1 : {}
165
+ };
166
+ null == history || history(next.url.href, true);
167
+ settle('goto', {
168
+ kind: 'none',
169
+ leaving: null,
170
+ stack: [
171
+ entry
172
+ ]
173
+ });
174
+ return true;
175
+ }
152
176
  const current = top();
153
177
  const existing = state.stack.findIndex((e)=>e.url.href === next.url.href);
154
178
  if (existing >= 0 && existing < state.stack.length - 1 && !opts.replaceState) {
@@ -272,7 +296,7 @@ function createG9PathRouter(options) {
272
296
  get url () {
273
297
  var _ref;
274
298
  var _top;
275
- return null != (_ref = null == (_top = top()) ? void 0 : _top.url) ? _ref : g9ParsePath('/');
299
+ return null != (_ref = null == (_top = top()) ? void 0 : _top.url) ? _ref : g9ParsePath('/', origin);
276
300
  },
277
301
  get params () {
278
302
  var _ref;
@@ -322,6 +346,24 @@ function createG9PathRouter(options) {
322
346
  }))
323
347
  })
324
348
  };
349
+ if (void 0 !== options.initialPath) {
350
+ const first = match(options.initialPath);
351
+ state = {
352
+ stack: [
353
+ {
354
+ key: 0,
355
+ url: first.url,
356
+ params: first.params,
357
+ route: first.route,
358
+ state: {}
359
+ }
360
+ ],
361
+ kind: 'none',
362
+ version: 0,
363
+ leaving: null
364
+ };
365
+ seeded = true;
366
+ }
325
367
  return router;
326
368
  }
327
369
  export { createG9PathRouter, g9CompilePattern, g9ParsePath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@g9tm/lynxcontrols",
3
- "version": "2.5.8",
3
+ "version": "2.5.9",
4
4
  "description": "ReactLynx controls and overlay infrastructure: provider/host, sheets, popups, toasts, fields, buttons, pickers, tab view, tab bar, edge panel, swipe rows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -234,7 +234,7 @@
234
234
  "build": "rslib build"
235
235
  },
236
236
  "dependencies": {
237
- "@g9tm/lynxcontrols-foundation": "2.5.8"
237
+ "@g9tm/lynxcontrols-foundation": "2.5.9"
238
238
  },
239
239
  "peerDependencies": {
240
240
  "@lynx-js/react": ">=0.129.3 <0.130.0",
@@ -8,8 +8,12 @@ Draws the router: the top page (and the one parked under it), or a list and its
8
8
 
9
9
  Props:
10
10
  - `router`: object
11
- - `renderPage?`: (entry, page, pane) => ReactNode
12
- - `leaveMs?`: number = 0
11
+ - `onMasterResize?`: (pattern: string, width: number) => void
12
+ - `renderPage?`: (entry, page, pane, motion) => ReactNode
13
+ - `leaveMs?`: number = "motionMs"
14
+ - `motion?`: 'none' | 'custom' | 'auto'
15
+ - `motionMs?`: number = 280
16
+ - `reducedMotion?`: boolean
13
17
  - `wide?`: boolean
14
18
 
15
19
  Example: `<G9PathNavigator router={router} />`