@jsenv/navi 0.29.329 → 0.29.330
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 +169 -15
- package/dist/dev/jsenv_navi.js.map +4 -4
- package/dist/jsenv_navi.js +169 -15
- package/dist/jsenv_navi.js.map +4 -4
- package/docs/control_value.md +21 -15
- package/package.json +2 -2
package/dist/dev/jsenv_navi.js
CHANGED
|
@@ -32749,9 +32749,10 @@ registerNaviCommand("--navi-void", (source) => {
|
|
|
32749
32749
|
});
|
|
32750
32750
|
|
|
32751
32751
|
// "--navi-update:smooth" asks the control to be SEEN moving to the value — a
|
|
32752
|
-
// wheel scrolls to it rather than swapping its digits
|
|
32753
|
-
//
|
|
32754
|
-
//
|
|
32752
|
+
// wheel scrolls to it rather than swapping its digits, a spin plays the travel
|
|
32753
|
+
// its chevron would play — so a shortcut under a control shows which value it
|
|
32754
|
+
// changed, and by how much. What that movement is, and whether the value
|
|
32755
|
+
// travels with it, belongs to the control: see control_value.md.
|
|
32755
32756
|
registerNaviCommand("--navi-update", (source, event, { argument }) => {
|
|
32756
32757
|
const target =
|
|
32757
32758
|
resolveExplicitTarget(source) || resolveFirstParentControl(source);
|
|
@@ -64008,11 +64009,7 @@ const PickerNative = props => {
|
|
|
64008
64009
|
e.preventDefault();
|
|
64009
64010
|
},
|
|
64010
64011
|
allowed: () => {
|
|
64011
|
-
|
|
64012
|
-
pickerInput.showPicker();
|
|
64013
|
-
} catch {
|
|
64014
|
-
pickerInput.click();
|
|
64015
|
-
}
|
|
64012
|
+
showNativePicker(pickerInput, e);
|
|
64016
64013
|
}
|
|
64017
64014
|
});
|
|
64018
64015
|
},
|
|
@@ -64028,11 +64025,7 @@ const PickerNative = props => {
|
|
|
64028
64025
|
const pickerInput = getPickerInput(pickerEl);
|
|
64029
64026
|
if (pickerInput.type === "color") ; else {
|
|
64030
64027
|
// other picker might not open the picker when clicking the input surface (only the calendar picker for instance would open)
|
|
64031
|
-
|
|
64032
|
-
pickerInput.showPicker();
|
|
64033
|
-
} catch {
|
|
64034
|
-
pickerInput.click();
|
|
64035
|
-
}
|
|
64028
|
+
showNativePicker(pickerInput, e);
|
|
64036
64029
|
}
|
|
64037
64030
|
}
|
|
64038
64031
|
};
|
|
@@ -64931,6 +64924,32 @@ const PickerCalloutPopup = ({
|
|
|
64931
64924
|
);
|
|
64932
64925
|
};
|
|
64933
64926
|
|
|
64927
|
+
// Under a finger the input is focused before the browser's picker is asked
|
|
64928
|
+
// for: iOS presents a date/time input's picker as that input's own inputView,
|
|
64929
|
+
// so what the tap focuses is what opens. showPicker() presents nothing there
|
|
64930
|
+
// and throws nothing either, so the catch below cannot be what learns about
|
|
64931
|
+
// it — and a synthetic click() does not focus a date input there.
|
|
64932
|
+
// A departure from the coarse-pointer policy (see focus_transfer.js), argued
|
|
64933
|
+
// here: the press asked for this input's picker, and the types whose focus
|
|
64934
|
+
// would raise the on-screen keyboard instead are held readOnly already (see
|
|
64935
|
+
// NON_MOBILE_KEYBOARD_TYPES in picker.jsx). No ring: nobody is about to type.
|
|
64936
|
+
// Not with a mouse, where showPicker() presents the picker on its own: the
|
|
64937
|
+
// keyboard stays where it was — a spin's middle, the button that sent the
|
|
64938
|
+
// command — so one keeps going with the keys once the calendar closes, rather
|
|
64939
|
+
// than on an input drawn behind (see the headless variant in picker.jsx).
|
|
64940
|
+
const showNativePicker = (pickerInput, event) => {
|
|
64941
|
+
if (findEvent(event, isTouchDrivenEvent)) {
|
|
64942
|
+
moveFocusTo(pickerInput, {
|
|
64943
|
+
focusVisible: false
|
|
64944
|
+
});
|
|
64945
|
+
}
|
|
64946
|
+
try {
|
|
64947
|
+
pickerInput.showPicker();
|
|
64948
|
+
} catch {
|
|
64949
|
+
pickerInput.click();
|
|
64950
|
+
}
|
|
64951
|
+
};
|
|
64952
|
+
|
|
64934
64953
|
installImportMetaCssBuild(import.meta);
|
|
64935
64954
|
const css$A = /* css */`.navi_picker_confirm_body {
|
|
64936
64955
|
min-width: 180px;
|
|
@@ -74873,6 +74892,10 @@ const css$s = /* css */`@layer navi {
|
|
|
74873
74892
|
}
|
|
74874
74893
|
`;
|
|
74875
74894
|
|
|
74895
|
+
// No travel waiting to be played. One array rather than a new one per render,
|
|
74896
|
+
// so "nothing pending" compares equal to itself.
|
|
74897
|
+
const TRAVELS_NONE = [];
|
|
74898
|
+
|
|
74876
74899
|
/**
|
|
74877
74900
|
* @type {import("ignore:preact").FunctionComponent<{
|
|
74878
74901
|
* value?: any,
|
|
@@ -75131,6 +75154,126 @@ const Spin = ({
|
|
|
75131
75154
|
const valueAtEnd = startIsNext ? valuePrevious : valueNext;
|
|
75132
75155
|
const startAllowed = startIsNext ? nextAllowed : previousAllowed;
|
|
75133
75156
|
const endAllowed = startIsNext ? previousAllowed : nextAllowed;
|
|
75157
|
+
|
|
75158
|
+
// A value asked to be SEEN arriving (`--navi-update:smooth`): the spin plays
|
|
75159
|
+
// the travel a chevron would play and lets the value land with the slides, so
|
|
75160
|
+
// a shortcut under it reads as "go to that day" rather than "be that day".
|
|
75161
|
+
// Whatever the distance it is ONE travel — a spin is not a wheel, and three
|
|
75162
|
+
// weeks are read as "it moved forward" rather than as twenty-one slides — so
|
|
75163
|
+
// the slide arriving is the one that shows the value being travelled to.
|
|
75164
|
+
//
|
|
75165
|
+
// Queued rather than held one at a time: two shortcuts pressed in a row are
|
|
75166
|
+
// two travels, each landing on its own value, and the one being played is
|
|
75167
|
+
// always the head. And started from a layout effect rather than from the
|
|
75168
|
+
// request itself, so the arriving slide is written before the container
|
|
75169
|
+
// places it — started there, the first frame would show the neighbouring
|
|
75170
|
+
// value and swap to the target mid-flight.
|
|
75171
|
+
const [travelsPending, setTravelsPendingState] = useState(TRAVELS_NONE);
|
|
75172
|
+
const travelsPendingRef = useRef(TRAVELS_NONE);
|
|
75173
|
+
const travelPending = travelsPending[0];
|
|
75174
|
+
const setTravelsPending = travels => {
|
|
75175
|
+
travelsPendingRef.current = travels.length ? travels : TRAVELS_NONE;
|
|
75176
|
+
setTravelsPendingState(travelsPendingRef.current);
|
|
75177
|
+
};
|
|
75178
|
+
const onRequestSetUIStateRef = useRef();
|
|
75179
|
+
onRequestSetUIStateRef.current = e => {
|
|
75180
|
+
if (editable) {
|
|
75181
|
+
// Nothing travels around a field: the value is typed into the middle.
|
|
75182
|
+
return;
|
|
75183
|
+
}
|
|
75184
|
+
const {
|
|
75185
|
+
behavior,
|
|
75186
|
+
value: valueRequested
|
|
75187
|
+
} = e.detail;
|
|
75188
|
+
if (behavior !== "smooth") {
|
|
75189
|
+
return;
|
|
75190
|
+
}
|
|
75191
|
+
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
75192
|
+
// Whoever asked to see less motion is answered first: the value is swapped
|
|
75193
|
+
// in place, which is what `--navi-update` alone does.
|
|
75194
|
+
return;
|
|
75195
|
+
}
|
|
75196
|
+
if (valueRequested === undefined || valueRequested === null || valueRequested === "") {
|
|
75197
|
+
// Nowhere to travel to — the erase a calendar offers, say.
|
|
75198
|
+
return;
|
|
75199
|
+
}
|
|
75200
|
+
const travelsQueued = travelsPendingRef.current;
|
|
75201
|
+
// Where the spin stands when this travel starts: behind the ones already
|
|
75202
|
+
// queued, rather than where the eye is now.
|
|
75203
|
+
const valueFrom = travelsQueued.length ? travelsQueued[travelsQueued.length - 1].value : valueShown;
|
|
75204
|
+
const direction = compareValues(valueRequested, valueFrom);
|
|
75205
|
+
if (direction === 0) {
|
|
75206
|
+
return;
|
|
75207
|
+
}
|
|
75208
|
+
const goingNext = direction > 0;
|
|
75209
|
+
// Out of reach, in both the ways a value can be: past the end of what one
|
|
75210
|
+
// may reach, or one step past it — the first step of the travel is the very
|
|
75211
|
+
// one the chevron that way is refused.
|
|
75212
|
+
const outOfReach = goingNext ? hasMax && (compareValues(valueRequested, max) > 0 || compareValues(valueAtStep(valueFrom, step), max) > 0) : hasMin && (compareValues(valueRequested, min) < 0 || compareValues(valueAtStep(valueFrom, -step), min) < 0);
|
|
75213
|
+
if (outOfReach) {
|
|
75214
|
+
// The same refusal a chevron gives, in the same words — said at the value
|
|
75215
|
+
// rather than at the chevron that way, because the press was not on a
|
|
75216
|
+
// chevron: what was asked about is the value, and that is where the
|
|
75217
|
+
// answer belongs.
|
|
75218
|
+
e.preventDefault();
|
|
75219
|
+
e.stopPropagation();
|
|
75220
|
+
openCallout(naviI18n(goingNext ? "spin.nothing_after" : "spin.nothing_before"), {
|
|
75221
|
+
anchorElement: middleRef.current,
|
|
75222
|
+
status: "info",
|
|
75223
|
+
openingEvent: e.detail.event ?? e
|
|
75224
|
+
});
|
|
75225
|
+
return;
|
|
75226
|
+
}
|
|
75227
|
+
// Taken here and answered when the slides land (see onLoop): the control
|
|
75228
|
+
// must not be given the value on the way past, or there would be nothing
|
|
75229
|
+
// left to arrive.
|
|
75230
|
+
e.stopPropagation();
|
|
75231
|
+
// A direction on the map, the way a chevron says it (see wayOut): the
|
|
75232
|
+
// slides are laid out from start to end, so which value sits where is what
|
|
75233
|
+
// decides the way, not which value is bigger.
|
|
75234
|
+
const atStart = goingNext ? startIsNext : !startIsNext;
|
|
75235
|
+
const towardsEnd = atStart ? -1 : 1;
|
|
75236
|
+
setTravelsPending([...travelsQueued, {
|
|
75237
|
+
value: valueRequested,
|
|
75238
|
+
area: atStart ? "start" : "end",
|
|
75239
|
+
dx: vertical ? 0 : towardsEnd,
|
|
75240
|
+
dy: vertical ? towardsEnd : 0,
|
|
75241
|
+
event: e.detail.event ?? e
|
|
75242
|
+
}]);
|
|
75243
|
+
};
|
|
75244
|
+
useLayoutEffect(() => {
|
|
75245
|
+
const middleEl = middleRef.current;
|
|
75246
|
+
const onRequestSetUIState = e => {
|
|
75247
|
+
onRequestSetUIStateRef.current(e);
|
|
75248
|
+
};
|
|
75249
|
+
// On the way DOWN, and on the box holding the control rather than on the
|
|
75250
|
+
// control: the request is dispatched AT the control host, where the
|
|
75251
|
+
// controller is already listening, and the spin has to be able to take it
|
|
75252
|
+
// before the value is set.
|
|
75253
|
+
middleEl.addEventListener("navi_set_ui_state", onRequestSetUIState, true);
|
|
75254
|
+
return () => {
|
|
75255
|
+
middleEl.removeEventListener("navi_set_ui_state", onRequestSetUIState, true);
|
|
75256
|
+
};
|
|
75257
|
+
}, []);
|
|
75258
|
+
useLayoutEffect(() => {
|
|
75259
|
+
if (!travelPending) {
|
|
75260
|
+
return;
|
|
75261
|
+
}
|
|
75262
|
+
// What `--navi-left` and friends ask the container for (see
|
|
75263
|
+
// registerSlideCommand): asked directly because the container already
|
|
75264
|
+
// carries a `commandfor` of its own — pressing the middle opens the picker
|
|
75265
|
+
// — so a command triggered from it would be about the picker.
|
|
75266
|
+
dispatchCustomEvent(document.getElementById(containerId), "navi_slide_move", {
|
|
75267
|
+
event: travelPending.event,
|
|
75268
|
+
dx: travelPending.dx,
|
|
75269
|
+
dy: travelPending.dy
|
|
75270
|
+
});
|
|
75271
|
+
}, [travelPending]);
|
|
75272
|
+
// What the slide the travel is heading for shows: the value being travelled
|
|
75273
|
+
// TO, not the neighbour that place holds at rest — one travel covers the
|
|
75274
|
+
// whole distance, so the far value is what arrives.
|
|
75275
|
+
const valueDrawnAtStart = travelPending?.area === "start" ? travelPending.value : valueAtStart;
|
|
75276
|
+
const valueDrawnAtEnd = travelPending?.area === "end" ? travelPending.value : valueAtEnd;
|
|
75134
75277
|
const wayOut = atStart => {
|
|
75135
75278
|
const isNext = atStart ? startIsNext : !startIsNext;
|
|
75136
75279
|
return jsx(WayOut, {
|
|
@@ -75244,6 +75387,17 @@ const Spin = ({
|
|
|
75244
75387
|
dy,
|
|
75245
75388
|
event
|
|
75246
75389
|
}) => {
|
|
75390
|
+
// A travel asked for by a VALUE (`--navi-update:smooth`):
|
|
75391
|
+
// that value is what lands, whatever the distance it covered,
|
|
75392
|
+
// and the press that asked for it is what says so to uiAction.
|
|
75393
|
+
// Recognized by that press: a chevron travel hurrying this one
|
|
75394
|
+
// along lands first and is a step of its own.
|
|
75395
|
+
const travelLanding = travelsPendingRef.current[0];
|
|
75396
|
+
if (travelLanding && event?.detail?.event === travelLanding.event) {
|
|
75397
|
+
setTravelsPending(travelsPendingRef.current.slice(1));
|
|
75398
|
+
setValue(travelLanding.value, travelLanding.event);
|
|
75399
|
+
return;
|
|
75400
|
+
}
|
|
75247
75401
|
// One step, whichever axis it came from: the map is a line, so
|
|
75248
75402
|
// only one of the two is ever anything but zero. Towards the
|
|
75249
75403
|
// end of the line is a step forward, unless the line was laid
|
|
@@ -75276,7 +75430,7 @@ const Spin = ({
|
|
|
75276
75430
|
area: "start",
|
|
75277
75431
|
flex: true,
|
|
75278
75432
|
align: "center",
|
|
75279
|
-
children: renderValue(
|
|
75433
|
+
children: renderValue(valueDrawnAtStart, {
|
|
75280
75434
|
maxLines
|
|
75281
75435
|
})
|
|
75282
75436
|
}), jsx(Slide, {
|
|
@@ -75296,7 +75450,7 @@ const Spin = ({
|
|
|
75296
75450
|
area: "end",
|
|
75297
75451
|
flex: true,
|
|
75298
75452
|
align: "center",
|
|
75299
|
-
children: renderValue(
|
|
75453
|
+
children: renderValue(valueDrawnAtEnd, {
|
|
75300
75454
|
maxLines
|
|
75301
75455
|
})
|
|
75302
75456
|
})]
|