@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.
@@ -0,0 +1,333 @@
1
+ import { t as _Checkbox } from "./Checkbox-D6DudF_g.mjs";
2
+ import { SVG, cn, useClassNames, useStateProps, width } from "@marigold/system";
3
+ import { createContext, useContext, useRef } from "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { mergeProps } from "@react-aria/utils";
6
+ import { useHover } from "@react-aria/interactions";
7
+ import { useFocusRing } from "@react-aria/focus";
8
+ import { useTable, useTableCell, useTableColumnHeader, useTableHeaderRow, useTableRow, useTableRowGroup, useTableSelectAllCheckbox, useTableSelectionCheckbox } from "@react-aria/table";
9
+ import { Cell, Column, Row, TableBody, TableHeader, useTableState } from "@react-stately/table";
10
+
11
+ //#region src/legacy/Table/Context.tsx
12
+ const TableContext = createContext({});
13
+ const useTableContext = () => useContext(TableContext);
14
+
15
+ //#endregion
16
+ //#region src/legacy/Table/TableBody.tsx
17
+ const TableBody$1 = ({ children = void 0, className, emptyState }) => {
18
+ const { rowGroupProps } = useTableRowGroup();
19
+ const { state, classNames } = useTableContext();
20
+ if (state.collection.size === 0 && emptyState) return /* @__PURE__ */ jsx("tbody", {
21
+ className,
22
+ "data-rac": true,
23
+ children: /* @__PURE__ */ jsx("tr", {
24
+ className: classNames?.row,
25
+ role: "row",
26
+ "data-rac": true,
27
+ children: /* @__PURE__ */ jsx("td", {
28
+ className: classNames?.cell,
29
+ colSpan: state.collection.columnCount,
30
+ role: "rowheader",
31
+ "data-rac": true,
32
+ children: emptyState()
33
+ })
34
+ })
35
+ });
36
+ return /* @__PURE__ */ jsx("tbody", {
37
+ ...rowGroupProps,
38
+ className,
39
+ "data-rac": true,
40
+ children
41
+ });
42
+ };
43
+
44
+ //#endregion
45
+ //#region src/legacy/Table/TableCell.tsx
46
+ const TableCell = ({ cell, align = "left", alignY = "middle" }) => {
47
+ const ref = useRef(null);
48
+ const { interactive, state, classNames } = useTableContext();
49
+ const disabled = state.disabledKeys.has(cell.parentKey);
50
+ const { gridCellProps } = useTableCell({ node: cell }, state, ref);
51
+ const cellProps = interactive ? gridCellProps : {
52
+ ...gridCellProps,
53
+ onMouseDown: (e) => e.stopPropagation(),
54
+ onPointerDown: (e) => e.stopPropagation()
55
+ };
56
+ const { focusProps, isFocusVisible } = useFocusRing();
57
+ const stateProps = useStateProps({
58
+ disabled,
59
+ focusVisible: isFocusVisible
60
+ });
61
+ return /* @__PURE__ */ jsx("td", {
62
+ ref,
63
+ className: classNames?.cell,
64
+ ...mergeProps(cellProps, focusProps),
65
+ ...stateProps,
66
+ align,
67
+ valign: alignY,
68
+ "data-rac": true,
69
+ children: cell.rendered
70
+ });
71
+ };
72
+
73
+ //#endregion
74
+ //#region src/legacy/Table/utils.ts
75
+ /**
76
+ * Map `react-aria` props to ours (no "is"-prefix)
77
+ */
78
+ const mapCheckboxProps = ({ checkboxProps: { isIndeterminate, isSelected, isDisabled, defaultSelected, ...rest } }) => {
79
+ return { checkboxProps: {
80
+ disabled: isDisabled,
81
+ checked: isSelected,
82
+ defaultChecked: defaultSelected,
83
+ indeterminate: isIndeterminate,
84
+ ...rest
85
+ } };
86
+ };
87
+
88
+ //#endregion
89
+ //#region src/legacy/Table/TableCheckboxCell.tsx
90
+ const TableCheckboxCell = ({ cell, alignY = "middle" }) => {
91
+ const ref = useRef(null);
92
+ const { state, classNames } = useTableContext();
93
+ const disabled = state.disabledKeys.has(cell.parentKey);
94
+ const { gridCellProps } = useTableCell({ node: cell }, state, ref);
95
+ const { checkboxProps } = mapCheckboxProps(useTableSelectionCheckbox({ key: cell.parentKey }, state));
96
+ const { focusProps, isFocusVisible } = useFocusRing();
97
+ const stateProps = useStateProps({
98
+ disabled,
99
+ focusVisible: isFocusVisible
100
+ });
101
+ return /* @__PURE__ */ jsx("td", {
102
+ ref,
103
+ className: cn("leading-none", classNames?.cell),
104
+ ...mergeProps(gridCellProps, focusProps),
105
+ ...stateProps,
106
+ valign: alignY,
107
+ "data-rac": true,
108
+ children: /* @__PURE__ */ jsx(_Checkbox, { ...checkboxProps })
109
+ });
110
+ };
111
+
112
+ //#endregion
113
+ //#region src/icons/SortDown.tsx
114
+ const SortDown = ({ size = 24, className, ...props }) => /* @__PURE__ */ jsx(SVG, {
115
+ width: size,
116
+ height: size,
117
+ viewBox: "0 0 24 24",
118
+ className: cn("flex-none shrink-0 fill-current", className),
119
+ ...props,
120
+ children: /* @__PURE__ */ 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" })
121
+ });
122
+
123
+ //#endregion
124
+ //#region src/icons/SortUp.tsx
125
+ const SortUp = ({ size = 24, className, ...props }) => /* @__PURE__ */ jsx(SVG, {
126
+ width: size,
127
+ height: size,
128
+ viewBox: "0 0 24 24",
129
+ className: cn("flex-none shrink-0 fill-current", className),
130
+ ...props,
131
+ children: /* @__PURE__ */ 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" })
132
+ });
133
+
134
+ //#endregion
135
+ //#region src/legacy/Table/TableColumnHeader.tsx
136
+ const TableColumnHeader = ({ column, width: width$1 = "auto", align = "left" }) => {
137
+ const ref = useRef(null);
138
+ const { state, classNames } = useTableContext();
139
+ const { columnHeaderProps } = useTableColumnHeader({ node: column }, state, ref);
140
+ const { hoverProps, isHovered } = useHover({});
141
+ const { focusProps, isFocusVisible } = useFocusRing();
142
+ const stateProps = useStateProps({
143
+ hover: isHovered,
144
+ focusVisible: isFocusVisible
145
+ });
146
+ return /* @__PURE__ */ jsxs("th", {
147
+ colSpan: column.colspan,
148
+ ref,
149
+ className: cn("whitespace-nowrap data-[react-aria-pressable=\"true\"]:cursor-pointer", width[width$1], classNames?.header),
150
+ ...mergeProps(columnHeaderProps, hoverProps, focusProps),
151
+ ...stateProps,
152
+ align,
153
+ "data-rac": true,
154
+ children: [column.rendered, column.props.allowsSorting && (state.sortDescriptor?.column === column.key ? state.sortDescriptor?.direction === "ascending" ? /* @__PURE__ */ jsx(SortUp, { className: "inline-block" }) : /* @__PURE__ */ jsx(SortDown, { className: "inline-block" }) : /* @__PURE__ */ jsx("span", {
155
+ className: "hidden",
156
+ children: /* @__PURE__ */ jsx(SortDown, { className: "inline-block" })
157
+ }))]
158
+ });
159
+ };
160
+
161
+ //#endregion
162
+ //#region src/legacy/Table/TableHeader.tsx
163
+ const TableHeader$1 = ({ stickyHeader, children }) => {
164
+ const { rowGroupProps } = useTableRowGroup();
165
+ const { classNames } = useTableContext();
166
+ return /* @__PURE__ */ jsx("thead", {
167
+ ...rowGroupProps,
168
+ className: cn(classNames?.thead, stickyHeader ? "sticky [&_th]:sticky [&_th]:top-0" : ""),
169
+ "data-rac": true,
170
+ children
171
+ });
172
+ };
173
+
174
+ //#endregion
175
+ //#region src/legacy/Table/TableHeaderRow.tsx
176
+ const TableHeaderRow = ({ item, className, children }) => {
177
+ const { state } = useTableContext();
178
+ const ref = useRef(null);
179
+ const { rowProps } = useTableHeaderRow({ node: item }, state, ref);
180
+ return /* @__PURE__ */ jsx("tr", {
181
+ ...rowProps,
182
+ className,
183
+ ref,
184
+ "data-rac": true,
185
+ children
186
+ });
187
+ };
188
+
189
+ //#endregion
190
+ //#region src/legacy/Table/TableRow.tsx
191
+ const TableRow = ({ children, row }) => {
192
+ const ref = useRef(null);
193
+ const { interactive, state, ...ctx } = useTableContext();
194
+ const { variant, size } = row.props;
195
+ const classNames = useClassNames({
196
+ component: "LegacyTable",
197
+ variant: variant || ctx.variant,
198
+ size: size || ctx.size
199
+ });
200
+ const { rowProps, isPressed } = useTableRow({ node: row }, state, ref);
201
+ const disabled = state.disabledKeys.has(row.key);
202
+ const selected = state.selectionManager.isSelected(row.key);
203
+ const { focusProps, isFocusVisible } = useFocusRing();
204
+ const { hoverProps, isHovered } = useHover({ isDisabled: disabled || !interactive });
205
+ const stateProps = useStateProps({
206
+ disabled,
207
+ selected,
208
+ hover: isHovered,
209
+ focusVisible: isFocusVisible,
210
+ active: isPressed
211
+ });
212
+ return /* @__PURE__ */ jsx("tr", {
213
+ ref,
214
+ className: cn([!interactive ? "cursor-text" : disabled ? "cursor-default" : "cursor-pointer"], classNames?.row),
215
+ ...mergeProps(rowProps, focusProps, hoverProps),
216
+ ...stateProps,
217
+ "data-rac": true,
218
+ children
219
+ });
220
+ };
221
+
222
+ //#endregion
223
+ //#region src/legacy/Table/TableSelectAllCell.tsx
224
+ const TableSelectAllCell = ({ column, width: width$1 = "auto", align = "left" }) => {
225
+ const ref = useRef(null);
226
+ const { state, classNames } = useTableContext();
227
+ const { columnHeaderProps } = useTableColumnHeader({ node: column }, state, ref);
228
+ const { checkboxProps } = mapCheckboxProps(useTableSelectAllCheckbox(state));
229
+ const { hoverProps, isHovered } = useHover({});
230
+ const { focusProps, isFocusVisible } = useFocusRing();
231
+ const stateProps = useStateProps({
232
+ hover: isHovered,
233
+ focusVisible: isFocusVisible
234
+ });
235
+ return /* @__PURE__ */ jsx("th", {
236
+ ref,
237
+ className: cn(width[width$1], ["leading-none"], classNames?.header),
238
+ ...mergeProps(columnHeaderProps, hoverProps, focusProps),
239
+ ...stateProps,
240
+ align,
241
+ "data-rac": true,
242
+ children: /* @__PURE__ */ jsx(_Checkbox, { ...checkboxProps })
243
+ });
244
+ };
245
+
246
+ //#endregion
247
+ //#region src/legacy/Table/Table.tsx
248
+ const Table = ({ variant, size, stretch = false, selectionMode = "none", disableKeyboardNavigation = false, stickyHeader, emptyState, alignY = "middle", ...props }) => {
249
+ const interactive = selectionMode !== "none";
250
+ const tableRef = useRef(null);
251
+ const state = useTableState({
252
+ ...props,
253
+ selectionMode,
254
+ showSelectionCheckboxes: selectionMode === "multiple" && props.selectionBehavior !== "replace"
255
+ });
256
+ /**
257
+ * Behavior is a bit flacky with the table when using a keyboard
258
+ * so we test here for undefined here to be save.
259
+ */
260
+ if (disableKeyboardNavigation !== void 0) state.isKeyboardNavigationDisabled = disableKeyboardNavigation;
261
+ const { gridProps } = useTable(props, state, tableRef);
262
+ const classNames = useClassNames({
263
+ component: "LegacyTable",
264
+ variant,
265
+ size
266
+ });
267
+ const { collection } = state;
268
+ return /* @__PURE__ */ jsx(TableContext.Provider, {
269
+ value: {
270
+ state,
271
+ interactive,
272
+ classNames,
273
+ variant,
274
+ size
275
+ },
276
+ children: /* @__PURE__ */ jsxs("table", {
277
+ ref: tableRef,
278
+ "data-rac": true,
279
+ className: cn(
280
+ "group/table border-collapse",
281
+ /**
282
+ * Prevents wide tables from causing overlays to become scrollable on
283
+ * small screens, ensuring overlays remain fixed as intended.
284
+ */
285
+ "max-[600px]:in-aria-hidden:overflow-hidden",
286
+ stretch ? "table w-full" : "block",
287
+ classNames.table
288
+ ),
289
+ ...gridProps,
290
+ children: [/* @__PURE__ */ jsx(TableHeader$1, {
291
+ stickyHeader,
292
+ children: collection.headerRows.map((headerRow) => /* @__PURE__ */ jsx(TableHeaderRow, {
293
+ item: headerRow,
294
+ className: classNames.headerRow,
295
+ children: [...collection.getChildren(headerRow.key)].map((column) => column.props?.isSelectionCell ? /* @__PURE__ */ jsx(TableSelectAllCell, {
296
+ width: column.props?.width,
297
+ column,
298
+ align: column.props?.align
299
+ }, column.key) : /* @__PURE__ */ jsx(TableColumnHeader, {
300
+ width: column.props?.width,
301
+ column,
302
+ align: column.props?.align
303
+ }, column.key))
304
+ }, headerRow.key))
305
+ }), /* @__PURE__ */ jsx(TableBody$1, {
306
+ className: classNames.body,
307
+ emptyState,
308
+ children: [...collection.rows.map((row) => row.type === "item" && /* @__PURE__ */ jsx(TableRow, {
309
+ row,
310
+ children: [...collection.getChildren(row.key)].map((cell, index) => {
311
+ const currentColumn = collection.columns[index];
312
+ return cell.props?.isSelectionCell ? /* @__PURE__ */ jsx(TableCheckboxCell, {
313
+ cell,
314
+ alignY
315
+ }, cell.key) : /* @__PURE__ */ jsx(TableCell, {
316
+ align: currentColumn.props?.align,
317
+ alignY,
318
+ cell
319
+ }, cell.key);
320
+ })
321
+ }, row.key))]
322
+ })]
323
+ })
324
+ });
325
+ };
326
+ Table.Body = TableBody;
327
+ Table.Cell = Cell;
328
+ Table.Column = Column;
329
+ Table.Header = TableHeader;
330
+ Table.Row = Row;
331
+
332
+ //#endregion
333
+ export { Table };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marigold/components",
3
- "version": "16.1.0",
3
+ "version": "17.0.0",
4
4
  "description": "Components for the Marigold Design System",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -10,17 +10,29 @@
