@flipdish/ui-library 0.69.0 → 0.70.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 (146) hide show
  1. package/README.md +2 -2
  2. package/dist/components/atoms/Buttons/Button/hooks/useLoadingLinkPress.d.ts +1 -1
  3. package/dist/components/atoms/LiveStatus/index.cjs +18 -0
  4. package/dist/components/atoms/LiveStatus/index.cjs.map +1 -0
  5. package/dist/components/atoms/LiveStatus/index.d.ts +17 -0
  6. package/dist/components/atoms/LiveStatus/index.d.ts.map +1 -0
  7. package/dist/components/atoms/LiveStatus/index.js +16 -0
  8. package/dist/components/atoms/LiveStatus/index.js.map +1 -0
  9. package/dist/components/forms/Form/index.cjs +1 -1
  10. package/dist/components/forms/Form/index.js +1 -1
  11. package/dist/components/molecules/Dropdown/index.d.ts +2 -2
  12. package/dist/components/molecules/Tags/TagGroup/TagGroup.d.ts +1 -1
  13. package/dist/components/molecules/Tags/TagGroup/TagGroup.d.ts.map +1 -1
  14. package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.cjs +2 -0
  15. package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.cjs.map +1 -1
  16. package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.d.ts +10 -0
  17. package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.d.ts.map +1 -1
  18. package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.js +2 -0
  19. package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.js.map +1 -1
  20. package/dist/components/organisms/Table/Table.styles.cjs +29 -0
  21. package/dist/components/organisms/Table/Table.styles.cjs.map +1 -0
  22. package/dist/components/organisms/Table/Table.styles.d.ts +16 -0
  23. package/dist/components/organisms/Table/Table.styles.d.ts.map +1 -0
  24. package/dist/components/organisms/Table/Table.styles.js +27 -0
  25. package/dist/components/organisms/Table/Table.styles.js.map +1 -0
  26. package/dist/components/organisms/Table/components/TableCardRow.cjs +2 -1
  27. package/dist/components/organisms/Table/components/TableCardRow.cjs.map +1 -1
  28. package/dist/components/organisms/Table/components/TableCardRow.d.ts.map +1 -1
  29. package/dist/components/organisms/Table/components/TableCardRow.js +2 -1
  30. package/dist/components/organisms/Table/components/TableCardRow.js.map +1 -1
  31. package/dist/components/organisms/Table/components/TableCardsSelectAll.cjs +2 -2
  32. package/dist/components/organisms/Table/components/TableCardsSelectAll.cjs.map +1 -1
  33. package/dist/components/organisms/Table/components/TableCardsSelectAll.d.ts +3 -1
  34. package/dist/components/organisms/Table/components/TableCardsSelectAll.d.ts.map +1 -1
  35. package/dist/components/organisms/Table/components/TableCardsSelectAll.js +2 -2
  36. package/dist/components/organisms/Table/components/TableCardsSelectAll.js.map +1 -1
  37. package/dist/components/organisms/Table/components/TableRowCard.cjs +3 -2
  38. package/dist/components/organisms/Table/components/TableRowCard.cjs.map +1 -1
  39. package/dist/components/organisms/Table/components/TableRowCard.d.ts +1 -1
  40. package/dist/components/organisms/Table/components/TableRowCard.d.ts.map +1 -1
  41. package/dist/components/organisms/Table/components/TableRowCard.js +3 -2
  42. package/dist/components/organisms/Table/components/TableRowCard.js.map +1 -1
  43. package/dist/components/organisms/Table/components/TableSortMenu.cjs +4 -4
  44. package/dist/components/organisms/Table/components/TableSortMenu.cjs.map +1 -1
  45. package/dist/components/organisms/Table/components/TableSortMenu.d.ts +5 -5
  46. package/dist/components/organisms/Table/components/TableSortMenu.d.ts.map +1 -1
  47. package/dist/components/organisms/Table/components/TableSortMenu.js +4 -4
  48. package/dist/components/organisms/Table/components/TableSortMenu.js.map +1 -1
  49. package/dist/components/organisms/Table/hooks/useBusyCount.cjs +22 -0
  50. package/dist/components/organisms/Table/hooks/useBusyCount.cjs.map +1 -0
  51. package/dist/components/organisms/Table/hooks/useBusyCount.d.ts +12 -0
  52. package/dist/components/organisms/Table/hooks/useBusyCount.d.ts.map +1 -0
  53. package/dist/components/organisms/Table/hooks/useBusyCount.js +20 -0
  54. package/dist/components/organisms/Table/hooks/useBusyCount.js.map +1 -0
  55. package/dist/components/organisms/Table/hooks/useIsPlaceholderPage.cjs +42 -0
  56. package/dist/components/organisms/Table/hooks/useIsPlaceholderPage.cjs.map +1 -0
  57. package/dist/components/organisms/Table/hooks/useIsPlaceholderPage.d.ts +14 -0
  58. package/dist/components/organisms/Table/hooks/useIsPlaceholderPage.d.ts.map +1 -0
  59. package/dist/components/organisms/Table/hooks/useIsPlaceholderPage.js +40 -0
  60. package/dist/components/organisms/Table/hooks/useIsPlaceholderPage.js.map +1 -0
  61. package/dist/components/organisms/Table/hooks/usePlaceholderRows.cjs +8 -11
  62. package/dist/components/organisms/Table/hooks/usePlaceholderRows.cjs.map +1 -1
  63. package/dist/components/organisms/Table/hooks/usePlaceholderRows.d.ts +9 -2
  64. package/dist/components/organisms/Table/hooks/usePlaceholderRows.d.ts.map +1 -1
  65. package/dist/components/organisms/Table/hooks/usePlaceholderRows.js +9 -12
  66. package/dist/components/organisms/Table/hooks/usePlaceholderRows.js.map +1 -1
  67. package/dist/components/organisms/Table/hooks/useTableSelection.cjs +12 -4
  68. package/dist/components/organisms/Table/hooks/useTableSelection.cjs.map +1 -1
  69. package/dist/components/organisms/Table/hooks/useTableSelection.d.ts +4 -2
  70. package/dist/components/organisms/Table/hooks/useTableSelection.d.ts.map +1 -1
  71. package/dist/components/organisms/Table/hooks/useTableSelection.js +12 -4
  72. package/dist/components/organisms/Table/hooks/useTableSelection.js.map +1 -1
  73. package/dist/components/organisms/Table/index.cjs +65 -24
  74. package/dist/components/organisms/Table/index.cjs.map +1 -1
  75. package/dist/components/organisms/Table/index.d.ts +17 -3
  76. package/dist/components/organisms/Table/index.d.ts.map +1 -1
  77. package/dist/components/organisms/Table/index.js +67 -26
  78. package/dist/components/organisms/Table/index.js.map +1 -1
  79. package/dist/components/organisms/Table/providers/Table.context.cjs.map +1 -1
  80. package/dist/components/organisms/Table/providers/Table.context.d.ts +11 -2
  81. package/dist/components/organisms/Table/providers/Table.context.d.ts.map +1 -1
  82. package/dist/components/organisms/Table/providers/Table.context.js.map +1 -1
  83. package/dist/components/organisms/Table/table.types.d.ts +9 -1
  84. package/dist/components/organisms/Table/table.types.d.ts.map +1 -1
  85. package/dist/components/organisms/Table/utilities/tableCard.utils.cjs.map +1 -1
  86. package/dist/components/organisms/Table/utilities/tableCard.utils.d.ts +1 -1
  87. package/dist/components/organisms/Table/utilities/tableCard.utils.d.ts.map +1 -1
  88. package/dist/components/organisms/Table/utilities/tableCard.utils.js.map +1 -1
  89. package/dist/components/organisms/Table/utilities/tableChildren.utils.cjs +7 -4
  90. package/dist/components/organisms/Table/utilities/tableChildren.utils.cjs.map +1 -1
  91. package/dist/components/organisms/Table/utilities/tableChildren.utils.d.ts +4 -2
  92. package/dist/components/organisms/Table/utilities/tableChildren.utils.d.ts.map +1 -1
  93. package/dist/components/organisms/Table/utilities/tableChildren.utils.js +7 -4
  94. package/dist/components/organisms/Table/utilities/tableChildren.utils.js.map +1 -1
  95. package/dist/components/organisms/Table/utilities/tableIterable.utils.cjs +23 -0
  96. package/dist/components/organisms/Table/utilities/tableIterable.utils.cjs.map +1 -0
  97. package/dist/components/organisms/Table/utilities/tableIterable.utils.d.ts +8 -0
  98. package/dist/components/organisms/Table/utilities/tableIterable.utils.d.ts.map +1 -0
  99. package/dist/components/organisms/Table/utilities/tableIterable.utils.js +21 -0
  100. package/dist/components/organisms/Table/utilities/tableIterable.utils.js.map +1 -0
  101. package/dist/components/organisms/Table/utilities/tableLoading.utils.cjs +57 -0
  102. package/dist/components/organisms/Table/utilities/tableLoading.utils.cjs.map +1 -0
  103. package/dist/components/organisms/Table/utilities/tableLoading.utils.d.ts +66 -0
  104. package/dist/components/organisms/Table/utilities/tableLoading.utils.d.ts.map +1 -0
  105. package/dist/components/organisms/Table/utilities/tableLoading.utils.js +52 -0
  106. package/dist/components/organisms/Table/utilities/tableLoading.utils.js.map +1 -0
  107. package/dist/components/organisms/Table/utilities/tableSelection.utils.cjs +21 -21
  108. package/dist/components/organisms/Table/utilities/tableSelection.utils.cjs.map +1 -1
  109. package/dist/components/organisms/Table/utilities/tableSelection.utils.d.ts +29 -19
  110. package/dist/components/organisms/Table/utilities/tableSelection.utils.d.ts.map +1 -1
  111. package/dist/components/organisms/Table/utilities/tableSelection.utils.js +20 -21
  112. package/dist/components/organisms/Table/utilities/tableSelection.utils.js.map +1 -1
  113. package/dist/components/organisms/Table/utilities/tableSort.utils.cjs +1 -1
  114. package/dist/components/organisms/Table/utilities/tableSort.utils.d.ts +1 -1
  115. package/dist/components/organisms/Table/utilities/tableSort.utils.js +1 -1
  116. package/dist/hooks/useFocusAfterRetry/index.cjs +21 -19
  117. package/dist/hooks/useFocusAfterRetry/index.cjs.map +1 -1
  118. package/dist/hooks/useFocusAfterRetry/index.d.ts +15 -5
  119. package/dist/hooks/useFocusAfterRetry/index.d.ts.map +1 -1
  120. package/dist/hooks/useFocusAfterRetry/index.js +21 -19
  121. package/dist/hooks/useFocusAfterRetry/index.js.map +1 -1
  122. package/dist/hooks/useFocusHandOff/index.cjs +67 -0
  123. package/dist/hooks/useFocusHandOff/index.cjs.map +1 -0
  124. package/dist/hooks/useFocusHandOff/index.d.ts +17 -0
  125. package/dist/hooks/useFocusHandOff/index.d.ts.map +1 -0
  126. package/dist/hooks/useFocusHandOff/index.js +65 -0
  127. package/dist/hooks/useFocusHandOff/index.js.map +1 -0
  128. package/dist/native/components/atoms/LiveStatus/index.d.ts +12 -0
  129. package/dist/native/hooks/useFocusHandOff/index.d.ts +12 -0
  130. package/dist/styles.css +12 -0
  131. package/dist/{components/forms/Form/utilities → utilities/__internal__/focusUtils}/focusFromCode.utils.cjs +9 -0
  132. package/dist/utilities/__internal__/focusUtils/focusFromCode.utils.cjs.map +1 -0
  133. package/dist/{components/forms/Form/utilities → utilities/__internal__/focusUtils}/focusFromCode.utils.d.ts +8 -0
  134. package/dist/utilities/__internal__/focusUtils/focusFromCode.utils.d.ts.map +1 -0
  135. package/dist/{components/forms/Form/utilities → utilities/__internal__/focusUtils}/focusFromCode.utils.js +9 -1
  136. package/dist/utilities/__internal__/focusUtils/focusFromCode.utils.js.map +1 -0
  137. package/package.json +7 -7
  138. package/dist/components/forms/Form/utilities/focusFromCode.utils.cjs.map +0 -1
  139. package/dist/components/forms/Form/utilities/focusFromCode.utils.d.ts.map +0 -1
  140. package/dist/components/forms/Form/utilities/focusFromCode.utils.js.map +0 -1
  141. package/dist/components/organisms/Table/components/TableFocusGuard.cjs +0 -23
  142. package/dist/components/organisms/Table/components/TableFocusGuard.cjs.map +0 -1
  143. package/dist/components/organisms/Table/components/TableFocusGuard.d.ts +0 -2
  144. package/dist/components/organisms/Table/components/TableFocusGuard.d.ts.map +0 -1
  145. package/dist/components/organisms/Table/components/TableFocusGuard.js +0 -21
  146. package/dist/components/organisms/Table/components/TableFocusGuard.js.map +0 -1
