@dimaan/ui 0.0.9 → 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.cjs CHANGED
@@ -7,6 +7,7 @@ var tailwindMerge = require('tailwind-merge');
7
7
  var jsxRuntime = require('react/jsx-runtime');
8
8
  var lucideReact = require('lucide-react');
9
9
  var reactHookForm = require('react-hook-form');
10
+ var RadixRadioGroup = require('@radix-ui/react-radio-group');
10
11
  var RadixSelect = require('@radix-ui/react-select');
11
12
  var RadixSwitch = require('@radix-ui/react-switch');
12
13
 
@@ -28,6 +29,7 @@ function _interopNamespace(e) {
28
29
  return Object.freeze(n);
29
30
  }
30
31
 
32
+ var RadixRadioGroup__namespace = /*#__PURE__*/_interopNamespace(RadixRadioGroup);
31
33
  var RadixSelect__namespace = /*#__PURE__*/_interopNamespace(RadixSelect);
32
34
  var RadixSwitch__namespace = /*#__PURE__*/_interopNamespace(RadixSwitch);
33
35
 
@@ -934,86 +936,67 @@ var inputBaseClass = "group/input relative inline-flex w-full items-center text-
934
936
  var Input = react.forwardRef(function Input2({
935
937
  variant = "default",
936
938
  inputSize = "md",
937
- label,
938
- helperText,
939
- error,
940
939
  leadingIcon,
941
940
  trailingIcon,
942
- fullWidth = true,
943
941
  type = "text",
944
942
  id,
945
943
  className,
946
944
  wrapperClassName,
947
- containerClassName,
948
- "aria-invalid": ariaInvalidProp,
949
- "aria-describedby": ariaDescribedByProp,
945
+ "aria-invalid": ariaInvalid,
946
+ "aria-describedby": ariaDescribedBy,
950
947
  disabled,
951
948
  ...props
952
949
  }, ref) {
953
950
  const generatedId = react.useId();
954
951
  const inputId = id ?? generatedId;
955
- const helperId = `${inputId}-helper`;
956
- const errorId = `${inputId}-error`;
957
- const hasError = error !== void 0 && error !== null && error !== false;
958
- const ariaInvalid = ariaInvalidProp ?? (hasError ? true : void 0);
959
- const describedByIds = [
960
- ariaDescribedByProp,
961
- hasError ? errorId : null,
962
- !hasError && helperText ? helperId : null
963
- ].filter(Boolean).join(" ");
964
- const ariaDescribedBy = describedByIds.length > 0 ? describedByIds : void 0;
965
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-1.5", fullWidth && "w-full", containerClassName), children: [
966
- label !== void 0 && label !== null && /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: inputId, className: "text-sm font-medium text-foreground select-none", children: label }),
967
- /* @__PURE__ */ jsxRuntime.jsxs(
968
- "div",
969
- {
970
- "data-slot": "input-wrapper",
971
- className: cn(
972
- inputBaseClass,
973
- inputVariantClass[variant],
974
- inputSizeClass[inputSize],
975
- wrapperClassName
952
+ return /* @__PURE__ */ jsxRuntime.jsxs(
953
+ "div",
954
+ {
955
+ "data-slot": "input-wrapper",
956
+ className: cn(
957
+ inputBaseClass,
958
+ inputVariantClass[variant],
959
+ inputSizeClass[inputSize],
960
+ wrapperClassName
961
+ ),
962
+ "aria-invalid": ariaInvalid,
963
+ "data-disabled": disabled ? "true" : void 0,
964
+ children: [
965
+ leadingIcon ? /* @__PURE__ */ jsxRuntime.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: leadingIcon
971
+ }
972
+ ) : null,
973
+ /* @__PURE__ */ jsxRuntime.jsx(
974
+ "input",
975
+ {
976
+ ref,
977
+ id: inputId,
978
+ type,
979
+ disabled,
980
+ "aria-invalid": ariaInvalid,
981
+ "aria-describedby": ariaDescribedBy,
982
+ className: cn(
983
+ "h-full w-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed",
984
+ className
985
+ ),
986
+ ...props
987
+ }
976
988
  ),
977
- "aria-invalid": ariaInvalid,
978
- "data-disabled": disabled ? "true" : void 0,
979
- children: [
980
- leadingIcon ? /* @__PURE__ */ jsxRuntime.jsx(
981
- "span",
982
- {
983
- "aria-hidden": "true",
984
- className: "inline-flex h-4 w-4 items-center justify-center text-muted-foreground",
985
- children: leadingIcon
986
- }
987
- ) : null,
988
- /* @__PURE__ */ jsxRuntime.jsx(
989
- "input",
990
- {
991
- ref,
992
- id: inputId,
993
- type,
994
- disabled,
995
- "aria-invalid": ariaInvalid,
996
- "aria-describedby": ariaDescribedBy,
997
- className: cn(
998
- "h-full w-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed",
999
- className
1000
- ),
1001
- ...props
1002
- }
1003
- ),
1004
- trailingIcon ? /* @__PURE__ */ jsxRuntime.jsx(
1005
- "span",
1006
- {
1007
- "aria-hidden": "true",
1008
- className: "inline-flex h-4 w-4 items-center justify-center text-muted-foreground",
1009
- children: trailingIcon
1010
- }
1011
- ) : null
1012
- ]
1013
- }
1014
- ),
1015
- 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
1016
- ] });
989
+ trailingIcon ? /* @__PURE__ */ jsxRuntime.jsx(
990
+ "span",
991
+ {
992
+ "aria-hidden": "true",
993
+ className: "inline-flex h-4 w-4 items-center justify-center text-muted-foreground",
994
+ children: trailingIcon
995
+ }
996
+ ) : null
997
+ ]
998
+ }
999
+ );
1017
1000
  });
