@dimaan/ui 0.0.8 → 0.0.10

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.js CHANGED
@@ -1,11 +1,35 @@
1
- import { createContext, forwardRef, Children, isValidElement, cloneElement, useRef, useImperativeHandle, useLayoutEffect, useId, useContext, useState, useCallback, useMemo, useEffect } from 'react';
1
+ import { DirectionProvider } from '@radix-ui/react-direction';
2
+ import { createContext, forwardRef, Children, isValidElement, cloneElement, useRef, useImperativeHandle, useLayoutEffect, useId, useCallback, useState, useEffect, useContext, useMemo } from 'react';
2
3
  import { clsx } from 'clsx';
3
4
  import { twMerge } from 'tailwind-merge';
4
5
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
5
- import { Loader2, Check, Minus, ChevronLeft, Menu, ChevronDown, ChevronsUpDown, ChevronUp, ChevronRight } from 'lucide-react';
6
+ import { Loader2, Check, Minus, ChevronDown, ChevronUp, ChevronLeft, Menu, ChevronsUpDown, ChevronRight } from 'lucide-react';
6
7
  import { useFormContext, Controller } from 'react-hook-form';
8
+ import * as RadixRadioGroup from '@radix-ui/react-radio-group';
9
+ import * as RadixSelect from '@radix-ui/react-select';
10
+ import * as RadixSwitch from '@radix-ui/react-switch';
7
11
 
8
- // src/components/dashboard-layout/context.ts
12
+ // src/components/app-shell/AppShell.tsx
13
+ function readDocumentDirection() {
14
+ if (typeof document === "undefined") return "ltr";
15
+ const dir = document.documentElement.getAttribute("dir");
16
+ return dir === "rtl" ? "rtl" : "ltr";
17
+ }
18
+ function useDirection() {
19
+ const [dir, setDir] = useState(() => readDocumentDirection());
20
+ useEffect(() => {
21
+ setDir(readDocumentDirection());
22
+ const observer = new MutationObserver(() => {
23
+ setDir(readDocumentDirection());
24
+ });
25
+ observer.observe(document.documentElement, {
26
+ attributes: true,
27
+ attributeFilter: ["dir"]
28
+ });
29
+ return () => observer.disconnect();
30
+ }, []);
31
+ return dir;
32
+ }
9
33
  var DashboardLayoutContext = createContext(null);
10
34
  function useDashboardLayout() {
11
35
  const ctx = useContext(DashboardLayoutContext);
@@ -599,7 +623,8 @@ function AppShell({
599
623
  onCollapsedChange,
600
624
  children
601
625
  }) {
602
- return /* @__PURE__ */ jsxs(
626
+ const dir = useDirection();
627
+ return /* @__PURE__ */ jsx(DirectionProvider, { dir, children: /* @__PURE__ */ jsxs(
603
628
  DashboardLayout,
604
629
  {
605
630
  defaultCollapsed,
@@ -644,7 +669,7 @@ function AppShell({
644
669
  ] })
645
670
  ]
646
671
  }
647
- );
672
+ ) });
648
673
  }
