@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/jsenv_navi.js
CHANGED
|
@@ -45019,16 +45019,23 @@ const writeInSignal = (signal, value, { history }) => {
|
|
|
45019
45019
|
// those writes: they are spelled into the url first (only the signal knows
|
|
45020
45020
|
// how "closed" reads there), and that url is written onto the entry the back
|
|
45021
45021
|
// lands on.
|
|
45022
|
-
|
|
45023
|
-
|
|
45022
|
+
//
|
|
45023
|
+
// What "open" is worth in the signal is `true`, or the popup's `value`
|
|
45024
|
+
// when it has one: several popups then share one signal saying WHICH of them
|
|
45025
|
+
// is open (`?seat=<gameId>` over a list of cards), and closed is the signal
|
|
45026
|
+
// holding none of their values — `undefined`, which a state signal reads as
|
|
45027
|
+
// its default.
|
|
45028
|
+
const writeOpenedInSignal = (signal, opened, event, popupValue) => {
|
|
45029
|
+
if (readOpened(signal.peek(), popupValue) === opened) {
|
|
45024
45030
|
// The signal already says so, meaning this open/close IS what it asked
|
|
45025
45031
|
// for: a back press that took the popup out of the url, the application
|
|
45026
45032
|
// writing it. Nothing to write back — and nothing to go back to either,
|
|
45027
45033
|
// since the navigation navBack would undo is the one that asked for this.
|
|
45028
45034
|
return;
|
|
45029
45035
|
}
|
|
45036
|
+
const closedValue = popupValue === undefined ? false : undefined;
|
|
45030
45037
|
if (opened) {
|
|
45031
|
-
signal.value = true;
|
|
45038
|
+
signal.value = popupValue === undefined ? true : popupValue;
|
|
45032
45039
|
return;
|
|
45033
45040
|
}
|
|
45034
45041
|
if (
|
|
@@ -45043,11 +45050,17 @@ const writeOpenedInSignal = (signal, opened, event) => {
|
|
|
45043
45050
|
navBack();
|
|
45044
45051
|
return;
|
|
45045
45052
|
}
|
|
45046
|
-
writeInSignal(signal,
|
|
45053
|
+
writeInSignal(signal, closedValue, { history: "replace" });
|
|
45047
45054
|
navBack({ landOn: { url: window.location.href } });
|
|
45048
45055
|
return;
|
|
45049
45056
|
}
|
|
45050
|
-
writeInSignal(signal,
|
|
45057
|
+
writeInSignal(signal, closedValue, { history: "replace" });
|
|
45058
|
+
};
|
|
45059
|
+
const readOpened = (signalValue, popupValue) => {
|
|
45060
|
+
if (popupValue === undefined) {
|
|
45061
|
+
return signalValue;
|
|
45062
|
+
}
|
|
45063
|
+
return signalValue === popupValue;
|
|
45051
45064
|
};
|
|
45052
45065
|
|
|
45053
45066
|
/**
|
|
@@ -45062,7 +45075,7 @@ const writeOpenedInSignal = (signal, opened, event) => {
|
|
|
45062
45075
|
* `expandable.jsx` (open in flow rather than on a layer, same decision).
|
|
45063
45076
|
*
|
|
45064
45077
|
* @param {{ open: (e: Event, detail?: object) => void, requestClose: (e: Event, detail?: object) => void, opened: boolean }} openController
|
|
45065
|
-
* @param {{ id?: string, open?: boolean|"interaction", defaultOpen?: boolean|"interaction", signal?: import("@preact/signals").Signal
|
|
45078
|
+
* @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
|
|
45066
45079
|
* @param {string} [name] What the dev warnings call the thing being opened.
|
|
45067
45080
|
*/
|
|
45068
45081
|
const useOpenPropsEffectOnOpenController = (
|
|
@@ -45070,7 +45083,7 @@ const useOpenPropsEffectOnOpenController = (
|
|
|
45070
45083
|
props,
|
|
45071
45084
|
name = "popup",
|
|
45072
45085
|
) => {
|
|
45073
|
-
const { signal, defaultOpen, navState } = props;
|
|
45086
|
+
const { signal, value, defaultOpen, navState } = props;
|
|
45074
45087
|
const { id: navStateId, type: navStateType } = resolveNavStateProp(
|
|
45075
45088
|
navState,
|
|
45076
45089
|
props.id);
|
|
@@ -45088,7 +45101,7 @@ const useOpenPropsEffectOnOpenController = (
|
|
|
45088
45101
|
const open = navStateId
|
|
45089
45102
|
? Boolean(navStateValue)
|
|
45090
45103
|
: signal
|
|
45091
|
-
? signal.value
|
|
45104
|
+
? readOpened(signal.value, value)
|
|
45092
45105
|
: props.open;
|
|
45093
45106
|
// Assigned on every render, like openEffect, so it always closes over the
|
|
45094
45107
|
// latest prop: a popup that opens or closes on its own (Escape, backdrop, a
|
|
@@ -45108,7 +45121,7 @@ const useOpenPropsEffectOnOpenController = (
|
|
|
45108
45121
|
}
|
|
45109
45122
|
}
|
|
45110
45123
|
if (signal) {
|
|
45111
|
-
writeOpenedInSignal(signal, opened, event);
|
|
45124
|
+
writeOpenedInSignal(signal, opened, event, value);
|
|
45112
45125
|
}
|
|
45113
45126
|
}
|
|
45114
45127
|
: null;
|
|
@@ -45166,9 +45179,16 @@ const useOpenPropsEffectOnOpenController = (
|
|
|
45166
45179
|
// then stays where it was, and whoever holds the open state is told so —
|
|
45167
45180
|
// otherwise it would keep saying "closed" about a popup still open.
|
|
45168
45181
|
// Written over rather than stacked on: a refusal corrects the state that
|
|
45169
|
-
// asked, it is not a place one came from.
|
|
45170
|
-
|
|
45171
|
-
|
|
45182
|
+
// asked, it is not a place one came from. Only on a refusal: an accepted
|
|
45183
|
+
// request already reads in the signal, and with a `value` what the
|
|
45184
|
+
// signal holds may be another popup's, which the write would erase.
|
|
45185
|
+
if (signal && openController.opened !== open) {
|
|
45186
|
+
const opened = openController.opened;
|
|
45187
|
+
writeInSignal(
|
|
45188
|
+
signal,
|
|
45189
|
+
value === undefined ? opened : opened ? value : undefined,
|
|
45190
|
+
{ history: "replace" },
|
|
45191
|
+
);
|
|
45172
45192
|
}
|
|
45173
45193
|
if (navStateId && openController.opened) {
|
|
45174
45194
|
enterNavState();
|
|
@@ -46028,7 +46048,8 @@ const useExpandableContext = partName => {
|
|
|
46028
46048
|
* ui?: import("ignore:preact").ComponentChildren | ((state: { open: boolean }) => import("ignore:preact").ComponentChildren),
|
|
46029
46049
|
* open?: boolean,
|
|
46030
46050
|
* defaultOpen?: boolean,
|
|
46031
|
-
* signal?: import("@preact/signals").Signal
|
|
46051
|
+
* signal?: import("@preact/signals").Signal,
|
|
46052
|
+
* value?: any,
|
|
46032
46053
|
* navState?: boolean | string | { id?: string, type?: "push" | "replace" },
|
|
46033
46054
|
* onClose?: (event: Event) => void,
|
|
46034
46055
|
* onToggle?: (event: Event) => void,
|
|
@@ -46057,6 +46078,10 @@ const useExpandableContext = partName => {
|
|
|
46057
46078
|
* @param defaultOpen - Uncontrolled, mount-only initial state.
|
|
46058
46079
|
* @param signal - Two-way binding: the expandable follows the signal and
|
|
46059
46080
|
* writes back into it whenever it toggles on its own. Excludes `open`.
|
|
46081
|
+
* @param value - What `signal` holds while THIS expandable is open, for
|
|
46082
|
+
* several sharing one signal that says which is open (an accordion): open
|
|
46083
|
+
* while `signal.value` is this value, closed otherwise; opening writes it,
|
|
46084
|
+
* closing writes `undefined`. Without it the signal holds a boolean.
|
|
46060
46085
|
* @param navState - Keeps the open state in the history entry, so a screen
|
|
46061
46086
|
* left and come back to finds its sections as they were: `true` uses the
|
|
46062
46087
|
* expandable's own `id`, a string names the key, `{ id, type }` chooses
|
|
@@ -46117,6 +46142,7 @@ const Expandable = props => {
|
|
|
46117
46142
|
open,
|
|
46118
46143
|
defaultOpen,
|
|
46119
46144
|
signal,
|
|
46145
|
+
value,
|
|
46120
46146
|
navState,
|
|
46121
46147
|
onClose,
|
|
46122
46148
|
action,
|
|
@@ -57941,6 +57967,11 @@ const css$E = /* css */`
|
|
|
57941
57967
|
* Excludes `open`; `onOpen`/`onClose` still fire. A signal holding `true` at
|
|
57942
57968
|
* mount behaves like `defaultOpen`: the dialog was already open, no entrance
|
|
57943
57969
|
* plays.
|
|
57970
|
+
* @param {any} [props.value] - What `signal` holds while THIS dialog is
|
|
57971
|
+
* open, for several of them sharing one signal that says which is open
|
|
57972
|
+
* (`?seat=<gameId>` over a list of cards): open while `signal.value` is this
|
|
57973
|
+
* value, closed otherwise; opening writes it, closing writes `undefined`
|
|
57974
|
+
* (a state signal's default). Without it the signal holds a boolean.
|
|
57944
57975
|
* @param {boolean|"interaction"} [props.defaultOpen] - Uncontrolled, mount-only
|
|
57945
57976
|
* initial open state. `true` plays no entrance animation: the dialog was
|
|
57946
57977
|
* already open when the page appeared, and nothing was ever shown as "closed"
|
|
@@ -58037,6 +58068,7 @@ const UncontrolledDialog = props => {
|
|
|
58037
58068
|
...props,
|
|
58038
58069
|
open: undefined,
|
|
58039
58070
|
signal: undefined,
|
|
58071
|
+
value: undefined,
|
|
58040
58072
|
defaultOpen: undefined,
|
|
58041
58073
|
navState: undefined,
|
|
58042
58074
|
onClose: undefined,
|
|
@@ -59534,6 +59566,11 @@ const css$D = /* css */`
|
|
|
59534
59566
|
* put it. Excludes `open`; `onOpen`/`onClose` still fire. A signal holding
|
|
59535
59567
|
* `true` at mount behaves like `defaultOpen`: the popover was already open,
|
|
59536
59568
|
* no entrance plays.
|
|
59569
|
+
* @param {any} [props.value] - What `signal` holds while THIS popover is
|
|
59570
|
+
* open, for several of them sharing one signal that says which is open
|
|
59571
|
+
* (`?seat=<gameId>` over a list of cards): open while `signal.value` is this
|
|
59572
|
+
* value, closed otherwise; opening writes it, closing writes `undefined`
|
|
59573
|
+
* (a state signal's default). Without it the signal holds a boolean.
|
|
59537
59574
|
* @param {boolean|"interaction"} [props.defaultOpen] - Uncontrolled, mount-only
|
|
59538
59575
|
* initial open state. `true` plays no entrance animation: the popover was
|
|
59539
59576
|
* already open when the page appeared, and nothing was ever shown as "closed"
|
|
@@ -59628,6 +59665,7 @@ const UncontrolledPopover = props => {
|
|
|
59628
59665
|
...props,
|
|
59629
59666
|
open: undefined,
|
|
59630
59667
|
signal: undefined,
|
|
59668
|
+
value: undefined,
|
|
59631
59669
|
defaultOpen: undefined,
|
|
59632
59670
|
navState: undefined,
|
|
59633
59671
|
onClose: undefined,
|
|
@@ -82080,6 +82118,9 @@ const css = /* css */`.navi_side_panel {
|
|
|
82080
82118
|
* own (Escape, swipe, a --navi-close command) — one binding to both drive
|
|
82081
82119
|
* the panel and know where it is. Forwarded as-is to `Popup`; excludes
|
|
82082
82120
|
* `open` (see `Dialog`/`Popover`'s own `signal`).
|
|
82121
|
+
* @param {any} [props.value] - What `signal` holds while this panel is
|
|
82122
|
+
* open, for several panels sharing one signal that says which is open.
|
|
82123
|
+
* Forwarded as-is to `Popup` (see `Dialog`/`Popover`'s own `value`).
|
|
82083
82124
|
* @param {boolean} [props.defaultOpen] - Uncontrolled, mount-only initial
|
|
82084
82125
|
* open state, forwarded as-is to `Popup`. Neither this nor `open` is
|
|
82085
82126
|
* required at all for a purely command-driven panel (an `id` plus a
|
|
@@ -82167,6 +82208,7 @@ const css = /* css */`.navi_side_panel {
|
|
|
82167
82208
|
const SidePanel = ({
|
|
82168
82209
|
open,
|
|
82169
82210
|
signal,
|
|
82211
|
+
value,
|
|
82170
82212
|
defaultOpen,
|
|
82171
82213
|
onClose,
|
|
82172
82214
|
children,
|
|
@@ -82196,6 +82238,7 @@ const SidePanel = ({
|
|
|
82196
82238
|
open
|
|
82197
82239
|
}),
|
|
82198
82240
|
signal: signal,
|
|
82241
|
+
value: value,
|
|
82199
82242
|
defaultOpen: defaultOpen,
|
|
82200
82243
|
onClose: onClose,
|
|
82201
82244
|
layer: layer,
|