@@ -1,34 +1,36 @@
1
1
  'use strict';
2
2
 
3
- var React = require('react');
3
+ var useFocusHandOff = require('@flipdish/ui-library/hooks/useFocusHandOff');
4
4
 
5
- // The ring shows for keyboard focus only, as on every other focus target in the library.
5
+ // The ring `contentProps` spreads, for the callers still on it.
6
6
  const FOCUS_TARGET_CLASSES = 'outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2';
7
7
  /**
8
8
  * Keeps keyboard focus in place across a retry. A "Try again" button unmounts once the data arrives, and focus would
9
9
  * otherwise fall back to the top of the page; use it wherever a load error is replaced by the content it failed to load.
10
+ * It is `useFocusHandOff` for one action; for several controls that hand focus on, use that hook.
10
11
  *
11
12
  * @param retry Starts the failed request again.
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 already takes focus from code, as `Form` does.
14
- * That element takes focus when it mounts after a retry, unless the user has moved focus elsewhere.
13
+ * @returns `retryLoad` for the retry button, and `contentRef` for the element that replaces the error. That element takes
14
+ * focus when it mounts after a retry, unless the user has moved focus elsewhere; one that cannot take focus is made
15
+ * focusable from code only, so a click inside it does not give it focus, with the library's keyboard focus ring. `contentRef`
16
+ * is the same function on every render, so only a target that mounts after `retryLoad` is called spends the retry.
17
+ * `contentProps` is deprecated.
15
18
  */