649
674
  var sizeClass = {
650
675
  sm: "h-7 w-7 text-xs",
@@ -780,6 +805,7 @@ function FieldShell({
780
805
  required = false,
781
806
  disabled = false,
782
807
  fullWidth = true,
808
+ orientation = "vertical",
783
809
  className,
784
810
  children
785
811
  }) {
@@ -802,39 +828,47 @@ function FieldShell({
802
828
  disabled: childProps.disabled ?? disabled,
803
829
  required: childProps.required ?? required
804
830
  });
831
+ const labelEl = label !== void 0 && label !== null ? /* @__PURE__ */ jsxs(
832
+ "label",
833
+ {
834
+ htmlFor: id,
835
+ className: cn(
836
+ "text-sm font-medium select-none text-foreground",
837
+ disabled && "opacity-50",
838
+ invalid && "text-destructive"
839
+ ),
840
+ children: [
841
+ label,
842
+ required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "ms-0.5 text-destructive", children: "*" })
843
+ ]
844
+ }
845
+ ) : null;
846
+ const messageEl = showError ? /* @__PURE__ */ jsx(
847
+ "p",
848
+ {
849
+ id: errorId,
850
+ role: "alert",
851
+ "aria-live": "polite",
852
+ className: "text-xs font-medium text-destructive",
853
+ children: error
854
+ }
855
+ ) : showDescription ? /* @__PURE__ */ jsx("p", { id: descriptionId, className: "text-xs text-muted-foreground", children: description }) : null;
805
856
  return /* @__PURE__ */ jsxs(
806
857
  "div",
807
858
  {
808
859
  "data-invalid": invalid || void 0,
809
860
  "data-disabled": disabled || void 0,
861
+ "data-orientation": orientation,
810
862
  className: cn("flex flex-col gap-1.5", fullWidth && "w-full", className),
811
863
  children: [
812
- label !== void 0 && label !== null && /* @__PURE__ */ jsxs(
813
- "label",
814
- {
815
- htmlFor: id,
816
- className: cn(
817
- "text-sm font-medium select-none text-foreground",
818
- disabled && "opacity-50",
819
- invalid && "text-destructive"
820
- ),
821
- children: [
822
- label,
823
- required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "ms-0.5 text-destructive", children: "*" })
824
- ]
825
- }
826
- ),
827
- enhancedChild,
828
- showError ? /* @__PURE__ */ jsx(
829
- "p",
830
- {
831
- id: errorId,
832
- role: "alert",
833
- "aria-live": "polite",
834
- className: "text-xs font-medium text-destructive",
835
- children: error
836
- }
837
- ) : showDescription ? /* @__PURE__ */ jsx("p", { id: descriptionId, className: "text-xs text-muted-foreground", children: description }) : null
864
+ orientation === "horizontal" ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
865
+ labelEl,
866
+ enhancedChild
867
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
868
+ labelEl,
869
+ enhancedChild
870
+ ] }),
871
+ messageEl
838
872
  ]
839
873
  }
840
874
  );
@@ -878,86 +912,67 @@ var inputBaseClass = "group/input relative inline-flex w-full items-center text-
878
912
  var Input = forwardRef(function Input2({
879
913
  variant = "default",
880
914
  inputSize = "md",
881
- label,
882
- helperText,
883
- error,
884
915
  leadingIcon,
885
916
  trailingIcon,
886
- fullWidth = true,
887
917
  type = "text",
888
918
  id,
889
919
  className,
890
920
  wrapperClassName,
891
- containerClassName,
892
- "aria-invalid": ariaInvalidProp,
893
- "aria-describedby": ariaDescribedByProp,
921
+ "aria-invalid": ariaInvalid,
922
+ "aria-describedby": ariaDescribedBy,
894
923
  disabled,
895
924
  ...props
896
925
  }, ref) {
897
926
  const generatedId = useId();
898
927
  const inputId = id ?? generatedId;
899
- const helperId = `${inputId}-helper`;
900
- const errorId = `${inputId}-error`;
901
- const hasError = error !== void 0 && error !== null && error !== false;
902
- const ariaInvalid = ariaInvalidProp ?? (hasError ? true : void 0);
903
- const describedByIds = [
904
- ariaDescribedByProp,
905
- hasError ? errorId : null,
906
- !hasError && helperText ? helperId : null
907
- ].filter(Boolean).join(" ");
908
- const ariaDescribedBy = describedByIds.length > 0 ? describedByIds : void 0;
909
- return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-1.5", fullWidth && "w-full", containerClassName), children: [
910
- label !== void 0 && label !== null && /* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "text-sm font-medium text-foreground select-none", children: label }),
911
- /* @__PURE__ */ jsxs(
912
- "div",
913
- {
914
- "data-slot": "input-wrapper",
915
- className: cn(
916
- inputBaseClass,
917
- inputVariantClass[variant],
918
- inputSizeClass[inputSize],
919
- wrapperClassName
928
+ return /* @__PURE__ */ jsxs(
929
+ "div",
930
+ {
931
+ "data-slot": "input-wrapper",
932
+ className: cn(
933
+ inputBaseClass,
934
+ inputVariantClass[variant],
935
+ inputSizeClass[inputSize],
936
+ wrapperClassName
937
+ ),
938
+ "aria-invalid": ariaInvalid,
939
+ "data-disabled": disabled ? "true" : void 0,
940
+ children: [
941
+ leadingIcon ? /* @__PURE__ */ jsx(
942
+ "span",
943
+ {
944
+ "aria-hidden": "true",
945
+ className: "inline-flex h-4 w-4 items-center justify-center text-muted-foreground",
946
+ children: leadingIcon
947
+ }
948
+ ) : null,
949
+ /* @__PURE__ */ jsx(
950
+ "input",
951
+ {
952
+ ref,
953
+ id: inputId,
954
+ type,
955
+ disabled,
956
+ "aria-invalid": ariaInvalid,
957
+ "aria-describedby": ariaDescribedBy,
958
+ className: cn(
959
+ "h-full w-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed",
960
+ className
961
+ ),
962
+ ...props
963
+ }
920
964
  ),
921
- "aria-invalid": ariaInvalid,
922
- "data-disabled": disabled ? "true" : void 0,
923
- children: [
924
- leadingIcon ? /* @__PURE__ */ jsx(
925
- "span",
926
- {
927
- "aria-hidden": "true",
928
- className: "inline-flex h-4 w-4 items-center justify-center text-muted-foreground",
929
- children: leadingIcon
930
- }
931
- ) : null,
932
- /* @__PURE__ */ jsx(
933
- "input",
934
- {
935
- ref,
936
- id: inputId,
937
- type,
938
- disabled,
939
- "aria-invalid": ariaInvalid,
940
- "aria-describedby": ariaDescribedBy,
941
- className: cn(
942
- "h-full w-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed",
943
- className
944
- ),
945
- ...props
946
- }
947
- ),
948
- trailingIcon ? /* @__PURE__ */ jsx(
949
- "span",
950
- {
951
- "aria-hidden": "true",
952
- className: "inline-flex h-4 w-4 items-center justify-center text-muted-foreground",
953
- children: trailingIcon
954
- }
955
- ) : null
956
- ]
957
- }
958
- ),
959
- hasError ? /* @__PURE__ */ jsx("p", { id: errorId, className: "text-xs text-destructive", children: error }) : helperText ? /* @__PURE__ */ jsx("p", { id: helperId, className: "text-xs text-muted-foreground", children: helperText }) : null
960
- ] });
965
+ trailingIcon ? /* @__PURE__ */ jsx(
966
+ "span",
967
+ {
968
+ "aria-hidden": "true",
969
+ className: "inline-flex h-4 w-4 items-center justify-center text-muted-foreground",
970
+ children: trailingIcon
971
+ }
972
+ ) : null
973
+ ]
974
+ }
975
+ );
961
976
  });
