@dimaan/ui 0.0.7 → 0.0.9

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 CHANGED
@@ -1,13 +1,57 @@
1
1
  'use strict';
2
2
 
3
+ var reactDirection = require('@radix-ui/react-direction');
3
4
  var react = require('react');
4
5
  var clsx = require('clsx');
5
6
  var tailwindMerge = require('tailwind-merge');
6
7
  var jsxRuntime = require('react/jsx-runtime');
7
8
  var lucideReact = require('lucide-react');
8
9
  var reactHookForm = require('react-hook-form');
10
+ var RadixSelect = require('@radix-ui/react-select');
11
+ var RadixSwitch = require('@radix-ui/react-switch');
9
12
 
10
- // src/components/dashboard-layout/context.ts
13
+ function _interopNamespace(e) {
14
+ if (e && e.__esModule) return e;
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ Object.keys(e).forEach(function (k) {
18
+ if (k !== 'default') {
19
+ var d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: function () { return e[k]; }
23
+ });
24
+ }
25
+ });
26
+ }
27
+ n.default = e;
28
+ return Object.freeze(n);
29
+ }
30
+
31
+ var RadixSelect__namespace = /*#__PURE__*/_interopNamespace(RadixSelect);
32
+ var RadixSwitch__namespace = /*#__PURE__*/_interopNamespace(RadixSwitch);
33
+
34
+ // src/components/app-shell/AppShell.tsx
35
+ function readDocumentDirection() {
36
+ if (typeof document === "undefined") return "ltr";
37
+ const dir = document.documentElement.getAttribute("dir");
38
+ return dir === "rtl" ? "rtl" : "ltr";
39
+ }
40
+ function useDirection() {
41
+ const [dir, setDir] = react.useState(() => readDocumentDirection());
42
+ react.useEffect(() => {
43
+ setDir(readDocumentDirection());
44
+ const observer = new MutationObserver(() => {
45
+ setDir(readDocumentDirection());
46
+ });
47
+ observer.observe(document.documentElement, {
48
+ attributes: true,
49
+ attributeFilter: ["dir"]
50
+ });
51
+ return () => observer.disconnect();
52
+ }, []);
53
+ return dir;
54
+ }
11
55
  var DashboardLayoutContext = react.createContext(null);
12
56
  function useDashboardLayout() {
13
57
  const ctx = react.useContext(DashboardLayoutContext);
@@ -601,7 +645,8 @@ function AppShell({
601
645
  onCollapsedChange,
602
646
  children
603
647
  }) {
604
- return /* @__PURE__ */ jsxRuntime.jsxs(
648
+ const dir = useDirection();
649
+ return /* @__PURE__ */ jsxRuntime.jsx(reactDirection.DirectionProvider, { dir, children: /* @__PURE__ */ jsxRuntime.jsxs(
605
650
  DashboardLayout,
606
651
  {
607
652
  defaultCollapsed,
@@ -646,7 +691,7 @@ function AppShell({
646
691
  ] })
647
692
  ]
648
693
  }
649
- );
694
+ ) });
650
695
  }
651
696
  var sizeClass = {
652
697
  sm: "h-7 w-7 text-xs",
@@ -782,6 +827,7 @@ function FieldShell({
782
827
  required = false,
783
828
  disabled = false,
784
829
  fullWidth = true,
830
+ orientation = "vertical",
785
831
  className,
786
832
  children
787
833
  }) {
@@ -804,39 +850,47 @@ function FieldShell({
804
850
  disabled: childProps.disabled ?? disabled,
805
851
  required: childProps.required ?? required
806
852
  });
853
+ const labelEl = label !== void 0 && label !== null ? /* @__PURE__ */ jsxRuntime.jsxs(
854
+ "label",
855
+ {
856
+ htmlFor: id,
857
+ className: cn(
858
+ "text-sm font-medium select-none text-foreground",
859
+ disabled && "opacity-50",
860
+ invalid && "text-destructive"
861
+ ),
862
+ children: [
863
+ label,
864
+ required && /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "ms-0.5 text-destructive", children: "*" })
865
+ ]
866
+ }
867
+ ) : null;
868
+ const messageEl = showError ? /* @__PURE__ */ jsxRuntime.jsx(
869
+ "p",
870
+ {
871
+ id: errorId,
872
+ role: "alert",
873
+ "aria-live": "polite",
874
+ className: "text-xs font-medium text-destructive",
875
+ children: error
876
+ }
877
+ ) : showDescription ? /* @__PURE__ */ jsxRuntime.jsx("p", { id: descriptionId, className: "text-xs text-muted-foreground", children: description }) : null;
807
878
  return /* @__PURE__ */ jsxRuntime.jsxs(
808
879
  "div",
809
880
  {
810
881
  "data-invalid": invalid || void 0,
811
882
  "data-disabled": disabled || void 0,
883
+ "data-orientation": orientation,
812
884
  className: cn("flex flex-col gap-1.5", fullWidth && "w-full", className),
813
885
  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
886
+ orientation === "horizontal" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-3", children: [
887
+ labelEl,
888
+ enhancedChild
889
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
890
+ labelEl,
891
+ enhancedChild
892
+ ] }),
893
+ messageEl
840
894
  ]