1018
1001
  function LanguageSwitcher({
1019
1002
  languages,
@@ -1053,6 +1036,131 @@ function LanguageSwitcher({
1053
1036
  );
1054
1037
  }
1055
1038
 
1039
+ // src/components/radio-group/radioGroupVariants.ts
1040
+ var radioItemSizeClass = {
1041
+ sm: "size-4",
1042
+ md: "size-5",
1043
+ lg: "size-6"
1044
+ };
1045
+ var radioIndicatorSizeClass = {
1046
+ sm: "size-1.5",
1047
+ md: "size-2",
1048
+ lg: "size-2.5"
1049
+ };
1050
+ var radioLabelSizeClass = {
1051
+ sm: "text-xs",
1052
+ md: "text-sm",
1053
+ lg: "text-base"
1054
+ };
1055
+ 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";
1056
+ var radioIndicatorBaseClass = "flex h-full w-full items-center justify-center";
1057
+ var radioIndicatorDotClass = "rounded-full bg-primary";
1058
+ var radioOptionRowClass = "flex cursor-pointer items-start gap-2 has-[button:disabled]:cursor-not-allowed";
1059
+ var radioGroupBaseClass = "flex gap-3";
1060
+ var radioGroupOrientationClass = {
1061
+ vertical: "flex-col",
1062
+ horizontal: "flex-row flex-wrap"
1063
+ };
1064
+ var RadioGroup = react.forwardRef(function RadioGroup2({
1065
+ radioSize = "md",
1066
+ orientation = "vertical",
1067
+ value,
1068
+ defaultValue,
1069
+ onValueChange,
1070
+ onChange,
1071
+ onBlur,
1072
+ name,
1073
+ disabled,
1074
+ required,
1075
+ id,
1076
+ options,
1077
+ className,
1078
+ "aria-label": ariaLabel,
1079
+ "aria-labelledby": ariaLabelledBy,
1080
+ "aria-describedby": ariaDescribedBy,
1081
+ "aria-invalid": ariaInvalid,
1082
+ children
1083
+ }, ref) {
1084
+ const generatedId = react.useId();
1085
+ const groupId = id ?? generatedId;
1086
+ const handleValueChange = react.useCallback(
1087
+ (next) => {
1088
+ onValueChange?.(next);
1089
+ if (onChange) {
1090
+ const synthetic = {
1091
+ target: { value: next, name },
1092
+ currentTarget: { value: next, name },
1093
+ type: "change"
1094
+ };
1095
+ onChange(synthetic);
1096
+ }
1097
+ },
1098
+ [onValueChange, onChange, name]
1099
+ );
1100
+ return /* @__PURE__ */ jsxRuntime.jsx(
1101
+ RadixRadioGroup__namespace.Root,
1102
+ {
1103
+ ref,
1104
+ id: groupId,
1105
+ value,
1106
+ defaultValue,
1107
+ onValueChange: handleValueChange,
1108
+ onBlur,
1109
+ disabled,
1110
+ required,
1111
+ name,
1112
+ orientation,
1113
+ "aria-label": ariaLabel,
1114
+ "aria-labelledby": ariaLabelledBy,
1115
+ "aria-describedby": ariaDescribedBy,
1116
+ "aria-invalid": ariaInvalid,
1117
+ "data-slot": "radio-group",
1118
+ className: cn(radioGroupBaseClass, radioGroupOrientationClass[orientation], className),
1119
+ children: children ?? options?.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(
1120
+ RadioGroupOptionRow,
1121
+ {
1122
+ option: opt,
1123
+ radioSize,
1124
+ groupId
1125
+ },
1126
+ opt.value
1127
+ ))
1128
+ }
1129
+ );
1130
+ });
1131
+ function RadioGroupOptionRow({ option, radioSize, groupId }) {
1132
+ const itemId = `${groupId}-${option.value}`;
1133
+ return /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: itemId, className: radioOptionRowClass, children: [
1134
+ /* @__PURE__ */ jsxRuntime.jsx(
1135
+ RadixRadioGroup__namespace.Item,
1136
+ {
1137
+ id: itemId,
1138
+ value: option.value,
1139
+ disabled: option.disabled,
1140
+ "data-slot": "radio-item",
1141
+ className: cn(radioItemBaseClass, radioItemSizeClass[radioSize], "mt-0.5"),
1142
+ children: /* @__PURE__ */ jsxRuntime.jsx(RadixRadioGroup__namespace.Indicator, { className: radioIndicatorBaseClass, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(radioIndicatorDotClass, radioIndicatorSizeClass[radioSize]) }) })
1143
+ }
1144
+ ),
1145
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "min-w-0 flex-1 leading-tight", children: [
1146
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("block font-medium text-foreground", radioLabelSizeClass[radioSize]), children: option.label }),
1147
+ option.description ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: option.description }) : null
1148
+ ] })
1149
+ ] });
1150
+ }
1151
+ var RadioGroupItem = react.forwardRef(function RadioGroupItem2({ className, radioSize = "md", ...props }, ref) {
1152
+ return /* @__PURE__ */ jsxRuntime.jsx(
1153
+ RadixRadioGroup__namespace.Item,
1154
+ {
1155
+ ref,
1156
+ "data-slot": "radio-item",
1157
+ className: cn(radioItemBaseClass, radioItemSizeClass[radioSize], className),
1158
+ ...props,
1159
+ children: /* @__PURE__ */ jsxRuntime.jsx(RadixRadioGroup__namespace.Indicator, { className: radioIndicatorBaseClass, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(radioIndicatorDotClass, radioIndicatorSizeClass[radioSize]) }) })
1160
+ }
1161
+ );
1162
+ });
1163
+
1056
1164
  // src/components/select/selectVariants.ts
