@flipdish/ui-library 0.67.0 → 0.68.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 +31 -31
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.cjs +13 -30
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.cjs.map +1 -1
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.d.ts.map +1 -1
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.js +10 -27
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.js.map +1 -1
- package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.cjs +55 -0
- package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.cjs.map +1 -0
- package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.d.ts +56 -0
- package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.d.ts.map +1 -0
- package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.js +52 -0
- package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.js.map +1 -0
- package/dist/components/molecules/EmptyState/index.cjs +4 -2
- package/dist/components/molecules/EmptyState/index.cjs.map +1 -1
- package/dist/components/molecules/EmptyState/index.d.ts.map +1 -1
- package/dist/components/molecules/EmptyState/index.js +4 -2
- package/dist/components/molecules/EmptyState/index.js.map +1 -1
- package/dist/components/molecules/Pagination/index.d.ts +1 -1
- package/dist/components/molecules/Pagination/index.d.ts.map +1 -1
- package/dist/components/molecules/Paginations/Pagination/Pagination.cjs +21 -5
- package/dist/components/molecules/Paginations/Pagination/Pagination.cjs.map +1 -1
- package/dist/components/molecules/Paginations/Pagination/Pagination.d.ts +7 -1
- package/dist/components/molecules/Paginations/Pagination/Pagination.d.ts.map +1 -1
- package/dist/components/molecules/Paginations/Pagination/Pagination.js +22 -6
- package/dist/components/molecules/Paginations/Pagination/Pagination.js.map +1 -1
- package/dist/components/molecules/Paginations/components/PaginationBase.cjs +2 -2
- package/dist/components/molecules/Paginations/components/PaginationBase.cjs.map +1 -1
- package/dist/components/molecules/Paginations/components/PaginationBase.d.ts +4 -2
- package/dist/components/molecules/Paginations/components/PaginationBase.d.ts.map +1 -1
- package/dist/components/molecules/Paginations/components/PaginationBase.js +2 -2
- package/dist/components/molecules/Paginations/components/PaginationBase.js.map +1 -1
- package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.cjs +125 -0
- package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.cjs.map +1 -0
- package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.d.ts +42 -0
- package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.d.ts.map +1 -0
- package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.js +118 -0
- package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.js.map +1 -0
- package/dist/components/organisms/FilterBar/index.cjs +3 -1
- package/dist/components/organisms/FilterBar/index.cjs.map +1 -1
- package/dist/components/organisms/FilterBar/index.d.ts.map +1 -1
- package/dist/components/organisms/FilterBar/index.js +3 -1
- package/dist/components/organisms/FilterBar/index.js.map +1 -1
- package/dist/components/organisms/Table/components/TableCardList.cjs +27 -0
- package/dist/components/organisms/Table/components/TableCardList.cjs.map +1 -0
- package/dist/components/organisms/Table/components/TableCardList.d.ts +4 -0
- package/dist/components/organisms/Table/components/TableCardList.d.ts.map +1 -0
- package/dist/components/organisms/Table/components/TableCardList.js +25 -0
- package/dist/components/organisms/Table/components/TableCardList.js.map +1 -0
- package/dist/components/organisms/Table/components/TableCardRow.cjs +80 -0
- package/dist/components/organisms/Table/components/TableCardRow.cjs.map +1 -0
- package/dist/components/organisms/Table/components/TableCardRow.d.ts +4 -0
- package/dist/components/organisms/Table/components/TableCardRow.d.ts.map +1 -0
- package/dist/components/organisms/Table/components/TableCardRow.js +78 -0
- package/dist/components/organisms/Table/components/TableCardRow.js.map +1 -0
- package/dist/components/organisms/Table/components/TableCardsSelectAll.cjs +24 -0
- package/dist/components/organisms/Table/components/TableCardsSelectAll.cjs.map +1 -0
- package/dist/components/organisms/Table/components/TableCardsSelectAll.d.ts +13 -0
- package/dist/components/organisms/Table/components/TableCardsSelectAll.d.ts.map +1 -0
- package/dist/components/organisms/Table/components/TableCardsSelectAll.js +22 -0
- package/dist/components/organisms/Table/components/TableCardsSelectAll.js.map +1 -0
- package/dist/components/organisms/Table/components/TableFallbackCard.cjs +12 -0
- package/dist/components/organisms/Table/components/TableFallbackCard.cjs.map +1 -0
- package/dist/components/organisms/Table/components/TableFallbackCard.d.ts +6 -0
- package/dist/components/organisms/Table/components/TableFallbackCard.d.ts.map +1 -0
- package/dist/components/organisms/Table/components/TableFallbackCard.js +10 -0
- package/dist/components/organisms/Table/components/TableFallbackCard.js.map +1 -0
- package/dist/components/organisms/Table/components/TableFocusGuard.cjs +23 -0
- package/dist/components/organisms/Table/components/TableFocusGuard.cjs.map +1 -0
- package/dist/components/organisms/Table/components/TableFocusGuard.d.ts +2 -0
- package/dist/components/organisms/Table/components/TableFocusGuard.d.ts.map +1 -0
- package/dist/components/organisms/Table/components/TableFocusGuard.js +21 -0
- package/dist/components/organisms/Table/components/TableFocusGuard.js.map +1 -0
- package/dist/components/organisms/Table/components/TableLayoutToggle.cjs +27 -0
- package/dist/components/organisms/Table/components/TableLayoutToggle.cjs.map +1 -0
- package/dist/components/organisms/Table/components/TableLayoutToggle.d.ts +17 -0
- package/dist/components/organisms/Table/components/TableLayoutToggle.d.ts.map +1 -0
- package/dist/components/organisms/Table/components/TableLayoutToggle.js +25 -0
- package/dist/components/organisms/Table/components/TableLayoutToggle.js.map +1 -0
- package/dist/components/organisms/Table/components/TableRowCard.cjs +79 -0
- package/dist/components/organisms/Table/components/TableRowCard.cjs.map +1 -0
- package/dist/components/organisms/Table/components/TableRowCard.d.ts +71 -0
- package/dist/components/organisms/Table/components/TableRowCard.d.ts.map +1 -0
- package/dist/components/organisms/Table/components/TableRowCard.js +72 -0
- package/dist/components/organisms/Table/components/TableRowCard.js.map +1 -0
- package/dist/components/organisms/Table/components/TableSortMenu.cjs +48 -0
- package/dist/components/organisms/Table/components/TableSortMenu.cjs.map +1 -0
- package/dist/components/organisms/Table/components/TableSortMenu.d.ts +35 -0
- package/dist/components/organisms/Table/components/TableSortMenu.d.ts.map +1 -0
- package/dist/components/organisms/Table/components/TableSortMenu.js +46 -0
- package/dist/components/organisms/Table/components/TableSortMenu.js.map +1 -0
- package/dist/components/organisms/Table/hooks/useFirstSortDirection.cjs +25 -0
- package/dist/components/organisms/Table/hooks/useFirstSortDirection.cjs.map +1 -0
- package/dist/components/organisms/Table/hooks/useFirstSortDirection.d.ts +12 -0
- package/dist/components/organisms/Table/hooks/useFirstSortDirection.d.ts.map +1 -0
- package/dist/components/organisms/Table/hooks/useFirstSortDirection.js +23 -0
- package/dist/components/organisms/Table/hooks/useFirstSortDirection.js.map +1 -0
- package/dist/components/organisms/Table/hooks/useIsAtLeastMd.cjs +21 -0
- package/dist/components/organisms/Table/hooks/useIsAtLeastMd.cjs.map +1 -0
- package/dist/components/organisms/Table/hooks/useIsAtLeastMd.d.ts +9 -0
- package/dist/components/organisms/Table/hooks/useIsAtLeastMd.d.ts.map +1 -0
- package/dist/components/organisms/Table/hooks/useIsAtLeastMd.js +19 -0
- package/dist/components/organisms/Table/hooks/useIsAtLeastMd.js.map +1 -0
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.cjs +43 -0
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.cjs.map +1 -0
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.d.ts +23 -0
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.d.ts.map +1 -0
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.js +40 -0
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.js.map +1 -0
- package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.cjs +20 -2
- package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.cjs.map +1 -1
- package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.d.ts +8 -4
- package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.d.ts.map +1 -1
- package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.js +21 -3
- package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.js.map +1 -1
- package/dist/components/organisms/Table/hooks/useTableSelection.cjs +47 -0
- package/dist/components/organisms/Table/hooks/useTableSelection.cjs.map +1 -0
- package/dist/components/organisms/Table/hooks/useTableSelection.d.ts +31 -0
- package/dist/components/organisms/Table/hooks/useTableSelection.d.ts.map +1 -0
- package/dist/components/organisms/Table/hooks/useTableSelection.js +45 -0
- package/dist/components/organisms/Table/hooks/useTableSelection.js.map +1 -0
- package/dist/components/organisms/Table/index.cjs +169 -38
- package/dist/components/organisms/Table/index.cjs.map +1 -1
- package/dist/components/organisms/Table/index.d.ts +57 -20
- package/dist/components/organisms/Table/index.d.ts.map +1 -1
- package/dist/components/organisms/Table/index.js +162 -33
- package/dist/components/organisms/Table/index.js.map +1 -1
- package/dist/components/organisms/Table/providers/Table.context.cjs +19 -0
- package/dist/components/organisms/Table/providers/Table.context.cjs.map +1 -0
- package/dist/components/organisms/Table/providers/Table.context.d.ts +44 -0
- package/dist/components/organisms/Table/providers/Table.context.d.ts.map +1 -0
- package/dist/components/organisms/Table/providers/Table.context.js +13 -0
- package/dist/components/organisms/Table/providers/Table.context.js.map +1 -0
- package/dist/components/organisms/Table/table.types.d.ts +35 -0
- package/dist/components/organisms/Table/table.types.d.ts.map +1 -0
- package/dist/components/organisms/Table/utilities/tableCard.utils.cjs +197 -0
- package/dist/components/organisms/Table/utilities/tableCard.utils.cjs.map +1 -0
- package/dist/components/organisms/Table/utilities/tableCard.utils.d.ts +161 -0
- package/dist/components/organisms/Table/utilities/tableCard.utils.d.ts.map +1 -0
- package/dist/components/organisms/Table/utilities/tableCard.utils.js +180 -0
- package/dist/components/organisms/Table/utilities/tableCard.utils.js.map +1 -0
- package/dist/components/organisms/Table/utilities/tableChildren.utils.cjs +47 -0
- package/dist/components/organisms/Table/utilities/tableChildren.utils.cjs.map +1 -0
- package/dist/components/organisms/Table/utilities/tableChildren.utils.d.ts +39 -0
- package/dist/components/organisms/Table/utilities/tableChildren.utils.d.ts.map +1 -0
- package/dist/components/organisms/Table/utilities/tableChildren.utils.js +43 -0
- package/dist/components/organisms/Table/utilities/tableChildren.utils.js.map +1 -0
- package/dist/components/organisms/Table/utilities/tableSelection.utils.cjs +106 -0
- package/dist/components/organisms/Table/utilities/tableSelection.utils.cjs.map +1 -0
- package/dist/components/organisms/Table/utilities/tableSelection.utils.d.ts +82 -0
- package/dist/components/organisms/Table/utilities/tableSelection.utils.d.ts.map +1 -0
- package/dist/components/organisms/Table/utilities/tableSelection.utils.js +98 -0
- package/dist/components/organisms/Table/utilities/tableSelection.utils.js.map +1 -0
- package/dist/components/organisms/Table/utilities/tableSort.utils.cjs +87 -0
- package/dist/components/organisms/Table/utilities/tableSort.utils.cjs.map +1 -0
- package/dist/components/organisms/Table/utilities/tableSort.utils.d.ts +67 -0
- package/dist/components/organisms/Table/utilities/tableSort.utils.d.ts.map +1 -0
- package/dist/components/organisms/Table/utilities/tableSort.utils.js +79 -0
- package/dist/components/organisms/Table/utilities/tableSort.utils.js.map +1 -0
- package/dist/utilities/searchParamsUtils/index.cjs +2 -9
- package/dist/utilities/searchParamsUtils/index.cjs.map +1 -1
- package/dist/utilities/searchParamsUtils/index.d.ts +5 -3
- package/dist/utilities/searchParamsUtils/index.d.ts.map +1 -1
- package/dist/utilities/searchParamsUtils/index.js +2 -9
- package/dist/utilities/searchParamsUtils/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/organisms/Table/table.utils.cjs +0 -61
- package/dist/components/organisms/Table/table.utils.cjs.map +0 -1
- package/dist/components/organisms/Table/table.utils.d.ts +0 -48
- package/dist/components/organisms/Table/table.utils.d.ts.map +0 -1
- package/dist/components/organisms/Table/table.utils.js +0 -55
- package/dist/components/organisms/Table/table.utils.js.map +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { FallbackCardSlots } from '../utilities/tableCard.utils';
|
|
3
|
+
export declare const TableFallbackCard: ({ slots: { title, trailing, lines } }: {
|
|
4
|
+
slots: FallbackCardSlots<ReactNode>;
|
|
5
|
+
}) => import("react").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=TableFallbackCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableFallbackCard.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/Table/components/TableFallbackCard.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAoB,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAYxF,eAAO,MAAM,iBAAiB,GAAI,uCAAuC;IAAE,KAAK,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;CAAE,gCAK/G,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { TableRowCard, TableRowCardHeader } from './TableRowCard.js';
|
|
3
|
+
|
|
4
|
+
// The label keeps one line at up to 40% of the card, and a long value wraps beside it, top-aligned with it.
|
|
5
|
+
const renderLine = ({ key, label, value }) => (jsxs("div", { className: "flex items-start gap-3 text-sm", children: [label && jsx("span", { className: "max-w-2/5 shrink-0 truncate text-tertiary", children: label }), jsx("div", { className: "ml-auto min-w-0 text-right wrap-break-word text-secondary", children: value })] }, key));
|
|
6
|
+
// The card of a row that declares none: its row-header cell as the title, each other column a label/value line.
|
|
7
|
+
const TableFallbackCard = ({ slots: { title, trailing, lines } }) => (jsxs(TableRowCard, { children: [jsx(TableRowCardHeader, { title: title, badge: trailing.length > 0 ? trailing : undefined }), lines.length > 0 && jsx("div", { className: "flex flex-col gap-2 px-4 pt-3 pb-4", children: lines.map(renderLine) })] }));
|
|
8
|
+
|
|
9
|
+
export { TableFallbackCard };
|
|
10
|
+
//# sourceMappingURL=TableFallbackCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableFallbackCard.js","sources":["../../../../../src/components/organisms/Table/components/TableFallbackCard.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;AAMA;AACA,MAAM,UAAU,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAA+B,MACpEA,cAAe,SAAS,EAAC,gCAAgC,EAAA,QAAA,EAAA,CACtD,KAAK,IAAIC,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,2CAA2C,YAAE,KAAK,EAAA,CAAQ,EACpFA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,2DAA2D,YAAE,KAAK,EAAA,CAAO,KAFhF,GAAG,CAGP,CACP;AAED;AACO,MAAM,iBAAiB,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAA2C,MAC9GD,IAAA,CAAC,YAAY,EAAA,EAAA,QAAA,EAAA,CACXC,GAAA,CAAC,kBAAkB,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,GAAG,QAAQ,GAAG,SAAS,EAAA,CAAI,EACtF,KAAK,CAAC,MAAM,GAAG,CAAC,IAAIA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,oCAAoC,YAAE,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,EAAA,CAAO,CAAA,EAAA,CACzF;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableFocusGuard.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/Table/components/TableFocusGuard.tsx"],"names":[],"mappings":"AAOA,eAAO,MAAM,eAAe,YAY3B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var uiIcons = require('@flipdish/ui-icons');
|
|
5
|
+
var ButtonGroup = require('@flipdish/ui-library/components/molecules/ButtonGroup');
|
|
6
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
7
|
+
var useIsAtLeastMd = require('../hooks/useIsAtLeastMd.cjs');
|
|
8
|
+
|
|
9
|
+
const isTableLayout = (key) => key === 'table' || key === 'cards';
|
|
10
|
+
/** Two icon buttons, Table view and Card view, that switch a `Table`'s `desktopLayout`; renders nothing below `md`, where `mobileLayout` decides. */
|
|
11
|
+
const TableLayoutToggle = ({ value, onChange, className, 'data-testid': dataTestId }) => {
|
|
12
|
+
// Nothing on the server and while hydrating, as the table's own layout waits for the viewport there too.
|
|
13
|
+
const isAtLeastMd = useIsAtLeastMd.useIsAtLeastMd();
|
|
14
|
+
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'table-layout-toggle', rootName: 'table-layout-toggle' });
|
|
15
|
+
const chooseLayout = (keys) => {
|
|
16
|
+
const [layout] = keys;
|
|
17
|
+
if (isTableLayout(layout))
|
|
18
|
+
onChange(layout);
|
|
19
|
+
};
|
|
20
|
+
if (!isAtLeastMd)
|
|
21
|
+
return null;
|
|
22
|
+
return (jsxRuntime.jsxs(ButtonGroup.ButtonGroup, { "aria-label": "Table layout", size: "sm", selectedKeys: [value], onSelectionChange: chooseLayout, disallowEmptySelection: true, className: className, "data-testid": rootTestId, children: [jsxRuntime.jsx(ButtonGroup.ButtonGroupItem, { id: "table", "aria-label": "Table view", iconLeading: uiIcons.Table }), jsxRuntime.jsx(ButtonGroup.ButtonGroupItem, { id: "cards", "aria-label": "Card view", iconLeading: uiIcons.Grid01 })] }));
|
|
23
|
+
};
|
|
24
|
+
TableLayoutToggle.displayName = 'TableLayoutToggle';
|
|
25
|
+
|
|
26
|
+
exports.TableLayoutToggle = TableLayoutToggle;
|
|
27
|
+
//# sourceMappingURL=TableLayoutToggle.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableLayoutToggle.cjs","sources":["../../../../../src/components/organisms/Table/components/TableLayoutToggle.tsx"],"sourcesContent":[null],"names":["useIsAtLeastMd","useResolvedTestId","_jsxs","ButtonGroup","_jsx","ButtonGroupItem","TableIcon","Grid01"],"mappings":";;;;;;;;AAoBA,MAAM,aAAa,GAAG,CAAC,GAAoB,KAAyB,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,OAAO;AAEtG;AACO,MAAM,iBAAiB,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAA0B,KAAI;;AAErH,IAAA,MAAM,WAAW,GAAGA,6BAAc,EAAE;AACpC,IAAA,MAAM,UAAU,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,qBAAqB,EAAE,CAAC;AAE7H,IAAA,MAAM,YAAY,GAAG,CAAC,IAAc,KAAI;AACtC,QAAA,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI;QACrB,IAAI,aAAa,CAAC,MAAM,CAAC;YAAE,QAAQ,CAAC,MAAM,CAAC;AAC7C,IAAA,CAAC;AAED,IAAA,IAAI,CAAC,WAAW;AAAE,QAAA,OAAO,IAAI;IAE7B,QACEC,eAAA,CAACC,uBAAW,EAAA,EAAA,YAAA,EACC,cAAc,EACzB,IAAI,EAAC,IAAI,EACT,YAAY,EAAE,CAAC,KAAK,CAAC,EACrB,iBAAiB,EAAE,YAAY,EAC/B,sBAAsB,EAAA,IAAA,EACtB,SAAS,EAAE,SAAS,EAAA,aAAA,EACP,UAAU,EAAA,QAAA,EAAA,CAEvBC,eAACC,2BAAe,EAAA,EAAC,EAAE,EAAC,OAAO,EAAA,YAAA,EAAY,YAAY,EAAC,WAAW,EAAEC,aAAS,EAAA,CAAI,EAC9EF,cAAA,CAACC,2BAAe,EAAA,EAAC,EAAE,EAAC,OAAO,EAAA,YAAA,EAAY,WAAW,EAAC,WAAW,EAAEE,cAAM,EAAA,CAAI,CAAA,EAAA,CAC9D;AAElB;AACA,iBAAiB,CAAC,WAAW,GAAG,mBAAmB;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TableLayout } from '../table.types';
|
|
2
|
+
export interface TableLayoutToggleProps {
|
|
3
|
+
/** The layout the table shows from `md` up; pass the same value to the table's `desktopLayout`. */
|
|
4
|
+
value: TableLayout;
|
|
5
|
+
/** Called with the layout the user picks. */
|
|
6
|
+
onChange: (value: TableLayout) => void;
|
|
7
|
+
/** Classes for the group of two buttons. */
|
|
8
|
+
className?: string;
|
|
9
|
+
/** Overrides the root `data-testid` (defaults to `fd-table-layout-toggle`); the options derive `<root>--item-table` and `<root>--item-cards`. */
|
|
10
|
+
'data-testid'?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Two icon buttons, Table view and Card view, that switch a `Table`'s `desktopLayout`; renders nothing below `md`, where `mobileLayout` decides. */
|
|
13
|
+
export declare const TableLayoutToggle: {
|
|
14
|
+
({ value, onChange, className, "data-testid": dataTestId }: TableLayoutToggleProps): import("react").JSX.Element | null;
|
|
15
|
+
displayName: string;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=TableLayoutToggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableLayoutToggle.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/Table/components/TableLayoutToggle.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,sBAAsB;IACrC,mGAAmG;IACnG,KAAK,EAAE,WAAW,CAAC;IACnB,6CAA6C;IAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iJAAiJ;IACjJ,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAID,qJAAqJ;AACrJ,eAAO,MAAM,iBAAiB;gEAA+D,sBAAsB;;CA0BlH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Table, Grid01 } from '@flipdish/ui-icons';
|
|
3
|
+
import { ButtonGroup, ButtonGroupItem } from '@flipdish/ui-library/components/molecules/ButtonGroup';
|
|
4
|
+
import { useResolvedTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
5
|
+
import { useIsAtLeastMd } from '../hooks/useIsAtLeastMd.js';
|
|
6
|
+
|
|
7
|
+
const isTableLayout = (key) => key === 'table' || key === 'cards';
|
|
8
|
+
/** Two icon buttons, Table view and Card view, that switch a `Table`'s `desktopLayout`; renders nothing below `md`, where `mobileLayout` decides. */
|
|
9
|
+
const TableLayoutToggle = ({ value, onChange, className, 'data-testid': dataTestId }) => {
|
|
10
|
+
// Nothing on the server and while hydrating, as the table's own layout waits for the viewport there too.
|
|
11
|
+
const isAtLeastMd = useIsAtLeastMd();
|
|
12
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'table-layout-toggle', rootName: 'table-layout-toggle' });
|
|
13
|
+
const chooseLayout = (keys) => {
|
|
14
|
+
const [layout] = keys;
|
|
15
|
+
if (isTableLayout(layout))
|
|
16
|
+
onChange(layout);
|
|
17
|
+
};
|
|
18
|
+
if (!isAtLeastMd)
|
|
19
|
+
return null;
|
|
20
|
+
return (jsxs(ButtonGroup, { "aria-label": "Table layout", size: "sm", selectedKeys: [value], onSelectionChange: chooseLayout, disallowEmptySelection: true, className: className, "data-testid": rootTestId, children: [jsx(ButtonGroupItem, { id: "table", "aria-label": "Table view", iconLeading: Table }), jsx(ButtonGroupItem, { id: "cards", "aria-label": "Card view", iconLeading: Grid01 })] }));
|
|
21
|
+
};
|
|
22
|
+
TableLayoutToggle.displayName = 'TableLayoutToggle';
|
|
23
|
+
|
|
24
|
+
export { TableLayoutToggle };
|
|
25
|
+
//# sourceMappingURL=TableLayoutToggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableLayoutToggle.js","sources":["../../../../../src/components/organisms/Table/components/TableLayoutToggle.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx","TableIcon"],"mappings":";;;;;;AAoBA,MAAM,aAAa,GAAG,CAAC,GAAoB,KAAyB,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,OAAO;AAEtG;AACO,MAAM,iBAAiB,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAA0B,KAAI;;AAErH,IAAA,MAAM,WAAW,GAAG,cAAc,EAAE;AACpC,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,qBAAqB,EAAE,CAAC;AAE7H,IAAA,MAAM,YAAY,GAAG,CAAC,IAAc,KAAI;AACtC,QAAA,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI;QACrB,IAAI,aAAa,CAAC,MAAM,CAAC;YAAE,QAAQ,CAAC,MAAM,CAAC;AAC7C,IAAA,CAAC;AAED,IAAA,IAAI,CAAC,WAAW;AAAE,QAAA,OAAO,IAAI;IAE7B,QACEA,IAAA,CAAC,WAAW,EAAA,EAAA,YAAA,EACC,cAAc,EACzB,IAAI,EAAC,IAAI,EACT,YAAY,EAAE,CAAC,KAAK,CAAC,EACrB,iBAAiB,EAAE,YAAY,EAC/B,sBAAsB,EAAA,IAAA,EACtB,SAAS,EAAE,SAAS,EAAA,aAAA,EACP,UAAU,EAAA,QAAA,EAAA,CAEvBC,IAAC,eAAe,EAAA,EAAC,EAAE,EAAC,OAAO,EAAA,YAAA,EAAY,YAAY,EAAC,WAAW,EAAEC,KAAS,EAAA,CAAI,EAC9ED,GAAA,CAAC,eAAe,EAAA,EAAC,EAAE,EAAC,OAAO,EAAA,YAAA,EAAY,WAAW,EAAC,WAAW,EAAE,MAAM,EAAA,CAAI,CAAA,EAAA,CAC9D;AAElB;AACA,iBAAiB,CAAC,WAAW,GAAG,mBAAmB;;"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var Checkboxes = require('@flipdish/ui-library/components/atoms/Checkboxes');
|
|
5
|
+
var Skeleton = require('@flipdish/ui-library/components/atoms/Skeleton');
|
|
6
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
7
|
+
var renderUtils = require('@flipdish/ui-library/utilities/renderUtils');
|
|
8
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var children_utils = require('../../../../utilities/__internal__/childrenUtils/children.utils.cjs');
|
|
11
|
+
var log_utils = require('../../../../utilities/__internal__/logUtils/log.utils.cjs');
|
|
12
|
+
var Table_context = require('../providers/Table.context.cjs');
|
|
13
|
+
var tableCard_utils = require('../utilities/tableCard.utils.cjs');
|
|
14
|
+
|
|
15
|
+
// The row's own selection checkbox, react-aria's `selection` slot, centred on the title's 20px line.
|
|
16
|
+
const TableRowCardSelectionCheckbox = ({ rowTestId, isPlaceholder }) => (jsxRuntime.jsx("div", { className: "flex h-5 shrink-0 items-center", children: isPlaceholder ? (
|
|
17
|
+
// A placeholder holds the box's place, so its title sits where the loaded row's will.
|
|
18
|
+
jsxRuntime.jsx(Skeleton.Skeleton, { width: 20, height: 20, radius: "md" })) : (
|
|
19
|
+
// 12px of padding, taken back by a negative margin: a 44px touch target around the 20px box that moves nothing.
|
|
20
|
+
jsxRuntime.jsx(Checkboxes.Checkbox, { slot: "selection", size: "md", className: "-m-3 p-3", "data-testid": rowTestId ? testIdUtils.joinTestId(rowTestId, 'selection') : undefined })) }));
|
|
21
|
+
/** The card a `Table.Row` renders in place of its cells in the cards layout; a direct child of the row, and nothing in the table. */
|
|
22
|
+
const TableRowCard = ({ children, className, 'data-testid': dataTestId }) => {
|
|
23
|
+
const { layout } = React.useContext(Table_context.TableContext);
|
|
24
|
+
const row = React.useContext(Table_context.TableRowCardContext);
|
|
25
|
+
// Inside another card's surface this is not the row's own card: one wrapped in another element lands among the cells.
|
|
26
|
+
const isNested = React.useContext(Table_context.TableRowCardSurfaceContext);
|
|
27
|
+
const isMisplaced = layout === 'cards' && isNested;
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
if (!isMisplaced || renderUtils.isProductionBuild())
|
|
30
|
+
return;
|
|
31
|
+
log_utils.warnOnce('Table:nested-card', 'Table: a `Table.RowCard` renders only as a direct child of `Table.Row`; one inside another element renders nothing.');
|
|
32
|
+
}, [isMisplaced]);
|
|
33
|
+
if (layout !== 'cards' || !row || isNested)
|
|
34
|
+
return null;
|
|
35
|
+
// Only the card's first direct header takes the checkbox; without one, the card gives it a row of its own.
|
|
36
|
+
const parts = children_utils.flattenChildren(children);
|
|
37
|
+
const headerIndex = row.showsSelection ? parts.findIndex((part) => React.isValidElement(part) && part.type === TableRowCardHeader) : -1;
|
|
38
|
+
const renderPart = (part, index) => index === headerIndex && React.isValidElement(part) ? (jsxRuntime.jsx(Table_context.TableRowCardHeaderCheckboxContext.Provider, { value: true, children: part }, part.key)) : (part);
|
|
39
|
+
return (jsxRuntime.jsx(Table_context.TableRowCardSurfaceContext.Provider, { value: true, children: jsxRuntime.jsxs("div", { "data-testid": dataTestId ?? (row.testId ? testIdUtils.joinTestId(row.testId, 'card') : undefined), className: cx.cx(
|
|
40
|
+
// `flex-1` fills a row of cards to the height of the tallest.
|
|
41
|
+
'flex flex-1 flex-col overflow-hidden rounded-xl border border-secondary bg-primary text-left outline-focus-ring transition-colors duration-100 ease-linear', row.isInteractive ? 'cursor-pointer' : 'cursor-default',
|
|
42
|
+
// Before the states, so a tinted card still shows hover, press and highlight.
|
|
43
|
+
className, row.isHovered && 'bg-primary_hover', row.isPressed && 'bg-secondary_hover',
|
|
44
|
+
// `_alt` is brand-50 in light, like `bg-brand-primary`, and stays a surface in dark, where `bg-brand-primary` is solid brand-500.
|
|
45
|
+
row.isHighlighted && 'border-brand bg-brand-primary_alt', row.isFocusVisible && 'outline-2 outline-offset-2'), children: [row.showsSelection && headerIndex === -1 && (jsxRuntime.jsx("div", { className: "flex px-4 pt-4 last:pb-4", children: jsxRuntime.jsx(TableRowCardSelectionCheckbox, { rowTestId: row.testId, isPlaceholder: row.isPlaceholder }) })), parts.map(renderPart)] }) }));
|
|
46
|
+
};
|
|
47
|
+
TableRowCard.displayName = 'TableRowCard';
|
|
48
|
+
/** The card's first row: the selection checkbox on a selectable table, an optional avatar, the title over its description, and a trailing badge. */
|
|
49
|
+
const TableRowCardHeader = ({ title, description, badge, avatar, className }) => {
|
|
50
|
+
const showsCheckbox = React.useContext(Table_context.TableRowCardHeaderCheckboxContext);
|
|
51
|
+
const row = React.useContext(Table_context.TableRowCardContext);
|
|
52
|
+
return (jsxRuntime.jsxs("div", { className: cx.cx('flex items-start gap-3 px-4 pt-4 last:pb-4', className), children: [showsCheckbox && jsxRuntime.jsx(TableRowCardSelectionCheckbox, { rowTestId: row?.testId, isPlaceholder: row?.isPlaceholder }), jsxRuntime.jsxs(Table_context.TableRowCardHeaderCheckboxContext.Provider, { value: false, children: [tableCard_utils.isSlotShown(avatar) && jsxRuntime.jsx("div", { className: "flex shrink-0", children: avatar }), jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [jsxRuntime.jsx("div", { className: "truncate text-sm font-semibold text-primary", children: title }), tableCard_utils.isSlotShown(description) && jsxRuntime.jsx("div", { className: "text-xs text-tertiary", children: description })] }), tableCard_utils.isSlotShown(badge) && jsxRuntime.jsx("div", { className: "flex shrink-0 items-center gap-2 whitespace-nowrap", children: badge })] })] }));
|
|
53
|
+
};
|
|
54
|
+
TableRowCardHeader.displayName = 'TableRowCardHeader';
|
|
55
|
+
/** A wrapping row under the header for badges and icons; give an icon-only item an accessible name. */
|
|
56
|
+
const TableRowCardContent = ({ children, className }) => (jsxRuntime.jsx("div", { className: cx.cx('flex flex-wrap items-center gap-2 px-4 pt-3 last:pb-4', className), children: children }));
|
|
57
|
+
TableRowCardContent.displayName = 'TableRowCardContent';
|
|
58
|
+
/** A tinted strip across the bottom of the card, under a divider, with a start and an end value. */
|
|
59
|
+
const TableRowCardFooter = ({ start, end, className }) => (
|
|
60
|
+
// `mt-auto` keeps the strip at the bottom of a card stretched to its row's height; `pt-4` keeps 16px above it.
|
|
61
|
+
jsxRuntime.jsx("div", { className: "mt-auto pt-4", children: jsxRuntime.jsxs("div", { className: cx.cx('flex items-center gap-3 border-t border-secondary bg-secondary px-4 py-3 text-sm font-semibold text-primary', className), children: [tableCard_utils.isSlotShown(start) && jsxRuntime.jsx("div", { className: "min-w-0 flex-1 truncate", children: start }), tableCard_utils.isSlotShown(end) && jsxRuntime.jsx("div", { className: "ml-auto shrink-0 whitespace-nowrap", children: end })] }) }));
|
|
62
|
+
TableRowCardFooter.displayName = 'TableRowCardFooter';
|
|
63
|
+
/** A placeholder card for a loading row; the row carrying it is disabled and the table's row action skips it. */
|
|
64
|
+
const TableRowCardSkeleton = ({ children }) => (jsxRuntime.jsx(TableRowCard, { children: children ?? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(TableRowCardHeader, { title: jsxRuntime.jsx(Skeleton.Skeleton, { width: 96, height: 14, radius: "sm", className: "my-[3px]" }), description: jsxRuntime.jsx(Skeleton.Skeleton, { width: 128, height: 12, radius: "sm", className: "mt-1" }), badge: jsxRuntime.jsx(Skeleton.Skeleton, { width: 64, height: 22, radius: "full" }) }), jsxRuntime.jsxs(TableRowCardContent, { children: [jsxRuntime.jsx(Skeleton.Skeleton, { width: 20, height: 20, radius: "sm" }), jsxRuntime.jsx(Skeleton.Skeleton, { width: 20, height: 20, radius: "sm" }), jsxRuntime.jsx(Skeleton.Skeleton, { width: 72, height: 22, radius: "full" })] }), jsxRuntime.jsx(TableRowCardFooter, { start: jsxRuntime.jsx(Skeleton.Skeleton, { width: 120, height: 14, radius: "sm" }), end: jsxRuntime.jsx(Skeleton.Skeleton, { width: 56, height: 14, radius: "sm" }) })] })) }));
|
|
65
|
+
TableRowCardSkeleton.displayName = 'TableRowCardSkeleton';
|
|
66
|
+
/**
|
|
67
|
+
* Tells a row's card apart from its cells.
|
|
68
|
+
* @param element - One of the row's direct children.
|
|
69
|
+
* @returns `true` for a `Table.RowCard` or a `Table.RowCard.Skeleton`.
|
|
70
|
+
*/
|
|
71
|
+
const isRowCardElement = (element) => element.type === TableRowCard || element.type === TableRowCardSkeleton;
|
|
72
|
+
|
|
73
|
+
exports.TableRowCard = TableRowCard;
|
|
74
|
+
exports.TableRowCardContent = TableRowCardContent;
|
|
75
|
+
exports.TableRowCardFooter = TableRowCardFooter;
|
|
76
|
+
exports.TableRowCardHeader = TableRowCardHeader;
|
|
77
|
+
exports.TableRowCardSkeleton = TableRowCardSkeleton;
|
|
78
|
+
exports.isRowCardElement = isRowCardElement;
|
|
79
|
+
//# sourceMappingURL=TableRowCard.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableRowCard.cjs","sources":["../../../../../src/components/organisms/Table/components/TableRowCard.tsx"],"sourcesContent":[null],"names":["_jsx","Skeleton","Checkbox","joinTestId","useContext","TableContext","TableRowCardContext","TableRowCardSurfaceContext","useEffect","isProductionBuild","warnOnce","flattenChildren","isValidElement","TableRowCardHeaderCheckboxContext","_jsxs","cx","isSlotShown"],"mappings":";;;;;;;;;;;;;;AAaA;AACA,MAAM,6BAA6B,GAAG,CAAC,EAAE,SAAS,EAAE,aAAa,EAAmD,MAClHA,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,gCAAgC,YAC5C,aAAa;;AAEZ,IAAAA,cAAA,CAACC,iBAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAC,IAAI,GAAG;;AAG/C,IAAAD,cAAA,CAACE,mBAAQ,EAAA,EAAC,IAAI,EAAC,WAAW,EAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,UAAU,iBAAc,SAAS,GAAGC,sBAAU,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,SAAS,EAAA,CAAI,CACtI,EAAA,CACG,CACP;AAWD;AACO,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAqB,KAAI;IACpG,MAAM,EAAE,MAAM,EAAE,GAAGC,gBAAU,CAACC,0BAAY,CAAC;AAC3C,IAAA,MAAM,GAAG,GAAGD,gBAAU,CAACE,iCAAmB,CAAC;;AAE3C,IAAA,MAAM,QAAQ,GAAGF,gBAAU,CAACG,wCAA0B,CAAC;AACvD,IAAA,MAAM,WAAW,GAAG,MAAM,KAAK,OAAO,IAAI,QAAQ;IAElDC,eAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,WAA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type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
export interface TableRowCardProps {
|
|
3
|
+
/** The card's parts: `Table.RowCard.Header`, `Table.RowCard.Content` and `Table.RowCard.Footer`, in that order. */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** Classes for the card's surface. A row's own `className` never reaches its card, so a tinted row repeats its tint here. */
|
|
6
|
+
className?: string;
|
|
7
|
+
/** Overrides the derived `data-testid` (defaults to `<row>--card`). */
|
|
8
|
+
'data-testid'?: string;
|
|
9
|
+
}
|
|
10
|
+
/** The card a `Table.Row` renders in place of its cells in the cards layout; a direct child of the row, and nothing in the table. */
|
|
11
|
+
export declare const TableRowCard: {
|
|
12
|
+
({ children, className, "data-testid": dataTestId }: TableRowCardProps): import("react").JSX.Element | null;
|
|
13
|
+
displayName: string;
|
|
14
|
+
};
|
|
15
|
+
export interface TableRowCardHeaderProps {
|
|
16
|
+
/** The card's name, on one line with an ellipsis. Its text names the row; a title that is not plain text needs `textValue` on the row. */
|
|
17
|
+
title: ReactNode;
|
|
18
|
+
/** A second line under the title, such as a time or a reference. */
|
|
19
|
+
description?: ReactNode;
|
|
20
|
+
/** Trailing content, such as a status badge or a row's actions menu; it never shrinks, wraps or clips. */
|
|
21
|
+
badge?: ReactNode;
|
|
22
|
+
/** A leading avatar or logo, such as the brand in a list that spans several brands. */
|
|
23
|
+
avatar?: ReactNode;
|
|
24
|
+
/** Classes for the header row. Keep its 12px gap: the checkbox's 44px touch target fills it. */
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
/** The card's first row: the selection checkbox on a selectable table, an optional avatar, the title over its description, and a trailing badge. */
|
|
28
|
+
export declare const TableRowCardHeader: {
|
|
29
|
+
({ title, description, badge, avatar, className }: TableRowCardHeaderProps): import("react").JSX.Element;
|
|
30
|
+
displayName: string;
|
|
31
|
+
};
|
|
32
|
+
export interface TableRowCardContentProps {
|
|
33
|
+
/** Badges, icons and short values; they wrap onto further lines rather than widen the card. */
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
/** Classes for the content row. */
|
|
36
|
+
className?: string;
|
|
37
|
+
}
|
|
38
|
+
/** A wrapping row under the header for badges and icons; give an icon-only item an accessible name. */
|
|
39
|
+
export declare const TableRowCardContent: {
|
|
40
|
+
({ children, className }: TableRowCardContentProps): import("react").JSX.Element;
|
|
41
|
+
displayName: string;
|
|
42
|
+
};
|
|
43
|
+
export interface TableRowCardFooterProps {
|
|
44
|
+
/** The leading value, such as a customer; it truncates with an ellipsis. */
|
|
45
|
+
start?: ReactNode;
|
|
46
|
+
/** The trailing value, such as a total; it never shrinks, wraps or clips, and stays right-aligned without a `start`. */
|
|
47
|
+
end?: ReactNode;
|
|
48
|
+
/** Classes for the footer strip. */
|
|
49
|
+
className?: string;
|
|
50
|
+
}
|
|
51
|
+
/** A tinted strip across the bottom of the card, under a divider, with a start and an end value. */
|
|
52
|
+
export declare const TableRowCardFooter: {
|
|
53
|
+
({ start, end, className }: TableRowCardFooterProps): import("react").JSX.Element;
|
|
54
|
+
displayName: string;
|
|
55
|
+
};
|
|
56
|
+
export interface TableRowCardSkeletonProps {
|
|
57
|
+
/** The card's own parts holding `Skeleton`s, so the placeholder has the shape of the real card; a header, content and footer without. */
|
|
58
|
+
children?: ReactNode;
|
|
59
|
+
}
|
|
60
|
+
/** A placeholder card for a loading row; the row carrying it is disabled and the table's row action skips it. */
|
|
61
|
+
export declare const TableRowCardSkeleton: {
|
|
62
|
+
({ children }: TableRowCardSkeletonProps): import("react").JSX.Element;
|
|
63
|
+
displayName: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Tells a row's card apart from its cells.
|
|
67
|
+
* @param element - One of the row's direct children.
|
|
68
|
+
* @returns `true` for a `Table.RowCard` or a `Table.RowCard.Skeleton`.
|
|
69
|
+
*/
|
|
70
|
+
export declare const isRowCardElement: (element: ReactElement) => boolean;
|
|
71
|
+
//# sourceMappingURL=TableRowCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableRowCard.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/Table/components/TableRowCard.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAkB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAyB,MAAM,OAAO,CAAC;AAmBjG,MAAM,WAAW,iBAAiB;IAChC,mHAAmH;IACnH,QAAQ,EAAE,SAAS,CAAC;IACpB,6HAA6H;IAC7H,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qIAAqI;AACrI,eAAO,MAAM,YAAY;yDAAwD,iBAAiB;;CAuDjG,CAAC;AAGF,MAAM,WAAW,uBAAuB;IACtC,0IAA0I;IAC1I,KAAK,EAAE,SAAS,CAAC;IACjB,oEAAoE;IACpE,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,0GAA0G;IAC1G,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,uFAAuF;IACvF,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,gGAAgG;IAChG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,oJAAoJ;AACpJ,eAAO,MAAM,kBAAkB;uDAAsD,uBAAuB;;CAkB3G,CAAC;AAGF,MAAM,WAAW,wBAAwB;IACvC,+FAA+F;IAC/F,QAAQ,EAAE,SAAS,CAAC;IACpB,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,uGAAuG;AACvG,eAAO,MAAM,mBAAmB;8BAA6B,wBAAwB;;CAEpF,CAAC;AAGF,MAAM,WAAW,uBAAuB;IACtC,4EAA4E;IAC5E,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,wHAAwH;IACxH,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,oGAAoG;AACpG,eAAO,MAAM,kBAAkB;gCAA+B,uBAAuB;;CAQpF,CAAC;AAGF,MAAM,WAAW,yBAAyB;IACxC,yIAAyI;IACzI,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,iHAAiH;AACjH,eAAO,MAAM,oBAAoB;mBAAkB,yBAAyB;;CAkB3E,CAAC;AAGF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,YAAY,YAA2E,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { Checkbox } from '@flipdish/ui-library/components/atoms/Checkboxes';
|
|
3
|
+
import { Skeleton } from '@flipdish/ui-library/components/atoms/Skeleton';
|
|
4
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
5
|
+
import { isProductionBuild } from '@flipdish/ui-library/utilities/renderUtils';
|
|
6
|
+
import { joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
7
|
+
import { useContext, useEffect, isValidElement } from 'react';
|
|
8
|
+
import { flattenChildren } from '../../../../utilities/__internal__/childrenUtils/children.utils.js';
|
|
9
|
+
import { warnOnce } from '../../../../utilities/__internal__/logUtils/log.utils.js';
|
|
10
|
+
import { TableContext, TableRowCardContext, TableRowCardSurfaceContext, TableRowCardHeaderCheckboxContext } from '../providers/Table.context.js';
|
|
11
|
+
import { isSlotShown } from '../utilities/tableCard.utils.js';
|
|
12
|
+
|
|
13
|
+
// The row's own selection checkbox, react-aria's `selection` slot, centred on the title's 20px line.
|
|
14
|
+
const TableRowCardSelectionCheckbox = ({ rowTestId, isPlaceholder }) => (jsx("div", { className: "flex h-5 shrink-0 items-center", children: isPlaceholder ? (
|
|
15
|
+
// A placeholder holds the box's place, so its title sits where the loaded row's will.
|
|
16
|
+
jsx(Skeleton, { width: 20, height: 20, radius: "md" })) : (
|
|
17
|
+
// 12px of padding, taken back by a negative margin: a 44px touch target around the 20px box that moves nothing.
|
|
18
|
+
jsx(Checkbox, { slot: "selection", size: "md", className: "-m-3 p-3", "data-testid": rowTestId ? joinTestId(rowTestId, 'selection') : undefined })) }));
|
|
19
|
+
/** The card a `Table.Row` renders in place of its cells in the cards layout; a direct child of the row, and nothing in the table. */
|
|
20
|
+
const TableRowCard = ({ children, className, 'data-testid': dataTestId }) => {
|
|
21
|
+
const { layout } = useContext(TableContext);
|
|
22
|
+
const row = useContext(TableRowCardContext);
|
|
23
|
+
// Inside another card's surface this is not the row's own card: one wrapped in another element lands among the cells.
|
|
24
|
+
const isNested = useContext(TableRowCardSurfaceContext);
|
|
25
|
+
const isMisplaced = layout === 'cards' && isNested;
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!isMisplaced || isProductionBuild())
|
|
28
|
+
return;
|
|
29
|
+
warnOnce('Table:nested-card', 'Table: a `Table.RowCard` renders only as a direct child of `Table.Row`; one inside another element renders nothing.');
|
|
30
|
+
}, [isMisplaced]);
|
|
31
|
+
if (layout !== 'cards' || !row || isNested)
|
|
32
|
+
return null;
|
|
33
|
+
// Only the card's first direct header takes the checkbox; without one, the card gives it a row of its own.
|
|
34
|
+
const parts = flattenChildren(children);
|
|
35
|
+
const headerIndex = row.showsSelection ? parts.findIndex((part) => isValidElement(part) && part.type === TableRowCardHeader) : -1;
|
|
36
|
+
const renderPart = (part, index) => index === headerIndex && isValidElement(part) ? (jsx(TableRowCardHeaderCheckboxContext.Provider, { value: true, children: part }, part.key)) : (part);
|
|
37
|
+
return (jsx(TableRowCardSurfaceContext.Provider, { value: true, children: jsxs("div", { "data-testid": dataTestId ?? (row.testId ? joinTestId(row.testId, 'card') : undefined), className: cx(
|
|
38
|
+
// `flex-1` fills a row of cards to the height of the tallest.
|
|
39
|
+
'flex flex-1 flex-col overflow-hidden rounded-xl border border-secondary bg-primary text-left outline-focus-ring transition-colors duration-100 ease-linear', row.isInteractive ? 'cursor-pointer' : 'cursor-default',
|
|
40
|
+
// Before the states, so a tinted card still shows hover, press and highlight.
|
|
41
|
+
className, row.isHovered && 'bg-primary_hover', row.isPressed && 'bg-secondary_hover',
|
|
42
|
+
// `_alt` is brand-50 in light, like `bg-brand-primary`, and stays a surface in dark, where `bg-brand-primary` is solid brand-500.
|
|
43
|
+
row.isHighlighted && 'border-brand bg-brand-primary_alt', row.isFocusVisible && 'outline-2 outline-offset-2'), children: [row.showsSelection && headerIndex === -1 && (jsx("div", { className: "flex px-4 pt-4 last:pb-4", children: jsx(TableRowCardSelectionCheckbox, { rowTestId: row.testId, isPlaceholder: row.isPlaceholder }) })), parts.map(renderPart)] }) }));
|
|
44
|
+
};
|
|
45
|
+
TableRowCard.displayName = 'TableRowCard';
|
|
46
|
+
/** The card's first row: the selection checkbox on a selectable table, an optional avatar, the title over its description, and a trailing badge. */
|
|
47
|
+
const TableRowCardHeader = ({ title, description, badge, avatar, className }) => {
|
|
48
|
+
const showsCheckbox = useContext(TableRowCardHeaderCheckboxContext);
|
|
49
|
+
const row = useContext(TableRowCardContext);
|
|
50
|
+
return (jsxs("div", { className: cx('flex items-start gap-3 px-4 pt-4 last:pb-4', className), children: [showsCheckbox && jsx(TableRowCardSelectionCheckbox, { rowTestId: row?.testId, isPlaceholder: row?.isPlaceholder }), jsxs(TableRowCardHeaderCheckboxContext.Provider, { value: false, children: [isSlotShown(avatar) && jsx("div", { className: "flex shrink-0", children: avatar }), jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [jsx("div", { className: "truncate text-sm font-semibold text-primary", children: title }), isSlotShown(description) && jsx("div", { className: "text-xs text-tertiary", children: description })] }), isSlotShown(badge) && jsx("div", { className: "flex shrink-0 items-center gap-2 whitespace-nowrap", children: badge })] })] }));
|
|
51
|
+
};
|
|
52
|
+
TableRowCardHeader.displayName = 'TableRowCardHeader';
|
|
53
|
+
/** A wrapping row under the header for badges and icons; give an icon-only item an accessible name. */
|
|
54
|
+
const TableRowCardContent = ({ children, className }) => (jsx("div", { className: cx('flex flex-wrap items-center gap-2 px-4 pt-3 last:pb-4', className), children: children }));
|
|
55
|
+
TableRowCardContent.displayName = 'TableRowCardContent';
|
|
56
|
+
/** A tinted strip across the bottom of the card, under a divider, with a start and an end value. */
|
|
57
|
+
const TableRowCardFooter = ({ start, end, className }) => (
|
|
58
|
+
// `mt-auto` keeps the strip at the bottom of a card stretched to its row's height; `pt-4` keeps 16px above it.
|
|
59
|
+
jsx("div", { className: "mt-auto pt-4", children: jsxs("div", { className: cx('flex items-center gap-3 border-t border-secondary bg-secondary px-4 py-3 text-sm font-semibold text-primary', className), children: [isSlotShown(start) && jsx("div", { className: "min-w-0 flex-1 truncate", children: start }), isSlotShown(end) && jsx("div", { className: "ml-auto shrink-0 whitespace-nowrap", children: end })] }) }));
|
|
60
|
+
TableRowCardFooter.displayName = 'TableRowCardFooter';
|
|
61
|
+
/** A placeholder card for a loading row; the row carrying it is disabled and the table's row action skips it. */
|
|
62
|
+
const TableRowCardSkeleton = ({ children }) => (jsx(TableRowCard, { children: children ?? (jsxs(Fragment, { children: [jsx(TableRowCardHeader, { title: jsx(Skeleton, { width: 96, height: 14, radius: "sm", className: "my-[3px]" }), description: jsx(Skeleton, { width: 128, height: 12, radius: "sm", className: "mt-1" }), badge: jsx(Skeleton, { width: 64, height: 22, radius: "full" }) }), jsxs(TableRowCardContent, { children: [jsx(Skeleton, { width: 20, height: 20, radius: "sm" }), jsx(Skeleton, { width: 20, height: 20, radius: "sm" }), jsx(Skeleton, { width: 72, height: 22, radius: "full" })] }), jsx(TableRowCardFooter, { start: jsx(Skeleton, { width: 120, height: 14, radius: "sm" }), end: jsx(Skeleton, { width: 56, height: 14, radius: "sm" }) })] })) }));
|
|
63
|
+
TableRowCardSkeleton.displayName = 'TableRowCardSkeleton';
|
|
64
|
+
/**
|
|
65
|
+
* Tells a row's card apart from its cells.
|
|
66
|
+
* @param element - One of the row's direct children.
|
|
67
|
+
* @returns `true` for a `Table.RowCard` or a `Table.RowCard.Skeleton`.
|
|
68
|
+
*/
|
|
69
|
+
const isRowCardElement = (element) => element.type === TableRowCard || element.type === TableRowCardSkeleton;
|
|
70
|
+
|
|
71
|
+
export { TableRowCard, TableRowCardContent, TableRowCardFooter, TableRowCardHeader, TableRowCardSkeleton, isRowCardElement };
|
|
72
|
+
//# sourceMappingURL=TableRowCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableRowCard.js","sources":["../../../../../src/components/organisms/Table/components/TableRowCard.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;AAaA;AACA,MAAM,6BAA6B,GAAG,CAAC,EAAE,SAAS,EAAE,aAAa,EAAmD,MAClHA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,gCAAgC,YAC5C,aAAa;;AAEZ,IAAAA,GAAA,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAC,IAAI,GAAG;;AAG/C,IAAAA,GAAA,CAAC,QAAQ,EAAA,EAAC,IAAI,EAAC,WAAW,EAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,UAAU,iBAAc,SAAS,GAAG,UAAU,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,SAAS,EAAA,CAAI,CACtI,EAAA,CACG,CACP;AAWD;AACO,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAqB,KAAI;IACpG,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC;AAC3C,IAAA,MAAM,GAAG,GAAG,UAAU,CAAC,mBAAmB,CAAC;;AAE3C,IAAA,MAAM,QAAQ,GAAG,UAAU,CAAC,0BAA0B,CAAC;AACvD,IAAA,MAAM,WAAW,GAAG,MAAM,KAAK,OAAO,IAAI,QAAQ;IAElD,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,WAAW,IAAI,iBAAiB,EAAE;YAAE;AACzC,QAAA,QAAQ,CACN,mBAAmB,EACnB,qHAAqH,CACtH;AACH,IAAA,CAAC,EAAE,C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AM,GAAG,EAC9E,KAAK,EAAEA,GAAA,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAC,MAAM,EAAA,CAAG,EAAA,CACxD,EACFC,IAAA,CAAC,mBAAmB,eAClBD,GAAA,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAC,IAAI,EAAA,CAAG,EAC/CA,IAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAC,IAAI,GAAG,EAC/CA,GAAA,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAC,MAAM,EAAA,CAAG,CAAA,EAAA,CAC7B,EACtBA,GAAA,CAAC,kBAAkB,EAAA,EAAC,KAAK,EAAEA,GAAA,CAAC,QAAQ,IAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAC,IAAI,GAAG,EAAE,GAAG,EAAEA,GAAA,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAC,IAAI,EAAA,CAAG,EAAA,CAAI,IACpI,CACJ,EAAA,CACY;AAEjB,oBAAoB,CAAC,WAAW,GAAG,sBAAsB;AAEzD;;;;AAIG;MACU,gBAAgB,GAAG,CAAC,OAAqB,KAAK,OAAO,CAAC,IAAI,KAAK,YAAY,IAAI,OAAO,CAAC,IAAI,KAAK;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var uiIcons = require('@flipdish/ui-icons');
|
|
5
|
+
var Buttons = require('@flipdish/ui-library/components/atoms/Buttons');
|
|
6
|
+
var Dropdown = require('@flipdish/ui-library/components/molecules/Dropdown');
|
|
7
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
8
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
9
|
+
var useIsAtLeastMd = require('../hooks/useIsAtLeastMd.cjs');
|
|
10
|
+
var tableCard_utils = require('../utilities/tableCard.utils.cjs');
|
|
11
|
+
var tableSort_utils = require('../utilities/tableSort.utils.cjs');
|
|
12
|
+
|
|
13
|
+
const firstKeyOf = (selection) => (selection === 'all' ? undefined : [...selection][0]);
|
|
14
|
+
/** A "Sort by" menu of a table's sortable columns, both directions and "Clear sort", shown while the table shows cards; icon-only below `md`. */
|
|
15
|
+
const TableSortMenu = ({ columns, sortDescriptor, defaultSortDescriptor, onSortChange, mobileLayout = 'cards', desktopLayout = 'table', size = 'md', className, 'data-testid': dataTestId, }) => {
|
|
16
|
+
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'table-sort-menu', rootName: 'table-sort-menu' });
|
|
17
|
+
// Icon-only on the server and while hydrating too, so the two renders agree; the label comes once the viewport is known.
|
|
18
|
+
const isAtLeastMd = useIsAtLeastMd.useIsAtLeastMd();
|
|
19
|
+
const isIconOnly = !isAtLeastMd;
|
|
20
|
+
const sortedColumn = sortDescriptor ? columns.find((column) => column.id === sortDescriptor.column) : undefined;
|
|
21
|
+
const sortName = sortedColumn && sortDescriptor ? `Sort by ${sortedColumn.label}, ${sortDescriptor.direction}` : undefined;
|
|
22
|
+
// The order differs from the one the page rests at, so there is something to clear and the icon marks it.
|
|
23
|
+
const isAwayFromRest = !tableSort_utils.isSameSort(sortDescriptor, defaultSortDescriptor);
|
|
24
|
+
const chooseColumn = (selection) => {
|
|
25
|
+
const column = tableSort_utils.columnOfSortMenuKey(columns, firstKeyOf(selection));
|
|
26
|
+
if (column)
|
|
27
|
+
onSortChange(tableSort_utils.sortOfColumnChoice(sortDescriptor, column.id));
|
|
28
|
+
};
|
|
29
|
+
const chooseDirection = (selection) => {
|
|
30
|
+
const direction = firstKeyOf(selection);
|
|
31
|
+
if (direction === 'ascending' || direction === 'descending')
|
|
32
|
+
onSortChange(tableSort_utils.sortOfDirectionChoice(sortDescriptor, direction));
|
|
33
|
+
};
|
|
34
|
+
const clearSort = () => onSortChange(defaultSortDescriptor);
|
|
35
|
+
const renderColumnItem = (column) => (jsxRuntime.jsx(Dropdown.Dropdown.Item, { id: tableSort_utils.sortMenuColumnKeyOf(column.id), label: column.label }, tableSort_utils.sortMenuColumnKeyOf(column.id)));
|
|
36
|
+
// Read as the table reads it, so the two always agree, on the server and while hydrating too.
|
|
37
|
+
if (tableCard_utils.tableLayoutOf(isAtLeastMd, mobileLayout, desktopLayout) === 'table')
|
|
38
|
+
return null;
|
|
39
|
+
return (jsxRuntime.jsxs(Dropdown.Dropdown.Root, { "data-testid": rootTestId, children: [isIconOnly ? (jsxRuntime.jsx(Buttons.Button, { color: "secondary", size: size, iconLeading: uiIcons.SwitchVertical01, className: cx.cx('shrink-0',
|
|
40
|
+
// A decorative dot while the sort differs from the resting one; the name already states what the sort is.
|
|
41
|
+
isAwayFromRest && "after:absolute after:top-1 after:right-1 after:size-2 after:rounded-full after:bg-brand-solid after:content-['']", className), "aria-label": sortName ?? 'Sort by', "data-testid": testIdUtils.joinTestId(rootTestId, 'trigger') })) : (jsxRuntime.jsxs(Buttons.Button, { color: "secondary", size: size, iconLeading: uiIcons.SwitchVertical01,
|
|
42
|
+
// The label truncates, so the trigger never grows wider than the space it is given.
|
|
43
|
+
className: cx.cx('max-w-full min-w-0 *:data-text:min-w-0 *:data-text:truncate', className), "aria-label": sortName, "data-testid": testIdUtils.joinTestId(rootTestId, 'trigger'), children: ["Sort by", sortedColumn && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [' ', jsxRuntime.jsx("span", { className: "text-tertiary", children: sortedColumn.label })] }))] })), jsxRuntime.jsx(Dropdown.Dropdown.Popover, { children: jsxRuntime.jsxs(Dropdown.Dropdown.Menu, { "aria-label": "Sort by", children: [jsxRuntime.jsx(Dropdown.Dropdown.Section, { "aria-label": "Column", selectionMode: "single", disallowEmptySelection: true, selectedKeys: sortedColumn ? [tableSort_utils.sortMenuColumnKeyOf(sortedColumn.id)] : [], onSelectionChange: chooseColumn, children: columns.map(renderColumnItem) }), jsxRuntime.jsx(Dropdown.Dropdown.Separator, {}), jsxRuntime.jsxs(Dropdown.Dropdown.Section, { "aria-label": "Direction", selectionMode: "single", disallowEmptySelection: true, selectedKeys: sortedColumn && sortDescriptor ? [sortDescriptor.direction] : [], onSelectionChange: chooseDirection, children: [jsxRuntime.jsx(Dropdown.Dropdown.Item, { id: "ascending", label: "Ascending", isDisabled: !sortedColumn }), jsxRuntime.jsx(Dropdown.Dropdown.Item, { id: "descending", label: "Descending", isDisabled: !sortedColumn })] }), isAwayFromRest && jsxRuntime.jsx(Dropdown.Dropdown.Separator, {}), isAwayFromRest && jsxRuntime.jsx(Dropdown.Dropdown.Item, { id: "clear", label: "Clear sort", onAction: clearSort })] }) })] }));
|
|
44
|
+
};
|
|
45
|
+
TableSortMenu.displayName = 'TableSortMenu';
|
|
46
|
+
|
|
47
|
+
exports.TableSortMenu = TableSortMenu;
|
|
48
|
+
//# sourceMappingURL=TableSortMenu.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableSortMenu.cjs","sources":["../../../../../src/components/organisms/Table/components/TableSortMenu.tsx"],"sourcesContent":[null],"names":["useResolvedTestId","useIsAtLeastMd","isSameSort","columnOfSortMenuKey","sortOfColumnChoice","sortOfDirectionChoice","_jsx","Dropdown","sortMenuColumnKeyOf","tableLayoutOf","_jsxs","Button","SwitchVertical01","cx","joinTestId","_Fragment"],"mappings":";;;;;;;;;;;;AAsCA,MAAM,UAAU,GAAG,CAAC,SAAoB,MAAuB,SAAS,KAAK,KAAK,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAEnH;AACO,MAAM,aAAa,GAAG,CAAC,EAC5B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AC,YAAY,EAAC,QAAQ,EAAE,SAAS,GAAI,CAAA,EAAA,CACzE,EAAA,CACC,CAAA,EAAA,CACL;AAEpB;AACA,aAAa,CAAC,WAAW,GAAG,eAAe;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Key, SortDescriptor } from 'react-aria-components';
|
|
2
|
+
import type { TableLayout } from '../table.types';
|
|
3
|
+
export interface TableSortMenuProps {
|
|
4
|
+
/** The columns a user can sort by, in menu order: each `id` is its `Table.Head`'s `id`, and `label` names it in the menu. */
|
|
5
|
+
columns: readonly {
|
|
6
|
+
id: Key;
|
|
7
|
+
label: string;
|
|
8
|
+
}[];
|
|
9
|
+
/** The table's current sort; unset while nothing is sorted. */
|
|
10
|
+
sortDescriptor?: SortDescriptor;
|
|
11
|
+
/**
|
|
12
|
+
* What "Clear sort" reports, the table's own `defaultSortDescriptor`: the page's resting sort, which the page starts its
|
|
13
|
+
* `sortDescriptor` from. While the sort matches it the icon-only trigger has no dot and the menu no "Clear sort". Omitted,
|
|
14
|
+
* a clear reports `undefined`.
|
|
15
|
+
*/
|
|
16
|
+
defaultSortDescriptor?: SortDescriptor;
|
|
17
|
+
/** Called with the sort the user picks, or `defaultSortDescriptor` from "Clear sort"; pass the handler the table's `onSortChange` gets. */
|
|
18
|
+
onSortChange: (descriptor: SortDescriptor | undefined) => void;
|
|
19
|
+
/** The table's `mobileLayout`: the menu renders nothing below `md` while that is the table, which its headers sort. */
|
|
20
|
+
mobileLayout?: TableLayout;
|
|
21
|
+
/** The table's `desktopLayout`: the menu renders nothing from `md` up while that is the table, as it is by default. */
|
|
22
|
+
desktopLayout?: TableLayout;
|
|
23
|
+
/** The trigger's size, as a `Button`'s. */
|
|
24
|
+
size?: 'sm' | 'md';
|
|
25
|
+
/** Classes for the trigger button, such as `w-full` to fill a row. */
|
|
26
|
+
className?: string;
|
|
27
|
+
/** Overrides the root `data-testid` (defaults to `fd-table-sort-menu`); the trigger derives `<root>--trigger` and each item `<root>--item-<key>`. */
|
|
28
|
+
'data-testid'?: string;
|
|
29
|
+
}
|
|
30
|
+
/** A "Sort by" menu of a table's sortable columns, both directions and "Clear sort", shown while the table shows cards; icon-only below `md`. */
|
|
31
|
+
export declare const TableSortMenu: {
|
|
32
|
+
({ columns, sortDescriptor, defaultSortDescriptor, onSortChange, mobileLayout, desktopLayout, size, className, "data-testid": dataTestId, }: TableSortMenuProps): import("react").JSX.Element | null;
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=TableSortMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableSortMenu.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/Table/components/TableSortMenu.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,GAAG,EAAa,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,MAAM,WAAW,kBAAkB;IACjC,6HAA6H;IAC7H,OAAO,EAAE,SAAS;QAAE,EAAE,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC/C,+DAA+D;IAC/D,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,cAAc,CAAC;IACvC,2IAA2I;IAC3I,YAAY,EAAE,CAAC,UAAU,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/D,uHAAuH;IACvH,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,uHAAuH;IACvH,aAAa,CAAC,EAAE,WAAW,CAAC;IAC5B,2CAA2C;IAC3C,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qJAAqJ;IACrJ,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAID,iJAAiJ;AACjJ,eAAO,MAAM,aAAa;iJAUvB,kBAAkB;;CA2FpB,CAAC"}
|