841
895
  }
842
896
  );
@@ -998,26 +1052,207 @@ function LanguageSwitcher({
998
1052
  }
999
1053
  );
1000
1054
  }
1001
- function readDocumentDirection() {
1002
- if (typeof document === "undefined") return "ltr";
1003
- const dir = document.documentElement.getAttribute("dir");
1004
- return dir === "rtl" ? "rtl" : "ltr";
1055
+
1056
+ // src/components/select/selectVariants.ts
1057
+ var selectVariantClass = {
1058
+ default: "border border-input bg-background hover:border-ring",
1059
+ filled: "border border-transparent bg-muted hover:bg-muted/80",
1060
+ ghost: "border border-transparent bg-transparent hover:bg-accent"
1061
+ };
1062
+ var selectSizeClass = {
1063
+ sm: "h-8 rounded-md ps-2.5 pe-8 text-sm",
1064
+ md: "h-9 rounded-md ps-3 pe-9 text-sm",
1065
+ lg: "h-11 rounded-md ps-4 pe-10 text-base"
1066
+ };
1067
+ 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";
1068
+ 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";
1069
+ var selectViewportClass = "p-1";
1070
+ 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";
1071
+ 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";
1072
+ var selectGroupLabelClass = "px-2 py-1.5 text-xs font-semibold text-muted-foreground";
1073
+ var selectSeparatorClass = "-mx-1 my-1 h-px bg-border";
1074
+ function isGroupedOptions(options) {
1075
+ const first = options[0];
1076
+ return first !== void 0 && "options" in first;
1005
1077
  }
1006
- function useDirection() {
1007
- const [dir, setDir] = react.useState(() => readDocumentDirection());
1008
- react.useEffect(() => {
1009
- setDir(readDocumentDirection());
1010
- const observer = new MutationObserver(() => {
1011
- setDir(readDocumentDirection());
1012
- });
1013
- observer.observe(document.documentElement, {
1014
- attributes: true,
1015
- attributeFilter: ["dir"]
1016
- });
1017
- return () => observer.disconnect();
1018
- }, []);
1019
- return dir;
1078
+ var Select = react.forwardRef(function Select2({
1079
+ variant = "default",
1080
+ selectSize = "md",
1081
+ options,
1082
+ placeholder,
1083
+ value,
1084
+ defaultValue,
1085
+ onValueChange,
1086
+ onChange,
1087
+ onBlur,
1088
+ name,
1089
+ disabled,
1090
+ required,
1091
+ id,
1092
+ className,
1093
+ "aria-invalid": ariaInvalid,
1094
+ "aria-describedby": ariaDescribedBy,
1095
+ "aria-label": ariaLabel,
1096
+ children
1097
+ }, ref) {
1098
+ const generatedId = react.useId();
1099
+ const triggerId = id ?? generatedId;
1100
+ const handleValueChange = react.useCallback(
1101
+ (next) => {
1102
+ onValueChange?.(next);
1103
+ if (onChange) {
1104
+ const synthetic = {
1105
+ target: { value: next, name },
1106
+ currentTarget: { value: next, name },
1107
+ type: "change"
1108
+ };
1109
+ onChange(synthetic);
1110
+ }
1111
+ },
1112
+ [onValueChange, onChange, name]
1113
+ );
1114
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1115
+ RadixSelect__namespace.Root,
1116
+ {
1117
+ value,
1118
+ defaultValue,
1119
+ onValueChange: handleValueChange,
1120
+ disabled,
1121
+ required,
1122
+ name,
1123
+ children: [
1124
+ /* @__PURE__ */ jsxRuntime.jsxs(
1125
+ RadixSelect__namespace.Trigger,
1126
+ {
1127
+ ref,
1128
+ id: triggerId,
1129
+ "aria-label": ariaLabel,
1130
+ "aria-invalid": ariaInvalid,
1131
+ "aria-describedby": ariaDescribedBy,
1132
+ onBlur,
1133
+ "data-slot": "select-trigger",
1134
+ className: cn(
1135
+ selectBaseClass,
1136
+ selectVariantClass[variant],
1137
+ selectSizeClass[selectSize],
1138
+ className
1139
+ ),
1140
+ children: [
1141
+ /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.Value, { placeholder }),
1142
+ /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.Icon, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "pointer-events-none absolute end-3 top-1/2 size-4 shrink-0 -translate-y-1/2 text-muted-foreground" }) })
1143
+ ]
1144
+ }
1145
+ ),
1146
+ /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
1147
+ RadixSelect__namespace.Content,
1148
+ {
1149
+ position: "popper",
1150
+ sideOffset: 4,
1151
+ "data-slot": "select-content",
1152
+ className: selectContentClass,
1153
+ children: [
1154
+ /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.ScrollUpButton, { className: "flex h-6 cursor-default items-center justify-center bg-popover text-muted-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "size-4" }) }),
1155
+ /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.Viewport, { className: selectViewportClass, children: children ?? (options ? renderOptions(options) : null) }),
1156
+ /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.ScrollDownButton, { className: "flex h-6 cursor-default items-center justify-center bg-popover text-muted-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "size-4" }) })
1157
+ ]
1158
+ }
1159
+ ) })
1160
+ ]
1161
+ }
1162
+ );
1163
+ });
1164
+ function renderOptions(options) {
1165
+ if (isGroupedOptions(options)) {
1166
+ const lastIndex = options.length - 1;
1167
+ return options.map((group, idx) => /* @__PURE__ */ jsxRuntime.jsxs(RadixSelect__namespace.Group, { children: [
1168
+ /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.Label, { className: selectGroupLabelClass, children: group.label }),
1169
+ group.options.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value)),
1170
+ idx < lastIndex && /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.Separator, { className: selectSeparatorClass })
1171
+ ] }, group.label));
1172
+ }
1173
+ return options.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value));
1020
1174
  }