962
977
  function LanguageSwitcher({
963
978
  languages,
@@ -996,26 +1011,332 @@ function LanguageSwitcher({
996
1011
  }
997
1012
  );
998
1013
  }
999
- function readDocumentDirection() {
1000
- if (typeof document === "undefined") return "ltr";
1001
- const dir = document.documentElement.getAttribute("dir");
1002
- return dir === "rtl" ? "rtl" : "ltr";
1014
+
1015
+ // src/components/radio-group/radioGroupVariants.ts
1016
+ var radioItemSizeClass = {
1017
+ sm: "size-4",
1018
+ md: "size-5",
1019
+ lg: "size-6"
1020
+ };
1021
+ var radioIndicatorSizeClass = {
1022
+ sm: "size-1.5",
1023
+ md: "size-2",
1024
+ lg: "size-2.5"
1025
+ };
1026
+ var radioLabelSizeClass = {
1027
+ sm: "text-xs",
1028
+ md: "text-sm",
1029
+ lg: "text-base"
1030
+ };
1031
+ var radioItemBaseClass = "aspect-square shrink-0 rounded-full border border-input bg-background text-primary outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-offset-2 focus-visible:ring-offset-background hover:border-ring disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-destructive aria-[invalid=true]:focus-visible:ring-destructive/40 data-[state=checked]:border-primary";
1032
+ var radioIndicatorBaseClass = "flex h-full w-full items-center justify-center";
1033
+ var radioIndicatorDotClass = "rounded-full bg-primary";
1034
+ var radioOptionRowClass = "flex cursor-pointer items-start gap-2 has-[button:disabled]:cursor-not-allowed";
1035
+ var radioGroupBaseClass = "flex gap-3";
1036
+ var radioGroupOrientationClass = {
1037
+ vertical: "flex-col",
1038
+ horizontal: "flex-row flex-wrap"
1039
+ };
1040
+ var RadioGroup = forwardRef(function RadioGroup2({
1041
+ radioSize = "md",
1042
+ orientation = "vertical",
1043
+ value,
1044
+ defaultValue,
1045
+ onValueChange,
1046
+ onChange,
1047
+ onBlur,
1048
+ name,
1049
+ disabled,
1050
+ required,
1051
+ id,
1052
+ options,
1053
+ className,
1054
+ "aria-label": ariaLabel,
1055
+ "aria-labelledby": ariaLabelledBy,
1056
+ "aria-describedby": ariaDescribedBy,
1057
+ "aria-invalid": ariaInvalid,
1058
+ children
1059
+ }, ref) {
1060
+ const generatedId = useId();
1061
+ const groupId = id ?? generatedId;
1062
+ const handleValueChange = useCallback(
1063
+ (next) => {
1064
+ onValueChange?.(next);
1065
+ if (onChange) {
1066
+ const synthetic = {
1067
+ target: { value: next, name },
1068
+ currentTarget: { value: next, name },
1069
+ type: "change"
1070
+ };
1071
+ onChange(synthetic);
1072
+ }
1073
+ },
1074
+ [onValueChange, onChange, name]
1075
+ );
1076
+ return /* @__PURE__ */ jsx(
1077
+ RadixRadioGroup.Root,
1078
+ {
1079
+ ref,
1080
+ id: groupId,
1081
+ value,
1082
+ defaultValue,
1083
+ onValueChange: handleValueChange,
1084
+ onBlur,
1085
+ disabled,
1086
+ required,
1087
+ name,
1088
+ orientation,
1089
+ "aria-label": ariaLabel,
1090
+ "aria-labelledby": ariaLabelledBy,
1091
+ "aria-describedby": ariaDescribedBy,
1092
+ "aria-invalid": ariaInvalid,
1093
+ "data-slot": "radio-group",
1094
+ className: cn(radioGroupBaseClass, radioGroupOrientationClass[orientation], className),
1095
+ children: children ?? options?.map((opt) => /* @__PURE__ */ jsx(
1096
+ RadioGroupOptionRow,
1097
+ {
1098
+ option: opt,
1099
+ radioSize,
1100
+ groupId
1101
+ },
1102
+ opt.value
1103
+ ))
1104
+ }
1105
+ );
1106
+ });
1107
+ function RadioGroupOptionRow({ option, radioSize, groupId }) {
1108
+ const itemId = `${groupId}-${option.value}`;
1109
+ return /* @__PURE__ */ jsxs("label", { htmlFor: itemId, className: radioOptionRowClass, children: [
1110
+ /* @__PURE__ */ jsx(
1111
+ RadixRadioGroup.Item,
1112
+ {
1113
+ id: itemId,
1114
+ value: option.value,
1115
+ disabled: option.disabled,
1116
+ "data-slot": "radio-item",
1117
+ className: cn(radioItemBaseClass, radioItemSizeClass[radioSize], "mt-0.5"),
1118
+ children: /* @__PURE__ */ jsx(RadixRadioGroup.Indicator, { className: radioIndicatorBaseClass, children: /* @__PURE__ */ jsx("span", { className: cn(radioIndicatorDotClass, radioIndicatorSizeClass[radioSize]) }) })
1119
+ }
1120
+ ),
1121
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1 leading-tight", children: [
1122
+ /* @__PURE__ */ jsx("span", { className: cn("block font-medium text-foreground", radioLabelSizeClass[radioSize]), children: option.label }),
1123
+ option.description ? /* @__PURE__ */ jsx("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: option.description }) : null
1124
+ ] })
1125
+ ] });
1003
1126
  }
