@canonical/react-ds-global-form 0.36.0 → 0.38.0
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/README.md +40 -0
- package/dist/esm/density.css +320 -302
- package/dist/esm/docs/examples/density-examples.css +19 -14
- package/dist/esm/index.css +361 -335
- package/dist/esm/lib/_work_in_progress/DensityTestbed/baseline-system.css +71 -64
- package/dist/esm/lib/_work_in_progress/DensityTestbed/density.testbed.css +127 -123
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.css +73 -54
- package/dist/esm/lib/common/Wrapper/styles.css +35 -31
- package/dist/esm/lib/component/ChoicesField/common/Option/Option.js +4 -1
- package/dist/esm/lib/component/ChoicesField/common/Option/Option.js.map +1 -1
- package/dist/esm/lib/component/ChoicesField/styles.css +195 -163
- package/dist/esm/lib/component/RangeField/common/RangeControl/styles.css +39 -35
- package/dist/esm/lib/component/RichChoicesField/styles.css +93 -89
- package/dist/esm/lib/index.js +2 -0
- package/dist/esm/lib/index.js.map +1 -1
- package/dist/esm/lib/subcomponent/CheckboxInput/styles.css +115 -111
- package/dist/esm/lib/subcomponent/ColorInput/styles.css +177 -173
- package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js +2 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js.map +1 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/List/List.js +1 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/List/List.js.map +1 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/List/styles.css +33 -29
- package/dist/esm/lib/subcomponent/ComboboxInput/common/ResetButton/styles.css +21 -17
- package/dist/esm/lib/subcomponent/ComboboxInput/styles.css +59 -55
- package/dist/esm/lib/subcomponent/ComboboxInput/utils/index.js +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/utils/index.js.map +1 -1
- package/dist/esm/lib/subcomponent/DateInput/styles.css +23 -19
- package/dist/esm/lib/subcomponent/DateTimeInput/styles.css +24 -20
- package/dist/esm/lib/subcomponent/Field/Description/styles.css +9 -5
- package/dist/esm/lib/subcomponent/Field/Error/styles.css +9 -5
- package/dist/esm/lib/subcomponent/Field/Label/Label.js +2 -2
- package/dist/esm/lib/subcomponent/Field/Label/Label.js.map +1 -1
- package/dist/esm/lib/subcomponent/Field/Label/styles.css +25 -21
- package/dist/esm/lib/subcomponent/FileUploadInput/styles.css +125 -119
- package/dist/esm/lib/subcomponent/NumberInput/styles.css +32 -28
- package/dist/esm/lib/subcomponent/PasswordInput/styles.css +58 -54
- package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js +44 -20
- package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/PhoneInput/styles.css +53 -49
- package/dist/esm/lib/subcomponent/RadioInput/styles.css +70 -66
- package/dist/esm/lib/subcomponent/RangeInput/styles.css +74 -70
- package/dist/esm/lib/subcomponent/RatingInput/styles.css +132 -128
- package/dist/esm/lib/subcomponent/SelectInput/styles.css +44 -40
- package/dist/esm/lib/subcomponent/SwitchInput/styles.css +90 -86
- package/dist/esm/lib/subcomponent/TextInput/styles.css +30 -26
- package/dist/esm/lib/subcomponent/TextareaInput/styles.css +14 -10
- package/dist/esm/lib/subcomponent/TimeInput/styles.css +19 -15
- package/dist/esm/lib/utils/countries/index.js +3 -3
- package/dist/esm/lib/utils/countries/index.js.map +1 -1
- package/dist/esm/lib/utils/formatter/applyPattern.js +38 -0
- package/dist/esm/lib/utils/formatter/applyPattern.js.map +1 -0
- package/dist/esm/lib/utils/formatter/createFormatterRegisterOptions.js +22 -0
- package/dist/esm/lib/utils/formatter/createFormatterRegisterOptions.js.map +1 -0
- package/dist/esm/lib/utils/formatter/createPatternFormatter.js +25 -0
- package/dist/esm/lib/utils/formatter/createPatternFormatter.js.map +1 -0
- package/dist/esm/lib/utils/formatter/index.js +8 -0
- package/dist/esm/lib/utils/formatter/index.js.map +1 -0
- package/dist/esm/lib/utils/formatter/stripToDigits.js +12 -0
- package/dist/esm/lib/utils/formatter/stripToDigits.js.map +1 -0
- package/dist/esm/lib/utils/formatter/types.js +2 -0
- package/dist/esm/lib/utils/formatter/types.js.map +1 -0
- package/dist/esm/lib/utils/hooks/index.js +1 -0
- package/dist/esm/lib/utils/hooks/index.js.map +1 -1
- package/dist/esm/lib/utils/hooks/types.js +2 -0
- package/dist/esm/lib/utils/hooks/types.js.map +1 -0
- package/dist/esm/lib/utils/hooks/useFormattedValue.js +195 -0
- package/dist/esm/lib/utils/hooks/useFormattedValue.js.map +1 -0
- package/dist/esm/lib/utils/index.js +6 -2
- package/dist/esm/lib/utils/index.js.map +1 -1
- package/dist/esm/lib/utils/mergeRefs.js +25 -0
- package/dist/esm/lib/utils/mergeRefs.js.map +1 -0
- package/dist/esm/lib/utils/middleware/addRESTValidation.js +1 -1
- package/dist/esm/lib/utils/middleware/addRESTValidation.js.map +1 -1
- package/dist/types/lib/component/ChoicesField/common/Option/Option.d.ts.map +1 -1
- package/dist/types/lib/component/PhoneField/PhoneField.d.ts +2 -1
- package/dist/types/lib/component/PhoneField/PhoneField.d.ts.map +1 -1
- package/dist/types/lib/index.d.ts +4 -0
- package/dist/types/lib/index.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/ComboboxInput/SingleCombobox.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/ComboboxInput/utils/index.d.ts +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/utils/index.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/PhoneInput/PhoneInput.d.ts +19 -2
- package/dist/types/lib/subcomponent/PhoneInput/PhoneInput.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/PhoneInput/types.d.ts +20 -7
- package/dist/types/lib/subcomponent/PhoneInput/types.d.ts.map +1 -1
- package/dist/types/lib/utils/countries/index.d.ts +0 -3
- package/dist/types/lib/utils/countries/index.d.ts.map +1 -1
- package/dist/types/lib/utils/formatter/applyPattern.d.ts +17 -0
- package/dist/types/lib/utils/formatter/applyPattern.d.ts.map +1 -0
- package/dist/types/lib/utils/formatter/createFormatterRegisterOptions.d.ts +20 -0
- package/dist/types/lib/utils/formatter/createFormatterRegisterOptions.d.ts.map +1 -0
- package/dist/types/lib/utils/formatter/createPatternFormatter.d.ts +19 -0
- package/dist/types/lib/utils/formatter/createPatternFormatter.d.ts.map +1 -0
- package/dist/types/lib/utils/formatter/index.d.ts +6 -0
- package/dist/types/lib/utils/formatter/index.d.ts.map +1 -0
- package/dist/types/lib/utils/formatter/stripToDigits.d.ts +10 -0
- package/dist/types/lib/utils/formatter/stripToDigits.d.ts.map +1 -0
- package/dist/types/lib/utils/formatter/types.d.ts +30 -0
- package/dist/types/lib/utils/formatter/types.d.ts.map +1 -0
- package/dist/types/lib/utils/hooks/index.d.ts +2 -0
- package/dist/types/lib/utils/hooks/index.d.ts.map +1 -1
- package/dist/types/lib/utils/hooks/types.d.ts +33 -0
- package/dist/types/lib/utils/hooks/types.d.ts.map +1 -0
- package/dist/types/lib/utils/hooks/useFormattedValue.d.ts +30 -0
- package/dist/types/lib/utils/hooks/useFormattedValue.d.ts.map +1 -0
- package/dist/types/lib/utils/index.d.ts +2 -0
- package/dist/types/lib/utils/index.d.ts.map +1 -1
- package/dist/types/lib/utils/mergeRefs.d.ts +14 -0
- package/dist/types/lib/utils/mergeRefs.d.ts.map +1 -0
- package/package.json +17 -16
- package/dist/esm/lib/subcomponent/ComboboxInput/utils/mergeRefs.js +0 -12
- package/dist/esm/lib/subcomponent/ComboboxInput/utils/mergeRefs.js.map +0 -1
- package/dist/esm/lib/utils/countries/applyPhoneMask.js +0 -35
- package/dist/esm/lib/utils/countries/applyPhoneMask.js.map +0 -1
- package/dist/esm/lib/utils/countries/phoneRegisterOptions.js +0 -18
- package/dist/esm/lib/utils/countries/phoneRegisterOptions.js.map +0 -1
- package/dist/esm/lib/utils/countries/removePhoneMask.js +0 -12
- package/dist/esm/lib/utils/countries/removePhoneMask.js.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/utils/mergeRefs.d.ts +0 -3
- package/dist/types/lib/subcomponent/ComboboxInput/utils/mergeRefs.d.ts.map +0 -1
- package/dist/types/lib/utils/countries/applyPhoneMask.d.ts +0 -14
- package/dist/types/lib/utils/countries/applyPhoneMask.d.ts.map +0 -1
- package/dist/types/lib/utils/countries/phoneRegisterOptions.d.ts +0 -14
- package/dist/types/lib/utils/countries/phoneRegisterOptions.d.ts.map +0 -1
- package/dist/types/lib/utils/countries/removePhoneMask.d.ts +0 -10
- package/dist/types/lib/utils/countries/removePhoneMask.d.ts.map +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { Formatter } from "../formatter/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Prop and result types for the hooks in this folder.
|
|
5
|
+
*
|
|
6
|
+
* They live together rather than beside each hook so a hook's contract can be
|
|
7
|
+
* read without opening its implementation, and so a consumer typing a wrapper
|
|
8
|
+
* around one has a single import to reach for.
|
|
9
|
+
*/
|
|
10
|
+
export type UseFormattedValueProps = {
|
|
11
|
+
/**
|
|
12
|
+
* The model/view pair driving the input. `format` renders the model for
|
|
13
|
+
* display, `parse` recovers the model from what the user typed.
|
|
14
|
+
*/
|
|
15
|
+
formatter: Formatter;
|
|
16
|
+
/** The stored value — raw digits, for a phone number. */
|
|
17
|
+
model: string;
|
|
18
|
+
/** Called with the next model whenever the user edits the input. */
|
|
19
|
+
onModelChange: (next: string) => void;
|
|
20
|
+
};
|
|
21
|
+
export type UseFormattedValueResult = {
|
|
22
|
+
/** The formatted string to render as the input's `value`. */
|
|
23
|
+
value: string;
|
|
24
|
+
/** Change handler that keeps the model, the display, and the caret in step. */
|
|
25
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
26
|
+
/** Suspends reformatting while an IME composition is in progress. */
|
|
27
|
+
onCompositionStart: () => void;
|
|
28
|
+
/** Resumes reformatting and commits the composed text. */
|
|
29
|
+
onCompositionEnd: (event: React.CompositionEvent<HTMLInputElement>) => void;
|
|
30
|
+
/** Must reach the input element — the caret cannot be placed without it. */
|
|
31
|
+
ref: React.RefObject<HTMLInputElement | null>;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/utils/hooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;;;GAMG;AAEH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;OAGG;IACH,SAAS,EAAE,SAAS,CAAC;IAErB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IAEd,oEAAoE;IACpE,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IAEd,+EAA+E;IAC/E,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAE/D,qEAAqE;IACrE,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAE/B,0DAA0D;IAC1D,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAE5E,4EAA4E;IAC5E,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CAC/C,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { UseFormattedValueProps, UseFormattedValueResult } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Drive a text input whose displayed string is a formatted projection of the
|
|
4
|
+
* value it stores, without the caret jumping to the end on every keystroke.
|
|
5
|
+
*
|
|
6
|
+
* The naive spelling of this — `value={format(model)}` with an `onChange` that
|
|
7
|
+
* parses back — reformats the whole string on each edit, so React rewrites
|
|
8
|
+
* `input.value` and the browser drops the caret at the end. Editing anywhere but
|
|
9
|
+
* the end becomes impossible. This hook does the same projection but restores
|
|
10
|
+
* the caret afterwards, by position in the model rather than in the display.
|
|
11
|
+
*
|
|
12
|
+
* Composed text is rendered verbatim until `compositionend`, so an IME is never
|
|
13
|
+
* rewritten mid-composition.
|
|
14
|
+
*
|
|
15
|
+
* The value is owned by the caller: this hook never holds it in state, so it
|
|
16
|
+
* composes with react-hook-form, a `useState` above it, or any other source.
|
|
17
|
+
*
|
|
18
|
+
* The `formatter` must satisfy the contract on {@link Formatter} — in
|
|
19
|
+
* particular `parse(format(m)) === m`. A `parse` that truncates or is not a left
|
|
20
|
+
* inverse will strand the caret at the end and can make a deletion remove the
|
|
21
|
+
* wrong character.
|
|
22
|
+
*
|
|
23
|
+
* Only for inputs that support text selection. `setSelectionRange` throws on
|
|
24
|
+
* `type="number"` and `type="email"`.
|
|
25
|
+
*
|
|
26
|
+
* @note Impure — moves the caret on the element behind `ref`, which is the whole
|
|
27
|
+
* point of the hook and cannot be expressed as a return value.
|
|
28
|
+
*/
|
|
29
|
+
export default function useFormattedValue({ formatter, model, onModelChange, }: UseFormattedValueProps): UseFormattedValueResult;
|
|
30
|
+
//# sourceMappingURL=useFormattedValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormattedValue.d.ts","sourceRoot":"","sources":["../../../../../src/lib/utils/hooks/useFormattedValue.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AA+IpB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,SAAS,EACT,KAAK,EACL,aAAa,GACd,EAAE,sBAAsB,GAAG,uBAAuB,CAmFlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/index.ts"],"names":[],"mappings":"AAIA,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fan one element out to several refs, so a component can keep its own internal
|
|
3
|
+
* ref while still honouring a forwarded one. Accepts both callback refs and ref
|
|
4
|
+
* objects, and ignores `undefined` entries, so an optional forwarded ref can be
|
|
5
|
+
* passed straight through.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <input ref={mergeRefs(internalRef, forwardedRef)} />
|
|
9
|
+
*
|
|
10
|
+
* @note Pure — returns a new callback ref; the returned callback is impure by
|
|
11
|
+
* necessity, since assigning the element to each ref is its whole purpose.
|
|
12
|
+
*/
|
|
13
|
+
export default function mergeRefs<T>(...refs: (React.Ref<T> | undefined)[]): (instance: T | null) => void;
|
|
14
|
+
//# sourceMappingURL=mergeRefs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeRefs.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/mergeRefs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,EACjC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,GACpC,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAU9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-ds-global-form",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -37,31 +37,32 @@
|
|
|
37
37
|
"check:biome": "biome check",
|
|
38
38
|
"check:biome:fix": "biome check --write",
|
|
39
39
|
"check:ts": "tsc --noEmit",
|
|
40
|
-
"storybook": "storybook dev -p
|
|
40
|
+
"storybook": "storybook dev -p 6007 --no-open --host 0.0.0.0",
|
|
41
41
|
"test": "bun run test:vitest",
|
|
42
42
|
"test:vitest": "vitest run",
|
|
43
43
|
"test:vitest:watch": "vitest"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@canonical/
|
|
47
|
-
"@canonical/
|
|
48
|
-
"@canonical/
|
|
49
|
-
"@canonical/
|
|
46
|
+
"@canonical/ds-utils": "^0.38.0",
|
|
47
|
+
"@canonical/react-ds-global": "^0.38.0",
|
|
48
|
+
"@canonical/storybook-config": "^0.38.0",
|
|
49
|
+
"@canonical/styles": "^0.38.0",
|
|
50
|
+
"@canonical/utils": "^0.38.0",
|
|
50
51
|
"downshift": "^9.3.2",
|
|
51
52
|
"react": "^19.2.4",
|
|
52
53
|
"react-dom": "^19.2.4",
|
|
53
54
|
"react-hook-form": "^7.71.2"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
|
-
"@biomejs/biome": "2.
|
|
57
|
-
"@canonical/biome-config": "^0.
|
|
58
|
-
"@canonical/design-tokens": "0.
|
|
59
|
-
"@canonical/storybook-addon-form-state": "^0.
|
|
60
|
-
"@canonical/storybook-addon-msw": "^0.
|
|
61
|
-
"@canonical/storybook-helpers": "^0.
|
|
62
|
-
"@canonical/typescript-config-react": "^0.
|
|
63
|
-
"@canonical/vitest-config-react": "^0.
|
|
64
|
-
"@canonical/webarchitect": "^0.
|
|
57
|
+
"@biomejs/biome": "2.5.13",
|
|
58
|
+
"@canonical/biome-config": "^0.38.0",
|
|
59
|
+
"@canonical/design-tokens": "0.10.0",
|
|
60
|
+
"@canonical/storybook-addon-form-state": "^0.38.0",
|
|
61
|
+
"@canonical/storybook-addon-msw": "^0.38.0",
|
|
62
|
+
"@canonical/storybook-helpers": "^0.38.0",
|
|
63
|
+
"@canonical/typescript-config-react": "^0.38.0",
|
|
64
|
+
"@canonical/vitest-config-react": "^0.38.0",
|
|
65
|
+
"@canonical/webarchitect": "^0.38.0",
|
|
65
66
|
"@chromatic-com/storybook": "^5.0.1",
|
|
66
67
|
"@storybook/addon-docs": "^10.3.1",
|
|
67
68
|
"@storybook/react-vite": "^10.3.1",
|
|
@@ -81,5 +82,5 @@
|
|
|
81
82
|
"vite": "^8.0.1",
|
|
82
83
|
"vitest": "^4.0.18"
|
|
83
84
|
},
|
|
84
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "4d10a68a9b299af6fe3d1d7d053e54ca128944ad"
|
|
85
86
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const mergeRefs = (...refs) => (instance) => {
|
|
2
|
-
for (const ref of refs) {
|
|
3
|
-
if (typeof ref === "function") {
|
|
4
|
-
ref(instance);
|
|
5
|
-
}
|
|
6
|
-
else if (ref) {
|
|
7
|
-
ref.current = instance;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
export default mergeRefs;
|
|
12
|
-
//# sourceMappingURL=mergeRefs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mergeRefs.js","sourceRoot":"","sources":["../../../../../../src/lib/subcomponent/ComboboxInput/utils/mergeRefs.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GACb,CAAI,GAAG,IAAkC,EAAE,EAAE,CAC7C,CAAC,QAAkB,EAAE,EAAE;IACrB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;YAC9B,GAAG,CAAC,QAAQ,CAAC,CAAC;QAChB,CAAC;aAAM,IAAI,GAAG,EAAE,CAAC;YACd,GAAiC,CAAC,OAAO,GAAG,QAAQ,CAAC;QACxD,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEJ,eAAe,SAAS,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Apply a national-number display mask to a raw value (cosmetic only).
|
|
3
|
-
*
|
|
4
|
-
* The mask uses `#` as a digit slot; any other character is a literal separator
|
|
5
|
-
* emitted between digits (e.g. `"(###) ###-####"`). Non-digits in `value` are
|
|
6
|
-
* stripped first, so the result is purely a function of the typed digits. Extra
|
|
7
|
-
* digits beyond the mask length are appended unformatted (so longer-than-typical
|
|
8
|
-
* numbers are never truncated). With no mask, the raw digits are returned.
|
|
9
|
-
*
|
|
10
|
-
* This is display-only — callers keep the raw digits as the source of truth.
|
|
11
|
-
* @note Pure.
|
|
12
|
-
*/
|
|
13
|
-
export default function applyPhoneMask(value, format) {
|
|
14
|
-
const digits = value.replace(/\D/g, "");
|
|
15
|
-
if (!format)
|
|
16
|
-
return digits;
|
|
17
|
-
let out = "";
|
|
18
|
-
let d = 0;
|
|
19
|
-
for (const char of format) {
|
|
20
|
-
if (d >= digits.length)
|
|
21
|
-
break;
|
|
22
|
-
if (char === "#") {
|
|
23
|
-
out += digits[d];
|
|
24
|
-
d += 1;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
out += char;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
// Any digits beyond the mask's slots are appended raw (never dropped).
|
|
31
|
-
if (d < digits.length)
|
|
32
|
-
out += digits.slice(d);
|
|
33
|
-
return out;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=applyPhoneMask.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"applyPhoneMask.js","sourceRoot":"","sources":["../../../../../src/lib/utils/countries/applyPhoneMask.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAa,EAAE,MAAe;IACnE,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACxC,IAAI,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC;IAE3B,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM;YAAE,MAAM;QAC9B,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACjB,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC,IAAI,CAAC,CAAC;QACT,CAAC;aAAM,CAAC;YACN,GAAG,IAAI,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,uEAAuE;IACvE,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM;QAAE,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC9C,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import removePhoneMask from "./removePhoneMask.js";
|
|
2
|
-
/**
|
|
3
|
-
* react-hook-form `register()` options that strip any phone display mask so the
|
|
4
|
-
* registered/submitted value is always raw digits, regardless of how the input
|
|
5
|
-
* is formatted on screen. Spread into `register(name, phoneRegisterOptions())`,
|
|
6
|
-
* or merge with your own rules.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* <input {...register("phone", phoneRegisterOptions())} />
|
|
10
|
-
*
|
|
11
|
-
* @note Pure.
|
|
12
|
-
*/
|
|
13
|
-
export default function phoneRegisterOptions() {
|
|
14
|
-
return {
|
|
15
|
-
setValueAs: (value) => removePhoneMask(String(value ?? "")),
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=phoneRegisterOptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"phoneRegisterOptions.js","sourceRoot":"","sources":["../../../../../src/lib/utils/countries/phoneRegisterOptions.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB;IAC1C,OAAO;QACL,UAAU,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;KACrE,CAAC;AACJ,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Strip a phone display mask back to raw digits — the inverse of
|
|
3
|
-
* {@link applyPhoneMask}. Removes every non-digit (separators, spaces, dashes,
|
|
4
|
-
* parens), leaving only the national-number digits. Use it to derive the
|
|
5
|
-
* submitted/registered value from a masked display string.
|
|
6
|
-
*
|
|
7
|
-
* @note Pure.
|
|
8
|
-
*/
|
|
9
|
-
export default function removePhoneMask(value) {
|
|
10
|
-
return value.replace(/\D/g, "");
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=removePhoneMask.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"removePhoneMask.js","sourceRoot":"","sources":["../../../../../src/lib/utils/countries/removePhoneMask.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAa;IACnD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mergeRefs.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/subcomponent/ComboboxInput/utils/mergeRefs.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,SAAS,GACZ,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,MACxC,UAAU,CAAC,GAAG,IAAI,SAQlB,CAAC;AAEJ,eAAe,SAAS,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Apply a national-number display mask to a raw value (cosmetic only).
|
|
3
|
-
*
|
|
4
|
-
* The mask uses `#` as a digit slot; any other character is a literal separator
|
|
5
|
-
* emitted between digits (e.g. `"(###) ###-####"`). Non-digits in `value` are
|
|
6
|
-
* stripped first, so the result is purely a function of the typed digits. Extra
|
|
7
|
-
* digits beyond the mask length are appended unformatted (so longer-than-typical
|
|
8
|
-
* numbers are never truncated). With no mask, the raw digits are returned.
|
|
9
|
-
*
|
|
10
|
-
* This is display-only — callers keep the raw digits as the source of truth.
|
|
11
|
-
* @note Pure.
|
|
12
|
-
*/
|
|
13
|
-
export default function applyPhoneMask(value: string, format?: string): string;
|
|
14
|
-
//# sourceMappingURL=applyPhoneMask.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"applyPhoneMask.d.ts","sourceRoot":"","sources":["../../../../../src/lib/utils/countries/applyPhoneMask.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAkB7E"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { RegisterOptions } from "react-hook-form";
|
|
2
|
-
/**
|
|
3
|
-
* react-hook-form `register()` options that strip any phone display mask so the
|
|
4
|
-
* registered/submitted value is always raw digits, regardless of how the input
|
|
5
|
-
* is formatted on screen. Spread into `register(name, phoneRegisterOptions())`,
|
|
6
|
-
* or merge with your own rules.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* <input {...register("phone", phoneRegisterOptions())} />
|
|
10
|
-
*
|
|
11
|
-
* @note Pure.
|
|
12
|
-
*/
|
|
13
|
-
export default function phoneRegisterOptions(): RegisterOptions;
|
|
14
|
-
//# sourceMappingURL=phoneRegisterOptions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"phoneRegisterOptions.d.ts","sourceRoot":"","sources":["../../../../../src/lib/utils/countries/phoneRegisterOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,IAAI,eAAe,CAI9D"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Strip a phone display mask back to raw digits — the inverse of
|
|
3
|
-
* {@link applyPhoneMask}. Removes every non-digit (separators, spaces, dashes,
|
|
4
|
-
* parens), leaving only the national-number digits. Use it to derive the
|
|
5
|
-
* submitted/registered value from a masked display string.
|
|
6
|
-
*
|
|
7
|
-
* @note Pure.
|
|
8
|
-
*/
|
|
9
|
-
export default function removePhoneMask(value: string): string;
|
|
10
|
-
//# sourceMappingURL=removePhoneMask.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"removePhoneMask.d.ts","sourceRoot":"","sources":["../../../../../src/lib/utils/countries/removePhoneMask.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7D"}
|