1175
+ var SelectItem = react.forwardRef(function SelectItem2({ className, children, ...props }, ref) {
1176
+ return /* @__PURE__ */ jsxRuntime.jsxs(RadixSelect__namespace.Item, { ref, className: cn(selectItemClass, className), ...props, children: [
1177
+ /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.ItemIndicator, { className: selectItemIndicatorClass, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, {}) }),
1178
+ /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.ItemText, { children })
1179
+ ] });
1180
+ });
1181
+
1182
+ // src/components/switch/switchVariants.ts
1183
+ var switchTrackClass = {
1184
+ sm: "h-4 w-7",
1185
+ md: "h-5 w-9",
1186
+ lg: "h-6 w-11"
1187
+ };
1188
+ var switchThumbClass = {
1189
+ sm: "size-3 data-[state=checked]:translate-x-3 data-[state=checked]:rtl:-translate-x-3",
1190
+ md: "size-4 data-[state=checked]:translate-x-4 data-[state=checked]:rtl:-translate-x-4",
1191
+ lg: "size-5 data-[state=checked]:translate-x-5 data-[state=checked]:rtl:-translate-x-5"
1192
+ };
1193
+ 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";
1194
+ var switchThumbBaseClass = "pointer-events-none block rounded-full bg-background shadow-sm ring-0 transition-transform";
1195
+ var Switch = react.forwardRef(function Switch2({
1196
+ switchSize = "md",
1197
+ checked,
1198
+ defaultChecked,
1199
+ onCheckedChange,
1200
+ value,
1201
+ onChange,
1202
+ onBlur,
1203
+ name,
1204
+ disabled,
1205
+ required,
1206
+ id,
1207
+ className,
1208
+ "aria-label": ariaLabel,
1209
+ "aria-describedby": ariaDescribedBy,
1210
+ "aria-invalid": ariaInvalid
1211
+ }, ref) {
1212
+ const generatedId = react.useId();
1213
+ const switchId = id ?? generatedId;
1214
+ const resolvedChecked = checked ?? (value === void 0 ? void 0 : Boolean(value));
1215
+ const handleCheckedChange = react.useCallback(
1216
+ (next) => {
1217
+ onCheckedChange?.(next);
1218
+ if (onChange) {
1219
+ const synthetic = {
1220
+ target: { checked: next, value: next, name },
1221
+ currentTarget: { checked: next, value: next, name },
1222
+ type: "change"
1223
+ };
1224
+ onChange(synthetic);
1225
+ }
1226
+ },
1227
+ [onCheckedChange, onChange, name]
1228
+ );
1229
+ return /* @__PURE__ */ jsxRuntime.jsx(
1230
+ RadixSwitch__namespace.Root,
1231
+ {
1232
+ ref,
1233
+ id: switchId,
1234
+ checked: resolvedChecked,
1235
+ defaultChecked,
1236
+ onCheckedChange: handleCheckedChange,
1237
+ onBlur,
1238
+ disabled,
1239
+ required,
1240
+ name,
1241
+ "aria-label": ariaLabel,
1242
+ "aria-invalid": ariaInvalid,
1243
+ "aria-describedby": ariaDescribedBy,
1244
+ "data-slot": "switch-track",
1245
+ className: cn(switchTrackBaseClass, switchTrackClass[switchSize], className),
1246
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1247
+ RadixSwitch__namespace.Thumb,
1248
+ {
1249
+ "data-slot": "switch-thumb",
1250
+ className: cn(switchThumbBaseClass, switchThumbClass[switchSize])
1251
+ }
1252
+ )
1253
+ }
1254
+ );
1255
+ });
1021
1256
  function Pagination({
1022
1257
  pageIndex,
1023
1258
  pageSize,
@@ -1607,6 +1842,7 @@ exports.HeaderSearch = HeaderSearch;
1607
1842
  exports.HeaderTitle = HeaderTitle;
1608
1843
  exports.Input = Input;
1609
1844
  exports.LanguageSwitcher = LanguageSwitcher;
1845
+ exports.Select = Select;
1610
1846
  exports.Sidebar = Sidebar;
1611
1847
  exports.SidebarFooter = SidebarFooter;
1612
1848
  exports.SidebarGroup = SidebarGroup;
@@ -1614,6 +1850,7 @@ exports.SidebarHeader = SidebarHeader;
1614
1850
  exports.SidebarNav = SidebarNav;
1615
1851
  exports.SidebarNavGroup = SidebarNavGroup;
1616
1852
  exports.SidebarNavItem = SidebarNavItem;
1853
+ exports.Switch = Switch;
1617
1854
  exports.Table = Table;
1618
1855
  exports.Textarea = Textarea;
1619
1856
  exports.buttonBaseClass = buttonBaseClass;
@@ -1623,6 +1860,13 @@ exports.cn = cn;
1623
1860
  exports.inputBaseClass = inputBaseClass;
1624
1861
  exports.inputSizeClass = inputSizeClass;
1625
1862
  exports.inputVariantClass = inputVariantClass;
1863
+ exports.selectBaseClass = selectBaseClass;
1864
+ exports.selectSizeClass = selectSizeClass;
1865
+ exports.selectVariantClass = selectVariantClass;
1866
+ exports.switchThumbBaseClass = switchThumbBaseClass;
1867
+ exports.switchThumbClass = switchThumbClass;
1868
+ exports.switchTrackBaseClass = switchTrackBaseClass;
1869
+ exports.switchTrackClass = switchTrackClass;
1626
1870
  exports.tableAlignClass = alignClass;
1627
1871
  exports.tableBaseClass = tableBaseClass;
1628
1872
  exports.tableSelectedRowClass = selectedRowClass;