@wonderflow/react-components 5.4.0 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/components/menu/menu-item/menu-item.module.css +1 -1
  2. package/dist/components/selection-controls/checkbox.d.ts.map +1 -1
  3. package/dist/components/selection-controls/checkbox.js +8 -2
  4. package/dist/components/selection-controls/selection-controls.module.css +1 -1
  5. package/dist/components/skeleton/skeleton.d.ts +5 -1
  6. package/dist/components/skeleton/skeleton.d.ts.map +1 -1
  7. package/dist/components/skeleton/skeleton.js +4 -6
  8. package/dist/components/skeleton/skeleton.module.css +1 -1
  9. package/dist/components/table/index.d.ts +0 -1
  10. package/dist/components/table/index.d.ts.map +1 -1
  11. package/dist/components/table/table-cell/index.d.ts +2 -0
  12. package/dist/components/table/table-cell/index.d.ts.map +1 -0
  13. package/dist/components/table/table-cell/index.js +1 -0
  14. package/dist/components/table/table-cell/table-cell.d.ts +18 -0
  15. package/dist/components/table/table-cell/table-cell.d.ts.map +1 -0
  16. package/dist/components/table/table-cell/table-cell.js +29 -0
  17. package/dist/components/table/table-cell/table-cell.module.css +1 -0
  18. package/dist/components/table/table-checkbox/index.d.ts +2 -0
  19. package/dist/components/table/table-checkbox/index.d.ts.map +1 -0
  20. package/dist/components/table/table-checkbox/index.js +1 -0
  21. package/dist/components/table/table-checkbox/table-checkbox.d.ts +5 -0
  22. package/dist/components/table/table-checkbox/table-checkbox.d.ts.map +1 -0
  23. package/dist/components/table/table-checkbox/table-checkbox.js +4 -0
  24. package/dist/components/table/table-checkbox/table-checkbox.module.css +1 -0
  25. package/dist/components/table/table-controls/index.d.ts +2 -0
  26. package/dist/components/table/table-controls/index.d.ts.map +1 -0
  27. package/dist/components/table/table-controls/index.js +1 -0
  28. package/dist/components/table/table-controls/toggle-columns.d.ts +9 -0
  29. package/dist/components/table/table-controls/toggle-columns.d.ts.map +1 -0
  30. package/dist/components/table/table-controls/toggle-columns.js +23 -0
  31. package/dist/components/table/table-expand/index.d.ts +3 -0
  32. package/dist/components/table/table-expand/index.d.ts.map +1 -0
  33. package/dist/components/table/table-expand/index.js +1 -0
  34. package/dist/components/table/table-expand/table-expand.d.ts +7 -0
  35. package/dist/components/table/table-expand/table-expand.d.ts.map +1 -0
  36. package/dist/components/table/table-expand/table-expand.js +3 -0
  37. package/dist/components/table/table-expand/table-expand.module.css +1 -0
  38. package/dist/components/table/table-header/index.d.ts +3 -0
  39. package/dist/components/table/table-header/index.d.ts.map +1 -0
  40. package/dist/components/table/table-header/index.js +1 -0
  41. package/dist/components/table/table-header/table-header.d.ts +7 -0
  42. package/dist/components/table/table-header/table-header.d.ts.map +1 -0
  43. package/dist/components/table/table-header/table-header.js +4 -0
  44. package/dist/components/table/table-header/table-header.module.css +1 -0
  45. package/dist/components/table/table-pagination/index.d.ts +3 -0
  46. package/dist/components/table/table-pagination/index.d.ts.map +1 -0
  47. package/dist/components/table/table-pagination/index.js +1 -0
  48. package/dist/components/table/table-pagination/table-pagination.d.ts +13 -0
  49. package/dist/components/table/table-pagination/table-pagination.d.ts.map +1 -0
  50. package/dist/components/table/table-pagination/table-pagination.js +11 -0
  51. package/dist/components/table/table-row/index.d.ts +2 -0
  52. package/dist/components/table/table-row/index.d.ts.map +1 -0
  53. package/dist/components/table/table-row/index.js +1 -0
  54. package/dist/components/table/table-row/table-row.d.ts +5 -0
  55. package/dist/components/table/table-row/table-row.d.ts.map +1 -0
  56. package/dist/components/table/table-row/table-row.js +6 -0
  57. package/dist/components/table/table-row/table-row.module.css +1 -0
  58. package/dist/components/table/table.d.ts +127 -15
  59. package/dist/components/table/table.d.ts.map +1 -1
  60. package/dist/components/table/table.js +114 -15
  61. package/dist/components/table/table.module.css +1 -1
  62. package/dist/components/table/types.d.ts +21 -0
  63. package/dist/components/table/types.d.ts.map +1 -0
  64. package/dist/components/table/types.js +1 -0
  65. package/package.json +13 -12
  66. package/dist/components/table/theme.d.ts +0 -3
  67. package/dist/components/table/theme.d.ts.map +0 -1
  68. package/dist/components/table/theme.js +0 -78
