@marigold/components 16.1.0 → 17.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/dist/Checkbox-D6DudF_g.mjs +431 -0
- package/dist/Checkbox-DIbAWlSt.cjs +503 -0
- package/dist/index.cjs +1595 -1066
- package/dist/index.d.cts +842 -264
- package/dist/index.d.mts +730 -152
- package/dist/index.mjs +1529 -1014
- package/dist/legacy.cjs +334 -0
- package/dist/legacy.d.cts +60 -0
- package/dist/legacy.d.mts +60 -0
- package/dist/legacy.mjs +333 -0
- package/package.json +50 -36
package/dist/legacy.cjs
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
const require_Checkbox = require('./Checkbox-DIbAWlSt.cjs');
|
|
2
|
+
const require_index = require('./index.cjs');
|
|
3
|
+
let __marigold_system = require("@marigold/system");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
let __react_aria_utils = require("@react-aria/utils");
|
|
7
|
+
let __react_aria_interactions = require("@react-aria/interactions");
|
|
8
|
+
let __react_aria_focus = require("@react-aria/focus");
|
|
9
|
+
let __react_aria_table = require("@react-aria/table");
|
|
10
|
+
let __react_stately_table = require("@react-stately/table");
|
|
11
|
+
|
|
12
|
+
//#region src/legacy/Table/Context.tsx
|
|
13
|
+
const TableContext = (0, react.createContext)({});
|
|
14
|
+
const useTableContext = () => (0, react.useContext)(TableContext);
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/legacy/Table/TableBody.tsx
|
|
18
|
+
const TableBody = ({ children = void 0, className, emptyState }) => {
|
|
19
|
+
const { rowGroupProps } = (0, __react_aria_table.useTableRowGroup)();
|
|
20
|
+
const { state, classNames } = useTableContext();
|
|
21
|
+
if (state.collection.size === 0 && emptyState) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", {
|
|
22
|
+
className,
|
|
23
|
+
"data-rac": true,
|
|
24
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
25
|
+
className: classNames?.row,
|
|
26
|
+
role: "row",
|
|
27
|
+
"data-rac": true,
|
|
28
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
29
|
+
className: classNames?.cell,
|
|
30
|
+
colSpan: state.collection.columnCount,
|
|
31
|
+
role: "rowheader",
|
|
32
|
+
"data-rac": true,
|
|
33
|
+
children: emptyState()
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", {
|
|
38
|
+
...rowGroupProps,
|
|
39
|
+
className,
|
|
40
|
+
"data-rac": true,
|
|
41
|
+
children
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/legacy/Table/TableCell.tsx
|
|
47
|
+
const TableCell = ({ cell, align = "left", alignY = "middle" }) => {
|
|
48
|
+
const ref = (0, react.useRef)(null);
|
|
49
|
+
const { interactive, state, classNames } = useTableContext();
|
|
50
|
+
const disabled = state.disabledKeys.has(cell.parentKey);
|
|
51
|
+
const { gridCellProps } = (0, __react_aria_table.useTableCell)({ node: cell }, state, ref);
|
|
52
|
+
const cellProps = interactive ? gridCellProps : {
|
|
53
|
+
...gridCellProps,
|
|
54
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
55
|
+
onPointerDown: (e) => e.stopPropagation()
|
|
56
|
+
};
|
|
57
|
+
const { focusProps, isFocusVisible } = (0, __react_aria_focus.useFocusRing)();
|
|
58
|
+
const stateProps = (0, __marigold_system.useStateProps)({
|
|
59
|
+
disabled,
|
|
60
|
+
focusVisible: isFocusVisible
|
|
61
|
+
});
|
|
62
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
63
|
+
ref,
|
|
64
|
+
className: classNames?.cell,
|
|
65
|
+
...(0, __react_aria_utils.mergeProps)(cellProps, focusProps),
|
|
66
|
+
...stateProps,
|
|
67
|
+
align,
|
|
68
|
+
valign: alignY,
|
|
69
|
+
"data-rac": true,
|
|
70
|
+
children: cell.rendered
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/legacy/Table/utils.ts
|
|
76
|
+
/**
|
|
77
|
+
* Map `react-aria` props to ours (no "is"-prefix)
|
|
78
|
+
*/
|
|
79
|
+
const mapCheckboxProps = ({ checkboxProps: { isIndeterminate, isSelected, isDisabled, defaultSelected, ...rest } }) => {
|
|
80
|
+
return { checkboxProps: {
|
|
81
|
+
disabled: isDisabled,
|
|
82
|
+
checked: isSelected,
|
|
83
|
+
defaultChecked: defaultSelected,
|
|
84
|
+
indeterminate: isIndeterminate,
|
|
85
|
+
...rest
|
|
86
|
+
} };
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/legacy/Table/TableCheckboxCell.tsx
|
|
91
|
+
const TableCheckboxCell = ({ cell, alignY = "middle" }) => {
|
|
92
|
+
const ref = (0, react.useRef)(null);
|
|
93
|
+
const { state, classNames } = useTableContext();
|
|
94
|
+
const disabled = state.disabledKeys.has(cell.parentKey);
|
|
95
|
+
const { gridCellProps } = (0, __react_aria_table.useTableCell)({ node: cell }, state, ref);
|
|
96
|
+
const { checkboxProps } = mapCheckboxProps((0, __react_aria_table.useTableSelectionCheckbox)({ key: cell.parentKey }, state));
|
|
97
|
+
const { focusProps, isFocusVisible } = (0, __react_aria_focus.useFocusRing)();
|
|
98
|
+
const stateProps = (0, __marigold_system.useStateProps)({
|
|
99
|
+
disabled,
|
|
100
|
+
focusVisible: isFocusVisible
|
|
101
|
+
});
|
|
102
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
103
|
+
ref,
|
|
104
|
+
className: (0, __marigold_system.cn)("leading-none", classNames?.cell),
|
|
105
|
+
...(0, __react_aria_utils.mergeProps)(gridCellProps, focusProps),
|
|
106
|
+
...stateProps,
|
|
107
|
+
valign: alignY,
|
|
108
|
+
"data-rac": true,
|
|
109
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Checkbox._Checkbox, { ...checkboxProps })
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/icons/SortDown.tsx
|
|
115
|
+
const SortDown = ({ size = 24, className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__marigold_system.SVG, {
|
|
116
|
+
width: size,
|
|
117
|
+
height: size,
|
|
118
|
+
viewBox: "0 0 24 24",
|
|
119
|
+
className: (0, __marigold_system.cn)("flex-none shrink-0 fill-current", className),
|
|
120
|
+
...props,
|
|
121
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M17.3962 10.0496L12.5042 14.9416C12.3731 15.0727 12.1984 15.1492 12.0128 15.1492C11.8272 15.1492 11.6524 15.0727 11.5214 14.9416L6.62934 10.0496C6.49827 9.91854 6.42188 9.7439 6.42188 9.55816C6.42188 9.17606 6.73856 8.85938 7.12078 8.85938H16.9048C17.287 8.85938 17.6037 9.17606 17.6037 9.55816C17.6037 9.7439 17.5273 9.91854 17.3962 10.0496Z" })
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/icons/SortUp.tsx
|
|
126
|
+
const SortUp = ({ size = 24, className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__marigold_system.SVG, {
|
|
127
|
+
width: size,
|
|
128
|
+
height: size,
|
|
129
|
+
viewBox: "0 0 24 24",
|
|
130
|
+
className: (0, __marigold_system.cn)("flex-none shrink-0 fill-current", className),
|
|
131
|
+
...props,
|
|
132
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M16.9048 15.1491H7.12078C6.73856 15.1491 6.42188 14.8324 6.42188 14.4503C6.42188 14.2645 6.49827 14.0899 6.62934 13.9588L11.5214 9.06684C11.6524 8.93577 11.8272 8.85938 12.0128 8.85938C12.1984 8.85938 12.3731 8.93577 12.5042 9.06684L17.3962 13.9588C17.5273 14.0899 17.6037 14.2645 17.6037 14.4503C17.6037 14.8324 17.287 15.1491 16.9048 15.1491Z" })
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/legacy/Table/TableColumnHeader.tsx
|
|
137
|
+
const TableColumnHeader = ({ column, width = "auto", align = "left" }) => {
|
|
138
|
+
const ref = (0, react.useRef)(null);
|
|
139
|
+
const { state, classNames } = useTableContext();
|
|
140
|
+
const { columnHeaderProps } = (0, __react_aria_table.useTableColumnHeader)({ node: column }, state, ref);
|
|
141
|
+
const { hoverProps, isHovered } = (0, __react_aria_interactions.useHover)({});
|
|
142
|
+
const { focusProps, isFocusVisible } = (0, __react_aria_focus.useFocusRing)();
|
|
143
|
+
const stateProps = (0, __marigold_system.useStateProps)({
|
|
144
|
+
hover: isHovered,
|
|
145
|
+
focusVisible: isFocusVisible
|
|
146
|
+
});
|
|
147
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", {
|
|
148
|
+
colSpan: column.colspan,
|
|
149
|
+
ref,
|
|
150
|
+
className: (0, __marigold_system.cn)("whitespace-nowrap data-[react-aria-pressable=\"true\"]:cursor-pointer", __marigold_system.width[width], classNames?.header),
|
|
151
|
+
...(0, __react_aria_utils.mergeProps)(columnHeaderProps, hoverProps, focusProps),
|
|
152
|
+
...stateProps,
|
|
153
|
+
align,
|
|
154
|
+
"data-rac": true,
|
|
155
|
+
children: [column.rendered, column.props.allowsSorting && (state.sortDescriptor?.column === column.key ? state.sortDescriptor?.direction === "ascending" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SortUp, { className: "inline-block" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SortDown, { className: "inline-block" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
156
|
+
className: "hidden",
|
|
157
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SortDown, { className: "inline-block" })
|
|
158
|
+
}))]
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/legacy/Table/TableHeader.tsx
|
|
164
|
+
const TableHeader = ({ stickyHeader, children }) => {
|
|
165
|
+
const { rowGroupProps } = (0, __react_aria_table.useTableRowGroup)();
|
|
166
|
+
const { classNames } = useTableContext();
|
|
167
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", {
|
|
168
|
+
...rowGroupProps,
|
|
169
|
+
className: (0, __marigold_system.cn)(classNames?.thead, stickyHeader ? "sticky [&_th]:sticky [&_th]:top-0" : ""),
|
|
170
|
+
"data-rac": true,
|
|
171
|
+
children
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/legacy/Table/TableHeaderRow.tsx
|
|
177
|
+
const TableHeaderRow = ({ item, className, children }) => {
|
|
178
|
+
const { state } = useTableContext();
|
|
179
|
+
const ref = (0, react.useRef)(null);
|
|
180
|
+
const { rowProps } = (0, __react_aria_table.useTableHeaderRow)({ node: item }, state, ref);
|
|
181
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
182
|
+
...rowProps,
|
|
183
|
+
className,
|
|
184
|
+
ref,
|
|
185
|
+
"data-rac": true,
|
|
186
|
+
children
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/legacy/Table/TableRow.tsx
|
|
192
|
+
const TableRow = ({ children, row }) => {
|
|
193
|
+
const ref = (0, react.useRef)(null);
|
|
194
|
+
const { interactive, state, ...ctx } = useTableContext();
|
|
195
|
+
const { variant, size } = row.props;
|
|
196
|
+
const classNames = (0, __marigold_system.useClassNames)({
|
|
197
|
+
component: "LegacyTable",
|
|
198
|
+
variant: variant || ctx.variant,
|
|
199
|
+
size: size || ctx.size
|
|
200
|
+
});
|
|
201
|
+
const { rowProps, isPressed } = (0, __react_aria_table.useTableRow)({ node: row }, state, ref);
|
|
202
|
+
const disabled = state.disabledKeys.has(row.key);
|
|
203
|
+
const selected = state.selectionManager.isSelected(row.key);
|
|
204
|
+
const { focusProps, isFocusVisible } = (0, __react_aria_focus.useFocusRing)();
|
|
205
|
+
const { hoverProps, isHovered } = (0, __react_aria_interactions.useHover)({ isDisabled: disabled || !interactive });
|
|
206
|
+
const stateProps = (0, __marigold_system.useStateProps)({
|
|
207
|
+
disabled,
|
|
208
|
+
selected,
|
|
209
|
+
hover: isHovered,
|
|
210
|
+
focusVisible: isFocusVisible,
|
|
211
|
+
active: isPressed
|
|
212
|
+
});
|
|
213
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
214
|
+
ref,
|
|
215
|
+
className: (0, __marigold_system.cn)([!interactive ? "cursor-text" : disabled ? "cursor-default" : "cursor-pointer"], classNames?.row),
|
|
216
|
+
...(0, __react_aria_utils.mergeProps)(rowProps, focusProps, hoverProps),
|
|
217
|
+
...stateProps,
|
|
218
|
+
"data-rac": true,
|
|
219
|
+
children
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/legacy/Table/TableSelectAllCell.tsx
|
|
225
|
+
const TableSelectAllCell = ({ column, width = "auto", align = "left" }) => {
|
|
226
|
+
const ref = (0, react.useRef)(null);
|
|
227
|
+
const { state, classNames } = useTableContext();
|
|
228
|
+
const { columnHeaderProps } = (0, __react_aria_table.useTableColumnHeader)({ node: column }, state, ref);
|
|
229
|
+
const { checkboxProps } = mapCheckboxProps((0, __react_aria_table.useTableSelectAllCheckbox)(state));
|
|
230
|
+
const { hoverProps, isHovered } = (0, __react_aria_interactions.useHover)({});
|
|
231
|
+
const { focusProps, isFocusVisible } = (0, __react_aria_focus.useFocusRing)();
|
|
232
|
+
const stateProps = (0, __marigold_system.useStateProps)({
|
|
233
|
+
hover: isHovered,
|
|
234
|
+
focusVisible: isFocusVisible
|
|
235
|
+
});
|
|
236
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
237
|
+
ref,
|
|
238
|
+
className: (0, __marigold_system.cn)(__marigold_system.width[width], ["leading-none"], classNames?.header),
|
|
239
|
+
...(0, __react_aria_utils.mergeProps)(columnHeaderProps, hoverProps, focusProps),
|
|
240
|
+
...stateProps,
|
|
241
|
+
align,
|
|
242
|
+
"data-rac": true,
|
|
243
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Checkbox._Checkbox, { ...checkboxProps })
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/legacy/Table/Table.tsx
|
|
249
|
+
const Table = ({ variant, size, stretch = false, selectionMode = "none", disableKeyboardNavigation = false, stickyHeader, emptyState, alignY = "middle", ...props }) => {
|
|
250
|
+
const interactive = selectionMode !== "none";
|
|
251
|
+
const tableRef = (0, react.useRef)(null);
|
|
252
|
+
const state = (0, __react_stately_table.useTableState)({
|
|
253
|
+
...props,
|
|
254
|
+
selectionMode,
|
|
255
|
+
showSelectionCheckboxes: selectionMode === "multiple" && props.selectionBehavior !== "replace"
|
|
256
|
+
});
|
|
257
|
+
/**
|
|
258
|
+
* Behavior is a bit flacky with the table when using a keyboard
|
|
259
|
+
* so we test here for undefined here to be save.
|
|
260
|
+
*/
|
|
261
|
+
if (disableKeyboardNavigation !== void 0) state.isKeyboardNavigationDisabled = disableKeyboardNavigation;
|
|
262
|
+
const { gridProps } = (0, __react_aria_table.useTable)(props, state, tableRef);
|
|
263
|
+
const classNames = (0, __marigold_system.useClassNames)({
|
|
264
|
+
component: "LegacyTable",
|
|
265
|
+
variant,
|
|
266
|
+
size
|
|
267
|
+
});
|
|
268
|
+
const { collection } = state;
|
|
269
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableContext.Provider, {
|
|
270
|
+
value: {
|
|
271
|
+
state,
|
|
272
|
+
interactive,
|
|
273
|
+
classNames,
|
|
274
|
+
variant,
|
|
275
|
+
size
|
|
276
|
+
},
|
|
277
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
278
|
+
ref: tableRef,
|
|
279
|
+
"data-rac": true,
|
|
280
|
+
className: (0, __marigold_system.cn)(
|
|
281
|
+
"group/table border-collapse",
|
|
282
|
+
/**
|
|
283
|
+
* Prevents wide tables from causing overlays to become scrollable on
|
|
284
|
+
* small screens, ensuring overlays remain fixed as intended.
|
|
285
|
+
*/
|
|
286
|
+
"max-[600px]:in-aria-hidden:overflow-hidden",
|
|
287
|
+
stretch ? "table w-full" : "block",
|
|
288
|
+
classNames.table
|
|
289
|
+
),
|
|
290
|
+
...gridProps,
|
|
291
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableHeader, {
|
|
292
|
+
stickyHeader,
|
|
293
|
+
children: collection.headerRows.map((headerRow) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableHeaderRow, {
|
|
294
|
+
item: headerRow,
|
|
295
|
+
className: classNames.headerRow,
|
|
296
|
+
children: [...collection.getChildren(headerRow.key)].map((column) => column.props?.isSelectionCell ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableSelectAllCell, {
|
|
297
|
+
width: column.props?.width,
|
|
298
|
+
column,
|
|
299
|
+
align: column.props?.align
|
|
300
|
+
}, column.key) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableColumnHeader, {
|
|
301
|
+
width: column.props?.width,
|
|
302
|
+
column,
|
|
303
|
+
align: column.props?.align
|
|
304
|
+
}, column.key))
|
|
305
|
+
}, headerRow.key))
|
|
306
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableBody, {
|
|
307
|
+
className: classNames.body,
|
|
308
|
+
emptyState,
|
|
309
|
+
children: [...collection.rows.map((row) => row.type === "item" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableRow, {
|
|
310
|
+
row,
|
|
311
|
+
children: [...collection.getChildren(row.key)].map((cell, index) => {
|
|
312
|
+
const currentColumn = collection.columns[index];
|
|
313
|
+
return cell.props?.isSelectionCell ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableCheckboxCell, {
|
|
314
|
+
cell,
|
|
315
|
+
alignY
|
|
316
|
+
}, cell.key) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableCell, {
|
|
317
|
+
align: currentColumn.props?.align,
|
|
318
|
+
alignY,
|
|
319
|
+
cell
|
|
320
|
+
}, cell.key);
|
|
321
|
+
})
|
|
322
|
+
}, row.key))]
|
|
323
|
+
})]
|
|
324
|
+
})
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
Table.Body = __react_stately_table.TableBody;
|
|
328
|
+
Table.Cell = __react_stately_table.Cell;
|
|
329
|
+
Table.Column = __react_stately_table.Column;
|
|
330
|
+
Table.Header = __react_stately_table.TableHeader;
|
|
331
|
+
Table.Row = __react_stately_table.Row;
|
|
332
|
+
|
|
333
|
+
//#endregion
|
|
334
|
+
exports.Table = Table;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { WidthProp } from "@marigold/system";
|
|
2
|
+
import { JSX, ReactNode } from "react";
|
|
3
|
+
import { AriaTableProps } from "@react-aria/table";
|
|
4
|
+
import { Cell, ColumnProps as ColumnProps$1, RowProps as RowProps$1, TableBody, TableHeader, TableStateProps } from "@react-stately/table";
|
|
5
|
+
|
|
6
|
+
//#region src/legacy/Table/Table.d.ts
|
|
7
|
+
interface TableProps extends Pick<AriaTableProps, 'focusMode' | 'onRowAction' | 'onCellAction'>, Omit<TableStateProps<object>, 'showSelectionCheckboxes' | 'showDragButtons' | 'allowDuplicateSelectionEvents'> {
|
|
8
|
+
variant?: 'grid' | 'default' | 'muted' | (string & {});
|
|
9
|
+
size?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Stretch the table to fill the container.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
stretch?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Make the column sticky to the top of the table.
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
stickyHeader?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Disable keyboard navigation. Use if you have input fields in your table. Be aware that this is bad for accessibility.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
disableKeyboardNavigation?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Content to display when there are no rows in the table.
|
|
27
|
+
*/
|
|
28
|
+
emptyState?: () => ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Control the vertical alignment of table content.
|
|
31
|
+
* @default middle
|
|
32
|
+
*/
|
|
33
|
+
alignY?: Exclude<JSX.IntrinsicElements['td']['valign'], 'baseline' | 'sub' | 'super' | 'bottom'>;
|
|
34
|
+
}
|
|
35
|
+
declare const Table: Table;
|
|
36
|
+
interface RowProps extends RowProps$1<any> {
|
|
37
|
+
variant?: 'default' | 'grid' | 'admin' | 'master' | (string & {});
|
|
38
|
+
size?: string;
|
|
39
|
+
}
|
|
40
|
+
interface ColumnProps extends Omit<ColumnProps$1<any>, 'width'>, WidthProp {
|
|
41
|
+
/**
|
|
42
|
+
* Control the alignment of Column.
|
|
43
|
+
* @default left
|
|
44
|
+
*/
|
|
45
|
+
align?: Exclude<JSX.IntrinsicElements['td']['align'], 'char'>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Necessary since TypeScript can not infer the
|
|
49
|
+
* types of the @react-stately components.
|
|
50
|
+
*/
|
|
51
|
+
interface Table {
|
|
52
|
+
(props: TableProps): JSX.Element;
|
|
53
|
+
Body: typeof TableBody;
|
|
54
|
+
Cell: typeof Cell;
|
|
55
|
+
Header: typeof TableHeader;
|
|
56
|
+
Column: (props: ColumnProps) => JSX.Element;
|
|
57
|
+
Row: (props: RowProps) => JSX.Element;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { type ColumnProps, type RowProps, Table, type TableProps };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { WidthProp } from "@marigold/system";
|
|
2
|
+
import { JSX, ReactNode } from "react";
|
|
3
|
+
import { AriaTableProps } from "@react-aria/table";
|
|
4
|
+
import { Cell, ColumnProps as ColumnProps$1, RowProps as RowProps$1, TableBody, TableHeader, TableStateProps } from "@react-stately/table";
|
|
5
|
+
|
|
6
|
+
//#region src/legacy/Table/Table.d.ts
|
|
7
|
+
interface TableProps extends Pick<AriaTableProps, 'focusMode' | 'onRowAction' | 'onCellAction'>, Omit<TableStateProps<object>, 'showSelectionCheckboxes' | 'showDragButtons' | 'allowDuplicateSelectionEvents'> {
|
|
8
|
+
variant?: 'grid' | 'default' | 'muted' | (string & {});
|
|
9
|
+
size?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Stretch the table to fill the container.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
stretch?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Make the column sticky to the top of the table.
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
stickyHeader?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Disable keyboard navigation. Use if you have input fields in your table. Be aware that this is bad for accessibility.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
disableKeyboardNavigation?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Content to display when there are no rows in the table.
|
|
27
|
+
*/
|
|
28
|
+
emptyState?: () => ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Control the vertical alignment of table content.
|
|
31
|
+
* @default middle
|
|
32
|
+
*/
|
|
33
|
+
alignY?: Exclude<JSX.IntrinsicElements['td']['valign'], 'baseline' | 'sub' | 'super' | 'bottom'>;
|
|
34
|
+
}
|
|
35
|
+
declare const Table: Table;
|
|
36
|
+
interface RowProps extends RowProps$1<any> {
|
|
37
|
+
variant?: 'default' | 'grid' | 'admin' | 'master' | (string & {});
|
|
38
|
+
size?: string;
|
|
39
|
+
}
|
|
40
|
+
interface ColumnProps extends Omit<ColumnProps$1<any>, 'width'>, WidthProp {
|
|
41
|
+
/**
|
|
42
|
+
* Control the alignment of Column.
|
|
43
|
+
* @default left
|
|
44
|
+
*/
|
|
45
|
+
align?: Exclude<JSX.IntrinsicElements['td']['align'], 'char'>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Necessary since TypeScript can not infer the
|
|
49
|
+
* types of the @react-stately components.
|
|
50
|
+
*/
|
|
51
|
+
interface Table {
|
|
52
|
+
(props: TableProps): JSX.Element;
|
|
53
|
+
Body: typeof TableBody;
|
|
54
|
+
Cell: typeof Cell;
|
|
55
|
+
Header: typeof TableHeader;
|
|
56
|
+
Column: (props: ColumnProps) => JSX.Element;
|
|
57
|
+
Row: (props: RowProps) => JSX.Element;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { type ColumnProps, type RowProps, Table, type TableProps };
|