@wonderflow/react-components 5.5.0 → 6.1.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/dist/components/autocomplete/autocomplete.js +2 -2
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +4 -4
- package/dist/components/card/card.d.ts +1 -1
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/card.js +2 -2
- package/dist/components/card/card.module.css +1 -1
- package/dist/components/chip/chip.js +1 -1
- package/dist/components/chip/chip.module.css +1 -1
- package/dist/components/drawer/drawer.js +1 -1
- package/dist/components/dropdown/dropdown.d.ts +28 -0
- package/dist/components/dropdown/dropdown.d.ts.map +1 -1
- package/dist/components/dropdown/dropdown.js +13 -8
- package/dist/components/elevator/elevator.d.ts.map +1 -1
- package/dist/components/elevator/elevator.js +2 -2
- package/dist/components/grid/grid.js +3 -3
- package/dist/components/grid/grid.module.css +1 -1
- package/dist/components/icon/icon.d.ts +7 -5
- package/dist/components/icon/icon.d.ts.map +1 -1
- package/dist/components/icon/icon.js +1 -1
- package/dist/components/info-state/info-state.js +1 -1
- package/dist/components/input-group/input-group.d.ts.map +1 -1
- package/dist/components/input-group/input-group.js +4 -4
- package/dist/components/list/list.js +1 -1
- package/dist/components/masonry/masonry.d.ts.map +1 -1
- package/dist/components/masonry/masonry.js +2 -2
- package/dist/components/menu/menu-item/menu-item.js +1 -1
- package/dist/components/menu/menu.js +1 -1
- package/dist/components/modal/content/modal-content.js +1 -1
- package/dist/components/select/select.js +1 -1
- package/dist/components/selection-controls/checkbox.d.ts.map +1 -1
- package/dist/components/selection-controls/checkbox.js +2 -1
- package/dist/components/selection-controls/radio.d.ts.map +1 -1
- package/dist/components/selection-controls/radio.js +2 -1
- package/dist/components/selection-controls/selection-controls.module.css +1 -1
- package/dist/components/slider/slider.js +1 -1
- package/dist/components/snackbar/snackbar.js +1 -1
- package/dist/components/stack/stack.d.ts +4 -4
- package/dist/components/stack/stack.d.ts.map +1 -1
- package/dist/components/stack/stack.js +6 -6
- package/dist/components/star-meter/star-meter.js +1 -1
- package/dist/components/tab/tab-item.d.ts.map +1 -1
- package/dist/components/tab/tab-item.js +3 -2
- package/dist/components/tab/tab.d.ts.map +1 -1
- package/dist/components/tab/tab.js +4 -5
- package/dist/components/tab/tab.module.css +1 -1
- package/dist/components/table/table-cell/table-cell.d.ts +0 -4
- package/dist/components/table/table-cell/table-cell.d.ts.map +1 -1
- package/dist/components/table/table-cell/table-cell.js +9 -20
- package/dist/components/table/table-cell/table-cell.module.css +1 -1
- package/dist/components/table/table-controls/toggle-columns.d.ts +4 -4
- package/dist/components/table/table-controls/toggle-columns.d.ts.map +1 -1
- package/dist/components/table/table-controls/toggle-columns.js +3 -3
- package/dist/components/table/table-header/table-header.d.ts +1 -1
- package/dist/components/table/table-header/table-header.d.ts.map +1 -1
- package/dist/components/table/table-header/table-header.js +2 -2
- package/dist/components/table/table-pagination/table-pagination.d.ts +1 -1
- package/dist/components/table/table-pagination/table-pagination.d.ts.map +1 -1
- package/dist/components/table/table-pagination/table-pagination.js +5 -3
- package/dist/components/table/table-row/table-row.d.ts +8 -3
- package/dist/components/table/table-row/table-row.d.ts.map +1 -1
- package/dist/components/table/table-row/table-row.js +12 -3
- package/dist/components/table/table-row/table-row.module.css +1 -1
- package/dist/components/table/table.d.ts +9 -9
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +50 -37
- package/dist/components/table/types.d.ts +9 -5
- package/dist/components/table/types.d.ts.map +1 -1
- package/dist/components/textfield/textfield.d.ts.map +1 -1
- package/dist/components/textfield/textfield.js +2 -2
- package/dist/components/toggle-button/toggle-button.module.css +1 -1
- package/dist/components/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/tooltip/tooltip.js +4 -3
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { forwardRef } from 'react';
|
|
|
3
3
|
import tkns from '@wonderflow/tokens/platforms/web/tokens.json';
|
|
4
4
|
import styles from './stack.module.css';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
export const Stack = forwardRef(({ children, className, rowGap, columnGap, as: Wrapper = 'div', inline = false, direction = 'column', wrap = false, fill = true,
|
|
6
|
+
export const Stack = forwardRef(({ children, className, rowGap, columnGap, as: Wrapper = 'div', inline = false, direction = 'column', wrap = false, fill = true, vAlign = 'initial', hAlign = 'initial', hPadding, vPadding, style, ...otherProps }, forwardedRef) => {
|
|
7
7
|
const alignmentTemplate = (prop) => {
|
|
8
8
|
if (prop.includes('start') || prop.includes('end')) {
|
|
9
9
|
return `flex-${prop}`;
|
|
@@ -13,10 +13,10 @@ export const Stack = forwardRef(({ children, className, rowGap, columnGap, as: W
|
|
|
13
13
|
const computedStyle = {
|
|
14
14
|
'--rGap': rowGap ? tkns.space[rowGap] : 0,
|
|
15
15
|
'--cGap': columnGap ? tkns.space[columnGap] : 0,
|
|
16
|
-
'--vAlign':
|
|
17
|
-
'--hAlign':
|
|
18
|
-
'--vPadding':
|
|
19
|
-
'--hPadding':
|
|
16
|
+
'--vAlign': vAlign && alignmentTemplate(vAlign),
|
|
17
|
+
'--hAlign': hAlign && alignmentTemplate(hAlign),
|
|
18
|
+
'--vPadding': vPadding ? tkns.space[vPadding] : 0,
|
|
19
|
+
'--hPadding': hPadding ? tkns.space[hPadding] : 0
|
|
20
20
|
};
|
|
21
|
-
return (_jsx(Wrapper, { ref: forwardedRef, style: { ...computedStyle, ...style }, "data-stack-inline": inline, "data-stack-wrap": wrap, "data-stack-direction": direction, "data-stack-fill": fill, "data-stack-has-padding": Boolean(
|
|
21
|
+
return (_jsx(Wrapper, { ref: forwardedRef, style: { ...computedStyle, ...style }, "data-stack-inline": inline, "data-stack-wrap": wrap, "data-stack-direction": direction, "data-stack-fill": fill, "data-stack-has-padding": Boolean(hPadding || vPadding), className: clsx(styles.Stack, styles.StackWrapper, className), ...otherProps, children: children }, void 0));
|
|
22
22
|
});
|
|
@@ -49,5 +49,5 @@ export const StarMeter = forwardRef(({ className, value = 0, starCount = 5, labe
|
|
|
49
49
|
return _jsx(Icon, { source: "star", weight: "solid", className: styles.Icon, dimension: properties[dimension].iconSize, fill: fillType }, starIndex);
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
|
-
return (_jsxs(Stack, { inline: true, direction: "row",
|
|
52
|
+
return (_jsxs(Stack, { inline: true, direction: "row", vAlign: "center", columnGap: 8, className: clsx(styles.StarMeter, className), role: "meter", fill: false, "aria-valuenow": clamp(value, 0, starCount), "aria-valuemin": 0, "aria-valuemax": starCount, "aria-labelledby": seedID('star-meter'), "data-star-meter-dimension": dimension, ref: forwardedRef, ...otherProps, children: [_jsx("svg", { "aria-hidden": "true", className: styles.Gradient, width: "100", height: "50", version: "1.1", xmlns: "http://www.w3.org/2000/svg", children: _jsx("defs", { children: _jsxs("linearGradient", { id: "HalfStar", children: [_jsx("stop", { offset: "0", style: { stopColor: 'var(--star-color)' } }, void 0), _jsx("stop", { offset: "50%", style: { stopColor: 'var(--star-color)' } }, void 0), _jsx("stop", { offset: "50.1%", style: { stopColor: 'var(--star-dimmed-color)' } }, void 0), _jsx("stop", { offset: "100%", style: { stopColor: 'var(--star-dimmed-color)' } }, void 0)] }, void 0) }, void 0) }, void 0), _jsx(Stack, { direction: "row", columnGap: dimension === 'small' ? 2 : 4, children: starType(starCount, value) }, void 0), _jsx(Text, { dimmed: 6, id: seedID('star-meter'), size: properties[dimension].labelSize, weight: "bold", children: !hideLabel && _jsx(_Fragment, { children: label || value.toString() }, void 0) }, void 0)] }, void 0));
|
|
53
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-item.d.ts","sourceRoot":"","sources":["../../../src/components/tab/tab-item.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,EAErB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"tab-item.d.ts","sourceRoot":"","sources":["../../../src/components/tab/tab-item.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,EAErB,MAAM,OAAO,CAAA;AAId,OAAO,EAAe,SAAS,EAAE,MAAM,cAAc,CAAA;AAKrD;;;GAGG;AACH,oBAAY,YAAY,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IACnE;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;CAC5B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO;IAVlB;;OAEG;;qDAwDH,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useRef, forwardRef } from 'react';
|
|
3
3
|
import { useRovingTabIndex, useFocusEffect } from 'react-roving-tabindex';
|
|
4
|
+
import { domMax, LazyMotion, m } from 'framer-motion';
|
|
4
5
|
import clsx from 'clsx';
|
|
5
6
|
import { Stack, Icon } from '../..';
|
|
6
7
|
import { useTabState } from './primitive-tab';
|
|
@@ -9,7 +10,7 @@ import styles from './tab.module.css';
|
|
|
9
10
|
* Tab.Item
|
|
10
11
|
* Component
|
|
11
12
|
*/
|
|
12
|
-
export const TabItem = forwardRef(({ children, className, icon, ...otherProps }, forwardedRef) => {
|
|
13
|
+
export const TabItem = forwardRef(({ children, className, icon, id, ...otherProps }, forwardedRef) => {
|
|
13
14
|
const { onClick, isActive } = useTabState(children);
|
|
14
15
|
const internalRef = useRef(forwardedRef);
|
|
15
16
|
const [, focused, handleKeyDown, handleClick] = useRovingTabIndex(internalRef, false);
|
|
@@ -18,6 +19,6 @@ export const TabItem = forwardRef(({ children, className, icon, ...otherProps },
|
|
|
18
19
|
onClick();
|
|
19
20
|
handleClick();
|
|
20
21
|
}, [handleClick, onClick]);
|
|
21
|
-
return (_jsxs(Stack, { as: "button", direction: "row",
|
|
22
|
+
return (_jsx(LazyMotion, { features: domMax, strict: true, children: _jsxs(Stack, { as: "button", direction: "row", vAlign: "center", hAlign: "start", fill: false, columnGap: 8, role: "tab", ref: internalRef, className: clsx(styles.TabItem, className), "aria-selected": isActive, onClick: fireClick, onKeyDown: handleKeyDown, onFocus: fireClick, type: "button", tabIndex: isActive ? 0 : -1, id: id, ...otherProps, children: [icon && _jsx(Icon, { source: icon, dimension: 16 }, void 0), children, isActive && _jsx(m.span, { initial: false, className: styles.Highlight, layoutId: id }, void 0)] }, void 0) }, void 0));
|
|
22
23
|
});
|
|
23
24
|
TabItem.displayName = 'Tab.Item';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab.d.ts","sourceRoot":"","sources":["../../../src/components/tab/tab.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,
|
|
1
|
+
{"version":3,"file":"tab.d.ts","sourceRoot":"","sources":["../../../src/components/tab/tab.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EAIV,MAAM,OAAO,CAAA;AAGd,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAW,YAAY,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAY,aAAa,EAAE,MAAM,aAAa,CAAA;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAQ1C;;;GAGG;AACH,oBAAY,QAAQ,GAAG,cAAc,GAAG;IACtC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/D;;OAEG;IACH,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAA;AAED,aAAK,YAAY,GAAG,KAAK,CAAC,yBAAyB,CAAC,QAAQ,CAAC,GAAG;IAC9D,KAAK,EAAE,KAAK,CAAC,yBAAyB,CAAC,aAAa,CAAC,CAAC;IACtD,IAAI,EAAE,KAAK,CAAC,yBAAyB,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC;IAC5E,IAAI,EAAE,KAAK,CAAC,yBAAyB,CAAC,YAAY,CAAC,CAAC;CACrD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,GAAG,cAwDE,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState, forwardRef, Children, cloneElement } from 'react';
|
|
2
|
+
import { useEffect, useState, forwardRef, Children, cloneElement, isValidElement } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { useUIDSeed } from 'react-uid';
|
|
5
5
|
import { TabItem } from './tab-item';
|
|
@@ -12,7 +12,6 @@ import styles from './tab.module.css';
|
|
|
12
12
|
* Component
|
|
13
13
|
*/
|
|
14
14
|
export const Tab = forwardRef(({ children, className, state, onChange, ...otherProps }, forwardedRef) => {
|
|
15
|
-
const renderedChildren = Children.toArray(children).filter(Boolean);
|
|
16
15
|
const innerState = useState(0);
|
|
17
16
|
const tabState = state || innerState;
|
|
18
17
|
const [currentTab] = tabState;
|
|
@@ -22,9 +21,9 @@ export const Tab = forwardRef(({ children, className, state, onChange, ...otherP
|
|
|
22
21
|
onChange(currentTab);
|
|
23
22
|
}
|
|
24
23
|
}, [currentTab, onChange]);
|
|
25
|
-
return (_jsx("div", { ref: forwardedRef, className: clsx(styles.Tab, className), ...otherProps, children: _jsxs(TabsWrapper, { state: tabState, children: [_jsx(TabList, { children: Children.map(
|
|
26
|
-
id: seedID(
|
|
27
|
-
'aria-labelledby': seedID(
|
|
24
|
+
return (_jsx("div", { ref: forwardedRef, className: clsx(styles.Tab, className), ...otherProps, children: _jsxs(TabsWrapper, { state: tabState, children: [_jsx(TabList, { children: Children.map(children, (child, index) => isValidElement(child) && (_jsx(TabItem, { id: seedID('tab-item'), "aria-controls": seedID('tab-panel'), icon: child.props.icon, children: child.props.label }, void 0))) }, void 0), Children.map(children, (child, index) => isValidElement(child) && cloneElement(child, {
|
|
25
|
+
id: seedID('tab-panel'),
|
|
26
|
+
'aria-labelledby': seedID('tab-item')
|
|
28
27
|
}))] }, void 0) }, void 0));
|
|
29
28
|
});
|
|
30
29
|
Tab.displayName = 'Tab';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.Tab{display:block}.TabList{-webkit-overflow-scrolling:touch;box-shadow:inset 0 -
|
|
1
|
+
.Tab{display:block}.TabList{--separator-size:1px;-webkit-overflow-scrolling:touch;box-shadow:inset 0 calc(var(--separator-size)*-1) 0 var(--dimmed-2);display:flex;flex-wrap:nowrap;outline:none;overflow-x:auto;overscroll-behavior-x:contain;padding:0 .44rem;scroll-snap-type:x mandatory}@media (max-width:47.999em){.TabList{-ms-overflow-style:none;scrollbar-color:transparent transparent;scrollbar-width:none}.TabList::-webkit-scrollbar{display:none}.TabList::-webkit-scrollbar-track{background:transparent}.TabList::-webkit-scrollbar-thumb{background-color:transparent;border:3px solid transparent;border-radius:6px}}.TabItem{-webkit-appearance:none;appearance:none;background-color:transparent;block-size:2.67rem;border:0;color:var(--dimmed-6);flex-shrink:0;font-family:inherit;font-size:inherit;outline-offset:-4px;overflow:unset;padding:.44rem .89rem;position:relative;white-space:nowrap}.TabItem[aria-selected=true]{-webkit-text-stroke:.7px currentcolor;color:var(--global-foreground)}.TabItem:not([aria-selected=true]) svg{fill:var(--dimmed-6)}.TabItem:not([aria-selected=true]):hover{cursor:pointer}.Highlight{background:var(--cta-default);border-radius:2px 2px 0 0;bottom:0;height:4px;left:0;pointer-events:none;position:absolute;width:100%}.TabPanel{animation:fade-in .2s;animation-timing-function:cubic-bezier(0,0,.34,1))}@keyframes fade-in{0%{opacity:0;transform:translate(var(--fade-from-x,0),var(--fade-from-y,0))}to{opacity:unset;transform:none}}
|
|
@@ -6,10 +6,6 @@ declare type TableCellProps = PropsWithClass & {
|
|
|
6
6
|
isSortedDesc?: boolean;
|
|
7
7
|
align?: OptionalColumnTypes['align'];
|
|
8
8
|
padding?: boolean;
|
|
9
|
-
depth?: number;
|
|
10
|
-
isExpander?: boolean;
|
|
11
|
-
expanded?: boolean;
|
|
12
|
-
hasSubrows?: boolean;
|
|
13
9
|
width?: string | number;
|
|
14
10
|
};
|
|
15
11
|
declare type PolymorphicCell = Polymorphic.ForwardRefComponent<'td', TableCellProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-cell.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-cell/table-cell.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"table-cell.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-cell/table-cell.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAQ,WAAW,EAAE,MAAM,cAAc,CAAA;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAG9C,aAAK,cAAc,GAAG,cAAc,GAAG;IACrC,SAAS,CAAC,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB,CAAA;AAED,aAAK,eAAe,GAAG,WAAW,CAAC,mBAAmB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;AAE7E,eAAO,MAAM,SAAS,iBA8CD,CAAA"}
|
|
@@ -1,27 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import styles from './table-cell.module.css';
|
|
3
|
-
import { forwardRef, useMemo } from 'react';
|
|
4
|
-
import { Icon } from '../../..';
|
|
5
2
|
import clsx from 'clsx';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
`hsl(${tkns.color.red[30]})`,
|
|
13
|
-
`hsl(${tkns.color.yellow[20]})`,
|
|
14
|
-
`hsl(${tkns.color.purple[20]})`
|
|
15
|
-
];
|
|
16
|
-
const currentIndex = useMemo(() => (depth - 1) % colors.length, [colors.length, depth]);
|
|
17
|
-
const nextIndex = useMemo(() => depth % colors.length, [colors.length, depth]);
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { Icon } from '../../..';
|
|
5
|
+
import styles from './table-cell.module.css';
|
|
6
|
+
export const TableCell = forwardRef(({ children, className, collapsed, isSorted, align = 'start', style, isSortedDesc, as: Wrapper = 'td', padding = true, width, ...otherProps }, forwardedRef) => {
|
|
7
|
+
const isWidthString = typeof width === 'string';
|
|
8
|
+
const computedWidthNumber = typeof width === 'number' ? `${width}px` : undefined;
|
|
18
9
|
const dynamicStyle = {
|
|
19
|
-
'--width':
|
|
20
|
-
'--text-align': align
|
|
21
|
-
'--line-current-color': depth ? colors[currentIndex] : undefined,
|
|
22
|
-
'--line-next-color': depth ? colors[nextIndex] : colors[0]
|
|
10
|
+
'--width': isWidthString ? width : computedWidthNumber,
|
|
11
|
+
'--text-align': align
|
|
23
12
|
};
|
|
24
|
-
return (_jsxs(Wrapper, { ref: forwardedRef, className: clsx(styles.TableCell, className), "data-table-cell-collapsed": collapsed, "data-table-cell-padding": padding, "data-table-cell-
|
|
13
|
+
return (_jsxs(Wrapper, { ref: forwardedRef, className: clsx(styles.TableCell, className), "data-table-cell-collapsed": collapsed, "data-table-cell-padding": padding, "data-table-cell-fixed": Boolean(width), style: {
|
|
25
14
|
...dynamicStyle,
|
|
26
15
|
...style,
|
|
27
16
|
userSelect: Wrapper === 'td' ? undefined : 'none'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.TableCell{--indent-guide-width:24px;font-feature-settings:"tnum";word-wrap:break-word;font-variant-numeric:tabular-nums;line-height:1.2;margin:0;max-width:var(--width);padding:0;position:relative;text-align:start}.TableCell:not(:only-child){text-align:var(--text-align,start)}.TableCell[data-table-cell-fixed=true]{width:var(--width,1%)}.TableCell[data-table-cell-collapsed=true]{width:1e-10%}.TableCell[data-table-cell-padding=true]{padding:.66rem .44rem}.
|
|
1
|
+
.TableCell{--indent-guide-width:24px;font-feature-settings:"tnum";word-wrap:break-word;font-variant-numeric:tabular-nums;line-height:1.2;margin:0;max-width:var(--width);padding:0;position:relative;text-align:start}.TableCell:not(:only-child){text-align:var(--text-align,start)}.TableCell[data-table-cell-fixed=true]{width:var(--width,1%)}.TableCell[data-table-cell-collapsed=true]{width:1e-10%}.TableCell[data-table-cell-padding=true]{padding:.66rem .44rem}.HeadCellIcon{margin-inline-start:.44rem}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CustomColumnInstanceType } from '../types';
|
|
3
|
-
declare type ToggleColumnsControlProps = {
|
|
4
|
-
columns: CustomColumnInstanceType
|
|
5
|
-
visibleColumns: CustomColumnInstanceType
|
|
3
|
+
declare type ToggleColumnsControlProps<T extends Record<string, unknown>> = {
|
|
4
|
+
columns: Array<CustomColumnInstanceType<T>>;
|
|
5
|
+
visibleColumns: Array<CustomColumnInstanceType<T>>;
|
|
6
6
|
};
|
|
7
|
-
export declare const ToggleColumnsControl: ({ columns, visibleColumns }: ToggleColumnsControlProps) => JSX.Element;
|
|
7
|
+
export declare const ToggleColumnsControl: <T extends Record<string, unknown>>({ columns, visibleColumns }: ToggleColumnsControlProps<T>) => JSX.Element;
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=toggle-columns.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-columns.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-controls/toggle-columns.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"toggle-columns.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-controls/toggle-columns.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAEnD,aAAK,yBAAyB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IAClE,OAAO,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,cAAc,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;CACpD,CAAA;AAED,eAAO,MAAM,oBAAoB,+GAqDhC,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Dropdown, Menu, Button } from '../../..';
|
|
3
2
|
import { useCallback, useMemo } from 'react';
|
|
3
|
+
import { Button, Menu, Dropdown } from '../../..';
|
|
4
4
|
export const ToggleColumnsControl = ({ columns, visibleColumns }) => {
|
|
5
5
|
const someVisibleColums = useMemo(() => visibleColumns.length !== 0, [visibleColumns]);
|
|
6
6
|
const filteredColumns = useMemo(() => columns.filter(col => !col.hideFromList), [columns]);
|
|
@@ -10,14 +10,14 @@ export const ToggleColumnsControl = ({ columns, visibleColumns }) => {
|
|
|
10
10
|
* hide them all by calling `toggleHidden(true)` for each column
|
|
11
11
|
*/
|
|
12
12
|
if (someVisibleColums) {
|
|
13
|
-
visibleColumns.forEach(
|
|
13
|
+
visibleColumns.forEach(col => col.toggleHidden(true));
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* If there are no visible columns (excluding artificial ones), call
|
|
18
18
|
* toggleHidden(false) for each column
|
|
19
19
|
*/
|
|
20
|
-
filteredColumns.forEach(
|
|
20
|
+
filteredColumns.forEach(col => col.toggleHidden(false));
|
|
21
21
|
}, [someVisibleColums, filteredColumns, visibleColumns]);
|
|
22
22
|
return (_jsx(Dropdown, { placement: "bottom-start", trigger: _jsx(Button, { kind: "secondary", children: "Toggle columns" }, void 0), children: _jsxs(Menu, { children: [_jsx(Menu.ItemCheckbox, { onClick: () => handleToggleAll(), checked: true, icon: visibleColumns.length === 0 ? 'check' : 'minus', children: "Toggle All" }, void 0), columns.filter(col => !col.hideFromList).map((column, i) => (_jsx(Menu.ItemCheckbox, { autoFocus: i === 0, checked: column.isVisible, icon: column.isVisible ? 'check' : undefined, onClick: () => column.toggleHidden(), children: column.render('Header') }, column.id)))] }, void 0) }, void 0));
|
|
23
23
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Title, Polymorphic } from '../../..';
|
|
2
1
|
import { FC, HTMLAttributes } from 'react';
|
|
2
|
+
import { Polymorphic, Title } from '../../..';
|
|
3
3
|
export declare type TableHeaderProps = HTMLAttributes<HTMLElement> & {
|
|
4
4
|
title?: string | Polymorphic.IntrinsicElement<typeof Title>;
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-header.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-header/table-header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"table-header.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-header/table-header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAS,KAAK,EAAE,MAAM,cAAc,CAAA;AAGxD,oBAAY,gBAAgB,GAAG,cAAc,CAAC,WAAW,CAAC,GAAG;IAC3D,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,gBAAgB,CAAC,OAAO,KAAK,CAAC,CAAC;CAC7D,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAuB5C,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Stack, Title } from '../../..';
|
|
3
3
|
import styles from './table-header.module.css';
|
|
4
|
-
export const TableHeader = ({ children, title, id, ...otherProps }) => (_jsxs(Stack, { direction: "row", columnGap: 32,
|
|
4
|
+
export const TableHeader = ({ children, title, id, ...otherProps }) => (_jsxs(Stack, { direction: "row", columnGap: 32, vAlign: "center", hAlign: "space-between", fill: false, className: styles.TableHeader, ...otherProps, children: [_jsx("div", { children: typeof title === 'string' ? _jsx(Title, { id: id, level: "5", children: title }, void 0) : title }, void 0), _jsx(Stack, { direction: "row", vAlign: "center", columnGap: 8, inline: true, children: children }, void 0)] }, void 0));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-pagination.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-pagination/table-pagination.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"table-pagination.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-pagination/table-pagination.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAW,MAAM,OAAO,CAAA;AAOnC,oBAAY,oBAAoB,GAAG,cAAc,GAAG;IAClD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CA4DpD,CAAA"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Select, Stack, Text, Pagination } from '../../..';
|
|
3
2
|
import { useMemo } from 'react';
|
|
4
3
|
import { useUIDSeed } from 'react-uid';
|
|
4
|
+
import { Pagination, Select, Stack, Text } from '../../..';
|
|
5
5
|
export const TablePagination = ({ children, pageSize, onPageSizeChange, clusters = [5, 10, 20, 30, 50, 100], totalItems, currentPage, isManual, totalPages, onPageClick, ...otherProps }) => {
|
|
6
6
|
const uid = useUIDSeed();
|
|
7
|
-
const computedPageCount = useMemo(() => isManual ? Math.ceil(totalItems / pageSize) : totalPages, [isManual, pageSize, totalItems, totalPages]);
|
|
7
|
+
const computedPageCount = useMemo(() => (isManual ? Math.ceil(totalItems / pageSize) : totalPages), [isManual, pageSize, totalItems, totalPages]);
|
|
8
8
|
const computedItemsInPageStart = useMemo(() => (currentPage && pageSize) && currentPage * pageSize, [currentPage, pageSize]);
|
|
9
9
|
const computedItemsInPageEnd = useMemo(() => currentPage * pageSize + pageSize, [currentPage, pageSize]);
|
|
10
|
-
return (_jsxs(Stack, { fill: false, direction: "row", columnGap: 16,
|
|
10
|
+
return (_jsxs(Stack, { fill: false, direction: "row", columnGap: 16, vAlign: "center", hAlign: "end", vPadding: 16, ...otherProps, children: [_jsxs(Stack, { direction: "row", columnGap: 4, children: [_jsx(Text, { as: "label", htmlFor: uid('table-i-per-page'), size: 14, children: "Items per page:" }, void 0), _jsx(Select, { value: pageSize, dimension: "small", id: uid('table-i-per-page'), onChange: ({ currentTarget }) => {
|
|
11
|
+
onPageSizeChange?.(Number(currentTarget.value));
|
|
12
|
+
}, children: clusters.map(cluster => (_jsx("option", { value: cluster, children: cluster }, cluster))) }, void 0)] }, void 0), _jsx(Text, { "aria-hidden": "true", weight: "bold", size: 14, children: `${computedItemsInPageStart + 1}-${computedItemsInPageEnd > totalItems ? totalItems : computedItemsInPageEnd} of ${totalItems}` }, void 0), _jsx(Pagination, { itemsCount: totalItems, itemsPerPage: pageSize, pageCount: computedPageCount, onPageClick: ({ selected }) => onPageClick?.(selected), renderOnZeroPageCount: () => null, forcePage: currentPage }, void 0)] }, void 0));
|
|
11
13
|
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { IdType, Row } from 'react-table';
|
|
3
|
+
declare type TableRowProps<T extends Record<string, unknown>> = PropsWithChildren<PropsWithClass> & {
|
|
4
|
+
expanded?: boolean;
|
|
5
|
+
rowData?: Row<T>;
|
|
6
|
+
expandedRows?: Array<IdType<T>>;
|
|
7
|
+
};
|
|
8
|
+
export declare const TableRow: <T extends Record<string, unknown>>({ children, className, expanded, rowData, expandedRows, ...otherProps }: TableRowProps<T>) => JSX.Element;
|
|
4
9
|
export {};
|
|
5
10
|
//# sourceMappingURL=table-row.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-row.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-row/table-row.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"table-row.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-row/table-row.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAW,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAIzC,aAAK,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,iBAAiB,CAAC,cAAc,CAAC,GAAG;IAC1F,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CACjC,CAAA;AAED,eAAO,MAAM,QAAQ,+IA4BpB,CAAA"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import styles from './table-row.module.css';
|
|
3
2
|
import clsx from 'clsx';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import styles from './table-row.module.css';
|
|
5
|
+
export const TableRow = ({ children, className, expanded, rowData, expandedRows, ...otherProps }) => {
|
|
6
|
+
const highlightRow = useMemo(() => {
|
|
7
|
+
const [currentParentRowId] = rowData?.id.match(/.*(?=\.)/) ?? [];
|
|
8
|
+
const isHighlight = expandedRows?.includes(currentParentRowId) && expandedRows.every((rowId) => {
|
|
9
|
+
const [parentRowMatch] = rowId.match(/.*(?=\.)/) ?? [];
|
|
10
|
+
return parentRowMatch !== currentParentRowId;
|
|
11
|
+
});
|
|
12
|
+
return Boolean(isHighlight);
|
|
13
|
+
}, [expandedRows, rowData]);
|
|
14
|
+
return (_jsx("tr", { className: clsx(styles.TableRow, className), "data-table-row-expanded": expanded, "data-table-row-highlight": highlightRow || undefined, ...otherProps, children: children }, void 0));
|
|
6
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.TableRow:not([data-table-row-expander=true]){block-size:calc(2.67rem + 1px)}.TableRow+.TableRow{border-top:1px solid transparent}[data-table-stripes=true] .TableRow:nth-child(2n):not([data-table-row-highlight=true],[data-table-row-expander]){background-color:var(--dimmed-0)}[data-table-separators=true] .TableRow+.TableRow{border-color:var(--dimmed-1)}
|
|
1
|
+
.TableRow:not([data-table-row-expander=true]){block-size:calc(2.67rem + 1px)}.TableRow+.TableRow{border-top:1px solid transparent}[data-table-stripes=true] .TableRow:nth-child(2n):not([data-table-row-highlight=true],[data-table-row-expander]){background-color:var(--dimmed-0)}[data-table-separators=true] .TableRow+.TableRow{border-color:var(--dimmed-1)}.TableRow[data-table-row-expanded=true]{background-color:rgba(110,179,231,.13)}.TableRow[data-table-row-highlight]{background-color:hsl(206 72% 67%/7%)}[data-table-separators=true] .TableRow[data-table-row-highlight]+.TableRow[data-table-row-highlight]{border-color:rgba(110,179,231,.18)}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import { IdType, Row, SortingRule } from 'react-table';
|
|
2
3
|
import { TableHeaderProps } from './table-header';
|
|
3
4
|
import { TablePaginationProps } from './table-pagination';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export declare type TableProps<T extends object> = PropsWithClass & {
|
|
5
|
+
import { CustomColumnsType, CustomSortingRule, OptionalDataTypes, PaginationType } from './types';
|
|
6
|
+
export declare type TableProps<T extends Record<string, unknown>> = PropsWithClass & {
|
|
7
7
|
/**
|
|
8
8
|
* Define the columns and headers of the table.
|
|
9
9
|
*/
|
|
@@ -33,7 +33,7 @@ export declare type TableProps<T extends object> = PropsWithClass & {
|
|
|
33
33
|
* Passing this property along side `showPagination` will enable manual pagination,
|
|
34
34
|
* disabling the automatic one.
|
|
35
35
|
*/
|
|
36
|
-
onDataUpdate?: ({ pageIndex, pageSize }: PaginationType) => Promise<void
|
|
36
|
+
onDataUpdate?: ({ pageIndex, pageSize }: PaginationType) => Promise<void> | void;
|
|
37
37
|
/**
|
|
38
38
|
* Set the number of pages to show in the pagination. Used only when doing manual pagination.
|
|
39
39
|
*/
|
|
@@ -51,7 +51,7 @@ export declare type TableProps<T extends object> = PropsWithClass & {
|
|
|
51
51
|
/**
|
|
52
52
|
* Callback run when the selected rows change
|
|
53
53
|
*/
|
|
54
|
-
onSelectionChange
|
|
54
|
+
onSelectionChange?: (selectedRows?: Array<Row<T>>, selectedRowIds?: Record<IdType<T>, boolean>) => void;
|
|
55
55
|
/**
|
|
56
56
|
* If true, disable the automatic column sorting of the table. Turn this on if you want to
|
|
57
57
|
* to control the sorting yourself.
|
|
@@ -60,7 +60,7 @@ export declare type TableProps<T extends object> = PropsWithClass & {
|
|
|
60
60
|
/**
|
|
61
61
|
* Callback run when a column is sorted
|
|
62
62
|
*/
|
|
63
|
-
onSortChange
|
|
63
|
+
onSortChange?: (sorting: Array<CustomSortingRule<T>>) => void;
|
|
64
64
|
/**
|
|
65
65
|
* Add an alternate style to the table rows
|
|
66
66
|
*/
|
|
@@ -97,7 +97,7 @@ export declare type TableProps<T extends object> = PropsWithClass & {
|
|
|
97
97
|
/**
|
|
98
98
|
* Set the label for selected items in the table. Default to "Selected items"
|
|
99
99
|
*/
|
|
100
|
-
selectedLabel?:
|
|
100
|
+
selectedLabel?: (selectedRows: Array<Row<T>>) => ReactNode;
|
|
101
101
|
/**
|
|
102
102
|
* Pass custom components to show when rows are selected.
|
|
103
103
|
*/
|
|
@@ -134,5 +134,5 @@ export declare type TableProps<T extends object> = PropsWithClass & {
|
|
|
134
134
|
*/
|
|
135
135
|
initialSortBy?: Array<SortingRule<T>>;
|
|
136
136
|
};
|
|
137
|
-
export declare const Table: <T extends
|
|
137
|
+
export declare const Table: <T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, onSelectionChange, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, actionsRowComponent: ActionsRowComponent, emptyComponent, showPagination, isManualSorted, onDataUpdate, onSortChange, itemsPerPage, totalRows, activePageIndex, pageClusters, initialSortBy, ...otherProps }: TableProps<T>) => JSX.Element;
|
|
138
138
|
//# sourceMappingURL=table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/components/table/table.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/components/table/table.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
4
|
+
import { Fragment, useEffect, useMemo } from 'react';
|
|
5
|
+
import { useExpanded, usePagination, useRowSelect, useSortBy, useTable } from 'react-table';
|
|
6
|
+
import { useUIDSeed } from 'react-uid';
|
|
7
|
+
import { Skeleton, Stack, Text, ToggleButton } from '../..';
|
|
8
|
+
import styles from './table.module.css';
|
|
5
9
|
import { TableCell } from './table-cell';
|
|
6
10
|
import { TableCheckbox } from './table-checkbox';
|
|
7
|
-
import { TableHeader } from './table-header';
|
|
8
11
|
import { ToggleColumnsControl } from './table-controls';
|
|
9
12
|
import { TableExpand } from './table-expand';
|
|
13
|
+
import { TableHeader } from './table-header';
|
|
10
14
|
import { TablePagination } from './table-pagination';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
import styles from './table.module.css';
|
|
14
|
-
import { Fragment, useEffect, useMemo } from 'react';
|
|
15
|
-
import { Text, Stack, IconButton, Skeleton } from '../..';
|
|
16
|
-
export const Table = ({ className, style, columns, data = [], selectableRows, onSelectionChange, stripes, showSeparators = true, title, actions, selectedActions, selectedLabel = 'Selected items', showHeader = false, showTableHead = true, columnsControl = false, defaultHiddenColumns, height, loading, background, expandableRowComponent, actionsRowComponent: ActionsRowComponent, emptyComponent, showPagination, isManualSorted, onDataUpdate, onSortChange, itemsPerPage = 10, totalRows, activePageIndex = 0, pageClusters, initialSortBy = [], ...otherProps }) => {
|
|
15
|
+
import { TableRow } from './table-row';
|
|
16
|
+
export const Table = ({ className, style, columns, data = [], selectableRows, onSelectionChange, stripes, showSeparators = true, title, actions, selectedActions, selectedLabel = selectedRows => `Selected items: ${selectedRows.length}`, showHeader = false, showTableHead = true, columnsControl = false, defaultHiddenColumns, height, loading, background, expandableRowComponent, actionsRowComponent: ActionsRowComponent, emptyComponent, showPagination, isManualSorted, onDataUpdate, onSortChange, itemsPerPage = 10, totalRows, activePageIndex = 0, pageClusters, initialSortBy = [], ...otherProps }) => {
|
|
17
17
|
const uid = useUIDSeed();
|
|
18
18
|
const hasSomeExpandableRows = useMemo(() => data.some(d => d.subRows), [data]);
|
|
19
|
-
const isManualPaginated = useMemo(() =>
|
|
20
|
-
return Boolean(onDataUpdate && showPagination && totalRows);
|
|
21
|
-
}, [onDataUpdate, showPagination, totalRows]);
|
|
19
|
+
const isManualPaginated = useMemo(() => Boolean(onDataUpdate && showPagination && totalRows), [onDataUpdate, showPagination, totalRows]);
|
|
22
20
|
const { getTableProps, getTableBodyProps, headerGroups, rows, page, pageCount, gotoPage, allColumns, prepareRow, selectedFlatRows, visibleColumns, setPageSize, setHiddenColumns, state: { pageSize, pageIndex, selectedRowIds, sortBy } } = useTable({
|
|
23
21
|
columns,
|
|
24
22
|
data,
|
|
@@ -30,8 +28,11 @@ export const Table = ({ className, style, columns, data = [], selectableRows, on
|
|
|
30
28
|
manualPagination: isManualPaginated,
|
|
31
29
|
autoResetSelectedRows: false,
|
|
32
30
|
pageCount: (isManualPaginated && totalRows) ? Math.ceil(totalRows / itemsPerPage) : 10,
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
/**
|
|
32
|
+
* This `paginateExpandedRows` prop prevent expanded rows to
|
|
33
|
+
* be placed in the next page. But it breaks row selection
|
|
34
|
+
* paginateExpandedRows: !showPagination,
|
|
35
|
+
*/
|
|
35
36
|
initialState: {
|
|
36
37
|
sortBy: initialSortBy,
|
|
37
38
|
pageIndex: activePageIndex,
|
|
@@ -41,30 +42,34 @@ export const Table = ({ className, style, columns, data = [], selectableRows, on
|
|
|
41
42
|
}, useSortBy, useExpanded, usePagination, useRowSelect, (hooks) => {
|
|
42
43
|
const checkboxColumn = [{
|
|
43
44
|
id: 'selection',
|
|
44
|
-
Header: ({ getToggleAllRowsSelectedProps }) => !loading ? _jsx(TableCheckbox, { ...getToggleAllRowsSelectedProps() }, void 0) : null,
|
|
45
|
-
Cell: ({ row }) => _jsx(TableCheckbox, { ...row.getToggleRowSelectedProps() }, void 0),
|
|
46
45
|
isCollapsed: true,
|
|
47
|
-
hideFromList: true
|
|
46
|
+
hideFromList: true,
|
|
47
|
+
Header: ({ getToggleAllRowsSelectedProps }) => (!loading
|
|
48
|
+
? (_jsx(TableCheckbox, { ...getToggleAllRowsSelectedProps() }, void 0))
|
|
49
|
+
: null),
|
|
50
|
+
Cell: ({ row }) => (_jsx(TableCheckbox, { ...row.getToggleRowSelectedProps() }, void 0))
|
|
48
51
|
}];
|
|
49
52
|
const expanderColumn = [{
|
|
50
53
|
id: 'expander',
|
|
51
|
-
isCollapsed: true,
|
|
52
54
|
hideFromList: true,
|
|
53
55
|
expander: true,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
minWidth: 40,
|
|
57
|
+
align: 'center',
|
|
58
|
+
Cell: ({ row }) => (row.canExpand
|
|
59
|
+
? (_jsx(ToggleButton, { kind: "secondary", dimension: "small", restingIcon: "chevron-right", pressedIcon: "chevron-down", ...row.getToggleRowExpandedProps(), onClick: () => {
|
|
60
|
+
const subRowsExpanded = row.subRows.filter(r => r.isExpanded);
|
|
61
|
+
subRowsExpanded.forEach(r => r.toggleRowExpanded(!r.isExpanded));
|
|
62
|
+
row.toggleRowExpanded(!row.isExpanded);
|
|
63
|
+
} }, void 0))
|
|
64
|
+
: null)
|
|
60
65
|
}];
|
|
61
66
|
const actionsColumn = [{
|
|
62
67
|
id: 'actions',
|
|
63
68
|
isCollapsed: true,
|
|
64
69
|
hideFromList: true,
|
|
65
|
-
Cell: ({ row }) => ActionsRowComponent ? _jsx(ActionsRowComponent, { ...row }, void 0) : null
|
|
70
|
+
Cell: ({ row }) => (ActionsRowComponent ? _jsx(ActionsRowComponent, { ...row }, void 0) : null)
|
|
66
71
|
}];
|
|
67
|
-
hooks.visibleColumns.push(
|
|
72
|
+
hooks.visibleColumns.push(columns => [
|
|
68
73
|
...checkboxColumn,
|
|
69
74
|
...expanderColumn,
|
|
70
75
|
...actionsColumn,
|
|
@@ -72,7 +77,7 @@ export const Table = ({ className, style, columns, data = [], selectableRows, on
|
|
|
72
77
|
]);
|
|
73
78
|
});
|
|
74
79
|
useEffect(() => {
|
|
75
|
-
const artificialColumns = defaultHiddenColumns
|
|
80
|
+
const artificialColumns = defaultHiddenColumns ?? [];
|
|
76
81
|
if (!selectableRows)
|
|
77
82
|
artificialColumns.push('selection');
|
|
78
83
|
if (!hasSomeExpandableRows)
|
|
@@ -80,23 +85,31 @@ export const Table = ({ className, style, columns, data = [], selectableRows, on
|
|
|
80
85
|
if (!ActionsRowComponent)
|
|
81
86
|
artificialColumns.push('actions');
|
|
82
87
|
setHiddenColumns(artificialColumns);
|
|
83
|
-
}, [
|
|
88
|
+
}, [
|
|
89
|
+
selectableRows,
|
|
90
|
+
setHiddenColumns,
|
|
91
|
+
defaultHiddenColumns,
|
|
92
|
+
expandableRowComponent,
|
|
93
|
+
hasSomeExpandableRows,
|
|
94
|
+
ActionsRowComponent
|
|
95
|
+
]);
|
|
84
96
|
useEffect(() => {
|
|
85
|
-
onSelectionChange
|
|
97
|
+
onSelectionChange?.(selectedFlatRows, selectedRowIds);
|
|
86
98
|
}, [onSelectionChange, selectedFlatRows, selectedRowIds]);
|
|
87
99
|
useEffect(() => {
|
|
88
|
-
onSortChange
|
|
100
|
+
onSortChange?.(sortBy);
|
|
89
101
|
}, [onSortChange, sortBy]);
|
|
90
102
|
useEffect(() => {
|
|
91
|
-
onDataUpdate
|
|
103
|
+
onDataUpdate?.({ pageIndex, pageSize });
|
|
92
104
|
}, [onDataUpdate, pageIndex, pageSize]);
|
|
93
|
-
const rowEntries = useMemo(() => showPagination ? page : rows, [page, rows, showPagination]);
|
|
94
|
-
const filteredVisibleColumns = useMemo(() => visibleColumns.filter((col) => !col.hideFromList), [visibleColumns]);
|
|
105
|
+
const rowEntries = useMemo(() => (showPagination ? page : rows), [page, rows, showPagination]);
|
|
106
|
+
const filteredVisibleColumns = useMemo(() => (visibleColumns.filter((col) => !col.hideFromList)), [visibleColumns]);
|
|
107
|
+
const expandedRows = useMemo(() => rows.filter(row => row.canExpand && row.isExpanded).map(r => r.id), [rows]);
|
|
95
108
|
const dynamicStyle = {
|
|
96
109
|
'--table-height': height,
|
|
97
110
|
'--table-background': background
|
|
98
111
|
};
|
|
99
|
-
return (_jsxs("div", { className: clsx(styles.Table, className), style: { ...dynamicStyle, ...style }, children: [_jsx(AnimatePresence, { children: selectedFlatRows?.length && (_jsxs(Stack, { as: motion.div, className: styles.Toast, direction: "row",
|
|
112
|
+
return (_jsxs("div", { className: clsx(styles.Table, className), style: { ...dynamicStyle, ...style }, children: [_jsx(AnimatePresence, { children: selectedFlatRows?.length && (_jsxs(Stack, { as: motion.div, className: styles.Toast, direction: "row", hAlign: "space-between", vAlign: "center", hPadding: 16, vPadding: 8, fill: false, columnGap: 16, initial: { y: '-16px', opacity: 0 }, animate: {
|
|
100
113
|
y: 0,
|
|
101
114
|
opacity: 1,
|
|
102
115
|
transition: {
|
|
@@ -104,14 +117,14 @@ export const Table = ({ className, style, columns, data = [], selectableRows, on
|
|
|
104
117
|
stiffness: 700,
|
|
105
118
|
damping: 30
|
|
106
119
|
}
|
|
107
|
-
}, exit: { y: '-16px', opacity: 0 }, children: [_jsx(Text, { as: "span", size: 14, weight: "bold", children:
|
|
120
|
+
}, exit: { y: '-16px', opacity: 0 }, children: [_jsx(Text, { as: "span", size: 14, weight: "bold", children: selectedLabel(selectedFlatRows) }, void 0), selectedActions] }, void 0)) }, void 0), (showHeader || selectableRows) && (_jsxs(TableHeader, { title: title, children: [(columnsControl && data.length)
|
|
108
121
|
? (_jsx(ToggleColumnsControl, { columns: allColumns, visibleColumns: filteredVisibleColumns }, void 0))
|
|
109
122
|
: null, actions] }, void 0)), ((data.length || loading) && filteredVisibleColumns.length)
|
|
110
123
|
? (_jsx("div", { className: styles.TableWrapper, "data-table-scrolling": Boolean(height), children: _jsxs("table", { className: styles.TableElement, "data-table-stripes": stripes, "data-table-separators": showSeparators, "data-table-loading": loading, "aria-labelledby": uid('table-title'), ...getTableProps(), ...otherProps, children: [showTableHead && (_jsx("thead", { role: "rowgroup", className: styles.THead, children: headerGroups.map(headerGroup => (_jsx(TableRow, { ...headerGroup.getHeaderGroupProps(), children: headerGroup.headers.map((column) => (_jsx(TableCell, { as: "th", width: column.minWidth === 0 ? undefined : column.minWidth, collapsed: column.isCollapsed, isSorted: column.isSorted, isSortedDesc: column.isSorted && column.isSortedDesc, align: column.align, ...column.getHeaderProps(column.getSortByToggleProps()), children: column.render('Header') }, void 0))) }, void 0))) }, void 0)), _jsx("tbody", { role: "rowgroup", className: styles.TBody, ...getTableBodyProps(), children: loading
|
|
111
124
|
? (_jsx(TableRow, { children: visibleColumns.map(() => (_jsx(TableCell, { children: _jsx(Skeleton, { gap: 16, height: 16, count: 5 }, void 0) }, void 0))) }, void 0))
|
|
112
125
|
: rowEntries.map((row) => {
|
|
113
126
|
prepareRow(row);
|
|
114
|
-
return (_jsxs(Fragment, { children: [_jsx(TableRow, { ...row.getRowProps(),
|
|
127
|
+
return (_jsxs(Fragment, { children: [_jsx(TableRow, { ...row.getRowProps(), expanded: (row.isExpanded && !row.subRows.some(subrow => subrow.isExpanded && subrow.canExpand)), rowData: row, expandedRows: expandedRows, children: row.cells.map((cell) => (_jsx(TableCell, { collapsed: cell.column.isCollapsed, width: cell.column.minWidth === 0 ? undefined : cell.column.minWidth, align: cell.column.align, ...cell.getCellProps(), children: cell.render('Cell') }, void 0))) }, void 0), (row.subRows && row.isExpanded && expandableRowComponent) && row.subRows.map(subRow => (_jsx(TableRow, { "data-table-row-expander": true, children: _jsx(TableCell, { padding: false, colSpan: 100, children: _jsx(TableExpand, { data: subRow.original, component: expandableRowComponent }, void 0) }, void 0) }, subRow.id)))] }, row.id));
|
|
115
128
|
}) }, void 0)] }, void 0) }, void 0))
|
|
116
|
-
: (_jsx(Stack, {
|
|
129
|
+
: (_jsx(Stack, { vAlign: "center", hAlign: "center", children: emptyComponent ?? 'No data' }, void 0)), (showPagination && filteredVisibleColumns.length > 0 && !!rows.length) && (_jsx(TablePagination, { clusters: pageClusters, pageSize: pageSize, totalItems: totalRows ?? rows.length, currentPage: pageIndex, totalPages: pageCount, isManual: Boolean(isManualPaginated && totalRows), onPageSizeChange: newPageSize => setPageSize(newPageSize), onPageClick: selected => gotoPage(selected) }, void 0))] }, void 0));
|
|
117
130
|
};
|