1004
- function useDirection() {
1005
- const [dir, setDir] = useState(() => readDocumentDirection());
1006
- useEffect(() => {
1007
- setDir(readDocumentDirection());
1008
- const observer = new MutationObserver(() => {
1009
- setDir(readDocumentDirection());
1010
- });
1011
- observer.observe(document.documentElement, {
1012
- attributes: true,
1013
- attributeFilter: ["dir"]
1014
- });
1015
- return () => observer.disconnect();
1016
- }, []);
1017
- return dir;
1127
+ var RadioGroupItem = forwardRef(function RadioGroupItem2({ className, radioSize = "md", ...props }, ref) {
1128
+ return /* @__PURE__ */ jsx(
1129
+ RadixRadioGroup.Item,
1130
+ {
1131
+ ref,
1132
+ "data-slot": "radio-item",
1133
+ className: cn(radioItemBaseClass, radioItemSizeClass[radioSize], className),
1134
+ ...props,
1135
+ children: /* @__PURE__ */ jsx(RadixRadioGroup.Indicator, { className: radioIndicatorBaseClass, children: /* @__PURE__ */ jsx("span", { className: cn(radioIndicatorDotClass, radioIndicatorSizeClass[radioSize]) }) })
1136
+ }
1137
+ );
1138
+ });
1139
+
1140
+ // src/components/select/selectVariants.ts
1141
+ var selectVariantClass = {
1142
+ default: "border border-input bg-background hover:border-ring",
1143
+ filled: "border border-transparent bg-muted hover:bg-muted/80",
1144
+ ghost: "border border-transparent bg-transparent hover:bg-accent"
1145
+ };
1146
+ var selectSizeClass = {
1147
+ sm: "h-8 rounded-md ps-2.5 pe-8 text-sm",
1148
+ md: "h-9 rounded-md ps-3 pe-9 text-sm",
1149
+ lg: "h-11 rounded-md ps-4 pe-10 text-base"
1150
+ };
1151
+ var selectBaseClass = "group/select relative inline-flex w-full items-center text-foreground outline-none transition-[background-color,border-color,box-shadow] focus:ring-2 focus:ring-ring/40 focus:ring-offset-1 focus:ring-offset-background aria-[invalid=true]:border-destructive aria-[invalid=true]:focus:ring-destructive/40 disabled:pointer-events-none disabled:opacity-50 cursor-pointer data-[placeholder]:text-muted-foreground";
1152
+ var selectContentClass = "z-50 max-h-(--radix-select-content-available-height) min-w-(--radix-select-trigger-width) overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md 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";
1153
+ var selectViewportClass = "p-1";
1154
+ var selectItemClass = "relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 ps-8 pe-2 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50";
1155
+ var selectItemIndicatorClass = "absolute start-2 inline-flex h-3.5 w-3.5 items-center justify-center [&_svg]:h-3.5 [&_svg]:w-3.5";
1156
+ var selectGroupLabelClass = "px-2 py-1.5 text-xs font-semibold text-muted-foreground";
1157
+ var selectSeparatorClass = "-mx-1 my-1 h-px bg-border";
1158
+ function isGroupedOptions(options) {
1159
+ const first = options[0];
1160
+ return first !== void 0 && "options" in first;
1161
+ }
1162
+ var Select = forwardRef(function Select2({
1163
+ variant = "default",
1164
+ selectSize = "md",
1165
+ options,
1166
+ placeholder,
1167
+ value,
1168
+ defaultValue,
1169
+ onValueChange,
1170
+ onChange,
1171
+ onBlur,
1172
+ name,
1173
+ disabled,
1174
+ required,
1175
+ id,
1176
+ className,
1177
+ "aria-invalid": ariaInvalid,
1178
+ "aria-describedby": ariaDescribedBy,
1179
+ "aria-label": ariaLabel,
1180
+ children
1181
+ }, ref) {
1182
+ const generatedId = useId();
1183
+ const triggerId = id ?? generatedId;
1184
+ const handleValueChange = useCallback(
1185
+ (next) => {
1186
+ onValueChange?.(next);
1187
+ if (onChange) {
1188
+ const synthetic = {
1189
+ target: { value: next, name },
1190
+ currentTarget: { value: next, name },
1191
+ type: "change"
1192
+ };
1193
+ onChange(synthetic);
1194
+ }
1195
+ },
1196
+ [onValueChange, onChange, name]
1197
+ );
1198
+ return /* @__PURE__ */ jsxs(
1199
+ RadixSelect.Root,
1200
+ {
1201
+ value,
1202
+ defaultValue,
1203
+ onValueChange: handleValueChange,
1204
+ disabled,
1205
+ required,
1206
+ name,
1207
+ children: [
1208
+ /* @__PURE__ */ jsxs(
1209
+ RadixSelect.Trigger,
1210
+ {
1211
+ ref,
1212
+ id: triggerId,
1213
+ "aria-label": ariaLabel,
1214
+ "aria-invalid": ariaInvalid,
1215
+ "aria-describedby": ariaDescribedBy,
1216
+ onBlur,
1217
+ "data-slot": "select-trigger",
1218
+ className: cn(
1219
+ selectBaseClass,
1220
+ selectVariantClass[variant],
1221
+ selectSizeClass[selectSize],
1222
+ className
1223
+ ),
1224
+ children: [
1225
+ /* @__PURE__ */ jsx(RadixSelect.Value, { placeholder }),
1226
+ /* @__PURE__ */ jsx(RadixSelect.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "pointer-events-none absolute end-3 top-1/2 size-4 shrink-0 -translate-y-1/2 text-muted-foreground" }) })
1227
+ ]
1228
+ }
1229
+ ),
1230
+ /* @__PURE__ */ jsx(RadixSelect.Portal, { children: /* @__PURE__ */ jsxs(
1231
+ RadixSelect.Content,
1232
+ {
1233
+ position: "popper",
1234
+ sideOffset: 4,
1235
+ "data-slot": "select-content",
1236
+ className: selectContentClass,
1237
+ children: [
1238
+ /* @__PURE__ */ jsx(RadixSelect.ScrollUpButton, { className: "flex h-6 cursor-default items-center justify-center bg-popover text-muted-foreground", children: /* @__PURE__ */ jsx(ChevronUp, { className: "size-4" }) }),
1239
+ /* @__PURE__ */ jsx(RadixSelect.Viewport, { className: selectViewportClass, children: children ?? (options ? renderOptions(options) : null) }),
1240
+ /* @__PURE__ */ jsx(RadixSelect.ScrollDownButton, { className: "flex h-6 cursor-default items-center justify-center bg-popover text-muted-foreground", children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-4" }) })
1241
+ ]
1242
+ }
1243
+ ) })
1244
+ ]
1245
+ }
1246
+ );
1247
+ });
1248
+ function renderOptions(options) {
1249
+ if (isGroupedOptions(options)) {
1250
+ const lastIndex = options.length - 1;
1251
+ return options.map((group, idx) => /* @__PURE__ */ jsxs(RadixSelect.Group, { children: [
1252
+ /* @__PURE__ */ jsx(RadixSelect.Label, { className: selectGroupLabelClass, children: group.label }),
1253
+ group.options.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value)),
1254
+ idx < lastIndex && /* @__PURE__ */ jsx(RadixSelect.Separator, { className: selectSeparatorClass })
1255
+ ] }, group.label));
1256
+ }
1257
+ return options.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value));
1018
1258
  }
