@dreamtree-org/twreact-ui 2.1.1 → 2.1.2
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 +1 -0
- package/dist/components/core/Table/Table.d.ts.map +1 -1
- package/dist/components/navigation/Navbar.d.ts.map +1 -1
- package/dist/esm/components/core/Table/MobileCard.js +2 -2
- package/dist/esm/components/core/Table/MobileFilters.js +1 -1
- package/dist/esm/components/core/Table/Table.js +28 -26
- package/dist/esm/components/navigation/Navbar.js +5 -2
- package/dist/index.css +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +36 -31
- package/dist/index.js +36 -31
- package/mcp/catalog.snapshot.json +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -523,6 +523,7 @@ Top navigation bar with user menu and notifications.
|
|
|
523
523
|
- `onLeftIconClick`: (event) => void
|
|
524
524
|
- `leftIconLabel`: string (default: "Go back") — the left button's accessible name, e.g. "Open navigation" when it opens a Sidebar drawer
|
|
525
525
|
- `leftIconProps`: ButtonHTMLAttributes — spread onto the left button (e.g. `aria-expanded`, `aria-controls`); `className` merges last
|
|
526
|
+
- `rightMenuContent`: ReactNode | (props) => ReactNode — replaces the notifications menu; an element renders as is, a function receives `{ notifications, ...navbarProps }`
|
|
526
527
|
|
|
527
528
|
```jsx
|
|
528
529
|
<Navbar
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/core/Table/Table.jsx"],"names":[],"mappings":";AAgDA,+
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/core/Table/Table.jsx"],"names":[],"mappings":";AAgDA,+EA4lDG;kBAnoDI,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Navbar.d.ts","sourceRoot":"","sources":["../../../src/components/navigation/Navbar.jsx"],"names":[],"mappings":"AAmQA,+
|
|
1
|
+
{"version":3,"file":"Navbar.d.ts","sourceRoot":"","sources":["../../../src/components/navigation/Navbar.jsx"],"names":[],"mappings":"AAmQA,+EAqZG;;kBAvpBmF,OAAO"}
|
|
@@ -201,10 +201,10 @@ function MobileCard(_ref) {
|
|
|
201
201
|
return jsxs("div", {
|
|
202
202
|
className: cn("flex justify-between items-center flex-row py-2 border-b last:border-b-0", safeExtraCellClass),
|
|
203
203
|
children: [jsx("div", {
|
|
204
|
-
className: "text-xs font-medium text-primary-700 uppercase tracking-wide mb-1 sm:mb-0 sm:w-1/3 sm:pr-2",
|
|
204
|
+
className: "text-xs font-medium text-primary-700 dark:text-primary-300 uppercase tracking-wide mb-1 sm:mb-0 sm:w-1/3 sm:pr-2",
|
|
205
205
|
children: column.label
|
|
206
206
|
}), jsx("div", {
|
|
207
|
-
className: "text-sm text-primary-900 sm:w-2/3 sm:pl-2 break-words",
|
|
207
|
+
className: "text-sm text-primary-900 dark:text-foreground sm:w-2/3 sm:pl-2 break-words",
|
|
208
208
|
children: renderCell(column, row, globalIndex)
|
|
209
209
|
})]
|
|
210
210
|
}, column.key);
|
|
@@ -205,7 +205,7 @@ function MobileFilters(_ref5) {
|
|
|
205
205
|
});
|
|
206
206
|
},
|
|
207
207
|
"aria-expanded": !!showMobileFilters,
|
|
208
|
-
className: "text-xs font-medium text-primary-700",
|
|
208
|
+
className: "text-xs font-medium text-primary-700 dark:text-primary-300",
|
|
209
209
|
children: showMobileFilters ? "Hide" : "Show"
|
|
210
210
|
})]
|
|
211
211
|
}), showMobileFilters && jsxs("div", {
|
|
@@ -178,6 +178,12 @@ var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
|
|
|
178
178
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
179
179
|
filters = _useState14[0],
|
|
180
180
|
setFilters = _useState14[1];
|
|
181
|
+
// The handlers below read and advance these refs synchronously, so they can
|
|
182
|
+
// call onSort / onFilter after setting state instead of inside a setState
|
|
183
|
+
// updater (updaters must be pure; React runs them during render and twice
|
|
184
|
+
// in StrictMode, #194). They are the only writers of sortConfig / filters.
|
|
185
|
+
var sortConfigRef = useRef(sortConfig);
|
|
186
|
+
var filtersRef = useRef(filters);
|
|
181
187
|
var _useState15 = useState(""),
|
|
182
188
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
183
189
|
searchInput = _useState16[0],
|
|
@@ -932,34 +938,30 @@ var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
|
|
|
932
938
|
}, []);
|
|
933
939
|
var handleSort = useCallback(function (key) {
|
|
934
940
|
if (!sortable) return;
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
941
|
+
var prev = sortConfigRef.current;
|
|
942
|
+
var direction = prev.key === key && prev.direction === "asc" ? "desc" : "asc";
|
|
943
|
+
var next = {
|
|
944
|
+
key: key,
|
|
945
|
+
direction: direction
|
|
946
|
+
};
|
|
947
|
+
sortConfigRef.current = next;
|
|
948
|
+
setSortConfig(next);
|
|
949
|
+
onSort === null || onSort === void 0 || onSort(key, direction);
|
|
943
950
|
}, [sortable, onSort]);
|
|
944
|
-
var
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
onFilter === null || onFilter === void 0 || onFilter(newFilters);
|
|
948
|
-
onFilterChange === null || onFilterChange === void 0 || onFilterChange(newFilters);
|
|
949
|
-
return newFilters;
|
|
950
|
-
});
|
|
951
|
+
var commitFilters = useCallback(function (newFilters) {
|
|
952
|
+
filtersRef.current = newFilters;
|
|
953
|
+
setFilters(newFilters);
|
|
951
954
|
setCurrentPage(1);
|
|
955
|
+
onFilter === null || onFilter === void 0 || onFilter(newFilters);
|
|
956
|
+
onFilterChange === null || onFilterChange === void 0 || onFilterChange(newFilters);
|
|
952
957
|
}, [onFilter, onFilterChange]);
|
|
958
|
+
var handleFilter = useCallback(function (key, value) {
|
|
959
|
+
return commitFilters(_objectSpread2(_objectSpread2({}, filtersRef.current), {}, _defineProperty({}, key, value)));
|
|
960
|
+
}, [commitFilters]);
|
|
953
961
|
// Commits several filters at once (the phone filter sheet's Apply).
|
|
954
962
|
var applyFilters = useCallback(function (patch) {
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
onFilter === null || onFilter === void 0 || onFilter(newFilters);
|
|
958
|
-
onFilterChange === null || onFilterChange === void 0 || onFilterChange(newFilters);
|
|
959
|
-
return newFilters;
|
|
960
|
-
});
|
|
961
|
-
setCurrentPage(1);
|
|
962
|
-
}, [onFilter, onFilterChange]);
|
|
963
|
+
return commitFilters(_objectSpread2(_objectSpread2({}, filtersRef.current), patch));
|
|
964
|
+
}, [commitFilters]);
|
|
963
965
|
// One open swipe row at a time: `{ key, side }`.
|
|
964
966
|
var _useState37 = useState(null),
|
|
965
967
|
_useState38 = _slicedToArray(_useState37, 2),
|
|
@@ -1196,7 +1198,7 @@ var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
|
|
|
1196
1198
|
className: "bg-primary-50/40 hover:bg-primary-100/70 active:bg-primary-100 transition-colors border-t-2 border-b-2 border-dashed border-primary-300 cursor-pointer group",
|
|
1197
1199
|
children: jsx("td", {
|
|
1198
1200
|
colSpan: visibleCount,
|
|
1199
|
-
className: "px-6 py-3.5 text-left text-sm font-semibold text-primary-700 group-hover:text-primary-800",
|
|
1201
|
+
className: "px-6 py-3.5 text-left text-sm font-semibold text-primary-700 group-hover:text-primary-800 dark:text-primary-300 dark:group-hover:text-primary-200",
|
|
1200
1202
|
children: jsxs("div", {
|
|
1201
1203
|
className: "flex items-center justify-start gap-2",
|
|
1202
1204
|
children: [jsx(Plus, {
|
|
@@ -1376,7 +1378,7 @@ var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
|
|
|
1376
1378
|
children: [hasDetailsColumn && jsx("th", {
|
|
1377
1379
|
className: "w-8 px-4 py-3"
|
|
1378
1380
|
}), showSerial && jsx("th", {
|
|
1379
|
-
className: "w-8 px-4 py-3 text-left text-xs font-medium text-primary-700 uppercase tracking-wider",
|
|
1381
|
+
className: "w-8 px-4 py-3 text-left text-xs font-medium text-primary-700 dark:text-primary-300 uppercase tracking-wider",
|
|
1380
1382
|
children: "#"
|
|
1381
1383
|
}), selectable && jsx("th", {
|
|
1382
1384
|
className: "w-12 px-6 py-3",
|
|
@@ -1403,7 +1405,7 @@ var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
|
|
|
1403
1405
|
return jsx("th", {
|
|
1404
1406
|
scope: "col",
|
|
1405
1407
|
"aria-sort": ariaSort,
|
|
1406
|
-
className: cn("px-6 py-3 text-left text-xs font-medium text-primary-700 uppercase tracking-wider", isSortable && "p-0"),
|
|
1408
|
+
className: cn("px-6 py-3 text-left text-xs font-medium text-primary-700 dark:text-primary-300 uppercase tracking-wider", isSortable && "p-0"),
|
|
1407
1409
|
children: isSortable ? jsxs("button", {
|
|
1408
1410
|
type: "button",
|
|
1409
1411
|
onClick: function onClick() {
|
|
@@ -347,8 +347,11 @@ var Navbar = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
347
347
|
})
|
|
348
348
|
});
|
|
349
349
|
};
|
|
350
|
-
// RightMenuContent:
|
|
351
|
-
|
|
350
|
+
// RightMenuContent: a render function or an element (#193), else the
|
|
351
|
+
// built-in notifications menu.
|
|
352
|
+
var RightMenuComponent = typeof RightMenuContentProp === "function" ? RightMenuContentProp : RightMenuContentProp != null ? function () {
|
|
353
|
+
return RightMenuContentProp;
|
|
354
|
+
} : function (rest) {
|
|
352
355
|
return jsx(RightMenuContent, _objectSpread2({
|
|
353
356
|
emitter: emitter
|
|
354
357
|
}, rest));
|