musae 0.2.2 → 0.2.3

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 (49) hide show
  1. package/dist/components/checkbox/checkbox.js +3 -2
  2. package/dist/components/collapse/collapse.d.ts +4 -0
  3. package/dist/components/collapse/collapse.js +97 -0
  4. package/dist/components/collapse/context.d.ts +7 -0
  5. package/dist/components/collapse/context.js +12 -0
  6. package/dist/components/collapse/hooks.d.ts +12 -0
  7. package/dist/components/collapse/hooks.js +43 -0
  8. package/dist/components/collapse/index.d.ts +2 -0
  9. package/dist/components/collapse/item.d.ts +4 -0
  10. package/dist/components/collapse/item.js +144 -0
  11. package/dist/components/collapse/types.d.ts +87 -0
  12. package/dist/components/icon/icon.js +1 -1
  13. package/dist/components/icon/icons/index.js +1 -0
  14. package/dist/components/icon/icons/navigation/index.d.ts +2 -1
  15. package/dist/components/icon/icons/navigation/index.js +1 -0
  16. package/dist/components/icon/icons/navigation/unfold-more.d.ts +3 -0
  17. package/dist/components/icon/icons/navigation/unfold-more.js +10 -0
  18. package/dist/components/loading/loading.d.ts +1 -1
  19. package/dist/components/loading/loading.js +69 -4
  20. package/dist/components/loading/types.d.ts +13 -0
  21. package/dist/components/rate/star.js +11 -13
  22. package/dist/components/ripple/hooks.js +4 -1
  23. package/dist/components/table/body.js +35 -3
  24. package/dist/components/table/context.d.ts +6 -0
  25. package/dist/components/table/context.js +10 -2
  26. package/dist/components/table/header/cell.d.ts +3 -0
  27. package/dist/components/table/header/cell.js +129 -0
  28. package/dist/components/table/{header.d.ts → header/header.d.ts} +1 -1
  29. package/dist/components/table/{header.js → header/header.js} +37 -10
  30. package/dist/components/table/hooks.d.ts +8 -21
  31. package/dist/components/table/hooks.js +36 -58
  32. package/dist/components/table/table.d.ts +1 -1
  33. package/dist/components/table/table.js +12 -6
  34. package/dist/components/table/types.d.ts +72 -4
  35. package/dist/components/waterfall/hooks.d.ts +1 -2
  36. package/dist/components/waterfall/hooks.js +2 -8
  37. package/dist/components/waterfall/waterfall.js +9 -5
  38. package/dist/components/watermark/types.d.ts +1 -1
  39. package/dist/components/watermark/watermark.js +1 -1
  40. package/dist/hooks/use-class-names.d.ts +15 -0
  41. package/dist/hooks/use-expand-effect.d.ts +1 -1
  42. package/dist/hooks/use-expand-effect.js +12 -8
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.js +1 -0
  45. package/dist/stylex.css +17 -3
  46. package/dist/utils/class-name.d.ts +65 -3
  47. package/dist/utils/class-name.js +39 -5
  48. package/dist/utils/styles.d.ts +1 -1
  49. package/package.json +4 -4
@@ -31,8 +31,8 @@ const styles = {
31
31
  $$css: true
32
32
  }
33
33
  },