1259
+ var SelectItem = forwardRef(function SelectItem2({ className, children, ...props }, ref) {
1260
+ return /* @__PURE__ */ jsxs(RadixSelect.Item, { ref, className: cn(selectItemClass, className), ...props, children: [
1261
+ /* @__PURE__ */ jsx(RadixSelect.ItemIndicator, { className: selectItemIndicatorClass, children: /* @__PURE__ */ jsx(Check, {}) }),
1262
+ /* @__PURE__ */ jsx(RadixSelect.ItemText, { children })
1263
+ ] });
1264
+ });
1265
+
1266
+ // src/components/switch/switchVariants.ts
1267
+ var switchTrackClass = {
1268
+ sm: "h-4 w-7",
1269
+ md: "h-5 w-9",
1270
+ lg: "h-6 w-11"
1271
+ };
1272
+ var switchThumbClass = {
1273
+ sm: "size-3 data-[state=checked]:translate-x-3 data-[state=checked]:rtl:-translate-x-3",
1274
+ md: "size-4 data-[state=checked]:translate-x-4 data-[state=checked]:rtl:-translate-x-4",
1275
+ lg: "size-5 data-[state=checked]:translate-x-5 data-[state=checked]:rtl:-translate-x-5"
1276
+ };
1277
+ var switchTrackBaseClass = "relative inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent bg-input transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary aria-[invalid=true]:ring-2 aria-[invalid=true]:ring-destructive/40";
1278
+ var switchThumbBaseClass = "pointer-events-none block rounded-full bg-background shadow-sm ring-0 transition-transform";
1279
+ var Switch = forwardRef(function Switch2({
1280
+ switchSize = "md",
1281
+ checked,
1282
+ defaultChecked,
1283
+ onCheckedChange,
1284
+ value,
1285
+ onChange,
1286
+ onBlur,
1287
+ name,
1288
+ disabled,
1289
+ required,
1290
+ id,
1291
+ className,
1292
+ "aria-label": ariaLabel,
1293
+ "aria-describedby": ariaDescribedBy,
1294
+ "aria-invalid": ariaInvalid
1295
+ }, ref) {
1296
+ const generatedId = useId();
1297
+ const switchId = id ?? generatedId;
1298
+ const resolvedChecked = checked ?? (value === void 0 ? void 0 : Boolean(value));
1299
+ const handleCheckedChange = useCallback(
1300
+ (next) => {
1301
+ onCheckedChange?.(next);
1302
+ if (onChange) {
1303
+ const synthetic = {
1304
+ target: { checked: next, value: next, name },
1305
+ currentTarget: { checked: next, value: next, name },
1306
+ type: "change"
1307
+ };
1308
+ onChange(synthetic);
1309
+ }
1310
+ },
1311
+ [onCheckedChange, onChange, name]
1312
+ );
1313
+ return /* @__PURE__ */ jsx(
1314
+ RadixSwitch.Root,
1315
+ {
1316
+ ref,
1317
+ id: switchId,
1318
+ checked: resolvedChecked,
1319
+ defaultChecked,
1320
+ onCheckedChange: handleCheckedChange,
1321
+ onBlur,
1322
+ disabled,
1323
+ required,
1324
+ name,
1325
+ "aria-label": ariaLabel,
1326
+ "aria-invalid": ariaInvalid,
1327
+ "aria-describedby": ariaDescribedBy,
1328
+ "data-slot": "switch-track",
1329
+ className: cn(switchTrackBaseClass, switchTrackClass[switchSize], className),
1330
+ children: /* @__PURE__ */ jsx(
1331
+ RadixSwitch.Thumb,
1332
+ {
1333
+ "data-slot": "switch-thumb",
1334
+ className: cn(switchThumbBaseClass, switchThumbClass[switchSize])
1335
+ }
1336
+ )
1337
+ }
1338
+ );
1339
+ });
1019
1340
  function Pagination({
1020
1341
  pageIndex,
1021
1342
  pageSize,
@@ -1526,69 +1847,50 @@ var Textarea = forwardRef(function Textarea2({
1526
1847
  variant = "default",
1527
1848
  textareaSize = "md",
1528
1849
  resize = "vertical",
1529
- label,
1530
- helperText,
1531
- error,
1532
- fullWidth = true,
1533
1850
  rows = 4,
1534
1851
  id,
1535
1852
  className,
1536
1853
  wrapperClassName,
1537
- containerClassName,
1538
- "aria-invalid": ariaInvalidProp,
1539
- "aria-describedby": ariaDescribedByProp,
1854
+ "aria-invalid": ariaInvalid,
1855
+ "aria-describedby": ariaDescribedBy,
1540
1856
  disabled,
1541
1857
  ...props
1542
1858
  }, ref) {
1543
1859
  const generatedId = useId();
1544
1860
  const textareaId = id ?? generatedId;
1545
- const helperId = `${textareaId}-helper`;
1546
- const errorId = `${textareaId}-error`;
1547
- const hasError = error !== void 0 && error !== null && error !== false;
1548
- const ariaInvalid = ariaInvalidProp ?? (hasError ? true : void 0);
1549
- const describedByIds = [
1550
- ariaDescribedByProp,
1551
- hasError ? errorId : null,
1552
- !hasError && helperText ? helperId : null
1553
- ].filter(Boolean).join(" ");
1554
- const ariaDescribedBy = describedByIds.length > 0 ? describedByIds : void 0;
1555
- return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-1.5", fullWidth && "w-full", containerClassName), children: [
1556
- label !== void 0 && label !== null && /* @__PURE__ */ jsx("label", { htmlFor: textareaId, className: "text-sm font-medium text-foreground select-none", children: label }),
1557
- /* @__PURE__ */ jsx(
1558
- "div",
1559
- {
1560
- "data-slot": "textarea-wrapper",
1561
- className: cn(
1562
- textareaBaseClass,
1563
- textareaVariantClass[variant],
1564
- textareaSizeClass[textareaSize],
1565
- wrapperClassName
1566
- ),
1567
- "aria-invalid": ariaInvalid,
1568
- "data-disabled": disabled ? "true" : void 0,
1569
- children: /* @__PURE__ */ jsx(
1570
- "textarea",
1571
- {
1572
- ref,
1573
- id: textareaId,
1574
- rows,
1575
- disabled,
1576
- "aria-invalid": ariaInvalid,
1577
- "aria-describedby": ariaDescribedBy,
1578
- className: cn(
1579
- "w-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed",
1580
- textareaResizeClass[resize],
1581
- className
1582
- ),
1583
- ...props
1584
- }
1585
- )
1586
- }
1587
- ),
1588
- hasError ? /* @__PURE__ */ jsx("p", { id: errorId, className: "text-xs text-destructive", children: error }) : helperText ? /* @__PURE__ */ jsx("p", { id: helperId, className: "text-xs text-muted-foreground", children: helperText }) : null
1589
- ] });
1861
+ return /* @__PURE__ */ jsx(
1862
+ "div",
1863
+ {
1864
+ "data-slot": "textarea-wrapper",
1865
+ className: cn(
1866
+ textareaBaseClass,
1867
+ textareaVariantClass[variant],
1868
+ textareaSizeClass[textareaSize],
1869
+ wrapperClassName
1870
+ ),
1871
+ "aria-invalid": ariaInvalid,
1872
+ "data-disabled": disabled ? "true" : void 0,
1873
+ children: /* @__PURE__ */ jsx(
1874
+ "textarea",
1875
+ {
1876
+ ref,
1877
+ id: textareaId,
1878
+ rows,
1879
+ disabled,
1880
+ "aria-invalid": ariaInvalid,
1881
+ "aria-describedby": ariaDescribedBy,
1882
+ className: cn(
1883
+ "w-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed",
1884
+ textareaResizeClass[resize],
1885
+ className
1886
+ ),
1887
+ ...props
1888
+ }
1889
+ )
1890
+ }
1891
+ );
1590
1892
  });