1057
1165
  var selectVariantClass = {
1058
1166
  default: "border border-input bg-background hover:border-ring",
@@ -1763,67 +1871,48 @@ var Textarea = react.forwardRef(function Textarea2({
1763
1871
  variant = "default",
1764
1872
  textareaSize = "md",
1765
1873
  resize = "vertical",
1766
- label,
1767
- helperText,
1768
- error,
1769
- fullWidth = true,
1770
1874
  rows = 4,
1771
1875
  id,
1772
1876
  className,
1773
1877
  wrapperClassName,
1774
- containerClassName,
1775
- "aria-invalid": ariaInvalidProp,
1776
- "aria-describedby": ariaDescribedByProp,
1878
+ "aria-invalid": ariaInvalid,
1879
+ "aria-describedby": ariaDescribedBy,
1777
1880
  disabled,
1778
1881
  ...props
1779
1882
  }, ref) {
1780
1883
  const generatedId = react.useId();
1781
1884
  const textareaId = id ?? generatedId;
1782
- const helperId = `${textareaId}-helper`;
1783
- const errorId = `${textareaId}-error`;
1784
- const hasError = error !== void 0 && error !== null && error !== false;
1785
- const ariaInvalid = ariaInvalidProp ?? (hasError ? true : void 0);
1786
- const describedByIds = [
1787
- ariaDescribedByProp,
1788
- hasError ? errorId : null,
1789
- !hasError && helperText ? helperId : null
1790
- ].filter(Boolean).join(" ");
1791
- const ariaDescribedBy = describedByIds.length > 0 ? describedByIds : void 0;
1792
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-1.5", fullWidth && "w-full", containerClassName), children: [
1793
- label !== void 0 && label !== null && /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: textareaId, className: "text-sm font-medium text-foreground select-none", children: label }),
1794
- /* @__PURE__ */ jsxRuntime.jsx(
1795
- "div",
1796
- {
1797
- "data-slot": "textarea-wrapper",
1798
- className: cn(
1799
- textareaBaseClass,
1800
- textareaVariantClass[variant],
1801
- textareaSizeClass[textareaSize],
1802
- wrapperClassName
1803
- ),
1804
- "aria-invalid": ariaInvalid,
1805
- "data-disabled": disabled ? "true" : void 0,
1806
- children: /* @__PURE__ */ jsxRuntime.jsx(
1807
- "textarea",
1808
- {
1809
- ref,
1810
- id: textareaId,
1811
- rows,
1812
- disabled,
1813
- "aria-invalid": ariaInvalid,
1814
- "aria-describedby": ariaDescribedBy,
1815
- className: cn(
1816
- "w-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed",
1817
- textareaResizeClass[resize],
1818
- className
1819
- ),
1820
- ...props
1821
- }
1822
- )
1823
- }
1824
- ),
1825
- 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
1826
- ] });
1885
+ return /* @__PURE__ */ jsxRuntime.jsx(
1886
+ "div",
1887
+ {
1888
+ "data-slot": "textarea-wrapper",
1889
+ className: cn(
1890
+ textareaBaseClass,
1891
+ textareaVariantClass[variant],
1892
+ textareaSizeClass[textareaSize],
1893
+ wrapperClassName
1894
+ ),
1895
+ "aria-invalid": ariaInvalid,
1896
+ "data-disabled": disabled ? "true" : void 0,
1897
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1898
+ "textarea",
1899
+ {
1900
+ ref,
1901
+ id: textareaId,
1902
+ rows,
1903
+ disabled,
1904
+ "aria-invalid": ariaInvalid,
1905
+ "aria-describedby": ariaDescribedBy,
1906
+ className: cn(
1907
+ "w-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed",
1908
+ textareaResizeClass[resize],
1909
+ className
1910
+ ),
1911
+ ...props
1912
+ }
1913
+ )
1914
+ }
1915
+ );
1827
1916
  });
