@jsenv/navi 0.29.383 → 0.29.385

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.
@@ -4739,14 +4739,40 @@ const timeFromMinutes = (minutes) => {
4739
4739
 
4740
4740
  const padTwo$1 = (value) => String(value).padStart(2, "0");
4741
4741
 
4742
- // Maps validity type names → navi input type names.
4743
- // Numeric signal types must not fall through to the native type="number"
4744
- // (which adds spinner buttons and has poor UX) — they map to navi_number instead.
4745
- const VALIDITY_TYPE_TO_INPUT_TYPE = {
4742
+ // What a bound signal's type says is what its VALUE is (a validity type);
4743
+ // what a control's `type` says is what the control IS. This table is the whole
4744
+ // bridge between the two vocabularies: a value type with a row here asks for
4745
+ // that control, one without a row asks for nothing and the control keeps its
4746
+ // own default. "string" has no row on purpose — it is the value every typeless
4747
+ // control already holds — and a name only one side knows must never cross as
4748
+ // is: a control type nobody implements is a plain text field that writes an
4749
+ // object as "[object Object]" (see warnOnUnknownPickerType in picker.jsx).
4750
+ // Numeric value types map to navi_number rather than the native type="number"
4751
+ // (spinner buttons, poor UX).
4752
+ const CONTROL_TYPE_BY_SIGNAL_TYPE = {
4746
4753
  boolean: "checkbox",
4747
4754
  number: "navi_number",
4748
4755
  integer: "navi_number",
4756
+ float: "navi_number",
4757
+ ratio: "navi_number",
4758
+ longitude: "navi_number",
4759
+ latitude: "navi_number",
4760
+ second: "navi_number",
4761
+ minute: "navi_number",
4762
+ hour: "navi_number",
4763
+ year: "navi_number",
4749
4764
  percentage: "navi_percentage",
4765
+ date: "date",
4766
+ month: "month",
4767
+ week: "week",
4768
+ time: "time",
4769
+ datetime: "datetime",
4770
+ duration: "duration",
4771
+ color: "color",
4772
+ email: "email",
4773
+ url: "url",
4774
+ array: "array",
4775
+ object: "object",
4750
4776
  };
4751
4777
 
4752
4778
  // Conceptual navi types: defaults, plus the host type they resolve to.
@@ -4877,18 +4903,16 @@ const resolveInputProps = (props, { controlType = "input" } = {}) => {
4877
4903
  }
4878
4904
  }
4879
4905
  if (props.type === undefined && signalOptions.type !== undefined) {
4880
- const typeFromSignal =
4881
- VALIDITY_TYPE_TO_INPUT_TYPE[signalOptions.type] ?? signalOptions.type;
4882
- // What a signal says is what its value IS; what a control's `type` says
4883
- // is what the control is. They usually agree — a date-typed signal wants
4884
- // a date field — but a boolean one maps to a checkbox, and a picker made
4885
- // into a checkbox is not a picker with a different look: it is another
4886
- // control, with no popup to open. A picker asked to hold a yes/no keeps
4887
- // its two rows and stays itself.
4906
+ const typeFromSignal = CONTROL_TYPE_BY_SIGNAL_TYPE[signalOptions.type];
4907
+ // A value type and the control for it usually agree — a date-typed
4908
+ // signal wants a date field — but a boolean one maps to a checkbox, and
4909
+ // a picker made into a checkbox is not a picker with a different look:
4910
+ // it is another control, with no popup to open. A picker asked to hold
4911
+ // a yes/no keeps its two rows and stays itself.
4888
4912
  const wouldChangeWhatTheControlIs =
4889
4913
  controlType === "picker" &&
4890
4914
  (typeFromSignal === "checkbox" || typeFromSignal === "radio");
4891
- if (!wouldChangeWhatTheControlIs) {
4915
+ if (typeFromSignal !== undefined && !wouldChangeWhatTheControlIs) {
4892
4916
  props.type = typeFromSignal;
4893
4917
  }
4894
4918
  }
@@ -60190,10 +60214,12 @@ let releaseLiftInProgress = null;
60190
60214
  // cancelled with the movement so a finished one cannot go on applying its
60191
60215
  // last values to the next movement's picture.
60192
60216
  let boxAnimationInProgress = null;
60193
- // The page held still for the length of the movement. Its picture is frozen
60194
- // anyway, and the browser keeps following the live anchor: a scroll would
60195
- // carry the arriving box along under a page that does not move, and past the
60196
- // clip to the room between the bars, computed where the boxes stood.
60217
+ // The page held still from the first read about it to the end of the
60218
+ // movement. Its picture is frozen anyway, and the browser keeps following the
60219
+ // live anchor: a scroll would carry the arriving box along under a page that
60220
+ // does not move, and past the clip to the room between the bars, computed
60221
+ // where the boxes stood — and read once, before the opening waits for its
60222
+ // target (see liftPopupFromAnchor).
60197
60223
  let releaseScrollHold = null;
60198
60224
 
60199
60225
  /**
@@ -60219,11 +60245,20 @@ const liftPopupFromAnchor = (
60219
60245
  releaseLiftInProgress?.();
60220
60246
 
60221
60247
  const elementLeaving = opened ? resolveAnchor() : resolveLiftTarget(popupEl);
60222
- // Read before the first write: the read brings the style up to date, and a
60223
- // write before it would make it bring it up to date once more.
60248
+ // Everything read about the leaving side, before the first write. A read
60249
+ // brings the style up to date, and the writes below land on the root — an
60250
+ // attribute or an unregistered custom property there invalidates the
60251
+ // computed style of every element — so a read placed after any of them is
60252
+ // the whole document's style over again. Nothing on the leaving side moves
60253
+ // before the movement, the page being held from here on.
60254
+ releaseScrollHold = trapScrollInside(popupEl, { backdrop: true });
60224
60255
  const duration = getComputedStyle(popupEl)
60225
60256
  .getPropertyValue("--popup-animation-duration")
60226
60257
  .trim();
60258
+ const cornersLeaving = readCorners(elementLeaving);
60259
+ const room = measureRoomBetweenBars();
60260
+ const boxLeaving = elementLeaving.getBoundingClientRect();
60261
+ const paintLeaving = opened ? null : readBoxPaint(elementLeaving);
60227
60262
  const giveBackNameLeaving = wearLiftName(elementLeaving);
60228
60263
  const root = document.documentElement;
60229
60264
  root.setAttribute(ROOT_ATTRIBUTE, opened ? "opening" : "closing");
@@ -60234,11 +60269,10 @@ const liftPopupFromAnchor = (
60234
60269
  // browser's own pace.
60235
60270
  root.style.setProperty(DURATION_PROPERTY, duration);
60236
60271
  }
60237
- if (!opened) {
60238
- publishBoxPaint(elementLeaving);
60239
- }
60240
- const cornersLeaving = readCorners(elementLeaving);
60241
60272
  root.style.setProperty(BORDER_RADIUS_PROPERTY, cornersLeaving);
60273
+ if (paintLeaving) {
60274
+ publishBoxPaint(paintLeaving);
60275
+ }
60242
60276
 
60243
60277
  let giveBackNameArriving = null;
60244
60278
  let stopWaitingForTarget = null;
@@ -60270,10 +60304,6 @@ const liftPopupFromAnchor = (
60270
60304
  releaseLiftInProgress = release;
60271
60305
 
60272
60306
  const startMovement = (change, resolveElementArriving) => {
60273
- releaseScrollHold?.();
60274
- releaseScrollHold = trapScrollInside(popupEl, { backdrop: true });
60275
- const room = measureRoomBetweenBars();
60276
- const boxLeaving = elementLeaving.getBoundingClientRect();
60277
60307
  let boxArriving = null;
60278
60308
  let cornersArriving = null;
60279
60309
  const viewTransition = startViewTransition(async () => {
@@ -60342,7 +60372,9 @@ const liftPopupFromAnchor = (
60342
60372
  popupEl.removeAttribute(ARRIVING_ATTRIBUTE);
60343
60373
  };
60344
60374
  const liftTarget = (target) => {
60345
- publishBoxPaint(target);
60375
+ // The last write before the transition: nothing reads between it and the
60376
+ // style pass the browser makes on its own to take the first picture.
60377
+ publishBoxPaint(readBoxPaint(target));
60346
60378
  startMovement(reveal, () => target);
60347
60379
  };
60348
60380
  const targetNow = findLiftTarget(popupEl);
@@ -60360,10 +60392,16 @@ const liftPopupFromAnchor = (
60360
60392
  });
60361
60393
  };
60362
60394
 
60363
- const publishBoxPaint = (liftedElement) => {
60395
+ // Read and published apart, so that a closing can read the paint with the
60396
+ // rest of what it reads and write it with the rest of what it writes.
60397
+ const readBoxPaint = (liftedElement) => {
60364
60398
  const { backgroundColor, backgroundImage } = getComputedStyle(
60365
60399
  findPaintedBox(liftedElement),
60366
60400
  );
60401
+ return { backgroundColor, backgroundImage };
60402
+ };
60403
+
60404
+ const publishBoxPaint = ({ backgroundColor, backgroundImage }) => {
60367
60405
  const root = document.documentElement;
60368
60406
  root.style.setProperty(BACKGROUND_COLOR_PROPERTY, backgroundColor);
60369
60407
  root.style.setProperty(BACKGROUND_IMAGE_PROPERTY, backgroundImage);