@dust-tt/sparkle 0.2.236 → 0.2.238
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/cjs/index.js +38 -40
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/DataTable.d.ts +17 -6
- package/dist/esm/components/DataTable.d.ts.map +1 -1
- package/dist/esm/components/DataTable.js +34 -22
- package/dist/esm/components/DataTable.js.map +1 -1
- package/dist/esm/components/Dialog.d.ts.map +1 -1
- package/dist/esm/components/Dialog.js +2 -2
- package/dist/esm/components/Dialog.js.map +1 -1
- package/dist/esm/components/TextArea.d.ts +2 -2
- package/dist/esm/components/TextArea.d.ts.map +1 -1
- package/dist/esm/components/TextArea.js +3 -17
- package/dist/esm/components/TextArea.js.map +1 -1
- package/dist/esm/stories/DataTable.stories.d.ts.map +1 -1
- package/dist/esm/stories/DataTable.stories.js +32 -2
- package/dist/esm/stories/DataTable.stories.js.map +1 -1
- package/dist/esm/stories/TextArea.stories.js +1 -1
- package/dist/esm/stories/TextArea.stories.js.map +1 -1
- package/dist/sparkle.css +4 -4
- package/package.json +1 -1
- package/src/components/DataTable.tsx +74 -19
- package/src/components/Dialog.tsx +2 -4
- package/src/components/TextArea.tsx +4 -20
- package/src/stories/DataTable.stories.tsx +32 -0
- package/src/stories/TextArea.stories.tsx +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -103414,10 +103414,10 @@ function shouldRenderColumn(windowWidth, breakpoint) {
|
|
|
103414
103414
|
return windowWidth >= breakpoints[breakpoint];
|
|
103415
103415
|
}
|
|
103416
103416
|
function DataTable(_a) {
|
|
103417
|
-
var data = _a.data, totalRowCount = _a.totalRowCount, columns = _a.columns, className = _a.className, filter = _a.filter, filterColumn = _a.filterColumn, initialColumnOrder = _a.initialColumnOrder,
|
|
103417
|
+
var data = _a.data, totalRowCount = _a.totalRowCount, columns = _a.columns, className = _a.className, _b = _a.widthClassName, widthClassName = _b === void 0 ? "s-w-full s-max-w-4xl" : _b, filter = _a.filter, filterColumn = _a.filterColumn, initialColumnOrder = _a.initialColumnOrder, _c = _a.columnsBreakpoints, columnsBreakpoints = _c === void 0 ? {} : _c, pagination = _a.pagination, setPagination = _a.setPagination;
|
|
103418
103418
|
var windowSize = useWindowSize();
|
|
103419
|
-
var
|
|
103420
|
-
var
|
|
103419
|
+
var _d = __read(React.useState(initialColumnOrder !== null && initialColumnOrder !== void 0 ? initialColumnOrder : []), 2), sorting = _d[0], setSorting = _d[1];
|
|
103420
|
+
var _e = __read(React.useState([]), 2), columnFilters = _e[0], setColumnFilters = _e[1];
|
|
103421
103421
|
var isServerSidePagination = !!totalRowCount && totalRowCount > data.length;
|
|
103422
103422
|
var onPaginationChange = pagination && setPagination
|
|
103423
103423
|
? function (updater) {
|
|
@@ -103452,15 +103452,15 @@ function DataTable(_a) {
|
|
|
103452
103452
|
(_a = table.getColumn(filterColumn)) === null || _a === void 0 ? void 0 : _a.setFilterValue(filter);
|
|
103453
103453
|
}
|
|
103454
103454
|
}, [filter, filterColumn]);
|
|
103455
|
-
return (React.createElement("div", { className: "s-flex s-flex-col s-gap-2" },
|
|
103456
|
-
React.createElement(DataTable.Root,
|
|
103457
|
-
React.createElement(DataTable.Header, null, table.getHeaderGroups().map(function (headerGroup) { return (React.createElement(DataTable.Row, { key: headerGroup.id }, headerGroup.headers.map(function (header) {
|
|
103455
|
+
return (React.createElement("div", { className: classNames("s-flex s-flex-col s-gap-2", className || "", widthClassName) },
|
|
103456
|
+
React.createElement(DataTable.Root, null,
|
|
103457
|
+
React.createElement(DataTable.Header, null, table.getHeaderGroups().map(function (headerGroup) { return (React.createElement(DataTable.Row, { key: headerGroup.id, widthClassName: widthClassName }, headerGroup.headers.map(function (header) {
|
|
103458
103458
|
var breakpoint = columnsBreakpoints[header.id];
|
|
103459
103459
|
if (!windowSize.width ||
|
|
103460
103460
|
!shouldRenderColumn(windowSize.width, breakpoint)) {
|
|
103461
103461
|
return null;
|
|
103462
103462
|
}
|
|
103463
|
-
return (React.createElement(DataTable.Head, { key: header.id, onClick: header.column.getToggleSortingHandler(), className: classNames(header.column.getCanSort() ? "s-cursor-pointer" : "") },
|
|
103463
|
+
return (React.createElement(DataTable.Head, { column: header.column, key: header.id, onClick: header.column.getToggleSortingHandler(), className: classNames(header.column.getCanSort() ? "s-cursor-pointer" : "") },
|
|
103464
103464
|
React.createElement("div", { className: "s-flex s-items-center s-space-x-1 s-whitespace-nowrap" },
|
|
103465
103465
|
flexRender(header.column.columnDef.header, header.getContext()),
|
|
103466
103466
|
header.column.getCanSort() && (React.createElement(Icon, { visual: header.column.getIsSorted() === "asc"
|
|
@@ -103471,55 +103471,67 @@ function DataTable(_a) {
|
|
|
103471
103471
|
? "s-opacity-100"
|
|
103472
103472
|
: "s-opacity-0") })))));
|
|
103473
103473
|
}))); })),
|
|
103474
|
-
React.createElement(DataTable.Body, null, table.getRowModel().rows.map(function (row) { return (React.createElement(DataTable.Row, { key: row.id, onClick: row.original.onClick, moreMenuItems: row.original.moreMenuItems }, row.getVisibleCells().map(function (cell) {
|
|
103474
|
+
React.createElement(DataTable.Body, null, table.getRowModel().rows.map(function (row) { return (React.createElement(DataTable.Row, { widthClassName: widthClassName, key: row.id, onClick: row.original.onClick, moreMenuItems: row.original.moreMenuItems }, row.getVisibleCells().map(function (cell) {
|
|
103475
103475
|
var breakpoint = columnsBreakpoints[cell.column.id];
|
|
103476
103476
|
if (!windowSize.width ||
|
|
103477
103477
|
!shouldRenderColumn(windowSize.width, breakpoint)) {
|
|
103478
103478
|
return null;
|
|
103479
103479
|
}
|
|
103480
|
-
return (React.createElement(DataTable.Cell, { key: cell.id }, flexRender(cell.column.columnDef.cell, cell.getContext())));
|
|
103480
|
+
return (React.createElement(DataTable.Cell, { column: cell.column, key: cell.id }, flexRender(cell.column.columnDef.cell, cell.getContext())));
|
|
103481
103481
|
}))); }))),
|
|
103482
103482
|
pagination && (React.createElement("div", { className: "s-p-1" },
|
|
103483
103483
|
React.createElement(Pagination, { pagination: table.getState().pagination, setPagination: table.setPagination, rowCount: table.getRowCount() })))));
|
|
103484
103484
|
}
|
|
103485
103485
|
DataTable.Root = function DataTableRoot(_a) {
|
|
103486
|
-
var children = _a.children,
|
|
103487
|
-
return (React.createElement("table", __assign({ className:
|
|
103486
|
+
var children = _a.children, props = __rest(_a, ["children"]);
|
|
103487
|
+
return (React.createElement("table", __assign({ className: "s-w-full s-border-collapse" }, props), children));
|
|
103488
103488
|
};
|
|
103489
103489
|
DataTable.Header = function Header(_a) {
|
|
103490
103490
|
var children = _a.children, className = _a.className, props = __rest(_a, ["children", "className"]);
|
|
103491
103491
|
return (React.createElement("thead", __assign({ className: classNames("s-text-xs s-capitalize", className || "") }, props), children));
|
|
103492
103492
|
};
|
|
103493
103493
|
DataTable.Head = function Head(_a) {
|
|
103494
|
-
var children = _a.children, className = _a.className, props = __rest(_a, ["children", "className"]);
|
|
103495
|
-
return (React.createElement("th", __assign({ className: classNames("s-
|
|
103494
|
+
var children = _a.children, className = _a.className, column = _a.column, props = __rest(_a, ["children", "className", "column"]);
|
|
103495
|
+
return (React.createElement("th", __assign({ style: getSize(column.columnDef), className: classNames("s-py-1 s-pr-3 s-text-left s-font-medium s-text-element-800", className || "") }, props), children));
|
|
103496
103496
|
};
|
|
103497
103497
|
DataTable.Body = function Body(_a) {
|
|
103498
103498
|
var children = _a.children, className = _a.className, props = __rest(_a, ["children", "className"]);
|
|
103499
103499
|
return (React.createElement("tbody", __assign({ className: className }, props), children));
|
|
103500
103500
|
};
|
|
103501
103501
|
DataTable.Row = function Row(_a) {
|
|
103502
|
-
var children = _a.children, className = _a.className, onClick = _a.onClick, moreMenuItems = _a.moreMenuItems, props = __rest(_a, ["children", "className", "onClick", "moreMenuItems"]);
|
|
103503
|
-
return (React.createElement("tr", __assign({ className: classNames("s-group/dt s-border-b s-border-structure-200 s-text-sm s-transition-colors s-duration-300 s-ease-out", onClick ? "s-cursor-pointer hover:s-bg-structure-50" : "", className || ""), onClick: onClick ? onClick : undefined }, props),
|
|
103502
|
+
var children = _a.children, className = _a.className, onClick = _a.onClick, moreMenuItems = _a.moreMenuItems, widthClassName = _a.widthClassName, props = __rest(_a, ["children", "className", "onClick", "moreMenuItems", "widthClassName"]);
|
|
103503
|
+
return (React.createElement("tr", __assign({ className: classNames("s-group/dt s-flex s-items-center s-border-b s-border-structure-200 s-text-sm s-transition-colors s-duration-300 s-ease-out", onClick ? "s-cursor-pointer hover:s-bg-structure-50" : "", widthClassName, className || ""), onClick: onClick ? onClick : undefined }, props),
|
|
103504
103504
|
children,
|
|
103505
|
-
React.createElement("td", { className: "s-w-
|
|
103505
|
+
React.createElement("td", { className: "s-flex s-w-8 s-cursor-pointer s-items-center s-pl-1 s-text-element-600" }, moreMenuItems && moreMenuItems.length > 0 && (React.createElement(DropdownMenu, { className: "s-mr-1.5 s-flex" },
|
|
103506
103506
|
React.createElement(DropdownMenu.Button, null,
|
|
103507
|
-
React.createElement(IconButton, { icon: SvgMore$1, size: "sm", variant: "tertiary" })),
|
|
103507
|
+
React.createElement(IconButton, { icon: SvgMore$1, size: "sm", variant: "tertiary", className: "s-m-1" })),
|
|
103508
103508
|
React.createElement(DropdownMenu.Items, { origin: "topRight", width: 220 }, moreMenuItems === null || moreMenuItems === void 0 ? void 0 : moreMenuItems.map(function (item, index) { return (React.createElement(DropdownMenu.Item, __assign({ key: index }, item))); })))))));
|
|
103509
103509
|
};
|
|
103510
103510
|
DataTable.Cell = function Cell(_a) {
|
|
103511
|
-
var
|
|
103512
|
-
|
|
103511
|
+
var _b;
|
|
103512
|
+
var children = _a.children, className = _a.className, column = _a.column, props = __rest(_a, ["children", "className", "column"]);
|
|
103513
|
+
column.columnDef.minSize;
|
|
103514
|
+
return (React.createElement("td", __assign({ style: getSize(column.columnDef), className: classNames("s-flex s-h-12 s-items-center s-truncate s-whitespace-nowrap s-pl-1.5 s-text-element-800", ((_b = column.columnDef.meta) === null || _b === void 0 ? void 0 : _b.className) || "", className || "") }, props), children));
|
|
103513
103515
|
};
|
|
103516
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103517
|
+
function getSize(columnDef) {
|
|
103518
|
+
var _a, _b, _c;
|
|
103519
|
+
if ((_a = columnDef.meta) === null || _a === void 0 ? void 0 : _a.width) {
|
|
103520
|
+
return { width: columnDef.meta.width };
|
|
103521
|
+
}
|
|
103522
|
+
return {
|
|
103523
|
+
flex: (_c = (_b = columnDef.meta) === null || _b === void 0 ? void 0 : _b.flex) !== null && _c !== void 0 ? _c : 1,
|
|
103524
|
+
};
|
|
103525
|
+
}
|
|
103514
103526
|
DataTable.CellContent = function CellContent(_a) {
|
|
103515
103527
|
var children = _a.children, className = _a.className, avatarUrl = _a.avatarUrl, avatarTooltipLabel = _a.avatarTooltipLabel, roundedAvatar = _a.roundedAvatar, icon = _a.icon, iconClassName = _a.iconClassName, description = _a.description, props = __rest(_a, ["children", "className", "avatarUrl", "avatarTooltipLabel", "roundedAvatar", "icon", "iconClassName", "description"]);
|
|
103516
|
-
return (React.createElement("div", __assign({ className: classNames("s-flex s-items-center s-py-2", className || "") }, props),
|
|
103528
|
+
return (React.createElement("div", __assign({ className: classNames("s-flex s-w-full s-items-center s-py-2", className || "") }, props),
|
|
103517
103529
|
avatarUrl && avatarTooltipLabel && (React.createElement(Tooltip, { label: avatarTooltipLabel, position: "above" },
|
|
103518
103530
|
React.createElement(Avatar, { visual: avatarUrl, size: "xs", className: "s-mr-2", isRounded: roundedAvatar !== null && roundedAvatar !== void 0 ? roundedAvatar : false }))),
|
|
103519
103531
|
avatarUrl && !avatarTooltipLabel && (React.createElement(Avatar, { visual: avatarUrl, size: "xs", className: "s-mr-2", isRounded: roundedAvatar !== null && roundedAvatar !== void 0 ? roundedAvatar : false })),
|
|
103520
103532
|
icon && (React.createElement(Icon, { visual: icon, size: "sm", className: classNames("s-mr-2 s-text-element-800", iconClassName || "") })),
|
|
103521
|
-
React.createElement("div", { className: "s-flex" },
|
|
103522
|
-
React.createElement("span", { className: "s-text-sm s-text-element-800" }, children),
|
|
103533
|
+
React.createElement("div", { className: "s-flex s-shrink s-truncate" },
|
|
103534
|
+
React.createElement("span", { className: "s-truncate s-text-sm s-text-element-800" }, children),
|
|
103523
103535
|
description && (React.createElement("span", { className: "s-pl-2 s-text-sm s-text-element-600" }, description)))));
|
|
103524
103536
|
};
|
|
103525
103537
|
DataTable.Caption = function Caption(_a) {
|
|
@@ -103539,8 +103551,8 @@ function Dialog(_a) {
|
|
|
103539
103551
|
React.createElement(qe.Child, { as: React.Fragment, enter: "s-ease-out s-duration-300", enterFrom: "s-opacity-0 s-translate-y-4 s-scale-95", enterTo: "s-opacity-100 s-translate-y-0 s-scale-100", leave: "s-ease-in s-duration-200", leaveFrom: "s-opacity-100 s-translate-y-0 s-scale-100", leaveTo: "s-opacity-0 s-translate-y-4 s-scale-95" },
|
|
103540
103552
|
React.createElement(_t.Panel, { className: classNames("s-relative s-rounded-xl s-border s-border-structure-100 s-bg-structure-0 s-p-4 s-shadow-xl s-transition-all", "s-w-full sm:s-w-[448px]", "s-flex s-flex-col s-gap-6"), ref: referentRef },
|
|
103541
103553
|
React.createElement(_t.Title, { className: "s-text-element-950 s-truncate s-text-lg s-font-medium" }, title),
|
|
103542
|
-
React.createElement("div", { className: "s-
|
|
103543
|
-
React.createElement("div", { className: "s-
|
|
103554
|
+
React.createElement("div", { className: "s-text-base s-text-element-700" }, children),
|
|
103555
|
+
React.createElement("div", { className: "s-flex s-w-full s-justify-end" },
|
|
103544
103556
|
React.createElement(Button.List, null,
|
|
103545
103557
|
!isSaving && (React.createElement(React.Fragment, null,
|
|
103546
103558
|
React.createElement(Button, { label: cancelLabel, variant: "tertiary", onClick: onCancel }),
|
|
@@ -129110,26 +129122,12 @@ function Tab(_a) {
|
|
|
129110
129122
|
}
|
|
129111
129123
|
|
|
129112
129124
|
function TextArea(_a) {
|
|
129113
|
-
var placeholder = _a.placeholder, value = _a.value, onChange = _a.onChange, error = _a.error, _b = _a.showErrorLabel, showErrorLabel = _b === void 0 ? false : _b, className = _a.className, _c = _a.
|
|
129125
|
+
var placeholder = _a.placeholder, value = _a.value, onChange = _a.onChange, error = _a.error, _b = _a.showErrorLabel, showErrorLabel = _b === void 0 ? false : _b, className = _a.className, _c = _a.minRows, minRows = _c === void 0 ? 10 : _c;
|
|
129114
129126
|
var textareaRef = React.useRef(null);
|
|
129115
|
-
React.useEffect(function () {
|
|
129116
|
-
var textarea = textareaRef.current;
|
|
129117
|
-
if (textarea) {
|
|
129118
|
-
textarea.style.height = 'auto'; // Reset height
|
|
129119
|
-
textarea.style.height = "".concat(textarea.scrollHeight, "px"); // Set to scroll height
|
|
129120
|
-
}
|
|
129121
|
-
}, [value]); // Re-run when value changes
|
|
129122
129127
|
return (React.createElement("div", { className: "s-flex s-flex-col s-gap-1 s-p-px" },
|
|
129123
|
-
React.createElement("textarea", { rows:
|
|
129128
|
+
React.createElement("textarea", { rows: minRows, ref: textareaRef, className: classNames("overflow-y-auto s-block s-w-full s-min-w-0 s-rounded-xl s-text-sm s-placeholder-element-700 s-transition-all s-duration-200 s-scrollbar-hide", !error
|
|
129124
129129
|
? "s-border-structure-100 focus:s-border-action-300 focus:s-ring-action-300"
|
|
129125
129130
|
: "s-border-red-500 focus:s-border-red-500 focus:s-ring-red-500", "s-border-structure-200 s-bg-structure-50", "s-resize-y", className !== null && className !== void 0 ? className : ""), placeholder: placeholder, value: value !== null && value !== void 0 ? value : "", onChange: function (e) {
|
|
129126
|
-
var newValue = e.target.value;
|
|
129127
|
-
var textAreaComponent = textareaRef.current;
|
|
129128
|
-
if (textAreaComponent &&
|
|
129129
|
-
(value === null || value === void 0 ? void 0 : value.length) &&
|
|
129130
|
-
newValue.length < value.length) {
|
|
129131
|
-
textAreaComponent.style.height = "auto"; // Reset height to recalculate
|
|
129132
|
-
}
|
|
129133
129131
|
onChange(e.target.value);
|
|
129134
129132
|
} }),
|
|
129135
129133
|
error && showErrorLabel && (React.createElement("div", { className: "s-ml-2 s-text-sm s-text-warning-500" }, error))));
|