@flipdish/ui-library 0.68.0 → 0.69.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 (37) hide show
  1. package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.cjs +10 -4
  2. package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.cjs.map +1 -1
  3. package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.d.ts +3 -3
  4. package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.d.ts.map +1 -1
  5. package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.js +11 -5
  6. package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.js.map +1 -1
  7. package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.cjs +13 -0
  8. package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.cjs.map +1 -1
  9. package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.d.ts +9 -0
  10. package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.d.ts.map +1 -1
  11. package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.js +14 -2
  12. package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.js.map +1 -1
  13. package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.cjs +51 -16
  14. package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.cjs.map +1 -1
  15. package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.d.ts +19 -6
  16. package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.d.ts.map +1 -1
  17. package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.js +51 -17
  18. package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.js.map +1 -1
  19. package/dist/components/forms/Form/index.cjs +5 -3
  20. package/dist/components/forms/Form/index.cjs.map +1 -1
  21. package/dist/components/forms/Form/index.d.ts +8 -2
  22. package/dist/components/forms/Form/index.d.ts.map +1 -1
  23. package/dist/components/forms/Form/index.js +5 -3
  24. package/dist/components/forms/Form/index.js.map +1 -1
  25. package/dist/components/forms/Form/utilities/focusFromCode.utils.cjs +47 -0
  26. package/dist/components/forms/Form/utilities/focusFromCode.utils.cjs.map +1 -0
  27. package/dist/components/forms/Form/utilities/focusFromCode.utils.d.ts +12 -0
  28. package/dist/components/forms/Form/utilities/focusFromCode.utils.d.ts.map +1 -0
  29. package/dist/components/forms/Form/utilities/focusFromCode.utils.js +45 -0
  30. package/dist/components/forms/Form/utilities/focusFromCode.utils.js.map +1 -0
  31. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.cjs +2 -2
  32. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.d.ts +2 -2
  33. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.js +2 -2
  34. package/dist/hooks/useFocusAfterRetry/index.cjs +1 -1
  35. package/dist/hooks/useFocusAfterRetry/index.d.ts +1 -1
  36. package/dist/hooks/useFocusAfterRetry/index.js +1 -1
  37. package/package.json +2 -2
@@ -12,9 +12,9 @@ var phoneInput_utils = require('../utilities/phoneInput.utils.cjs');
12
12
  *
13
13
  * @param options The field's value, its change handler, the country to start on and any limit on the countries offered.
14
14
  * @returns The `country` and `text` to show, the international `value`, `type` to apply an edit to the text, which
15
- * gives back where the cursor belongs, `chooseCountry` to switch country and keep the digits, `settle` to drop a
16
- * calling code left half typed when the user leaves the field, and `reset` to return to the number and country the
17
- * field started with, as a form reset does.
15
+ * gives back where the cursor belongs, `chooseCountry` to switch country and keep the digits, `settle` to write the
16
+ * number as a saved one shows and drop a calling code left half typed when the user leaves the field, and `reset`
17
+ * to return to the number and country the field started with, as a form reset does.
18
18
  */