1828
1917
 
1829
1918
  exports.AppShell = AppShell;
@@ -1842,6 +1931,8 @@ exports.HeaderSearch = HeaderSearch;
1842
1931
  exports.HeaderTitle = HeaderTitle;
1843
1932
  exports.Input = Input;
1844
1933
  exports.LanguageSwitcher = LanguageSwitcher;
1934
+ exports.RadioGroup = RadioGroup;
1935
+ exports.RadioGroupItem = RadioGroupItem;
1845
1936
  exports.Select = Select;
1846
1937
  exports.Sidebar = Sidebar;
1847
1938
  exports.SidebarFooter = SidebarFooter;
@@ -1860,6 +1951,15 @@ exports.cn = cn;
1860
1951
  exports.inputBaseClass = inputBaseClass;
1861
1952
  exports.inputSizeClass = inputSizeClass;
1862
1953
  exports.inputVariantClass = inputVariantClass;
1954
+ exports.radioGroupBaseClass = radioGroupBaseClass;
1955
+ exports.radioGroupOrientationClass = radioGroupOrientationClass;
1956
+ exports.radioIndicatorBaseClass = radioIndicatorBaseClass;
1957
+ exports.radioIndicatorDotClass = radioIndicatorDotClass;
1958
+ exports.radioIndicatorSizeClass = radioIndicatorSizeClass;
1959
+ exports.radioItemBaseClass = radioItemBaseClass;
1960
+ exports.radioItemSizeClass = radioItemSizeClass;
1961
+ exports.radioLabelSizeClass = radioLabelSizeClass;
1962
+ exports.radioOptionRowClass = radioOptionRowClass;
1863
1963
  exports.selectBaseClass = selectBaseClass;
1864
1964
  exports.selectSizeClass = selectSizeClass;
1865
1965
  exports.selectVariantClass = selectVariantClass;