@canonical/react-ds-global-form 0.35.0 → 0.37.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.
Files changed (86) hide show
  1. package/dist/esm/lib/index.js +2 -0
  2. package/dist/esm/lib/index.js.map +1 -1
  3. package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js +2 -1
  4. package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js.map +1 -1
  5. package/dist/esm/lib/subcomponent/ComboboxInput/common/List/List.js +1 -1
  6. package/dist/esm/lib/subcomponent/ComboboxInput/common/List/List.js.map +1 -1
  7. package/dist/esm/lib/subcomponent/ComboboxInput/utils/index.js +0 -1
  8. package/dist/esm/lib/subcomponent/ComboboxInput/utils/index.js.map +1 -1
  9. package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js +44 -20
  10. package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js.map +1 -1
  11. package/dist/esm/lib/utils/countries/index.js +3 -3
  12. package/dist/esm/lib/utils/countries/index.js.map +1 -1
  13. package/dist/esm/lib/utils/formatter/applyPattern.js +38 -0
  14. package/dist/esm/lib/utils/formatter/applyPattern.js.map +1 -0
  15. package/dist/esm/lib/utils/formatter/createFormatterRegisterOptions.js +22 -0
  16. package/dist/esm/lib/utils/formatter/createFormatterRegisterOptions.js.map +1 -0
  17. package/dist/esm/lib/utils/formatter/createPatternFormatter.js +25 -0
  18. package/dist/esm/lib/utils/formatter/createPatternFormatter.js.map +1 -0
  19. package/dist/esm/lib/utils/formatter/index.js +8 -0
  20. package/dist/esm/lib/utils/formatter/index.js.map +1 -0
  21. package/dist/esm/lib/utils/formatter/stripToDigits.js +12 -0
  22. package/dist/esm/lib/utils/formatter/stripToDigits.js.map +1 -0
  23. package/dist/esm/lib/utils/formatter/types.js +2 -0
  24. package/dist/esm/lib/utils/formatter/types.js.map +1 -0
  25. package/dist/esm/lib/utils/hooks/index.js +1 -0
  26. package/dist/esm/lib/utils/hooks/index.js.map +1 -1
  27. package/dist/esm/lib/utils/hooks/types.js +2 -0
  28. package/dist/esm/lib/utils/hooks/types.js.map +1 -0
  29. package/dist/esm/lib/utils/hooks/useFormattedValue.js +195 -0
  30. package/dist/esm/lib/utils/hooks/useFormattedValue.js.map +1 -0
  31. package/dist/esm/lib/utils/index.js +6 -2
  32. package/dist/esm/lib/utils/index.js.map +1 -1
  33. package/dist/esm/lib/utils/mergeRefs.js +25 -0
  34. package/dist/esm/lib/utils/mergeRefs.js.map +1 -0
  35. package/dist/types/lib/component/PhoneField/PhoneField.d.ts +2 -1
  36. package/dist/types/lib/component/PhoneField/PhoneField.d.ts.map +1 -1
  37. package/dist/types/lib/index.d.ts +4 -0
  38. package/dist/types/lib/index.d.ts.map +1 -1
  39. package/dist/types/lib/subcomponent/ComboboxInput/SingleCombobox.d.ts.map +1 -1
  40. package/dist/types/lib/subcomponent/ComboboxInput/utils/index.d.ts +0 -1
  41. package/dist/types/lib/subcomponent/ComboboxInput/utils/index.d.ts.map +1 -1
  42. package/dist/types/lib/subcomponent/PhoneInput/PhoneInput.d.ts +19 -2
  43. package/dist/types/lib/subcomponent/PhoneInput/PhoneInput.d.ts.map +1 -1
  44. package/dist/types/lib/subcomponent/PhoneInput/types.d.ts +20 -7
  45. package/dist/types/lib/subcomponent/PhoneInput/types.d.ts.map +1 -1
  46. package/dist/types/lib/utils/countries/index.d.ts +0 -3
  47. package/dist/types/lib/utils/countries/index.d.ts.map +1 -1
  48. package/dist/types/lib/utils/formatter/applyPattern.d.ts +17 -0
  49. package/dist/types/lib/utils/formatter/applyPattern.d.ts.map +1 -0
  50. package/dist/types/lib/utils/formatter/createFormatterRegisterOptions.d.ts +20 -0
  51. package/dist/types/lib/utils/formatter/createFormatterRegisterOptions.d.ts.map +1 -0
  52. package/dist/types/lib/utils/formatter/createPatternFormatter.d.ts +19 -0
  53. package/dist/types/lib/utils/formatter/createPatternFormatter.d.ts.map +1 -0
  54. package/dist/types/lib/utils/formatter/index.d.ts +6 -0
  55. package/dist/types/lib/utils/formatter/index.d.ts.map +1 -0
  56. package/dist/types/lib/utils/formatter/stripToDigits.d.ts +10 -0
  57. package/dist/types/lib/utils/formatter/stripToDigits.d.ts.map +1 -0
  58. package/dist/types/lib/utils/formatter/types.d.ts +30 -0
  59. package/dist/types/lib/utils/formatter/types.d.ts.map +1 -0
  60. package/dist/types/lib/utils/hooks/index.d.ts +2 -0
  61. package/dist/types/lib/utils/hooks/index.d.ts.map +1 -1
  62. package/dist/types/lib/utils/hooks/types.d.ts +33 -0
  63. package/dist/types/lib/utils/hooks/types.d.ts.map +1 -0
  64. package/dist/types/lib/utils/hooks/useFormattedValue.d.ts +30 -0
  65. package/dist/types/lib/utils/hooks/useFormattedValue.d.ts.map +1 -0
  66. package/dist/types/lib/utils/index.d.ts +2 -0
  67. package/dist/types/lib/utils/index.d.ts.map +1 -1
  68. package/dist/types/lib/utils/mergeRefs.d.ts +14 -0
  69. package/dist/types/lib/utils/mergeRefs.d.ts.map +1 -0
  70. package/package.json +13 -13
  71. package/dist/esm/lib/subcomponent/ComboboxInput/utils/mergeRefs.js +0 -12
  72. package/dist/esm/lib/subcomponent/ComboboxInput/utils/mergeRefs.js.map +0 -1
  73. package/dist/esm/lib/utils/countries/applyPhoneMask.js +0 -35
  74. package/dist/esm/lib/utils/countries/applyPhoneMask.js.map +0 -1
  75. package/dist/esm/lib/utils/countries/phoneRegisterOptions.js +0 -18
  76. package/dist/esm/lib/utils/countries/phoneRegisterOptions.js.map +0 -1
  77. package/dist/esm/lib/utils/countries/removePhoneMask.js +0 -12
  78. package/dist/esm/lib/utils/countries/removePhoneMask.js.map +0 -1
  79. package/dist/types/lib/subcomponent/ComboboxInput/utils/mergeRefs.d.ts +0 -3
  80. package/dist/types/lib/subcomponent/ComboboxInput/utils/mergeRefs.d.ts.map +0 -1
  81. package/dist/types/lib/utils/countries/applyPhoneMask.d.ts +0 -14
  82. package/dist/types/lib/utils/countries/applyPhoneMask.d.ts.map +0 -1
  83. package/dist/types/lib/utils/countries/phoneRegisterOptions.d.ts +0 -14
  84. package/dist/types/lib/utils/countries/phoneRegisterOptions.d.ts.map +0 -1
  85. package/dist/types/lib/utils/countries/removePhoneMask.d.ts +0 -10
  86. package/dist/types/lib/utils/countries/removePhoneMask.d.ts.map +0 -1
@@ -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,3 +0,0 @@
1
- declare const mergeRefs: <T>(...refs: (React.Ref<T> | undefined)[]) => (instance: T | null) => void;
2
- export default mergeRefs;
3
- //# sourceMappingURL=mergeRefs.d.ts.map
@@ -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"}