@flipdish/ui-library 0.68.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.
- package/README.md +2 -2
- package/dist/components/atoms/Buttons/Button/hooks/useLoadingLinkPress.d.ts +1 -1
- package/dist/components/atoms/LiveStatus/index.cjs +18 -0
- package/dist/components/atoms/LiveStatus/index.cjs.map +1 -0
- package/dist/components/atoms/LiveStatus/index.d.ts +17 -0
- package/dist/components/atoms/LiveStatus/index.d.ts.map +1 -0
- package/dist/components/atoms/LiveStatus/index.js +16 -0
- package/dist/components/atoms/LiveStatus/index.js.map +1 -0
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.cjs +10 -4
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.cjs.map +1 -1
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.d.ts +3 -3
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.d.ts.map +1 -1
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.js +11 -5
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.js.map +1 -1
- package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.cjs +13 -0
- package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.cjs.map +1 -1
- package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.d.ts +9 -0
- package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.d.ts.map +1 -1
- package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.js +14 -2
- package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.js.map +1 -1
- package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.cjs +51 -16
- package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.cjs.map +1 -1
- package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.d.ts +19 -6
- package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.d.ts.map +1 -1
- package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.js +51 -17
- package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.js.map +1 -1
- package/dist/components/forms/Form/index.cjs +5 -3
- package/dist/components/forms/Form/index.cjs.map +1 -1
- package/dist/components/forms/Form/index.d.ts +8 -2
- package/dist/components/forms/Form/index.d.ts.map +1 -1
- package/dist/components/forms/Form/index.js +5 -3
- package/dist/components/forms/Form/index.js.map +1 -1
- package/dist/components/molecules/Dropdown/index.d.ts +2 -2
- package/dist/components/molecules/Tags/TagGroup/TagGroup.d.ts +1 -1
- package/dist/components/molecules/Tags/TagGroup/TagGroup.d.ts.map +1 -1
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.cjs +2 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.cjs.map +1 -1
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.d.ts +10 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.d.ts.map +1 -1
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.js +2 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.js.map +1 -1
- package/dist/components/organisms/Table/Table.styles.cjs +29 -0
- package/dist/components/organisms/Table/Table.styles.cjs.map +1 -0
- package/dist/components/organisms/Table/Table.styles.d.ts +16 -0
- package/dist/components/organisms/Table/Table.styles.d.ts.map +1 -0
- package/dist/components/organisms/Table/Table.styles.js +27 -0
- package/dist/components/organisms/Table/Table.styles.js.map +1 -0
- package/dist/components/organisms/Table/components/TableCardRow.cjs +2 -1
- package/dist/components/organisms/Table/components/TableCardRow.cjs.map +1 -1
- package/dist/components/organisms/Table/components/TableCardRow.d.ts.map +1 -1
- package/dist/components/organisms/Table/components/TableCardRow.js +2 -1
- package/dist/components/organisms/Table/components/TableCardRow.js.map +1 -1
- package/dist/components/organisms/Table/components/TableCardsSelectAll.cjs +2 -2
- package/dist/components/organisms/Table/components/TableCardsSelectAll.cjs.map +1 -1
- package/dist/components/organisms/Table/components/TableCardsSelectAll.d.ts +3 -1
- package/dist/components/organisms/Table/components/TableCardsSelectAll.d.ts.map +1 -1
- package/dist/components/organisms/Table/components/TableCardsSelectAll.js +2 -2
- package/dist/components/organisms/Table/components/TableCardsSelectAll.js.map +1 -1
- package/dist/components/organisms/Table/components/TableRowCard.cjs +3 -2
- package/dist/components/organisms/Table/components/TableRowCard.cjs.map +1 -1
- package/dist/components/organisms/Table/components/TableRowCard.d.ts +1 -1
- package/dist/components/organisms/Table/components/TableRowCard.d.ts.map +1 -1
- package/dist/components/organisms/Table/components/TableRowCard.js +3 -2
- package/dist/components/organisms/Table/components/TableRowCard.js.map +1 -1
- package/dist/components/organisms/Table/components/TableSortMenu.cjs +4 -4
- package/dist/components/organisms/Table/components/TableSortMenu.cjs.map +1 -1
- package/dist/components/organisms/Table/components/TableSortMenu.d.ts +5 -5
- package/dist/components/organisms/Table/components/TableSortMenu.d.ts.map +1 -1
- package/dist/components/organisms/Table/components/TableSortMenu.js +4 -4
- package/dist/components/organisms/Table/components/TableSortMenu.js.map +1 -1
- package/dist/components/organisms/Table/hooks/useBusyCount.cjs +22 -0
- package/dist/components/organisms/Table/hooks/useBusyCount.cjs.map +1 -0
- package/dist/components/organisms/Table/hooks/useBusyCount.d.ts +12 -0
- package/dist/components/organisms/Table/hooks/useBusyCount.d.ts.map +1 -0
- package/dist/components/organisms/Table/hooks/useBusyCount.js +20 -0
- package/dist/components/organisms/Table/hooks/useBusyCount.js.map +1 -0
- package/dist/components/organisms/Table/hooks/useIsPlaceholderPage.cjs +42 -0
- package/dist/components/organisms/Table/hooks/useIsPlaceholderPage.cjs.map +1 -0
- package/dist/components/organisms/Table/hooks/useIsPlaceholderPage.d.ts +14 -0
- package/dist/components/organisms/Table/hooks/useIsPlaceholderPage.d.ts.map +1 -0
- package/dist/components/organisms/Table/hooks/useIsPlaceholderPage.js +40 -0
- package/dist/components/organisms/Table/hooks/useIsPlaceholderPage.js.map +1 -0
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.cjs +8 -11
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.cjs.map +1 -1
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.d.ts +9 -2
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.d.ts.map +1 -1
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.js +9 -12
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.js.map +1 -1
- package/dist/components/organisms/Table/hooks/useTableSelection.cjs +12 -4
- package/dist/components/organisms/Table/hooks/useTableSelection.cjs.map +1 -1
- package/dist/components/organisms/Table/hooks/useTableSelection.d.ts +4 -2
- package/dist/components/organisms/Table/hooks/useTableSelection.d.ts.map +1 -1
- package/dist/components/organisms/Table/hooks/useTableSelection.js +12 -4
- package/dist/components/organisms/Table/hooks/useTableSelection.js.map +1 -1
- package/dist/components/organisms/Table/index.cjs +65 -24
- package/dist/components/organisms/Table/index.cjs.map +1 -1
- package/dist/components/organisms/Table/index.d.ts +17 -3
- package/dist/components/organisms/Table/index.d.ts.map +1 -1
- package/dist/components/organisms/Table/index.js +67 -26
- package/dist/components/organisms/Table/index.js.map +1 -1
- package/dist/components/organisms/Table/providers/Table.context.cjs.map +1 -1
- package/dist/components/organisms/Table/providers/Table.context.d.ts +11 -2
- package/dist/components/organisms/Table/providers/Table.context.d.ts.map +1 -1
- package/dist/components/organisms/Table/providers/Table.context.js.map +1 -1
- package/dist/components/organisms/Table/table.types.d.ts +9 -1
- package/dist/components/organisms/Table/table.types.d.ts.map +1 -1
- package/dist/components/organisms/Table/utilities/tableCard.utils.cjs.map +1 -1
- package/dist/components/organisms/Table/utilities/tableCard.utils.d.ts +1 -1
- package/dist/components/organisms/Table/utilities/tableCard.utils.d.ts.map +1 -1
- package/dist/components/organisms/Table/utilities/tableCard.utils.js.map +1 -1
- package/dist/components/organisms/Table/utilities/tableChildren.utils.cjs +7 -4
- package/dist/components/organisms/Table/utilities/tableChildren.utils.cjs.map +1 -1
- package/dist/components/organisms/Table/utilities/tableChildren.utils.d.ts +4 -2
- package/dist/components/organisms/Table/utilities/tableChildren.utils.d.ts.map +1 -1
- package/dist/components/organisms/Table/utilities/tableChildren.utils.js +7 -4
- package/dist/components/organisms/Table/utilities/tableChildren.utils.js.map +1 -1
- package/dist/components/organisms/Table/utilities/tableIterable.utils.cjs +23 -0
- package/dist/components/organisms/Table/utilities/tableIterable.utils.cjs.map +1 -0
- package/dist/components/organisms/Table/utilities/tableIterable.utils.d.ts +8 -0
- package/dist/components/organisms/Table/utilities/tableIterable.utils.d.ts.map +1 -0
- package/dist/components/organisms/Table/utilities/tableIterable.utils.js +21 -0
- package/dist/components/organisms/Table/utilities/tableIterable.utils.js.map +1 -0
- package/dist/components/organisms/Table/utilities/tableLoading.utils.cjs +57 -0
- package/dist/components/organisms/Table/utilities/tableLoading.utils.cjs.map +1 -0
- package/dist/components/organisms/Table/utilities/tableLoading.utils.d.ts +66 -0
- package/dist/components/organisms/Table/utilities/tableLoading.utils.d.ts.map +1 -0
- package/dist/components/organisms/Table/utilities/tableLoading.utils.js +52 -0
- package/dist/components/organisms/Table/utilities/tableLoading.utils.js.map +1 -0
- package/dist/components/organisms/Table/utilities/tableSelection.utils.cjs +21 -21
- package/dist/components/organisms/Table/utilities/tableSelection.utils.cjs.map +1 -1
- package/dist/components/organisms/Table/utilities/tableSelection.utils.d.ts +29 -19
- package/dist/components/organisms/Table/utilities/tableSelection.utils.d.ts.map +1 -1
- package/dist/components/organisms/Table/utilities/tableSelection.utils.js +20 -21
- package/dist/components/organisms/Table/utilities/tableSelection.utils.js.map +1 -1
- package/dist/components/organisms/Table/utilities/tableSort.utils.cjs +1 -1
- package/dist/components/organisms/Table/utilities/tableSort.utils.d.ts +1 -1
- package/dist/components/organisms/Table/utilities/tableSort.utils.js +1 -1
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.cjs +2 -2
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.d.ts +2 -2
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.js +2 -2
- package/dist/hooks/useFocusAfterRetry/index.cjs +21 -19
- package/dist/hooks/useFocusAfterRetry/index.cjs.map +1 -1
- package/dist/hooks/useFocusAfterRetry/index.d.ts +15 -5
- package/dist/hooks/useFocusAfterRetry/index.d.ts.map +1 -1
- package/dist/hooks/useFocusAfterRetry/index.js +21 -19
- package/dist/hooks/useFocusAfterRetry/index.js.map +1 -1
- package/dist/hooks/useFocusHandOff/index.cjs +67 -0
- package/dist/hooks/useFocusHandOff/index.cjs.map +1 -0
- package/dist/hooks/useFocusHandOff/index.d.ts +17 -0
- package/dist/hooks/useFocusHandOff/index.d.ts.map +1 -0
- package/dist/hooks/useFocusHandOff/index.js +65 -0
- package/dist/hooks/useFocusHandOff/index.js.map +1 -0
- package/dist/native/components/atoms/LiveStatus/index.d.ts +12 -0
- package/dist/native/hooks/useFocusHandOff/index.d.ts +12 -0
- package/dist/styles.css +12 -0
- package/dist/utilities/__internal__/focusUtils/focusFromCode.utils.cjs +56 -0
- package/dist/utilities/__internal__/focusUtils/focusFromCode.utils.cjs.map +1 -0
- package/dist/utilities/__internal__/focusUtils/focusFromCode.utils.d.ts +20 -0
- package/dist/utilities/__internal__/focusUtils/focusFromCode.utils.d.ts.map +1 -0
- package/dist/utilities/__internal__/focusUtils/focusFromCode.utils.js +53 -0
- package/dist/utilities/__internal__/focusUtils/focusFromCode.utils.js.map +1 -0
- package/package.json +8 -8
- package/dist/components/organisms/Table/components/TableFocusGuard.cjs +0 -23
- package/dist/components/organisms/Table/components/TableFocusGuard.cjs.map +0 -1
- package/dist/components/organisms/Table/components/TableFocusGuard.d.ts +0 -2
- package/dist/components/organisms/Table/components/TableFocusGuard.d.ts.map +0 -1
- package/dist/components/organisms/Table/components/TableFocusGuard.js +0 -21
- package/dist/components/organisms/Table/components/TableFocusGuard.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Children, isValidElement } from 'react';
|
|
2
2
|
import { flattenChildren } from '../../../../utilities/__internal__/childrenUtils/children.utils.js';
|
|
3
|
+
import { reusableIterableOf } from './tableIterable.utils.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Finds the first element of a type among children, looking through fragments.
|
|
@@ -13,13 +14,14 @@ const findElement = (children, type) => flattenChildren(children).find((child) =
|
|
|
13
14
|
* another element stays among the cells, so the row gets the fallback card, and the nested card renders nothing in either
|
|
14
15
|
* layout (`Table.RowCard` checks where it sits). A row whose cells come from a column function has no card.
|
|
15
16
|
* @param children - The row's children, as nodes or as a function of each column.
|
|
16
|
-
* @param columns - The row's `columns`, which a function of each column is called with
|
|
17
|
+
* @param columns - The row's `columns`, which a function of each column is called with; a one-shot iterator is read once, for
|
|
18
|
+
* every reader.
|
|
17
19
|
* @param isCard - Tells a card element apart from a cell.
|
|
18
20
|
* @returns The card, when the row declares one, and the cells.
|
|
19
21
|
*/
|
|
20
22
|
const splitRowChildren = (children, columns, isCard) => {
|
|
21
23
|
if (typeof children === 'function')
|
|
22
|
-
return { cardCount: 0, cells: Children.toArray(Array.from(columns ?? [], children)) };
|
|
24
|
+
return { cardCount: 0, cells: Children.toArray(Array.from(reusableIterableOf(columns) ?? [], children)) };
|
|
23
25
|
const flat = flattenChildren(children);
|
|
24
26
|
const isCardChild = (child) => isValidElement(child) && isCard(child);
|
|
25
27
|
const cards = flat.filter(isCardChild);
|
|
@@ -28,11 +30,12 @@ const splitRowChildren = (children, columns, isCard) => {
|
|
|
28
30
|
/**
|
|
29
31
|
* Reads each column a `Table.Header` declares, for a card, which has no header of its own to read them from.
|
|
30
32
|
* @param children - The header's children: `Table.Head` elements, conditionals among them, or a function of each column.
|
|
31
|
-
* @param columns - The header's `columns`, which a function of each column is called with
|
|
33
|
+
* @param columns - The header's `columns`, which a function of each column is called with; a one-shot iterator is read once,
|
|
34
|
+
* so react-aria still gets every column.
|
|
32
35
|
* @returns One entry per rendered column, in order; a string child stands in for a missing `label`.
|
|
33
36
|
*/
|
|
34
37
|
const columnsOfHeader = (children, columns) => {
|
|
35
|
-
const heads = typeof children === 'function' ? Array.from(columns ?? [], children) : flattenChildren(children);
|
|
38
|
+
const heads = typeof children === 'function' ? Array.from(reusableIterableOf(columns) ?? [], children) : flattenChildren(children);
|
|
36
39
|
return heads.filter((isValidElement)).map(({ props }) => ({
|
|
37
40
|
label: props.label ?? (typeof props.children === 'string' ? props.children : undefined),
|
|
38
41
|
isRowHeader: props.isRowHeader === true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableChildren.utils.js","sources":["../../../../../src/components/organisms/Table/utilities/tableChildren.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tableChildren.utils.js","sources":["../../../../../src/components/organisms/Table/utilities/tableChildren.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAQA;;;;;AAKG;AACI,MAAM,WAAW,GAAG,CAAI,QAAmB,EAAE,IAAa,KAC/D,eAAe,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,KAA+B,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI;AAYlH;;;;;;;;;AASG;AACI,MAAM,gBAAgB,GAAG,CAC9B,QAA+B,EAC/B,OAAgC,EAChC,MAA0C,KAC3B;IACf,IAAI,OAAO,QAAQ,KAAK,UAAU;QAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC,EAAE;AAC7I,IAAA,MAAM,IAAI,GAAG,eAAe,CAAC,QAAQ,CAAC;AACtC,IAAA,MAAM,WAAW,GAAG,CAAC,KAAgB,KAA4B,cAAc,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC;IACvG,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;AACtC,IAAA,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE;AACxG;AAQA;;;;;;AAMG;MACU,eAAe,GAAG,CAAI,QAA+B,EAAE,OAAqB,KAAuB;AAC9G,IAAA,MAAM,KAAK,GAAG,OAAO,QAAQ,KAAK,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,GAAG,eAAe,CAAC,QAAQ,CAAC;AAClI,IAAA,OAAO,KAAK,CAAC,MAAM,EAAC,cAAyB,EAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM;QACjE,KAAK,EAAE,KAAK,CAAC,KAAK,KAAK,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,GAAG,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC;AACvF,QAAA,WAAW,EAAE,KAAK,CAAC,WAAW,KAAK,IAAI;AACxC,KAAA,CAAC,CAAC;AACL;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// One array per one-shot iterator, so every read of that iterator, in any render or layout, sees everything it yielded.
|
|
4
|
+
const readOnce = new WeakMap();
|
|
5
|
+
/**
|
|
6
|
+
* Makes an iterable the consumer passed safe to read more than once, as the table and react-aria both read `columns`, `items`
|
|
7
|
+
* and `disabledKeys`. A one-shot iterator, such as `array.values()`, yields its items to the first read alone.
|
|
8
|
+
* @param items - What the consumer passed; an array, a `Set` or any iterable that starts afresh on each read is left as it is.
|
|
9
|
+
* @returns The same iterable, or for a one-shot iterator the array of everything it yielded, the same array on every call.
|
|
10
|
+
*/
|
|
11
|
+
const reusableIterableOf = (items) => {
|
|
12
|
+
if (items === undefined || items === null || typeof items !== 'object')
|
|
13
|
+
return items;
|
|
14
|
+
// An iterator is its own iterator, and reading it empties it; an array or a `Set` hands out a new one each time.
|
|
15
|
+
if (!Object.is(items[Symbol.iterator](), items))
|
|
16
|
+
return items;
|
|
17
|
+
const read = readOnce.get(items) ?? Array.from(items);
|
|
18
|
+
readOnce.set(items, read);
|
|
19
|
+
return read;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.reusableIterableOf = reusableIterableOf;
|
|
23
|
+
//# sourceMappingURL=tableIterable.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableIterable.utils.cjs","sources":["../../../../../src/components/organisms/Table/utilities/tableIterable.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAqB;AAEjD;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG,CAAI,KAA8B,KAA6B;IAC/F,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,KAAK;;AAEpF,IAAA,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;AAC7D,IAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;AACrD,IAAA,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC;AACzB,IAAA,OAAO,IAAW;AACpB;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes an iterable the consumer passed safe to read more than once, as the table and react-aria both read `columns`, `items`
|
|
3
|
+
* and `disabledKeys`. A one-shot iterator, such as `array.values()`, yields its items to the first read alone.
|
|
4
|
+
* @param items - What the consumer passed; an array, a `Set` or any iterable that starts afresh on each read is left as it is.
|
|
5
|
+
* @returns The same iterable, or for a one-shot iterator the array of everything it yielded, the same array on every call.
|
|
6
|
+
*/
|
|
7
|
+
export declare const reusableIterableOf: <T>(items: Iterable<T> | undefined) => Iterable<T> | undefined;
|
|
8
|
+
//# sourceMappingURL=tableIterable.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableIterable.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/Table/utilities/tableIterable.utils.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,OAAO,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,KAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAOpF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// One array per one-shot iterator, so every read of that iterator, in any render or layout, sees everything it yielded.
|
|
2
|
+
const readOnce = new WeakMap();
|
|
3
|
+
/**
|
|
4
|
+
* Makes an iterable the consumer passed safe to read more than once, as the table and react-aria both read `columns`, `items`
|
|
5
|
+
* and `disabledKeys`. A one-shot iterator, such as `array.values()`, yields its items to the first read alone.
|
|
6
|
+
* @param items - What the consumer passed; an array, a `Set` or any iterable that starts afresh on each read is left as it is.
|
|
7
|
+
* @returns The same iterable, or for a one-shot iterator the array of everything it yielded, the same array on every call.
|
|
8
|
+
*/
|
|
9
|
+
const reusableIterableOf = (items) => {
|
|
10
|
+
if (items === undefined || items === null || typeof items !== 'object')
|
|
11
|
+
return items;
|
|
12
|
+
// An iterator is its own iterator, and reading it empties it; an array or a `Set` hands out a new one each time.
|
|
13
|
+
if (!Object.is(items[Symbol.iterator](), items))
|
|
14
|
+
return items;
|
|
15
|
+
const read = readOnce.get(items) ?? Array.from(items);
|
|
16
|
+
readOnce.set(items, read);
|
|
17
|
+
return read;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { reusableIterableOf };
|
|
21
|
+
//# sourceMappingURL=tableIterable.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableIterable.utils.js","sources":["../../../../../src/components/organisms/Table/utilities/tableIterable.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAqB;AAEjD;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG,CAAI,KAA8B,KAA6B;IAC/F,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,KAAK;;AAEpF,IAAA,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;AAC7D,IAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;AACrD,IAAA,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC;AACzB,IAAA,OAAO,IAAW;AACpB;;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var children_utils = require('../../../../utilities/__internal__/childrenUtils/children.utils.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Names the rows a `Table` draws while `isLoading`, so each keeps its id, and with it its test id, from render to render.
|
|
8
|
+
* @param count - The table's `loadingRowCount`; a fraction rounds down, and a negative or non-finite count draws none.
|
|
9
|
+
* @returns `loading-0`, `loading-1` and so on, one per row.
|
|
10
|
+
*/
|
|
11
|
+
const loadingRowIdsOf = (count) => {
|
|
12
|
+
const rowCount = Number.isFinite(count) ? Math.max(0, Math.floor(count)) : 0;
|
|
13
|
+
return Array.from({ length: rowCount }, (_, index) => `loading-${index}`);
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Splits a table's `loadingRow` into the cells and the card each loading row renders, with a default for the part it leaves out.
|
|
17
|
+
* @param loadingRow - What the page passed: `Table.Cell`s and/or a `Table.RowCard.Skeleton`, possibly in a fragment; nothing
|
|
18
|
+
* for the defaults.
|
|
19
|
+
* @param columns - The columns `Table.Header` declares, so the default cells fill the row; none when the table found no
|
|
20
|
+
* `Table.Header` among its direct children.
|
|
21
|
+
* @param defaults - The table's own parts; see `LoadingRowDefaults`.
|
|
22
|
+
* @returns Its cells, or one default cell per column when it has none, and its first `Table.RowCard.Skeleton`, or the default
|
|
23
|
+
* card. A `Table.RowCard` among them is dropped: a loading row's card is always a skeleton, which is what keeps it a placeholder.
|
|
24
|
+
*/
|
|
25
|
+
const loadingRowPartsOf = (loadingRow, columns, defaults) => {
|
|
26
|
+
const parts = children_utils.flattenChildren(loadingRow);
|
|
27
|
+
const isCardPart = (part) => React.isValidElement(part) && defaults.isCard(part);
|
|
28
|
+
const cells = parts.filter((part) => !isCardPart(part));
|
|
29
|
+
const card = parts.find((part) => isCardPart(part) && defaults.isSkeletonCard(part));
|
|
30
|
+
return {
|
|
31
|
+
cells: cells.length > 0 ? cells : columns.map((column, index) => defaults.cellOf(index, column.isRowHeader)),
|
|
32
|
+
card: card ?? defaults.card,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Says whether a table can draw its loading rows: in the table each needs a cell per column, and react-aria throws on a row
|
|
37
|
+
* with none; a card needs no cell.
|
|
38
|
+
* @param layout - The layout the table renders.
|
|
39
|
+
* @param cellCount - The cells each loading row has, from `loadingRow` or one per column the table found.
|
|
40
|
+
* @returns `false` only for the table layout with no cells, as when `Table.Header` is rendered by another component and
|
|
41
|
+
* `loadingRow` gives no cells of its own.
|
|
42
|
+
*/
|
|
43
|
+
const canDrawLoadingRows = (layout, cellCount) => layout === 'cards' || cellCount > 0;
|
|
44
|
+
/**
|
|
45
|
+
* Swaps the page's rows in `Table.Body`'s props for the loading rows while the table loads, so a page can keep passing its rows.
|
|
46
|
+
* @param props - `Table.Body`'s props as the page wrote them.
|
|
47
|
+
* @param loadingRows - The rows the table draws while loading; `undefined` while it is not loading.
|
|
48
|
+
* @returns The props unchanged when not loading; otherwise the loading rows as `children`, with no `items`, `dependencies` or
|
|
49
|
+
* `renderEmptyState`, so neither the page's collection nor its empty state renders.
|
|
50
|
+
*/
|
|
51
|
+
const loadingBodyPropsOf = (props, loadingRows) => loadingRows === undefined ? props : { ...props, items: undefined, dependencies: undefined, renderEmptyState: undefined, children: loadingRows };
|
|
52
|
+
|
|
53
|
+
exports.canDrawLoadingRows = canDrawLoadingRows;
|
|
54
|
+
exports.loadingBodyPropsOf = loadingBodyPropsOf;
|
|
55
|
+
exports.loadingRowIdsOf = loadingRowIdsOf;
|
|
56
|
+
exports.loadingRowPartsOf = loadingRowPartsOf;
|
|
57
|
+
//# sourceMappingURL=tableLoading.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableLoading.utils.cjs","sources":["../../../../../src/components/organisms/Table/utilities/tableLoading.utils.ts"],"sourcesContent":[null],"names":["flattenChildren","isValidElement"],"mappings":";;;;;AAIA;;;;AAIG;AACI,MAAM,eAAe,GAAG,CAAC,KAAa,KAAc;AACzD,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;IAC5E,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,CAAA,QAAA,EAAW,KAAK,CAAA,CAAE,CAAC;AAC3E;AAyBA;;;;;;;;;AASG;AACI,MAAM,iBAAiB,GAAG,CAAC,UAAqB,EAAE,OAAmC,EAAE,QAA4B,KAAqB;AAC7I,IAAA,MAAM,KAAK,GAAGA,8BAAe,CAAC,UAAU,CAAC;AACzC,IAAA,MAAM,UAAU,GAAG,CAAC,IAAe,KAA2BC,oBAAc,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;AAC3G,IAAA,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAA2B,UAAU,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC1G,OAAO;AACL,QAAA,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,KAAK,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;AAC5G,QAAA,IAAI,EAAE,IAAI,IAAI,QAAQ,CAAC,IAAI;KAC5B;AACH;AAEA;;;;;;;AAOG;AACI,MAAM,kBAAkB,GAAG,CAAC,MAAmB,EAAE,SAAiB,KAAc,MAAM,KAAK,OAAO,IAAI,SAAS,GAAG;AAUzH;;;;;;AAMG;AACI,MAAM,kBAAkB,GAAG,CAA6B,KAAQ,EAAE,WAAkC,KACzG,WAAW,KAAK,SAAS,GAAG,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW;;;;;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import type { TableCardColumn, TableLayout } from '../table.types';
|
|
3
|
+
/**
|
|
4
|
+
* Names the rows a `Table` draws while `isLoading`, so each keeps its id, and with it its test id, from render to render.
|
|
5
|
+
* @param count - The table's `loadingRowCount`; a fraction rounds down, and a negative or non-finite count draws none.
|
|
6
|
+
* @returns `loading-0`, `loading-1` and so on, one per row.
|
|
7
|
+
*/
|
|
8
|
+
export declare const loadingRowIdsOf: (count: number) => string[];
|
|
9
|
+
/** The table's own parts for a loading row, passed in so this file renders nothing itself. */
|
|
10
|
+
export interface LoadingRowDefaults {
|
|
11
|
+
/** Tells a `Table.RowCard` or a `Table.RowCard.Skeleton` apart from a cell. */
|
|
12
|
+
isCard: (element: ReactElement) => boolean;
|
|
13
|
+
/** Tells a `Table.RowCard.Skeleton` apart from a `Table.RowCard`. */
|
|
14
|
+
isSkeletonCard: (element: ReactElement) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The cell for one column when `loadingRow` has none, keyed by the column's position; a row-header column's cell also
|
|
17
|
+
* names the row, as its empty `rowheader` would leave the row with no name.
|
|
18
|
+
*/
|
|
19
|
+
cellOf: (column: number, isRowHeader: boolean) => ReactNode;
|
|
20
|
+
/** The card when `loadingRow` has no `Table.RowCard.Skeleton`. */
|
|
21
|
+
card: ReactElement;
|
|
22
|
+
}
|
|
23
|
+
/** The cells and the card every loading row renders. */
|
|
24
|
+
export interface LoadingRowParts {
|
|
25
|
+
/** One per column, in order; the table renders them, the cards layout ignores them. */
|
|
26
|
+
cells: ReactNode[];
|
|
27
|
+
/** A `Table.RowCard.Skeleton`, which also makes the row a placeholder in the table. */
|
|
28
|
+
card: ReactElement;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Splits a table's `loadingRow` into the cells and the card each loading row renders, with a default for the part it leaves out.
|
|
32
|
+
* @param loadingRow - What the page passed: `Table.Cell`s and/or a `Table.RowCard.Skeleton`, possibly in a fragment; nothing
|
|
33
|
+
* for the defaults.
|
|
34
|
+
* @param columns - The columns `Table.Header` declares, so the default cells fill the row; none when the table found no
|
|
35
|
+
* `Table.Header` among its direct children.
|
|
36
|
+
* @param defaults - The table's own parts; see `LoadingRowDefaults`.
|
|
37
|
+
* @returns Its cells, or one default cell per column when it has none, and its first `Table.RowCard.Skeleton`, or the default
|
|
38
|
+
* card. A `Table.RowCard` among them is dropped: a loading row's card is always a skeleton, which is what keeps it a placeholder.
|
|
39
|
+
*/
|
|
40
|
+
export declare const loadingRowPartsOf: (loadingRow: ReactNode, columns: readonly TableCardColumn[], defaults: LoadingRowDefaults) => LoadingRowParts;
|
|
41
|
+
/**
|
|
42
|
+
* Says whether a table can draw its loading rows: in the table each needs a cell per column, and react-aria throws on a row
|
|
43
|
+
* with none; a card needs no cell.
|
|
44
|
+
* @param layout - The layout the table renders.
|
|
45
|
+
* @param cellCount - The cells each loading row has, from `loadingRow` or one per column the table found.
|
|
46
|
+
* @returns `false` only for the table layout with no cells, as when `Table.Header` is rendered by another component and
|
|
47
|
+
* `loadingRow` gives no cells of its own.
|
|
48
|
+
*/
|
|
49
|
+
export declare const canDrawLoadingRows: (layout: TableLayout, cellCount: number) => boolean;
|
|
50
|
+
/** The props of `Table.Body` that the loading rows replace. */
|
|
51
|
+
interface LoadingBodyProps {
|
|
52
|
+
items?: unknown;
|
|
53
|
+
dependencies?: unknown;
|
|
54
|
+
renderEmptyState?: unknown;
|
|
55
|
+
children?: unknown;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Swaps the page's rows in `Table.Body`'s props for the loading rows while the table loads, so a page can keep passing its rows.
|
|
59
|
+
* @param props - `Table.Body`'s props as the page wrote them.
|
|
60
|
+
* @param loadingRows - The rows the table draws while loading; `undefined` while it is not loading.
|
|
61
|
+
* @returns The props unchanged when not loading; otherwise the loading rows as `children`, with no `items`, `dependencies` or
|
|
62
|
+
* `renderEmptyState`, so neither the page's collection nor its empty state renders.
|
|
63
|
+
*/
|
|
64
|
+
export declare const loadingBodyPropsOf: <P extends LoadingBodyProps>(props: P, loadingRows: ReactNode | undefined) => P;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=tableLoading.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableLoading.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/Table/utilities/tableLoading.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,KAAG,MAAM,EAGrD,CAAC;AAEF,8FAA8F;AAC9F,MAAM,WAAW,kBAAkB;IACjC,+EAA+E;IAC/E,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC;IAC3C,qEAAqE;IACrE,cAAc,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC;IACnD;;;OAGG;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,KAAK,SAAS,CAAC;IAC5D,kEAAkE;IAClE,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,uFAAuF;IACvF,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,uFAAuF;IACvF,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,YAAY,SAAS,EAAE,SAAS,SAAS,eAAe,EAAE,EAAE,UAAU,kBAAkB,KAAG,eAS5H,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,WAAW,EAAE,WAAW,MAAM,KAAG,OAA8C,CAAC;AAE3H,+DAA+D;AAC/D,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,gBAAgB,EAAE,OAAO,CAAC,EAAE,aAAa,SAAS,GAAG,SAAS,KAAG,CACmC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { isValidElement } from 'react';
|
|
2
|
+
import { flattenChildren } from '../../../../utilities/__internal__/childrenUtils/children.utils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Names the rows a `Table` draws while `isLoading`, so each keeps its id, and with it its test id, from render to render.
|
|
6
|
+
* @param count - The table's `loadingRowCount`; a fraction rounds down, and a negative or non-finite count draws none.
|
|
7
|
+
* @returns `loading-0`, `loading-1` and so on, one per row.
|
|
8
|
+
*/
|
|
9
|
+
const loadingRowIdsOf = (count) => {
|
|
10
|
+
const rowCount = Number.isFinite(count) ? Math.max(0, Math.floor(count)) : 0;
|
|
11
|
+
return Array.from({ length: rowCount }, (_, index) => `loading-${index}`);
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Splits a table's `loadingRow` into the cells and the card each loading row renders, with a default for the part it leaves out.
|
|
15
|
+
* @param loadingRow - What the page passed: `Table.Cell`s and/or a `Table.RowCard.Skeleton`, possibly in a fragment; nothing
|
|
16
|
+
* for the defaults.
|
|
17
|
+
* @param columns - The columns `Table.Header` declares, so the default cells fill the row; none when the table found no
|
|
18
|
+
* `Table.Header` among its direct children.
|
|
19
|
+
* @param defaults - The table's own parts; see `LoadingRowDefaults`.
|
|
20
|
+
* @returns Its cells, or one default cell per column when it has none, and its first `Table.RowCard.Skeleton`, or the default
|
|
21
|
+
* card. A `Table.RowCard` among them is dropped: a loading row's card is always a skeleton, which is what keeps it a placeholder.
|
|
22
|
+
*/
|
|
23
|
+
const loadingRowPartsOf = (loadingRow, columns, defaults) => {
|
|
24
|
+
const parts = flattenChildren(loadingRow);
|
|
25
|
+
const isCardPart = (part) => isValidElement(part) && defaults.isCard(part);
|
|
26
|
+
const cells = parts.filter((part) => !isCardPart(part));
|
|
27
|
+
const card = parts.find((part) => isCardPart(part) && defaults.isSkeletonCard(part));
|
|
28
|
+
return {
|
|
29
|
+
cells: cells.length > 0 ? cells : columns.map((column, index) => defaults.cellOf(index, column.isRowHeader)),
|
|
30
|
+
card: card ?? defaults.card,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Says whether a table can draw its loading rows: in the table each needs a cell per column, and react-aria throws on a row
|
|
35
|
+
* with none; a card needs no cell.
|
|
36
|
+
* @param layout - The layout the table renders.
|
|
37
|
+
* @param cellCount - The cells each loading row has, from `loadingRow` or one per column the table found.
|
|
38
|
+
* @returns `false` only for the table layout with no cells, as when `Table.Header` is rendered by another component and
|
|
39
|
+
* `loadingRow` gives no cells of its own.
|
|
40
|
+
*/
|
|
41
|
+
const canDrawLoadingRows = (layout, cellCount) => layout === 'cards' || cellCount > 0;
|
|
42
|
+
/**
|
|
43
|
+
* Swaps the page's rows in `Table.Body`'s props for the loading rows while the table loads, so a page can keep passing its rows.
|
|
44
|
+
* @param props - `Table.Body`'s props as the page wrote them.
|
|
45
|
+
* @param loadingRows - The rows the table draws while loading; `undefined` while it is not loading.
|
|
46
|
+
* @returns The props unchanged when not loading; otherwise the loading rows as `children`, with no `items`, `dependencies` or
|
|
47
|
+
* `renderEmptyState`, so neither the page's collection nor its empty state renders.
|
|
48
|
+
*/
|
|
49
|
+
const loadingBodyPropsOf = (props, loadingRows) => loadingRows === undefined ? props : { ...props, items: undefined, dependencies: undefined, renderEmptyState: undefined, children: loadingRows };
|
|
50
|
+
|
|
51
|
+
export { canDrawLoadingRows, loadingBodyPropsOf, loadingRowIdsOf, loadingRowPartsOf };
|
|
52
|
+
//# sourceMappingURL=tableLoading.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableLoading.utils.js","sources":["../../../../../src/components/organisms/Table/utilities/tableLoading.utils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BAAkB,GAAG,CAAC,MAAmB,EAAE,SAAiB,KAAc,MAAM,KAAK,OAAO,IAAI,SAAS,GAAG;AAUzH;;;;;;AAMG;AACI,MAAM,kBAAkB,GAAG,CAA6B,KAAQ,EAAE,WAAkC,KACzG,WAAW,KAAK,SAAS,GAAG,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW;;"}
|
|
@@ -44,16 +44,33 @@ const reportSelectionChange = (selection, rowKeys, disabledKeys, listeners) => {
|
|
|
44
44
|
listeners.onSelectedKeyChange?.(keyOfSelection(selection));
|
|
45
45
|
listeners.onSelectedKeysChange?.(keysOfSelection(selection, rowKeys, disabledKeys));
|
|
46
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Says whether any mounted row with an `id` can be selected.
|
|
49
|
+
* @param rowKeys - Every mounted selectable row's id, as the table's row registry holds them.
|
|
50
|
+
* @param disabledKeys - Rows the table disables, which select all leaves out.
|
|
51
|
+
* @returns `true` while at least one such row can be selected.
|
|
52
|
+
*/
|
|
53
|
+
const hasSelectableRow = (rowKeys, disabledKeys) => keysOfSelection('all', rowKeys, disabledKeys).length > 0;
|
|
54
|
+
/**
|
|
55
|
+
* Says whether the table knows its page is placeholders, so select all would only store `'all'` for the rows that load
|
|
56
|
+
* next: while it `isLoading`, or with a placeholder row mounted and no selectable one. Nothing else counts, so before any
|
|
57
|
+
* row registers, with rows that have no `id`, or on a page the consumer disabled, select all is react-aria's as ever.
|
|
58
|
+
* @param page - The table's loading state and its mounted rows; see `PlaceholderPage`.
|
|
59
|
+
* @returns `true` only for a page of placeholders.
|
|
60
|
+
*/
|
|
61
|
+
const isPlaceholderPage = ({ isLoading, rowKeys, placeholderKeys, disabledKeys }) => isLoading || (Array.from(placeholderKeys).length > 0 && !hasSelectableRow(rowKeys, disabledKeys));
|
|
47
62
|
/**
|
|
48
63
|
* Works out the select-all checkbox from the selection and the rows on screen, as the table's header checkbox does.
|
|
49
64
|
* @param selection - The current selection; `'all'` after select all.
|
|
50
65
|
* @param rowKeys - Every mounted selectable row's id.
|
|
51
66
|
* @param disabledKeys - Rows the table disables, which select all leaves out.
|
|
67
|
+
* @param isOnPlaceholderPage - Whether `isPlaceholderPage` holds, which turns the checkbox off at once, before the rows
|
|
68
|
+
* that are leaving have dropped out of `rowKeys`.
|
|
52
69
|
* @returns Whether the checkbox is checked, indeterminate or disabled.
|
|
53
70
|
*/
|
|
54
|
-
const selectAllStateOf = (selection, rowKeys, disabledKeys) => {
|
|
71
|
+
const selectAllStateOf = (selection, rowKeys, disabledKeys, isOnPlaceholderPage = false) => {
|
|
55
72
|
const selectable = keysOfSelection('all', rowKeys, disabledKeys);
|
|
56
|
-
if (selectable.length === 0)
|
|
73
|
+
if (isOnPlaceholderPage || selectable.length === 0)
|
|
57
74
|
return { isSelected: false, isIndeterminate: false, isDisabled: true };
|
|
58
75
|
if (selection === 'all')
|
|
59
76
|
return { isSelected: true, isIndeterminate: false, isDisabled: false };
|
|
@@ -77,26 +94,9 @@ const selectAllToggleOf = (isSelected, disallowEmptySelection = false) => {
|
|
|
77
94
|
return 'all';
|
|
78
95
|
return disallowEmptySelection ? undefined : new Set();
|
|
79
96
|
};
|
|
80
|
-
/**
|
|
81
|
-
* Says whether a table must drop its focused key before react-stately looks for a row to move focus to. That search can
|
|
82
|
-
* loop for ever only when it meets disabled rows, or finds no body row at all, so the key goes in either case. The cost:
|
|
83
|
-
* in a table with a disabled row, such as a placeholder, removing the focused row drops focus instead of moving it to a
|
|
84
|
-
* neighbour.
|
|
85
|
-
* @param focusedKey - The key the table's selection state holds as focused; `null` when nothing is.
|
|
86
|
-
* @param hasKey - Whether the table's new collection still holds a key.
|
|
87
|
-
* @param rows - The new collection's rows; only its body rows count.
|
|
88
|
-
* @param isDisabled - Whether the table's selection manager counts a row as disabled, as placeholder rows are.
|
|
89
|
-
* @returns `true` when the focused key is gone and a body row left is disabled, or none is left; `false` otherwise, so
|
|
90
|
-
* react-aria still moves focus to a neighbouring row in a table with no disabled row.
|
|
91
|
-
*/
|
|
92
|
-
const isFocusRecoveryAtRisk = (focusedKey, hasKey, rows, isDisabled) => {
|
|
93
|
-
if (focusedKey == null || hasKey(focusedKey))
|
|
94
|
-
return false;
|
|
95
|
-
const bodyRows = rows.filter((row) => row.type === 'item');
|
|
96
|
-
return bodyRows.length === 0 || bodyRows.some((row) => isDisabled(row.key));
|
|
97
|
-
};
|
|
98
97
|
|
|
99
|
-
exports.
|
|
98
|
+
exports.hasSelectableRow = hasSelectableRow;
|
|
99
|
+
exports.isPlaceholderPage = isPlaceholderPage;
|
|
100
100
|
exports.keyOfSelection = keyOfSelection;
|
|
101
101
|
exports.keysOfSelection = keysOfSelection;
|
|
102
102
|
exports.reportSelectionChange = reportSelectionChange;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableSelection.utils.cjs","sources":["../../../../../src/components/organisms/Table/utilities/tableSelection.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,GAAe,KAAgB,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;AAE/F;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,SAAoB,KAAgB;IACjE,IAAI,SAAS,KAAK,KAAK;AAAE,QAAA,OAAO,IAAI;AACpC,IAAA,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS;IACzB,OAAO,KAAK,IAAI,IAAI;AACtB;AAEA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAAC,SAAoB,EAAE,OAAsB,EAAE,YAAA,GAA8B,EAAE,KAAW;IACvH,IAAI,SAAS,KAAK,KAAK;AAAE,QAAA,OAAO,CAAC,GAAG,SAAS,CAAC;AAC9C,IAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC;IACtC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzD;AAWA;;;;;;;;AAQG;AACI,MAAM,qBAAqB,GAAG,CACnC,SAAoB,EACpB,OAAsB,EACtB,YAAuC,EACvC,SAAmC,KAC3B;AACR,IAAA,SAAS,CAAC,iBAAiB,GAAG,SAAS,CAAC;IACxC,SAAS,CAAC,mBAAmB,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;AAC1D,IAAA,SAAS,CAAC,oBAAoB,GAAG,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AACrF;
|
|
1
|
+
{"version":3,"file":"tableSelection.utils.cjs","sources":["../../../../../src/components/organisms/Table/utilities/tableSelection.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,GAAe,KAAgB,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;AAE/F;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,SAAoB,KAAgB;IACjE,IAAI,SAAS,KAAK,KAAK;AAAE,QAAA,OAAO,IAAI;AACpC,IAAA,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS;IACzB,OAAO,KAAK,IAAI,IAAI;AACtB;AAEA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAAC,SAAoB,EAAE,OAAsB,EAAE,YAAA,GAA8B,EAAE,KAAW;IACvH,IAAI,SAAS,KAAK,KAAK;AAAE,QAAA,OAAO,CAAC,GAAG,SAAS,CAAC;AAC9C,IAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC;IACtC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,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,SAAS,CAAC;IACnC,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM;IAC1E,OAAO;AACL,QAAA,UAAU,EAAE,aAAa,KAAK,UAAU,CAAC,MAAM;;QAE/C,eAAe,EAAE,QAAQ,CAAC,IAAI,GAAG,CAAC,IAAI,aAAa,GAAG,UAAU,CAAC,MAAM;AACvE,QAAA,UAAU,EAAE,KAAK;KAClB;AACH;AAEA;;;;;AAKG;AACI,MAAM,iBAAiB,GAAG,CAAC,UAAmB,EAAE,sBAAsB,GAAG,KAAK,KAA2B;AAC9G,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAO,KAAK;IAC7B,OAAO,sBAAsB,GAAG,SAAS,GAAG,IAAI,GAAG,EAAE;AACvD;;;;;;;;;"}
|
|
@@ -37,6 +37,32 @@ export interface SelectionChangeListeners {
|
|
|
37
37
|
* @returns Nothing. Each provided listener is called.
|
|
38
38
|
*/
|
|
39
39
|
export declare const reportSelectionChange: (selection: Selection, rowKeys: Iterable<Key>, disabledKeys: Iterable<Key> | undefined, listeners: SelectionChangeListeners) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Says whether any mounted row with an `id` can be selected.
|
|
42
|
+
* @param rowKeys - Every mounted selectable row's id, as the table's row registry holds them.
|
|
43
|
+
* @param disabledKeys - Rows the table disables, which select all leaves out.
|
|
44
|
+
* @returns `true` while at least one such row can be selected.
|
|
45
|
+
*/
|
|
46
|
+
export declare const hasSelectableRow: (rowKeys: Iterable<Key>, disabledKeys?: Iterable<Key>) => boolean;
|
|
47
|
+
/** What decides whether a table's page is placeholders, which select all has nothing to cover on. */
|
|
48
|
+
export interface PlaceholderPage {
|
|
49
|
+
/** The table's `isLoading`, known from its props on the first render, before any row registers. */
|
|
50
|
+
isLoading: boolean;
|
|
51
|
+
/** Every mounted selectable row's id. */
|
|
52
|
+
rowKeys: Iterable<Key>;
|
|
53
|
+
/** Every mounted placeholder row's id: a row with an `id` carrying `Table.RowCard.Skeleton`, as each loading row does. */
|
|
54
|
+
placeholderKeys: Iterable<Key>;
|
|
55
|
+
/** Rows the table disables. */
|
|
56
|
+
disabledKeys?: Iterable<Key>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Says whether the table knows its page is placeholders, so select all would only store `'all'` for the rows that load
|
|
60
|
+
* next: while it `isLoading`, or with a placeholder row mounted and no selectable one. Nothing else counts, so before any
|
|
61
|
+
* row registers, with rows that have no `id`, or on a page the consumer disabled, select all is react-aria's as ever.
|
|
62
|
+
* @param page - The table's loading state and its mounted rows; see `PlaceholderPage`.
|
|
63
|
+
* @returns `true` only for a page of placeholders.
|
|
64
|
+
*/
|
|
65
|
+
export declare const isPlaceholderPage: ({ isLoading, rowKeys, placeholderKeys, disabledKeys }: PlaceholderPage) => boolean;
|
|
40
66
|
/** What the card list's select-all checkbox shows. */
|
|
41
67
|
export interface SelectAllState {
|
|
42
68
|
/** Every selectable row is selected. */
|
|
@@ -51,9 +77,11 @@ export interface SelectAllState {
|
|
|
51
77
|
* @param selection - The current selection; `'all'` after select all.
|
|
52
78
|
* @param rowKeys - Every mounted selectable row's id.
|
|
53
79
|
* @param disabledKeys - Rows the table disables, which select all leaves out.
|
|
80
|
+
* @param isOnPlaceholderPage - Whether `isPlaceholderPage` holds, which turns the checkbox off at once, before the rows
|
|
81
|
+
* that are leaving have dropped out of `rowKeys`.
|
|
54
82
|
* @returns Whether the checkbox is checked, indeterminate or disabled.
|
|
55
83
|
*/
|
|
56
|
-
export declare const selectAllStateOf: (selection: "all" | Iterable<Key>, rowKeys: Iterable<Key>, disabledKeys?: Iterable<Key
|
|
84
|
+
export declare const selectAllStateOf: (selection: "all" | Iterable<Key>, rowKeys: Iterable<Key>, disabledKeys?: Iterable<Key>, isOnPlaceholderPage?: boolean) => SelectAllState;
|
|
57
85
|
/**
|
|
58
86
|
* Picks the selection a press on the select-all checkbox reports, the values react-aria's header checkbox reports.
|
|
59
87
|
* @param isSelected - Whether every selectable row is selected now.
|
|
@@ -61,22 +89,4 @@ export declare const selectAllStateOf: (selection: "all" | Iterable<Key>, rowKey
|
|
|
61
89
|
* @returns `'all'`, an empty selection, or `undefined` when clearing is not allowed.
|
|
62
90
|
*/
|
|
63
91
|
export declare const selectAllToggleOf: (isSelected: boolean, disallowEmptySelection?: boolean) => Selection | undefined;
|
|
64
|
-
/** One of a table's rows as react-stately's focus recovery walks them: a body row, a header row or a loader. */
|
|
65
|
-
export interface FocusRecoveryRow {
|
|
66
|
-
key: Key;
|
|
67
|
-
type: string;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Says whether a table must drop its focused key before react-stately looks for a row to move focus to. That search can
|
|
71
|
-
* loop for ever only when it meets disabled rows, or finds no body row at all, so the key goes in either case. The cost:
|
|
72
|
-
* in a table with a disabled row, such as a placeholder, removing the focused row drops focus instead of moving it to a
|
|
73
|
-
* neighbour.
|
|
74
|
-
* @param focusedKey - The key the table's selection state holds as focused; `null` when nothing is.
|
|
75
|
-
* @param hasKey - Whether the table's new collection still holds a key.
|
|
76
|
-
* @param rows - The new collection's rows; only its body rows count.
|
|
77
|
-
* @param isDisabled - Whether the table's selection manager counts a row as disabled, as placeholder rows are.
|
|
78
|
-
* @returns `true` when the focused key is gone and a body row left is disabled, or none is left; `false` otherwise, so
|
|
79
|
-
* react-aria still moves focus to a neighbouring row in a table with no disabled row.
|
|
80
|
-
*/
|
|
81
|
-
export declare const isFocusRecoveryAtRisk: (focusedKey: Key | null, hasKey: (key: Key) => boolean, rows: readonly FocusRecoveryRow[], isDisabled: (key: Key) => boolean) => boolean;
|
|
82
92
|
//# sourceMappingURL=tableSelection.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableSelection.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/Table/utilities/tableSelection.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,GAAG,GAAG,IAAI,KAAG,SAA+C,CAAC;AAEjG;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,WAAW,SAAS,KAAG,GAAG,GAAG,IAI3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,WAAW,SAAS,EAAE,SAAS,QAAQ,CAAC,GAAG,CAAC,EAAE,eAAc,QAAQ,CAAC,GAAG,CAAM,KAAG,GAAG,EAInH,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;IACnD,sGAAsG;IACtG,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC;IAChD,qGAAqG;IACrG,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CAC9C;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAChC,WAAW,SAAS,EACpB,SAAS,QAAQ,CAAC,GAAG,CAAC,EACtB,cAAc,QAAQ,CAAC,GAAG,CAAC,GAAG,SAAS,EACvC,WAAW,wBAAwB,KAClC,IAIF,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"tableSelection.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/Table/utilities/tableSelection.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,GAAG,GAAG,IAAI,KAAG,SAA+C,CAAC;AAEjG;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,WAAW,SAAS,KAAG,GAAG,GAAG,IAI3D,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E,OAAO,CAAC;IACpB,gGAAgG;IAChG,eAAe,EAAE,OAAO,CAAC;IACzB,gEAAgE;IAChE,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAC3B,WAAW,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,EAChC,SAAS,QAAQ,CAAC,GAAG,CAAC,EACtB,eAAe,QAAQ,CAAC,GAAG,CAAC,EAC5B,6BAA2B,KAC1B,cAaF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,YAAY,OAAO,EAAE,gCAA8B,KAAG,SAAS,GAAG,SAGnG,CAAC"}
|
|
@@ -42,16 +42,33 @@ const reportSelectionChange = (selection, rowKeys, disabledKeys, listeners) => {
|
|
|
42
42
|
listeners.onSelectedKeyChange?.(keyOfSelection(selection));
|
|
43
43
|
listeners.onSelectedKeysChange?.(keysOfSelection(selection, rowKeys, disabledKeys));
|
|
44
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Says whether any mounted row with an `id` can be selected.
|
|
47
|
+
* @param rowKeys - Every mounted selectable row's id, as the table's row registry holds them.
|
|
48
|
+
* @param disabledKeys - Rows the table disables, which select all leaves out.
|
|
49
|
+
* @returns `true` while at least one such row can be selected.
|
|
50
|
+
*/
|
|
51
|
+
const hasSelectableRow = (rowKeys, disabledKeys) => keysOfSelection('all', rowKeys, disabledKeys).length > 0;
|
|
52
|
+
/**
|
|
53
|
+
* Says whether the table knows its page is placeholders, so select all would only store `'all'` for the rows that load
|
|
54
|
+
* next: while it `isLoading`, or with a placeholder row mounted and no selectable one. Nothing else counts, so before any
|
|
55
|
+
* row registers, with rows that have no `id`, or on a page the consumer disabled, select all is react-aria's as ever.
|
|
56
|
+
* @param page - The table's loading state and its mounted rows; see `PlaceholderPage`.
|
|
57
|
+
* @returns `true` only for a page of placeholders.
|
|
58
|
+
*/
|
|
59
|
+
const isPlaceholderPage = ({ isLoading, rowKeys, placeholderKeys, disabledKeys }) => isLoading || (Array.from(placeholderKeys).length > 0 && !hasSelectableRow(rowKeys, disabledKeys));
|
|
45
60
|
/**
|
|
46
61
|
* Works out the select-all checkbox from the selection and the rows on screen, as the table's header checkbox does.
|
|
47
62
|
* @param selection - The current selection; `'all'` after select all.
|
|
48
63
|
* @param rowKeys - Every mounted selectable row's id.
|
|
49
64
|
* @param disabledKeys - Rows the table disables, which select all leaves out.
|
|
65
|
+
* @param isOnPlaceholderPage - Whether `isPlaceholderPage` holds, which turns the checkbox off at once, before the rows
|
|
66
|
+
* that are leaving have dropped out of `rowKeys`.
|
|
50
67
|
* @returns Whether the checkbox is checked, indeterminate or disabled.
|
|
51
68
|
*/
|
|
52
|
-
const selectAllStateOf = (selection, rowKeys, disabledKeys) => {
|
|
69
|
+
const selectAllStateOf = (selection, rowKeys, disabledKeys, isOnPlaceholderPage = false) => {
|
|
53
70
|
const selectable = keysOfSelection('all', rowKeys, disabledKeys);
|
|
54
|
-
if (selectable.length === 0)
|
|
71
|
+
if (isOnPlaceholderPage || selectable.length === 0)
|
|
55
72
|
return { isSelected: false, isIndeterminate: false, isDisabled: true };
|
|
56
73
|
if (selection === 'all')
|
|
57
74
|
return { isSelected: true, isIndeterminate: false, isDisabled: false };
|
|
@@ -75,24 +92,6 @@ const selectAllToggleOf = (isSelected, disallowEmptySelection = false) => {
|
|
|
75
92
|
return 'all';
|
|
76
93
|
return disallowEmptySelection ? undefined : new Set();
|
|
77
94
|
};
|
|
78
|
-
/**
|
|
79
|
-
* Says whether a table must drop its focused key before react-stately looks for a row to move focus to. That search can
|
|
80
|
-
* loop for ever only when it meets disabled rows, or finds no body row at all, so the key goes in either case. The cost:
|
|
81
|
-
* in a table with a disabled row, such as a placeholder, removing the focused row drops focus instead of moving it to a
|
|
82
|
-
* neighbour.
|
|
83
|
-
* @param focusedKey - The key the table's selection state holds as focused; `null` when nothing is.
|
|
84
|
-
* @param hasKey - Whether the table's new collection still holds a key.
|
|
85
|
-
* @param rows - The new collection's rows; only its body rows count.
|
|
86
|
-
* @param isDisabled - Whether the table's selection manager counts a row as disabled, as placeholder rows are.
|
|
87
|
-
* @returns `true` when the focused key is gone and a body row left is disabled, or none is left; `false` otherwise, so
|
|
88
|
-
* react-aria still moves focus to a neighbouring row in a table with no disabled row.
|
|
89
|
-
*/
|
|
90
|
-
const isFocusRecoveryAtRisk = (focusedKey, hasKey, rows, isDisabled) => {
|
|
91
|
-
if (focusedKey == null || hasKey(focusedKey))
|
|
92
|
-
return false;
|
|
93
|
-
const bodyRows = rows.filter((row) => row.type === 'item');
|
|
94
|
-
return bodyRows.length === 0 || bodyRows.some((row) => isDisabled(row.key));
|
|
95
|
-
};
|
|
96
95
|
|
|
97
|
-
export {
|
|
96
|
+
export { hasSelectableRow, isPlaceholderPage, keyOfSelection, keysOfSelection, reportSelectionChange, selectAllStateOf, selectAllToggleOf, selectionOfKey };
|
|
98
97
|
//# sourceMappingURL=tableSelection.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableSelection.utils.js","sources":["../../../../../src/components/organisms/Table/utilities/tableSelection.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,GAAe,KAAgB,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;AAE/F;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,SAAoB,KAAgB;IACjE,IAAI,SAAS,KAAK,KAAK;AAAE,QAAA,OAAO,IAAI;AACpC,IAAA,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS;IACzB,OAAO,KAAK,IAAI,IAAI;AACtB;AAEA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAAC,SAAoB,EAAE,OAAsB,EAAE,YAAA,GAA8B,EAAE,KAAW;IACvH,IAAI,SAAS,KAAK,KAAK;AAAE,QAAA,OAAO,CAAC,GAAG,SAAS,CAAC;AAC9C,IAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC;IACtC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzD;AAWA;;;;;;;;AAQG;AACI,MAAM,qBAAqB,GAAG,CACnC,SAAoB,EACpB,OAAsB,EACtB,YAAuC,EACvC,SAAmC,KAC3B;AACR,IAAA,SAAS,CAAC,iBAAiB,GAAG,SAAS,CAAC;IACxC,SAAS,CAAC,mBAAmB,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;AAC1D,IAAA,SAAS,CAAC,oBAAoB,GAAG,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AACrF;
|
|
1
|
+
{"version":3,"file":"tableSelection.utils.js","sources":["../../../../../src/components/organisms/Table/utilities/tableSelection.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,GAAe,KAAgB,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;AAE/F;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,SAAoB,KAAgB;IACjE,IAAI,SAAS,KAAK,KAAK;AAAE,QAAA,OAAO,IAAI;AACpC,IAAA,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS;IACzB,OAAO,KAAK,IAAI,IAAI;AACtB;AAEA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAAC,SAAoB,EAAE,OAAsB,EAAE,YAAA,GAA8B,EAAE,KAAW;IACvH,IAAI,SAAS,KAAK,KAAK;AAAE,QAAA,OAAO,CAAC,GAAG,SAAS,CAAC;AAC9C,IAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC;IACtC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GA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E/F,IAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC;IACnC,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM;IAC1E,OAAO;AACL,QAAA,UAAU,EAAE,aAAa,KAAK,UAAU,CAAC,MAAM;;QAE/C,eAAe,EAAE,QAAQ,CAAC,IAAI,GAAG,CAAC,IAAI,aAAa,GAAG,UAAU,CAAC,MAAM;AACvE,QAAA,UAAU,EAAE,KAAK;KAClB;AACH;AAEA;;;;;AAKG;AACI,MAAM,iBAAiB,GAAG,CAAC,UAAmB,EAAE,sBAAsB,GAAG,KAAK,KAA2B;AAC9G,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAO,KAAK;IAC7B,OAAO,sBAAsB,GAAG,SAAS,GAAG,IAAI,GAAG,EAAE;AACvD;;"}
|
|
@@ -63,7 +63,7 @@ const sortOfColumnChoice = (current, column) => ({
|
|
|
63
63
|
*/
|
|
64
64
|
const sortOfDirectionChoice = (current, direction) => current && { column: current.column, direction };
|
|
65
65
|
/**
|
|
66
|
-
* Keys a column's item in the sort menu, apart from the direction and "
|
|
66
|
+
* Keys a column's item in the sort menu, apart from the direction and "Reset sort" items and from every other column's.
|
|
67
67
|
* @param id - The column's id, as its `Table.Head` has it.
|
|
68
68
|
* @returns `col-<id>` for a string id and `colnum-<id>` for a number, so `'1'` and `1` stay apart; the item's test id
|
|
69
69
|
* derives from it too.
|
|
@@ -49,7 +49,7 @@ export declare const sortOfColumnChoice: (current: SortDescriptor | undefined, c
|
|
|
49
49
|
*/
|
|
50
50
|
export declare const sortOfDirectionChoice: (current: SortDescriptor | undefined, direction: SortDirection) => SortDescriptor | undefined;
|
|
51
51
|
/**
|
|
52
|
-
* Keys a column's item in the sort menu, apart from the direction and "
|
|
52
|
+
* Keys a column's item in the sort menu, apart from the direction and "Reset sort" items and from every other column's.
|
|
53
53
|
* @param id - The column's id, as its `Table.Head` has it.
|
|
54
54
|
* @returns `col-<id>` for a string id and `colnum-<id>` for a number, so `'1'` and `1` stay apart; the item's test id
|
|
55
55
|
* derives from it too.
|
|
@@ -61,7 +61,7 @@ const sortOfColumnChoice = (current, column) => ({
|
|
|
61
61
|
*/
|
|
62
62
|
const sortOfDirectionChoice = (current, direction) => current && { column: current.column, direction };
|
|
63
63
|
/**
|
|
64
|
-
* Keys a column's item in the sort menu, apart from the direction and "
|
|
64
|
+
* Keys a column's item in the sort menu, apart from the direction and "Reset sort" items and from every other column's.
|
|
65
65
|
* @param id - The column's id, as its `Table.Head` has it.
|
|
66
66
|
* @returns `col-<id>` for a string id and `colnum-<id>` for a number, so `'1'` and `1` stay apart; the item's test id
|
|
67
67
|
* derives from it too.
|
|
@@ -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 (
|
|
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') => {
|