16
19
  const useFocusAfterRetry = (retry) => {
17
- const hasRetried = React.useRef(false);
18
- const retryLoad = () => {
19
- hasRetried.current = true;
20
- retry();
20
+ const { handOff, targetRef } = useFocusHandOff.useFocusHandOff();
21
+ const retryLoad = handOff(retry);
22
+ return {
23
+ retryLoad,
24
+ contentRef: targetRef,
25
+ /**
26
+ * The ref, `tabIndex={-1}` and the focus ring as props to spread.
27
+ *
28
+ * @deprecated Pass `contentRef` as the target's `ref` instead: the hook makes the target focusable from code only and the
29
+ * library draws the ring, so the target keeps its own `className` without merging. The standing `tabIndex={-1}` spread
30
+ * here, unlike `contentRef`, also hands the target the focus of a click on anything inside it that cannot hold focus.
31
+ */
32
+ contentProps: { ref: targetRef, tabIndex: -1, className: FOCUS_TARGET_CLASSES },
21
33
  };
22
- const contentRef = (content) => {
23
- if (!content || !hasRetried.current)
24
- return;
25
- hasRetried.current = false;
26
- // Focus sits on `<body>` only when the button it was on is gone; anywhere else, the user chose it.
27
- if (content.ownerDocument.activeElement === content.ownerDocument.body)
28
- content.focus();
29
- };
30
- const contentProps = { ref: contentRef, tabIndex: -1, className: FOCUS_TARGET_CLASSES };
31
- return { retryLoad, contentRef, contentProps };
32
34
  };
33
35
 
34
36
  exports.useFocusAfterRetry = useFocusAfterRetry;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"sourcesContent":[null],"names":["useRef"],"mappings":";;;;AAIA;AACA,MAAM,oBAAoB,GAAG,2EAA2E;AAExG;;;;;;;;AAQG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAoB,KAAI;AACzD,IAAA,MAAM,UAAU,GAAGA,YAAM,CAAC,KAAK,CAAC;IAEhC,MAAM,SAAS,GAAG,MAAK;AACrB,QAAA,UAAU,CAAC,OAAO,GAAG,IAAI;AACzB,QAAA,KAAK,EAAE;AACT,IAAA,CAAC;AAED,IAAA,MAAM,UAAU,GAAG,CAAC,OAA2B,KAAI;AACjD,QAAA,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO;YAAE;AACrC,QAAA,UAAU,CAAC,OAAO,GAAG,KAAK;;QAE1B,IAAI,OAAO,CAAC,aAAa,CAAC,aAAa,KAAK,OAAO,CAAC,aAAa,CAAC,IAAI;YAAE,OAAO,CAAC,KAAK,EAAE;AACzF,IAAA,CAAC;AAED,IAAA,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,oBAAoB,EAAW;AAEhG,IAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE;AAChD;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"sourcesContent":[null],"names":["useFocusHandOff"],"mappings":";;;;AAIA;AACA,MAAM,oBAAoB,GAAG,2EAA2E;AAExG;;;;;;;;;;;AAWG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAoB,KAAI;IACzD,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAGA,+BAAe,EAAE;AAEhD,IAAA,MAAM,SAAS,GAAe,OAAO,CAAC,KAAK,CAAC;IAE5C,OAAO;QACL,SAAS;AACT,QAAA,UAAU,EAAE,SAAS;AACrB;;;;;;AAMG;AACH,QAAA,YAAY,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,oBAAoB,EAAW;KACzF;AACH;;"}
@@ -1,17 +1,27 @@
1
1
  /**
2
2
  * Keeps keyboard focus in place across a retry. A "Try again" button unmounts once the data arrives, and focus would
3
3
  * otherwise fall back to the top of the page; use it wherever a load error is replaced by the content it failed to load.
4
+ * It is `useFocusHandOff` for one action; for several controls that hand focus on, use that hook.
4
5
  *
5
6
  * @param retry Starts the failed request again.
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 already takes focus from code, as `Form` does.
8
- * That element takes focus when it mounts after a retry, unless the user has moved focus elsewhere.
7
+ * @returns `retryLoad` for the retry button, and `contentRef` for the element that replaces the error. That element takes
8
+ * focus when it mounts after a retry, unless the user has moved focus elsewhere; one that cannot take focus is made
9
+ * focusable from code only, so a click inside it does not give it focus, with the library's keyboard focus ring. `contentRef`
10
+ * is the same function on every render, so only a target that mounts after `retryLoad` is called spends the retry.
11
+ * `contentProps` is deprecated.
9
12
  */
10
13
  export declare const useFocusAfterRetry: (retry: () => unknown) => {
11
14
  retryLoad: () => void;
12
- contentRef: (content: HTMLElement | null) => void;
15
+ contentRef: (target: HTMLElement | null) => void;
16
+ /**
17
+ * The ref, `tabIndex={-1}` and the focus ring as props to spread.
18
+ *
19
+ * @deprecated Pass `contentRef` as the target's `ref` instead: the hook makes the target focusable from code only and the
20
+ * library draws the ring, so the target keeps its own `className` without merging. The standing `tabIndex={-1}` spread
21
+ * here, unlike `contentRef`, also hands the target the focus of a click on anything inside it that cannot hold focus.
22
+ */
13
23
  contentProps: {
14
- readonly ref: (content: HTMLElement | null) => void;
24
+ readonly ref: (target: HTMLElement | null) => void;
15
25
  readonly tabIndex: -1;
16
26
  readonly className: "outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2";
17
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,OAAO;;0BAQxB,WAAW,GAAG,IAAI;;gCAAlB,WAAW,GAAG,IAAI;;;;CAUhD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,OAAO;qBAG9B,IAAI;;IAKzB;;;;;;OAMG;;;;;;CAGN,CAAC"}
@@ -1,32 +1,34 @@
1
- import { useRef } from 'react';
1
+ import { useFocusHandOff } from '@flipdish/ui-library/hooks/useFocusHandOff';
2
2
 
3
- // The ring shows for keyboard focus only, as on every other focus target in the library.
3
+ // The ring `contentProps` spreads, for the callers still on it.
4
4
  const FOCUS_TARGET_CLASSES = 'outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2';
5
5
  /**
6
6
  * Keeps keyboard focus in place across a retry. A "Try again" button unmounts once the data arrives, and focus would
7
7
  * otherwise fall back to the top of the page; use it wherever a load error is replaced by the content it failed to load.
8
+ * It is `useFocusHandOff` for one action; for several controls that hand focus on, use that hook.
8
9
  *
9
10
  * @param retry Starts the failed request again.
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 already takes focus from code, as `Form` does.
12
- * That element takes focus when it mounts after a retry, unless the user has moved focus elsewhere.
11
+ * @returns `retryLoad` for the retry button, and `contentRef` for the element that replaces the error. That element takes
12
+ * focus when it mounts after a retry, unless the user has moved focus elsewhere; one that cannot take focus is made
13
+ * focusable from code only, so a click inside it does not give it focus, with the library's keyboard focus ring. `contentRef`
14
+ * is the same function on every render, so only a target that mounts after `retryLoad` is called spends the retry.
15
+ * `contentProps` is deprecated.
13
16
  */
14
17
  const useFocusAfterRetry = (retry) => {
15
- const hasRetried = useRef(false);
16
- const retryLoad = () => {
17
- hasRetried.current = true;
18
- retry();
18
+ const { handOff, targetRef } = useFocusHandOff();
19
+ const retryLoad = handOff(retry);
20
+ return {
21
+ retryLoad,
22
+ contentRef: targetRef,
23
+ /**
24
+ * The ref, `tabIndex={-1}` and the focus ring as props to spread.
25
+ *
26
+ * @deprecated Pass `contentRef` as the target's `ref` instead: the hook makes the target focusable from code only and the
27
+ * library draws the ring, so the target keeps its own `className` without merging. The standing `tabIndex={-1}` spread
28
+ * here, unlike `contentRef`, also hands the target the focus of a click on anything inside it that cannot hold focus.
29
+ */
30
+ contentProps: { ref: targetRef, tabIndex: -1, className: FOCUS_TARGET_CLASSES },
19
31
  };
20
- const contentRef = (content) => {
21
- if (!content || !hasRetried.current)
22
- return;
23
- hasRetried.current = false;
24
- // Focus sits on `<body>` only when the button it was on is gone; anywhere else, the user chose it.
25
- if (content.ownerDocument.activeElement === content.ownerDocument.body)
26
- content.focus();
27
- };
28
- const contentProps = { ref: contentRef, tabIndex: -1, className: FOCUS_TARGET_CLASSES };
29
- return { retryLoad, contentRef, contentProps };
30
32
  };
31
33
 
32
34
  export { useFocusAfterRetry };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;AACA,MAAM,oBAAoB,GAAG,2EAA2E;AAExG;;;;;;;;AAQG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAoB,KAAI;AACzD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC;IAEhC,MAAM,SAAS,GAAG,MAAK;AACrB,QAAA,UAAU,CAAC,OAAO,GAAG,IAAI;AACzB,QAAA,KAAK,EAAE;AACT,IAAA,CAAC;AAED,IAAA,MAAM,UAAU,GAAG,CAAC,OAA2B,KAAI;AACjD,QAAA,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO;YAAE;AACrC,QAAA,UAAU,CAAC,OAAO,GAAG,KAAK;;QAE1B,IAAI,OAAO,CAAC,aAAa,CAAC,aAAa,KAAK,OAAO,CAAC,aAAa,CAAC,IAAI;YAAE,OAAO,CAAC,KAAK,EAAE;AACzF,IAAA,CAAC;AAED,IAAA,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,oBAAoB,EAAW;AAEhG,IAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE;AAChD;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;AACA,MAAM,oBAAoB,GAAG,2EAA2E;AAExG;;;;;;;;;;;AAWG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAoB,KAAI;IACzD,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,eAAe,EAAE;AAEhD,IAAA,MAAM,SAAS,GAAe,OAAO,CAAC,KAAK,CAAC;IAE5C,OAAO;QACL,SAAS;AACT,QAAA,UAAU,EAAE,SAAS;AACrB;;;;;;AAMG;AACH,QAAA,YAAY,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,oBAAoB,EAAW;KACzF;AACH;;"}
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var focusFromCode_utils = require('../../utilities/__internal__/focusUtils/focusFromCode.utils.cjs');
5
+
6
+ // What `styles.css` draws the keyboard-only focus ring from; also spelled there.
7
+ const FOCUS_TARGET_ATTRIBUTE = 'data-focus-hand-off-target';
8
+ // An editing host takes focus, and a place in the Tab order, with no `tabindex`, yet its `tabIndex` reads -1. The attribute
9
+ // is read because jsdom has no `isContentEditable`; `false` and any other value leave the element as it is.
10
+ const EDITING_HOST_STATES = new Set(['', 'true', 'plaintext-only']);
11
+ const isEditingHost = (element) => {
12
+ const state = element.getAttribute('contenteditable');
13
+ return state !== null && EDITING_HOST_STATES.has(state.toLowerCase());
14
+ };
15
+ // A target that can take focus already, natively, as an editing host, by a `tabindex` of its own or from code as a `Form`
16
+ // does, keeps its own focus handling and ring. Any other takes focus from code only, never as a standing `tabindex`, which
17
+ // would hand it the focus of a click inside it; the ring's attribute is set, not a prop, so React never writes over it.
18
+ const makeFocusTarget = (element) => {
19
+ if (element.hasAttribute('tabindex') || element.tabIndex >= 0 || isEditingHost(element) || focusFromCode_utils.isFocusableFromCodeOnly(element))
20
+ return;
21
+ focusFromCode_utils.takeFocusFromCodeOnly(element);
22
+ element.setAttribute(FOCUS_TARGET_ATTRIBUTE, '');
23
+ };
24
+ /**
25
+ * Hands keyboard focus on when a control unmounts as a result of its own press, such as "Try again", "Clear filters" or
26
+ * "Go to page 6" in an empty state, so it lands on what replaces the control instead of the top of the page. Use it for any
27
+ * number of such controls with one shared target ref; for a single retry, `useFocusAfterRetry` is the same thing.
28
+ *
29
+ * @returns `handOff`, which wraps an action so that calling it first marks a hand-off as pending, and `targetRef`, the one
30
+ * `ref` for every element that can replace those controls. While a hand-off is pending and focus has fallen to the page,
31
+ * each target that mounts is given focus, until one holds it, so a disabled button mounting first leaves it for the next;
32
+ * focus elsewhere ends the hand-off where the user put it. One that cannot take focus is made focusable from code only, so
33
+ * a click inside it does not give it focus, with the library's keyboard focus ring. Both are the same functions on every
34
+ * render, so a target already on screen never spends a hand-off.
35
+ */
36
+ const useFocusHandOff = () => {
37
+ const isPending = React.useRef(false);
38
+ const handOff = React.useCallback((action) => (...args) => {
39
+ isPending.current = true;
40
+ try {
41
+ return action(...args);
42
+ }
43
+ catch (error) {
44
+ // An action that throws has replaced nothing, so nothing should take focus for it later.
45
+ isPending.current = false;
46
+ throw error;
47
+ }
48
+ }, []);
49
+ const targetRef = React.useCallback((target) => {
50
+ if (!target)
51
+ return;
52
+ makeFocusTarget(target);
53
+ if (!isPending.current)
54
+ return;
55
+ const { ownerDocument } = target;
56
+ // Focus sits on `<body>` only when the control it was on is gone; anywhere else, the user chose it, and that ends it.
57
+ if (ownerDocument.activeElement === ownerDocument.body)
58
+ target.focus();
59
+ // Spent only once focus is held: a target that could not take it, such as a disabled button, leaves it for the next.
60
+ if (ownerDocument.activeElement !== ownerDocument.body)
61
+ isPending.current = false;
62
+ }, []);
63
+ return { handOff, targetRef };
64
+ };
65
+
66
+ exports.useFocusHandOff = useFocusHandOff;
67
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/hooks/useFocusHandOff/index.ts"],"sourcesContent":[null],"names":["isFocusableFromCodeOnly","takeFocusFromCodeOnly","useRef","useCallback"],"mappings":";;;;;AAKA;AACA,MAAM,sBAAsB,GAAG,4BAA4B;AAE3D;AACA;AACA,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAEnE,MAAM,aAAa,GAAG,CAAC,OAAoB,KAAI;IAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC;AACrD,IAAA,OAAO,KAAK,KAAK,IAAI,IAAI,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;AACvE,CAAC;AAED;AACA;AACA;AACA,MAAM,eAAe,GAAG,CAAC,OAAoB,KAAI;IAC/C,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,IAAIA,2CAAuB,CAAC,OAAO,CAAC;QAAE;IAC7HC,yCAAqB,CAAC,OAAO,CAAC;AAC9B,IAAA,OAAO,CAAC,YAAY,CAAC,sBAAsB,EAAE,EAAE,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;AAWG;AACI,MAAM,eAAe,GAAG,MAAK;AAClC,IAAA,MAAM,SAAS,GAAGC,YAAM,CAAC,KAAK,CAAC;AAE/B,IAAA,MAAM,OAAO,GAAGC,iBAAW,CACzB,CAAiC,MAAiC,KAChE,CAAC,GAAG,IAAU,KAAY;AACxB,QAAA,SAAS,CAAC,OAAO,GAAG,IAAI;AACxB,QAAA,IAAI;AACF,YAAA,OAAO,MAAM,CAAC,GAAG,IAAI,CAAC;QACxB;QAAE,OAAO,KAAK,EAAE;;AAEd,YAAA,SAAS,CAAC,OAAO,GAAG,KAAK;AACzB,YAAA,MAAM,KAAK;QACb;IACF,CAAC,EACH,EAAE,CACH;AAED,IAAA,MAAM,SAAS,GAAGA,iBAAW,CAAC,CAAC,MAA0B,KAAI;AAC3D,QAAA,IAAI,CAAC,MAAM;YAAE;QACb,eAAe,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,OAAO;YAAE;AACxB,QAAA,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM;;AAEhC,QAAA,IAAI,aAAa,CAAC,aAAa,KAAK,aAAa,CAAC,IAAI;YAAE,MAAM,CAAC,KAAK,EAAE;;AAEtE,QAAA,IAAI,aAAa,CAAC,aAAa,KAAK,aAAa,CAAC,IAAI;AAAE,YAAA,SAAS,CAAC,OAAO,GAAG,KAAK;IACnF,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE;AAC/B;;"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Hands keyboard focus on when a control unmounts as a result of its own press, such as "Try again", "Clear filters" or
3
+ * "Go to page 6" in an empty state, so it lands on what replaces the control instead of the top of the page. Use it for any
4
+ * number of such controls with one shared target ref; for a single retry, `useFocusAfterRetry` is the same thing.
5
+ *
6
+ * @returns `handOff`, which wraps an action so that calling it first marks a hand-off as pending, and `targetRef`, the one
7
+ * `ref` for every element that can replace those controls. While a hand-off is pending and focus has fallen to the page,
8
+ * each target that mounts is given focus, until one holds it, so a disabled button mounting first leaves it for the next;
9
+ * focus elsewhere ends the hand-off where the user put it. One that cannot take focus is made focusable from code only, so
10
+ * a click inside it does not give it focus, with the library's keyboard focus ring. Both are the same functions on every
11
+ * render, so a target already on screen never spends a hand-off.
12
+ */
13
+ export declare const useFocusHandOff: () => {
14
+ handOff: <Args extends unknown[], Result>(action: (...args: Args) => Result) => (...args: Args) => Result;
15
+ targetRef: (target: HTMLElement | null) => void;
16
+ };
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFocusHandOff/index.ts"],"names":[],"mappings":"AA0BA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe;cAIvB,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,UAAU,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,eACtD,IAAI,KAAG,MAAM;wBAaY,WAAW,GAAG,IAAI;CAY1D,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { useRef, useCallback } from 'react';
2
+ import { isFocusableFromCodeOnly, takeFocusFromCodeOnly } from '../../utilities/__internal__/focusUtils/focusFromCode.utils.js';
3
+
4
+ // What `styles.css` draws the keyboard-only focus ring from; also spelled there.
5
+ const FOCUS_TARGET_ATTRIBUTE = 'data-focus-hand-off-target';
6
+ // An editing host takes focus, and a place in the Tab order, with no `tabindex`, yet its `tabIndex` reads -1. The attribute
7
+ // is read because jsdom has no `isContentEditable`; `false` and any other value leave the element as it is.
8
+ const EDITING_HOST_STATES = new Set(['', 'true', 'plaintext-only']);
9
+ const isEditingHost = (element) => {
10
+ const state = element.getAttribute('contenteditable');
11
+ return state !== null && EDITING_HOST_STATES.has(state.toLowerCase());
12
+ };
13
+ // A target that can take focus already, natively, as an editing host, by a `tabindex` of its own or from code as a `Form`
14
+ // does, keeps its own focus handling and ring. Any other takes focus from code only, never as a standing `tabindex`, which
15
+ // would hand it the focus of a click inside it; the ring's attribute is set, not a prop, so React never writes over it.
16
+ const makeFocusTarget = (element) => {
17
+ if (element.hasAttribute('tabindex') || element.tabIndex >= 0 || isEditingHost(element) || isFocusableFromCodeOnly(element))
18
+ return;
19
+ takeFocusFromCodeOnly(element);
20
+ element.setAttribute(FOCUS_TARGET_ATTRIBUTE, '');
21
+ };
22
+ /**
23
+ * Hands keyboard focus on when a control unmounts as a result of its own press, such as "Try again", "Clear filters" or
24
+ * "Go to page 6" in an empty state, so it lands on what replaces the control instead of the top of the page. Use it for any
25
+ * number of such controls with one shared target ref; for a single retry, `useFocusAfterRetry` is the same thing.
26
+ *
27
+ * @returns `handOff`, which wraps an action so that calling it first marks a hand-off as pending, and `targetRef`, the one
28
+ * `ref` for every element that can replace those controls. While a hand-off is pending and focus has fallen to the page,
29
+ * each target that mounts is given focus, until one holds it, so a disabled button mounting first leaves it for the next;
30
+ * focus elsewhere ends the hand-off where the user put it. One that cannot take focus is made focusable from code only, so
31
+ * a click inside it does not give it focus, with the library's keyboard focus ring. Both are the same functions on every
32
+ * render, so a target already on screen never spends a hand-off.
33
+ */
34
+ const useFocusHandOff = () => {
35
+ const isPending = useRef(false);
36
+ const handOff = useCallback((action) => (...args) => {
37
+ isPending.current = true;
38
+ try {
39
+ return action(...args);
40
+ }
41
+ catch (error) {
42
+ // An action that throws has replaced nothing, so nothing should take focus for it later.
43
+ isPending.current = false;
44
+ throw error;
45
+ }
46
+ }, []);
47
+ const targetRef = useCallback((target) => {
48
+ if (!target)
49
+ return;
50
+ makeFocusTarget(target);
51
+ if (!isPending.current)
52
+ return;
53
+ const { ownerDocument } = target;
54
+ // Focus sits on `<body>` only when the control it was on is gone; anywhere else, the user chose it, and that ends it.
55
+ if (ownerDocument.activeElement === ownerDocument.body)
56
+ target.focus();
57
+ // Spent only once focus is held: a target that could not take it, such as a disabled button, leaves it for the next.
58
+ if (ownerDocument.activeElement !== ownerDocument.body)
59
+ isPending.current = false;
60
+ }, []);
61
+ return { handOff, targetRef };
62
+ };
63
+
64
+ export { useFocusHandOff };
65
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/hooks/useFocusHandOff/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAKA;AACA,MAAM,sBAAsB,GAAG,4BAA4B;AAE3D;AACA;AACA,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAEnE,MAAM,aAAa,GAAG,CAAC,OAAoB,KAAI;IAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC;AACrD,IAAA,OAAO,KAAK,KAAK,IAAI,IAAI,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;AACvE,CAAC;AAED;AACA;AACA;AACA,MAAM,eAAe,GAAG,CAAC,OAAoB,KAAI;IAC/C,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,uBAAuB,CAAC,OAAO,CAAC;QAAE;IAC7H,qBAAqB,CAAC,OAAO,CAAC;AAC9B,IAAA,OAAO,CAAC,YAAY,CAAC,sBAAsB,EAAE,EAAE,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;AAWG;AACI,MAAM,eAAe,GAAG,MAAK;AAClC,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC;AAE/B,IAAA,MAAM,OAAO,GAAG,WAAW,CACzB,CAAiC,MAAiC,KAChE,CAAC,GAAG,IAAU,KAAY;AACxB,QAAA,SAAS,CAAC,OAAO,GAAG,IAAI;AACxB,QAAA,IAAI;AACF,YAAA,OAAO,MAAM,CAAC,GAAG,IAAI,CAAC;QACxB;QAAE,OAAO,KAAK,EAAE;;AAEd,YAAA,SAAS,CAAC,OAAO,GAAG,KAAK;AACzB,YAAA,MAAM,KAAK;QACb;IACF,CAAC,EACH,EAAE,CACH;AAED,IAAA,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,MAA0B,KAAI;AAC3D,QAAA,IAAI,CAAC,MAAM;YAAE;QACb,eAAe,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,OAAO;YAAE;AACxB,QAAA,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM;;AAEhC,QAAA,IAAI,aAAa,CAAC,aAAa,KAAK,aAAa,CAAC,IAAI;YAAE,MAAM,CAAC,KAAK,EAAE;;AAEtE,QAAA,IAAI,aAAa,CAAC,aAAa,KAAK,aAAa,CAAC,IAAI;AAAE,YAAA,SAAS,CAAC,OAAO,GAAG,KAAK;IACnF,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE;AAC/B;;"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `LiveStatus` has no React Native implementation.
3
+ *
4
+ * This is a generated types-only stub (scripts/emit-native-stubs.mjs). It exists so
5
+ * that importing `@flipdish/ui-library/components/atoms/LiveStatus` from React Native fails at
6
+ * compile time rather than resolving to the web build's types. There is no
7
+ * matching `index.js`, so Metro cannot bundle this module either.
8
+ *
9
+ * To make `LiveStatus` available on React Native, add an `index.native.tsx` beside
10
+ * its `index.tsx` — the build picks it up automatically and this stub disappears.
11
+ */
12
+ export declare const __NO_REACT_NATIVE_IMPLEMENTATION__: never;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `useFocusHandOff` has no React Native implementation.
3
+ *
4
+ * This is a generated types-only stub (scripts/emit-native-stubs.mjs). It exists so
5
+ * that importing `@flipdish/ui-library/hooks/useFocusHandOff` from React Native fails at
6
+ * compile time rather than resolving to the web build's types. There is no
7
+ * matching `index.js`, so Metro cannot bundle this module either.
8
+ *
9
+ * To make `useFocusHandOff` available on React Native, add an `index.native.tsx` beside
10
+ * its `index.tsx` — the build picks it up automatically and this stub disappears.
11
+ */
12
+ export declare const __NO_REACT_NATIVE_IMPLEMENTATION__: never;
package/dist/styles.css CHANGED
@@ -141,6 +141,18 @@
141
141
  }
142
142
  }
143
143
 
144
+ /*
145
+ * The keyboard focus ring of an element `useFocusHandOff` (or `useFocusAfterRetry`, built on it) made focusable, which marks
146
+ * it with this attribute, so the element keeps its own classes. In `base`, so a utility on the element such as
147
+ * `focus-visible:outline-hidden` still wins.
148
+ */
149
+ @layer base {
150
+ [data-focus-hand-off-target]:focus-visible {
151
+ outline: 2px solid var(--color-focus-ring);
152
+ outline-offset: 2px;
153
+ }
154
+ }
155
+
144
156
  /* ============================================================
145
157
  CodeSnippet — Shiki syntax-highlighting overrides
146
158
  ============================================================ */
@@ -42,6 +42,15 @@ const takeFocusFromCodeOnly = (element) => {
42
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
43
  Reflect.defineProperty(element, 'focus', { configurable: true, writable: true, value: focus });
44
44
  };
45
+ /**
46
+ * Says whether `takeFocusFromCodeOnly` already handles an element, so a second caller, such as a focus hand-off whose target
47
+ * is a `Form`, leaves the element and its own focus ring as they are.
48
+ *
49
+ * @param element The element to ask about.
50
+ * @returns `true` once `takeFocusFromCodeOnly` has been called on it.
51
+ */
52
+ const isFocusableFromCodeOnly = (element) => wrapped.has(element);
45
53
 
54
+ exports.isFocusableFromCodeOnly = isFocusableFromCodeOnly;
46
55
  exports.takeFocusFromCodeOnly = takeFocusFromCodeOnly;
47
56
  //# sourceMappingURL=focusFromCode.utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focusFromCode.utils.cjs","sources":["../../../../src/utilities/__internal__/focusUtils/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;AAEA;;;;;;AAMG;AACI,MAAM,uBAAuB,GAAG,CAAC,OAAoB,KAAc,OAAO,CAAC,GAAG,CAAC,OAAO;;;"}
@@ -9,4 +9,12 @@
9
9
  * the browser returns in the method's place.
10
10
  */
11
11
  export declare const takeFocusFromCodeOnly: (element: HTMLElement) => void;
12
+ /**
13
+ * Says whether `takeFocusFromCodeOnly` already handles an element, so a second caller, such as a focus hand-off whose target
14
+ * is a `Form`, leaves the element and its own focus ring as they are.
15
+ *
16
+ * @param element The element to ask about.
17
+ * @returns `true` once `takeFocusFromCodeOnly` has been called on it.
18
+ */
19
+ export declare const isFocusableFromCodeOnly: (element: HTMLElement) => boolean;
12
20
  //# sourceMappingURL=focusFromCode.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focusFromCode.utils.d.ts","sourceRoot":"","sources":["../../../../src/utilities/__internal__/focusUtils/focusFromCode.utils.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,WAAW,KAAG,IAyB5D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,WAAW,KAAG,OAA+B,CAAC"}
@@ -40,6 +40,14 @@ const takeFocusFromCodeOnly = (element) => {
40
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
41
  Reflect.defineProperty(element, 'focus', { configurable: true, writable: true, value: focus });
42
42
  };
43
+ /**
44
+ * Says whether `takeFocusFromCodeOnly` already handles an element, so a second caller, such as a focus hand-off whose target
45
+ * is a `Form`, leaves the element and its own focus ring as they are.
46
+ *
47
+ * @param element The element to ask about.
48
+ * @returns `true` once `takeFocusFromCodeOnly` has been called on it.
49
+ */
50
+ const isFocusableFromCodeOnly = (element) => wrapped.has(element);
43
51
 
44
- export { takeFocusFromCodeOnly };
52
+ export { isFocusableFromCodeOnly, takeFocusFromCodeOnly };
45
53
  //# sourceMappingURL=focusFromCode.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focusFromCode.utils.js","sources":["../../../../src/utilities/__internal__/focusUtils/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;AAEA;;;;;;AAMG;AACI,MAAM,uBAAuB,GAAG,CAAC,OAAoB,KAAc,OAAO,CAAC,GAAG,CAAC,OAAO;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flipdish/ui-library",
3
- "version": "0.69.0",
3
+ "version": "0.70.0",
4
4
  "description": "Flipdish Design System — atomic-design component library (Tailwind v4 + UntitledUI + React Aria).",
5
5
  "type": "module",
6
6
  "imports": {
@@ -120,12 +120,12 @@
120
120
  "dependencies": {
121
121
  "@flipdish/ui-icons": "^0.8.0",
122
122
  "@floating-ui/dom": "^1.7.6",
123
- "@internationalized/date": "^3.12.2",
123
+ "@internationalized/date": "^3.12.4",
124
124
  "@react-aria/focus": "^3.22.1",
125
125
  "@react-aria/i18n": "^3.13.1",
126
126
  "@react-aria/utils": "^3.34.1",
127
127
  "@react-stately/utils": "^3.12.1",
128
- "@react-types/shared": "^3.36.0",
128
+ "@react-types/shared": "^3.37.0",
129
129
  "country-flag-icons": "^1.6.20",
130
130
  "react-error-boundary": "^4.1.2",
131
131
  "tailwindcss-animate": "^1.0.7",
@@ -154,8 +154,8 @@
154
154
  "postcss-prefix-selector": "^2.1.1",
155
155
  "qr-code-styling": "^1.9.2",
156
156
  "react": "^18.3.0 || ^19.0.0",
157
- "react-aria": "3.50.0",
158
- "react-aria-components": "1.19.0",
157
+ "react-aria": "3.53.1",
158
+ "react-aria-components": "1.22.1",
159
159
  "react-dom": "^18.3.0 || ^19.0.0",
160
160
  "react-hook-form": "^7.91.0",
161
161
  "react-hotkeys-hook": "^5.3.2",
@@ -311,8 +311,8 @@
311
311
  "qr-code-styling": "^1.9.2",
312
312
  "react": "^19.0.0",
313
313
  "react-18": "npm:react@18.3.1",
314
- "react-aria": "3.50.0",
315
- "react-aria-components": "1.19.0",
314
+ "react-aria": "3.53.1",
315
+ "react-aria-components": "1.22.1",
316
316
  "react-dom": "^19.0.0",
317
317
  "react-dom-18": "npm:react-dom@18.3.1",
318
318
  "react-hook-form": "^7.91.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"focusFromCode.utils.cjs","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;;"}
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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;;"}
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var reactAriaComponents = require('react-aria-components');
5
- var tableSelection_utils = require('../utilities/tableSelection.utils.cjs');
6
-
7
- // react-stately 3.48 `useGridState` can loop for ever refocusing a deleted row among disabled rows, so the key goes first; its passive effect runs after this one.
8
- const TableFocusGuard = () => {
9
- const state = React.useContext(reactAriaComponents.TableStateContext);
10
- React.useLayoutEffect(() => {
11
- if (!state)
12
- return;
13
- const { collection, selectionManager } = state;
14
- const hasKey = (key) => collection.getItem(key) != null;
15
- const isDisabled = (key) => selectionManager.isDisabled(key);
16
- if (tableSelection_utils.isFocusRecoveryAtRisk(selectionManager.focusedKey, hasKey, collection.rows, isDisabled))
17
- selectionManager.setFocusedKey(null);
18
- });
19
- return null;
20
- };
21
-
22
- exports.TableFocusGuard = TableFocusGuard;
23
- //# sourceMappingURL=TableFocusGuard.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableFocusGuard.cjs","sources":["../../../../../src/components/organisms/Table/components/TableFocusGuard.tsx"],"sourcesContent":[null],"names":["useContext","TableStateContext","useLayoutEffect","isFocusRecoveryAtRisk"],"mappings":";;;;;;AAMA;AACO,MAAM,eAAe,GAAG,MAAK;AAClC,IAAA,MAAM,KAAK,GAAGA,gBAAU,CAACC,qCAAiB,CAAC;IAE3CC,qBAAe,CAAC,MAAK;AACnB,QAAA,IAAI,CAAC,KAAK;YAAE;AACZ,QAAA,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,KAAK;AAC9C,QAAA,MAAM,MAAM,GAAG,CAAC,GAA6C,KAAK,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI;AACjG,QAAA,MAAM,UAAU,GAAG,CAAC,GAAsD,KAAK,gBAAgB,CAAC,UAAU,CAAC,GAAG,CAAC;AAC/G,QAAA,IAAIC,0CAAqB,CAAC,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC;AAAE,YAAA,gBAAgB,CAAC,aAAa,CAAC,IAAI,CAAC;AACnI,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,IAAI;AACb;;"}
@@ -1,2 +0,0 @@
1
- export declare const TableFocusGuard: () => null;
2
- //# sourceMappingURL=TableFocusGuard.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableFocusGuard.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/Table/components/TableFocusGuard.tsx"],"names":[],"mappings":"AAOA,eAAO,MAAM,eAAe,YAY3B,CAAC"}
@@ -1,21 +0,0 @@
1
- import { useContext, useLayoutEffect } from 'react';
2
- import { TableStateContext } from 'react-aria-components';
3
- import { isFocusRecoveryAtRisk } from '../utilities/tableSelection.utils.js';
4
-
5
- // react-stately 3.48 `useGridState` can loop for ever refocusing a deleted row among disabled rows, so the key goes first; its passive effect runs after this one.
6
- const TableFocusGuard = () => {
7
- const state = useContext(TableStateContext);
8
- useLayoutEffect(() => {
9
- if (!state)
10
- return;
11
- const { collection, selectionManager } = state;
12
- const hasKey = (key) => collection.getItem(key) != null;
13
- const isDisabled = (key) => selectionManager.isDisabled(key);
14
- if (isFocusRecoveryAtRisk(selectionManager.focusedKey, hasKey, collection.rows, isDisabled))
15
- selectionManager.setFocusedKey(null);
16
- });
17
- return null;
18
- };
19
-
20
- export { TableFocusGuard };
21
- //# sourceMappingURL=TableFocusGuard.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableFocusGuard.js","sources":["../../../../../src/components/organisms/Table/components/TableFocusGuard.tsx"],"sourcesContent":[null],"names":[],"mappings":";;;;AAMA;AACO,MAAM,eAAe,GAAG,MAAK;AAClC,IAAA,MAAM,KAAK,GAAG,UAAU,CAAC,iBAAiB,CAAC;IAE3C,eAAe,CAAC,MAAK;AACnB,QAAA,IAAI,CAAC,KAAK;YAAE;AACZ,QAAA,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,KAAK;AAC9C,QAAA,MAAM,MAAM,GAAG,CAAC,GAA6C,KAAK,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI;AACjG,QAAA,MAAM,UAAU,GAAG,CAAC,GAAsD,KAAK,gBAAgB,CAAC,UAAU,CAAC,GAAG,CAAC;AAC/G,QAAA,IAAI,qBAAqB,CAAC,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC;AAAE,YAAA,gBAAgB,CAAC,aAAa,CAAC,IAAI,CAAC;AACnI,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,IAAI;AACb;;"}