@wonderflow/react-components 5.6.0 → 7.0.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/core/utils/media.css +5 -5
- package/dist/components/autocomplete/autocomplete-option.js +1 -1
- package/dist/components/autocomplete/autocomplete.js +4 -4
- package/dist/components/avatar/avatar.js +1 -1
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +5 -5
- package/dist/components/button/button.module.css +1 -1
- 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/circular-progress/circular-progress.js +3 -3
- package/dist/components/clamp-text/clamp-text.js +1 -1
- package/dist/components/container/container.js +1 -1
- package/dist/components/datetime/datetime.js +1 -1
- package/dist/components/disclosure/disclosure.js +3 -3
- package/dist/components/disclosure/disclosure.module.css +1 -1
- package/dist/components/drawer/drawer.js +1 -1
- package/dist/components/elevator/elevator.d.ts.map +1 -1
- package/dist/components/elevator/elevator.js +3 -3
- package/dist/components/grid/grid.js +4 -4
- package/dist/components/grid/grid.module.css +1 -1
- package/dist/components/grid/item/grid-item.js +1 -1
- package/dist/components/icon/icon.d.ts +1 -1
- package/dist/components/icon/icon.js +2 -2
- package/dist/components/icon-button/icon-button.js +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.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 +5 -5
- package/dist/components/linear-progress/linear-progress.js +2 -2
- package/dist/components/list/index.d.ts +1 -0
- package/dist/components/list/index.d.ts.map +1 -1
- package/dist/components/list/list-item.d.ts +28 -0
- package/dist/components/list/list-item.d.ts.map +1 -0
- package/dist/components/list/list-item.js +31 -0
- package/dist/components/list/list.d.ts +6 -11
- package/dist/components/list/list.d.ts.map +1 -1
- package/dist/components/list/list.js +9 -19
- package/dist/components/list/list.module.css +1 -1
- package/dist/components/masonry/masonry.d.ts.map +1 -1
- package/dist/components/masonry/masonry.js +3 -3
- package/dist/components/menu/menu-item/menu-item-checkbox.js +1 -1
- package/dist/components/menu/menu-item/menu-item.js +3 -3
- package/dist/components/menu/menu.d.ts +1 -1
- package/dist/components/menu/menu.js +1 -1
- package/dist/components/modal/content/modal-content.js +1 -1
- package/dist/components/modal/modal.js +1 -1
- package/dist/components/overlay-container/overlay-container.js +1 -1
- package/dist/components/overlay-container/overlay-context.js +1 -1
- package/dist/components/pagination/pagination.js +1 -1
- package/dist/components/popover/index.d.ts +4 -0
- package/dist/components/popover/index.d.ts.map +1 -0
- package/dist/components/popover/index.js +2 -0
- package/dist/components/popover/popover.d.ts +95 -0
- package/dist/components/popover/popover.d.ts.map +1 -0
- package/dist/components/popover/popover.js +93 -0
- package/dist/components/popover/popover.module.css +1 -0
- package/dist/components/prose/prose.js +1 -1
- package/dist/components/select/select.js +1 -1
- package/dist/components/select/select.module.css +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/selection-controls/toggle.js +1 -1
- package/dist/components/separator/separator.js +1 -1
- package/dist/components/skeleton/skeleton.js +3 -3
- package/dist/components/slider/slider.d.ts.map +1 -1
- package/dist/components/slider/slider.js +2 -2
- package/dist/components/slider/slider.module.css +1 -1
- package/dist/components/snackbar/snackbar.js +1 -1
- package/dist/components/spinner/spinner.js +1 -1
- package/dist/components/split-button/split-button.d.ts +2 -2
- package/dist/components/split-button/split-button.d.ts.map +1 -1
- package/dist/components/split-button/split-button.js +2 -2
- 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.d.ts.map +1 -1
- package/dist/components/star-meter/star-meter.js +10 -10
- package/dist/components/star-meter/star-meter.module.css +1 -1
- package/dist/components/tab/primitive-tab.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-list.js +1 -1
- package/dist/components/tab/tab-panel.js +1 -1
- package/dist/components/tab/tab.d.ts.map +1 -1
- package/dist/components/tab/tab.js +5 -6
- 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 +10 -21
- package/dist/components/table/table-cell/table-cell.module.css +1 -1
- package/dist/components/table/table-checkbox/table-checkbox.js +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 +4 -4
- package/dist/components/table/table-expand/table-expand.js +1 -1
- 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 +10 -10
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +67 -49
- package/dist/components/table/types.d.ts +9 -5
- package/dist/components/table/types.d.ts.map +1 -1
- package/dist/components/text/text.js +3 -3
- package/dist/components/text/text.module.css +1 -1
- package/dist/components/textfield/base-field/base-field.js +1 -1
- package/dist/components/textfield/base-field/base-field.module.css +1 -1
- package/dist/components/textfield/textfield.d.ts.map +1 -1
- package/dist/components/textfield/textfield.js +3 -3
- package/dist/components/title/title.js +3 -3
- package/dist/components/title/title.module.css +1 -1
- package/dist/components/toggle-button/toggle-button.js +2 -2
- package/dist/components/toggle-button/toggle-button.module.css +1 -1
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/components/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/tooltip/tooltip.js +6 -5
- package/dist/components/tooltip/tooltip.module.css +1 -1
- package/package.json +10 -11
- package/dist/components/dropdown/dropdown.d.ts +0 -59
- package/dist/components/dropdown/dropdown.d.ts.map +0 -1
- package/dist/components/dropdown/dropdown.js +0 -64
- package/dist/components/dropdown/dropdown.module.css +0 -1
- package/dist/components/dropdown/index.d.ts +0 -3
- package/dist/components/dropdown/index.d.ts.map +0 -1
- package/dist/components/dropdown/index.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
|
-
import { Button,
|
|
4
|
+
import { Button, Popover, Stack } from '../..';
|
|
5
5
|
import styles from './split-button.module.css';
|
|
6
6
|
export const SplitButton = forwardRef(({ className, label, icon = 'chevron-down', kind, dimension, fullWidth, disabled, busy, children, placement, offset, onClick, ...otherProps }, forwardedRef) => {
|
|
7
7
|
const commonProps = {
|
|
@@ -9,5 +9,5 @@ export const SplitButton = forwardRef(({ className, label, icon = 'chevron-down'
|
|
|
9
9
|
dimension,
|
|
10
10
|
disabled
|
|
11
11
|
};
|
|
12
|
-
return (_jsxs(Stack, { className: clsx(styles.SplitButton, className), direction: "row", inline: !fullWidth, children: [_jsx(Button, { busy: busy, fullWidth: fullWidth, onClick: onClick, ref: forwardedRef, ...commonProps, ...otherProps, children: label }
|
|
12
|
+
return (_jsxs(Stack, { className: clsx(styles.SplitButton, className), direction: "row", inline: !fullWidth, children: [_jsx(Button, { busy: busy, fullWidth: fullWidth, onClick: onClick, ref: forwardedRef, ...commonProps, ...otherProps, children: label }), _jsx(Popover, { placement: placement, offset: offset, disabled: disabled, trigger: _jsx(Button, { icon: icon, ...commonProps }), children: children })] }));
|
|
13
13
|
});
|
|
@@ -26,20 +26,20 @@ export declare type StackProps = {
|
|
|
26
26
|
* Set the vertical content placement instead of
|
|
27
27
|
* growing to fill the available space.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
vAlign?: string;
|
|
30
30
|
/**
|
|
31
31
|
* Set the horizontal content placement instead of
|
|
32
32
|
* growing to fill the available space.
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
hAlign?: string;
|
|
35
35
|
/**
|
|
36
36
|
* Set the horizontal padding (left/right)
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
hPadding?: TokensTypes['space'];
|
|
39
39
|
/**
|
|
40
40
|
* Set the vertical padding (top/bottom)
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
vPadding?: TokensTypes['space'];
|
|
43
43
|
/**
|
|
44
44
|
* Renderes children as rows or columns. The value can be one of the flex directions.
|
|
45
45
|
* More info: https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../../src/components/stack/stack.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAI1C,oBAAY,UAAU,GAAG;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9B;;OAEG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACjC;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../../src/components/stack/stack.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAI1C,oBAAY,UAAU,GAAG;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9B;;OAEG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACjC;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAChC;;OAEG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,aAAa,GAAG,gBAAgB,CAAC;CACjE,CAAA;AAED,aAAK,gBAAgB,GAAG,WAAW,CAAC,mBAAmB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AAE3E,eAAO,MAAM,KAAK,kBAgDI,CAAA"}
|
|
@@ -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 }));
|
|
22
22
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"star-meter.d.ts","sourceRoot":"","sources":["../../../src/components/star-meter/star-meter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,
|
|
1
|
+
{"version":3,"file":"star-meter.d.ts","sourceRoot":"","sources":["../../../src/components/star-meter/star-meter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAwB,MAAM,OAAO,CAAA;AAGnE,OAAO,EAAmB,KAAK,EAAQ,WAAW,EAAa,MAAM,cAAc,CAAA;AAInF,oBAAY,cAAc,GAAG;IAC3B;;;;;;;;;;;OAWG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;IACxC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAA;AAED,aAAK,oBAAoB,GAAG,WAAW,CAAC,mBAAmB,CACzD,WAAW,CAAC,gBAAgB,CAAC,OAAO,KAAK,CAAC,EAC1C,WAAW,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,GAAG,cAAc,CACpD,CAAC;AAEF,eAAO,MAAM,SAAS,sBA6GI,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from 'react';
|
|
2
|
+
import { forwardRef, useCallback, useMemo } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { useUIDSeed } from 'react-uid';
|
|
5
5
|
import { Text, Stack, Icon } from '../..';
|
|
6
6
|
import styles from './star-meter.module.css';
|
|
7
7
|
export const StarMeter = forwardRef(({ className, value = 0, starCount = 5, label, dimension = 'regular', hideLabel = false, ...otherProps }, forwardedRef) => {
|
|
8
8
|
const seedID = useUIDSeed();
|
|
9
|
-
const properties = {
|
|
9
|
+
const properties = useMemo(() => ({
|
|
10
10
|
small: {
|
|
11
11
|
labelSize: 14,
|
|
12
12
|
iconSize: 12
|
|
@@ -19,9 +19,9 @@ export const StarMeter = forwardRef(({ className, value = 0, starCount = 5, labe
|
|
|
19
19
|
labelSize: 18,
|
|
20
20
|
iconSize: 24
|
|
21
21
|
}
|
|
22
|
-
};
|
|
23
|
-
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
|
24
|
-
const roundValue = (value) => {
|
|
22
|
+
}), []);
|
|
23
|
+
const clamp = useMemo(() => (num, min, max) => Math.min(Math.max(num, min), max), []);
|
|
24
|
+
const roundValue = useCallback((value) => {
|
|
25
25
|
const integer = parseInt(String(value), 10);
|
|
26
26
|
const fraction = value - integer;
|
|
27
27
|
if (fraction >= 0.75) {
|
|
@@ -34,8 +34,8 @@ export const StarMeter = forwardRef(({ className, value = 0, starCount = 5, labe
|
|
|
34
34
|
return integer + 0.5;
|
|
35
35
|
}
|
|
36
36
|
return 0;
|
|
37
|
-
};
|
|
38
|
-
const starType = (maxStars, value) => {
|
|
37
|
+
}, []);
|
|
38
|
+
const starType = useCallback((maxStars, value) => {
|
|
39
39
|
const roundedValue = roundValue(value);
|
|
40
40
|
return new Array(maxStars).fill(0).map((_, index) => {
|
|
41
41
|
const starIndex = index + 1;
|
|
@@ -46,8 +46,8 @@ export const StarMeter = forwardRef(({ className, value = 0, starCount = 5, labe
|
|
|
46
46
|
if (roundedValue < starIndex && roundedValue > starIndex - 1) {
|
|
47
47
|
fillType = 'url(#HalfStar)';
|
|
48
48
|
}
|
|
49
|
-
return _jsx(Icon, { source: "star", weight: "solid", className: styles.Icon, dimension: properties[dimension].iconSize, fill: fillType }, starIndex);
|
|
49
|
+
return (_jsx(Icon, { source: "star", weight: "solid", className: styles.Icon, dimension: properties[dimension].iconSize, fill: fillType }, starIndex));
|
|
50
50
|
});
|
|
51
|
-
};
|
|
52
|
-
return (_jsxs(Stack, { inline: true, direction: "row",
|
|
51
|
+
}, [dimension, properties, roundValue]);
|
|
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)' } }), _jsx("stop", { offset: "50%", style: { stopColor: 'var(--star-color)' } }), _jsx("stop", { offset: "50.1%", style: { stopColor: 'var(--star-dimmed-color)' } }), _jsx("stop", { offset: "100%", style: { stopColor: 'var(--star-dimmed-color)' } })] }) }) }), _jsx(Stack, { direction: "row", columnGap: dimension === 'small' ? 2 : 4, children: starType(starCount, value) }), _jsx(Text, { dimmed: 6, id: seedID('star-meter'), size: properties[dimension].labelSize, weight: "bold", children: !hideLabel && _jsx(_Fragment, { children: label || value.toString() }) })] }));
|
|
53
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.StarMeter{--star-color:#f5a856;--star-dimmed-color:var(--dimmed-2);--icon-size:0.89rem;position:relative}.StarMeter[data-star-meter-dimension=small]{--icon-size:
|
|
1
|
+
.StarMeter{--star-color:#f5a856;--star-dimmed-color:var(--dimmed-2);--icon-size:0.89rem;position:relative}.StarMeter[data-star-meter-dimension=small]{--icon-size:token(--icon-size-14)}.StarMeter[data-star-meter-dimension=big]{--icon-size:1.33rem}.Gradient{clip:rect(0 0 0 0);block-size:1px;clip-path:inset(50%);inline-size:1px;overflow:hidden;position:absolute;white-space:nowrap}.Icon{block-size:var(--icon-size);inline-size:var(--icon-size)}
|
|
@@ -10,7 +10,7 @@ export const Tabs = ({ state: outerState, children }) => {
|
|
|
10
10
|
const innerState = useState(0);
|
|
11
11
|
const elements = useConstant(() => ({ tabs: [], panels: [] }));
|
|
12
12
|
const state = outerState || innerState;
|
|
13
|
-
return (_jsx(Elements.Provider, { value: elements, children: _jsx(TabsState.Provider, { value: state, children: children }
|
|
13
|
+
return (_jsx(Elements.Provider, { value: elements, children: _jsx(TabsState.Provider, { value: state, children: children }) }));
|
|
14
14
|
};
|
|
15
15
|
export const useTabState = (children) => {
|
|
16
16
|
const [activeIndex, setActive] = useContext(TabsState);
|
|
@@ -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;;qDA8DH,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 }), children, isActive && (_jsx(m.span, { transition: { type: 'spring', duration: 0.4, bounce: 0 }, className: styles.Highlight, layoutId: id }))] }) }));
|
|
22
23
|
});
|
|
23
24
|
TabItem.displayName = 'Tab.Item';
|
|
@@ -7,5 +7,5 @@ import styles from './tab.module.css';
|
|
|
7
7
|
* Tab.List
|
|
8
8
|
* Component
|
|
9
9
|
*/
|
|
10
|
-
export const TabList = forwardRef(({ children, className, ...otherProps }, forwardedRef) => (_jsx("div", { ref: forwardedRef, role: "tablist", tabIndex: -1, className: clsx(styles.TabList, className), ...otherProps, children: _jsx(RovingTabIndexProvider, { children: children }
|
|
10
|
+
export const TabList = forwardRef(({ children, className, ...otherProps }, forwardedRef) => (_jsx("div", { ref: forwardedRef, role: "tablist", tabIndex: -1, className: clsx(styles.TabList, className), ...otherProps, children: _jsx(RovingTabIndexProvider, { children: children }) })));
|
|
11
11
|
TabList.displayName = 'Tab.List';
|
|
@@ -10,7 +10,7 @@ import styles from './tab.module.css';
|
|
|
10
10
|
export const TabPanel = forwardRef(({ children, className, ...otherProps }, forwardedRef) => {
|
|
11
11
|
const isActive = usePanelState(children);
|
|
12
12
|
return isActive
|
|
13
|
-
? (_jsx("div", { ref: forwardedRef, tabIndex: 0, className: clsx(styles.TabPanel, className), ...otherProps, children: children }
|
|
13
|
+
? (_jsx("div", { ref: forwardedRef, tabIndex: 0, className: clsx(styles.TabPanel, className), ...otherProps, children: children }))
|
|
14
14
|
: null;
|
|
15
15
|
});
|
|
16
16
|
TabPanel.displayName = 'Tab.Panel';
|
|
@@ -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,10 +21,10 @@ 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(
|
|
28
|
-
}))] }
|
|
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 }))) }), Children.map(children, (child, index) => isValidElement(child) && cloneElement(child, {
|
|
25
|
+
id: seedID('tab-panel'),
|
|
26
|
+
'aria-labelledby': seedID('tab-item')
|
|
27
|
+
}))] }) }));
|
|
29
28
|
});
|
|
30
29
|
Tab.displayName = 'Tab';
|
|
31
30
|
/* -------------------------------------------------------------------------- */
|
|
@@ -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,29 +1,18 @@
|
|
|
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'
|
|
28
|
-
}, ...otherProps, children: [children, isSorted && (_jsx(Icon, { dimension: 12, className: styles.HeadCellIcon, fill: "var(--highlight-red-foreground)", source: isSortedDesc ? 'bars-sort-down' : 'bars-sort-up' }
|
|
17
|
+
}, ...otherProps, children: [children, isSorted && (_jsx(Icon, { dimension: 12, className: styles.HeadCellIcon, fill: "var(--highlight-red-foreground)", source: isSortedDesc ? 'bars-sort-down' : 'bars-sort-up' }))] }));
|
|
29
18
|
});
|
|
@@ -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,4 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Checkbox } from '../../..';
|
|
3
3
|
import styles from './table-checkbox.module.css';
|
|
4
|
-
export const TableCheckbox = ({ ...otherProps }) => (_jsx(Checkbox, { className: styles.TableCheckbox, dimension: "small", ...otherProps }
|
|
4
|
+
export const TableCheckbox = ({ ...otherProps }) => (_jsx(Checkbox, { className: styles.TableCheckbox, dimension: "small", ...otherProps }));
|
|
@@ -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, Popover } 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
|
-
return (_jsx(
|
|
22
|
+
return (_jsx(Popover, { placement: "bottom-start", trigger: _jsx(Button, { kind: "secondary", children: "Toggle columns" }), children: _jsxs(Menu, { children: [_jsx(Menu.ItemCheckbox, { onClick: () => handleToggleAll(), checked: true, icon: visibleColumns.length === 0 ? 'check' : 'minus', children: "Toggle All" }), 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)))] }) }));
|
|
23
23
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import styles from './table-expand.module.css';
|
|
3
|
-
export const TableExpand = ({ data, component: Component }) => (_jsx("div", { className: styles.TableExpand, children: _jsx("div", { className: styles.ExpandContent, children: Component ? _jsx(Component, { ...data }
|
|
3
|
+
export const TableExpand = ({ data, component: Component }) => (_jsx("div", { className: styles.TableExpand, children: _jsx("div", { className: styles.ExpandContent, children: Component ? _jsx(Component, { ...data }) : null }) }));
|
|
@@ -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 }) : title }), _jsx(Stack, { direction: "row", vAlign: "center", columnGap: 8, inline: true, children: children })] }));
|
|
@@ -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:" }), _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))) })] }), _jsx(Text, { "aria-hidden": "true", weight: "bold", size: 14, children: `${computedItemsInPageStart + 1}-${computedItemsInPageEnd > totalItems ? totalItems : computedItemsInPageEnd} of ${totalItems}` }), _jsx(Pagination, { itemsCount: totalItems, itemsPerPage: pageSize, pageCount: computedPageCount, onPageClick: ({ selected }) => onPageClick?.(selected), renderOnZeroPageCount: () => null, forcePage: currentPage })] }));
|
|
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 }));
|
|
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,14 +33,14 @@ 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
|
*/
|
|
40
40
|
totalRows?: number;
|
|
41
41
|
/**
|
|
42
42
|
* Set clusters of items to show in a single page. These values are used to
|
|
43
|
-
* compute the select options for the page size
|
|
43
|
+
* compute the select options for the page size select.
|
|
44
44
|
*/
|
|
45
45
|
pageClusters?: TablePaginationProps['clusters'];
|
|
46
46
|
/**
|
|
@@ -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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"}
|