@jsenv/navi 0.29.367 → 0.29.369

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.
@@ -89,6 +89,7 @@ const css$17 = /* css */ `@layer navi {
89
89
  --navi-z-index-bar: 100;
90
90
  --navi-z-index-popup: 1000;
91
91
  --navi-z-index-callout: var(--navi-z-index-popup);
92
+ --navi-z-index-top-layer: 10000;
92
93
  }
93
94
  }
94
95
  `;
@@ -29928,6 +29929,8 @@ const warnOnce$1 = (id, message) => {
29928
29929
  console.warn(message);
29929
29930
  };
29930
29931
 
29932
+ installImportMetaCssBuild(import.meta);
29933
+
29931
29934
  /**
29932
29935
  * The furniture around the pages — the fixed bars, and the popups standing
29933
29936
  * over them in the top layer — photographed with them for the length of a
@@ -29975,6 +29978,23 @@ const warnOnce$1 = (id, message) => {
29975
29978
  * that has nothing to do with it. Being unable to answer a press is the price
29976
29979
  * of being photographed, and a route transition is where it costs nothing:
29977
29980
  * both pages are pictures for those few hundred milliseconds anyway.
29981
+ *
29982
+ * The WALL of a modal dialog goes the other way round: it cannot be
29983
+ * photographed at all. It is the browser's own ::backdrop — a pseudo-element,
29984
+ * which wears no name — and the top layer it is painted in is drawn during a
29985
+ * transition only as part of the root's picture, which is opted out while an
29986
+ * area is marked (route_transition.jsx). Captured on its own, the dialog's
29987
+ * box travels; its wall is painted nowhere for the length of the movement,
29988
+ * and the page under it leaves undimmed. So the wall is painted INTO the
29989
+ * page's picture instead: a stand-in laid over the area before each of the
29990
+ * two pictures is taken, painting what the ::backdrop paints, and removed
29991
+ * with the movement. Carried by the page's picture, it leaves with the page
29992
+ * being left and arrives with the page arriving, cut at the page's edge — and
29993
+ * under the dialog's own picture, which stands over the pages (the z-order in
29994
+ * route_transition.jsx). A bar the two states share is outside both pictures
29995
+ * and goes undimmed for those few hundred milliseconds: it is the frame, not
29996
+ * part of the page. A dialog with layer="local" paints a real element for its
29997
+ * wall, inside the page, and needs none of this.
29978
29998
  */
29979
29999
 
29980
30000
  // The browser's top layer: painted above everything the document paints, so