34
- leading: {
35
- default: props => [{
34
+ half: {
35
+ default: {
36
36
  position: "musae-10l6tqk",
37
37
  width: "musae-1gn8jaj",
38
38
  height: "musae-b27hse",
@@ -46,7 +46,7 @@ const styles = {
46
46
  overflowX: null,
47
47
  overflowY: null,
48
48
  $$css: true
49
- }, {}],
49
+ },
50
50
  checked: props => [{
51
51
  opacity: "musae-1hc1fzr",
52
52
  color: "musae-19dipnz",
@@ -55,12 +55,12 @@ const styles = {
55
55
  "--color": props.color != null ? props.color : "initial"
56
56
  }]
57
57
  },
58
- trailing: {
58
+ full: {
59
59
  default: {
60
60
  userSelect: "musae-87ps6o",
61
61
  $$css: true
62
62
  },
63
- checkd: props => [{
63
+ checked: props => [{
64
64
  color: "musae-19dipnz",
65
65
  $$css: true
66
66
  }, {
@@ -104,12 +104,10 @@ const Star = ({
104
104
  star: _stylex.props(styles.star.default({
105
105
  color: theme.colors[ColorToken.SurfaceContainerHighest]
106
106
  }), disabled && styles.star.disabled),
107
- leading: _stylex.props(styles.leading.default({
108
- hoveredColor: theme.colors[ColorToken.Primary]
109
- }), isHalf && styles.leading.checked({
107
+ half: _stylex.props(styles.half.default, isHalf && styles.half.checked({
110
108
  color: theme.colors[ColorToken.Primary]
111
109
  })),
112
- trailing: _stylex.props(styles.trailing.default, isFull && styles.trailing.checkd({
110
+ full: _stylex.props(styles.full.default, isFull && styles.full.checked({
113
111
  color: theme.colors[ColorToken.Primary]
114
112
  }))
115
113
  };
@@ -117,8 +115,8 @@ const Star = ({
117
115
  className: clsx(classNames[RateClassToken.Star], styled.star.className),
118
116
  style: styled.star.style
119
117
  }, React.createElement("div", {
120
- className: clsx(classNames[RateClassToken.Leading], styled.leading.className),
121
- style: styled.leading.style,
118
+ className: clsx(classNames[RateClassToken.Half], styled.half.className),
119
+ style: styled.half.style,
122
120
  ...(!disabled && {
123
121
  ...halfHoverProps,
124
122
  onClick: half
@@ -126,8 +124,8 @@ const Star = ({
126
124
  }, createElement(_Star, {
127
125
  size: "large"
128
126
  })), React.createElement("div", {
129
- className: clsx(classNames[RateClassToken.Trailing], styled.trailing.className),
130
- style: styled.trailing.style,
127
+ className: clsx(classNames[RateClassToken.Full], styled.full.className),
128
+ style: styled.full.style,
131
129
  ...(!disabled && {
132
130
  ...fullHoverProps,
133
131
  onClick: full
@@ -1,18 +1,21 @@
1
1
  import { useState, useCallback, useMemo } from 'react';
2
+ import { useIdentity } from '@aiszlab/relax';
2
3
 
3
4
  function useRipple() {
4
5
  const [_ripples, _setRipples] = useState(new Map());
6
+ const [, unique] = useIdentity();
5
7
  const add = useCallback((event) => {
6
8
  const trigger = event.currentTarget;
7
9
  const size = Math.max(trigger.clientWidth, trigger.clientHeight);
8
10
  const { x, y } = trigger.getBoundingClientRect();
9
11
  _setRipples((prev) => {
10
- return new Map(prev).set(crypto.randomUUID(), {
12
+ return new Map(prev).set(unique(), {
11
13
  size,
12
14
  x: event.clientX - x - size / 2,
13
15
  y: event.clientY - y - size / 2,
14
16
  });
15
17
  });
18
+ // eslint-disable-next-line react-hooks/exhaustive-deps
16
19
  }, []);
17
20
  const clear = useCallback((key) => {
18
21
  _setRipples((prev) => {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { useTable, styles as styles$1 } from './hooks.js';
2
+ import { useTable } from './context.js';
3
3
  import { flexRender } from '@tanstack/react-table';
4
4
  import { props } from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
5
5
  import clsx from 'clsx';
@@ -8,6 +8,38 @@ import { useTheme } from '../theme/hooks.js';
8
8
  import { ColorToken } from '../../utils/colors.js';
9
9
 
10
10
  const styles = {
11
+ cell: props => [{
12
+ paddingInline: "musae-iujutg",
13
+ paddingStart: null,
14
+ paddingLeft: null,
15
+ paddingEnd: null,
16
+ paddingRight: null,
17
+ paddingBlock: "musae-avjae4",
18
+ paddingTop: null,
19
+ paddingBottom: null,
20
+ borderColor: "musae-eqt46j",
21
+ borderInlineColor: null,
22
+ borderInlineStartColor: null,
23
+ borderLeftColor: null,
24
+ borderInlineEndColor: null,
25
+ borderRightColor: null,
26
+ borderBlockColor: null,
27
+ borderTopColor: null,
28
+ borderBottomColor: null,
29
+ borderStyle: "musae-1y0btm7",
30
+ borderInlineStyle: null,
31
+ borderInlineStartStyle: null,
32
+ borderLeftStyle: null,
33
+ borderInlineEndStyle: null,
34
+ borderRightStyle: null,
35
+ borderBlockStyle: null,
36
+ borderTopStyle: null,
37
+ borderBottomStyle: null,
38
+ borderBottomWidth: "musae-lntmim",
39
+ $$css: true
40
+ }, {
41
+ "--borderColor": props.borderColor != null ? props.borderColor : "initial"
42
+ }],
11
43
  bordered: {
12
44
  borderInline: "musae-10htjfm",
13
45
  $$css: true
@@ -20,8 +52,8 @@ const Body = props$1 => {
20
52
  } = useTable();
21
53
  const theme = useTheme();
22
54
  if (!table) return null;
23
- const styled = props(bordered && styles.bordered, typography.body.small, styles$1.cell({
24
- outlineColor: theme.colors[ColorToken.OutlineVariant]
55
+ const styled = props(bordered && styles.bordered, typography.body.small, styles.cell({
56
+ borderColor: theme.colors[ColorToken.OutlineVariant]
25
57
  }));
26
58
  return React.createElement("tbody", null, table.getRowModel().rows.map(row => React.createElement("tr", {
27
59
  key: row.id
@@ -2,3 +2,9 @@
2
2
  import type { ContextValue } from "./types";
3
3
  declare const Context: import("react").Context<ContextValue<unknown>>;
4
4
  export default Context;
5
+ /**
6
+ * @author murukal
7
+ * @description
8
+ * use table context hook
9
+ */
10
+ export declare const useTable: <T>() => ContextValue<T>;
@@ -1,7 +1,15 @@
1
- import { createContext } from 'react';
1
+ import { createContext, useContext } from 'react';
2
2
 
3
3
  const Context = createContext({
4
4
  bordered: false,
5
5
  });
6
+ /**
7
+ * @author murukal
8
+ * @description
9
+ * use table context hook
10
+ */
11
+ const useTable = () => {
12
+ return useContext(Context);
13
+ };
6
14
 
7
- export { Context as default };
15
+ export { Context as default, useTable };
@@ -0,0 +1,3 @@
1
+ import type { HeaderCellProps } from "../types";
2
+ declare const Cell: ({ sortable, children: _children, value, sortDirections: _sortDirections }: HeaderCellProps) => any;
3
+ export default Cell;
@@ -0,0 +1,129 @@
1
+ import React, { useContext, useMemo } from 'react';
2
+ import { toFunction, useEvent, isUndefined } from '@aiszlab/relax';
3
+ import _stylex from '../../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
4
+ import { useTheme } from '../../theme/hooks.js';
5
+ import { ColorToken } from '../../../utils/colors.js';
6
+ import Context from '../context.js';
7
+ import UnfoldMore from '../../icon/icons/navigation/unfold-more.js';
8
+
9
+ const styles = {
10
+ cell: {
11
+ default: {
12
+ display: "musae-78zum5",
13
+ justifyContent: "musae-1qughib",
14
+ alignItems: "musae-6s0dn4",
15
+ $$css: true
16
+ },
17
+ handlers: props => [{
18
+ display: "musae-3nfvp2",
19
+ flexDirection: "musae-1q0g3np",
20
+ gap: "musae-29tp26",
21
+ rowGap: null,
22
+ columnGap: null,
23
+ color: "musae-19dipnz",
24
+ userSelect: "musae-87ps6o",
25
+ $$css: true
26
+ }, {
27
+ "--color": props.color != null ? props.color : "initial"
28
+ }]
29
+ },
30
+ sort: {
31
+ default: {
32
+ position: "musae-1n2onr6",
33
+ cursor: "musae-1ypdohk",
34
+ $$css: true
35
+ },
36
+ half: {
37
+ position: "musae-10l6tqk",
38
+ top: "musae-9oc6z4",
39
+ insetInlineStart: "musae-1at4hj2",
40
+ left: null,
41
+ right: null,
42
+ height: "musae-1cj5796",
43
+ overflow: "musae-b3r6kr",
44
+ overflowX: null,
45
+ overflowY: null,
46
+ $$css: true
47
+ },
48
+ checked: props => [{
49
+ color: "musae-19dipnz",
50
+ $$css: true
51
+ }, {
52
+ "--color": props.color != null ? props.color : "initial"
53
+ }]
54
+ }
55
+ };
56
+ const Cell = ({
57
+ sortable = false,
58
+ children: _children,
59
+ value,
60
+ sortDirections: _sortDirections
61
+ }) => {
62
+ const {
63
+ sortDescriptor,
64
+ onSortChange
65
+ } = useContext(Context);
66
+ const children = toFunction(_children)();
67
+ const theme = useTheme();
68
+ // convert sort directions to usable
69
+ const sortDirections = useMemo(() => {
70
+ return _sortDirections.reduce((prev, item, index) => {
71
+ return prev.set(item, _sortDirections[index + 1] ?? null);
72
+ }, new Map());
73
+ }, [_sortDirections]);
74
+ const sort = useMemo(() => {
75
+ if (sortDescriptor?.key === value) {
76
+ return sortDescriptor.direction;
77
+ }
78
+ return null;
79
+ }, [sortDescriptor, value]);
80
+ // sort handler
81
+ const onSort = useEvent(() => {
82
+ const _direction = sortDirections.get(sort);
83
+ const __direction = isUndefined(_direction) ? "ascending" : _direction;
84
+ onSortChange?.({
85
+ key: value,
86
+ direction: __direction
87
+ });
88
+ });
89
+ // only children, render directly
90
+ if (!sortable) {
91
+ return children;
92
+ }
93
+ const styled = {
94
+ cell: _stylex.props(styles.cell.default),
95
+ handlers: _stylex.props(styles.cell.handlers({
96
+ color: theme.colors[ColorToken.SurfaceContainerHighest]
97
+ })),
98
+ sort: _stylex.props(styles.sort.default),
99
+ fullSort: _stylex.props(sort === "descending" && styles.sort.checked({
100
+ color: theme.colors[ColorToken.Primary]
101
+ })),
102
+ halfSort: _stylex.props(styles.sort.half, sort === "ascending" && styles.sort.checked({
103
+ color: theme.colors[ColorToken.Primary]
104
+ }))
105
+ };
106
+ return React.createElement("div", {
107
+ className: styled.cell.className,
108
+ style: styled.cell.style
109
+ }, children, React.createElement("span", {
110
+ className: styled.handlers.className,
111
+ style: styled.handlers.style
112
+ }, React.createElement("span", {
113
+ className: styled.sort.className,
114
+ style: styled.sort.style,
115
+ onClick: onSort
116
+ }, React.createElement("div", {
117
+ className: styled.fullSort.className,
118
+ style: styled.fullSort.style
119
+ }, React.createElement(UnfoldMore, {
120
+ size: "medium"
121
+ })), !!sort && React.createElement("div", {
122
+ className: styled.halfSort.className,
123
+ style: styled.halfSort.style
124
+ }, React.createElement(UnfoldMore, {
125
+ size: "medium"
126
+ })))));
127
+ };
128
+
129
+ export { Cell as default };
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
- import { HeaderProps } from "./types";
2
+ import type { HeaderProps } from "../types";
3
3
  declare const Header: <T>(props: HeaderProps) => React.JSX.Element | null;
4
4
  export default Header;
@@ -1,20 +1,48 @@
1
1
  import React from 'react';
2
- import { useTable, styles as styles$1 } from './hooks.js';
2
+ import { useTable } from '../context.js';
3
3
  import { flexRender } from '@tanstack/react-table';
4
- import { props } from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
5
- import { useTheme } from '../theme/hooks.js';
4
+ import { props } from '../../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
5
+ import { useTheme } from '../../theme/hooks.js';
6
6
  import clsx from 'clsx';
7
- import { ColorToken } from '../../utils/colors.js';
8
- import { typography } from '../theme/theme.js';
7
+ import { ColorToken } from '../../../utils/colors.js';
8
+ import { typography } from '../../theme/theme.js';
9
9
 
10
10
  const styles = {
11
11
  cell: props => [{
12
12
  backgroundColor: "musae-q1mx2j",
13
13
  textAlign: "musae-1yc453h",
14
14
  position: "musae-1n2onr6",
15
+ paddingInline: "musae-iujutg",
16
+ paddingStart: null,
17
+ paddingLeft: null,
18
+ paddingEnd: null,
19
+ paddingRight: null,
20
+ paddingBlock: "musae-avjae4",
21
+ paddingTop: null,
22
+ paddingBottom: null,
23
+ borderColor: "musae-eqt46j",
24
+ borderInlineColor: null,
25
+ borderInlineStartColor: null,
26
+ borderLeftColor: null,
27
+ borderInlineEndColor: null,
28
+ borderRightColor: null,
29
+ borderBlockColor: null,
30
+ borderTopColor: null,
31
+ borderBottomColor: null,
32
+ borderStyle: "musae-1y0btm7",
33
+ borderInlineStyle: null,
34
+ borderInlineStartStyle: null,
35
+ borderLeftStyle: null,
36
+ borderInlineEndStyle: null,
37
+ borderRightStyle: null,
38
+ borderBlockStyle: null,
39
+ borderTopStyle: null,
40
+ borderBottomStyle: null,
41
+ borderBottomWidth: "musae-lntmim",
15
42
  $$css: true
16
43
  }, {
17
- "--backgroundColor": props.backgroundColor != null ? props.backgroundColor : "initial"
44
+ "--backgroundColor": props.backgroundColor != null ? props.backgroundColor : "initial",
45
+ "--borderColor": props.borderColor != null ? props.borderColor : "initial"
18
46
  }],
19
47
  unbordered: props => [{
20
48
  ":not(:last-of-type)::after_content": "musae-x7gz8e",
@@ -53,11 +81,10 @@ const Header = props$1 => {
53
81
  if (!table) return null;
54
82
  const headerGroups = table.getHeaderGroups();
55
83
  const styled = props(styles.cell({
56
- backgroundColor: theme.colors[ColorToken.Surface]
57
- }), typography.label.small, bordered ? styles.bordered : styles.unbordered({
84
+ backgroundColor: theme.colors[ColorToken.Surface],
85
+ borderColor: theme.colors[ColorToken.OutlineVariant]
86
+ }), typography.label.small, bordered && styles.bordered, !bordered && styles.unbordered({
58
87
  backgroundColor: theme.colors[ColorToken.OutlineVariant]
59
- }), styles$1.cell({
60
- outlineColor: theme.colors[ColorToken.OutlineVariant]
61
88
  }));
62
89
  return React.createElement("thead", {
63
90
  className: props$1.className
@@ -1,33 +1,20 @@
1
- import { type CSSProperties } from "react";
2
- import type { ContextValue, TableProps } from "./types";
3
- export declare const styles: Readonly<{
4
- readonly cell: (props: {
5
- outlineColor: CSSProperties["borderColor"];
6
- }) => readonly [Readonly<{
7
- paddingInline: import("@stylexjs/stylex/lib/StyleXTypes").StyleXClassNameFor<"paddingInline", string>;
8
- paddingBlock: import("@stylexjs/stylex/lib/StyleXTypes").StyleXClassNameFor<"paddingBlock", string>;
9
- borderColor: import("@stylexjs/stylex/lib/StyleXTypes").StyleXClassNameFor<"borderColor", import("csstype").Property.BorderColor | undefined>;
10
- borderStyle: import("@stylexjs/stylex/lib/StyleXTypes").StyleXClassNameFor<"borderStyle", "solid">;
11
- borderBottomWidth: import("@stylexjs/stylex/lib/StyleXTypes").StyleXClassNameFor<"borderBottomWidth", string>;
12
- }>, typeof import("@stylexjs/stylex/lib/StyleXTypes").StyleXInlineStylesTag];
13
- }>;
1
+ import { type ColumnDef } from "@tanstack/react-table";
2
+ import type { Column, ContextValue, SortDescriptor } from "./types";
14
3
  /**
15
4
  * @description
16
5
  * use columns
17
6
  */
18
- export declare const useColumns: <T>([columns]: [TableProps<T>["columns"]]) => import("@tanstack/react-table").ColumnDef<T, any>[];
19
- /**
20
- * @author murukal
21
- * @description
22
- * use table context hook
23
- */
24
- export declare const useTable: <T>() => ContextValue<T>;
7
+ export declare const useColumns: <T>({ columns }: {
8
+ columns: Column<T>[];
9
+ }) => ColumnDef<T, any>[];
25
10
  /**
26
11
  * @author murukal
27
12
  * @description
28
13
  * for context value
29
14
  */
30
- export declare const useContextValue: <T>({ table: _table, bordered, }: {
15
+ export declare const useContextValue: <T>({ table: _table, bordered, sortDescriptor: _sortDescriptor, onSortChange: _onSortChange, }: {
31
16
  table: ContextValue<T>["table"];
32
17
  bordered: boolean;
18
+ sortDescriptor?: SortDescriptor;
19
+ onSortChange?: (sortDescriptor: SortDescriptor) => void;
33
20
  }) => ContextValue<unknown>;
@@ -1,72 +1,50 @@
1
1
  import { createColumnHelper } from '@tanstack/react-table';
2
- import { useRef, useMemo, useContext } from 'react';
3
- import Context from './context.js';
2
+ import { useRef, useMemo, createElement } from 'react';
3
+ import Cell from './header/cell.js';
4
+ import { useControlledState, useEvent } from '@aiszlab/relax';
4
5
 
5
- const styles = {
6
- cell: props => [{
7
- paddingInline: "musae-iujutg",
8
- paddingStart: null,
9
- paddingLeft: null,
10
- paddingEnd: null,
11
- paddingRight: null,
12
- paddingBlock: "musae-avjae4",
13
- paddingTop: null,
14
- paddingBottom: null,
15
- borderColor: "musae-eqt46j",
16
- borderInlineColor: null,
17
- borderInlineStartColor: null,
18
- borderLeftColor: null,
19
- borderInlineEndColor: null,
20
- borderRightColor: null,
21
- borderBlockColor: null,
22
- borderTopColor: null,
23
- borderBottomColor: null,
24
- borderStyle: "musae-1y0btm7",
25
- borderInlineStyle: null,
26
- borderInlineStartStyle: null,
27
- borderLeftStyle: null,
28
- borderInlineEndStyle: null,
29
- borderRightStyle: null,
30
- borderBlockStyle: null,
31
- borderTopStyle: null,
32
- borderBottomStyle: null,
33
- borderBottomWidth: "musae-lntmim",
34
- $$css: true
35
- }, {
36
- "--borderColor": props.outlineColor != null ? props.outlineColor : "initial"
37
- }]
38
- };
39
6
  /**
40
7
  * @description
41
8
  * use columns
42
9
  */
43
- const useColumns = ([columns]) => {
44
- const {
45
- current: helper
46
- } = useRef(createColumnHelper());
47
- return columns ? columns(helper) : [];
48
- };
49
- /**
50
- * @author murukal
51
- * @description
52
- * use table context hook
53
- */
54
- const useTable = () => {
55
- return useContext(Context);
10
+ const useColumns = ({ columns }) => {
11
+ const helper = useRef(createColumnHelper());
12
+ return useMemo(() => {
13
+ return columns.map(({ key, render, title, sortable = false, sortDirections = ["ascending", "descending"] }) => {
14
+ // @ts-ignore
15
+ return helper.current.accessor(key, {
16
+ header: createElement(Cell, { children: title, sortable, value: key, sortDirections }),
17
+ cell: (_context) => {
18
+ const value = _context.getValue();
19
+ if (!render) {
20
+ return value;
21
+ }
22
+ return render(value, _context.row.original, _context.row.index);
23
+ },
24
+ });
25
+ });
26
+ }, [columns]);
56
27
  };
57
28
  /**
58
29
  * @author murukal
59
30
  * @description
60
31
  * for context value
61
32
  */
62
- const useContextValue = ({
63
- table: _table,
64
- bordered
65
- }) => {
66
- return useMemo(() => ({
67
- table: _table,
68
- bordered
69
- }), [_table, bordered]);
33
+ const useContextValue = ({ table: _table, bordered, sortDescriptor: _sortDescriptor, onSortChange: _onSortChange, }) => {
34
+ const [sortDescriptor, setSortDescriptor] = useControlledState(_sortDescriptor);
35
+ // sort change handler
36
+ const onSortChange = useEvent((sortDescriptor) => {
37
+ setSortDescriptor(sortDescriptor);
38
+ _onSortChange?.(sortDescriptor);
39
+ });
40
+ return useMemo(() => ({
41
+ // @ts-ignore
42
+ table: _table,
43
+ bordered,
44
+ // sort descriptor
45
+ sortDescriptor,
46
+ onSortChange,
47
+ }), [_table, bordered, sortDescriptor, onSortChange]);
70
48
  };
71
49
 
72
- export { styles, useColumns, useContextValue, useTable };
50
+ export { useColumns, useContextValue };
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import type { TableProps } from "./types";
3
- declare const Table: <T>({ bordered, dataSource, ...props }: TableProps<T>) => React.JSX.Element;
3
+ declare const Table: <T>({ bordered, dataSource, columns: _columns, sortDescriptor, onSortChange, }: TableProps<T>) => React.JSX.Element;
4
4
  export default Table;
@@ -1,30 +1,36 @@
1
1
  import { useReactTable, getCoreRowModel } from '@tanstack/react-table';
2
2
  import React from 'react';
3
3
  import { useColumns, useContextValue } from './hooks.js';
4
- import Header from './header.js';
4
+ import Header from './header/header.js';
5
5
  import Context from './context.js';
6
6
  import Body from './body.js';
7
7
 
8
8
  const Table = ({
9
9
  bordered = false,
10
10
  dataSource = [],
11
- ...props
11
+ columns: _columns = [],
12
+ sortDescriptor,
13
+ onSortChange
12
14
  }) => {
13
- const columns = useColumns([props.columns]);
15
+ const columns = useColumns({
16
+ columns: _columns
17
+ });
14
18
  const table = useReactTable({
15
- columns: columns,
19
+ columns,
16
20
  data: dataSource,
17
21
  getCoreRowModel: getCoreRowModel()
18
22
  });
19
23
  const contextValue = useContextValue({
20
24
  table,
21
- bordered
25
+ bordered,
26
+ sortDescriptor,
27
+ onSortChange
22
28
  });
23
29
  return React.createElement(Context.Provider, {
24
30
  value: contextValue
25
31
  }, React.createElement("table", {
26
32
  ...{
27
- className: "musae-1l2rt3b"
33
+ className: "musae-h8yej3"
28
34
  }
29
35
  }, React.createElement(Header, null), React.createElement(Body, null)));
30
36
  };