@platned/ui 0.9.7 → 0.10.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.
- package/dist/{chunk-O2Y4XUXQ.js → chunk-OVIRTNT4.js} +115 -117
- package/dist/chunk-OVIRTNT4.js.map +1 -0
- package/dist/data-table.cjs +18 -179
- package/dist/data-table.cjs.map +1 -1
- package/dist/data-table.js +1 -1
- package/dist/index.cjs +3270 -2589
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +602 -232
- package/dist/index.js +2449 -1756
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-O2Y4XUXQ.js.map +0 -1
package/dist/data-table.cjs
CHANGED
|
@@ -472,136 +472,6 @@ function useFieldControl() {
|
|
|
472
472
|
disabled: field.disabled || void 0
|
|
473
473
|
};
|
|
474
474
|
}
|
|
475
|
-
var GAP = {
|
|
476
|
-
lg: "gap-2",
|
|
477
|
-
md: "gap-1",
|
|
478
|
-
sm: "gap-0.5"
|
|
479
|
-
};
|
|
480
|
-
function Field({
|
|
481
|
-
children,
|
|
482
|
-
id,
|
|
483
|
-
size: size2 = "md",
|
|
484
|
-
invalid = false,
|
|
485
|
-
required = false,
|
|
486
|
-
disabled = false,
|
|
487
|
-
orientation = "vertical",
|
|
488
|
-
hasDescription = false,
|
|
489
|
-
hasError = false,
|
|
490
|
-
hasHint = false,
|
|
491
|
-
className,
|
|
492
|
-
...rest
|
|
493
|
-
}) {
|
|
494
|
-
const generated = (0, import_react7.useId)();
|
|
495
|
-
const controlId = id ?? generated;
|
|
496
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
497
|
-
FieldContext.Provider,
|
|
498
|
-
{
|
|
499
|
-
value: {
|
|
500
|
-
controlId,
|
|
501
|
-
labelId: `${controlId}-label`,
|
|
502
|
-
descriptionId: `${controlId}-description`,
|
|
503
|
-
errorId: `${controlId}-error`,
|
|
504
|
-
hintId: `${controlId}-hint`,
|
|
505
|
-
hasDescription,
|
|
506
|
-
hasError,
|
|
507
|
-
hasHint,
|
|
508
|
-
invalid: invalid || hasError,
|
|
509
|
-
required,
|
|
510
|
-
disabled,
|
|
511
|
-
size: size2
|
|
512
|
-
},
|
|
513
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
514
|
-
"div",
|
|
515
|
-
{
|
|
516
|
-
role: orientation === "horizontal" ? "group" : void 0,
|
|
517
|
-
"data-slot": "field",
|
|
518
|
-
"data-invalid": invalid || hasError || void 0,
|
|
519
|
-
"data-disabled": disabled || void 0,
|
|
520
|
-
className: cn(
|
|
521
|
-
orientation === "horizontal" ? "flex flex-row items-center justify-between gap-3" : cn("flex flex-col", GAP[size2]),
|
|
522
|
-
className
|
|
523
|
-
),
|
|
524
|
-
...rest,
|
|
525
|
-
children
|
|
526
|
-
}
|
|
527
|
-
)
|
|
528
|
-
}
|
|
529
|
-
);
|
|
530
|
-
}
|
|
531
|
-
var LABEL_TEXT = {
|
|
532
|
-
lg: "text-body",
|
|
533
|
-
md: "text-body-sm",
|
|
534
|
-
sm: "text-body-tiny"
|
|
535
|
-
};
|
|
536
|
-
function FieldLabel({ children, className, htmlFor, ...rest }) {
|
|
537
|
-
const field = useFieldContext();
|
|
538
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
539
|
-
"label",
|
|
540
|
-
{
|
|
541
|
-
id: field?.labelId,
|
|
542
|
-
htmlFor: htmlFor ?? field?.controlId,
|
|
543
|
-
"data-slot": "field-label",
|
|
544
|
-
className: cn(
|
|
545
|
-
LABEL_TEXT[field?.size ?? "md"],
|
|
546
|
-
field?.disabled ? "text-disabled" : "text-default",
|
|
547
|
-
// The required marker is CSS generated content, not a child element. An
|
|
548
|
-
// `<span aria-hidden>*</span>` would be correct for accessible-name computation
|
|
549
|
-
// (which skips aria-hidden) but it still lands in `textContent`, so every
|
|
550
|
-
// `getByLabelText('Name')` — ours and every consumer's — would have to become
|
|
551
|
-
// `/Name/`. Generated content is in neither, and the real signal is
|
|
552
|
-
// `aria-required` on the control regardless.
|
|
553
|
-
field?.required && "after:ml-0.5 after:text-danger after:content-['*']",
|
|
554
|
-
className
|
|
555
|
-
),
|
|
556
|
-
...rest,
|
|
557
|
-
children
|
|
558
|
-
}
|
|
559
|
-
);
|
|
560
|
-
}
|
|
561
|
-
function FieldDescription({ children, className, ...rest }) {
|
|
562
|
-
const field = useFieldContext();
|
|
563
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
564
|
-
"p",
|
|
565
|
-
{
|
|
566
|
-
id: field?.descriptionId,
|
|
567
|
-
"data-slot": "field-description",
|
|
568
|
-
className: cn(
|
|
569
|
-
LABEL_TEXT[field?.size ?? "md"],
|
|
570
|
-
field?.disabled ? "text-disabled" : "text-default-secondary",
|
|
571
|
-
className
|
|
572
|
-
),
|
|
573
|
-
...rest,
|
|
574
|
-
children
|
|
575
|
-
}
|
|
576
|
-
);
|
|
577
|
-
}
|
|
578
|
-
function FieldError({ children, className, ...rest }) {
|
|
579
|
-
const field = useFieldContext();
|
|
580
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
581
|
-
"p",
|
|
582
|
-
{
|
|
583
|
-
id: field?.errorId,
|
|
584
|
-
role: "alert",
|
|
585
|
-
"data-slot": "field-error",
|
|
586
|
-
className: cn(LABEL_TEXT[field?.size ?? "md"], "text-danger", className),
|
|
587
|
-
...rest,
|
|
588
|
-
children
|
|
589
|
-
}
|
|
590
|
-
);
|
|
591
|
-
}
|
|
592
|
-
function FieldHint({ children, className, ...rest }) {
|
|
593
|
-
const field = useFieldContext();
|
|
594
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
595
|
-
"p",
|
|
596
|
-
{
|
|
597
|
-
id: field?.hintId,
|
|
598
|
-
"data-slot": "field-hint",
|
|
599
|
-
className: cn(LABEL_TEXT[field?.size ?? "md"], "text-default-secondary", className),
|
|
600
|
-
...rest,
|
|
601
|
-
children
|
|
602
|
-
}
|
|
603
|
-
);
|
|
604
|
-
}
|
|
605
475
|
var FieldSet = (0, import_react7.forwardRef)(function FieldSet2({ children, className, ...rest }, ref) {
|
|
606
476
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
607
477
|
"fieldset",
|
|
@@ -833,7 +703,7 @@ function CheckControl({
|
|
|
833
703
|
|
|
834
704
|
// src/components/forms/checkbox.tsx
|
|
835
705
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
836
|
-
var
|
|
706
|
+
var LABEL_TEXT = {
|
|
837
707
|
sm: "text-body-tiny",
|
|
838
708
|
md: "text-body-xs"
|
|
839
709
|
};
|
|
@@ -902,7 +772,7 @@ var Checkbox = (0, import_react10.forwardRef)(function Checkbox2({
|
|
|
902
772
|
size: size2
|
|
903
773
|
}
|
|
904
774
|
),
|
|
905
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: (0, import_clsx10.default)(
|
|
775
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: (0, import_clsx10.default)(LABEL_TEXT[size2], "min-w-0 text-default [overflow-wrap:anywhere]"), children: label })
|
|
906
776
|
]
|
|
907
777
|
}
|
|
908
778
|
),
|
|
@@ -912,7 +782,7 @@ var Checkbox = (0, import_react10.forwardRef)(function Checkbox2({
|
|
|
912
782
|
id: descriptionId,
|
|
913
783
|
className: (0, import_clsx10.default)(
|
|
914
784
|
"mt-0.5 pl-[26px] [overflow-wrap:anywhere]",
|
|
915
|
-
|
|
785
|
+
LABEL_TEXT[size2],
|
|
916
786
|
disabled ? "text-disabled" : "text-default-secondary"
|
|
917
787
|
),
|
|
918
788
|
children: description
|
|
@@ -1427,8 +1297,8 @@ function isGroup(entry) {
|
|
|
1427
1297
|
function flatten(entries) {
|
|
1428
1298
|
return entries.flatMap((entry) => isGroup(entry) ? entry.options : [entry]);
|
|
1429
1299
|
}
|
|
1430
|
-
var
|
|
1431
|
-
function
|
|
1300
|
+
var Select = (0, import_react17.forwardRef)(
|
|
1301
|
+
function Select2({
|
|
1432
1302
|
options,
|
|
1433
1303
|
value: valueProp,
|
|
1434
1304
|
defaultValue = null,
|
|
@@ -1436,6 +1306,7 @@ var SelectControl = (0, import_react17.forwardRef)(
|
|
|
1436
1306
|
name,
|
|
1437
1307
|
size: sizeProp,
|
|
1438
1308
|
invalid = false,
|
|
1309
|
+
required = false,
|
|
1439
1310
|
placeholder = "Select\u2026",
|
|
1440
1311
|
className,
|
|
1441
1312
|
onKeyDown,
|
|
@@ -1462,10 +1333,10 @@ var SelectControl = (0, import_react17.forwardRef)(
|
|
|
1462
1333
|
const selected = flat.find((option) => option.value === value) ?? null;
|
|
1463
1334
|
const isInvalid = invalid || !!field["aria-invalid"];
|
|
1464
1335
|
const isDisabled = props.disabled ?? field.disabled;
|
|
1465
|
-
const isRequired = Boolean(field["aria-required"]) || Boolean(props["aria-required"]);
|
|
1336
|
+
const isRequired = required || Boolean(field["aria-required"]) || Boolean(props["aria-required"]);
|
|
1466
1337
|
if (!fieldContext && !props["aria-label"] && !props["aria-labelledby"]) {
|
|
1467
1338
|
devWarn(
|
|
1468
|
-
"
|
|
1339
|
+
"Select outside a Field needs aria-label or aria-labelledby; otherwise it is named only by its value."
|
|
1469
1340
|
);
|
|
1470
1341
|
}
|
|
1471
1342
|
const roving = useRovingFocus({ orientation: "vertical", loop: true, typeahead: true });
|
|
@@ -1572,6 +1443,8 @@ var SelectControl = (0, import_react17.forwardRef)(
|
|
|
1572
1443
|
"aria-labelledby": fieldContext ? `${fieldContext.labelId} ${valueId}` : void 0,
|
|
1573
1444
|
"data-size": size2,
|
|
1574
1445
|
...field,
|
|
1446
|
+
"aria-invalid": isInvalid || void 0,
|
|
1447
|
+
"aria-required": isRequired || void 0,
|
|
1575
1448
|
disabled: isDisabled,
|
|
1576
1449
|
onClick: () => setOpen(!open),
|
|
1577
1450
|
onKeyDown: triggerKeyDown,
|
|
@@ -1656,45 +1529,11 @@ var SelectControl = (0, import_react17.forwardRef)(
|
|
|
1656
1529
|
] });
|
|
1657
1530
|
}
|
|
1658
1531
|
);
|
|
1659
|
-
var
|
|
1660
|
-
label,
|
|
1661
|
-
description,
|
|
1662
|
-
error,
|
|
1663
|
-
hint,
|
|
1664
|
-
size: sizeProp,
|
|
1665
|
-
className,
|
|
1666
|
-
disabled,
|
|
1667
|
-
required,
|
|
1668
|
-
id,
|
|
1669
|
-
...props
|
|
1670
|
-
}, ref) {
|
|
1671
|
-
const size2 = useControlSize(sizeProp);
|
|
1672
|
-
const hasError = !!error;
|
|
1673
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1674
|
-
Field,
|
|
1675
|
-
{
|
|
1676
|
-
id,
|
|
1677
|
-
size: size2,
|
|
1678
|
-
disabled,
|
|
1679
|
-
required,
|
|
1680
|
-
hasDescription: !!description,
|
|
1681
|
-
hasError,
|
|
1682
|
-
hasHint: !!hint,
|
|
1683
|
-
className,
|
|
1684
|
-
children: [
|
|
1685
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FieldLabel, { children: label }),
|
|
1686
|
-
description && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FieldDescription, { children: description }),
|
|
1687
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SelectControl, { ref, size: size2, invalid: hasError, disabled, ...props }),
|
|
1688
|
-
hasError && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FieldError, { children: error }),
|
|
1689
|
-
!hasError && hint && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FieldHint, { children: hint })
|
|
1690
|
-
]
|
|
1691
|
-
}
|
|
1692
|
-
);
|
|
1693
|
-
});
|
|
1532
|
+
var SelectControl = Select;
|
|
1694
1533
|
|
|
1695
1534
|
// src/components/chrome/pagination.tsx
|
|
1696
1535
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1697
|
-
var
|
|
1536
|
+
var GAP = "\u2026";
|
|
1698
1537
|
function paginationRange(page, pageCount, siblingCount = 1) {
|
|
1699
1538
|
const totalSlots = siblingCount * 2 + 5;
|
|
1700
1539
|
if (pageCount <= totalSlots) {
|
|
@@ -1706,17 +1545,17 @@ function paginationRange(page, pageCount, siblingCount = 1) {
|
|
|
1706
1545
|
const showRightGap = right < pageCount - 2;
|
|
1707
1546
|
if (!showLeftGap && showRightGap) {
|
|
1708
1547
|
const count = siblingCount * 2 + 3;
|
|
1709
|
-
return [...Array.from({ length: count }, (_, i) => i + 1),
|
|
1548
|
+
return [...Array.from({ length: count }, (_, i) => i + 1), GAP, pageCount];
|
|
1710
1549
|
}
|
|
1711
1550
|
if (showLeftGap && !showRightGap) {
|
|
1712
1551
|
const count = siblingCount * 2 + 3;
|
|
1713
|
-
return [1,
|
|
1552
|
+
return [1, GAP, ...Array.from({ length: count }, (_, i) => pageCount - count + 1 + i)];
|
|
1714
1553
|
}
|
|
1715
1554
|
return [
|
|
1716
1555
|
1,
|
|
1717
|
-
|
|
1556
|
+
GAP,
|
|
1718
1557
|
...Array.from({ length: right - left + 1 }, (_, i) => left + i),
|
|
1719
|
-
|
|
1558
|
+
GAP,
|
|
1720
1559
|
pageCount
|
|
1721
1560
|
];
|
|
1722
1561
|
}
|
|
@@ -1788,12 +1627,12 @@ var Pagination = (0, import_react18.forwardRef)(function Pagination2({
|
|
|
1788
1627
|
}
|
|
1789
1628
|
)
|
|
1790
1629
|
) : paginationRange(page, pageCount, siblingCount).map(
|
|
1791
|
-
(entry, index) => entry ===
|
|
1630
|
+
(entry, index) => entry === GAP ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1792
1631
|
"span",
|
|
1793
1632
|
{
|
|
1794
1633
|
"aria-hidden": true,
|
|
1795
1634
|
className: "inline-flex size-9 items-center justify-center text-body-sm text-default-tertiary",
|
|
1796
|
-
children:
|
|
1635
|
+
children: GAP
|
|
1797
1636
|
},
|
|
1798
1637
|
`gap-${index}`
|
|
1799
1638
|
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|