@jsenv/navi 0.29.384 → 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
  }