@@ -29992,6 +30012,32 @@ const FURNITURE_SELECTOR = `.navi_fixed_bar, .navi_popover:is(${TOP_LAYER_SELECT
29992
30012
  const TRANSITION_ATTRIBUTE$1 = "data-navi-route-transition";
29993
30013
  const NAME_PROPERTY$1 = "view-transition-name";
29994
30014
  const FURNITURE_NAME_PREFIX = "navi-transition-furniture-";
30015
+ // The dialogs whose wall is the browser's ::backdrop: shown with showModal().
30016
+ // A top-layer dialog without a wall is shown as a popover and has nothing to
30017
+ // stand in for.
30018
+ const MODAL_DIALOG_SELECTOR = ".navi_dialog:modal";
30019
+ const WALL_ATTRIBUTE = "data-navi-transition-wall";
30020
+ // What the ::backdrop paints, resolved on the dialog (layout/dialog.jsx): the
30021
+ // same two properties, copied onto the wall.
30022
+ const WALL_PROPERTIES = ["--backdrop-background", "--backdrop-filter"];
30023
+
30024
+ const TRANSITION_WALL_CSS = /* css */ `[data-navi-transition-wall] {
30025
+ z-index: var(--navi-z-index-top-layer);
30026
+ background: var(--backdrop-background);
30027
+ backdrop-filter: var(--backdrop-filter);
30028
+ pointer-events: none;
30029
+ position: absolute;
30030
+ top: 0;
30031
+ left: 0;
30032
+ }
30033
+ `;
30034
+
30035
+ // Called from the render of whatever holds the pages, never at module scope:
30036
+ // a page that never travels between routes must not carry this sheet, and a
30037
+ // build that sees no caller drops the css with the function.
30038
+ const installTransitionFurnitureCss = () => {
30039
+ import.meta.css = [TRANSITION_WALL_CSS, "@jsenv/navi/src/nav/transition_furniture.js"];
30040
+ };
29995
30041
 
29996
30042
  const nameByElement = new WeakMap();
29997
30043
  let nameCount = 0;
@@ -30004,6 +30050,9 @@ let namedElements = new Set();
30004
30050
  // The rule giving the one-sided bars their movement, written for one movement
30005
30051
  // and taken down with it.
30006
30052
  let travelStyleElement = null;
30053
+ // The walls standing in for the ::backdrop of the modal dialogs open in the
30054
+ // area, painted for one picture and taken down before the next.
30055
+ let wallElements = [];
30007
30056
 
30008
30057
  /**
30009
30058
  * Name what stands around the area, before the picture of the state being left
@@ -30016,6 +30065,7 @@ const nameTransitionFurniture = (owner, areaElement) => {
30016
30065
  namedElements = new Set();
30017
30066
  }
30018
30067
  nameFurnitureAround(areaElement);
30068
+ paintTransitionWalls(areaElement);
30019
30069
  };
30020
30070
 
30021
30071
  /**
@@ -30036,6 +30086,7 @@ const holdTransitionFurniture = (owner, areaElement) => {
30036
30086
  }
30037
30087
  }
30038
30088
  const namesArriving = nameFurnitureAround(areaElement);
30089
+ paintTransitionWalls(areaElement);
30039
30090
  const cssText = `${travelRule("old", namesLeaving, "--navi-route-transition-leave")}${travelRule("new", namesArriving, "--navi-route-transition-enter")}`;
30040
30091
  if (!cssText) {
30041
30092
  return;
@@ -30118,6 +30169,40 @@ const releaseTransitionFurniture = (owner) => {
30118
30169
  travelStyleElement.remove();
30119
30170
  travelStyleElement = null;
30120
30171
  }
30172
+ removeTransitionWalls();
30173
+ };
30174
+
30175
+ // One wall per modal dialog open in the area, in document order: the
30176
+ // ::backdrops stack in the top layer, and what dims the page is all of them.
30177
+ const paintTransitionWalls = (areaElement) => {
30178
+ removeTransitionWalls();
30179
+ for (const dialog of areaElement.querySelectorAll(MODAL_DIALOG_SELECTOR)) {
30180
+ const dialogStyle = getComputedStyle(dialog);
30181
+ const wall = document.createElement("div");
30182
+ wall.setAttribute(WALL_ATTRIBUTE, "");
30183
+ for (const property of WALL_PROPERTIES) {
30184
+ wall.style.setProperty(property, dialogStyle.getPropertyValue(property));
30185
+ }
30186
+ areaElement.appendChild(wall);
30187
+ // The area is not necessarily a containing block, and made one for the
30188
+ // movement it would move whatever the page positioned against an ancestor
30189
+ // of the area: the wall is placed from wherever its containing block
30190
+ // turns out to be, by the offset between that box and the area's.
30191
+ const areaRect = areaElement.getBoundingClientRect();
30192
+ const wallRect = wall.getBoundingClientRect();
30193
+ wall.style.left = `${areaRect.left - wallRect.left}px`;
30194
+ wall.style.top = `${areaRect.top - wallRect.top}px`;
30195
+ wall.style.width = `${areaRect.width}px`;
30196
+ wall.style.height = `${areaRect.height}px`;
30197
+ wallElements.push(wall);
30198
+ }
30199
+ };
30200
+
30201
+ const removeTransitionWalls = () => {
30202
+ for (const wall of wallElements) {
30203
+ wall.remove();
30204
+ }
30205
+ wallElements = [];
30121
30206
  };
30122
30207
 
30123
30208
  installImportMetaCssBuild(import.meta);
@@ -30969,6 +31054,7 @@ const RouteTransitionArea = ({
30969
31054
  }) => {
30970
31055
  import.meta.css = [css$12, "@jsenv/navi/src/nav/route_transition.jsx"];
30971
31056
  installTransitionWindowCss();
31057
+ installTransitionFurnitureCss();
30972
31058
  const props = {
30973
31059
  ...rest,
30974
31060
  [TRANSITION_AREA_ATTRIBUTE]: ""
@@ -74690,6 +74776,7 @@ const css$t = /* css */`@layer navi {
74690
74776
  var(--picker-icon-color) 45%,
74691
74777
  transparent);
