@adsgency_npm/adsgency-ads-ui 0.1.0-alpha.10 → 0.1.0-alpha.12
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/index.cjs +127 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +126 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -68,6 +68,7 @@ __export(src_exports, {
|
|
|
68
68
|
AdsDatePicker: () => AdsDatePicker,
|
|
69
69
|
AdsDateTimePicker: () => AdsDateTimePicker,
|
|
70
70
|
AdsDialog: () => AdsDialog,
|
|
71
|
+
AdsDialogBody: () => AdsDialogBody,
|
|
71
72
|
AdsDialogClose: () => AdsDialogClose,
|
|
72
73
|
AdsDialogContent: () => AdsDialogContent,
|
|
73
74
|
AdsDialogDescription: () => AdsDialogDescription,
|
|
@@ -217,6 +218,7 @@ var adsDefaultMessages = {
|
|
|
217
218
|
collapseRow: "Collapse row",
|
|
218
219
|
expandRow: "Expand row",
|
|
219
220
|
filterColumn: "Filter column",
|
|
221
|
+
loadingRows: "Loading table rows",
|
|
220
222
|
noDataAvailable: "No data available",
|
|
221
223
|
selectAllRows: "Select all rows",
|
|
222
224
|
selectRow: "Select row",
|
|
@@ -266,6 +268,7 @@ var adsDefaultMessages = {
|
|
|
266
268
|
collapseRow: "\u6536\u8D77\u884C",
|
|
267
269
|
expandRow: "\u5C55\u5F00\u884C",
|
|
268
270
|
filterColumn: "\u7B5B\u9009\u5217",
|
|
271
|
+
loadingRows: "\u6B63\u5728\u52A0\u8F7D\u8868\u683C\u884C",
|
|
269
272
|
noDataAvailable: "\u6682\u65E0\u6570\u636E",
|
|
270
273
|
selectAllRows: "\u9009\u62E9\u5168\u90E8\u884C",
|
|
271
274
|
selectRow: "\u9009\u62E9\u884C",
|
|
@@ -4557,18 +4560,33 @@ var SKELETON_ROW_COUNT = 4;
|
|
|
4557
4560
|
var FLEX_WIDTH_UNIT = 160;
|
|
4558
4561
|
var sizeClassNames = {
|
|
4559
4562
|
small: {
|
|
4563
|
+
bodyHeight: 32,
|
|
4560
4564
|
cell: "py-1.5 text-xs leading-4",
|
|
4565
|
+
headHeight: 32,
|
|
4561
4566
|
head: "h-8 py-1.5 text-xs leading-4"
|
|
4562
4567
|
},
|
|
4563
4568
|
middle: {
|
|
4569
|
+
bodyHeight: 40,
|
|
4564
4570
|
cell: "py-2 text-sm leading-5",
|
|
4571
|
+
headHeight: 40,
|
|
4565
4572
|
head: "h-10 py-2 text-sm leading-5"
|
|
4566
4573
|
},
|
|
4567
4574
|
large: {
|
|
4575
|
+
bodyHeight: 48,
|
|
4568
4576
|
cell: "py-3 text-base leading-6",
|
|
4577
|
+
headHeight: 48,
|
|
4569
4578
|
head: "h-12 py-3 text-base leading-6"
|
|
4570
4579
|
}
|
|
4571
4580
|
};
|
|
4581
|
+
function getSpinnerLoadingHeight(scrollY, density) {
|
|
4582
|
+
if (typeof scrollY === "number") {
|
|
4583
|
+
return Math.max(scrollY - density.headHeight, density.bodyHeight * SKELETON_ROW_COUNT);
|
|
4584
|
+
}
|
|
4585
|
+
if (typeof scrollY === "string") {
|
|
4586
|
+
return `max(calc(${scrollY} - ${density.headHeight}px), ${density.bodyHeight * SKELETON_ROW_COUNT}px)`;
|
|
4587
|
+
}
|
|
4588
|
+
return density.bodyHeight * SKELETON_ROW_COUNT;
|
|
4589
|
+
}
|
|
4572
4590
|
function getColumnKey(column, index) {
|
|
4573
4591
|
if (column.key !== void 0) {
|
|
4574
4592
|
return String(column.key);
|
|
@@ -4779,6 +4797,8 @@ function AdsDataTable({
|
|
|
4779
4797
|
dataSource = [],
|
|
4780
4798
|
rowKey,
|
|
4781
4799
|
loading = false,
|
|
4800
|
+
loadingVariant = "skeleton",
|
|
4801
|
+
expandedRowSurface = "inset",
|
|
4782
4802
|
emptyText,
|
|
4783
4803
|
emptyState,
|
|
4784
4804
|
rowClassName,
|
|
@@ -4877,8 +4897,14 @@ function AdsDataTable({
|
|
|
4877
4897
|
const hasSelectionColumn = Boolean(rowSelection);
|
|
4878
4898
|
const hasExpandableColumn = Boolean(expandable?.expandedRowRender);
|
|
4879
4899
|
const density = sizeClassNames[size];
|
|
4900
|
+
const columnCount = resolvedColumns.length + Number(hasSelectionColumn) + Number(hasExpandableColumn);
|
|
4880
4901
|
const paginationMode = pagination === false ? "client" : pagination.mode ?? "client";
|
|
4881
4902
|
const allowsRowSelectionByClick = Boolean(rowSelection) && !suppressRowClickSelection;
|
|
4903
|
+
const spinnerLoadingHeight = React42.useMemo(
|
|
4904
|
+
() => getSpinnerLoadingHeight(scroll?.y, density),
|
|
4905
|
+
[density, scroll?.y]
|
|
4906
|
+
);
|
|
4907
|
+
const expandedRowContentClassName = expandedRowSurface === "plain" ? "bg-transparent p-4" : expandedRowSurface === "subtle" ? "mx-6 my-4 rounded-[20px] border border-border bg-transparent p-4" : "border-t border-border bg-popover/40 p-4";
|
|
4882
4908
|
const filterValues = React42.useMemo(
|
|
4883
4909
|
() => resolvedColumns.reduce((accumulator, column, index) => {
|
|
4884
4910
|
const columnKey = getColumnKey(column, index);
|
|
@@ -5234,7 +5260,26 @@ function AdsDataTable({
|
|
|
5234
5260
|
);
|
|
5235
5261
|
})
|
|
5236
5262
|
] }) }),
|
|
5237
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AdsTableBody, { children: loading
|
|
5263
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AdsTableBody, { children: loading && loadingVariant === "spinner" ? [
|
|
5264
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AdsTableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
5265
|
+
AdsTableCell,
|
|
5266
|
+
{
|
|
5267
|
+
className: "p-0",
|
|
5268
|
+
colSpan: columnCount,
|
|
5269
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
5270
|
+
"div",
|
|
5271
|
+
{
|
|
5272
|
+
"aria-label": messages.table.loadingRows,
|
|
5273
|
+
"aria-live": "polite",
|
|
5274
|
+
className: "flex items-center justify-center px-6 py-8 text-foreground",
|
|
5275
|
+
role: "status",
|
|
5276
|
+
style: { minHeight: spinnerLoadingHeight },
|
|
5277
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AdsSpinner, { size: "lg", tone: "foreground" })
|
|
5278
|
+
}
|
|
5279
|
+
)
|
|
5280
|
+
}
|
|
5281
|
+
) }, "spinner-row")
|
|
5282
|
+
] : loading ? Array.from({ length: SKELETON_ROW_COUNT }, (_, skeletonIndex) => /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(AdsTableRow, { children: [
|
|
5238
5283
|
hasSelectionColumn ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AdsTableCell, { className: "w-12 p-2", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AdsSkeleton, { className: "h-4 w-4 rounded-[4px]" }) }) : null,
|
|
5239
5284
|
hasExpandableColumn ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AdsTableCell, { className: "w-12 p-2", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AdsSkeleton, { className: "h-4 w-4 rounded-[4px]" }) }) : null,
|
|
5240
5285
|
resolvedColumns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
@@ -5337,7 +5382,7 @@ function AdsDataTable({
|
|
|
5337
5382
|
"div",
|
|
5338
5383
|
{
|
|
5339
5384
|
className: cn(
|
|
5340
|
-
|
|
5385
|
+
expandedRowContentClassName,
|
|
5341
5386
|
classNames?.expandedRowContent
|
|
5342
5387
|
),
|
|
5343
5388
|
children: expandable?.expandedRowRender?.(record, index)
|
|
@@ -5350,7 +5395,7 @@ function AdsDataTable({
|
|
|
5350
5395
|
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AdsTableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
5351
5396
|
AdsTableCell,
|
|
5352
5397
|
{
|
|
5353
|
-
colSpan:
|
|
5398
|
+
colSpan: columnCount,
|
|
5354
5399
|
className: cn("p-0", classNames?.emptyRowCell),
|
|
5355
5400
|
children: renderedEmptyState
|
|
5356
5401
|
}
|
|
@@ -6285,7 +6330,8 @@ var DialogPrimitive = __toESM(require("@radix-ui/react-dialog"), 1);
|
|
|
6285
6330
|
var import_lucide_react17 = require("lucide-react");
|
|
6286
6331
|
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
6287
6332
|
var overlayClassName2 = "fixed inset-0 z-50 bg-black/80 backdrop-blur-[2px] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0";
|
|
6288
|
-
var contentClassName2 = "fixed left-1/2 top-1/2 z-50
|
|
6333
|
+
var contentClassName2 = "fixed left-1/2 top-1/2 z-50 flex max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-[423px] -translate-x-1/2 -translate-y-1/2 flex-col gap-lg overflow-hidden rounded-radius-md border border-border bg-card p-xl shadow-[0px_4px_6px_-4px_rgba(0,0,0,0.1),0px_10px_15px_-3px_rgba(0,0,0,0.1)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]";
|
|
6334
|
+
var bodyClassName = "min-h-0 flex-1 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]";
|
|
6289
6335
|
var closeButtonClassName = "absolute right-xl top-xl inline-flex h-6 w-6 items-center justify-center rounded-sm opacity-80 transition-opacity hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card disabled:pointer-events-none";
|
|
6290
6336
|
var Dialog = DialogPrimitive.Root;
|
|
6291
6337
|
var DialogTrigger = DialogPrimitive.Trigger;
|
|
@@ -6311,15 +6357,83 @@ var DialogClose = React59.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
6311
6357
|
}
|
|
6312
6358
|
));
|
|
6313
6359
|
DialogClose.displayName = "DialogClose";
|
|
6360
|
+
function flattenDialogChildren(children) {
|
|
6361
|
+
const nodes = [];
|
|
6362
|
+
React59.Children.forEach(children, (child) => {
|
|
6363
|
+
if (React59.isValidElement(child) && child.type === React59.Fragment) {
|
|
6364
|
+
nodes.push(...flattenDialogChildren(child.props.children));
|
|
6365
|
+
return;
|
|
6366
|
+
}
|
|
6367
|
+
nodes.push(child);
|
|
6368
|
+
});
|
|
6369
|
+
return nodes;
|
|
6370
|
+
}
|
|
6371
|
+
function isDialogSlotElement(child, component) {
|
|
6372
|
+
return React59.isValidElement(child) && child.type === component;
|
|
6373
|
+
}
|
|
6374
|
+
var DialogBody = React59.forwardRef(
|
|
6375
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
6376
|
+
"div",
|
|
6377
|
+
{
|
|
6378
|
+
className: cn(bodyClassName, className),
|
|
6379
|
+
"data-slot": "ads-dialog-body",
|
|
6380
|
+
ref,
|
|
6381
|
+
...props
|
|
6382
|
+
}
|
|
6383
|
+
)
|
|
6384
|
+
);
|
|
6385
|
+
DialogBody.displayName = "DialogBody";
|
|
6314
6386
|
var DialogContent = React59.forwardRef(
|
|
6315
6387
|
({ children, className, closeLabel, hideCloseButton = false, ...props }, ref) => {
|
|
6316
6388
|
const { messages } = useAdsI18n();
|
|
6317
6389
|
const resolvedCloseLabel = closeLabel ?? messages.dialog.close;
|
|
6390
|
+
const childNodes = flattenDialogChildren(children);
|
|
6391
|
+
const headerIndex = childNodes.findIndex(
|
|
6392
|
+
(child) => isDialogSlotElement(child, DialogHeader)
|
|
6393
|
+
);
|
|
6394
|
+
let footerIndex = -1;
|
|
6395
|
+
for (let index = childNodes.length - 1; index >= 0; index -= 1) {
|
|
6396
|
+
if (isDialogSlotElement(childNodes[index], DialogFooter)) {
|
|
6397
|
+
footerIndex = index;
|
|
6398
|
+
break;
|
|
6399
|
+
}
|
|
6400
|
+
}
|
|
6401
|
+
const headerNode = headerIndex >= 0 ? childNodes[headerIndex] : null;
|
|
6402
|
+
const generatedHeaderNodes = [];
|
|
6403
|
+
if (headerNode === null) {
|
|
6404
|
+
for (let index = 0; index < childNodes.length; index += 1) {
|
|
6405
|
+
if (index === footerIndex) {
|
|
6406
|
+
break;
|
|
6407
|
+
}
|
|
6408
|
+
const child = childNodes[index];
|
|
6409
|
+
const isHeaderChild = isDialogSlotElement(child, DialogTitle) || isDialogSlotElement(child, DialogDescription);
|
|
6410
|
+
if (!isHeaderChild) {
|
|
6411
|
+
break;
|
|
6412
|
+
}
|
|
6413
|
+
generatedHeaderNodes.push(child);
|
|
6414
|
+
}
|
|
6415
|
+
}
|
|
6416
|
+
const footerNode = footerIndex >= 0 && footerIndex !== headerIndex ? childNodes[footerIndex] : null;
|
|
6417
|
+
const bodyNodes = childNodes.filter(
|
|
6418
|
+
(child, index) => {
|
|
6419
|
+
if (index === headerIndex || index === footerIndex) {
|
|
6420
|
+
return false;
|
|
6421
|
+
}
|
|
6422
|
+
return !generatedHeaderNodes.includes(child);
|
|
6423
|
+
}
|
|
6424
|
+
);
|
|
6425
|
+
const explicitBodyNodes = bodyNodes.filter(
|
|
6426
|
+
(child) => isDialogSlotElement(child, DialogBody)
|
|
6427
|
+
);
|
|
6428
|
+
const looseBodyNodes = bodyNodes.filter(
|
|
6429
|
+
(child) => !isDialogSlotElement(child, DialogBody)
|
|
6430
|
+
);
|
|
6318
6431
|
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(DialogPortal, { children: [
|
|
6319
6432
|
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(DialogOverlay, {}),
|
|
6320
6433
|
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
6321
6434
|
DialogPrimitive.Content,
|
|
6322
6435
|
{
|
|
6436
|
+
"data-slot": "ads-dialog-content",
|
|
6323
6437
|
className: cn(
|
|
6324
6438
|
contentClassName2,
|
|
6325
6439
|
adsTextColorClassName.card,
|
|
@@ -6328,7 +6442,11 @@ var DialogContent = React59.forwardRef(
|
|
|
6328
6442
|
ref,
|
|
6329
6443
|
...props,
|
|
6330
6444
|
children: [
|
|
6331
|
-
|
|
6445
|
+
headerNode,
|
|
6446
|
+
headerNode === null && generatedHeaderNodes.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(DialogHeader, { children: generatedHeaderNodes }) : null,
|
|
6447
|
+
explicitBodyNodes.length > 0 ? explicitBodyNodes : null,
|
|
6448
|
+
looseBodyNodes.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(DialogBody, { children: looseBodyNodes }) : null,
|
|
6449
|
+
footerNode,
|
|
6332
6450
|
!hideCloseButton ? /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
6333
6451
|
DialogPrimitive.Close,
|
|
6334
6452
|
{
|
|
@@ -6351,6 +6469,7 @@ var DialogHeader = React59.forwardRef(
|
|
|
6351
6469
|
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
6352
6470
|
"div",
|
|
6353
6471
|
{
|
|
6472
|
+
"data-slot": "ads-dialog-header",
|
|
6354
6473
|
className: cn("flex flex-col gap-sm pr-8 text-left", className),
|
|
6355
6474
|
ref,
|
|
6356
6475
|
...props
|
|
@@ -6362,6 +6481,7 @@ var DialogFooter = React59.forwardRef(
|
|
|
6362
6481
|
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
6363
6482
|
"div",
|
|
6364
6483
|
{
|
|
6484
|
+
"data-slot": "ads-dialog-footer",
|
|
6365
6485
|
className: cn(
|
|
6366
6486
|
"flex flex-col-reverse gap-sm sm:flex-row sm:justify-end",
|
|
6367
6487
|
className
|
|
@@ -6401,6 +6521,7 @@ var AdsDialogOverlay = DialogOverlay;
|
|
|
6401
6521
|
var AdsDialogClose = DialogClose;
|
|
6402
6522
|
var AdsDialogContent = DialogContent;
|
|
6403
6523
|
var AdsDialogHeader = DialogHeader;
|
|
6524
|
+
var AdsDialogBody = DialogBody;
|
|
6404
6525
|
var AdsDialogFooter = DialogFooter;
|
|
6405
6526
|
var AdsDialogTitle = DialogTitle;
|
|
6406
6527
|
var AdsDialogDescription = DialogDescription;
|
|
@@ -6669,6 +6790,7 @@ var designTokens = {
|
|
|
6669
6790
|
AdsDatePicker,
|
|
6670
6791
|
AdsDateTimePicker,
|
|
6671
6792
|
AdsDialog,
|
|
6793
|
+
AdsDialogBody,
|
|
6672
6794
|
AdsDialogClose,
|
|
6673
6795
|
AdsDialogContent,
|
|
6674
6796
|
AdsDialogDescription,
|