@dreamtree-org/twreact-ui 1.3.3 → 1.3.4
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/README.md +3 -1
- package/dist/ai-schema.json +2 -1
- package/dist/components/core/Table/MobileCard.d.ts.map +1 -1
- package/dist/components/core/Table/TableRow.d.ts.map +1 -1
- package/dist/components/core/Table/helpers.d.ts +12 -0
- package/dist/components/core/Table/helpers.d.ts.map +1 -1
- package/dist/esm/components/core/Table/ActionMenu.js +5 -5
- package/dist/esm/components/core/Table/ColumnMenu.js +1 -1
- package/dist/esm/components/core/Table/FieldInput.js +5 -5
- package/dist/esm/components/core/Table/MobileCard.js +9 -10
- package/dist/esm/components/core/Table/MobileFilters.js +1 -1
- package/dist/esm/components/core/Table/Pagination.js +1 -1
- package/dist/esm/components/core/Table/Table.js +12 -12
- package/dist/esm/components/core/Table/TableRow.js +10 -11
- package/dist/esm/components/core/Table/helpers.js +16 -1
- package/dist/esm/components/navigation/Dropdown.js +1 -1
- package/dist/esm/components/navigation/Navbar.js +21 -21
- package/dist/esm/components/navigation/Sidebar.js +12 -12
- package/dist/esm/components/utility/Card.js +5 -5
- package/dist/index.css +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +96 -83
- package/dist/index.js +96 -83
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/mcp/catalog.snapshot.json +9 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -896,6 +896,8 @@ function App() {
|
|
|
896
896
|
}
|
|
897
897
|
```
|
|
898
898
|
|
|
899
|
+
Surfaces such as `Card`, `Sidebar`, `Navbar`, `Table`, `FootNav` and `Dropdown` use the semantic `bg-surface` / `bg-background` / `border-line` / `text-foreground` / `text-muted` tokens, which switch under `.dark` (or `[data-theme="dark"]`). Re-theme them by overriding the `--dt-surface`, `--dt-background`, `--dt-line`, … variables.
|
|
900
|
+
|
|
899
901
|
## Examples
|
|
900
902
|
|
|
901
903
|
### Complete Form Example
|
|
@@ -1025,7 +1027,7 @@ MIT License - see [LICENSE](LICENSE) for details.
|
|
|
1025
1027
|
|
|
1026
1028
|
## Support
|
|
1027
1029
|
|
|
1028
|
-
- 📖 [
|
|
1030
|
+
- 📖 [Storybook](https://storybook.app.drm3.org)
|
|
1029
1031
|
- 🐛 [Issue Tracker](https://github.com/dreamtree-ui/dreamtree-ui/issues)
|
|
1030
1032
|
- 💬 [Discussions](https://github.com/dreamtree-ui/dreamtree-ui/discussions)
|
|
1031
1033
|
- 🌐 [Dreamtree Global](http://dreamtreeglobal.com/)
|
package/dist/ai-schema.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileCard.d.ts","sourceRoot":"","sources":["../../../../src/components/core/Table/MobileCard.jsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"MobileCard.d.ts","sourceRoot":"","sources":["../../../../src/components/core/Table/MobileCard.jsx"],"names":[],"mappings":";AAYA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4CAsOC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableRow.d.ts","sourceRoot":"","sources":["../../../../src/components/core/Table/TableRow.jsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"TableRow.d.ts","sourceRoot":"","sources":["../../../../src/components/core/Table/TableRow.jsx"],"names":[],"mappings":";AAYA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4CA+RC"}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
export function getRowKey(row: any, globalIndex: any): string;
|
|
2
|
+
export function getStripeProps(stripe: any): {
|
|
3
|
+
className?: undefined;
|
|
4
|
+
style?: undefined;
|
|
5
|
+
} | {
|
|
6
|
+
className: any;
|
|
7
|
+
style?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
style: {
|
|
10
|
+
backgroundColor: any;
|
|
11
|
+
};
|
|
12
|
+
className?: undefined;
|
|
13
|
+
};
|
|
2
14
|
export function rowHasDetails(hasDetails: any, row: any, index: any): boolean;
|
|
3
15
|
export function getActionLabelText(action: any): any;
|
|
4
16
|
export function mergeDefaultActions(overrides: any[], defaults: any[]): any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/components/core/Table/helpers.js"],"names":[],"mappings":"AAGO,8DAMN;AAaM,8EACqE;AAMrE,qDAGG;AAcH,8EAmBN;AAuBM,wCALI,gBAAc,OACd,MAAM,SACN,MAAM,GACJ;IAAE,aAAa,QAAQ;IAAC,WAAW,QAAO;CAAE,CAyBxD"}
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/components/core/Table/helpers.js"],"names":[],"mappings":"AAGO,8DAMN;AAOM;;;;;;;;;;;EAKN;AAaM,8EACqE;AAMrE,qDAGG;AAcH,8EAmBN;AAuBM,wCALI,gBAAc,OACd,MAAM,SACN,MAAM,GACJ;IAAE,aAAa,QAAQ;IAAC,WAAW,QAAO;CAAE,CAyBxD"}
|
|
@@ -6,8 +6,8 @@ import { createPortal } from 'react-dom';
|
|
|
6
6
|
import { cn } from '../../../utils/cn.js';
|
|
7
7
|
import { useLatestRef } from '../../../hooks/useLatestRef.js';
|
|
8
8
|
|
|
9
|
-
var DEFAULT_MENU_BG = "bg-
|
|
10
|
-
var DEFAULT_MENU_ITEM_HOVER = "opacity-75 hover:opacity-100 hover:bg-gray-100/80 active:bg-gray-200/80";
|
|
9
|
+
var DEFAULT_MENU_BG = "bg-surface border border-line shadow-xl";
|
|
10
|
+
var DEFAULT_MENU_ITEM_HOVER = "opacity-75 hover:opacity-100 hover:bg-gray-100/80 active:bg-gray-200/80 dark:hover:bg-gray-800 dark:active:bg-gray-700";
|
|
11
11
|
function ActionMenu(_ref) {
|
|
12
12
|
var _theme$menuBg, _theme$menuItemHover;
|
|
13
13
|
var _ref$actions = _ref.actions,
|
|
@@ -211,7 +211,7 @@ function ActionMenu(_ref) {
|
|
|
211
211
|
children: jsx("div", {
|
|
212
212
|
className: "p-1.5 space-y-0.5",
|
|
213
213
|
children: !Array.isArray(actions) || actions.length === 0 ? jsx("div", {
|
|
214
|
-
className: "px-3 py-2 text-sm text-
|
|
214
|
+
className: "px-3 py-2 text-sm text-muted italic",
|
|
215
215
|
children: "No actions"
|
|
216
216
|
}) : actions.map(function (action, idx) {
|
|
217
217
|
var _action$name;
|
|
@@ -222,7 +222,7 @@ function ActionMenu(_ref) {
|
|
|
222
222
|
type: "button",
|
|
223
223
|
disabled: isDisabled,
|
|
224
224
|
"aria-disabled": isDisabled || undefined,
|
|
225
|
-
className: cn("w-full text-left px-3 py-2 text-sm flex items-center gap-2.5 rounded-lg transition-colors font-medium", isDisabled ? "opacity-50 cursor-not-allowed text-
|
|
225
|
+
className: cn("w-full text-left px-3 py-2 text-sm flex items-center gap-2.5 rounded-lg transition-colors font-medium", isDisabled ? "opacity-50 cursor-not-allowed text-muted" : ["text-foreground", menuItemHover, isFocused ? "bg-gray-100 text-gray-900 ring-1 ring-gray-300 dark:bg-gray-800 dark:text-foreground dark:ring-gray-600" : ""]),
|
|
226
226
|
onMouseEnter: function onMouseEnter() {
|
|
227
227
|
return !isDisabled && setFocusedIndex(idx);
|
|
228
228
|
},
|
|
@@ -234,7 +234,7 @@ function ActionMenu(_ref) {
|
|
|
234
234
|
},
|
|
235
235
|
children: action.render ? action.render(row) : jsxs(Fragment, {
|
|
236
236
|
children: [action.icon && jsx("span", {
|
|
237
|
-
className: "inline-flex text-
|
|
237
|
+
className: "inline-flex text-muted flex-shrink-0",
|
|
238
238
|
children: action.icon
|
|
239
239
|
}), jsx("span", {
|
|
240
240
|
className: "truncate",
|
|
@@ -56,7 +56,7 @@ function FieldInput(_ref) {
|
|
|
56
56
|
onClick: stopProp,
|
|
57
57
|
onMouseDown: stopProp,
|
|
58
58
|
placeholder: "Enter ".concat(column.label || column.key, "..."),
|
|
59
|
-
className: cn("w-full px-2 py-1 text-sm border rounded outline-none transition-all focus:ring-2 focus:ring-primary-500 bg-
|
|
59
|
+
className: cn("w-full px-2 py-1 text-sm border rounded outline-none transition-all focus:ring-2 focus:ring-primary-500 bg-surface text-foreground resize-y min-h-[2.5rem]", className)
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
// Select / Dropdown
|
|
@@ -76,7 +76,7 @@ function FieldInput(_ref) {
|
|
|
76
76
|
onKeyDown: onKeyDown,
|
|
77
77
|
onClick: stopProp,
|
|
78
78
|
onMouseDown: stopProp,
|
|
79
|
-
className: cn("w-full px-2 py-1 text-sm border rounded outline-none focus:ring-2 focus:ring-primary-500 bg-
|
|
79
|
+
className: cn("w-full px-2 py-1 text-sm border rounded outline-none focus:ring-2 focus:ring-primary-500 bg-surface text-foreground", className),
|
|
80
80
|
children: [jsxs("option", {
|
|
81
81
|
value: "",
|
|
82
82
|
children: ["Select ", column.label || column.key]
|
|
@@ -119,7 +119,7 @@ function FieldInput(_ref) {
|
|
|
119
119
|
onKeyDown: onKeyDown,
|
|
120
120
|
onClick: stopProp,
|
|
121
121
|
onMouseDown: stopProp,
|
|
122
|
-
className: cn("w-full px-2 py-1 text-sm border rounded outline-none focus:ring-2 focus:ring-primary-500 bg-
|
|
122
|
+
className: cn("w-full px-2 py-1 text-sm border rounded outline-none focus:ring-2 focus:ring-primary-500 bg-surface text-foreground", className)
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
// Number
|
|
@@ -135,7 +135,7 @@ function FieldInput(_ref) {
|
|
|
135
135
|
onClick: stopProp,
|
|
136
136
|
onMouseDown: stopProp,
|
|
137
137
|
placeholder: "Enter ".concat(column.label || column.key, "..."),
|
|
138
|
-
className: cn("w-full px-2 py-1 text-sm border rounded outline-none focus:ring-2 focus:ring-primary-500 bg-
|
|
138
|
+
className: cn("w-full px-2 py-1 text-sm border rounded outline-none focus:ring-2 focus:ring-primary-500 bg-surface text-foreground", className)
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
// Default: Text
|
|
@@ -150,7 +150,7 @@ function FieldInput(_ref) {
|
|
|
150
150
|
onClick: stopProp,
|
|
151
151
|
onMouseDown: stopProp,
|
|
152
152
|
placeholder: "Enter ".concat(column.label || column.key, "..."),
|
|
153
|
-
className: cn("w-full px-2 py-1 text-sm border rounded outline-none focus:ring-2 focus:ring-primary-500 bg-
|
|
153
|
+
className: cn("w-full px-2 py-1 text-sm border rounded outline-none focus:ring-2 focus:ring-primary-500 bg-surface text-foreground", className)
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
|
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import { cn } from '../../../utils/cn.js';
|
|
5
5
|
import { MoreVertical } from 'lucide-react';
|
|
6
6
|
import ActionMenu from './ActionMenu.js';
|
|
7
|
-
import { getRowKey, resolveActions, rowHasDetails, getActionLabelText } from './helpers.js';
|
|
7
|
+
import { getRowKey, resolveActions, rowHasDetails, getActionLabelText, getStripeProps } from './helpers.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Mobile card view for a single table row
|
|
@@ -61,11 +61,10 @@ function MobileCard(_ref) {
|
|
|
61
61
|
var hasActions = withAction && (inlineActions.length > 0 || menuActions.length > 0);
|
|
62
62
|
var showHeader = showDetailsToggle || selectable || showSerial || hasActions;
|
|
63
63
|
var stripeBg = stripedRows && !isSelected && Array.isArray(stripedColors) && stripedColors.length > 0 ? stripedColors[globalIndex % stripedColors.length] : undefined;
|
|
64
|
+
var stripeProps = getStripeProps(stripeBg);
|
|
64
65
|
return jsxs("div", {
|
|
65
|
-
style:
|
|
66
|
-
|
|
67
|
-
} : undefined,
|
|
68
|
-
className: cn("border rounded-lg mb-3 shadow-sm overflow-hidden transition-all duration-200", {
|
|
66
|
+
style: stripeProps.style,
|
|
67
|
+
className: cn(stripeProps.className, "border border-line rounded-lg mb-3 shadow-sm overflow-hidden transition-all duration-200", {
|
|
69
68
|
"cursor-pointer": !!onRowClick,
|
|
70
69
|
"bg-primary-50 border-primary-200": isSelected,
|
|
71
70
|
"hover:shadow-md": !isSelected
|
|
@@ -74,7 +73,7 @@ function MobileCard(_ref) {
|
|
|
74
73
|
return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row, globalIndex);
|
|
75
74
|
},
|
|
76
75
|
children: [showHeader && jsxs("div", {
|
|
77
|
-
className: "flex items-center justify-between p-4 border-b bg-
|
|
76
|
+
className: "flex items-center justify-between p-4 border-b border-line bg-background",
|
|
78
77
|
children: [jsxs("div", {
|
|
79
78
|
className: "flex items-center gap-3",
|
|
80
79
|
children: [showDetailsToggle && jsx("button", {
|
|
@@ -85,7 +84,7 @@ function MobileCard(_ref) {
|
|
|
85
84
|
},
|
|
86
85
|
"aria-expanded": isExpanded,
|
|
87
86
|
"aria-label": isExpanded ? "Collapse row details" : "Expand row details",
|
|
88
|
-
className: "p-1 rounded hover:bg-gray-200",
|
|
87
|
+
className: "p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700",
|
|
89
88
|
children: isExpanded ? "▾" : "▸"
|
|
90
89
|
}), selectable && jsx("input", {
|
|
91
90
|
type: "checkbox",
|
|
@@ -119,7 +118,7 @@ function MobileCard(_ref) {
|
|
|
119
118
|
if (action.disabled) return;
|
|
120
119
|
handleOnAction(action, row);
|
|
121
120
|
},
|
|
122
|
-
className: cn("p-1.5 rounded", action.disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-gray-200"),
|
|
121
|
+
className: cn("p-1.5 rounded", action.disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-gray-200 dark:hover:bg-gray-700"),
|
|
123
122
|
children: action.render ? action.render(row) : (_action$icon = action.icon) !== null && _action$icon !== void 0 ? _action$icon : jsx("span", {
|
|
124
123
|
className: "text-xs",
|
|
125
124
|
children: actionLabel
|
|
@@ -136,7 +135,7 @@ function MobileCard(_ref) {
|
|
|
136
135
|
return toggleActions(e, actionCellKey, row);
|
|
137
136
|
},
|
|
138
137
|
"aria-expanded": activeActionRowKey === actionCellKey,
|
|
139
|
-
className: "p-1.5 rounded hover:bg-gray-200",
|
|
138
|
+
className: "p-1.5 rounded hover:bg-gray-200 dark:hover:bg-gray-700",
|
|
140
139
|
title: "Actions",
|
|
141
140
|
"aria-label": "Actions",
|
|
142
141
|
children: jsx(MoreVertical, {
|
|
@@ -178,7 +177,7 @@ function MobileCard(_ref) {
|
|
|
178
177
|
}, column.key);
|
|
179
178
|
})
|
|
180
179
|
}), showDetailsToggle && isExpanded && DetailsComponent && jsx("div", {
|
|
181
|
-
className: "border-t bg-
|
|
180
|
+
className: "border-t border-line bg-background p-4",
|
|
182
181
|
children: jsx(DetailsComponent, {
|
|
183
182
|
row: row,
|
|
184
183
|
index: globalIndex
|
|
@@ -19,7 +19,7 @@ function MobileFilters(_ref) {
|
|
|
19
19
|
handleFilter = _ref.handleFilter;
|
|
20
20
|
var idPrefix = React.useId();
|
|
21
21
|
return jsxs("div", {
|
|
22
|
-
className: "mb-4 p-3 bg-
|
|
22
|
+
className: "mb-4 p-3 bg-background rounded-lg",
|
|
23
23
|
children: [jsxs("div", {
|
|
24
24
|
className: "flex items-center justify-between mb-3",
|
|
25
25
|
children: [jsx("h3", {
|
|
@@ -9,7 +9,7 @@ import { ChevronsLeft, ChevronLeft, ChevronRight, ChevronsRight } from 'lucide-r
|
|
|
9
9
|
* Pagination controls component for the table
|
|
10
10
|
* Supports both header (icon-only) and footer (with page numbers) variants
|
|
11
11
|
*/
|
|
12
|
-
var DEFAULT_ROW_HOVER = "bg-
|
|
12
|
+
var DEFAULT_ROW_HOVER = "bg-background";
|
|
13
13
|
// Header pagination (compact, icon-based)
|
|
14
14
|
function PaginationHeader(_ref) {
|
|
15
15
|
var _theme$rowHover;
|
|
@@ -21,11 +21,11 @@ var _excluded = ["data", "columns", "sortable", "filterable", "selectable", "pag
|
|
|
21
21
|
var DEFAULT_DATA = [];
|
|
22
22
|
var DEFAULT_COLUMNS = [];
|
|
23
23
|
var DEFAULT_THEME = {
|
|
24
|
-
stripedColors: ["bg-
|
|
25
|
-
rowHover: "bg-
|
|
26
|
-
accentColor: "bg-
|
|
27
|
-
menuBg: "bg-
|
|
28
|
-
menuItemHover: "hover:bg-
|
|
24
|
+
stripedColors: ["bg-surface", "bg-background"],
|
|
25
|
+
rowHover: "bg-background",
|
|
26
|
+
accentColor: "bg-background",
|
|
27
|
+
menuBg: "bg-surface",
|
|
28
|
+
menuItemHover: "hover:bg-background"
|
|
29
29
|
};
|
|
30
30
|
var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
|
|
31
31
|
var _validationErrors$;
|
|
@@ -1239,7 +1239,7 @@ var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
|
|
|
1239
1239
|
onClick: handleClearChanges,
|
|
1240
1240
|
disabled: isSaving,
|
|
1241
1241
|
title: "Discard all pending modifications",
|
|
1242
|
-
className: "px-4 py-2 font-medium rounded-lg text-sm flex items-center gap-2 transition-all border border-primary-300 text-primary-700 bg-
|
|
1242
|
+
className: "px-4 py-2 font-medium rounded-lg text-sm flex items-center gap-2 transition-all border border-primary-300 text-primary-700 bg-surface hover:bg-primary-50 dark:text-primary-300 dark:border-primary-700 dark:hover:bg-primary-900/40 active:bg-primary-100 cursor-pointer shadow-sm disabled:opacity-50",
|
|
1243
1243
|
children: [jsx(X, {
|
|
1244
1244
|
className: "w-4 h-4 text-primary-600"
|
|
1245
1245
|
}), jsx("span", {
|
|
@@ -1283,7 +1283,7 @@ var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
|
|
|
1283
1283
|
onKeyDown: onGlobalKeyDown
|
|
1284
1284
|
}), jsx("button", {
|
|
1285
1285
|
onClick: applyGlobalSearch,
|
|
1286
|
-
className: "absolute right-2 top-1/2 transform -translate-y-1/2 p-2 rounded-lg hover:bg-gray-100",
|
|
1286
|
+
className: "absolute right-2 top-1/2 transform -translate-y-1/2 p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
1287
1287
|
title: "Search",
|
|
1288
1288
|
children: jsx(Search, {
|
|
1289
1289
|
className: "h-4 w-4 text-primary-400"
|
|
@@ -1294,7 +1294,7 @@ var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
|
|
|
1294
1294
|
setSearchInput("");
|
|
1295
1295
|
handleFilter("global", "");
|
|
1296
1296
|
},
|
|
1297
|
-
className: "whitespace-nowrap rounded-lg md:rounded-md border border-gray-300 px-4 py-3 md:py-2 text-sm hover:bg-gray-100 w-full sm:w-auto",
|
|
1297
|
+
className: "whitespace-nowrap rounded-lg md:rounded-md border border-gray-300 px-4 py-3 md:py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 w-full sm:w-auto",
|
|
1298
1298
|
children: "Clear"
|
|
1299
1299
|
})]
|
|
1300
1300
|
})
|
|
@@ -1318,7 +1318,7 @@ var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
|
|
|
1318
1318
|
}), !isMobileView && jsx("div", {
|
|
1319
1319
|
className: "overflow-x-auto overflow-y-visible",
|
|
1320
1320
|
children: jsxs("table", _objectSpread2(_objectSpread2({
|
|
1321
|
-
className: cn("min-w-full divide-y divide-
|
|
1321
|
+
className: cn("min-w-full divide-y divide-line", className)
|
|
1322
1322
|
}, props), {}, {
|
|
1323
1323
|
children: [jsxs("thead", {
|
|
1324
1324
|
className: safeTheme.accentColor,
|
|
@@ -1340,7 +1340,7 @@ var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
|
|
|
1340
1340
|
var _column$rules;
|
|
1341
1341
|
return jsx("th", {
|
|
1342
1342
|
className: cn("px-6 py-3 text-left text-xs font-medium text-primary-700 uppercase tracking-wider", {
|
|
1343
|
-
"cursor-pointer hover:bg-gray-100": sortable && column.sortable !== false
|
|
1343
|
+
"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800": sortable && column.sortable !== false
|
|
1344
1344
|
}),
|
|
1345
1345
|
onClick: function onClick() {
|
|
1346
1346
|
return column.sortable !== false && handleSort(column.key);
|
|
@@ -1384,7 +1384,7 @@ var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
|
|
|
1384
1384
|
return !s;
|
|
1385
1385
|
});
|
|
1386
1386
|
},
|
|
1387
|
-
className: "p-1 rounded hover:bg-gray-100",
|
|
1387
|
+
className: "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
1388
1388
|
children: jsx(MoreVertical, {
|
|
1389
1389
|
className: "h-4 w-4"
|
|
1390
1390
|
})
|
|
@@ -1420,7 +1420,7 @@ var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
|
|
|
1420
1420
|
})]
|
|
1421
1421
|
})]
|
|
1422
1422
|
}), jsx("tbody", {
|
|
1423
|
-
className: "divide-y divide-
|
|
1423
|
+
className: "divide-y divide-line",
|
|
1424
1424
|
children: loading ? jsx("tr", {
|
|
1425
1425
|
children: jsx("td", {
|
|
1426
1426
|
colSpan: visibleCount,
|
|
@@ -5,7 +5,7 @@ import React from 'react';
|
|
|
5
5
|
import { cn } from '../../../utils/cn.js';
|
|
6
6
|
import { Trash2, MoreVertical } from 'lucide-react';
|
|
7
7
|
import ActionMenu from './ActionMenu.js';
|
|
8
|
-
import { getRowKey, resolveActions, rowHasDetails, getActionLabelText } from './helpers.js';
|
|
8
|
+
import { getRowKey, resolveActions, rowHasDetails, getActionLabelText, getStripeProps } from './helpers.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Desktop table row component
|
|
@@ -86,6 +86,7 @@ function TableRow(_ref) {
|
|
|
86
86
|
var safeExtraRowClass = typeof extraRowClass === "string" ? extraRowClass.trim() : "";
|
|
87
87
|
var stripeColors = theme === null || theme === void 0 ? void 0 : theme.stripedColors;
|
|
88
88
|
var stripeBg = stripedRows && !isSelected && Array.isArray(stripeColors) && stripeColors.length > 0 ? stripeColors[globalIndex % stripeColors.length] : undefined;
|
|
89
|
+
var stripeProps = getStripeProps(stripeBg);
|
|
89
90
|
var rowKey = isNewRow ? row._key : key;
|
|
90
91
|
var isRowActive = interactive && (activeCell === null || activeCell === void 0 ? void 0 : activeCell.rowKey) === rowKey;
|
|
91
92
|
var effectiveRow = React.useMemo(function () {
|
|
@@ -94,10 +95,8 @@ function TableRow(_ref) {
|
|
|
94
95
|
}, [interactive, pendingEdits, rowKey, row]);
|
|
95
96
|
return jsxs(React.Fragment, {
|
|
96
97
|
children: [jsxs("tr", {
|
|
97
|
-
style:
|
|
98
|
-
|
|
99
|
-
} : undefined,
|
|
100
|
-
className: cn(theme !== null && theme !== void 0 && theme.rowHover ? ["hover:" + theme.rowHover] : [], {
|
|
98
|
+
style: stripeProps.style,
|
|
99
|
+
className: cn(stripeProps.className, theme !== null && theme !== void 0 && theme.rowHover ? ["hover:" + theme.rowHover] : [], {
|
|
101
100
|
"cursor-pointer": !!onRowClick,
|
|
102
101
|
"bg-primary-50": isSelected,
|
|
103
102
|
"bg-primary-50/20": isRowActive && !isSelected,
|
|
@@ -116,7 +115,7 @@ function TableRow(_ref) {
|
|
|
116
115
|
},
|
|
117
116
|
"aria-expanded": isExpanded,
|
|
118
117
|
"aria-label": isExpanded ? "Collapse row details" : "Expand row details",
|
|
119
|
-
className: "p-1 rounded hover:bg-gray-100",
|
|
118
|
+
className: "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
120
119
|
children: isExpanded ? "▾" : "▸"
|
|
121
120
|
})
|
|
122
121
|
}), showSerial && jsx("td", {
|
|
@@ -152,9 +151,9 @@ function TableRow(_ref) {
|
|
|
152
151
|
title: isCellInvalid ? "Field \"".concat(column.label || column.key, "\" is required or invalid") : undefined,
|
|
153
152
|
className: cn("px-6 py-4 text-sm transition-all", wrapCell ? "whitespace-normal break-words" : "whitespace-nowrap", {
|
|
154
153
|
"ring-2 ring-error-500 ring-inset bg-error-50/40 relative z-10": isCellInvalid && !isCellEditing,
|
|
155
|
-
"ring-2 ring-error-600 ring-inset bg-
|
|
154
|
+
"ring-2 ring-error-600 ring-inset bg-surface p-1 z-20 relative": isCellEditing && isCellInvalid,
|
|
156
155
|
"ring-2 ring-primary-500 ring-inset bg-primary-50/50 relative z-10": isCellActive && !isCellEditing && !isCellInvalid,
|
|
157
|
-
"ring-2 ring-primary-600 ring-inset bg-
|
|
156
|
+
"ring-2 ring-primary-600 ring-inset bg-surface p-1 z-20 relative": isCellEditing && !isCellInvalid
|
|
158
157
|
}, safeExtraCellClass),
|
|
159
158
|
onClick: function onClick() {
|
|
160
159
|
if (interactive && onCellClick) {
|
|
@@ -201,7 +200,7 @@ function TableRow(_ref) {
|
|
|
201
200
|
if (action.disabled) return;
|
|
202
201
|
handleOnAction(action, row);
|
|
203
202
|
},
|
|
204
|
-
className: cn("p-1 rounded", action.disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-gray-100"),
|
|
203
|
+
className: cn("p-1 rounded", action.disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-gray-100 dark:hover:bg-gray-800"),
|
|
205
204
|
children: action.render ? action.render(row) : (_action$icon = action.icon) !== null && _action$icon !== void 0 ? _action$icon : jsx("span", {
|
|
206
205
|
className: "text-xs",
|
|
207
206
|
children: actionLabel
|
|
@@ -217,7 +216,7 @@ function TableRow(_ref) {
|
|
|
217
216
|
return toggleActions(e, actionCellKey, row);
|
|
218
217
|
},
|
|
219
218
|
"aria-expanded": activeActionRowKey === actionCellKey,
|
|
220
|
-
className: "p-1 rounded hover:bg-gray-100",
|
|
219
|
+
className: "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
221
220
|
title: "Actions",
|
|
222
221
|
children: jsx(MoreVertical, {
|
|
223
222
|
className: "h-4 w-4"
|
|
@@ -241,7 +240,7 @@ function TableRow(_ref) {
|
|
|
241
240
|
colSpan: visibleCount,
|
|
242
241
|
className: cn(_defineProperty(_defineProperty({
|
|
243
242
|
"px-6 py-4": true
|
|
244
|
-
}, (_theme$accentColor = theme === null || theme === void 0 ? void 0 : theme.accentColor) !== null && _theme$accentColor !== void 0 ? _theme$accentColor : "bg-
|
|
243
|
+
}, (_theme$accentColor = theme === null || theme === void 0 ? void 0 : theme.accentColor) !== null && _theme$accentColor !== void 0 ? _theme$accentColor : "bg-background", true), (_theme$rowHover = theme === null || theme === void 0 ? void 0 : theme.rowHover) !== null && _theme$rowHover !== void 0 ? _theme$rowHover : "bg-background", true)),
|
|
245
244
|
children: jsx(DetailsComponent, {
|
|
246
245
|
row: row,
|
|
247
246
|
index: globalIndex
|
|
@@ -10,6 +10,21 @@ var getRowKey = function getRowKey(row, globalIndex) {
|
|
|
10
10
|
if (row._id !== undefined && row._id !== null) return String(row._id);
|
|
11
11
|
return String(globalIndex);
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* A `stripedColors` entry is either a CSS colour ("#f7fafc", "rgb(...)") applied as an
|
|
15
|
+
* inline background, or a Tailwind class ("bg-surface", "dark:bg-gray-900") applied as a
|
|
16
|
+
* className. Returns the props to spread onto the striped element.
|
|
17
|
+
*/
|
|
18
|
+
var getStripeProps = function getStripeProps(stripe) {
|
|
19
|
+
if (!stripe) return {};
|
|
20
|
+
return /(^|[\s:])bg-/.test(stripe) ? {
|
|
21
|
+
className: stripe
|
|
22
|
+
} : {
|
|
23
|
+
style: {
|
|
24
|
+
backgroundColor: stripe
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
13
28
|
/**
|
|
14
29
|
* Resolve a value that may be supplied directly or as a per-row producer.
|
|
15
30
|
* Used for an action's `label`, `icon`, `hidden` and `disabled`.
|
|
@@ -121,4 +136,4 @@ var resolveActions = function resolveActions(actions, row, index) {
|
|
|
121
136
|
};
|
|
122
137
|
};
|
|
123
138
|
|
|
124
|
-
export { getActionLabelText, getRowKey, mergeDefaultActions, resolveActions, rowHasDetails };
|
|
139
|
+
export { getActionLabelText, getRowKey, getStripeProps, mergeDefaultActions, resolveActions, rowHasDetails };
|
|
@@ -44,7 +44,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
44
44
|
},
|
|
45
45
|
children: trigger
|
|
46
46
|
}), isOpen && jsx("div", {
|
|
47
|
-
className: "absolute z-50 bg-
|
|
47
|
+
className: "absolute z-50 bg-surface text-foreground border border-line rounded-md shadow-lg ".concat(placementClasses[placement], " min-w-48"),
|
|
48
48
|
children: children
|
|
49
49
|
})]
|
|
50
50
|
}));
|
|
@@ -67,7 +67,7 @@ var NotificationsDropdown = function NotificationsDropdown(_ref) {
|
|
|
67
67
|
// For simplicity, shows notifications in the dropdown, can be expanded
|
|
68
68
|
return jsx(Dropdown, {
|
|
69
69
|
trigger: jsxs("button", {
|
|
70
|
-
className: "relative rounded-md p-2 text-primary-400 hover:text-primary-500 hover:bg-gray-100",
|
|
70
|
+
className: "relative rounded-md p-2 text-primary-400 hover:text-primary-500 hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
71
71
|
"aria-label": "notifications",
|
|
72
72
|
children: [jsx(Bell, {
|
|
73
73
|
className: "h-5 w-5"
|
|
@@ -80,9 +80,9 @@ var NotificationsDropdown = function NotificationsDropdown(_ref) {
|
|
|
80
80
|
children: jsxs("div", {
|
|
81
81
|
className: "py-2 min-w-56 max-h-80 overflow-y-auto",
|
|
82
82
|
children: [jsxs("div", {
|
|
83
|
-
className: "px-4 py-2 border-b border-
|
|
83
|
+
className: "px-4 py-2 border-b border-line flex items-center justify-between",
|
|
84
84
|
children: [jsx("span", {
|
|
85
|
-
className: "font-medium text-primary-800 text-sm",
|
|
85
|
+
className: "font-medium text-primary-800 dark:text-primary-100 text-sm",
|
|
86
86
|
children: "Notifications"
|
|
87
87
|
}), jsx("button", {
|
|
88
88
|
className: "text-xs text-primary-400 hover:text-error-600",
|
|
@@ -98,16 +98,16 @@ var NotificationsDropdown = function NotificationsDropdown(_ref) {
|
|
|
98
98
|
children: "No notifications"
|
|
99
99
|
}) : notifications.map(function (n) {
|
|
100
100
|
return jsxs("div", {
|
|
101
|
-
className: cn("flex items-start gap-3 px-4 py-2 hover:bg-gray-50 cursor-pointer group", !n.read ? "bg-primary-50" : ""),
|
|
101
|
+
className: cn("flex items-start gap-3 px-4 py-2 hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer group", !n.read ? "bg-primary-50 dark:bg-primary-900/40" : ""),
|
|
102
102
|
onClick: function onClick() {
|
|
103
103
|
return onView();
|
|
104
104
|
},
|
|
105
105
|
children: [jsx("span", {
|
|
106
|
-
className: cn("h-2 w-2 mt-2 rounded-full", !n.read ? "bg-primary-500" : "bg-gray-300")
|
|
106
|
+
className: cn("h-2 w-2 mt-2 rounded-full", !n.read ? "bg-primary-500" : "bg-gray-300 dark:bg-gray-600")
|
|
107
107
|
}), jsxs("div", {
|
|
108
108
|
className: "flex-1",
|
|
109
109
|
children: [jsx("div", {
|
|
110
|
-
className: "text-sm text-primary-800",
|
|
110
|
+
className: "text-sm text-primary-800 dark:text-primary-100",
|
|
111
111
|
children: n.title
|
|
112
112
|
}), n.message && jsx("div", {
|
|
113
113
|
className: "text-xs text-primary-500",
|
|
@@ -159,10 +159,10 @@ var RightMenuContent = function RightMenuContent(_ref2) {
|
|
|
159
159
|
});
|
|
160
160
|
};
|
|
161
161
|
var styledClassNames = {
|
|
162
|
-
button: "rounded-md p-2 text-primary-400 hover:text-primary-500 hover:bg-gray-100",
|
|
162
|
+
button: "rounded-md p-2 text-primary-400 hover:text-primary-500 hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
163
163
|
mobileItem: "md:hidden",
|
|
164
164
|
icon: "h-6 w-6",
|
|
165
|
-
dropdown: "w-56 rounded-md border border-
|
|
165
|
+
dropdown: "w-56 rounded-md border border-line bg-surface py-1 shadow-lg"
|
|
166
166
|
};
|
|
167
167
|
var Navbar = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
168
168
|
var emitter = _ref3.emitter,
|
|
@@ -247,7 +247,7 @@ var Navbar = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
247
247
|
},
|
|
248
248
|
className: cn("block w-full text-left px-4 py-2 text-sm", {
|
|
249
249
|
"text-primary-600": item.active,
|
|
250
|
-
"hover:bg-gray-50": !item.active
|
|
250
|
+
"hover:bg-gray-50 dark:hover:bg-gray-800": !item.active
|
|
251
251
|
}),
|
|
252
252
|
children: item.label
|
|
253
253
|
}, item.id);
|
|
@@ -262,7 +262,7 @@ var Navbar = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
262
262
|
};
|
|
263
263
|
return jsxs("nav", _objectSpread2(_objectSpread2({
|
|
264
264
|
ref: ref,
|
|
265
|
-
className: cn("bg-
|
|
265
|
+
className: cn("bg-surface text-foreground border-b border-line px-4 sm:px-6 lg:px-8", className)
|
|
266
266
|
}, props), {}, {
|
|
267
267
|
children: [jsxs("div", {
|
|
268
268
|
className: "flex h-16 min-w-0 items-center justify-between gap-2 sm:gap-4",
|
|
@@ -275,7 +275,7 @@ var Navbar = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
275
275
|
className: "flex min-w-0 items-center",
|
|
276
276
|
children: [leftIcon !== false && jsx("button", {
|
|
277
277
|
onClick: onLeftIconClick,
|
|
278
|
-
className: "shrink-0 md:hidden rounded-md p-2 text-primary-400 hover:text-primary-500 hover:bg-gray-100",
|
|
278
|
+
className: "shrink-0 md:hidden rounded-md p-2 text-primary-400 hover:text-primary-500 hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
279
279
|
"aria-label": "back",
|
|
280
280
|
children: leftIcon
|
|
281
281
|
}), logo && jsx("div", {
|
|
@@ -302,7 +302,7 @@ var Navbar = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
302
302
|
}), jsx("input", {
|
|
303
303
|
type: "text",
|
|
304
304
|
placeholder: "Search...",
|
|
305
|
-
className: "w-64 rounded-md border border-gray-300 bg-
|
|
305
|
+
className: "w-64 rounded-md border border-gray-300 bg-surface text-foreground dark:border-gray-700 pl-10 pr-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent",
|
|
306
306
|
value: searchTerm,
|
|
307
307
|
onChange: function onChange(e) {
|
|
308
308
|
return setSearchTerm(e.target.value);
|
|
@@ -365,9 +365,9 @@ var Navbar = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
365
365
|
children: jsxs("div", {
|
|
366
366
|
className: styledClassNames.dropdown,
|
|
367
367
|
children: [jsxs("div", {
|
|
368
|
-
className: "px-4 py-2 border-b border-
|
|
368
|
+
className: "px-4 py-2 border-b border-line",
|
|
369
369
|
children: [jsx("p", {
|
|
370
|
-
className: "text-sm font-medium text-primary-900",
|
|
370
|
+
className: "text-sm font-medium text-primary-900 dark:text-primary-100",
|
|
371
371
|
children: user.name
|
|
372
372
|
}), jsx("p", {
|
|
373
373
|
className: "text-xs text-primary-500",
|
|
@@ -377,23 +377,23 @@ var Navbar = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
377
377
|
className: "py-1",
|
|
378
378
|
children: renderNavItems(true)
|
|
379
379
|
}), user.menuItems && user.menuItems.length > 0 && jsx("div", {
|
|
380
|
-
className: "border-t border-
|
|
380
|
+
className: "border-t border-line",
|
|
381
381
|
children: user.menuItems.map(function (mi) {
|
|
382
382
|
return jsx("button", {
|
|
383
383
|
onClick: function onClick(e) {
|
|
384
384
|
var _mi$onClick;
|
|
385
385
|
return mi === null || mi === void 0 || (_mi$onClick = mi.onClick) === null || _mi$onClick === void 0 ? void 0 : _mi$onClick.call(mi, e);
|
|
386
386
|
},
|
|
387
|
-
className: "block w-full px-4 py-2 text-left text-sm hover:bg-gray-100",
|
|
387
|
+
className: "block w-full px-4 py-2 text-left text-sm hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
388
388
|
children: mi.label
|
|
389
389
|
}, mi.id);
|
|
390
390
|
})
|
|
391
391
|
}), jsx("div", {
|
|
392
|
-
className: "border-t border-
|
|
392
|
+
className: "border-t border-line sm:hidden",
|
|
393
393
|
children: jsxs("button", {
|
|
394
394
|
type: "button",
|
|
395
395
|
onClick: handleLogoutClick,
|
|
396
|
-
className: "flex w-full items-center gap-2 px-4 py-2 text-left text-sm hover:bg-gray-100",
|
|
396
|
+
className: "flex w-full items-center gap-2 px-4 py-2 text-left text-sm hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
397
397
|
children: [jsx(LogOut, {
|
|
398
398
|
className: "h-4 w-4",
|
|
399
399
|
"aria-hidden": "true"
|
|
@@ -407,13 +407,13 @@ var Navbar = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
407
407
|
}), isMobileMenuOpen && !user && jsx("div", {
|
|
408
408
|
className: "md:hidden h-full",
|
|
409
409
|
children: jsx("div", {
|
|
410
|
-
className: "space-y-1 border-t border-
|
|
410
|
+
className: "space-y-1 border-t border-line px-2 pt-4 pb-3",
|
|
411
411
|
children: items.map(function (item) {
|
|
412
412
|
return jsx("a", {
|
|
413
413
|
href: item.href,
|
|
414
414
|
className: cn("block rounded-md px-3 py-2 text-base font-medium", {
|
|
415
|
-
"bg-primary-50 text-primary-700": item.active,
|
|
416
|
-
"hover:bg-gray-50": !item.active
|
|
415
|
+
"bg-primary-50 text-primary-700 dark:bg-primary-900/40 dark:text-primary-300": item.active,
|
|
416
|
+
"hover:bg-gray-50 dark:hover:bg-gray-800": !item.active
|
|
417
417
|
}),
|
|
418
418
|
children: item.label
|
|
419
419
|
}, item.id);
|