@@ -1 +1 @@
1
- .MenuItem{background:none;border:0;box-sizing:border-box;color:var(--dimmed-6);cursor:pointer;font:inherit;font-size:.89rem;font-weight:600;inline-size:100%;padding:0;position:relative;text-align:start}.MenuItem:hover{color:var(--global-foreground)}.MenuItem[aria-checked=true]{color:var(--global-interactive-text)}.MenuItem:before{border-radius:.22rem;bottom:0;content:"";left:.44rem;opacity:.6;position:absolute;right:.44rem;top:0;z-index:0}.MenuItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.MenuItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.MenuItem[data-menu-item-dimension=small]{font-size:.78rem}.MenuItem>*{position:relative}.MenuItem[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}.MenuItem [data-menu-item-padding=true][data-menu-item-has-icon=false][data-menu-item-icon-right=false]{padding-left:2.22rem}.MenuItem [data-menu-item-padding=true][data-menu-item-has-icon=false][data-menu-item-icon-right=true]{padding-right:2.22rem}.ItemContent{position:relative}.DecorationContent{flex-grow:1}.Icon{align-self:flex-start;flex-grow:0;flex-shrink:0;margin-top:4px}
1
+ .MenuItem{--padding:2.22rem;background:none;border:0;box-sizing:border-box;color:var(--dimmed-6);cursor:pointer;font:inherit;font-size:.89rem;font-weight:600;inline-size:100%;padding:0;position:relative;text-align:start}.MenuItem:hover{color:var(--global-foreground)}.MenuItem[aria-checked=true]{color:var(--global-interactive-text)}.MenuItem:before{border-radius:.22rem;bottom:0;content:"";left:.44rem;opacity:.6;position:absolute;right:.44rem;top:0;z-index:0}.MenuItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.MenuItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.MenuItem[data-menu-item-dimension=small]{--padding:2rem;font-size:.78rem}.MenuItem>*{position:relative}.MenuItem[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}.MenuItem [data-menu-item-padding=true][data-menu-item-has-icon=false][data-menu-item-icon-right=false]{padding-left:var(--padding)}.MenuItem [data-menu-item-padding=true][data-menu-item-has-icon=false][data-menu-item-icon-right=true]{padding-right:var(--padding)}.ItemContent{position:relative}.DecorationContent{flex-grow:1}.Icon{align-self:flex-start;flex-grow:0;flex-shrink:0;margin-top:4px}
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/checkbox.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAc,mBAAmB,EAAE,MAAM,OAAO,CAAA;AAGpE,oBAAY,aAAa,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAClE;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;CACvD,CAAA;AAED,eAAO,MAAM,QAAQ;IApBnB;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;;OAGG;qBACc,YAAY,gBAAgB,CAAC,GAAG,IAAI;oDAwBrD,CAAA"}
1
+ {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/checkbox.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAc,mBAAmB,EAAqB,MAAM,OAAO,CAAA;AAGvF,oBAAY,aAAa,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAClE;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;CACvD,CAAA;AAED,eAAO,MAAM,QAAQ;IApBnB;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;;OAGG;qBACc,YAAY,gBAAgB,CAAC,GAAG,IAAI;oDA+BrD,CAAA"}
@@ -1,8 +1,14 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import clsx from 'clsx';
3
- import { forwardRef } from 'react';
3
+ import { forwardRef, useEffect, useRef } from 'react';
4
4
  import styles from './selection-controls.module.css';
5
5
  export const Checkbox = forwardRef(({ className, disabled, dimension = 'regular', onChange, indeterminate, ...otherProps }, forwardedRef) => {
6
- return (_jsx("input", { type: "checkbox", disabled: disabled, "aria-disabled": disabled, "data-control-dimension": dimension, "data-control-indeterminate": indeterminate, onChange: onChange, className: clsx(styles.Checkbox, className), ref: forwardedRef, ...otherProps }, void 0));
6
+ const ref = useRef(forwardedRef);
7
+ useEffect(() => {
8
+ if (ref.current) {
9
+ ref.current.indeterminate = indeterminate;
10
+ }
11
+ }, [indeterminate]);
12
+ return (_jsx("input", { type: "checkbox", disabled: disabled, "aria-disabled": disabled, "data-control-dimension": dimension, onChange: onChange, className: clsx(styles.Checkbox, className), ref: ref, ...otherProps }, void 0));
7
13
  });
8
14
  Checkbox.displayName = 'Checkbox';
@@ -1 +1 @@
1
- .Checkbox{--w:24px;--h:24px;-webkit-appearance:none;appearance:none;-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);block-size:var(--h);border-radius:.22rem;color:var(--global-background);inline-size:var(--w);max-block-size:var(--h);max-inline-size:var(--w);position:relative}.Checkbox:after{block-size:27%;border-bottom:2px solid;border-left:2px solid;content:"";display:none;inline-size:50%;left:50%;position:absolute;top:50%;transform:translate(-50%,-80%) rotate(-45deg)}.Checkbox:active{background-color:var(--global-vibrancy-background-hard)}.Checkbox:checked,.Checkbox[data-control-indeterminate=true]{background:var(--dimmed-7)}.Checkbox:checked:after,.Checkbox[data-control-indeterminate=true]:after{display:block}.Checkbox:disabled{background-color:var(--global-disabled-background);color:var(--global-disabled-foreground);cursor:not-allowed}.Checkbox[data-control-dimension=small]{--w:16px;--h:16px}.Checkbox[data-control-indeterminate=true]:after{block-size:2px;border-left:0;transform:translate(-50%,-50%)}.Radio{composes:Checkbox;border-radius:100%}.Radio:after{background-color:currentColor;block-size:50%;border:0;border-radius:100%;inline-size:50%;transform:translate(-50%,-50%)}.Toggle{--w:44px;--h:24px;--p:2px;composes:Radio;border-radius:200px;color:var(--dimmed-7)}.Toggle:checked{color:var(--global-background)}.Toggle:disabled{color:var(--global-disabled-foreground)}.Toggle:after{block-size:calc(var(--h) - var(--p)*2);bottom:var(--p);display:block;inline-size:calc(var(--h) - var(--p)*2);left:var(--p);top:var(--p);transform:none;transition:transform .1s cubic-bezier(.3,.07,.34,1),background-color .1s cubic-bezier(.3,.07,.34,1)}.Toggle:checked:after{display:block;transform:translateX(100%)}.Toggle[data-control-dimension=small]{--w:28px;--h:16px}
1
+ .Checkbox{--w:24px;--h:24px;-webkit-appearance:none;appearance:none;-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);block-size:var(--h);border-radius:.22rem;color:var(--global-background);inline-size:var(--w);max-block-size:var(--h);max-inline-size:var(--w);position:relative}.Checkbox:after{block-size:27%;border-bottom:2px solid;border-left:2px solid;content:"";display:none;inline-size:50%;left:50%;position:absolute;top:50%;transform:translate(-50%,-80%) rotate(-45deg)}.Checkbox:active{background-color:var(--global-vibrancy-background-hard)}.Checkbox:checked,.Checkbox:indeterminate{background:var(--dimmed-7)}.Checkbox:checked:after,.Checkbox:indeterminate:after{display:block}.Checkbox:disabled{background-color:var(--global-disabled-background);color:var(--global-disabled-foreground);cursor:not-allowed}.Checkbox[data-control-dimension=small]{--w:16px;--h:16px}.Checkbox:indeterminate:after{block-size:2px;border-left:0;transform:translate(-50%,-50%)}.Radio{composes:Checkbox;border-radius:100%}.Radio:after{background-color:currentcolor;block-size:50%;border:0;border-radius:100%;inline-size:50%;transform:translate(-50%,-50%)}.Toggle{--w:44px;--h:24px;--p:2px;composes:Radio;border-radius:200px;color:var(--dimmed-7)}.Toggle:checked{color:var(--global-background)}.Toggle:disabled{color:var(--global-disabled-foreground)}.Toggle:after{block-size:calc(var(--h) - var(--p)*2);bottom:var(--p);display:block;inline-size:calc(var(--h) - var(--p)*2);left:var(--p);top:var(--p);transform:none;transition:transform .1s cubic-bezier(.3,.07,.34,1),background-color .1s cubic-bezier(.3,.07,.34,1)}.Toggle:checked:after{display:block;transform:translateX(100%)}.Toggle[data-control-dimension=small]{--w:28px;--h:16px}
@@ -32,6 +32,10 @@ export declare type SkeletonProps = PropsWithClass & {
32
32
  * Enable the shim animation and the announcement of the loading state.
33
33
  */
34
34
  enableAnimation?: boolean;
35
+ /**
36
+ * Set the gap between stacked skeleton items.
37
+ */
38
+ gap?: TokensTypes['space'];
35
39
  };
36
- export declare const Skeleton: ({ className, borderRadius, style, width, height, count, enableAnimation, inline, circle, ...otherProps }: SkeletonProps) => JSX.Element;
40
+ export declare const Skeleton: ({ className, borderRadius, style, width, height, count, gap, enableAnimation, inline, circle, ...otherProps }: SkeletonProps) => JSX.Element;
37
41
  //# sourceMappingURL=skeleton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"skeleton.d.ts","sourceRoot":"","sources":["../../../src/components/skeleton/skeleton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAM9D,oBAAY,aAAa,GAAG,cAAc,GAAG;IAC3C;;;OAGG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrC;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAA;AAED,eAAO,MAAM,QAAQ,6GAWlB,aAAa,gBA+Cf,CAAA"}
