@jsenv/navi 0.27.47 → 0.27.48
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.
- package/dist/jsenv_navi.js +47 -11
- package/dist/jsenv_navi.js.map +8 -9
- package/package.json +2 -2
package/dist/jsenv_navi.js
CHANGED
|
@@ -15447,7 +15447,12 @@ const asControlHostValue = (
|
|
|
15447
15447
|
if (type === "datetime-local") {
|
|
15448
15448
|
return asDatetimeLocalString(jsValue);
|
|
15449
15449
|
}
|
|
15450
|
-
if (
|
|
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 (
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
}
|
|
@@ -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
|
});
|
|
@@ -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
|
+
autoSelect: true,
|
|
35091
35127
|
type: "navi_number",
|
|
35092
35128
|
"navi-input-type": unit,
|
|
35093
35129
|
name: unit,
|