74692
74778
  --picker-icon-color-disabled: var(--picker-icon-color-readonly);
74779
+ --picker-icon-color-hover: var(--picker-icon-color);
74693
74780
  --picker-align-x-default: flex-start;
74694
74781
  --picker-align-y-default: center;
74695
74782
  --picker-text-align-default: initial;
@@ -74707,6 +74794,7 @@ const css$t = /* css */`@layer navi {
74707
74794
  --x-picker-press-padding-right: var(--picker-press-padding-right, var(--picker-press-padding-x, var(--picker-press-padding, 0px)));
74708
74795
  --x-picker-press-padding-bottom: var(--picker-press-padding-bottom, var(--picker-press-padding-y, var(--picker-press-padding, 0px)));
74709
74796
  --x-picker-press-padding-left: var(--picker-press-padding-left, var(--picker-press-padding-x, var(--picker-press-padding, 0px)));
74797
+ --x-picker-chevron-reach: 0px;
74710
74798
  --x-picker-color: var(--picker-color);
74711
74799
  --x-picker-icon-color: var(--picker-icon-color);
74712
74800
  --x-picker-align-x: var(--picker-align-x, var(--picker-align-x-default));
@@ -74875,7 +74963,10 @@ const css$t = /* css */`@layer navi {
74875
74963
  & > .navi_picker_box > .navi_picker_input {
74876
74964
  top: calc(-1 * (var(--picker-border-width) + var(--x-picker-press-padding-top)));
74877
74965
  right: calc(-1 *
74878
- (var(--picker-border-width) + var(--x-picker-press-padding-right)));
74966
+ (
74967
+ var(--picker-border-width) + var(--x-picker-press-padding-right) +
74968
+ var(--x-picker-chevron-reach)
74969
+ ));
74879
74970
  bottom: calc(-1 *
74880
74971
  (var(--picker-border-width) + var(--x-picker-press-padding-bottom)));
74881
74972
  left: calc(-1 * (var(--picker-border-width) + var(--x-picker-press-padding-left)));
@@ -74921,6 +75012,7 @@ const css$t = /* css */`@layer navi {
74921
75012
  &[data-hover] {
74922
75013
  --x-picker-background-color: var(--picker-background-color-hover);
74923
75014
  --x-picker-border-color: var(--picker-border-color-hover);
75015
+ --x-picker-icon-color: var(--picker-icon-color-hover);
74924
75016
  }
74925
75017
 
74926
75018
  &[data-readonly] {
@@ -75030,6 +75122,30 @@ const css$t = /* css */`@layer navi {
75030
75122
  align-items: var(--x-picker-align-y);
75031
75123
  display: flex;
75032
75124
  }
75125
+
75126
+ & > .navi_picker_box > .navi_picker_right_slot {
75127
+ margin-right: 0;
75128
+ margin-left: var(--picker-slot-spacing, var(--navi-xxs));
75129
+ align-self: center;
75130
+ }
75131
+
75132
+ &[data-chevron="start"] > .navi_picker_box > .navi_picker_right_slot {
75133
+ margin-right: var(--picker-slot-spacing, var(--navi-xxs));
75134
+ order: -1;
75135
+ margin-left: 0;
75136
+ }
75137
+
75138
+ &[data-chevron="hang-end"] > .navi_picker_box {
75139
+ --x-picker-chevron-reach: calc(var(--x-picker-chevron-size) +
75140
+ var(--picker-slot-spacing, var(--navi-xxs)));
75141
+
75142
+ & > .navi_picker_right_slot {
75143
+ position: absolute;
75144
+ top: 50%;
75145
+ left: 100%;
75146
+ transform: translateY(-50%);
75147
+ }
75148
+ }
75033
75149
  }
75034
75150
 