1591
1893
 
1592
- export { AppShell, Avatar, Button, Checkbox, DashboardContent, DashboardHeader, DashboardLayout, DashboardMain, Field, HeaderActions, HeaderCollapseTrigger, HeaderMobileTrigger, HeaderSearch, HeaderTitle, Input, LanguageSwitcher, Sidebar, SidebarFooter, SidebarGroup, SidebarHeader, SidebarNav, SidebarNavGroup, SidebarNavItem, Table, Textarea, buttonBaseClass, buttonSizeClass, buttonVariantClass, cn, inputBaseClass, inputSizeClass, inputVariantClass, alignClass as tableAlignClass, tableBaseClass, selectedRowClass as tableSelectedRowClass, tableSizeClass, sortIconClass as tableSortIconClass, textareaBaseClass, textareaResizeClass, textareaSizeClass, textareaVariantClass, useDashboardLayout, useDirection };
1894
+ export { AppShell, Avatar, Button, Checkbox, DashboardContent, DashboardHeader, DashboardLayout, DashboardMain, Field, HeaderActions, HeaderCollapseTrigger, HeaderMobileTrigger, HeaderSearch, HeaderTitle, Input, LanguageSwitcher, RadioGroup, RadioGroupItem, Select, Sidebar, SidebarFooter, SidebarGroup, SidebarHeader, SidebarNav, SidebarNavGroup, SidebarNavItem, Switch, Table, Textarea, buttonBaseClass, buttonSizeClass, buttonVariantClass, cn, inputBaseClass, inputSizeClass, inputVariantClass, radioGroupBaseClass, radioGroupOrientationClass, radioIndicatorBaseClass, radioIndicatorDotClass, radioIndicatorSizeClass, radioItemBaseClass, radioItemSizeClass, radioLabelSizeClass, radioOptionRowClass, selectBaseClass, selectSizeClass, selectVariantClass, switchThumbBaseClass, switchThumbClass, switchTrackBaseClass, switchTrackClass, alignClass as tableAlignClass, tableBaseClass, selectedRowClass as tableSelectedRowClass, tableSizeClass, sortIconClass as tableSortIconClass, textareaBaseClass, textareaResizeClass, textareaSizeClass, textareaVariantClass, useDashboardLayout, useDirection };
1593
1895
  //# sourceMappingURL=index.js.map
1594
1896
  //# sourceMappingURL=index.js.map