1
+ {"version":3,"file":"skeleton.d.ts","sourceRoot":"","sources":["../../../src/components/skeleton/skeleton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAM9D,oBAAY,aAAa,GAAG,cAAc,GAAG;IAC3C;;;OAGG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrC;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,GAAG,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CAC5B,CAAA;AAED,eAAO,MAAM,QAAQ,kHAYlB,aAAa,gBA6Cf,CAAA"}
@@ -3,7 +3,7 @@ import tkns from '@wonderflow/tokens/platforms/web/tokens.json';
3
3
  import { Fragment, useCallback } from 'react';
4
4
  import { useUIDSeed } from 'react-uid';
5
5
  import styles from './skeleton.module.css';
6
- export const Skeleton = ({ className, borderRadius = 4, style, width, height, count = 1, enableAnimation = true, inline, circle, ...otherProps }) => {
6
+ export const Skeleton = ({ className, borderRadius = 4, style, width, height, count = 1, gap, enableAnimation = true, inline, circle, ...otherProps }) => {
7
7
  const uid = useUIDSeed();
8
8
  const computedWidth = typeof width === 'number' ? `${width}px` : width;
9
9
  const computedHeight = typeof height === 'number' ? `${height}px` : height;
@@ -11,13 +11,11 @@ export const Skeleton = ({ className, borderRadius = 4, style, width, height, co
11
11
  const dynamicStyle = {
12
12
  '--radius': borderRadius && tkns.radius[borderRadius],
13
13
  '--width': width && computedWidth,
14
- '--height': height && computedHeight
14
+ '--height': height && computedHeight,
15
+ '--gap': gap ? tkns.space[gap] : undefined
15
16
  };
16
17
  return (_jsx("span", { className: styles.SkeletonItem, "data-skeleton-circle": circle, "data-skeleton-animated": enableAnimation, style: { ...dynamicStyle, ...style }, children: "\u200C" }, void 0));
17
- }, [
18
- borderRadius, width, computedWidth, height,
19
- computedHeight, circle, style, enableAnimation
20
- ]);
18
+ }, [borderRadius, width, computedWidth, height, computedHeight, gap, circle, enableAnimation, style]);
21
19
  return (_jsx("span", { className: className, "aria-live": "polite", "aria-busy": enableAnimation, ...otherProps, children: Array.from({ length: count }).map((_, i) => {
22
20
  return inline
23
21
  ? _jsx(SkeletonItem, {}, uid(i))
@@ -1 +1 @@
1
- .SkeletonItem{--base-color:var(--dimmed-1);--highlight-color:var(--dimmed-0);--animation-duration:1.5s;--animation-direction:normal;background-color:var(--base-color);border-radius:var(--radius,1.78rem);display:inline-flex;height:var(--height);line-height:1;overflow:hidden;position:relative;width:var(--width,100%);z-index:1}.SkeletonItem:after{background-image:linear-gradient(to right,var(--base-color),var(--highlight-color),var(--base-color));background-repeat:no-repeat;content:" ";display:block;height:100%;left:0;position:absolute;right:0;transform:translateX(-100%)}.SkeletonItem[data-skeleton-animated=true]:after{animation-direction:normal;animation-duration:1.5s;animation-iteration-count:infinite;animation-name:skeleton-shimmer;animation-timing-function:ease-in-out}.SkeletonItem[data-skeleton-circle=true]{border-radius:100%}@keyframes skeleton-shimmer{to{transform:translateX(100%)}}
1
+ .SkeletonItem{--base-color:var(--dimmed-1);--highlight-color:var(--dimmed-0);--animation-duration:1.5s;--animation-direction:normal;background-color:var(--base-color);border-radius:var(--radius,1.78rem);display:inline-flex;height:var(--height);line-height:1;overflow:hidden;position:relative;width:var(--width,100%);z-index:1}.SkeletonItem+br+.SkeletonItem{margin-top:var(--gap,0)}.SkeletonItem:after{background-image:linear-gradient(to right,var(--base-color),var(--highlight-color),var(--base-color));background-repeat:no-repeat;content:" ";display:block;height:100%;left:0;position:absolute;right:0;transform:translateX(-100%)}.SkeletonItem[data-skeleton-animated=true]:after{animation-direction:normal;animation-duration:1.5s;animation-iteration-count:infinite;animation-name:skeleton-shimmer;animation-timing-function:ease-in-out}.SkeletonItem[data-skeleton-circle=true]{border-radius:100%}@keyframes skeleton-shimmer{to{transform:translateX(100%)}}
@@ -1,4 +1,3 @@
1
1
  export { Table } from './table';
2
2
  export type { TableProps } from './table';
3
- export type { TableColumn, TableRow, TableStyles, Theme, Themes, ConditionalStyles, ExpanderComponentProps, PaginationComponentProps, PaginationOptions, PaginationServerOptions, ContextMessage, SortOrder } from 'react-data-table-component';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,YAAY,EACV,WAAW,EAAE,QAAQ,EAAE,WAAW,EAClC,KAAK,EAAE,MAAM,EACb,iBAAiB,EAAE,sBAAsB,EACzC,wBAAwB,EACxB,iBAAiB,EAAE,uBAAuB,EAC1C,cAAc,EACd,SAAS,EACV,MAAM,4BAA4B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { TableCell } from './table-cell';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-cell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1 @@
1
+ export { TableCell } from './table-cell';
@@ -0,0 +1,18 @@
1
+ import { Polymorphic } from '../../..';
2
+ import { OptionalColumnTypes } from '../types';
3
+ declare type TableCellProps = PropsWithClass & {
4
+ collapsed?: OptionalColumnTypes['isCollapsed'];
5
+ isSorted?: boolean;
6
+ isSortedDesc?: boolean;
7
+ align?: OptionalColumnTypes['align'];
8
+ padding?: boolean;
9
+ depth?: number;
10
+ isExpander?: boolean;
11
+ expanded?: boolean;
12
+ hasSubrows?: boolean;
13
+ width?: string | number;
14
+ };
15
+ declare type PolymorphicCell = Polymorphic.ForwardRefComponent<'td', TableCellProps>;
16
+ export declare const TableCell: PolymorphicCell;
17
+ export {};
18
+ //# sourceMappingURL=table-cell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-cell.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-cell/table-cell.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAQ,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,CAAA;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,KAAK,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACxB,CAAA;AAED,aAAK,eAAe,GAAG,WAAW,CAAC,mBAAmB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;AAE7E,eAAO,MAAM,SAAS,iBAgED,CAAA"}
@@ -0,0 +1,29 @@
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
+ import clsx from 'clsx';
6
+ import tkns from '@wonderflow/tokens/platforms/web/tokens.json';
7
+ export const TableCell = forwardRef(({ children, className, collapsed, isSorted, align = 'start', style, isSortedDesc, as: Wrapper = 'td', padding = true, isExpander, expanded, depth = 0, hasSubrows, width, ...otherProps }, forwardedRef) => {
8
+ const colors = [
9
+ 'var(--highlight-gray-background)',
10
+ `hsl(${tkns.color.blue[30]})`,
11
+ `hsl(${tkns.color.green[30]})`,
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]);
18
+ const dynamicStyle = {
19
+ '--width': typeof width === 'string' ? width : typeof width === 'number' ? `${width}px` : undefined,
20
+ '--text-align': align,
21
+ '--line-current-color': depth ? colors[currentIndex] : undefined,
22
+ '--line-next-color': depth ? colors[nextIndex] : colors[0]
23
+ };
24
+ return (_jsxs(Wrapper, { ref: forwardedRef, className: clsx(styles.TableCell, className), "data-table-cell-collapsed": collapsed, "data-table-cell-padding": padding, "data-table-cell-is-expander": isExpander && (depth > 0 || hasSubrows), "data-table-cell-expanded": expanded, "data-table-cell-has-subrows": hasSubrows, "data-table-cell-fixed": Boolean(width), style: {
25
+ ...dynamicStyle,
26
+ ...style,
27
+ 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' }, void 0))] }, void 0));
29
+ });
@@ -0,0 +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}.TableCell[data-table-cell-is-expander=true] button{box-shadow:inset 0 0 0 2px var(--line-current-color);z-index:1}.TableCell[data-table-cell-is-expander=true] button:hover{box-shadow:inset 0 0 0 3px var(--line-current-color)}.TableCell[data-table-cell-is-expander=true]:after,.TableCell[data-table-cell-is-expander=true]:before{background:var(--line-current-color);content:"";height:calc(50% + 1px);left:50%;position:absolute;transform:translateX(-50%);width:var(--indent-guide-width)}.TableCell[data-table-cell-is-expander=true]:before{top:-1px}.TableCell[data-table-cell-is-expander=true]:after{bottom:-1px;z-index:0}.TableCell[data-table-cell-is-expander=true][data-table-cell-expanded=true][data-table-cell-has-subrows=true]:after{background:var(--line-next-color)}.HeadCellIcon{margin-inline-start:.44rem}
@@ -0,0 +1,2 @@
1
+ export { TableCheckbox } from './table-checkbox';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-checkbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1 @@
1
+ export { TableCheckbox } from './table-checkbox';
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export declare const TableCheckbox: ({ ...otherProps }: {
3
+ [x: string]: any;
4
+ }) => JSX.Element;
5
+ //# sourceMappingURL=table-checkbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-checkbox.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-checkbox/table-checkbox.tsx"],"names":[],"mappings":";AAGA,eAAO,MAAM,aAAa;;iBAMzB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Checkbox } from '../../..';
3
+ import styles from './table-checkbox.module.css';
4
+ export const TableCheckbox = ({ ...otherProps }) => (_jsx(Checkbox, { className: styles.TableCheckbox, dimension: "small", ...otherProps }, void 0));
@@ -0,0 +1 @@
1
+ .TableCheckbox{display:block}
@@ -0,0 +1,2 @@
1
+ export { ToggleColumnsControl } from './toggle-columns';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-controls/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1 @@
1
+ export { ToggleColumnsControl } from './toggle-columns';
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { CustomColumnInstanceType } from '../types';
3
+ declare type ToggleColumnsControlProps = {
4
+ columns: CustomColumnInstanceType[];
5
+ visibleColumns: CustomColumnInstanceType[];
6
+ };
7
+ export declare const ToggleColumnsControl: ({ columns, visibleColumns }: ToggleColumnsControlProps) => JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=toggle-columns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggle-columns.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-controls/toggle-columns.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAEnD,aAAK,yBAAyB,GAAG;IAC/B,OAAO,EAAE,wBAAwB,EAAE,CAAA;IACnC,cAAc,EAAE,wBAAwB,EAAE,CAAA;CAC3C,CAAA;AAED,eAAO,MAAM,oBAAoB,gCAG9B,yBAAyB,gBAkD3B,CAAA"}
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Dropdown, Menu, Button } from '../../..';
3
+ import { useCallback, useMemo } from 'react';
4
+ export const ToggleColumnsControl = ({ columns, visibleColumns }) => {
5
+ const someVisibleColums = useMemo(() => visibleColumns.length !== 0, [visibleColumns]);
6
+ const filteredColumns = useMemo(() => columns.filter(col => !col.hideFromList), [columns]);
7
+ const handleToggleAll = useCallback(() => {
8
+ /**
9
+ * If there are visible columns (excluding artificial ones),
10
+ * hide them all by calling `toggleHidden(true)` for each column
11
+ */
12
+ if (someVisibleColums) {
13
+ visibleColumns.forEach((col) => col.toggleHidden(true));
14
+ return;
15
+ }
16
+ /**
17
+ * If there are no visible columns (excluding artificial ones), call
18
+ * toggleHidden(false) for each column
19
+ */
20
+ filteredColumns.forEach((col) => col.toggleHidden(false));
21
+ }, [someVisibleColums, filteredColumns, visibleColumns]);
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
+ };
@@ -0,0 +1,3 @@
1
+ export { TableExpand } from './table-expand';
2
+ export type { TableExpandProps } from './table-expand';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-expand/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1 @@
1
+ export { TableExpand } from './table-expand';
@@ -0,0 +1,7 @@
1
+ import { ComponentType } from 'react';
2
+ export declare type TableExpandProps<T> = {
3
+ data: T;
4
+ component: ComponentType<T>;
5
+ };
6
+ export declare const TableExpand: <T>({ data, component: Component }: TableExpandProps<T>) => JSX.Element;
7
+ //# sourceMappingURL=table-expand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-expand.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-expand/table-expand.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAGrC,oBAAY,gBAAgB,CAAC,CAAC,IAAI;IAChC,IAAI,EAAE,CAAC,CAAC;IACR,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,WAAW,yEASrB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
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 }, void 0) : null }, void 0) }, void 0));
@@ -0,0 +1 @@
1
+ .TableExpand{overflow:hidden}.ExpandContent{--fade-from-y:-5px;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}}
@@ -0,0 +1,3 @@
1
+ export { TableHeader } from './table-header';
2
+ export type { TableHeaderProps } from './table-header';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-header/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1 @@
1
+ export { TableHeader } from './table-header';
@@ -0,0 +1,7 @@
1
+ import { Title, Polymorphic } from '../../..';
2
+ import { FC, HTMLAttributes } from 'react';
3
+ export declare type TableHeaderProps = HTMLAttributes<HTMLElement> & {
4
+ title?: string | Polymorphic.IntrinsicElement<typeof Title>;
5
+ };
6
+ export declare const TableHeader: FC<TableHeaderProps>;
7
+ //# sourceMappingURL=table-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-header.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-header/table-header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAS,WAAW,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAG1C,oBAAY,gBAAgB,GAAG,cAAc,CAAC,WAAW,CAAC,GAAG;IAC3D,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,gBAAgB,CAAC,OAAO,KAAK,CAAC,CAAA;CAC5D,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAuB5C,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Title, Stack } from '../../..';
3
+ import styles from './table-header.module.css';
4
+ export const TableHeader = ({ children, title, id, ...otherProps }) => (_jsxs(Stack, { direction: "row", columnGap: 32, verticalAlign: "center", horizontalAlign: "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", verticalAlign: "center", columnGap: 8, inline: true, children: children }, void 0)] }, void 0));
@@ -0,0 +1 @@
1
+ .TableHeader{min-block-size:3.11rem;position:relative;z-index:3}
@@ -0,0 +1,3 @@
1
+ export { TablePagination } from './table-pagination';
2
+ export type { TablePaginationProps } from './table-pagination';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-pagination/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA"}
@@ -0,0 +1 @@
1
+ export { TablePagination } from './table-pagination';
@@ -0,0 +1,13 @@
1
+ import { FC } from 'react';
2
+ export declare type TablePaginationProps = PropsWithClass & {
3
+ clusters?: Array<number>;
4
+ pageSize: number;
5
+ totalItems: number;
6
+ totalPages: number;
7
+ currentPage: number;
8
+ onPageSizeChange?: (pageSize: number) => void;
9
+ onPageClick?: (page: number) => void;
10
+ isManual?: boolean;
11
+ };
12
+ export declare const TablePagination: FC<TablePaginationProps>;
13
+ //# sourceMappingURL=table-pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-pagination.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-pagination/table-pagination.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAW,MAAM,OAAO,CAAA;AAGnC,oBAAY,oBAAoB,GAAG,cAAc,GAAG;IAClD,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7C,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAqDpD,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Select, Stack, Text, Pagination } from '../../..';
3
+ import { useMemo } from 'react';
4
+ import { useUIDSeed } from 'react-uid';
5
+ export const TablePagination = ({ children, pageSize, onPageSizeChange, clusters = [5, 10, 20, 30, 50, 100], totalItems, currentPage, isManual, totalPages, onPageClick, ...otherProps }) => {
6
+ const uid = useUIDSeed();
7
+ const computedPageCount = useMemo(() => isManual ? Math.ceil(totalItems / pageSize) : totalPages, [isManual, pageSize, totalItems, totalPages]);
8
+ const computedItemsInPageStart = useMemo(() => (currentPage && pageSize) && currentPage * pageSize, [currentPage, pageSize]);
9
+ const computedItemsInPageEnd = useMemo(() => currentPage * pageSize + pageSize, [currentPage, pageSize]);
10
+ return (_jsxs(Stack, { fill: false, direction: "row", columnGap: 16, verticalAlign: "center", horizontalAlign: "end", verticalPadding: 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 }) => { onPageSizeChange && onPageSizeChange(Number(currentTarget.value)); }, 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 && onPageClick(selected), renderOnZeroPageCount: () => null, forcePage: currentPage }, void 0)] }, void 0));
11
+ };
@@ -0,0 +1,2 @@
1
+ export { TableRow } from './table-row';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-row/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA"}
@@ -0,0 +1 @@
1
+ export { TableRow } from './table-row';
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ declare type TableRowProps = PropsWithClass;
3
+ export declare const TableRow: FC<TableRowProps>;
4
+ export {};
5
+ //# sourceMappingURL=table-row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-row.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-row/table-row.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAG1B,aAAK,aAAa,GAAG,cAAc,CAAA;AAEnC,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAatC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import styles from './table-row.module.css';
3
+ import clsx from 'clsx';
4
+ export const TableRow = ({ children, className, ...otherProps }) => {
5
+ return (_jsx("tr", { className: clsx(styles.TableRow, className), ...otherProps, children: children }, void 0));
6
+ };
@@ -0,0 +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,26 +1,138 @@
1
- import { FC } from 'react';
2
- import { TableProps as ReactTableProps } from 'react-data-table-component';
3
- import { IconProps } from '../..';
4
- export declare type TableProps<T> = ReactTableProps<T> & {
1
+ import { Row, IdType, SortingRule } from 'react-table';
2
+ import { TableHeaderProps } from './table-header';
3
+ import { TablePaginationProps } from './table-pagination';
4
+ import { ReactNode, ComponentType } from 'react';
5
+ import { CustomColumnsType, OptionalDataTypes, PaginationType } from './types';
6
+ export declare type TableProps<T extends object> = PropsWithClass & {
7
+ /**
8
+ * Define the columns and headers of the table.
9
+ */
10
+ columns: CustomColumnsType<T>;
11
+ /**
12
+ * Pass the data structure to the table. Each object key can be used as `accessor` for a column.
13
+ */
14
+ data: Array<T & OptionalDataTypes<T>>;
15
+ /**
16
+ * Define the default visibility of the columns. This is an array of columns `id`,
17
+ */
18
+ defaultHiddenColumns?: Array<IdType<T>>;
19
+ /**
20
+ * Show pagination below the table. This is recommended only for tables with a lot of rows.
21
+ */
22
+ showPagination?: boolean;
23
+ /**
24
+ * The amount of entries to show for each page.
25
+ */
26
+ itemsPerPage?: number;
27
+ /**
28
+ * The index of the page that should be set as active when the table is rendered.
29
+ */
30
+ activePageIndex?: number;
31
+ /**
32
+ * The callback that is called when the active page index and page size change.
33
+ * Passing this property along side `showPagination` will enable manual pagination,
34
+ * disabling the automatic one.
35
+ */
36
+ onDataUpdate?: ({ pageIndex, pageSize }: PaginationType) => Promise<void>;
37
+ /**
38
+ * Set the number of pages to show in the pagination. Used only when doing manual pagination.
39
+ */
40
+ totalRows?: number;
41
+ /**
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 dropdown.
44
+ */
45
+ pageClusters?: TablePaginationProps['clusters'];
46
+ /**
47
+ * Enable row selection. This property will render an additiona column
48
+ * at the start of the table, containing a checkbox.
49
+ */
50
+ selectableRows?: boolean;
51
+ /**
52
+ * Callback run when the selected rows change
53
+ */
54
+ onSelectionChange?(selectedRows?: Row[], selectedRowIds?: Record<IdType<T>, boolean>): void;
55
+ /**
56
+ * If true, disable the automatic column sorting of the table. Turn this on if you want to
57
+ * to control the sorting yourself.
58
+ */
59
+ isManualSorted?: boolean;
60
+ /**
61
+ * Callback run when a column is sorted
62
+ */
63
+ onSortChange?(sorting?: SortingRule<T>[]): void;
64
+ /**
65
+ * Add an alternate style to the table rows
66
+ */
67
+ stripes?: boolean;
68
+ /**
69
+ * Set the loading state of the table. This will sho skeleton loaders instead of the actual data.
70
+ */
71
+ loading?: boolean;
72
+ /**
73
+ * Enable horizontal separators between the table rows
74
+ */
75
+ showSeparators?: boolean;
76
+ /**
77
+ * Add an accessible title to the table component
78
+ */
79
+ title?: TableHeaderProps['title'];
80
+ /**
81
+ * Hide the header which includes the title and controls.
82
+ * This option is ignored and set to `true` if `selectableRows` is set to `true`.
83
+ */
84
+ showHeader?: boolean;
85
+ /**
86
+ * Hide the table header which includes columns names.
87
+ */
88
+ showTableHead?: boolean;
89
+ /**
90
+ * Enable the dropdown to choose the visibility of the column
91
+ */
92
+ columnsControl?: boolean;
93
+ /**
94
+ * Pass custom actions to the table header
95
+ */
96
+ actions?: ReactNode;
97
+ /**
98
+ * Set the label for selected items in the table. Default to "Selected items"
99
+ */
100
+ selectedLabel?: string;
101
+ /**
102
+ * Pass custom components to show when rows are selected.
103
+ */
104
+ selectedActions?: ReactNode;
105
+ /**
106
+ * Set the table height after which the table will scroll.
107
+ */
108
+ height?: string;
109
+ /**
110
+ * Set the table background color. This must be set if `height` is set because
111
+ * the color is used as background for sticky headers.
112
+ */
113
+ background?: string;
5
114
  /**
6
115
  * A react component that add additional content when the row is expanded.
7
- * By passing this prop, the row will be expandable.
116
+ * By passing this prop, the row will be expandable. If fuction is passed,
117
+ * the function will be called with the `subRow` data and the function must return
118
+ * a component.
8
119
  */
9
- ExpandableRowsComponent?: FC<{
10
- data?: T;
11
- }>;
120
+ expandableRowComponent?: ComponentType<T>;
12
121
  /**
13
- * Set the icon to use when the expandable rows are collapsed.
122
+ * A react component that add custom actions to rows. If fuction is passed,
123
+ * the function will be called with the row data and the function must return
124
+ * a component.
14
125
  */
15
- collapsedRowIcon?: IconProps['source'];
126
+ actionsRowComponent?: ComponentType<Row<T>>;
16
127
  /**
17
- * Set the icon to use when the expandable rows are expanded.
128
+ * Custom component/empty state to show when the table has no data or
129
+ * all columns have been toggled off.
18
130
  */
19
- expandedRowIcon?: IconProps['source'];
131
+ emptyComponent?: ReactNode;
20
132
  /**
21
- * Set minimum height for each row.
133
+ * Set the initial sorted column and order by passing column id and order.
22
134
  */
23
- minRowHeight?: string;
135
+ initialSortBy?: Array<SortingRule<T>>;
24
136
  };
25
- export declare const Table: <T>({ className, ExpandableRowsComponent, progressComponent, customStyles, pagination, responsive, fixedHeader, noHeader, paginationPerPage, striped, theme, collapsedRowIcon, expandedRowIcon, minRowHeight, ...otherProps }: TableProps<T>) => JSX.Element;
137
+ export declare const Table: <T extends object>({ 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;
26
138
  //# sourceMappingURL=table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/components/table/table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,MAAM,OAAO,CAAA;AACnC,OAAuB,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC1F,OAAO,EAAQ,SAAS,EAAsB,MAAM,cAAc,CAAA;AAKlE,oBAAY,UAAU,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,GAAG;IAC/C;;;OAGG;IACH,uBAAuB,CAAC,EAAE,EAAE,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,CAAA;KAAC,CAAC,CAAC;IACzC;;OAEG;IACH,gBAAgB,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IACvC;;OAEG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IACtC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAA;AAED,eAAO,MAAM,KAAK,8PAgEjB,CAAA"}
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/components/table/table.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,GAAG,EAAsB,MAAM,EAAE,WAAW,EAC7C,MAAM,aAAa,CAAA;AAIpB,OAAO,EAAe,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAG9D,OAAO,EAAmB,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAK1E,OAAO,EAA2B,SAAS,EAAsB,aAAa,EAAE,MAAM,OAAO,CAAA;AAE7F,OAAO,EAAsC,iBAAiB,EAAmB,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEnI,oBAAY,UAAU,CAAC,CAAC,SAAS,MAAM,IAAI,cAAc,GAAG;IAC1D;;OAEG;IACH,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC9B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC;;OAEG;IACH,oBAAoB,CAAC,EAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACzE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,oBAAoB,CAAC,UAAU,CAAC,CAAA;IAC/C;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,iBAAiB,CAAC,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC3F;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,YAAY,CAAC,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAA;IAC/C;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACjC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;MAEE;IACF,eAAe,CAAC,EAAE,SAAS,CAAA;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAC1C;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;CACtC,CAAA;AAED,eAAO,MAAM,KAAK,qgBAwUjB,CAAA"}
@@ -1,18 +1,117 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useMemo } from 'react';
3
- import ReactDataTable from 'react-data-table-component';
4
- import { Icon, Skeleton, Checkbox } from '../..';
5
- import { customStyle } from './theme';
6
- import styles from './table.module.css';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
2
  import clsx from 'clsx';
8
- export const Table = ({ className, ExpandableRowsComponent, progressComponent, customStyles, pagination = false, responsive = true, fixedHeader = false, noHeader = true, paginationPerPage = 8, striped = false, theme = 'wanda', collapsedRowIcon = 'chevron-right', expandedRowIcon = 'chevron-down', minRowHeight = '48px', ...otherProps }) => {
9
- const selectProps = {
10
- indeterminate: (isIndeterminate) => isIndeterminate,
11
- dimension: 'small'
3
+ import { useTable, useSortBy, useRowSelect, usePagination, useExpanded } from 'react-table';
4
+ import { TableRow } from './table-row';
5
+ import { TableCell } from './table-cell';
6
+ import { TableCheckbox } from './table-checkbox';
7
+ import { TableHeader } from './table-header';
8
+ import { ToggleColumnsControl } from './table-controls';
9
+ import { TableExpand } from './table-expand';
10
+ import { TablePagination } from './table-pagination';
11
+ import { AnimatePresence, motion } from 'framer-motion';
12
+ import { useUIDSeed } from 'react-uid';
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 }) => {
17
+ const uid = useUIDSeed();
18
+ const hasSomeExpandableRows = useMemo(() => data.some(d => d.subRows), [data]);
19
+ const isManualPaginated = useMemo(() => {
20
+ return Boolean(onDataUpdate && showPagination && totalRows);
21
+ }, [onDataUpdate, showPagination, totalRows]);
22
+ const { getTableProps, getTableBodyProps, headerGroups, rows, page, pageCount, gotoPage, allColumns, prepareRow, selectedFlatRows, visibleColumns, setPageSize, setHiddenColumns, state: { pageSize, pageIndex, selectedRowIds, sortBy } } = useTable({
23
+ columns,
24
+ data,
25
+ manualSortBy: isManualSorted,
26
+ disableMultiSort: true,
27
+ expandSubRows: Boolean(!expandableRowComponent),
28
+ autoResetHiddenColumns: false,
29
+ autoResetPage: false,
30
+ manualPagination: isManualPaginated,
31
+ autoResetSelectedRows: false,
32
+ pageCount: (isManualPaginated && totalRows) ? Math.ceil(totalRows / itemsPerPage) : 10,
33
+ // This `paginateExpandedRows` prop prevent expanded rows to be placed in the next page. But it breaks row selection
34
+ // paginateExpandedRows: !showPagination,
35
+ initialState: {
36
+ sortBy: initialSortBy,
37
+ pageIndex: activePageIndex,
38
+ pageSize: showPagination ? itemsPerPage : undefined,
39
+ hiddenColumns: ['selection', 'expander']
40
+ }
41
+ }, useSortBy, useExpanded, usePagination, useRowSelect, (hooks) => {
42
+ const checkboxColumn = [{
43
+ id: 'selection',
44
+ Header: ({ getToggleAllRowsSelectedProps }) => !loading ? _jsx(TableCheckbox, { ...getToggleAllRowsSelectedProps() }, void 0) : null,
45
+ Cell: ({ row }) => _jsx(TableCheckbox, { ...row.getToggleRowSelectedProps() }, void 0),
46
+ isCollapsed: true,
47
+ hideFromList: true
48
+ }];
49
+ const expanderColumn = [{
50
+ id: 'expander',
51
+ isCollapsed: true,
52
+ hideFromList: true,
53
+ expander: true,
54
+ Header: ({ getToggleAllRowsExpandedProps, isAllRowsExpanded }) => (!loading
55
+ ? (_jsx(IconButton, { kind: "flat", dimension: "small", className: styles.ExpandButton, icon: isAllRowsExpanded ? 'chevron-down' : 'chevron-right', ...getToggleAllRowsExpandedProps() }, void 0))
56
+ : null),
57
+ Cell: ({ row }) => row.canExpand
58
+ ? (_jsx(IconButton, { kind: "secondary", dimension: "small", icon: row.isExpanded ? 'chevron-down' : 'chevron-right', ...row.getToggleRowExpandedProps() }, void 0))
59
+ : null
60
+ }];
61
+ const actionsColumn = [{
62
+ id: 'actions',
63
+ isCollapsed: true,
64
+ hideFromList: true,
65
+ Cell: ({ row }) => ActionsRowComponent ? _jsx(ActionsRowComponent, { ...row }, void 0) : null
66
+ }];
67
+ hooks.visibleColumns.push((columns) => [
68
+ ...checkboxColumn,
69
+ ...expanderColumn,
70
+ ...actionsColumn,
71
+ ...columns
72
+ ]);
73
+ });
74
+ useEffect(() => {
75
+ const artificialColumns = defaultHiddenColumns || [];
76
+ if (!selectableRows)
77
+ artificialColumns.push('selection');
78
+ if (!hasSomeExpandableRows)
79
+ artificialColumns.push('expander');
80
+ if (!ActionsRowComponent)
81
+ artificialColumns.push('actions');
82
+ setHiddenColumns(artificialColumns);
83
+ }, [selectableRows, setHiddenColumns, defaultHiddenColumns, expandableRowComponent, hasSomeExpandableRows, ActionsRowComponent]);
84
+ useEffect(() => {
85
+ onSelectionChange && onSelectionChange(selectedFlatRows, selectedRowIds);
86
+ }, [onSelectionChange, selectedFlatRows, selectedRowIds]);
87
+ useEffect(() => {
88
+ onSortChange && onSortChange(sortBy);
89
+ }, [onSortChange, sortBy]);
90
+ useEffect(() => {
91
+ onDataUpdate && onDataUpdate({ pageIndex, pageSize });
92
+ }, [onDataUpdate, pageIndex, pageSize]);
93
+ const rowEntries = useMemo(() => showPagination ? page : rows, [page, rows, showPagination]);
94
+ const filteredVisibleColumns = useMemo(() => visibleColumns.filter((col) => !col.hideFromList), [visibleColumns]);
95
+ const dynamicStyle = {
96
+ '--table-height': height,
97
+ '--table-background': background
12
98
  };
13
- const ExpandComponent = useMemo(() => ({ data: innerData }) => (_jsx("div", { className: styles.ExpandWrapper, children: _jsx("div", { className: styles.ExpandContent, children: ExpandableRowsComponent ? _jsx(ExpandableRowsComponent, { data: innerData }, void 0) : null }, void 0) }, void 0)), [ExpandableRowsComponent]);
14
- return (_jsx("div", { className: clsx(styles.DataTable, className), children: _jsx(ReactDataTable, { pagination: pagination, responsive: responsive, fixedHeader: fixedHeader, paginationPerPage: paginationPerPage, expandableRows: Boolean(ExpandableRowsComponent), expandOnRowClicked: Boolean(ExpandableRowsComponent), expandableRowsComponent: ExpandComponent, theme: theme, noHeader: noHeader, progressComponent: progressComponent || _jsx("div", { style: { width: '100%' }, children: _jsx(Skeleton, { height: "40px", count: 8 }, void 0) }, void 0), striped: striped, customStyles: customStyles || customStyle(minRowHeight), selectableRowsComponent: Checkbox, selectableRowsComponentProps: selectProps, expandableIcon: {
15
- collapsed: _jsx(Icon, { source: collapsedRowIcon, fill: "var(--global-foreground)", dimension: 16 }, void 0),
16
- expanded: _jsx(Icon, { source: expandedRowIcon, fill: "var(--global-foreground)", dimension: 16 }, void 0)
17
- }, paginationIconFirstPage: _jsx(Icon, { source: "backward-step", dimension: 24 }, void 0), paginationIconPrevious: _jsx(Icon, { source: "chevron-left", dimension: 24 }, void 0), paginationIconNext: _jsx(Icon, { source: "chevron-right", dimension: 24 }, void 0), paginationIconLastPage: _jsx(Icon, { source: "forward-step", dimension: 24 }, void 0), sortIcon: (_jsx("span", { className: styles.SortIcon, children: _jsx(Icon, { source: "arrow-up" }, void 0) }, void 0)), ...otherProps }, void 0) }, void 0));
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", horizontalAlign: "space-between", verticalAlign: "center", horizontalPadding: 16, verticalPadding: 8, fill: false, columnGap: 16, initial: { y: '-16px', opacity: 0 }, animate: {
100
+ y: 0,
101
+ opacity: 1,
102
+ transition: {
103
+ type: 'spring',
104
+ stiffness: 700,
105
+ damping: 30
106
+ }
107
+ }, exit: { y: '-16px', opacity: 0 }, children: [_jsx(Text, { as: "span", size: 14, weight: "bold", children: `${selectedLabel}: ${selectedFlatRows.length}` }, void 0), selectedActions] }, void 0)) }, void 0), (showHeader || selectableRows) && (_jsxs(TableHeader, { title: title, children: [(columnsControl && data.length)
108
+ ? (_jsx(ToggleColumnsControl, { columns: allColumns, visibleColumns: filteredVisibleColumns }, void 0))
109
+ : null, actions] }, void 0)), ((data.length || loading) && filteredVisibleColumns.length)
110
+ ? (_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
+ ? (_jsx(TableRow, { children: visibleColumns.map(() => (_jsx(TableCell, { children: _jsx(Skeleton, { gap: 16, height: 16, count: 5 }, void 0) }, void 0))) }, void 0))
112
+ : rowEntries.map((row) => {
113
+ prepareRow(row);
114
+ return (_jsxs(Fragment, { children: [_jsx(TableRow, { ...row.getRowProps(), "data-row-expanded": row.isExpanded || undefined, "data-row-depth": row.depth > 0 ? row.depth : undefined, children: row.cells.map((cell) => (_jsx(TableCell, { collapsed: cell.column.isCollapsed, isExpander: cell.column.expander, expanded: row.isExpanded, depth: row.depth, width: cell.column.minWidth === 0 ? undefined : cell.column.minWidth, align: cell.column.align, hasSubrows: !!row.subRows?.length, ...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
+ }) }, void 0)] }, void 0) }, void 0))
116
+ : (_jsx(Stack, { verticalAlign: "center", horizontalAlign: "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));
18
117
  };
@@ -1 +1 @@
1
- .DataTable{--headcell-fs:0.89rem;--cell-fs:0.89rem;--pagination-fs:0.89rem}.SortIcon{display:block;margin-left:4px;transform:scale(.7)}.ExpandWrapper{overflow:hidden}.ExpandContent{--fade-from-y:-5px;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}}
1
+ .Table{position:relative;width:100%;z-index:0}.TableWrapper{-webkit-overflow-scrolling:touch;overflow:auto}.TableWrapper[data-table-scrolling=true]{background:var(--table-background);max-height:var(--table-height);overscroll-behavior:contain}.TableElement{border-collapse:collapse;font-size:.89rem;width:100%}.TableElement[data-table-loading=true]{pointer-events:none;-webkit-user-select:none;user-select:none}.THead{background:var(--table-background);box-shadow:inset 0 -3px 0 var(--dimmed-2);position:sticky;top:0;z-index:2}@media not all and (-webkit-min-device-pixel-ratio:0),not all and (min-resolution:0.001dpcm){@supports (-webkit-appearance:none) and (stroke-color:transparent){.THead{border-bottom:3px solid var(--dimmed-2);box-shadow:none}}}.THead th{padding-bottom:.89rem;padding-top:.89rem}.Toast{-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);border-radius:.44rem;left:0;min-block-size:3.11rem;position:absolute;right:0;top:0;z-index:4}.ExpandButton{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}
@@ -0,0 +1,21 @@
1
+ import { ReactNode } from 'react';
2
+ import { Column, CustomHeaderGroup, CustomCell, ColumnInstance } from 'react-table';
3
+ export declare type PaginationType = {
4
+ pageIndex: number;
5
+ pageSize: number;
6
+ };
7
+ export declare type OptionalColumnTypes = {
8
+ isCollapsed?: boolean;
9
+ align?: 'start' | 'center' | 'end';
10
+ hideFromList?: boolean;
11
+ expander?: boolean;
12
+ };
13
+ export declare type OptionalDataTypes<T> = {
14
+ subRows?: T[];
15
+ actions?: ReactNode | ReactNode[];
16
+ };
17
+ export declare type HeaderGroupType = CustomHeaderGroup<OptionalColumnTypes>;
18
+ export declare type CellType = CustomCell<OptionalColumnTypes>;
19
+ export declare type CustomColumnsType<T extends object> = (Column<T> & OptionalColumnTypes)[];
20
+ export declare type CustomColumnInstanceType = ColumnInstance & OptionalColumnTypes;
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/table/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EACL,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EACtD,MAAM,aAAa,CAAA;AAEpB,oBAAY,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,oBAAY,mBAAmB,GAAG;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAA;AAED,oBAAY,iBAAiB,CAAC,CAAC,IAAI;IACjC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;IACd,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;CACnC,CAAA;AAED,oBAAY,eAAe,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,CAAA;AACpE,oBAAY,QAAQ,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAA;AACtD,oBAAY,iBAAiB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,EAAE,CAAA;AACrF,oBAAY,wBAAwB,GAAG,cAAc,GAAG,mBAAmB,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
- "version": "5.4.0",
3
+ "version": "5.5.0",
4
4
  "description": "UI components from Wonderflow's Wanda design system",
5
5
  "author": "Wonderflow",
6
6
  "license": "MIT",
@@ -56,25 +56,26 @@
56
56
  "react-dom": "^17.0"
57
57
  },
58
58
  "devDependencies": {
59
- "@babel/core": "7.17.0",
59
+ "@babel/core": "7.17.5",
60
60
  "@babel/preset-typescript": "7.16.7",
61
- "@storybook/addon-actions": "6.4.18",
62
- "@storybook/addon-essentials": "6.4.18",
63
- "@storybook/addon-links": "6.4.18",
61
+ "@storybook/addon-actions": "6.4.19",
62
+ "@storybook/addon-essentials": "6.4.19",
63
+ "@storybook/addon-links": "6.4.19",
64
64
  "@storybook/addon-postcss": "2.0.0",
65
65
  "@storybook/addons": "6.5.0-alpha.21",
66
66
  "@storybook/builder-webpack5": "6.5.0-alpha.21",
67
67
  "@storybook/manager-webpack5": "6.5.0-alpha.21",
68
- "@storybook/react": "6.4.18",
68
+ "@storybook/react": "6.4.19",
69
69
  "@storybook/theming": "6.5.0-alpha.21",
70
70
  "@types/react": "17.0.39",
71
71
  "@types/react-dom": "17.0.11",
72
+ "@types/react-table": "7.7.9",
72
73
  "@wonderflow/config": "*",
73
74
  "@wonderflow/stylelint-config": "1.1.4",
74
75
  "@wonderflow/tokens": "*",
75
76
  "babel-loader": "8.2.3",
76
77
  "cpy-cli": "3.1.1",
77
- "postcss": "8.4.6",
78
+ "postcss": "8.4.7",
78
79
  "postcss-cli": "9.1.0",
79
80
  "react": "17.0.2",
80
81
  "react-dom": "17.0.2",
@@ -85,17 +86,17 @@
85
86
  "typescript-plugin-css-modules": "3.4.0"
86
87
  },
87
88
  "dependencies": {
88
- "ahooks": "3.1.9",
89
+ "ahooks": "3.1.10",
89
90
  "clsx": "1.1.1",
90
- "framer-motion": "6.2.4",
91
- "react-data-table-component": "7.4.7",
91
+ "framer-motion": "6.2.8",
92
92
  "react-focus-on": "3.5.4",
93
93
  "react-masonry-css": "1.0.16",
94
- "react-paginate": "8.1.0",
94
+ "react-paginate": "8.1.2",
95
95
  "react-popper-tooltip": "4.3.1",
96
96
  "react-roving-tabindex": "3.1.1",
97
+ "react-table": "7.7.0",
97
98
  "react-uid": "2.3.1",
98
99
  "styled-components": "5.3.3",
99
- "type-fest": "2.11.1"
100
+ "type-fest": "2.12.0"
100
101
  }
101
102
  }
@@ -1,3 +0,0 @@
1
- import { TableStyles } from 'react-data-table-component';
2
- export declare const customStyle: (rowHeight: string) => TableStyles;
3
- //# sourceMappingURL=theme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/components/table/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAwCrE,eAAO,MAAM,WAAW,cAAe,MAAM,KAAG,WAuC9C,CAAA"}
@@ -1,78 +0,0 @@
1
- import { createTheme } from 'react-data-table-component';
2
- /* Reference: https://github.com/jbetancur/react-data-table-component/blob/master/src/DataTable/themes.ts */
3
- createTheme('wanda', {
4
- text: {
5
- primary: 'var(--foreground-color)',
6
- secondary: 'var(--dimmed-6)',
7
- disabled: 'var(--global-disabled-foreground)'
8
- },
9
- background: {
10
- default: 'transparent'
11
- },
12
- context: {
13
- background: 'var(--global-vibrancy-background)',
14
- text: 'var(--global-vibrancy-foreground)'
15
- },
16
- divider: {
17
- default: 'transparent'
18
- },
19
- button: {
20
- default: 'transparent',
21
- focus: 'var(--dimmed-1)',
22
- hover: 'transparent',
23
- disabled: 'var(--global-disabled-foreground)'
24
- },
25
- selected: {
26
- default: 'var(--highlight-blue-background)',
27
- text: 'var(--highlight-blue-foreground)'
28
- },
29
- highlightOnHover: {
30
- default: 'var(--dimmed-1)',
31
- text: 'var(--global-foreground)'
32
- },
33
- striped: {
34
- default: 'var(--dimmed-0)',
35
- text: 'var(--global-foreground)'
36
- }
37
- });
38
- /* Reference: https://github.com/jbetancur/react-data-table-component/blob/master/src/DataTable/styles.ts */
39
- export const customStyle = (rowHeight) => ({
40
- rows: {
41
- style: {
42
- minHeight: rowHeight
43
- },
44
- highlightOnHoverStyle: {
45
- outline: 'none'
46
- }
47
- },
48
- headRow: {
49
- style: {
50
- borderBottom: '3px solid var(--dimmed-2)'
51
- }
52
- },
53
- headCells: {
54
- style: {
55
- fontWeight: 800,
56
- fontSize: 'var(--headcell-fs)'
57
- }
58
- },
59
- cells: {
60
- style: {
61
- fontSize: 'var(--cell-fs)'
62
- }
63
- },
64
- pagination: {
65
- style: {
66
- fontSize: 'var(--pagination-fs)'
67
- },
68
- pageButtonsStyle: {
69
- color: 'var(--global-foreground)'
70
- }
71
- },
72
- contextMenu: {
73
- style: {
74
- backdropFilter: 'blur(32px)',
75
- borderRadius: '4px'
76
- }
77
- }
78
- });