19
19
  const usePhoneEntry = ({ value: valueProp, defaultValue, onChange, defaultCountry, allowed }) => {
20
20
  const [value, setValue] = utils.useControlledState(valueProp, defaultValue ?? '', onChange);
@@ -64,8 +64,14 @@ const usePhoneEntry = ({ value: valueProp, defaultValue, onChange, defaultCountr
64
64
  show({ country, text: phoneInput_utils.formatTyped(country, digits) });
65
65
  };
66
66
  const settle = () => {
67
- if (shown.isPending)
67
+ // A report the owner has yet to hand back is what the field shows once it does, so it is settled as well.
68
+ if (reported)
69
+ setReported(phoneEntry_utils.settledEntry(reported));
70
+ if (shown.isPending) {
68
71
  setStored(phoneEntry_utils.entryOf(value, shown.country, allowed));
72
+ return;
73
+ }
74
+ setStored(phoneEntry_utils.settledEntry(shown));
69
75
  };
70
76
  const reset = () => {
71
77
  const initial = defaultValue ?? initialValue;
@@ -1 +1 @@
1
- {"version":3,"file":"usePhoneEntry.cjs","sources":["../../../../../src/components/atoms/PhoneInput/hooks/usePhoneEntry.ts"],"sourcesContent":[null],"names":["useControlledState","useState","entryOf","reconcilePhoneEntry","toInternational","editedDigits","entryFor","caretAfter","significantChars","nationalDigits","formatTyped"],"mappings":";;;;;;;AA4BA;;;;;;;;;;AAUG;AACI,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAqB,KAAI;AACxH,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGA,wBAAkB,CAAC,SAAS,EAAE,YAAY,IAAI,EAAE,EAAE,QAAQ,CAAC;;IAErF,MAAM,CAAC,YAAY,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC;IACtC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGA,cAAQ,CAAa,MAAMC,wBAAO,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;;IAE/F,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAGD,cAAQ,EAAiB;;AAEzD,IAAA,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAGA,cAAQ,CAAC,KAAK,KAAK,EAAE,CAAC;AAEtE,IAAA,MAAM,UAAU,GAAGE,oCAAmB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EA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,CAAC;AACjB,QAAA,mBAAmB,CAAC,OAAO,KAAK,EAAE,CAAC;AACrC,IAAA,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE;AAChG;;"}
1
+ {"version":3,"file":"usePhoneEntry.cjs","sources":["../../../../../src/components/atoms/PhoneInput/hooks/usePhoneEntry.ts"],"sourcesContent":[null],"names":["useControlledState","useState","entryOf","reconcilePhoneEntry","toInternational","editedDigits","entryFor","caretAfter","significantChars","nationalDigits","formatTyped","settledEntry"],"mappings":";;;;;;;AA4BA;;;;;;;;;;AAUG;AACI,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAqB,KAAI;AACxH,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGA,wBAAkB,CAAC,SAAS,EAAE,YAAY,IAAI,EAAE,EAAE,QAAQ,CAAC;;IAErF,MAAM,CAAC,YAAY,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC;IACtC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGA,cAAQ,CAAa,MAAMC,wBAAO,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;;IAE/F,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAGD,cAAQ,EAAiB;;AAEzD,IAAA,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAGA,cAAQ,CAAC,KAAK,KAAK,EAAE,CAAC;AAEtE,IAAA,MAAM,UAAU,GAAGE,oCAAmB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;AAC9G,IAAA,IAAI,UAAU,CAAC,QAAQ,KAAK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AAI,EAAE,KAAK,EAAE,CAAC;QACtC,SAAS,CAAC,KAAK,CAAC;QAChB,QAAQ,CAAC,OAAO,CAAC;AACjB,QAAA,mBAAmB,CAAC,OAAO,KAAK,EAAE,CAAC;AACrC,IAAA,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE;AAChG;;"}
@@ -19,9 +19,9 @@ export interface PhoneEntryOptions {
19
19
  *
20
20
  * @param options The field's value, its change handler, the country to start on and any limit on the countries offered.
21
21
  * @returns The `country` and `text` to show, the international `value`, `type` to apply an edit to the text, which
22
- * gives back where the cursor belongs, `chooseCountry` to switch country and keep the digits, `settle` to drop a
23
- * calling code left half typed when the user leaves the field, and `reset` to return to the number and country the
24
- * field started with, as a form reset does.
22
+ * gives back where the cursor belongs, `chooseCountry` to switch country and keep the digits, `settle` to write the
23
+ * number as a saved one shows and drop a calling code left half typed when the user leaves the field, and `reset`
24
+ * to return to the number and country the field started with, as a form reset does.
25
25
  */
26
26
  export declare const usePhoneEntry: ({ value: valueProp, defaultValue, onChange, defaultCountry, allowed }: PhoneEntryOptions) => {
27
27
  country: import("libphonenumber-js/min").CountryCode;
@@ -1 +1 @@
1
- {"version":3,"file":"usePhoneEntry.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/PhoneInput/hooks/usePhoneEntry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,qBAAqB,CAAC;AAExE,OAAO,EAML,KAAK,SAAS,EAGf,MAAM,+BAA+B,CAAC;AAEvC,MAAM,WAAW,iBAAiB;IAChC,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,qIAAqI;IACrI,cAAc,EAAE,gBAAgB,CAAC;IACjC,mEAAmE;IACnE,OAAO,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACvC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GAAI,uEAAuE,iBAAiB;;;;iBAuBhG,SAAS,KAAG,MAAM;6BAaN,gBAAgB;;;CA0BjD,CAAC"}
1
+ {"version":3,"file":"usePhoneEntry.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/PhoneInput/hooks/usePhoneEntry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,qBAAqB,CAAC;AAExE,OAAO,EAML,KAAK,SAAS,EAGf,MAAM,+BAA+B,CAAC;AAEvC,MAAM,WAAW,iBAAiB;IAChC,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,qIAAqI;IACrI,cAAc,EAAE,gBAAgB,CAAC;IACjC,mEAAmE;IACnE,OAAO,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACvC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GAAI,uEAAuE,iBAAiB;;;;iBAuBhG,SAAS,KAAG,MAAM;6BAaN,gBAAgB;;;CAgCjD,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { useControlledState } from '@react-stately/utils';
2
2
  import { useState } from 'react';
3
- import { entryOf, reconcilePhoneEntry } from '../utilities/phoneEntry.utils.js';
3
+ import { entryOf, reconcilePhoneEntry, settledEntry } from '../utilities/phoneEntry.utils.js';
4
4
  import { significantChars, toInternational, nationalDigits, formatTyped, editedDigits, entryFor, caretAfter } from '../utilities/phoneInput.utils.js';
5
5
 
6
6
  /**
@@ -10,9 +10,9 @@ import { significantChars, toInternational, nationalDigits, formatTyped, editedD
10
10
  *
11
11
  * @param options The field's value, its change handler, the country to start on and any limit on the countries offered.
12
12
  * @returns The `country` and `text` to show, the international `value`, `type` to apply an edit to the text, which
13
- * gives back where the cursor belongs, `chooseCountry` to switch country and keep the digits, `settle` to drop a
14
- * calling code left half typed when the user leaves the field, and `reset` to return to the number and country the
15
- * field started with, as a form reset does.
13
+ * gives back where the cursor belongs, `chooseCountry` to switch country and keep the digits, `settle` to write the
14
+ * number as a saved one shows and drop a calling code left half typed when the user leaves the field, and `reset`
15
+ * to return to the number and country the field started with, as a form reset does.
16
16
  */
17
17
  const usePhoneEntry = ({ value: valueProp, defaultValue, onChange, defaultCountry, allowed }) => {
18
18
  const [value, setValue] = useControlledState(valueProp, defaultValue ?? '', onChange);
@@ -62,8 +62,14 @@ const usePhoneEntry = ({ value: valueProp, defaultValue, onChange, defaultCountr
62
62
  show({ country, text: formatTyped(country, digits) });
63
63
  };
64
64
  const settle = () => {
65
- if (shown.isPending)
65
+ // A report the owner has yet to hand back is what the field shows once it does, so it is settled as well.
66
+ if (reported)
67
+ setReported(settledEntry(reported));
68
+ if (shown.isPending) {
66
69
  setStored(entryOf(value, shown.country, allowed));
70
+ return;
71
+ }
72
+ setStored(settledEntry(shown));
67
73
  };
68
74
  const reset = () => {
69
75
  const initial = defaultValue ?? initialValue;
@@ -1 +1 @@
1
- {"version":3,"file":"usePhoneEntry.js","sources":["../../../../../src/components/atoms/PhoneInput/hooks/usePhoneEntry.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AA4BA;;;;;;;;;;AAUG;AACI,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAqB,KAAI;AACxH,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,kBAAkB,CAAC,SAAS,EAAE,YAAY,IAAI,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KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACjD;QACF;AACA,QAAA,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AAChC,IAAA,CAAC;IAED,MAAM,KAAK,GAAG,MAAK;AACjB,QAAA,MAAM,OAAO,GAAG,YAAY,IAAI,YAAY;QAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC;;QAEvD,WAAW,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACtC,SAAS,CAAC,KAAK,CAAC;QAChB,QAAQ,CAAC,OAAO,CAAC;AACjB,QAAA,mBAAmB,CAAC,OAAO,KAAK,EAAE,CAAC;AACrC,IAAA,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE;AAChG;;"}
@@ -15,6 +15,18 @@ const entryOf = (value, country, allowed) => {
15
15
  const entry = phoneInput_utils.fromInternational(value, country, allowed) ?? { country, text: phoneInput_utils.formatTyped(country, phoneInput_utils.significantChars(value)) || value };
16
16
  return { ...entry, value };
17
17
  };
18
+ /**
19
+ * Writes an entry's number as a saved one shows, for when the user leaves the field, so a trunk prefix typed out of habit
20
+ * does not stay beside the calling code.
21
+ *
22
+ * @param entry The entry on screen, or one reported to an owner that has yet to hand its value back.
23
+ * @returns The entry with its text rewritten, in the country it had. The same object when the text already reads that
24
+ * way, or when the value is not a number of that country.
25
+ */
26
+ const settledEntry = (entry) => {
27
+ const text = phoneInput_utils.settledText(entry.value, entry.country);
28
+ return text === undefined || text === entry.text ? entry : { ...entry, text };
29
+ };
18
30
  const shownFor = (value, stored, reported, allowed) => {
19
31
  if (stored.value === value)
20
32
  return stored;
@@ -52,4 +64,5 @@ const reconcilePhoneEntry = ({ value, stored, reported, isCountrySettled, defaul
52
64
 
53
65
  exports.entryOf = entryOf;
54
66
  exports.reconcilePhoneEntry = reconcilePhoneEntry;
67
+ exports.settledEntry = settledEntry;
55
68
  //# sourceMappingURL=phoneEntry.utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"phoneEntry.utils.cjs","sources":["../../../../../src/components/atoms/PhoneInput/utilities/phoneEntry.utils.ts"],"sourcesContent":[null],"names":["fromInternational","formatTyped","significantChars"],"mappings":";;;;AA2CA;;;;;;;AAOG;AACI,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,OAAyB,EAAE,OAAqC,KAAgB;;AAErH,IAAA,MAAM,KAAK,GAAGA,kCAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAEC,4BAAW,CAAC,OAAO,EAAEC,iCAAgB,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,EAAE;AACrI,IAAA,OAAO,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE;AAC5B;AAEA,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,MAAkB,EAAE,QAAmC,EAAE,OAAqC,KAAgB;AAC7I,IAAA,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK;AAAE,QAAA,OAAO,MAAM;AACzC,IAAA,IAAI,QAAQ,EAAE,KAAK,KAAK,KAAK;AAAE,QAAA,OAAO,QAAQ;IAC9C,OAAO,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;AAChD,CAAC;AAED;;;;;;;AAOG;AACI,MAAM,mBAAmB,GAAG,CAAC,EAClC,KAAK,EACL,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,OAAO,GACY,KAA0B;AAC7C,IAAA,IAAI,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC;;AAEtD,IAAA,MAAM,cAAc,GAAG,KAAK,KAAK,QAAQ,EAAE,KAAK;;IAEhD,MAAM,UAAU,GAAG,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,QAAQ,EAAE,IAAI;IAC/D,IAAI,YAAY,GAAG,QAAQ;AAC3B,IAAA,IAAI,QAAQ,KAAK,cAAc,IAAI,UAAU,CAAC;QAAE,YAAY,GAAG,SAAS;;IAExE,IAAI,WAAW,GAAG,gBAAgB;AAClC,IAAA,IAAI,CAAC,gBAAgB,IAAI,KAAK,CAAC,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,QAAQ,EAAE,IAAI;QAAE,WAAW,GAAG,IAAI;;IAE3F,IAAI,CAAC,gBAAgB,IAAI,KAAK,CAAC,IAAI,KAAK,EAAE,IAAI,KAAK,CAAC,KAAK,KAAK,EAAE,IAAI,KAAK,CAAC,OAAO,KAAK,cAAc,EAAE;QACpG,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE;IAC/C;AAEA,IAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE;AACxF;;;"}
1
+ {"version":3,"file":"phoneEntry.utils.cjs","sources":["../../../../../src/components/atoms/PhoneInput/utilities/phoneEntry.utils.ts"],"sourcesContent":[null],"names":["fromInternational","formatTyped","significantChars","settledText"],"mappings":";;;;AA2CA;;;;;;;AAOG;AACI,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,OAAyB,EAAE,OAAqC,KAAgB;;AAErH,IAAA,MAAM,KAAK,GAAGA,kCAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAEC,4BAAW,CAAC,OAAO,EAAEC,iCAAgB,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,EAAE;AACrI,IAAA,OAAO,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE;AAC5B;AAEA;;;;;;;AAOG;AACI,MAAM,YAAY,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,gBAAgB,IAAI,KAAK,CAAC,IAAI,KAAK,EAAE,IAAI,KAAK,CAAC,KAAK,KAAK,EAAE,IAAI,KAAK,CAAC,OAAO,KAAK,cAAc,EAAE;QACpG,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE;IAC/C;AAEA,IAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE;AACxF;;;;"}
@@ -44,6 +44,15 @@ export interface ReconciledPhoneEntry {
44
44
  * @returns The country and text to show, carrying `value` unchanged.
45
45
  */
46
46
  export declare const entryOf: (value: string, country: PhoneCountryCode, allowed?: readonly PhoneCountryCode[]) => ShownEntry;
47
+ /**
48
+ * Writes an entry's number as a saved one shows, for when the user leaves the field, so a trunk prefix typed out of habit
49
+ * does not stay beside the calling code.
50
+ *
51
+ * @param entry The entry on screen, or one reported to an owner that has yet to hand its value back.
52
+ * @returns The entry with its text rewritten, in the country it had. The same object when the text already reads that
53
+ * way, or when the value is not a number of that country.
54
+ */
55
+ export declare const settledEntry: <TEntry extends ShownEntry>(entry: TEntry) => TEntry;
47
56
  /**
48
57
  * Brings the entry on screen in line with the number the field's owner holds. The shown text is kept when it belongs
49
58
  * to that number, and rebuilt from the number only when the number arrives from outside, so a trunk zero the value
@@ -1 +1 @@
1
- {"version":3,"file":"phoneEntry.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/PhoneInput/utilities/phoneEntry.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGxE,0DAA0D;AAC1D,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,wGAAwG;IACxG,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,2FAA2F;AAC3F,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,IAAI,EAAE,MAAM,CAAC;CACd;AAED,mGAAmG;AACnG,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,MAAM,EAAE,UAAU,CAAC;IACnB,6FAA6F;IAC7F,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAC;IACpC,kGAAkG;IAClG,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gEAAgE;IAChE,cAAc,EAAE,gBAAgB,CAAC;IACjC,mEAAmE;IACnE,OAAO,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACvC;AAED,qFAAqF;AACrF,MAAM,WAAW,oBAAoB;IACnC,oGAAoG;IACpG,KAAK,EAAE,UAAU,CAAC;IAClB,0GAA0G;IAC1G,MAAM,EAAE,UAAU,CAAC;IACnB,wGAAwG;IACxG,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAC;IACpC,8DAA8D;IAC9D,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,EAAE,SAAS,gBAAgB,EAAE,UAAU,SAAS,gBAAgB,EAAE,KAAG,UAIzG,CAAC;AAQF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,yEAOjC,kBAAkB,KAAG,oBAiBvB,CAAC"}
1
+ {"version":3,"file":"phoneEntry.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/PhoneInput/utilities/phoneEntry.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGxE,0DAA0D;AAC1D,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,wGAAwG;IACxG,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,2FAA2F;AAC3F,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,IAAI,EAAE,MAAM,CAAC;CACd;AAED,mGAAmG;AACnG,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,MAAM,EAAE,UAAU,CAAC;IACnB,6FAA6F;IAC7F,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAC;IACpC,kGAAkG;IAClG,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gEAAgE;IAChE,cAAc,EAAE,gBAAgB,CAAC;IACjC,mEAAmE;IACnE,OAAO,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACvC;AAED,qFAAqF;AACrF,MAAM,WAAW,oBAAoB;IACnC,oGAAoG;IACpG,KAAK,EAAE,UAAU,CAAC;IAClB,0GAA0G;IAC1G,MAAM,EAAE,UAAU,CAAC;IACnB,wGAAwG;IACxG,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAC;IACpC,8DAA8D;IAC9D,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,EAAE,SAAS,gBAAgB,EAAE,UAAU,SAAS,gBAAgB,EAAE,KAAG,UAIzG,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,SAAS,UAAU,EAAE,OAAO,MAAM,KAAG,MAGvE,CAAC;AAQF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,yEAOjC,kBAAkB,KAAG,oBAiBvB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { fromInternational, formatTyped, significantChars } from './phoneInput.utils.js';
1
+ import { fromInternational, formatTyped, significantChars, settledText } from './phoneInput.utils.js';
2
2
 
3
3
  /**
4
4
  * Builds the entry a value shows as, in the country it names or the one given when it names none.
@@ -13,6 +13,18 @@ const entryOf = (value, country, allowed) => {
13
13
  const entry = fromInternational(value, country, allowed) ?? { country, text: formatTyped(country, significantChars(value)) || value };
14
14
  return { ...entry, value };
15
15
  };
16
+ /**
17
+ * Writes an entry's number as a saved one shows, for when the user leaves the field, so a trunk prefix typed out of habit
18
+ * does not stay beside the calling code.
19
+ *
20
+ * @param entry The entry on screen, or one reported to an owner that has yet to hand its value back.
21
+ * @returns The entry with its text rewritten, in the country it had. The same object when the text already reads that
22
+ * way, or when the value is not a number of that country.
23
+ */
24
+ const settledEntry = (entry) => {
25
+ const text = settledText(entry.value, entry.country);
26
+ return text === undefined || text === entry.text ? entry : { ...entry, text };
27
+ };
16
28
  const shownFor = (value, stored, reported, allowed) => {
17
29
  if (stored.value === value)
18
30
  return stored;
@@ -48,5 +60,5 @@ const reconcilePhoneEntry = ({ value, stored, reported, isCountrySettled, defaul
48
60
  return { shown, stored: shown, reported: nextReported, isCountrySettled: nextSettled };
49
61
  };
50
62
 
51
- export { entryOf, reconcilePhoneEntry };
63
+ export { entryOf, reconcilePhoneEntry, settledEntry };
52
64
  //# sourceMappingURL=phoneEntry.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"phoneEntry.utils.js","sources":["../../../../../src/components/atoms/PhoneInput/utilities/phoneEntry.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AA2CA;;;;;;;AAOG;AACI,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,OAAyB,EAAE,OAAqC,KAAgB;;AAErH,IAAA,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,EAAE;AACrI,IAAA,OAAO,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE;AAC5B;AAEA,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,MAAkB,EAAE,QAAmC,EAAE,OAAqC,KAAgB;AAC7I,IAAA,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK;AAAE,QAAA,OAAO,MAAM;A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AK,QAAQ,EAAE,KAAK;;IAEhD,MAAM,UAAU,GAAG,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,QAAQ,EAAE,IAAI;IAC/D,IAAI,YAAY,GAAG,QAAQ;AAC3B,IAAA,IAAI,QAAQ,KAAK,cAAc,IAAI,UAAU,CAAC;QAAE,YAAY,GAAG,SAAS;;IAExE,IAAI,WAAW,GAAG,gBAAgB;AAClC,IAAA,IAAI,CAAC,gBAAgB,IAAI,KAAK,CAAC,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,QAAQ,EAAE,IAAI;QAAE,WAAW,GAAG,IAAI;;IAE3F,IAAI,CAAC,gBAAgB,IAAI,KAAK,CAAC,IAAI,KAAK,EAAE,IAAI,KAAK,CAAC,KAAK,KAAK,EAAE,IAAI,KAAK,CAAC,OAAO,KAAK,cAAc,EAAE;QACpG,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE;IAC/C;AAEA,IAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE;AACxF;;"}
@@ -66,21 +66,26 @@ const editedDigits = ({ previous, next, caret, inputType }) => {
66
66
  return { significant, position };
67
67
  return { significant: significant.slice(0, index) + significant.slice(index + 1), position: index };
68
68
  };
69
+ // The field shows the calling code beside the number, so the number reads on from it as an international one does.
70
+ const afterCallingCode = (international, callingCode) => international.replace(`+${callingCode}`, '').trim();
69
71
  /**
70
- * Formats a number as it is typed, in a country's national style, or internationally when it starts with a plus.
72
+ * Formats a number as it is typed. The country's calling code sits beside the field, so national digits are spaced as
73
+ * they are written after that code.
71
74
  *
72
75
  * @param country The country whose style applies.
73
76
  * @param significant The digits typed so far, after a plus for an international number.
74
- * @returns The number spaced as that country writes it, as far as it has been typed. Digits typed without the country's
75
- * trunk prefix, as after a calling code, are spaced as the international form spaces them.
77
+ * @returns The number spaced as it is written after the country's calling code, as far as it has been typed. One typed
78
+ * with the country's trunk prefix, such as a leading `0`, keeps it in the national style, and one after a plus is
79
+ * spaced as an international number.
76
80
  */
77
81
  const formatTyped = (country, significant) => {
78
- const national = new min.AsYouType(country).input(significant);
79
- if (significant.startsWith('+') || national !== significant)
82
+ const typed = new min.AsYouType(country);
83
+ const national = typed.input(significant);
84
+ // A trunk prefix is not dropped mid-number: where a number can start with the same digit, only the whole number tells them apart.
85
+ if (significant.startsWith('+') || typed.getNumber()?.nationalNumber !== significant)
80
86
  return national;
81
- // The national format of many countries needs the trunk prefix, so a number typed without it would get no spacing at all.
82
87
  const callingCode = min.getCountryCallingCode(country);
83
- return new min.AsYouType().input(`+${callingCode}${significant}`).replace(`+${callingCode}`, '').trim();
88
+ return afterCallingCode(new min.AsYouType().input(`+${callingCode}${significant}`), callingCode);
84
89
  };
85
90
  /**
86
91
  * Writes what the field shows as one international number, the form an API stores.
@@ -93,6 +98,31 @@ const toInternational = ({ country, text }) => {
93
98
  typed.input(text);
94
99
  return typed.getNumber()?.number ?? '';
95
100
  };
101
+ // Where a number starts with its country's trunk digit, as `812` does in Russia, the text after the code would read back as another number, so it keeps the national form.
102
+ const wholeNumberText = (country, number) => {
103
+ const written = afterCallingCode(number.formatInternational(), number.countryCallingCode);
104
+ // A number no pattern fits whole, such as one a digit short, comes back unspaced, so it is spaced as typing it is.
105
+ const text = written === number.nationalNumber ? formatTyped(country, number.nationalNumber) : written;
106
+ return toInternational({ country, text }) === number.number ? text : number.formatNational();
107
+ };
108
+ /**
109
+ * Writes the number a field holds the way a saved one shows, without moving the field off its country, for when the
110
+ * user leaves it.
111
+ *
112
+ * @param value The international number the field holds.
113
+ * @param country The country the field is on.
114
+ * @returns The number as it is written after that country's calling code, or `undefined` when the value is no number,
115
+ * belongs to another calling code, or would not read back in that country as the same number.
116
+ */
117
+ const settledText = (value, country) => {
118
+ const typed = new min.AsYouType();
119
+ typed.input(significantChars(value));
120
+ const number = typed.getNumber();
121
+ if (!number || number.countryCallingCode !== min.getCountryCallingCode(country))
122
+ return undefined;
123
+ const text = number.isPossible() ? wholeNumberText(country, number) : formatTyped(country, number.nationalNumber);
124
+ return toInternational({ country, text }) === number.number ? text : undefined;
125
+ };
96
126
  /**
97
127
  * Finds the calling code a run of digits starts with. No calling code starts with another, so the first match is the code.
98
128
  *
@@ -135,8 +165,9 @@ const countryForNumber = (international, current, allowed) => {
135
165
  * @param value The number, with its plus and calling code.
136
166
  * @param current The country the field is on, kept where the number could belong to it.
137
167
  * @param allowed The countries the field offers, when the app restricts them.
138
- * @returns The country and the number in its national format, or `undefined` for a value that is not an international
139
- * number or belongs to a country the field does not offer.
168
+ * @returns The country and the number as it is written after that country's calling code, with no trunk prefix unless
169
+ * the number needs it to read back as itself, or `undefined` for a value that is not an international number or
170
+ * belongs to a country the field does not offer.
140
171
  */
141
172
  const fromInternational = (value, current, allowed) => {
142
173
  const significant = significantChars(value);
@@ -146,8 +177,8 @@ const fromInternational = (value, current, allowed) => {
146
177
  const typed = new min.AsYouType();
147
178
  typed.input(significant);
148
179
  const number = typed.getNumber();
149
- // A whole number is written the way the country writes it, with its trunk prefix; a partial one has no such form yet.
150
- const text = number?.isPossible() ? number.formatNational() : formatTyped(country, number?.nationalNumber ?? '');
180
+ // A partial number has no whole form yet, so it is spaced as far as it goes.
181
+ const text = number?.isPossible() ? wholeNumberText(country, number) : formatTyped(country, number?.nationalNumber ?? '');
151
182
  return { country, text };
152
183
  };
153
184
  /**
@@ -215,10 +246,10 @@ const entryFor = (country, significant, position, allowed) => {
215
246
  const entry = fromInternational(digits, country, allowed);
216
247
  if (!entry)
217
248
  return { country, text: formatTyped(country, digits), position: cursor };
218
- // The national digits before the cursor, shifted by any trunk prefix the national format adds in front of them.
249
+ // The national digits before the cursor, shifted by a trunk prefix the shown number adds in front of them or leaves out.
219
250
  const nationalLength = digits.length - 1 - callingCode.length;
220
- const trunkLength = significantChars(entry.text).length - nationalLength;
221
- return { ...entry, position: before.length - callingCode.length + Math.max(0, trunkLength) };
251
+ const trunkShift = significantChars(entry.text).length - nationalLength;
252
+ return { ...entry, position: Math.max(0, before.length - callingCode.length + trunkShift) };
222
253
  };
223
254
  /**
224
255
  * Lists the countries the field offers, named and sorted for the user's language.
@@ -239,9 +270,12 @@ const countryOptions = (locale, allowed) => {
239
270
  * Gives a number that shows a country's format, for the field's placeholder.
240
271
  *
241
272
  * @param country The country to show.
242
- * @returns A mobile number in that country's national format, or `''` when the library has none.
273
+ * @returns A mobile number as it is written after that country's calling code, or `''` when the library has none.
243
274
  */
244
- const exampleNumber = (country) => min.getExampleNumber(country, examples)?.formatNational() ?? '';
275
+ const exampleNumber = (country) => {
276
+ const example = min.getExampleNumber(country, examples);
277
+ return example ? wholeNumberText(country, example) : '';
278
+ };
245
279
  // Reads the tag's region alone, so neither an extension key (`en-u-ca-gregory`) nor a POSIX codeset (`en_US.UTF-8`) is taken for one.
246
280
  const localeRegion = (locale) => {
247
281
  try {
@@ -298,6 +332,7 @@ exports.isFocusInside = isFocusInside;
298
332
  exports.leadingCallingCode = leadingCallingCode;
299
333
  exports.nationalDigits = nationalDigits;
300
334
  exports.offeredCountries = offeredCountries;
335
+ exports.settledText = settledText;
301
336
  exports.significantChars = significantChars;
302
337
  exports.startingCountry = startingCountry;
303
338
  exports.toInternational = toInternational;
@@ -1 +1 @@
1
- {"version":3,"file":"phoneInput.utils.cjs","sources":["../../../../../src/components/atoms/PhoneInput/utilities/phoneInput.utils.ts"],"sourcesContent":[null],"names":["parseDigits","AsYouType","getCountryCallingCode","isSupportedCountry","getCountries","getCountryName","getExampleNumber"],"mappings":";;;;;;;AAMA;AACA,MAAM,gBAAgB,GAAqB,IAAI;AAE/C;;;;;AAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAY,KAAY;IACvD,IAAI,WAAW,GAAG,EAAE;AACpB,IAAA,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;AACvB,QAAA,IAAI,IAAI,KAAK,GAAG,EAAE;YAChB,IAAI,WAAW,KAAK,E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BA,sBAAkB,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"phoneInput.utils.cjs","sources":["../../../../../src/components/atoms/PhoneInput/utilities/phoneInput.utils.ts"],"sourcesContent":[null],"names":["parseDigits","AsYouType","getCountryCallingCode","isSupportedCountry","getCountries","getCountryName","getExampleNumber"],"mappings":";;;;;;;AAcA;AACA,MAAM,gBAAgB,GAAqB,IAAI;AAE/C;;;;;AAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAY,KAAY;IACvD,IAAI,WAAW,GAAG,EAAE;AACpB,IAAA,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;AACvB,QAAA,IAAI,IAAI,KAAK,GAAG,EAAE;YAChB,IAAI,WAAW,KAAK,EAAE;gBAAE,WAAW,GAAG,GAAG;QAC3C;aAAO;AACL,YAAA,WAAW,IAAIA,eAAW,CAAC,IAAI,CAAC;QAClC;IACF;AACA,IAAA,OAAO,WAAW;AACpB;AAEA;;;;;;AAMG;MACU,UAAU,GAAG,CAAC,IAAY,EAAE,QAAgB,KAAY;IACnE,IAAI,IAAI,GAAG,CAAC;AACZ,IAAA,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAChD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC;AACnF,QAAA,IAAI,CAAC,aAAa;YAAE;QACpB,IAAI,QAAQ,IAAI,CAAC;AAAE,YAAA,OAAO,KAAK;AAC/B,QAAA,IAAI,EAAE;QACN,IAAI,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,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AE,QAAA,OAAO,SAAS;AAC1C,IAAA,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;IACnC,IAAI,SAAS,CAAC,MAAM,CAAC;AAAE,QAAA,OAAO,MAAM;AACpC,IAAA,OAAO,OAAO,GAAG,CAAC,CAAC,IAAI,gBAAgB;AACzC;AAEA;;;;;;;AAOG;AACI,MAAM,aAAa,GAAG,CAAC,IAAwB,EAAE,KAA+B,KACrF,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE,QAAQ,CAAC,IAAY,CAAC;AAEpE;;;;;AAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,SAA6B,KAC5D,SAAS,KAAK,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,KAA+BA,sBAAkB,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;"}
@@ -36,12 +36,14 @@ export declare const editedDigits: ({ previous, next, caret, inputType }: PhoneE
36
36
  position: number;
37
37
  };
38
38
  /**
39
- * Formats a number as it is typed, in a country's national style, or internationally when it starts with a plus.
39
+ * Formats a number as it is typed. The country's calling code sits beside the field, so national digits are spaced as
40
+ * they are written after that code.
40
41
  *
41
42
  * @param country The country whose style applies.
42
43
  * @param significant The digits typed so far, after a plus for an international number.
43
- * @returns The number spaced as that country writes it, as far as it has been typed. Digits typed without the country's
44
- * trunk prefix, as after a calling code, are spaced as the international form spaces them.
44
+ * @returns The number spaced as it is written after the country's calling code, as far as it has been typed. One typed
45
+ * with the country's trunk prefix, such as a leading `0`, keeps it in the national style, and one after a plus is
46
+ * spaced as an international number.
45
47
  */
46
48
  export declare const formatTyped: (country: PhoneCountryCode, significant: string) => string;
47
49
  /**
@@ -51,6 +53,16 @@ export declare const formatTyped: (country: PhoneCountryCode, significant: strin
51
53
  * @returns The number in E.164 form, such as `+353861234567`, as far as it has been typed, or `''` before any digit that counts.
52
54
  */
53
55
  export declare const toInternational: ({ country, text }: PhoneEntry) => string;
56
+ /**
57
+ * Writes the number a field holds the way a saved one shows, without moving the field off its country, for when the
58
+ * user leaves it.
59
+ *
60
+ * @param value The international number the field holds.
61
+ * @param country The country the field is on.
62
+ * @returns The number as it is written after that country's calling code, or `undefined` when the value is no number,
63
+ * belongs to another calling code, or would not read back in that country as the same number.
64
+ */
65
+ export declare const settledText: (value: string, country: PhoneCountryCode) => string | undefined;
54
66
  /**
55
67
  * Finds the calling code a run of digits starts with. No calling code starts with another, so the first match is the code.
56
68
  *
@@ -75,8 +87,9 @@ export declare const countryForNumber: (international: string, current: PhoneCou
75
87
  * @param value The number, with its plus and calling code.
76
88
  * @param current The country the field is on, kept where the number could belong to it.
77
89
  * @param allowed The countries the field offers, when the app restricts them.
78
- * @returns The country and the number in its national format, or `undefined` for a value that is not an international
79
- * number or belongs to a country the field does not offer.
90
+ * @returns The country and the number as it is written after that country's calling code, with no trunk prefix unless
91
+ * the number needs it to read back as itself, or `undefined` for a value that is not an international number or
92
+ * belongs to a country the field does not offer.
80
93
  */
81
94
  export declare const fromInternational: (value: string, current: PhoneCountryCode, allowed?: readonly PhoneCountryCode[]) => PhoneEntry | undefined;
82
95
  /**
@@ -115,7 +128,7 @@ export declare const countryOptions: (locale: string, allowed?: readonly string[
115
128
  * Gives a number that shows a country's format, for the field's placeholder.
116
129
  *
117
130
  * @param country The country to show.
118
- * @returns A mobile number in that country's national format, or `''` when the library has none.
131
+ * @returns A mobile number as it is written after that country's calling code, or `''` when the library has none.
119
132
  */
120
133
  export declare const exampleNumber: (country: PhoneCountryCode) => string;
121
134
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"phoneInput.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/PhoneInput/utilities/phoneInput.utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKtF;;;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B,UAAU,MAAM,EAChB,UAAU,SAAS,gBAAgB,EAAE,KACpC,UAAU,GAAG,SAqBf,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,UAAU,SAAS,MAAM,EAAE,KAAG,YAAY,EAOxF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,gBAAgB,KAAG,MAGzD,CAAC;AAWF;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,WAAW,MAAM,GAAG,SAAS,EAAE,QAAQ,MAAM,EAAE,UAAU,SAAS,gBAAgB,EAAE,KAAG,gBAOtH,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,WAAW,GAAG,IAAI,EAAE,OAAO,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,KAAG,OACrB,CAAC;AAEtE;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,WAAW,MAAM,GAAG,SAAS,KAAG,gBAAgB,EAAE,GAAG,SAC2C,CAAC"}
@@ -64,21 +64,26 @@ const editedDigits = ({ previous, next, caret, inputType }) => {
64
64
  return { significant, position };
65
65
  return { significant: significant.slice(0, index) + significant.slice(index + 1), position: index };
66
66
  };
67
+ // The field shows the calling code beside the number, so the number reads on from it as an international one does.
68
+ const afterCallingCode = (international, callingCode) => international.replace(`+${callingCode}`, '').trim();
67
69
  /**
68
- * Formats a number as it is typed, in a country's national style, or internationally when it starts with a plus.
70
+ * Formats a number as it is typed. The country's calling code sits beside the field, so national digits are spaced as
71
+ * they are written after that code.
69
72
  *
70
73
  * @param country The country whose style applies.
71
74
  * @param significant The digits typed so far, after a plus for an international number.
72
- * @returns The number spaced as that country writes it, as far as it has been typed. Digits typed without the country's
73
- * trunk prefix, as after a calling code, are spaced as the international form spaces them.
75
+ * @returns The number spaced as it is written after the country's calling code, as far as it has been typed. One typed
76
+ * with the country's trunk prefix, such as a leading `0`, keeps it in the national style, and one after a plus is
77
+ * spaced as an international number.
74
78
  */
75
79
  const formatTyped = (country, significant) => {
76
- const national = new AsYouType(country).input(significant);
77
- if (significant.startsWith('+') || national !== significant)
80
+ const typed = new AsYouType(country);
81
+ const national = typed.input(significant);
82
+ // A trunk prefix is not dropped mid-number: where a number can start with the same digit, only the whole number tells them apart.
83
+ if (significant.startsWith('+') || typed.getNumber()?.nationalNumber !== significant)
78
84
  return national;
79
- // The national format of many countries needs the trunk prefix, so a number typed without it would get no spacing at all.
80
85
  const callingCode = getCountryCallingCode(country);
81
- return new AsYouType().input(`+${callingCode}${significant}`).replace(`+${callingCode}`, '').trim();
86
+ return afterCallingCode(new AsYouType().input(`+${callingCode}${significant}`), callingCode);
82
87
  };
83
88
  /**
84
89
  * Writes what the field shows as one international number, the form an API stores.
@@ -91,6 +96,31 @@ const toInternational = ({ country, text }) => {
91
96
  typed.input(text);
92
97
  return typed.getNumber()?.number ?? '';
93
98
  };
99
+ // Where a number starts with its country's trunk digit, as `812` does in Russia, the text after the code would read back as another number, so it keeps the national form.
100
+ const wholeNumberText = (country, number) => {
101
+ const written = afterCallingCode(number.formatInternational(), number.countryCallingCode);
102
+ // A number no pattern fits whole, such as one a digit short, comes back unspaced, so it is spaced as typing it is.
103
+ const text = written === number.nationalNumber ? formatTyped(country, number.nationalNumber) : written;
104
+ return toInternational({ country, text }) === number.number ? text : number.formatNational();
105
+ };
106
+ /**
107
+ * Writes the number a field holds the way a saved one shows, without moving the field off its country, for when the
108
+ * user leaves it.
109
+ *
110
+ * @param value The international number the field holds.
111
+ * @param country The country the field is on.
112
+ * @returns The number as it is written after that country's calling code, or `undefined` when the value is no number,
113
+ * belongs to another calling code, or would not read back in that country as the same number.
114
+ */
115
+ const settledText = (value, country) => {
116
+ const typed = new AsYouType();
117
+ typed.input(significantChars(value));
118
+ const number = typed.getNumber();
119
+ if (!number || number.countryCallingCode !== getCountryCallingCode(country))
120
+ return undefined;
121
+ const text = number.isPossible() ? wholeNumberText(country, number) : formatTyped(country, number.nationalNumber);
122
+ return toInternational({ country, text }) === number.number ? text : undefined;
123
+ };
94
124
  /**
95
125
  * Finds the calling code a run of digits starts with. No calling code starts with another, so the first match is the code.
96
126
  *
@@ -133,8 +163,9 @@ const countryForNumber = (international, current, allowed) => {
133
163
  * @param value The number, with its plus and calling code.
134
164
  * @param current The country the field is on, kept where the number could belong to it.
135
165
  * @param allowed The countries the field offers, when the app restricts them.
136
- * @returns The country and the number in its national format, or `undefined` for a value that is not an international
137
- * number or belongs to a country the field does not offer.
166
+ * @returns The country and the number as it is written after that country's calling code, with no trunk prefix unless
167
+ * the number needs it to read back as itself, or `undefined` for a value that is not an international number or
168
+ * belongs to a country the field does not offer.
138
169
  */
139
170
  const fromInternational = (value, current, allowed) => {
140
171
  const significant = significantChars(value);
@@ -144,8 +175,8 @@ const fromInternational = (value, current, allowed) => {
144
175
  const typed = new AsYouType();
145
176
  typed.input(significant);
146
177
  const number = typed.getNumber();
147
- // A whole number is written the way the country writes it, with its trunk prefix; a partial one has no such form yet.
148
- const text = number?.isPossible() ? number.formatNational() : formatTyped(country, number?.nationalNumber ?? '');
178
+ // A partial number has no whole form yet, so it is spaced as far as it goes.
179
+ const text = number?.isPossible() ? wholeNumberText(country, number) : formatTyped(country, number?.nationalNumber ?? '');
149
180
  return { country, text };
150
181
  };
151
182
  /**
@@ -213,10 +244,10 @@ const entryFor = (country, significant, position, allowed) => {
213
244
  const entry = fromInternational(digits, country, allowed);
214
245
  if (!entry)
215
246
  return { country, text: formatTyped(country, digits), position: cursor };
216
- // The national digits before the cursor, shifted by any trunk prefix the national format adds in front of them.
247
+ // The national digits before the cursor, shifted by a trunk prefix the shown number adds in front of them or leaves out.
217
248
  const nationalLength = digits.length - 1 - callingCode.length;
218
- const trunkLength = significantChars(entry.text).length - nationalLength;
219
- return { ...entry, position: before.length - callingCode.length + Math.max(0, trunkLength) };
249
+ const trunkShift = significantChars(entry.text).length - nationalLength;
250
+ return { ...entry, position: Math.max(0, before.length - callingCode.length + trunkShift) };
220
251
  };
221
252
  /**
222
253
  * Lists the countries the field offers, named and sorted for the user's language.
@@ -237,9 +268,12 @@ const countryOptions = (locale, allowed) => {
237
268
  * Gives a number that shows a country's format, for the field's placeholder.
238
269
  *
239
270
  * @param country The country to show.
240
- * @returns A mobile number in that country's national format, or `''` when the library has none.
271
+ * @returns A mobile number as it is written after that country's calling code, or `''` when the library has none.
241
272
  */
242
- const exampleNumber = (country) => getExampleNumber(country, examples)?.formatNational() ?? '';
273
+ const exampleNumber = (country) => {
274
+ const example = getExampleNumber(country, examples);
275
+ return example ? wholeNumberText(country, example) : '';
276
+ };
243
277
  // Reads the tag's region alone, so neither an extension key (`en-u-ca-gregory`) nor a POSIX codeset (`en_US.UTF-8`) is taken for one.
244
278
  const localeRegion = (locale) => {
245
279
  try {
@@ -284,5 +318,5 @@ const isFocusInside = (next, parts) => next !== null && parts.some((part) => par
284
318
  */
285
319
  const offeredCountries = (countries) => countries === undefined ? undefined : countries.split(',').filter((code) => isSupportedCountry(code));
286
320
 
287
- export { caretAfter, countryForNumber, countryOptions, editedDigits, entryFor, exampleNumber, formatTyped, fromInternational, isFocusInside, leadingCallingCode, nationalDigits, offeredCountries, significantChars, startingCountry, toInternational };
321
+ export { caretAfter, countryForNumber, countryOptions, editedDigits, entryFor, exampleNumber, formatTyped, fromInternational, isFocusInside, leadingCallingCode, nationalDigits, offeredCountries, settledText, significantChars, startingCountry, toInternational };
288
322
  //# sourceMappingURL=phoneInput.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"phoneInput.utils.js","sources":["../../../../../src/components/atoms/PhoneInput/utilities/phoneInput.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAMA;AACA,MAAM,gBAAgB,GAAqB,IAAI;AAE/C;;;;;AAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAY,KAAY;IACvD,IAAI,WAAW,GAAG,EAAE;AACpB,IAAA,KAAK,MAAM,IAAI,IAAI,IAAI,EA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AC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,KAA+B,kBAAkB,CAAC,IAAI,CAAC;;"}
1
+ {"version":3,"file":"phoneInput.utils.js","sources":["../../../../../src/components/atoms/PhoneInput/utilities/phoneInput.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAcA;AACA,MAAM,gBAAgB,GAAqB,IAAI;AAE/C;;;;;AAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAY,KAAY;IACvD,IAAI,WAAW,GAAG,EAAE;AACpB,IAAA,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;AACvB,QAAA,IAAI,IAAI,KAAK,GAAG,EAAE;YAChB,IAAI,WAAW,KAAK,EAAE;gBAAE,WAAW,GAAG,GAAG;QAC3C;aAAO;AACL,YAAA,WAAW,IAAI,WAAW,CAAC,IAAI,CAAC;QAClC;IACF;AACA,IAAA,OAAO,WAAW;AACpB;AAEA;;;;;;AAMG;MACU,UAAU,GAAG,CAAC,IAAY,EAAE,QAAgB,KAAY;IACnE,IAAI,IAAI,GAAG,CAAC;AACZ,IAAA,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAChD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC;AACnF,QAAA,IAAI,CAAC,aAAa;YAAE;QACpB,IAAI,QAAQ,IAAI,CAAC;AAAE,YAAA,OAAO,KAAK;AAC/B,QAAA,IAAI,EAAE;QACN,IAAI,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM;IAC1F;IACA,OAAO,IAAI,CAA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AAY,CAAC,MAAM,CAAC;IACnC,IAAI,SAAS,CAAC,MAAM,CAAC;AAAE,QAAA,OAAO,MAAM;AACpC,IAAA,OAAO,OAAO,GAAG,CAAC,CAAC,IAAI,gBAAgB;AACzC;AAEA;;;;;;;AAOG;AACI,MAAM,aAAa,GAAG,CAAC,IAAwB,EAAE,KAA+B,KACrF,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE,QAAQ,CAAC,IAAY,CAAC;AAEpE;;;;;AAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,SAA6B,KAC5D,SAAS,KAAK,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,KAA+B,kBAAkB,CAAC,IAAI,CAAC;;"}
@@ -10,6 +10,7 @@ var fieldElements_utils = require('../__internal__/formField/utilities/fieldElem
10
10
  var formFocus_utils = require('../__internal__/formField/utilities/formFocus.utils.cjs');
11
11
  var FormSubmit_context = require('../__internal__/formSubmit/providers/FormSubmit.context.cjs');
12
12
  var useSubmitInTurn = require('./hooks/useSubmitInTurn.cjs');
13
+ var focusFromCode_utils = require('./utilities/focusFromCode.utils.cjs');
13
14
  var formSubmit_utils = require('./utilities/formSubmit.utils.cjs');
14
15
  var useForm = require('./hooks/useForm.cjs');
15
16
  var useSaveForm = require('./hooks/useSaveForm.cjs');
@@ -27,6 +28,9 @@ const FormRoot = ({ form, onSubmit, onInvalid, className, children, 'data-testid
27
28
  const formElement = React.useRef(null);
28
29
  const setFormElement = React.useCallback((element) => {
29
30
  formElement.current = element;
31
+ // A control that turns itself off, such as Discard, hands focus to the form so it is not lost; a click must not.
32
+ if (element)
33
+ focusFromCode_utils.takeFocusFromCodeOnly(element);
30
34
  if (typeof ref === 'function')
31
35
  return ref(element);
32
36
  if (ref)
@@ -45,9 +49,7 @@ const FormRoot = ({ form, onSubmit, onInvalid, className, children, 'data-testid
45
49
  const submit = useSubmitInTurn.useSubmitInTurn(formSubmit_utils.submitAfterValidations(form, onSubmit, focusFirstInvalid));
46
50
  return (jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: jsxRuntime.jsx(FieldElements_context.FieldElementsContext.Provider, { value: fieldElements, children: jsxRuntime.jsx(FormSubmit_context.FormSubmitContext.Provider, { value: requestSubmit, children: jsxRuntime.jsx("form", { ...formProps, ref: setFormElement,
47
51
  // The schema validates; the browser's own checks (`type="email"`, `required`) would block the submit before it runs.
48
- noValidate: true,
49
- // Focusable from code only: a control that turns itself off, such as Discard, hands focus here so it is not lost.
50
- tabIndex: -1, onSubmit: submit, "data-testid": formTestId, className: cx.cx('outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2', className), children: children }) }) }) }));
52
+ noValidate: true, onSubmit: submit, "data-testid": formTestId, className: cx.cx('outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2', className), children: children }) }) }) }));
51
53
  };
52
54
  /**
53
55
  * The `<form>` around `Form*` fields: it provides the react-hook-form form to them, leaves validation to the schema,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../src/components/forms/Form/index.tsx"],"sourcesContent":[null],"names":["forwardRef","useFormState","_jsx","useResolvedTestId","useState","createFieldElements","useRef","useCallback","firstInvalidFieldOnPage","useSubmitInTurn","submitAfterValidations","FormProvider","FieldElementsContext","FormSubmitContext","cx"],"mappings":";;;;;;;;;;;;;;;;AAwDA;AACA,MAAM,UAAU,GAAGA,gBAAU,CAAkC,CAAC,KAAK,EAAE,GAAG,KAAI;AAC5E,IAAA,MAAM,EAAE,YAAY,EAAE,GAAGC,0BAAY,EAAE;IAEvC,OAAOC,cAAA,CAAA,KAAA,EAAA,EAAA,GAAS,KAAK,EAAE,GAAG,EAAE,GAAG,EAAA,WAAA,EAAa,YAAY,EAAA,CAAI;AAC9D,CAAC,CAAC;AACF,UAAU,CAAC,WAAW,GAAG,aAAa;AAEtC,MAAM,QAAQ,GAAG,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AAA,CAACS,0BAAY,EAAA,EAAA,GAAK,IAAI,EAAA,QAAA,EACpBT,cAAA,CAACU,0CAAoB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,aAAa,EAAA,QAAA,EACjDV,cAAA,CAACW,oCAAiB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,aAAa,EAAA,QAAA,EAC9CX,cAAA,CAAA,MAAA,EAAA,EAAA,GACM,SAAS,EACb,GAAG,EAAE,cAAc;;oBAEnB,UAAU,EAAA,IAAA;;oBAEV,QAAQ,EAAE,EAAE,EACZ,QAAQ,EAAE,MAAM,EAAA,aAAA,EACH,UAAU,EACvB,SAAS,EAAEY,KAAE,CAAC,2EAA2E,EAAE,SAAS,CAAC,EAAA,QAAA,EAEpG,QAAQ,EAAA,CACJ,EAAA,CACoB,EAAA,CACC,EAAA,CACnB;AAEnB,CAAC;AAOD;;;;;;AAMG;MACU,IAAI,GAAGd,gBAAU,CAAC,QAAQ;AAEvC,IAAI,CAAC,WAAW,GAAG,MAAM;AACzB,IAAI,CAAC,MAAM,GAAG,UAAU;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/components/forms/Form/index.tsx"],"sourcesContent":[null],"names":["forwardRef","useFormState","_jsx","useResolvedTestId","useState","createFieldElements","useRef","useCallback","takeFocusFromCodeOnly","firstInvalidFieldOnPage","useSubmitInTurn","submitAfterValidations","FormProvider","FieldElementsContext","FormSubmitContext","cx"],"mappings":";;;;;;;;;;;;;;;;;AA6DA;AACA,MAAM,UAAU,GAAGA,gBAAU,CAAkC,CAAC,KAAK,EAAE,GAAG,KAAI;AAC5E,IAAA,MAAM,EAAE,YAAY,EAAE,GAAGC,0BAAY,EAAE;IAEvC,OAAOC,cAAA,CAAA,KAAA,EAAA,EAAA,GAAS,KAAK,EAAE,GAAG,EAAE,GAAG,EAAA,WAAA,EAAa,YAAY,EAAA,CAAI;AAC9D,CAAC,CAAC;AACF,UAAU,CAAC,WAAW,GAAG,aAAa;AAEtC,M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CAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;AAEzF,IAAA,QACET,cAAA,CAACU,0BAAY,EAAA,EAAA,GAAK,IAAI,EAAA,QAAA,EACpBV,cAAA,CAACW,0CAAoB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,aAAa,EAAA,QAAA,EACjDX,cAAA,CAACY,oCAAiB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,aAAa,EAAA,QAAA,EAC9CZ,cAAA,CAAA,MAAA,EAAA,EAAA,GACM,SAAS,EACb,GAAG,EAAE,cAAc;;oBAEnB,UAAU,EAAA,IAAA,EACV,QAAQ,EAAE,MAAM,iBACH,UAAU,EACvB,SAAS,EAAEa,KAAE,CAAC,2EAA2E,EAAE,SAAS,CAAC,EAAA,QAAA,EAEpG,QAAQ,GACJ,EAAA,CACoB,EAAA,CACC,EAAA,CACnB;AAEnB,CAAC;AAOD;;;;;;AAMG;MACU,IAAI,GAAGf,gBAAU,CAAC,QAAQ;AAEvC,IAAI,CAAC,WAAW,GAAG,MAAM;AACzB,IAAI,CAAC,MAAM,GAAG,UAAU;;;;"}
@@ -3,10 +3,16 @@ import { type FieldValues, type SubmitErrorHandler, type SubmitHandler, type Use
3
3
  export { useForm } from './hooks/useForm';
4
4
  export type { SaveFieldError, UseSaveFormOptions, UseSaveFormReturn } from './hooks/useSaveForm';
5
5
  export { useSaveForm } from './hooks/useSaveForm';
6
- export interface FormProps<TValues extends FieldValues = FieldValues, TSubmitValues = TValues> extends Omit<ComponentProps<'form'>, 'onSubmit' | 'onInvalid' | 'noValidate' | 'ref'> {
6
+ /** Form values with no top-level field named as a `<form>` method the library calls: the browser returns a control of that name in the method's place. */
7
+ type NoFieldNamedFocusOrRequestSubmit = {
8
+ focus?: never;
9
+ requestSubmit?: never;
10
+ };
11
+ export interface FormProps<TValues extends FieldValues & NoFieldNamedFocusOrRequestSubmit = FieldValues, TSubmitValues = TValues> extends Omit<ComponentProps<'form'>, 'onSubmit' | 'onInvalid' | 'noValidate' | 'ref'> {
7
12
  /**
8
13
  * The form from this module's `useForm` or `useSaveForm`; every `Form*` field and `FormFooter` beneath reads it. One from
9
14
  * react-hook-form's own `useForm` needs `mode` and `reValidateMode` set to `'onBlur'` and `shouldFocusError` to `false`.
15
+ * Its values cannot hold a top-level field named `focus` or `requestSubmit`; a nested one, such as `camera.focus`, is fine.
10
16
  */
11
17
  form: UseFormReturn<TValues, any, TSubmitValues>;
12
18
  /**
@@ -23,7 +29,7 @@ export interface FormFieldsProps extends Omit<ComponentPropsWithoutRef<'div'>, '
23
29
  }
24
30
  /** Wraps a form's fields and marks them busy while the form submits, which is when they lock themselves. */
25
31
  declare const FormFields: import("react").ForwardRefExoticComponent<FormFieldsProps & RefAttributes<HTMLDivElement>>;
26
- type FormComponent = (<TValues extends FieldValues = FieldValues, TSubmitValues = TValues>(props: FormProps<TValues, TSubmitValues> & RefAttributes<HTMLFormElement>) => ReactElement) & {
32
+ type FormComponent = (<TValues extends FieldValues & NoFieldNamedFocusOrRequestSubmit = FieldValues, TSubmitValues = TValues>(props: FormProps<TValues, TSubmitValues> & RefAttributes<HTMLFormElement>) => ReactElement) & {
27
33
  displayName?: string;
28
34
  Fields: typeof FormFields;
29
35
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/Form/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAG7B,KAAK,YAAY,EACjB,KAAK,aAAa,EAInB,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,aAAa,EAEnB,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC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GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,UAAU,CAAA;CAAE,CAAC;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,EAAsC,aAAa,CAAC"}
@@ -8,6 +8,7 @@ import { createFieldElements } from '../__internal__/formField/utilities/fieldEl
8
8
  import { firstInvalidFieldOnPage } from '../__internal__/formField/utilities/formFocus.utils.js';
9
9
  import { FormSubmitContext } from '../__internal__/formSubmit/providers/FormSubmit.context.js';
10
10
  import { useSubmitInTurn } from './hooks/useSubmitInTurn.js';
11
+ import { takeFocusFromCodeOnly } from './utilities/focusFromCode.utils.js';
11
12
  import { submitAfterValidations } from './utilities/formSubmit.utils.js';
12
13
  export { useForm } from './hooks/useForm.js';
13
14
  export { useSaveForm } from './hooks/useSaveForm.js';
@@ -25,6 +26,9 @@ const FormRoot = ({ form, onSubmit, onInvalid, className, children, 'data-testid
25
26
  const formElement = useRef(null);
26
27
  const setFormElement = useCallback((element) => {
27
28
  formElement.current = element;
29
+ // A control that turns itself off, such as Discard, hands focus to the form so it is not lost; a click must not.
30
+ if (element)
31
+ takeFocusFromCodeOnly(element);
28
32
  if (typeof ref === 'function')
29
33
  return ref(element);
30
34
  if (ref)
@@ -43,9 +47,7 @@ const FormRoot = ({ form, onSubmit, onInvalid, className, children, 'data-testid
43
47
  const submit = useSubmitInTurn(submitAfterValidations(form, onSubmit, focusFirstInvalid));
44
48
  return (jsx(FormProvider, { ...form, children: jsx(FieldElementsContext.Provider, { value: fieldElements, children: jsx(FormSubmitContext.Provider, { value: requestSubmit, children: jsx("form", { ...formProps, ref: setFormElement,
45
49
  // The schema validates; the browser's own checks (`type="email"`, `required`) would block the submit before it runs.
46
- noValidate: true,
47
- // Focusable from code only: a control that turns itself off, such as Discard, hands focus here so it is not lost.
48
- tabIndex: -1, onSubmit: submit, "data-testid": formTestId, className: cx('outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2', className), children: children }) }) }) }));
50
+ noValidate: true, onSubmit: submit, "data-testid": formTestId, className: cx('outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2', className), children: children }) }) }) }));
49
51
  };
50
52
  /**
51
53
  * The `<form>` around `Form*` fields: it provides the react-hook-form form to them, leaves validation to the schema,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/forms/Form/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;AAwDA;AACA,MAAM,UAAU,GAAG,UAAU,CAAkC,CAAC,KAAK,EAAE,GAAG,KAAI;AAC5E,IAAA,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE;IAEvC,OAAOA,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,KAAK,EAAE,GAAG,EAAE,GAAG,EAAA,WAAA,EAAa,YAAY,EAAA,CAAI;AAC9D,CAAC,CAAC;AACF,UAAU,CAAC,WAAW,GAAG,aAAa;AAEtC,MAAM,QAAQ,GAAG,CACf,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,SAAS,EAAqC,EAC9H,GAAkC,KAChC;AACF,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC/F,MAAM,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAC,mBAAmB,CAAC;;AAGrD,IAAA,MAAM,WAAW,GAAG,MAAM,CAAyB,IAAI,CAAC;AACxD,IAAA,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,OAA+B,KAAI;AAClC,QAAA,WAAW,CAAC,OAAO,GAAG,OAAO;QAC7B,IAAI,OAAO,GAAG,KAAK,UAAU;AAAE,YAAA,OAAO,GAAG,CAAC,OAAO,CAAC;AAClD,QAAA,IAAI,GAAG;AAAE,YAAA,GAAG,CAAC,O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= new WeakSet();
5
+ /**
6
+ * Lets an element take focus from code and never from a click. With a standing `tabIndex={-1}` the browser hands it the
7
+ * focus of a click on anything inside that cannot hold focus, such as a disabled field or the space between fields, so
8
+ * the element is focusable only from a `focus()` call until that focus leaves.
9
+ *
10
+ * @param element The element to focus from code, such as a `<form>` a control hands focus to. One given a `tabindex` of
11
+ * its own keeps it, and takes focus as the browser decides.
12
+ * @returns Nothing. The element's own `focus` method is replaced, except on a form with a control named `focus`, which
13
+ * the browser returns in the method's place.
14
+ */
15
+ const takeFocusFromCodeOnly = (element) => {
16
+ if (wrapped.has(element))
17
+ return;
18
+ wrapped.add(element);
19
+ // Taken from the prototype: a form names its controls as properties, so `element.focus` may be a control named `focus`.
20
+ const focusNatively = (options) => HTMLElement.prototype.focus.call(element, options);
21
+ // Asked of the element's own root: inside a shadow root the document names the host as the active element.
22
+ const hasFocus = () => element.getRootNode().activeElement === element;
23
+ const release = () => {
24
+ // A window that loses focus blurs the element too, and must find it focusable when it comes back.
25
+ if (hasFocus())
26
+ return;
27
+ // A `tabindex` the app has set since is the app's own, and stays.
28
+ if (element.getAttribute('tabindex') === '-1')
29
+ element.removeAttribute('tabindex');
30
+ element.removeEventListener('blur', release);
31
+ };
32
+ const focus = (options) => {
33
+ if (element.hasAttribute('tabindex'))
34
+ return focusNatively(options);
35
+ element.setAttribute('tabindex', '-1');
36
+ focusNatively(options);
37
+ if (hasFocus())
38
+ element.addEventListener('blur', release);
39
+ else
40
+ element.removeAttribute('tabindex');
41
+ };
42
+ // Defined, as a prototype setter such as Storybook's would take an assignment for every element; by `Reflect`, as a form whose control holds the name must not throw.
43
+ Reflect.defineProperty(element, 'focus', { configurable: true, writable: true, value: focus });
44
+ };
45
+
46
+ exports.takeFocusFromCodeOnly = takeFocusFromCodeOnly;
47
+ //# sourceMappingURL=focusFromCode.utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focusFromCode.utils.cjs","sources":["../../../../../src/components/forms/Form/utilities/focusFromCode.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AE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAChG;;"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Lets an element take focus from code and never from a click. With a standing `tabIndex={-1}` the browser hands it the
3
+ * focus of a click on anything inside that cannot hold focus, such as a disabled field or the space between fields, so
4
+ * the element is focusable only from a `focus()` call until that focus leaves.
5
+ *
6
+ * @param element The element to focus from code, such as a `<form>` a control hands focus to. One given a `tabindex` of
7
+ * its own keeps it, and takes focus as the browser decides.
8
+ * @returns Nothing. The element's own `focus` method is replaced, except on a form with a control named `focus`, which
9
+ * the browser returns in the method's place.
10
+ */
11
+ export declare const takeFocusFromCodeOnly: (element: HTMLElement) => void;
12
+ //# sourceMappingURL=focusFromCode.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focusFromCode.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/Form/utilities/focusFromCode.utils.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,WAAW,KAAG,IAyB5D,CAAC"}
@@ -0,0 +1,45 @@
1
+ // A ref callback runs again when the ref it wraps changes, and must not wrap an element's method twice.
2
+ const wrapped = new WeakSet();
3
+ /**
4
+ * Lets an element take focus from code and never from a click. With a standing `tabIndex={-1}` the browser hands it the
5
+ * focus of a click on anything inside that cannot hold focus, such as a disabled field or the space between fields, so
6
+ * the element is focusable only from a `focus()` call until that focus leaves.
7
+ *
8
+ * @param element The element to focus from code, such as a `<form>` a control hands focus to. One given a `tabindex` of
9
+ * its own keeps it, and takes focus as the browser decides.
10
+ * @returns Nothing. The element's own `focus` method is replaced, except on a form with a control named `focus`, which
11
+ * the browser returns in the method's place.
12
+ */
13
+ const takeFocusFromCodeOnly = (element) => {
14
+ if (wrapped.has(element))
15
+ return;
16
+ wrapped.add(element);
17
+ // Taken from the prototype: a form names its controls as properties, so `element.focus` may be a control named `focus`.
18
+ const focusNatively = (options) => HTMLElement.prototype.focus.call(element, options);
19
+ // Asked of the element's own root: inside a shadow root the document names the host as the active element.
20
+ const hasFocus = () => element.getRootNode().activeElement === element;
21
+ const release = () => {
22
+ // A window that loses focus blurs the element too, and must find it focusable when it comes back.
23
+ if (hasFocus())
24
+ return;
25
+ // A `tabindex` the app has set since is the app's own, and stays.
26
+ if (element.getAttribute('tabindex') === '-1')
27
+ element.removeAttribute('tabindex');
28
+ element.removeEventListener('blur', release);
29
+ };
30
+ const focus = (options) => {
31
+ if (element.hasAttribute('tabindex'))
32
+ return focusNatively(options);
33
+ element.setAttribute('tabindex', '-1');
34
+ focusNatively(options);
35
+ if (hasFocus())
36
+ element.addEventListener('blur', release);
37
+ else
38
+ element.removeAttribute('tabindex');
39
+ };
40
+ // Defined, as a prototype setter such as Storybook's would take an assignment for every element; by `Reflect`, as a form whose control holds the name must not throw.
41
+ Reflect.defineProperty(element, 'focus', { configurable: true, writable: true, value: focus });
42
+ };
43
+
44
+ export { takeFocusFromCodeOnly };
45
+ //# sourceMappingURL=focusFromCode.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focusFromCode.utils.js","sources":["../../../../../src/components/forms/Form/utilities/focusFromCode.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,MAAM,OAAO,GAAG,IAAI,OAAO,EAAe;AAE1C;;;;;;;;;AASG;AACI,MAAM,qBAAqB,GAAG,CAAC,OAAoB,KAAU;AAClE,IAAA,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE;AAC1B,IAAA,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;;AAEpB,IAAA,MAAM,aAAa,GAAG,CAAC,OAAsB,KAAK,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;;AAEpG,IAAA,MAAM,QAAQ,GAAG,MAAO,OAAO,CAAC,WAAW,EAA4B,CAAC,aAAa,KAAK,OAAO;IAEjG,MAAM,OAAO,GAAG,MAAK;;AAEnB,QAAA,IAAI,QAAQ,EAAE;YAAE;;AAEhB,QAAA,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,IAAI;AAAE,YAAA,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC;AAClF,QAAA,OAAO,CAAC,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC;AAC9C,IAAA,CAAC;AAED,IAAA,MAAM,KAAK,GAAG,CAAC,OAAsB,KAAI;AACvC,QAAA,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC;AAAE,YAAA,OAAO,aAAa,CAAC,OAAO,CAAC;AACnE,QAAA,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC;QACtC,aAAa,CAAC,OAAO,CAAC;AACtB,QAAA,IAAI,QAAQ,EAAE;AAAE,YAAA,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC;;AACpD,YAAA,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC;AAC1C,IAAA,CAAC;;IAED,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAChG;;"}
@@ -9,7 +9,7 @@ var React = require('react');
9
9
  * @param targetSelector A CSS selector for the control that should take focus, looked up inside each container in turn.
10
10
  * @param containerSelector A CSS selector for the containers, matched against `origin` and its ancestors, nearest first.
11
11
  * @returns The element that took focus: the first target that can, in the nearest container that holds one, else the nearest
12
- * container that can take focus itself (it needs `tabIndex={-1}`), else `null` when nothing could.
12
+ * container that can take focus itself (a `Form`, or one given `tabIndex={-1}`), else `null` when nothing could.
13
13
  */
14
14
  const moveFocusWithin = (origin, targetSelector, containerSelector) => {
15
15
  const containers = [];
@@ -34,7 +34,7 @@ const moveFocusWithin = (origin, targetSelector, containerSelector) => {
34
34
  * remove. Call `returnFocus` first, then run the action that unmounts or disables the focused element.
35
35
  *
36
36
  * @param targetSelector A CSS selector for the control that takes focus, found inside the nearest container that holds one; with none, `returnFocus` does nothing.
37
- * @param containerSelector A CSS selector for that container; it takes focus itself when the target cannot, so give it `tabIndex={-1}`.
37
+ * @param containerSelector A CSS selector for that container; it takes focus itself when the target cannot, so give it `tabIndex={-1}` unless it is a `Form`.
38
38
  * @returns `originRef` for an element inside the container, and `returnFocus`, which moves focus and reports where it landed.
39
39
  */
40
40
  const useReturnFocus = (targetSelector, containerSelector = 'form, section') => {
@@ -5,7 +5,7 @@
5
5
  * @param targetSelector A CSS selector for the control that should take focus, looked up inside each container in turn.
6
6
  * @param containerSelector A CSS selector for the containers, matched against `origin` and its ancestors, nearest first.
7
7
  * @returns The element that took focus: the first target that can, in the nearest container that holds one, else the nearest
8
- * container that can take focus itself (it needs `tabIndex={-1}`), else `null` when nothing could.
8
+ * container that can take focus itself (a `Form`, or one given `tabIndex={-1}`), else `null` when nothing could.
9
9
  */
10
10
  export declare const moveFocusWithin: (origin: Element | null, targetSelector: string, containerSelector: string) => HTMLElement | null;
11
11
  /**
@@ -13,7 +13,7 @@ export declare const moveFocusWithin: (origin: Element | null, targetSelector: s
13
13
  * remove. Call `returnFocus` first, then run the action that unmounts or disables the focused element.
14
14
  *
15
15
  * @param targetSelector A CSS selector for the control that takes focus, found inside the nearest container that holds one; with none, `returnFocus` does nothing.
16
- * @param containerSelector A CSS selector for that container; it takes focus itself when the target cannot, so give it `tabIndex={-1}`.
16
+ * @param containerSelector A CSS selector for that container; it takes focus itself when the target cannot, so give it `tabIndex={-1}` unless it is a `Form`.
17
17
  * @returns `originRef` for an element inside the container, and `returnFocus`, which moves focus and reports where it landed.
18
18
  */
19
19
  export declare const useReturnFocus: <TOrigin extends HTMLElement = HTMLElement>(targetSelector: string | undefined, containerSelector?: string) => {
@@ -7,7 +7,7 @@ import { useRef } from 'react';
7
7
  * @param targetSelector A CSS selector for the control that should take focus, looked up inside each container in turn.
8
8
  * @param containerSelector A CSS selector for the containers, matched against `origin` and its ancestors, nearest first.
9
9
  * @returns The element that took focus: the first target that can, in the nearest container that holds one, else the nearest
10
- * container that can take focus itself (it needs `tabIndex={-1}`), else `null` when nothing could.
10
+ * container that can take focus itself (a `Form`, or one given `tabIndex={-1}`), else `null` when nothing could.
11
11
  */
12
12
  const moveFocusWithin = (origin, targetSelector, containerSelector) => {
13
13
  const containers = [];
@@ -32,7 +32,7 @@ const moveFocusWithin = (origin, targetSelector, containerSelector) => {
32
32
  * remove. Call `returnFocus` first, then run the action that unmounts or disables the focused element.
33
33
  *
34
34
  * @param targetSelector A CSS selector for the control that takes focus, found inside the nearest container that holds one; with none, `returnFocus` does nothing.
35
- * @param containerSelector A CSS selector for that container; it takes focus itself when the target cannot, so give it `tabIndex={-1}`.
35
+ * @param containerSelector A CSS selector for that container; it takes focus itself when the target cannot, so give it `tabIndex={-1}` unless it is a `Form`.
36
36
  * @returns `originRef` for an element inside the container, and `returnFocus`, which moves focus and reports where it landed.
37
37
  */
38
38
  const useReturnFocus = (targetSelector, containerSelector = 'form, section') => {
@@ -10,7 +10,7 @@ const FOCUS_TARGET_CLASSES = 'outline-focus-ring focus-visible:outline-2 focus-v
10
10
  *
11
11
  * @param retry Starts the failed request again.
12
12
  * @returns `retryLoad` for the retry button, and for the element that replaces the error either `contentProps` to spread
13
- * onto it (the ref, `tabIndex={-1}` and a focus ring) or `contentRef` alone when it is already focusable, as `Form` is.
13
+ * onto it (the ref, `tabIndex={-1}` and a focus ring) or `contentRef` alone when it already takes focus from code, as `Form` does.
14
14
  * That element takes focus when it mounts after a retry, unless the user has moved focus elsewhere.
15
15
  */
16
16
  const useFocusAfterRetry = (retry) => {
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @param retry Starts the failed request again.
6
6
  * @returns `retryLoad` for the retry button, and for the element that replaces the error either `contentProps` to spread
7
- * onto it (the ref, `tabIndex={-1}` and a focus ring) or `contentRef` alone when it is already focusable, as `Form` is.
7
+ * onto it (the ref, `tabIndex={-1}` and a focus ring) or `contentRef` alone when it already takes focus from code, as `Form` does.
8
8
  * That element takes focus when it mounts after a retry, unless the user has moved focus elsewhere.
9
9
  */
10
10
  export declare const useFocusAfterRetry: (retry: () => unknown) => {
@@ -8,7 +8,7 @@ const FOCUS_TARGET_CLASSES = 'outline-focus-ring focus-visible:outline-2 focus-v
8
8
  *
9
9
  * @param retry Starts the failed request again.
10
10
  * @returns `retryLoad` for the retry button, and for the element that replaces the error either `contentProps` to spread
11
- * onto it (the ref, `tabIndex={-1}` and a focus ring) or `contentRef` alone when it is already focusable, as `Form` is.
11
+ * onto it (the ref, `tabIndex={-1}` and a focus ring) or `contentRef` alone when it already takes focus from code, as `Form` does.
12
12
  * That element takes focus when it mounts after a retry, unless the user has moved focus elsewhere.
13
13
  */
14
14
  const useFocusAfterRetry = (retry) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flipdish/ui-library",
3
- "version": "0.68.0",
3
+ "version": "0.69.0",
4
4
  "description": "Flipdish Design System — atomic-design component library (Tailwind v4 + UntitledUI + React Aria).",
5
5
  "type": "module",
6
6
  "imports": {
@@ -275,7 +275,7 @@
275
275
  "@storybook/addon-a11y": "^10.5.8",
276
276
  "@storybook/addon-docs": "^10.5.8",
277
277
  "@storybook/addon-mcp": "^0.7.0",
278
- "@storybook/addon-vitest": "10.6.7",
278
+ "@storybook/addon-vitest": "10.6.8",
279
279
  "@storybook/react-vite": "^10.5.8",
280
280
  "@tailwindcss/vite": "^4.3.1",
281
281
  "@tanstack/react-query": "^5.104.3",