@dimaan/ui 0.0.3 → 0.0.5
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 +211 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -2
- package/dist/index.d.ts +106 -2
- package/dist/index.js +206 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -2
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,7 @@ var clsx = require('clsx');
|
|
|
5
5
|
var tailwindMerge = require('tailwind-merge');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var lucideReact = require('lucide-react');
|
|
8
|
+
var reactHookForm = require('react-hook-form');
|
|
8
9
|
|
|
9
10
|
// src/components/dashboard-layout/context.ts
|
|
10
11
|
var DashboardLayoutContext = react.createContext(null);
|
|
@@ -744,6 +745,125 @@ var Checkbox = react.forwardRef(function Checkbox2({
|
|
|
744
745
|
)
|
|
745
746
|
] });
|
|
746
747
|
});
|
|
748
|
+
function Field(props) {
|
|
749
|
+
const formContext = reactHookForm.useFormContext();
|
|
750
|
+
if (props.name !== void 0) {
|
|
751
|
+
const { control: explicitControl, name, children: children2, ...layout2 } = props;
|
|
752
|
+
const control = explicitControl ?? formContext?.control;
|
|
753
|
+
if (!control) {
|
|
754
|
+
throw new Error(
|
|
755
|
+
'<Field name="..."> requires either a `control` prop OR being rendered inside <FormProvider>. Wrap your form with <FormProvider {...form}> from react-hook-form, or pass `control={form.control}` explicitly.'
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
759
|
+
reactHookForm.Controller,
|
|
760
|
+
{
|
|
761
|
+
control,
|
|
762
|
+
name,
|
|
763
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxRuntime.jsx(FieldShell, { ...layout2, error: fieldState.error?.message, invalid: fieldState.invalid, children: cloneFieldChild(children2, {
|
|
764
|
+
name: field.name,
|
|
765
|
+
value: field.value ?? "",
|
|
766
|
+
onChange: field.onChange,
|
|
767
|
+
onBlur: field.onBlur,
|
|
768
|
+
ref: field.ref,
|
|
769
|
+
disabled: layout2.disabled ?? field.disabled
|
|
770
|
+
}) })
|
|
771
|
+
}
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
const { children, error, invalid, ...layout } = props;
|
|
775
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FieldShell, { ...layout, error, invalid: invalid ?? Boolean(error), children });
|
|
776
|
+
}
|
|
777
|
+
function FieldShell({
|
|
778
|
+
label,
|
|
779
|
+
description,
|
|
780
|
+
error,
|
|
781
|
+
invalid = false,
|
|
782
|
+
required = false,
|
|
783
|
+
disabled = false,
|
|
784
|
+
fullWidth = true,
|
|
785
|
+
className,
|
|
786
|
+
children
|
|
787
|
+
}) {
|
|
788
|
+
const reactId = react.useId();
|
|
789
|
+
if (!react.isValidElement(children)) {
|
|
790
|
+
throw new Error("<Field> requires a single React element as its child.");
|
|
791
|
+
}
|
|
792
|
+
const childProps = children.props;
|
|
793
|
+
const id = childProps.id ?? reactId;
|
|
794
|
+
const descriptionId = `${id}-description`;
|
|
795
|
+
const errorId = `${id}-error`;
|
|
796
|
+
const showError = invalid && error !== void 0 && error !== null && error !== false;
|
|
797
|
+
const showDescription = !showError && description !== void 0 && description !== null;
|
|
798
|
+
const userDescribedBy = childProps["aria-describedby"];
|
|
799
|
+
const describedBy = [userDescribedBy, showDescription ? descriptionId : null, showError ? errorId : null].filter(Boolean).join(" ") || void 0;
|
|
800
|
+
const enhancedChild = cloneFieldChild(children, {
|
|
801
|
+
id,
|
|
802
|
+
"aria-invalid": childProps["aria-invalid"] ?? (invalid || void 0),
|
|
803
|
+
"aria-describedby": describedBy,
|
|
804
|
+
disabled: childProps.disabled ?? disabled,
|
|
805
|
+
required: childProps.required ?? required
|
|
806
|
+
});
|
|
807
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
808
|
+
"div",
|
|
809
|
+
{
|
|
810
|
+
"data-invalid": invalid || void 0,
|
|
811
|
+
"data-disabled": disabled || void 0,
|
|
812
|
+
className: cn("flex flex-col gap-1.5", fullWidth && "w-full", className),
|
|
813
|
+
children: [
|
|
814
|
+
label !== void 0 && label !== null && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
815
|
+
"label",
|
|
816
|
+
{
|
|
817
|
+
htmlFor: id,
|
|
818
|
+
className: cn(
|
|
819
|
+
"text-sm font-medium select-none text-foreground",
|
|
820
|
+
disabled && "opacity-50",
|
|
821
|
+
invalid && "text-destructive"
|
|
822
|
+
),
|
|
823
|
+
children: [
|
|
824
|
+
label,
|
|
825
|
+
required && /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "ms-0.5 text-destructive", children: "*" })
|
|
826
|
+
]
|
|
827
|
+
}
|
|
828
|
+
),
|
|
829
|
+
enhancedChild,
|
|
830
|
+
showError ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
831
|
+
"p",
|
|
832
|
+
{
|
|
833
|
+
id: errorId,
|
|
834
|
+
role: "alert",
|
|
835
|
+
"aria-live": "polite",
|
|
836
|
+
className: "text-xs font-medium text-destructive",
|
|
837
|
+
children: error
|
|
838
|
+
}
|
|
839
|
+
) : showDescription ? /* @__PURE__ */ jsxRuntime.jsx("p", { id: descriptionId, className: "text-xs text-muted-foreground", children: description }) : null
|
|
840
|
+
]
|
|
841
|
+
}
|
|
842
|
+
);
|
|
843
|
+
}
|
|
844
|
+
function cloneFieldChild(child, injected) {
|
|
845
|
+
const childProps = child.props;
|
|
846
|
+
const childRef = child.ref;
|
|
847
|
+
const merged = { ...injected };
|
|
848
|
+
for (const key of Object.keys(childProps)) {
|
|
849
|
+
const value = childProps[key];
|
|
850
|
+
if (value !== void 0) merged[key] = value;
|
|
851
|
+
}
|
|
852
|
+
if (injected.ref) {
|
|
853
|
+
merged.ref = mergeRefs(injected.ref, childRef);
|
|
854
|
+
} else if (childRef) {
|
|
855
|
+
merged.ref = childRef;
|
|
856
|
+
}
|
|
857
|
+
return react.cloneElement(child, merged);
|
|
858
|
+
}
|
|
859
|
+
function mergeRefs(...refs) {
|
|
860
|
+
return (instance) => {
|
|
861
|
+
for (const ref of refs) {
|
|
862
|
+
if (typeof ref === "function") ref(instance);
|
|
863
|
+
else if (ref && typeof ref === "object") ref.current = instance;
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
}
|
|
747
867
|
|
|
748
868
|
// src/components/input/inputVariants.ts
|
|
749
869
|
var inputVariantClass = {
|
|
@@ -1386,6 +1506,91 @@ function SortIndicator({ active, direction }) {
|
|
|
1386
1506
|
return direction === "asc" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { "aria-hidden": "true", className }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { "aria-hidden": "true", className });
|
|
1387
1507
|
}
|
|
1388
1508
|
|
|
1509
|
+
// src/components/textarea/textareaVariants.ts
|
|
1510
|
+
var textareaVariantClass = {
|
|
1511
|
+
default: "border border-input bg-background hover:border-ring",
|
|
1512
|
+
filled: "border border-transparent bg-muted hover:bg-muted/80",
|
|
1513
|
+
ghost: "border border-transparent bg-transparent hover:bg-accent"
|
|
1514
|
+
};
|
|
1515
|
+
var textareaSizeClass = {
|
|
1516
|
+
sm: "rounded-md px-2.5 py-1.5 text-sm",
|
|
1517
|
+
md: "rounded-md px-3 py-2 text-sm",
|
|
1518
|
+
lg: "rounded-md px-4 py-2.5 text-base"
|
|
1519
|
+
};
|
|
1520
|
+
var textareaResizeClass = {
|
|
1521
|
+
none: "resize-none",
|
|
1522
|
+
vertical: "resize-y",
|
|
1523
|
+
horizontal: "resize-x",
|
|
1524
|
+
both: "resize"
|
|
1525
|
+
};
|
|
1526
|
+
var textareaBaseClass = "group/textarea relative flex w-full text-foreground outline-none transition-[background-color,border-color,box-shadow] focus-within:ring-2 focus-within:ring-ring/40 focus-within:ring-offset-1 focus-within:ring-offset-background aria-[invalid=true]:border-destructive aria-[invalid=true]:focus-within:ring-destructive/40 has-[textarea:disabled]:pointer-events-none has-[textarea:disabled]:opacity-50";
|
|
1527
|
+
var Textarea = react.forwardRef(function Textarea2({
|
|
1528
|
+
variant = "default",
|
|
1529
|
+
textareaSize = "md",
|
|
1530
|
+
resize = "vertical",
|
|
1531
|
+
label,
|
|
1532
|
+
helperText,
|
|
1533
|
+
error,
|
|
1534
|
+
fullWidth = true,
|
|
1535
|
+
rows = 4,
|
|
1536
|
+
id,
|
|
1537
|
+
className,
|
|
1538
|
+
wrapperClassName,
|
|
1539
|
+
containerClassName,
|
|
1540
|
+
"aria-invalid": ariaInvalidProp,
|
|
1541
|
+
"aria-describedby": ariaDescribedByProp,
|
|
1542
|
+
disabled,
|
|
1543
|
+
...props
|
|
1544
|
+
}, ref) {
|
|
1545
|
+
const generatedId = react.useId();
|
|
1546
|
+
const textareaId = id ?? generatedId;
|
|
1547
|
+
const helperId = `${textareaId}-helper`;
|
|
1548
|
+
const errorId = `${textareaId}-error`;
|
|
1549
|
+
const hasError = error !== void 0 && error !== null && error !== false;
|
|
1550
|
+
const ariaInvalid = ariaInvalidProp ?? (hasError ? true : void 0);
|
|
1551
|
+
const describedByIds = [
|
|
1552
|
+
ariaDescribedByProp,
|
|
1553
|
+
hasError ? errorId : null,
|
|
1554
|
+
!hasError && helperText ? helperId : null
|
|
1555
|
+
].filter(Boolean).join(" ");
|
|
1556
|
+
const ariaDescribedBy = describedByIds.length > 0 ? describedByIds : void 0;
|
|
1557
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-1.5", fullWidth && "w-full", containerClassName), children: [
|
|
1558
|
+
label !== void 0 && label !== null && /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: textareaId, className: "text-sm font-medium text-foreground select-none", children: label }),
|
|
1559
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1560
|
+
"div",
|
|
1561
|
+
{
|
|
1562
|
+
"data-slot": "textarea-wrapper",
|
|
1563
|
+
className: cn(
|
|
1564
|
+
textareaBaseClass,
|
|
1565
|
+
textareaVariantClass[variant],
|
|
1566
|
+
textareaSizeClass[textareaSize],
|
|
1567
|
+
wrapperClassName
|
|
1568
|
+
),
|
|
1569
|
+
"aria-invalid": ariaInvalid,
|
|
1570
|
+
"data-disabled": disabled ? "true" : void 0,
|
|
1571
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1572
|
+
"textarea",
|
|
1573
|
+
{
|
|
1574
|
+
ref,
|
|
1575
|
+
id: textareaId,
|
|
1576
|
+
rows,
|
|
1577
|
+
disabled,
|
|
1578
|
+
"aria-invalid": ariaInvalid,
|
|
1579
|
+
"aria-describedby": ariaDescribedBy,
|
|
1580
|
+
className: cn(
|
|
1581
|
+
"w-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed",
|
|
1582
|
+
textareaResizeClass[resize],
|
|
1583
|
+
className
|
|
1584
|
+
),
|
|
1585
|
+
...props
|
|
1586
|
+
}
|
|
1587
|
+
)
|
|
1588
|
+
}
|
|
1589
|
+
),
|
|
1590
|
+
hasError ? /* @__PURE__ */ jsxRuntime.jsx("p", { id: errorId, className: "text-xs text-destructive", children: error }) : helperText ? /* @__PURE__ */ jsxRuntime.jsx("p", { id: helperId, className: "text-xs text-muted-foreground", children: helperText }) : null
|
|
1591
|
+
] });
|
|
1592
|
+
});
|
|
1593
|
+
|
|
1389
1594
|
exports.AppShell = AppShell;
|
|
1390
1595
|
exports.Avatar = Avatar;
|
|
1391
1596
|
exports.Button = Button;
|
|
@@ -1394,6 +1599,7 @@ exports.DashboardContent = DashboardContent;
|
|
|
1394
1599
|
exports.DashboardHeader = DashboardHeader;
|
|
1395
1600
|
exports.DashboardLayout = DashboardLayout;
|
|
1396
1601
|
exports.DashboardMain = DashboardMain;
|
|
1602
|
+
exports.Field = Field;
|
|
1397
1603
|
exports.HeaderActions = HeaderActions;
|
|
1398
1604
|
exports.HeaderCollapseTrigger = HeaderCollapseTrigger;
|
|
1399
1605
|
exports.HeaderMobileTrigger = HeaderMobileTrigger;
|
|
@@ -1409,6 +1615,7 @@ exports.SidebarNav = SidebarNav;
|
|
|
1409
1615
|
exports.SidebarNavGroup = SidebarNavGroup;
|
|
1410
1616
|
exports.SidebarNavItem = SidebarNavItem;
|
|
1411
1617
|
exports.Table = Table;
|
|
1618
|
+
exports.Textarea = Textarea;
|
|
1412
1619
|
exports.buttonBaseClass = buttonBaseClass;
|
|
1413
1620
|
exports.buttonSizeClass = buttonSizeClass;
|
|
1414
1621
|
exports.buttonVariantClass = buttonVariantClass;
|
|
@@ -1421,6 +1628,10 @@ exports.tableBaseClass = tableBaseClass;
|
|
|
1421
1628
|
exports.tableSelectedRowClass = selectedRowClass;
|
|
1422
1629
|
exports.tableSizeClass = tableSizeClass;
|
|
1423
1630
|
exports.tableSortIconClass = sortIconClass;
|
|
1631
|
+
exports.textareaBaseClass = textareaBaseClass;
|
|
1632
|
+
exports.textareaResizeClass = textareaResizeClass;
|
|
1633
|
+
exports.textareaSizeClass = textareaSizeClass;
|
|
1634
|
+
exports.textareaVariantClass = textareaVariantClass;
|
|
1424
1635
|
exports.useDashboardLayout = useDashboardLayout;
|
|
1425
1636
|
exports.useDirection = useDirection;
|
|
1426
1637
|
//# sourceMappingURL=index.cjs.map
|