10
10
  "design system",
11
11
  "react"
12
12
  ],
13
- "main": "./dist/index.js",
13
+ "main": "./dist/index.cjs",
14
14
  "module": "./dist/index.mjs",
15
- "types": "./dist/index.d.ts",
15
+ "types": "./dist/index.d.mts",
16
16
  "exports": {
17
17
  ".": {
18
- "require": "./dist/index.js",
19
- "import": "./dist/index.mjs"
18
+ "import": {
19
+ "types": "./dist/index.d.mts",
20
+ "default": "./dist/index.mjs"
21
+ },
22
+ "require": {
23
+ "types": "./dist/index.d.cts",
24
+ "default": "./dist/index.cjs"
25
+ }
20
26
  },
21
- "./*": {
22
- "require": "./dist/*.js",
23
- "import": "./dist/*.mjs"
27
+ "./legacy": {
28
+ "import": {
29
+ "types": "./dist/legacy.d.mts",
30
+ "default": "./dist/legacy.mjs"
31
+ },
32
+ "require": {
33
+ "types": "./dist/legacy.d.cts",
34
+ "default": "./dist/legacy.cjs"
35
+ }
24
36
  }
25
37
  },
26
38
  "sideEffects": false,
@@ -33,29 +45,31 @@
33
45
  "directory": "packages/components"
34
46
  },
