@jsenv/navi 0.29.218 → 0.29.220
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.
- package/dist/dev/jsenv_navi.js +56 -13
- package/dist/dev/jsenv_navi.js.map +7 -7
- package/dist/jsenv_navi.js +56 -13
- package/dist/jsenv_navi.js.map +7 -7
- package/docs/actions.md +11 -0
- package/docs/navigation.md +6 -3
- package/docs/popup_open.md +40 -0
- package/package.json +1 -1
package/dist/dev/jsenv_navi.js
CHANGED
|
@@ -45591,16 +45591,23 @@ const writeInSignal = (signal, value, { history }) => {
|
|
|
45591
45591
|
// those writes: they are spelled into the url first (only the signal knows
|
|
45592
45592
|
// how "closed" reads there), and that url is written onto the entry the back
|
|
45593
45593
|
// lands on.
|
|
45594
|
-
|
|
45595
|
-
|
|
45594
|
+
//
|
|
45595
|
+
// What "open" is worth in the signal is `true`, or the popup's `value`
|
|
45596
|
+
// when it has one: several popups then share one signal saying WHICH of them
|
|
45597
|
+
// is open (`?seat=<gameId>` over a list of cards), and closed is the signal
|
|
45598
|
+
// holding none of their values — `undefined`, which a state signal reads as
|
|
45599
|
+
// its default.
|
|
45600
|
+
const writeOpenedInSignal = (signal, opened, event, popupValue) => {
|
|
45601
|
+
if (readOpened(signal.peek(), popupValue) === opened) {
|
|
45596
45602
|
// The signal already says so, meaning this open/close IS what it asked
|
|
45597
45603
|
// for: a back press that took the popup out of the url, the application
|
|
45598
45604
|
// writing it. Nothing to write back — and nothing to go back to either,
|
|
45599
45605
|
// since the navigation navBack would undo is the one that asked for this.
|
|
45600
45606
|
return;
|
|
45601
45607
|
}
|
|
45608
|
+
const closedValue = popupValue === undefined ? false : undefined;
|
|
45602
45609
|
if (opened) {
|
|
45603
|
-
signal.value = true;
|
|
45610
|
+
signal.value = popupValue === undefined ? true : popupValue;
|
|
45604
45611
|
return;
|
|
45605
45612
|
}
|
|
45606
45613
|
if (
|
|
@@ -45615,11 +45622,17 @@ const writeOpenedInSignal = (signal, opened, event) => {
|
|
|
45615
45622
|
navBack();
|
|
45616
45623
|
return;
|
|
45617
45624
|
}
|
|
45618
|
-
writeInSignal(signal,
|
|
45625
|
+
writeInSignal(signal, closedValue, { history: "replace" });
|
|
45619
45626
|
navBack({ landOn: { url: window.location.href } });
|
|
45620
45627
|
return;
|
|
45621
45628
|
}
|
|
45622
|
-
writeInSignal(signal,
|
|
45629
|
+
writeInSignal(signal, closedValue, { history: "replace" });
|
|
45630
|
+
};
|
|
45631
|
+
const readOpened = (signalValue, popupValue) => {
|
|
45632
|
+
if (popupValue === undefined) {
|
|
45633
|
+
return signalValue;
|
|
45634
|
+
}
|
|
45635
|
+
return signalValue === popupValue;
|
|
45623
45636
|
};
|
|
45624
45637
|
|
|
45625
45638
|
/**
|
|
@@ -45634,7 +45647,7 @@ const writeOpenedInSignal = (signal, opened, event) => {
|
|
|
45634
45647
|
* `expandable.jsx` (open in flow rather than on a layer, same decision).
|
|
45635
45648
|
*
|
|
45636
45649
|
* @param {{ open: (e: Event, detail?: object) => void, requestClose: (e: Event, detail?: object) => void, opened: boolean }} openController
|
|
45637
|
-
* @param {{ id?: string, open?: boolean|"interaction", defaultOpen?: boolean|"interaction", signal?: import("@preact/signals").Signal
|
|
45650
|
+
* @param {{ id?: string, open?: boolean|"interaction", defaultOpen?: boolean|"interaction", signal?: import("@preact/signals").Signal, value?: any, navState?: boolean|string|{id?: string, type?: "push"|"replace"} }} props
|
|
45638
45651
|
* @param {string} [name] What the dev warnings call the thing being opened.
|
|
45639
45652
|
*/
|
|
45640
45653
|
const useOpenPropsEffectOnOpenController = (
|
|
@@ -45642,7 +45655,7 @@ const useOpenPropsEffectOnOpenController = (
|
|
|
45642
45655
|
props,
|
|
45643
45656
|
name = "popup",
|
|
45644
45657
|
) => {
|
|
45645
|
-
const { signal, defaultOpen, navState } = props;
|
|
45658
|
+
const { signal, value, defaultOpen, navState } = props;
|
|
45646
45659
|
const { id: navStateId, type: navStateType } = resolveNavStateProp(
|
|
45647
45660
|
navState,
|
|
45648
45661
|
props.id,
|
|
@@ -45672,7 +45685,7 @@ const useOpenPropsEffectOnOpenController = (
|
|
|
45672
45685
|
const open = navStateId
|
|
45673
45686
|
? Boolean(navStateValue)
|
|
45674
45687
|
: signal
|
|
45675
|
-
? signal.value
|
|
45688
|
+
? readOpened(signal.value, value)
|
|
45676
45689
|
: props.open;
|
|
45677
45690
|
// Assigned on every render, like openEffect, so it always closes over the
|
|
45678
45691
|
// latest prop: a popup that opens or closes on its own (Escape, backdrop, a
|
|
@@ -45692,7 +45705,7 @@ const useOpenPropsEffectOnOpenController = (
|
|
|
45692
45705
|
}
|
|
45693
45706
|
}
|
|
45694
45707
|
if (signal) {
|
|
45695
|
-
writeOpenedInSignal(signal, opened, event);
|
|
45708
|
+
writeOpenedInSignal(signal, opened, event, value);
|
|
45696
45709
|
}
|
|
45697
45710
|
}
|
|
45698
45711
|
: null;
|
|
@@ -45750,9 +45763,16 @@ const useOpenPropsEffectOnOpenController = (
|
|
|
45750
45763
|
// then stays where it was, and whoever holds the open state is told so —
|
|
45751
45764
|
// otherwise it would keep saying "closed" about a popup still open.
|
|
45752
45765
|
// Written over rather than stacked on: a refusal corrects the state that
|
|
45753
|
-
// asked, it is not a place one came from.
|
|
45754
|
-
|
|
45755
|
-
|
|
45766
|
+
// asked, it is not a place one came from. Only on a refusal: an accepted
|
|
45767
|
+
// request already reads in the signal, and with a `value` what the
|
|
45768
|
+
// signal holds may be another popup's, which the write would erase.
|
|
45769
|
+
if (signal && openController.opened !== open) {
|
|
45770
|
+
const opened = openController.opened;
|
|
45771
|
+
writeInSignal(
|
|
45772
|
+
signal,
|
|
45773
|
+
value === undefined ? opened : opened ? value : undefined,
|
|
45774
|
+
{ history: "replace" },
|
|
45775
|
+
);
|
|
45756
45776
|
}
|
|
45757
45777
|
if (navStateId && openController.opened) {
|
|
45758
45778
|
enterNavState();
|
|
@@ -46650,7 +46670,8 @@ const useExpandableContext = partName => {
|
|
|
46650
46670
|
* ui?: import("ignore:preact").ComponentChildren | ((state: { open: boolean }) => import("ignore:preact").ComponentChildren),
|
|
46651
46671
|
* open?: boolean,
|
|
46652
46672
|
* defaultOpen?: boolean,
|
|
46653
|
-
* signal?: import("@preact/signals").Signal
|
|
46673
|
+
* signal?: import("@preact/signals").Signal,
|
|
46674
|
+
* value?: any,
|
|
46654
46675
|
* navState?: boolean | string | { id?: string, type?: "push" | "replace" },
|
|
46655
46676
|
* onClose?: (event: Event) => void,
|
|
46656
46677
|
* onToggle?: (event: Event) => void,
|
|
@@ -46679,6 +46700,10 @@ const useExpandableContext = partName => {
|
|
|
46679
46700
|
* @param defaultOpen - Uncontrolled, mount-only initial state.
|
|
46680
46701
|
* @param signal - Two-way binding: the expandable follows the signal and
|
|
46681
46702
|
* writes back into it whenever it toggles on its own. Excludes `open`.
|
|
46703
|
+
* @param value - What `signal` holds while THIS expandable is open, for
|
|
46704
|
+
* several sharing one signal that says which is open (an accordion): open
|
|
46705
|
+
* while `signal.value` is this value, closed otherwise; opening writes it,
|
|
46706
|
+
* closing writes `undefined`. Without it the signal holds a boolean.
|
|
46682
46707
|
* @param navState - Keeps the open state in the history entry, so a screen
|
|
46683
46708
|
* left and come back to finds its sections as they were: `true` uses the
|
|
46684
46709
|
* expandable's own `id`, a string names the key, `{ id, type }` chooses
|
|
@@ -46739,6 +46764,7 @@ const Expandable = props => {
|
|
|
46739
46764
|
open,
|
|
46740
46765
|
defaultOpen,
|
|
46741
46766
|
signal,
|
|
46767
|
+
value,
|
|
46742
46768
|
navState,
|
|
46743
46769
|
onClose,
|
|
46744
46770
|
action,
|
|
@@ -58619,6 +58645,11 @@ const css$E = /* css */`
|
|
|
58619
58645
|
* Excludes `open`; `onOpen`/`onClose` still fire. A signal holding `true` at
|
|
58620
58646
|
* mount behaves like `defaultOpen`: the dialog was already open, no entrance
|
|
58621
58647
|
* plays.
|
|
58648
|
+
* @param {any} [props.value] - What `signal` holds while THIS dialog is
|
|
58649
|
+
* open, for several of them sharing one signal that says which is open
|
|
58650
|
+
* (`?seat=<gameId>` over a list of cards): open while `signal.value` is this
|
|
58651
|
+
* value, closed otherwise; opening writes it, closing writes `undefined`
|
|
58652
|
+
* (a state signal's default). Without it the signal holds a boolean.
|
|
58622
58653
|
* @param {boolean|"interaction"} [props.defaultOpen] - Uncontrolled, mount-only
|
|
58623
58654
|
* initial open state. `true` plays no entrance animation: the dialog was
|
|
58624
58655
|
* already open when the page appeared, and nothing was ever shown as "closed"
|
|
@@ -58715,6 +58746,7 @@ const UncontrolledDialog = props => {
|
|
|
58715
58746
|
...props,
|
|
58716
58747
|
open: undefined,
|
|
58717
58748
|
signal: undefined,
|
|
58749
|
+
value: undefined,
|
|
58718
58750
|
defaultOpen: undefined,
|
|
58719
58751
|
navState: undefined,
|
|
58720
58752
|
onClose: undefined,
|
|
@@ -60221,6 +60253,11 @@ const css$D = /* css */`
|
|
|
60221
60253
|
* put it. Excludes `open`; `onOpen`/`onClose` still fire. A signal holding
|
|
60222
60254
|
* `true` at mount behaves like `defaultOpen`: the popover was already open,
|
|
60223
60255
|
* no entrance plays.
|
|
60256
|
+
* @param {any} [props.value] - What `signal` holds while THIS popover is
|
|
60257
|
+
* open, for several of them sharing one signal that says which is open
|
|
60258
|
+
* (`?seat=<gameId>` over a list of cards): open while `signal.value` is this
|
|
60259
|
+
* value, closed otherwise; opening writes it, closing writes `undefined`
|
|
60260
|
+
* (a state signal's default). Without it the signal holds a boolean.
|
|
60224
60261
|
* @param {boolean|"interaction"} [props.defaultOpen] - Uncontrolled, mount-only
|
|
60225
60262
|
* initial open state. `true` plays no entrance animation: the popover was
|
|
60226
60263
|
* already open when the page appeared, and nothing was ever shown as "closed"
|
|
@@ -60315,6 +60352,7 @@ const UncontrolledPopover = props => {
|
|
|
60315
60352
|
...props,
|
|
60316
60353
|
open: undefined,
|
|
60317
60354
|
signal: undefined,
|
|
60355
|
+
value: undefined,
|
|
60318
60356
|
defaultOpen: undefined,
|
|
60319
60357
|
navState: undefined,
|
|
60320
60358
|
onClose: undefined,
|
|
@@ -83298,6 +83336,9 @@ const css = /* css */`.navi_side_panel {
|
|
|
83298
83336
|
* own (Escape, swipe, a --navi-close command) — one binding to both drive
|
|
83299
83337
|
* the panel and know where it is. Forwarded as-is to `Popup`; excludes
|
|
83300
83338
|
* `open` (see `Dialog`/`Popover`'s own `signal`).
|
|
83339
|
+
* @param {any} [props.value] - What `signal` holds while this panel is
|
|
83340
|
+
* open, for several panels sharing one signal that says which is open.
|
|
83341
|
+
* Forwarded as-is to `Popup` (see `Dialog`/`Popover`'s own `value`).
|
|
83301
83342
|
* @param {boolean} [props.defaultOpen] - Uncontrolled, mount-only initial
|
|
83302
83343
|
* open state, forwarded as-is to `Popup`. Neither this nor `open` is
|
|
83303
83344
|
* required at all for a purely command-driven panel (an `id` plus a
|
|
@@ -83385,6 +83426,7 @@ const css = /* css */`.navi_side_panel {
|
|
|
83385
83426
|
const SidePanel = ({
|
|
83386
83427
|
open,
|
|
83387
83428
|
signal,
|
|
83429
|
+
value,
|
|
83388
83430
|
defaultOpen,
|
|
83389
83431
|
onClose,
|
|
83390
83432
|
children,
|
|
@@ -83414,6 +83456,7 @@ const SidePanel = ({
|
|
|
83414
83456
|
open
|
|
83415
83457
|
}),
|
|
83416
83458
|
signal: signal,
|
|
83459
|
+
value: value,
|
|
83417
83460
|
defaultOpen: defaultOpen,
|
|
83418
83461
|
onClose: onClose,
|
|
83419
83462
|
layer: layer,
|