@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.
@@ -4900,14 +4900,40 @@ const timeFromMinutes = (minutes) => {
4900
4900
 
4901
4901
  const padTwo$1 = (value) => String(value).padStart(2, "0");
4902
4902
 
4903
- // Maps validity type names → navi input type names.
4904
- // Numeric signal types must not fall through to the native type="number"
4905
- // (which adds spinner buttons and has poor UX) — they map to navi_number instead.
4906
- const VALIDITY_TYPE_TO_INPUT_TYPE = {
4903
+ // What a bound signal's type says is what its VALUE is (a validity type);
4904
+ // what a control's `type` says is what the control IS. This table is the whole
4905
+ // bridge between the two vocabularies: a value type with a row here asks for
4906
+ // that control, one without a row asks for nothing and the control keeps its
4907
+ // own default. "string" has no row on purpose — it is the value every typeless
4908
+ // control already holds — and a name only one side knows must never cross as
4909
+ // is: a control type nobody implements is a plain text field that writes an
4910
+ // object as "[object Object]" (see warnOnUnknownPickerType in picker.jsx).
4911
+ // Numeric value types map to navi_number rather than the native type="number"
4912
+ // (spinner buttons, poor UX).
4913
+ const CONTROL_TYPE_BY_SIGNAL_TYPE = {
4907
4914
  boolean: "checkbox",
4908
4915
  number: "navi_number",
4909
4916
  integer: "navi_number",
4917
+ float: "navi_number",
4918
+ ratio: "navi_number",
4919
+ longitude: "navi_number",
4920
+ latitude: "navi_number",
4921
+ second: "navi_number",
4922
+ minute: "navi_number",
4923
+ hour: "navi_number",
4924
+ year: "navi_number",
4910
4925
  percentage: "navi_percentage",
4926
+ date: "date",
4927
+ month: "month",
4928
+ week: "week",
4929
+ time: "time",
4930
+ datetime: "datetime",
4931
+ duration: "duration",
4932
+ color: "color",
4933
+ email: "email",
4934
+ url: "url",
4935
+ array: "array",
4936
+ object: "object",
4911
4937
  };
4912
4938
 
4913
4939
  // Conceptual navi types: defaults, plus the host type they resolve to.
@@ -5038,18 +5064,16 @@ const resolveInputProps = (props, { controlType = "input" } = {}) => {
5038
5064
  }
5039
5065
  }
5040
5066
  if (props.type === undefined && signalOptions.type !== undefined) {
5041
- const typeFromSignal =
5042
- VALIDITY_TYPE_TO_INPUT_TYPE[signalOptions.type] ?? signalOptions.type;
5043
- // What a signal says is what its value IS; what a control's `type` says
5044
- // is what the control is. They usually agree — a date-typed signal wants
5045
- // a date field — but a boolean one maps to a checkbox, and a picker made
5046
- // into a checkbox is not a picker with a different look: it is another
5047
- // control, with no popup to open. A picker asked to hold a yes/no keeps
5048
- // its two rows and stays itself.
5067
+ const typeFromSignal = CONTROL_TYPE_BY_SIGNAL_TYPE[signalOptions.type];
5068
+ // A value type and the control for it usually agree — a date-typed
5069
+ // signal wants a date field — but a boolean one maps to a checkbox, and
5070
+ // a picker made into a checkbox is not a picker with a different look:
5071
+ // it is another control, with no popup to open. A picker asked to hold
5072
+ // a yes/no keeps its two rows and stays itself.
5049
5073
  const wouldChangeWhatTheControlIs =
5050
5074
  controlType === "picker" &&
5051
5075
  (typeFromSignal === "checkbox" || typeFromSignal === "radio");
5052
- if (!wouldChangeWhatTheControlIs) {
5076
+ if (typeFromSignal !== undefined && !wouldChangeWhatTheControlIs) {
5053
5077
  props.type = typeFromSignal;
5054
5078
  }
5055
5079
  }
@@ -61403,10 +61427,12 @@ let releaseLiftInProgress = null;
61403
61427
  // cancelled with the movement so a finished one cannot go on applying its
61404
61428
  // last values to the next movement's picture.
61405
61429
  let boxAnimationInProgress = null;
61406
- // The page held still for the length of the movement. Its picture is frozen
61407
- // anyway, and the browser keeps following the live anchor: a scroll would
61408
- // carry the arriving box along under a page that does not move, and past the
61409
- // clip to the room between the bars, computed where the boxes stood.
61430
+ // The page held still from the first read about it to the end of the
61431
+ // movement. Its picture is frozen anyway, and the browser keeps following the
61432
+ // live anchor: a scroll would carry the arriving box along under a page that
61433
+ // does not move, and past the clip to the room between the bars, computed
61434
+ // where the boxes stood — and read once, before the opening waits for its
61435
+ // target (see liftPopupFromAnchor).
61410
61436
  let releaseScrollHold = null;
61411
61437
 
61412
61438
  /**
@@ -61432,11 +61458,20 @@ const liftPopupFromAnchor = (
61432
61458
  releaseLiftInProgress?.();
61433
61459
 
61434
61460
  const elementLeaving = opened ? resolveAnchor() : resolveLiftTarget(popupEl);
61435
- // Read before the first write: the read brings the style up to date, and a
61436
- // write before it would make it bring it up to date once more.
61461
+ // Everything read about the leaving side, before the first write. A read
61462
+ // brings the style up to date, and the writes below land on the root — an
61463
+ // attribute or an unregistered custom property there invalidates the
61464
+ // computed style of every element — so a read placed after any of them is
61465
+ // the whole document's style over again. Nothing on the leaving side moves
61466
+ // before the movement, the page being held from here on.
61467
+ releaseScrollHold = trapScrollInside(popupEl, { backdrop: true });
61437
61468
  const duration = getComputedStyle(popupEl)
61438
61469
  .getPropertyValue("--popup-animation-duration")
61439
61470
  .trim();
61471
+ const cornersLeaving = readCorners(elementLeaving);
61472
+ const room = measureRoomBetweenBars();
61473
+ const boxLeaving = elementLeaving.getBoundingClientRect();
61474
+ const paintLeaving = opened ? null : readBoxPaint(elementLeaving);
61440
61475
  const giveBackNameLeaving = wearLiftName(elementLeaving);
61441
61476
  const root = document.documentElement;
61442
61477
  root.setAttribute(ROOT_ATTRIBUTE, opened ? "opening" : "closing");
@@ -61447,11 +61482,10 @@ const liftPopupFromAnchor = (
61447
61482
  // browser's own pace.
61448
61483
  root.style.setProperty(DURATION_PROPERTY, duration);
61449
61484
  }
61450
- if (!opened) {
61451
- publishBoxPaint(elementLeaving);
61452
- }
61453
- const cornersLeaving = readCorners(elementLeaving);
61454
61485
  root.style.setProperty(BORDER_RADIUS_PROPERTY, cornersLeaving);
61486
+ if (paintLeaving) {
61487
+ publishBoxPaint(paintLeaving);
61488
+ }
61455
61489
 
61456
61490
  let giveBackNameArriving = null;
61457
61491
  let stopWaitingForTarget = null;
@@ -61483,10 +61517,6 @@ const liftPopupFromAnchor = (
61483
61517
  releaseLiftInProgress = release;
61484
61518
 
61485
61519
  const startMovement = (change, resolveElementArriving) => {
61486
- releaseScrollHold?.();
61487
- releaseScrollHold = trapScrollInside(popupEl, { backdrop: true });
61488
- const room = measureRoomBetweenBars();
61489
- const boxLeaving = elementLeaving.getBoundingClientRect();
61490
61520
  let boxArriving = null;
61491
61521
  let cornersArriving = null;
61492
61522
  const viewTransition = startViewTransition(async () => {
@@ -61567,7 +61597,9 @@ const liftPopupFromAnchor = (
61567
61597
  if (lift === "box") {
61568
61598
  warnDrawingLiftedAsBox(target);
61569
61599
  }
61570
- publishBoxPaint(target);
61600
+ // The last write before the transition: nothing reads between it and the
61601
+ // style pass the browser makes on its own to take the first picture.
61602
+ publishBoxPaint(readBoxPaint(target));
61571
61603
  startMovement(reveal, () => target);
61572
61604
  };
61573
61605
  const targetNow = findLiftTarget(popupEl);
@@ -61608,10 +61640,16 @@ const warnDrawingLiftedAsBox = (liftedElement) => {
61608
61640
  }
61609
61641
  };
61610
61642
 
61611
- const publishBoxPaint = (liftedElement) => {
61643
+ // Read and published apart, so that a closing can read the paint with the
61644
+ // rest of what it reads and write it with the rest of what it writes.
61645
+ const readBoxPaint = (liftedElement) => {
61612
61646
  const { backgroundColor, backgroundImage } = getComputedStyle(
61613
61647
  findPaintedBox(liftedElement),
61614
61648
  );
61649
+ return { backgroundColor, backgroundImage };
61650
+ };
61651
+
61652
+ const publishBoxPaint = ({ backgroundColor, backgroundImage }) => {
61615
61653
  const root = document.documentElement;
61616
61654
  root.style.setProperty(BACKGROUND_COLOR_PROPERTY, backgroundColor);
61617
61655
  root.style.setProperty(BACKGROUND_IMAGE_PROPERTY, backgroundImage);