35
47
  "dependencies": {
36
- "@internationalized/date": "^3.10.0",
37
- "@react-aria/button": "^3.14.2",
38
- "@react-aria/calendar": "^3.9.2",
39
- "@react-aria/focus": "^3.21.2",
40
- "@react-aria/i18n": "^3.12.13",
41
- "@react-aria/interactions": "^3.25.6",
42
- "@react-aria/label": "^3.7.22",
43
- "@react-aria/landmark": "^3.0.7",
44
- "@react-aria/overlays": "^3.30.0",
45
- "@react-aria/selection": "^3.26.0",
48
+ "@internationalized/date": "^3.11.0",
49
+ "@react-aria/button": "^3.14.4",
50
+ "@react-aria/calendar": "^3.9.4",
51
+ "@react-aria/collections": "3.0.2",
52
+ "@react-aria/focus": "^3.21.4",
53
+ "@react-aria/i18n": "^3.12.15",
54
+ "@react-aria/interactions": "^3.27.0",
55
+ "@react-aria/label": "^3.7.24",
56
+ "@react-aria/landmark": "^3.0.9",
57
+ "@react-aria/overlays": "^3.31.1",
58
+ "@react-aria/selection": "^3.27.1",
46
59
  "@react-aria/ssr": "^3.9.10",
47
- "@react-aria/table": "^3.17.8",
48
- "@react-aria/utils": "^3.31.0",
49
- "@react-aria/visually-hidden": "^3.8.28",
50
- "@react-stately/collections": "^3.12.8",
51
- "@react-stately/data": "^3.14.1",
52
- "@react-stately/table": "^3.15.1",
53
- "@react-stately/tree": "^3.9.3",
54
- "@react-types/shared": "^3.32.1",
55
- "@react-types/table": "^3.13.4",
56
- "react-aria-components": "^1.13.0",
57
- "react-stately": "^3.42.0",
58
- "@marigold/system": "16.1.0",
60
+ "@react-aria/table": "^3.17.10",
61
+ "@react-aria/utils": "^3.33.0",
62
+ "@react-aria/visually-hidden": "^3.8.30",
63
+ "@react-stately/collections": "^3.12.9",
64
+ "@react-stately/data": "^3.15.1",
65
+ "@react-stately/table": "^3.15.3",
66
+ "@react-stately/tree": "^3.9.5",
67
+ "@react-types/shared": "^3.33.0",
68
+ "@react-types/table": "^3.13.5",
69
+ "motion": "12.23.26",
70
+ "react-aria-components": "^1.15.0",
71
+ "react-stately": "^3.44.0",
72
+ "@marigold/system": "17.0.0",
59
73
  "@marigold/types": "1.4.0"
60
74
  },
61
75
  "peerDependencies": {
@@ -63,17 +77,17 @@
63
77
  "react-dom": ">=17.0.0"
64
78
  },
65
79
  "devDependencies": {
66
- "@types/react": "19.2.2",
80
+ "@types/react": "19.2.7",
67
81
  "lucide-react": "0.555.0",
68
- "react": "19.2.0",
69
- "react-dom": "19.2.0",
82
+ "react": "19.2.3",
83
+ "react-dom": "19.2.3",
70
84
  "tsdown": "0.16.8",
71
- "@marigold/icons": "1.3.30",
85
+ "@marigold/icons": "1.3.31",
72
86
  "@marigold/tsconfig": "0.4.2"
73
87
  },
74
88
  "scripts": {
75
- "build": "tsdown src/index.ts",
76
- "watch": "tsdown src/index.ts --watch",
89
+ "build": "tsdown",
90
+ "watch": "tsdown --watch",
77
91
  "clean": "rm -rf node_modules && rm -rf dist"
78
92
  }
79
93
  }