75035
75151
  &[data-variant="button"] {
@@ -75109,6 +75225,9 @@ const PickerButton = props => {
75109
75225
  // an <Icon>, which is aria-hidden, and a focusable node under aria-hidden is
75110
75226
  // invisible to assistive tech while still being reachable by tab.
75111
75227
  rightSlot,
75228
+ // A bare picker's chevron, and where it goes so the drawing keeps its box
75229
+ // (see the `chevron` doc). Left out, a bare picker draws no slot at all.
75230
+ chevron,
75112
75231
  placeholder,
75113
75232
  ui,
75114
75233
  maxLines: maxLinesProp = 1,
@@ -75169,12 +75288,22 @@ const PickerButton = props => {
75169
75288
  // icon, a headless one draws nothing, a button says what it opens with its
75170
75289
  // label, a word in a sentence has no room for furniture. Nor a picker
75171
75290
  // rendering the browser's own control ("default").
75172
- // Nor a bare one: the picker is that drawing's box to the pixel, so anything
75173
- // navi adds beside it either grows the box or covers what the caller drew.
75174
- // The pieces are the caller's to place there instead — a <Picker.Clear /> in
75175
- // their own layout (see warnOnClearableWithoutSlot).
75176
- const hasRightSlot = !picksNothing && rightSlot !== null && !isIcon && variant !== "headless" && variant !== "button" && variant !== "text" && variant !== "bare" && ui !== "default";
75291
+ // Nor a bare one, unless `chevron` says where: the picker is that drawing's
75292
+ // box to the pixel, so anything navi adds beside it either grows the box or
75293
+ // covers what the caller drew. The pieces are the caller's to place there
75294
+ // instead — a <Picker.Clear /> in their own layout (see
75295
+ // warnOnClearableWithoutSlot) — or the slot goes where the drawing is not:
75296
+ // after it, before it, or out of the flow altogether.
75297
+ const isBare = variant === "bare";
75298
+ const bareChevron = isBare && chevron !== undefined ? chevron : undefined;
75299
+ warnOnChevronOffBare(props, isBare);
75300
+ const hasRightSlot = !picksNothing && rightSlot !== null && !isIcon && variant !== "headless" && variant !== "button" && variant !== "text" && (!isBare || bareChevron !== undefined) && ui !== "default";
75177
75301
  warnOnClearableWithoutSlot(props, hasRightSlot);
75302
+ // How far the press must follow a hanging chevron: its size, as a length the
75303
+ // input's inset can add up. "inherit" is 1em of the picker's own font, which
75304
+ // the input shares (font: inherit), so the em the icon is drawn in and the
75305
+ // em the reach is measured in are the same.
75306
+ const hangingChevronSize = bareChevron === "hang-end" && hasRightSlot ? rightSlotIconSize === "inherit" ? "1em" : stringifyStyleValue(rightSlotIconSize, "fontSize") : undefined;
75178
75307
  const inputRef = useRef(null);
75179
75308
  const [pickerRemainingProps, inputProps, facadeChildrenProps] = useControlFacadeProps({
75180
75309
  ...props,
@@ -75258,6 +75387,7 @@ const PickerButton = props => {
75258
75387
  pseudoClasses: PICKER_BUTTON_PSEUDO_CLASSES,
75259
75388
  "data-variant": variant,
75260
75389
  "data-icon": isIcon ? "" : undefined,
75390
+ "data-chevron": hasRightSlot ? bareChevron : undefined,
75261
75391
  "navi-picker": "",
75262
75392
  "navi-single-line": isSingleLine ? "" : undefined,
75263
75393
  "navi-ui-custom": ui === "default" ? undefined : "",
@@ -75271,6 +75401,7 @@ const PickerButton = props => {
75271
75401
  rightSlotIcon: undefined,
75272
75402
  rightSlotIconSize: undefined,
75273
75403
  rightSlot: undefined,
75404
+ chevron: undefined,
75274
75405
  clearConfirm: undefined,
75275
75406
  picksNothing: undefined,
75276
75407
  openWhileReadOnly: undefined,
@@ -75307,6 +75438,9 @@ const PickerButton = props => {
75307
75438
  },
75308
75439
  children: [jsx("span", {
75309
75440
  className: "navi_picker_box",
75441
+ style: hangingChevronSize === undefined ? undefined : {
75442
+ "--x-picker-chevron-size": hangingChevronSize
75443
+ },
75310
75444
  children: jsxs(PickerContext.Provider, {
75311
75445
  value: pickerContext,
75312
75446
  children: [variant === "headless" ? null : jsx(LoadingOutline, {
@@ -75848,6 +75982,7 @@ const PickerFirstResolver = props => {
75848
75982
  * rightSlotIcon?: import("ignore:preact").ComponentChildren,
75849
75983
  * rightSlotIconSize?: number | string,
75850
75984
  * rightSlot?: import("ignore:preact").ComponentChildren,
75985
+ * chevron?: "end" | "start" | "hang-end",
75851
75986
  * clearConfirm?: string | import("ignore:preact").ComponentChildren,
75852
75987
  * message?: import("ignore:preact").ComponentChildren,
75853
75988
  * confirmLabel?: import("ignore:preact").ComponentChildren,
@@ -75948,7 +76083,7 @@ const PickerFirstResolver = props => {
75948
76083
  * a drawing that paints outside it on purpose — an affordance in the margin
75949
76084
  * beside it, out of the flow so the rest keeps its width — is drawn and
75950
76085
  * opens nothing; `pressPadding` is how far the press area follows it out
75951
- * there.
76086
+ * there. The chevron itself is the `chevron` prop's to draw and place.
75952
76087
  *
75953
76088
  * A drawing that follows what the picker HOLDS — the value the popup just
75954
76089
  * closed on, before the server has answered, the same state navi's own
@@ -76052,7 +76187,23 @@ const PickerFirstResolver = props => {
76052
76187
 
76053
76188
  * `variant="bare"` has no slot either, for the same reason turned around: the
76054
76189
  * picker is the drawing's box to the pixel, so nothing may be added beside it
76055
- * — the drawing holds what it needs (`<Picker.Clear />`) and places it.
76190
+ * — the drawing holds what it needs (`<Picker.Clear />`) and places it. Its
76191
+ * `chevron` prop is the exception: the slot, put where the drawing is not.
76192
+ * @param {"end"|"start"|"hang-end"} [chevron] `variant="bare"` only: the
76193
+ * picker draws no chevron beside the drawing, so nothing says it opens; this
76194
+ * draws one — the icon the right slot would hold, `rightSlotIcon` or the
76195
+ * chevron, at `rightSlotIconSize`, `slotSpacing` away from the drawing (xxs
76196
+ * by default), taking the clear cross's place under `clearable` like any
76197
+ * slot — and says where, so the drawing keeps the box it has when nothing
76198
+ * opens. Which side depends on where the drawing is anchored in its line.
76199
+ * `"end"`: after it, in the flow — a label with room after it. `"start"`:
76200
+ * before it — a label pushed against the right edge, which the chevron
76201
+ * would otherwise push left by its width. `"hang-end"`: after it and OUT of
76202
+ * the flow, in the margin beside the box — a drawing filling its whole
76203
+ * line; the press follows it out there by its size plus its gap, on top of
76204
+ * any `pressPaddingRight`. The chevron is drawn in `--picker-icon-color`
76205
+ * (`currentColor` here) and `--picker-icon-color-hover`; a dimmed one is
76206
+ * `--picker-icon-color: color-mix(in srgb, currentColor 55%, transparent)`.
76056
76207
  * @param {import("ignore:preact").ComponentChildren} [rightSlot] Same place, rendered
76057
76208
  * as-is: no `<Icon>` around it, nothing `aria-hidden`. This is where an
76058
76209
  * interactive right slot goes. `null` takes the slot away entirely — the
@@ -76354,6 +76505,18 @@ const warnOnClearableWithoutSlot = (props, hasRightSlot) => {
76354
76505
  }
76355
76506
  console.warn(`[navi] <Picker ${cause} clearable> — that leaves no right slot, so no cross is drawn. ` + `Draw it where it belongs instead: <Picker ${cause} ui={<YourDrawing>… <Picker.Clear /></YourDrawing>}>. ` + `It is the same cross, and it takes itself away when there is nothing left to clear.`);
76356
76507
  };
76508
+ let chevronOffBareWarned = false;
76509
+ const warnOnChevronOffBare = (props, isBare) => {
76510
+ const {
76511
+ chevron,
76512
+ variant
76513
+ } = props;
76514
+ if (chevron === undefined || isBare || chevronOffBareWarned) {
76515
+ return;
76516
+ }
76517
+ chevronOffBareWarned = true;
76518
+ console.warn(`[navi] <Picker variant="${variant}" chevron="${chevron}"> — \`chevron\` places the chevron of a bare picker, whose drawing has no slot beside it. ` + `This variant draws its chevron in its right slot already (rightSlotIcon, rightSlot to change it); \`chevron\` is ignored.`);
76519
+ };
76357
76520
  const warnOnUnknownPickerType = props => {
76358
76521
  const {
76359
76522
  type