@jsenv/navi 0.27.47 → 0.27.49

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.
@@ -15447,7 +15447,12 @@ const asControlHostValue = (
15447
15447
  if (type === "datetime-local") {
15448
15448
  return asDatetimeLocalString(jsValue);
15449
15449
  }
15450
- if (type === "number" || type === "range" || inputMode === "numeric") {
15450
+ if (
15451
+ type === "number" ||
15452
+ type === "range" ||
15453
+ inputMode === "numeric" ||
15454
+ inputMode === "decimal"
15455
+ ) {
15451
15456
  return asNumberString(jsValue);
15452
15457
  }
15453
15458
  if (type === "color") {
@@ -15521,7 +15526,8 @@ const readControlValue = (controlHost) => {
15521
15526
  if (
15522
15527
  type === "number" ||
15523
15528
  type === "range" ||
15524
- controlHost.inputMode === "numeric"
15529
+ controlHost.inputMode === "numeric" ||
15530
+ controlHost.inputMode === "decimal"
15525
15531
  ) {
15526
15532
  return readNumberFromInput(controlHost);
15527
15533
  }
@@ -19426,7 +19432,11 @@ const REQUIRED_CONSTRAINT = {
19426
19432
  return naviI18n("constraint.required.time");
19427
19433
  }
19428
19434
  const inputMode = field.controlHostProps.inputMode;
19429
- if (type === "number" || inputMode === "numeric") {
19435
+ if (
19436
+ type === "number" ||
19437
+ inputMode === "numeric" ||
19438
+ inputMode === "decimal"
19439
+ ) {
19430
19440
  return naviI18n("constraint.required.number");
19431
19441
  }
19432
19442
  if (type === "datetime-local") {
@@ -19587,7 +19597,8 @@ const MAX_LENGTH_CONSTRAINT = {
19587
19597
  } else if (!isTextarea) {
19588
19598
  return null;
19589
19599
  }
19590
- const maxLength = field.controlHostProps.maxLength ?? field.props?.maxLengthGuard;
19600
+ const maxLength =
19601
+ field.controlHostProps.maxLength ?? field.props?.maxLengthGuard;
19591
19602
  if (maxLength === undefined) {
19592
19603
  return null;
19593
19604
  }
@@ -19630,7 +19641,8 @@ const TYPE_NUMBER_CONSTRAINT = {
19630
19641
  }
19631
19642
  const type = field.controlHostProps.type;
19632
19643
  const inputMode = field.controlHostProps.inputMode;
19633
- const isNumber = type === "number" || inputMode === "numeric";
19644
+ const isNumber =
19645
+ type === "number" || inputMode === "numeric" || inputMode === "decimal";
19634
19646
  if (!isNumber) {
19635
19647
  return null;
19636
19648
  }
@@ -19711,7 +19723,8 @@ const MIN_CONSTRAINT = {
19711
19723
  if (!valueAsString) {
19712
19724
  return null;
19713
19725
  }
19714
- const isNumber = type === "number" || inputMode === "numeric";
19726
+ const isNumber =
19727
+ type === "number" || inputMode === "numeric" || inputMode === "decimal";
19715
19728
  if (isNumber) {
19716
19729
  const minNumber = parseFloat(minString);
19717
19730
  if (isNaN(minNumber)) {
@@ -19818,7 +19831,8 @@ const MAX_CONSTRAINT = {
19818
19831
  if (!valueAsString) {
19819
19832
  return null;
19820
19833
  }
19821
- const isNumber = type === "number" || inputMode === "numeric";
19834
+ const isNumber =
19835
+ type === "number" || inputMode === "numeric" || inputMode === "decimal";
19822
19836
  if (isNumber) {
19823
19837
  const maxNumber = parseFloat(maxString);
19824
19838
  if (isNaN(maxNumber)) {
@@ -19940,7 +19954,8 @@ const STEP_CONSTRAINT = {
19940
19954
  }
19941
19955
  const type = field.controlHostProps.type;
19942
19956
  const inputMode = field.controlHostProps.inputMode;
19943
- const isNumericText = type === "text" && inputMode === "numeric";
19957
+ const isNumericText =
19958
+ type === "text" && (inputMode === "numeric" || inputMode === "decimal");
19944
19959
  if (!isNumericText && !STEP_SUPPORTED_TYPE_SET.has(type)) {
19945
19960
  return null;
19946
19961
  }
@@ -21279,7 +21294,7 @@ const isAncestorOpen = (ancestor) => {
21279
21294
  * the browser's built-in scroll-into-view that accompanies focus.
21280
21295
  * @param {boolean} [options.focusVisible]
21281
21296
  * Passed as `focusVisible` to `element.focus()`.
21282
- * @param {boolean} [options.autoSelect]
21297
+ * @param {boolean} [options.autoFocusSelect]
21283
21298
  * When true, also calls `element.select()` after focusing (useful for text inputs).
21284
21299
  * @returns {Function} triggerAutofocus — can be called manually with a synthetic
21285
21300
  * event to re-run the focus logic outside of the layout-effect lifecycle.
@@ -21392,7 +21407,7 @@ const useAutoFocus = (
21392
21407
  ? ""
21393
21408
  : autoFocus
21394
21409
  : undefined,
21395
- "navi-autofocus-select": autoFocus && autoSelect ? "" : undefined,
21410
+ "navi-autofocus-select": autoSelect ? "" : undefined,
21396
21411
  };
21397
21412
  };
21398
21413
 
@@ -21909,7 +21924,7 @@ const CONTROL_PROP_SET = new Set([
21909
21924
 
21910
21925
  "autoFocus",
21911
21926
  "autoFocusVisible",
21912
- "autoSelect",
21927
+ "autoFocusSelect",
21913
21928
 
21914
21929
  "onMouseDown",
21915
21930
  "onClick",
@@ -24573,11 +24588,11 @@ const useInteractiveProps = (props, {
24573
24588
  const {
24574
24589
  autoFocus,
24575
24590
  autoFocusVisible,
24576
- autoSelect
24591
+ autoFocusSelect
24577
24592
  } = props;
24578
24593
  const autoFocusProps = useAutoFocus(ref, autoFocus, {
24579
24594
  focusVisible: autoFocusVisible,
24580
- autoSelect
24595
+ autoSelect: autoFocusSelect
24581
24596
  });
24582
24597
  Object.assign(controlHostProps, autoFocusProps);
24583
24598
  }
@@ -32124,7 +32139,6 @@ const NAVI_TYPE_DEFAULTS = {
32124
32139
  },
32125
32140
  navi_number: {
32126
32141
  type: "text",
32127
- inputMode: "numeric",
32128
32142
  autoCorrect: "off",
32129
32143
  spellcheck: false,
32130
32144
  autoComplete: "off",
@@ -32203,6 +32217,16 @@ const resolveInputProps = (props) => {
32203
32217
  if (!currentTypeDefaults) {
32204
32218
  return;
32205
32219
  }
32220
+ // For navi_number: choose inputMode based on whether step/min/max suggest decimals.
32221
+ // inputMode="numeric" (integer keyboard) vs "decimal" (keyboard with decimal separator).
32222
+ if (currentType === "navi_number" && props.inputMode === undefined) {
32223
+ props.inputMode =
32224
+ hasDecimalPlaces(props.step) ||
32225
+ hasDecimalPlaces(props.min) ||
32226
+ hasDecimalPlaces(props.max)
32227
+ ? "decimal"
32228
+ : "numeric";
32229
+ }
32206
32230
  for (const key of Object.keys(currentTypeDefaults)) {
32207
32231
  if (props[key] === undefined) {
32208
32232
  props[key] = currentTypeDefaults[key];
@@ -32297,6 +32321,14 @@ const STEP_FORMATTER_BY_TYPE = {
32297
32321
  "datetime": timeStringToSeconds,
32298
32322
  };
32299
32323
 
32324
+ const hasDecimalPlaces = (value) => {
32325
+ if (value === undefined || value === null) {
32326
+ return false;
32327
+ }
32328
+ const num = Number(value);
32329
+ return !isNaN(num) && !Number.isInteger(num);
32330
+ };
32331
+
32300
32332
  installImportMetaCssBuild(import.meta);const css$y = /* css */`
32301
32333
  @layer navi {
32302
32334
  .navi_input_range {
@@ -32669,7 +32701,7 @@ const RangePseudoElements = ["::-navi-loader"];
32669
32701
 
32670
32702
  const InputModeResolver = props => {
32671
32703
  const Next = useNextResolver();
32672
- if (props.inputMode === "numeric") {
32704
+ if (props.inputMode === "numeric" || props.inputMode === "decimal") {
32673
32705
  return jsx(InputModeNumeric, {
32674
32706
  ...props
32675
32707
  });
@@ -33853,7 +33885,7 @@ const Editable = props => {
33853
33885
  maxLength,
33854
33886
  pattern,
33855
33887
  wrapperProps,
33856
- autoSelect = true,
33888
+ autoFocusSelect = true,
33857
33889
  width,
33858
33890
  height,
33859
33891
  ...rest
@@ -33898,7 +33930,7 @@ const Editable = props => {
33898
33930
  valueSignal: valueSignal,
33899
33931
  autoFocus: editing,
33900
33932
  autoFocusVisible: true,
33901
- autoSelect: autoSelect,
33933
+ autoFocusSelect: autoFocusSelect,
33902
33934
  cancelOnEscape: true,
33903
33935
  cancelOnBlurInvalid: true,
33904
33936
  constraints: constraints,
@@ -35087,7 +35119,11 @@ const InputDurationPart = ({
35087
35119
  return jsxs(Label, {
35088
35120
  flex: "y",
35089
35121
  "data-separator": separator || undefined,
35090
- children: [jsx(Input, {
35122
+ children: [jsx(Input
35123
+ // When autofocused this field should be selected
35124
+ // this help to modify the value on mobile
35125
+ , {
35126
+ autoFocusSelect: true,
35091
35127
  type: "navi_number",
35092
35128
  "navi-input-type": unit,
35093
35129
  name: unit,