@teach-in/react 1.3.0 → 1.5.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.
Files changed (137) hide show
  1. package/dist/chunk-2UHA3DYG.mjs +62 -0
  2. package/dist/{chunk-LJIVY6GU.mjs → chunk-46SKVFMZ.mjs} +1 -1
  3. package/dist/{chunk-JDFRAN4S.mjs → chunk-5FFWQB7D.mjs} +12 -2
  4. package/dist/{chunk-544SDU73.mjs → chunk-BBUPZCY6.mjs} +1 -1
  5. package/dist/chunk-C2VWADF5.mjs +34 -0
  6. package/dist/{chunk-NLHQDWUK.mjs → chunk-CKJ5U5Q4.mjs} +1 -1
  7. package/dist/chunk-CUEG2BFV.mjs +34 -0
  8. package/dist/chunk-GTE5VEBV.mjs +68 -0
  9. package/dist/{chunk-CETCW7DS.mjs → chunk-IU2JYI7W.mjs} +1 -1
  10. package/dist/{chunk-KTUGFQWJ.mjs → chunk-KTWHCUYV.mjs} +1 -1
  11. package/dist/chunk-MCQGBAUS.mjs +73 -0
  12. package/dist/chunk-NSU66J5E.mjs +59 -0
  13. package/dist/{chunk-UFYLYN5Z.mjs → chunk-QFWSQOF6.mjs} +20 -2
  14. package/dist/{chunk-R7LDL5CU.mjs → chunk-R46SWVWL.mjs} +1 -1
  15. package/dist/{chunk-WFNNN6WU.mjs → chunk-RPIOTLYT.mjs} +1 -1
  16. package/dist/chunk-SEJXJZSK.mjs +64 -0
  17. package/dist/chunk-TUIN5YJW.mjs +33 -0
  18. package/dist/chunk-UQAG7TKJ.mjs +1 -0
  19. package/dist/chunk-VXYV37IM.mjs +74 -0
  20. package/dist/{chunk-J3OZNLTZ.mjs → chunk-WG4IPOHE.mjs} +5 -5
  21. package/dist/{chunk-AFVGHUW2.mjs → chunk-YZB4VBX7.mjs} +24 -2
  22. package/dist/index.js +658 -247
  23. package/dist/index.mjs +200 -184
  24. package/dist/ui/data/index.mjs +8 -8
  25. package/dist/ui/feedback/index.mjs +11 -11
  26. package/dist/ui/feedback/progress/index.mjs +3 -3
  27. package/dist/ui/form/index.js +447 -106
  28. package/dist/ui/form/index.mjs +30 -20
  29. package/dist/ui/form/rhf/fields/autocomplete-field.mjs +19 -13
  30. package/dist/ui/form/rhf/fields/checkbox-field.mjs +19 -13
  31. package/dist/ui/form/rhf/fields/date-picker-field.mjs +19 -13
  32. package/dist/ui/form/rhf/fields/email-field.js +147 -10
  33. package/dist/ui/form/rhf/fields/email-field.mjs +20 -14
  34. package/dist/ui/form/rhf/fields/index.d.ts +1 -0
  35. package/dist/ui/form/rhf/fields/index.js +443 -102
  36. package/dist/ui/form/rhf/fields/index.mjs +30 -20
  37. package/dist/ui/form/rhf/fields/input-field.js +153 -6
  38. package/dist/ui/form/rhf/fields/input-field.mjs +20 -14
  39. package/dist/ui/form/rhf/fields/radio-field.mjs +19 -13
  40. package/dist/ui/form/rhf/fields/search-field.d.ts +10 -0
  41. package/dist/ui/form/rhf/fields/search-field.js +296 -0
  42. package/dist/ui/form/rhf/fields/search-field.mjs +37 -0
  43. package/dist/ui/form/rhf/fields/select-field.js +136 -26
  44. package/dist/ui/form/rhf/fields/select-field.mjs +20 -14
  45. package/dist/ui/form/rhf/fields/switch-field.mjs +19 -13
  46. package/dist/ui/form/rhf/fields/text-field.js +147 -10
  47. package/dist/ui/form/rhf/fields/text-field.mjs +20 -14
  48. package/dist/ui/form/rhf/fields/textarea-field.mjs +19 -13
  49. package/dist/ui/form/rhf/index.js +443 -102
  50. package/dist/ui/form/rhf/index.mjs +30 -20
  51. package/dist/ui/format/index.mjs +6 -6
  52. package/dist/ui/index.js +658 -247
  53. package/dist/ui/index.mjs +199 -183
  54. package/dist/ui/inputs/clear-button.d.ts +5 -0
  55. package/dist/ui/inputs/clear-button.js +67 -0
  56. package/dist/ui/inputs/clear-button.mjs +8 -0
  57. package/dist/ui/inputs/email/email.js +144 -7
  58. package/dist/ui/inputs/email/email.mjs +4 -2
  59. package/dist/ui/inputs/email/index.js +144 -7
  60. package/dist/ui/inputs/email/index.mjs +4 -2
  61. package/dist/ui/inputs/index.d.ts +2 -0
  62. package/dist/ui/inputs/index.js +396 -59
  63. package/dist/ui/inputs/index.mjs +33 -21
  64. package/dist/ui/inputs/input/index.js +140 -3
  65. package/dist/ui/inputs/input/index.mjs +3 -1
  66. package/dist/ui/inputs/input/input.d.ts +1 -0
  67. package/dist/ui/inputs/input/input.js +140 -3
  68. package/dist/ui/inputs/input/input.mjs +3 -1
  69. package/dist/ui/inputs/input/use-input.d.ts +19 -0
  70. package/dist/ui/inputs/input/use-input.js +82 -0
  71. package/dist/ui/inputs/input/use-input.mjs +7 -0
  72. package/dist/ui/inputs/radio/index.mjs +3 -3
  73. package/dist/ui/inputs/search/index.d.ts +1 -0
  74. package/dist/ui/inputs/search/index.js +270 -0
  75. package/dist/ui/inputs/search/index.mjs +13 -0
  76. package/dist/ui/inputs/search/search.d.ts +7 -0
  77. package/dist/ui/inputs/search/search.js +268 -0
  78. package/dist/ui/inputs/search/search.mjs +12 -0
  79. package/dist/ui/inputs/search/use-search.d.ts +12 -0
  80. package/dist/ui/inputs/search/use-search.js +57 -0
  81. package/dist/ui/inputs/search/use-search.mjs +7 -0
  82. package/dist/ui/inputs/select/index.js +132 -22
  83. package/dist/ui/inputs/select/index.mjs +3 -1
  84. package/dist/ui/inputs/select/select.d.ts +4 -0
  85. package/dist/ui/inputs/select/select.js +132 -22
  86. package/dist/ui/inputs/select/select.mjs +3 -1
  87. package/dist/ui/inputs/select/use-select.d.ts +17 -0
  88. package/dist/ui/inputs/select/use-select.js +85 -0
  89. package/dist/ui/inputs/select/use-select.mjs +7 -0
  90. package/dist/ui/inputs/switch/favorite-switch.d.ts +23 -2
  91. package/dist/ui/inputs/switch/favorite-switch.js +34 -4
  92. package/dist/ui/inputs/switch/favorite-switch.mjs +1 -1
  93. package/dist/ui/inputs/switch/index.js +34 -4
  94. package/dist/ui/inputs/switch/index.mjs +3 -3
  95. package/dist/ui/inputs/text/index.js +144 -7
  96. package/dist/ui/inputs/text/index.mjs +4 -2
  97. package/dist/ui/inputs/text/text.js +144 -7
  98. package/dist/ui/inputs/text/text.mjs +4 -2
  99. package/dist/ui/layout/container/container.mjs +96 -89
  100. package/dist/ui/layout/container/index.mjs +96 -89
  101. package/dist/ui/layout/index.mjs +101 -94
  102. package/dist/ui/layout/page/index.mjs +7 -7
  103. package/dist/ui/layout/page/page-loading.mjs +6 -6
  104. package/dist/ui/layout/page/section-loading.mjs +6 -6
  105. package/dist/ui/navigation/index.mjs +9 -9
  106. package/dist/ui/overlays/index.mjs +8 -8
  107. package/dist/ui/provider/index.mjs +6 -6
  108. package/dist/ui/provider/ui-provider.mjs +6 -6
  109. package/dist/ui/surface/bento/bento.d.ts +2 -2
  110. package/dist/ui/surface/bento/bento.js +5 -5
  111. package/dist/ui/surface/bento/bento.mjs +1 -1
  112. package/dist/ui/surface/bento/index.js +5 -5
  113. package/dist/ui/surface/bento/index.mjs +1 -1
  114. package/dist/ui/surface/card/card.d.ts +2427 -5
  115. package/dist/ui/surface/card/card.js +29 -2
  116. package/dist/ui/surface/card/card.mjs +5 -1
  117. package/dist/ui/surface/card/index.js +29 -2
  118. package/dist/ui/surface/card/index.mjs +5 -1
  119. package/dist/ui/surface/index.js +34 -7
  120. package/dist/ui/surface/index.mjs +7 -3
  121. package/dist/ui/theme/colors/index.js +24 -2
  122. package/dist/ui/theme/colors/index.mjs +2 -2
  123. package/dist/ui/theme/colors/semantic.js +24 -2
  124. package/dist/ui/theme/colors/semantic.mjs +1 -1
  125. package/dist/ui/theme/colors/types.d.ts +2 -0
  126. package/dist/ui/theme/colors.js +24 -2
  127. package/dist/ui/theme/colors.mjs +2 -2
  128. package/dist/ui/theme/index.js +24 -2
  129. package/dist/ui/theme/index.mjs +3 -3
  130. package/dist/ui/theme/theme.js +24 -2
  131. package/dist/ui/theme/theme.mjs +3 -3
  132. package/package.json +1 -1
  133. package/dist/chunk-3YOW5DEZ.mjs +0 -45
  134. package/dist/chunk-E5QSNLSR.mjs +0 -38
  135. package/dist/chunk-V2G5QHZZ.mjs +0 -14
  136. /package/dist/{chunk-CZEO3U25.mjs → chunk-5RNCFTW5.mjs} +0 -0
  137. /package/dist/{chunk-Q6JSJOU4.mjs → chunk-PTCNYQVY.mjs} +0 -0
@@ -36,39 +36,149 @@ __export(select_exports, {
36
36
  module.exports = __toCommonJS(select_exports);
37
37
 
38
38
  // src/ui/inputs/select/select.tsx
39
- var import_react = __toESM(require("react"));
39
+ var import_react3 = __toESM(require("react"));
40
40
  var import_select = require("@heroui/select");
41
+ var import_tailwind_variants = require("tailwind-variants");
42
+
43
+ // src/ui/inputs/clear-button.tsx
44
+ var import_react = __toESM(require("react"));
45
+ var import_button = require("@heroui/button");
46
+ var import_lucide_react = require("lucide-react");
41
47
  var import_jsx_runtime = require("react/jsx-runtime");
42
- var Select = import_react.default.forwardRef(
43
- ({ value, items, onChange, selectionMode, ...props }, ref) => {
44
- const isMultiple = selectionMode === "multiple";
45
- const selectedKeys = import_react.default.useMemo(() => {
46
- if (value == null) return /* @__PURE__ */ new Set();
47
- return new Set(Array.isArray(value) ? value : [value]);
48
- }, [value]);
49
- const handleSelectionChange = import_react.default.useCallback(
50
- (keys) => {
51
- var _a;
52
- if (keys === "all") return;
53
- const selected = Array.from(keys).filter((key) => typeof key === "string");
54
- if (isMultiple) {
55
- onChange == null ? void 0 : onChange(selected);
56
- } else {
57
- onChange == null ? void 0 : onChange((_a = selected[0]) != null ? _a : null);
58
- }
59
- },
60
- [onChange, isMultiple]
61
- );
48
+ var ClearButton = import_react.default.forwardRef(
49
+ ({ onClear }, ref) => {
62
50
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
51
+ import_button.Button,
52
+ {
53
+ ref,
54
+ isIconOnly: true,
55
+ "aria-label": "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C",
56
+ as: "span",
57
+ className: "opacity-0 transition-opacity group-hover:opacity-100",
58
+ color: "default",
59
+ radius: "full",
60
+ size: "sm",
61
+ tabIndex: 0,
62
+ variant: "light",
63
+ onPress: onClear,
64
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.XIcon, { className: "size-4 text-default-500" })
65
+ }
66
+ );
67
+ }
68
+ );
69
+ ClearButton.displayName = "TeachInUI.ClearButton";
70
+
71
+ // src/ui/inputs/select/use-select.ts
72
+ var import_react2 = require("react");
73
+ function useSelect({
74
+ value,
75
+ onChange,
76
+ onClear,
77
+ selectionMode,
78
+ isClearable = true
79
+ }) {
80
+ const isMultiple = selectionMode === "multiple";
81
+ const [internalValue, setInternalValue] = (0, import_react2.useState)(
82
+ isMultiple ? [] : null
83
+ );
84
+ const isControlled = value !== void 0;
85
+ const currentValue = isControlled ? value : internalValue;
86
+ const hasValue = currentValue != null && (Array.isArray(currentValue) ? currentValue.length > 0 : currentValue !== "");
87
+ const handleChange = (0, import_react2.useCallback)(
88
+ (newValue) => {
89
+ if (!isControlled) {
90
+ setInternalValue(newValue);
91
+ }
92
+ if (isMultiple) {
93
+ onChange == null ? void 0 : onChange(newValue);
94
+ } else {
95
+ onChange == null ? void 0 : onChange(newValue);
96
+ }
97
+ },
98
+ [isControlled, onChange, isMultiple]
99
+ );
100
+ const handleClear = (0, import_react2.useCallback)(() => {
101
+ onClear == null ? void 0 : onClear();
102
+ handleChange(isMultiple ? [] : null);
103
+ }, [onClear, handleChange, isMultiple]);
104
+ const selectedKeys = (0, import_react2.useMemo)(() => {
105
+ if (currentValue == null) return /* @__PURE__ */ new Set();
106
+ return new Set(Array.isArray(currentValue) ? currentValue : [currentValue]);
107
+ }, [currentValue]);
108
+ const handleSelectionChange = (0, import_react2.useCallback)(
109
+ (keys) => {
110
+ var _a;
111
+ if (keys === "all") return;
112
+ const selected = Array.from(keys).filter((key) => typeof key === "string");
113
+ handleChange(isMultiple ? selected : (_a = selected[0]) != null ? _a : null);
114
+ },
115
+ [handleChange, isMultiple]
116
+ );
117
+ const showClearButton = hasValue && isClearable;
118
+ return {
119
+ currentValue,
120
+ hasValue,
121
+ selectedKeys,
122
+ handleSelectionChange,
123
+ handleClear,
124
+ showClearButton
125
+ };
126
+ }
127
+
128
+ // src/ui/inputs/select/select.tsx
129
+ var import_jsx_runtime2 = require("react/jsx-runtime");
130
+ var selectWrapperVariants = (0, import_tailwind_variants.tv)({
131
+ variants: {
132
+ variant: {
133
+ flat: "",
134
+ underlined: "",
135
+ bordered: "border-1",
136
+ faded: "border-1"
137
+ }
138
+ }
139
+ });
140
+ var Select = import_react3.default.forwardRef(
141
+ ({
142
+ value,
143
+ defaultSelectedKeys,
144
+ items,
145
+ onChange,
146
+ selectionMode,
147
+ onClear,
148
+ variant,
149
+ classNames,
150
+ endContent,
151
+ isClearable,
152
+ ...props
153
+ }, ref) => {
154
+ const { selectedKeys, handleSelectionChange, handleClear, showClearButton } = useSelect({
155
+ value,
156
+ onChange,
157
+ onClear,
158
+ selectionMode,
159
+ isClearable
160
+ });
161
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
63
162
  import_select.Select,
64
163
  {
65
164
  ref,
165
+ classNames: {
166
+ ...classNames,
167
+ trigger: selectWrapperVariants({ variant }),
168
+ innerWrapper: "group"
169
+ },
170
+ defaultSelectedKeys,
171
+ endContent: (endContent || showClearButton) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-1", children: [
172
+ endContent,
173
+ showClearButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ClearButton, { onClear: handleClear })
174
+ ] }),
66
175
  items,
67
176
  selectedKeys,
68
177
  selectionMode,
178
+ variant,
69
179
  onSelectionChange: handleSelectionChange,
70
180
  ...props,
71
- children: (item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectItem, { children: item.label }, item.key)
181
+ children: (item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_select.SelectItem, { children: item.label }, item.key)
72
182
  }
73
183
  );
74
184
  }
@@ -2,7 +2,9 @@
2
2
  import "../../../chunk-AQ3ISJKU.mjs";
3
3
  import {
4
4
  Select
5
- } from "../../../chunk-3YOW5DEZ.mjs";
5
+ } from "../../../chunk-VXYV37IM.mjs";
6
+ import "../../../chunk-2UHA3DYG.mjs";
7
+ import "../../../chunk-TUIN5YJW.mjs";
6
8
  export {
7
9
  Select
8
10
  };
@@ -9,18 +9,22 @@ export type SelectProps = (BaseSelectProps & {
9
9
  selectionMode?: "single";
10
10
  value?: string;
11
11
  onChange?: (value: string | null) => void;
12
+ onClear?: () => void;
12
13
  }) | (BaseSelectProps & {
13
14
  selectionMode: "multiple";
14
15
  value?: string[];
15
16
  onChange?: (value: string[]) => void;
17
+ onClear?: () => void;
16
18
  });
17
19
  export declare const Select: React.ForwardRefExoticComponent<(Omit<BaseSelectProps & {
18
20
  selectionMode?: "single";
19
21
  value?: string;
20
22
  onChange?: (value: string | null) => void;
23
+ onClear?: () => void;
21
24
  }, "ref"> | Omit<BaseSelectProps & {
22
25
  selectionMode: "multiple";
23
26
  value?: string[];
24
27
  onChange?: (value: string[]) => void;
28
+ onClear?: () => void;
25
29
  }, "ref">) & React.RefAttributes<HTMLSelectElement>>;
26
30
  export {};
@@ -34,39 +34,149 @@ __export(select_exports, {
34
34
  Select: () => Select
35
35
  });
36
36
  module.exports = __toCommonJS(select_exports);
37
- var import_react = __toESM(require("react"));
37
+ var import_react3 = __toESM(require("react"));
38
38
  var import_select = require("@heroui/select");
39
+ var import_tailwind_variants = require("tailwind-variants");
40
+
41
+ // src/ui/inputs/clear-button.tsx
42
+ var import_react = __toESM(require("react"));
43
+ var import_button = require("@heroui/button");
44
+ var import_lucide_react = require("lucide-react");
39
45
  var import_jsx_runtime = require("react/jsx-runtime");
40
- var Select = import_react.default.forwardRef(
41
- ({ value, items, onChange, selectionMode, ...props }, ref) => {
42
- const isMultiple = selectionMode === "multiple";
43
- const selectedKeys = import_react.default.useMemo(() => {
44
- if (value == null) return /* @__PURE__ */ new Set();
45
- return new Set(Array.isArray(value) ? value : [value]);
46
- }, [value]);
47
- const handleSelectionChange = import_react.default.useCallback(
48
- (keys) => {
49
- var _a;
50
- if (keys === "all") return;
51
- const selected = Array.from(keys).filter((key) => typeof key === "string");
52
- if (isMultiple) {
53
- onChange == null ? void 0 : onChange(selected);
54
- } else {
55
- onChange == null ? void 0 : onChange((_a = selected[0]) != null ? _a : null);
56
- }
57
- },
58
- [onChange, isMultiple]
59
- );
46
+ var ClearButton = import_react.default.forwardRef(
47
+ ({ onClear }, ref) => {
60
48
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49
+ import_button.Button,
50
+ {
51
+ ref,
52
+ isIconOnly: true,
53
+ "aria-label": "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C",
54
+ as: "span",
55
+ className: "opacity-0 transition-opacity group-hover:opacity-100",
56
+ color: "default",
57
+ radius: "full",
58
+ size: "sm",
59
+ tabIndex: 0,
60
+ variant: "light",
61
+ onPress: onClear,
62
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.XIcon, { className: "size-4 text-default-500" })
63
+ }
64
+ );
65
+ }
66
+ );
67
+ ClearButton.displayName = "TeachInUI.ClearButton";
68
+
69
+ // src/ui/inputs/select/use-select.ts
70
+ var import_react2 = require("react");
71
+ function useSelect({
72
+ value,
73
+ onChange,
74
+ onClear,
75
+ selectionMode,
76
+ isClearable = true
77
+ }) {
78
+ const isMultiple = selectionMode === "multiple";
79
+ const [internalValue, setInternalValue] = (0, import_react2.useState)(
80
+ isMultiple ? [] : null
81
+ );
82
+ const isControlled = value !== void 0;
83
+ const currentValue = isControlled ? value : internalValue;
84
+ const hasValue = currentValue != null && (Array.isArray(currentValue) ? currentValue.length > 0 : currentValue !== "");
85
+ const handleChange = (0, import_react2.useCallback)(
86
+ (newValue) => {
87
+ if (!isControlled) {
88
+ setInternalValue(newValue);
89
+ }
90
+ if (isMultiple) {
91
+ onChange == null ? void 0 : onChange(newValue);
92
+ } else {
93
+ onChange == null ? void 0 : onChange(newValue);
94
+ }
95
+ },
96
+ [isControlled, onChange, isMultiple]
97
+ );
98
+ const handleClear = (0, import_react2.useCallback)(() => {
99
+ onClear == null ? void 0 : onClear();
100
+ handleChange(isMultiple ? [] : null);
101
+ }, [onClear, handleChange, isMultiple]);
102
+ const selectedKeys = (0, import_react2.useMemo)(() => {
103
+ if (currentValue == null) return /* @__PURE__ */ new Set();
104
+ return new Set(Array.isArray(currentValue) ? currentValue : [currentValue]);
105
+ }, [currentValue]);
106
+ const handleSelectionChange = (0, import_react2.useCallback)(
107
+ (keys) => {
108
+ var _a;
109
+ if (keys === "all") return;
110
+ const selected = Array.from(keys).filter((key) => typeof key === "string");
111
+ handleChange(isMultiple ? selected : (_a = selected[0]) != null ? _a : null);
112
+ },
113
+ [handleChange, isMultiple]
114
+ );
115
+ const showClearButton = hasValue && isClearable;
116
+ return {
117
+ currentValue,
118
+ hasValue,
119
+ selectedKeys,
120
+ handleSelectionChange,
121
+ handleClear,
122
+ showClearButton
123
+ };
124
+ }
125
+
126
+ // src/ui/inputs/select/select.tsx
127
+ var import_jsx_runtime2 = require("react/jsx-runtime");
128
+ var selectWrapperVariants = (0, import_tailwind_variants.tv)({
129
+ variants: {
130
+ variant: {
131
+ flat: "",
132
+ underlined: "",
133
+ bordered: "border-1",
134
+ faded: "border-1"
135
+ }
136
+ }
137
+ });
138
+ var Select = import_react3.default.forwardRef(
139
+ ({
140
+ value,
141
+ defaultSelectedKeys,
142
+ items,
143
+ onChange,
144
+ selectionMode,
145
+ onClear,
146
+ variant,
147
+ classNames,
148
+ endContent,
149
+ isClearable,
150
+ ...props
151
+ }, ref) => {
152
+ const { selectedKeys, handleSelectionChange, handleClear, showClearButton } = useSelect({
153
+ value,
154
+ onChange,
155
+ onClear,
156
+ selectionMode,
157
+ isClearable
158
+ });
159
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
61
160
  import_select.Select,
62
161
  {
63
162
  ref,
163
+ classNames: {
164
+ ...classNames,
165
+ trigger: selectWrapperVariants({ variant }),
166
+ innerWrapper: "group"
167
+ },
168
+ defaultSelectedKeys,
169
+ endContent: (endContent || showClearButton) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-1", children: [
170
+ endContent,
171
+ showClearButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ClearButton, { onClear: handleClear })
172
+ ] }),
64
173
  items,
65
174
  selectedKeys,
66
175
  selectionMode,
176
+ variant,
67
177
  onSelectionChange: handleSelectionChange,
68
178
  ...props,
69
- children: (item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectItem, { children: item.label }, item.key)
179
+ children: (item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_select.SelectItem, { children: item.label }, item.key)
70
180
  }
71
181
  );
72
182
  }
@@ -1,7 +1,9 @@
1
1
  "use client";
2
2
  import {
3
3
  Select
4
- } from "../../../chunk-3YOW5DEZ.mjs";
4
+ } from "../../../chunk-VXYV37IM.mjs";
5
+ import "../../../chunk-2UHA3DYG.mjs";
6
+ import "../../../chunk-TUIN5YJW.mjs";
5
7
  export {
6
8
  Select
7
9
  };
@@ -0,0 +1,17 @@
1
+ interface UseSelectProps {
2
+ value?: string | string[];
3
+ defaultSelectedKeys?: "all" | Iterable<React.Key>;
4
+ onChange?: ((value: string | null) => void) | ((value: string[]) => void);
5
+ onClear?: () => void;
6
+ selectionMode?: "single" | "multiple";
7
+ isClearable?: boolean;
8
+ }
9
+ export declare function useSelect({ value, onChange, onClear, selectionMode, isClearable, }: UseSelectProps): {
10
+ currentValue: string | string[] | null;
11
+ hasValue: boolean;
12
+ selectedKeys: Set<string>;
13
+ handleSelectionChange: (keys: "all" | Set<React.Key>) => void;
14
+ handleClear: () => void;
15
+ showClearButton: boolean;
16
+ };
17
+ export {};
@@ -0,0 +1,85 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/ui/inputs/select/use-select.ts
22
+ var use_select_exports = {};
23
+ __export(use_select_exports, {
24
+ useSelect: () => useSelect
25
+ });
26
+ module.exports = __toCommonJS(use_select_exports);
27
+ var import_react = require("react");
28
+ function useSelect({
29
+ value,
30
+ onChange,
31
+ onClear,
32
+ selectionMode,
33
+ isClearable = true
34
+ }) {
35
+ const isMultiple = selectionMode === "multiple";
36
+ const [internalValue, setInternalValue] = (0, import_react.useState)(
37
+ isMultiple ? [] : null
38
+ );
39
+ const isControlled = value !== void 0;
40
+ const currentValue = isControlled ? value : internalValue;
41
+ const hasValue = currentValue != null && (Array.isArray(currentValue) ? currentValue.length > 0 : currentValue !== "");
42
+ const handleChange = (0, import_react.useCallback)(
43
+ (newValue) => {
44
+ if (!isControlled) {
45
+ setInternalValue(newValue);
46
+ }
47
+ if (isMultiple) {
48
+ onChange == null ? void 0 : onChange(newValue);
49
+ } else {
50
+ onChange == null ? void 0 : onChange(newValue);
51
+ }
52
+ },
53
+ [isControlled, onChange, isMultiple]
54
+ );
55
+ const handleClear = (0, import_react.useCallback)(() => {
56
+ onClear == null ? void 0 : onClear();
57
+ handleChange(isMultiple ? [] : null);
58
+ }, [onClear, handleChange, isMultiple]);
59
+ const selectedKeys = (0, import_react.useMemo)(() => {
60
+ if (currentValue == null) return /* @__PURE__ */ new Set();
61
+ return new Set(Array.isArray(currentValue) ? currentValue : [currentValue]);
62
+ }, [currentValue]);
63
+ const handleSelectionChange = (0, import_react.useCallback)(
64
+ (keys) => {
65
+ var _a;
66
+ if (keys === "all") return;
67
+ const selected = Array.from(keys).filter((key) => typeof key === "string");
68
+ handleChange(isMultiple ? selected : (_a = selected[0]) != null ? _a : null);
69
+ },
70
+ [handleChange, isMultiple]
71
+ );
72
+ const showClearButton = hasValue && isClearable;
73
+ return {
74
+ currentValue,
75
+ hasValue,
76
+ selectedKeys,
77
+ handleSelectionChange,
78
+ handleClear,
79
+ showClearButton
80
+ };
81
+ }
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ useSelect
85
+ });
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import {
3
+ useSelect
4
+ } from "../../../chunk-2UHA3DYG.mjs";
5
+ export {
6
+ useSelect
7
+ };
@@ -1,6 +1,27 @@
1
+ import type { VariantProps } from "tailwind-variants";
1
2
  import React from "react";
2
- export interface Props {
3
+ declare const wrapperVariants: import("tailwind-variants").TVReturnType<{
4
+ size: {
5
+ sm: string;
6
+ md: string;
7
+ lg: string;
8
+ };
9
+ }, undefined, "flex cursor-pointer items-center justify-center rounded-sm bg-transparent!", {
10
+ size: {
11
+ sm: string;
12
+ md: string;
13
+ lg: string;
14
+ };
15
+ }, undefined, import("tailwind-variants").TVReturnType<{
16
+ size: {
17
+ sm: string;
18
+ md: string;
19
+ lg: string;
20
+ };
21
+ }, undefined, "flex cursor-pointer items-center justify-center rounded-sm bg-transparent!", unknown, unknown, undefined>>;
22
+ export interface Props extends VariantProps<typeof wrapperVariants> {
3
23
  isSelected: boolean;
4
24
  onValueChange?: (isSelected: boolean) => void;
5
25
  }
6
- export declare function FavoriteSwitch({ isSelected, onValueChange }: Props): React.JSX.Element;
26
+ export declare function FavoriteSwitch({ isSelected, onValueChange, size }: Props): React.JSX.Element;
27
+ export {};
@@ -30,14 +30,35 @@ var import_lucide_react = require("lucide-react");
30
30
  var import_tailwind_variants = require("tailwind-variants");
31
31
  var import_jsx_runtime = require("react/jsx-runtime");
32
32
  var bookmarkVariants = (0, import_tailwind_variants.tv)({
33
- base: "size-6 stroke-default-400 group-hover:fill-primary-100 group-hover:stroke-default-400",
33
+ base: "stroke-default-400 group-hover:fill-primary-100 group-hover:stroke-default-400",
34
34
  variants: {
35
+ size: {
36
+ sm: "size-6",
37
+ md: "size-8",
38
+ lg: "size-10"
39
+ },
35
40
  isSelected: {
36
41
  true: "stroke-primary fill-primary-100"
37
42
  }
43
+ },
44
+ defaultVariants: {
45
+ size: "md"
38
46
  }
39
47
  });
40
- function FavoriteSwitch({ isSelected, onValueChange }) {
48
+ var wrapperVariants = (0, import_tailwind_variants.tv)({
49
+ base: "flex cursor-pointer items-center justify-center rounded-sm bg-transparent!",
50
+ variants: {
51
+ size: {
52
+ sm: "h-8 w-8",
53
+ md: "h-10 w-10",
54
+ lg: "h-12 w-12"
55
+ }
56
+ },
57
+ defaultVariants: {
58
+ size: "md"
59
+ }
60
+ });
61
+ function FavoriteSwitch({ isSelected, onValueChange, size }) {
41
62
  const { Component, slots, getBaseProps, getInputProps, getWrapperProps } = (0, import_switch.useSwitch)({
42
63
  isSelected,
43
64
  onValueChange
@@ -49,9 +70,18 @@ function FavoriteSwitch({ isSelected, onValueChange }) {
49
70
  {
50
71
  ...getWrapperProps(),
51
72
  className: slots.wrapper({
52
- class: "flex h-8 w-8 cursor-pointer items-center justify-center rounded-sm !bg-transparent"
73
+ class: wrapperVariants({ size })
53
74
  }),
54
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Bookmark, { className: bookmarkVariants({ isSelected }) })
75
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
76
+ import_lucide_react.BookmarkIcon,
77
+ {
78
+ absoluteStrokeWidth: true,
79
+ className: bookmarkVariants({ isSelected, size }),
80
+ strokeLinecap: "round",
81
+ strokeLinejoin: "round",
82
+ strokeWidth: 1.5
83
+ }
84
+ )
55
85
  }
56
86
  )
57
87
  ] });
@@ -2,7 +2,7 @@
2
2
  "use client";
3
3
  import {
4
4
  FavoriteSwitch
5
- } from "../../../chunk-E5QSNLSR.mjs";
5
+ } from "../../../chunk-GTE5VEBV.mjs";
6
6
  export {
7
7
  FavoriteSwitch
8
8
  };
@@ -51,14 +51,35 @@ var import_lucide_react = require("lucide-react");
51
51
  var import_tailwind_variants = require("tailwind-variants");
52
52
  var import_jsx_runtime2 = require("react/jsx-runtime");
53
53
  var bookmarkVariants = (0, import_tailwind_variants.tv)({
54
- base: "size-6 stroke-default-400 group-hover:fill-primary-100 group-hover:stroke-default-400",
54
+ base: "stroke-default-400 group-hover:fill-primary-100 group-hover:stroke-default-400",
55
55
  variants: {
56
+ size: {
57
+ sm: "size-6",
58
+ md: "size-8",
59
+ lg: "size-10"
60
+ },
56
61
  isSelected: {
57
62
  true: "stroke-primary fill-primary-100"
58
63
  }
64
+ },
65
+ defaultVariants: {
66
+ size: "md"
59
67
  }
60
68
  });
61
- function FavoriteSwitch({ isSelected, onValueChange }) {
69
+ var wrapperVariants = (0, import_tailwind_variants.tv)({
70
+ base: "flex cursor-pointer items-center justify-center rounded-sm bg-transparent!",
71
+ variants: {
72
+ size: {
73
+ sm: "h-8 w-8",
74
+ md: "h-10 w-10",
75
+ lg: "h-12 w-12"
76
+ }
77
+ },
78
+ defaultVariants: {
79
+ size: "md"
80
+ }
81
+ });
82
+ function FavoriteSwitch({ isSelected, onValueChange, size }) {
62
83
  const { Component, slots, getBaseProps, getInputProps, getWrapperProps } = (0, import_switch2.useSwitch)({
63
84
  isSelected,
64
85
  onValueChange
@@ -70,9 +91,18 @@ function FavoriteSwitch({ isSelected, onValueChange }) {
70
91
  {
71
92
  ...getWrapperProps(),
72
93
  className: slots.wrapper({
73
- class: "flex h-8 w-8 cursor-pointer items-center justify-center rounded-sm !bg-transparent"
94
+ class: wrapperVariants({ size })
74
95
  }),
75
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Bookmark, { className: bookmarkVariants({ isSelected }) })
96
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
97
+ import_lucide_react.BookmarkIcon,
98
+ {
99
+ absoluteStrokeWidth: true,
100
+ className: bookmarkVariants({ isSelected, size }),
101
+ strokeLinecap: "round",
102
+ strokeLinejoin: "round",
103
+ strokeWidth: 1.5
104
+ }
105
+ )
76
106
  }
77
107
  )
78
108
  ] });
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import "../../../chunk-LLP2PTPK.mjs";
3
- import {
4
- FavoriteSwitch
5
- } from "../../../chunk-E5QSNLSR.mjs";
6
3
  import {
7
4
  Switch
8
5
  } from "../../../chunk-N3EAW6UO.mjs";
6
+ import {
7
+ FavoriteSwitch
8
+ } from "../../../chunk-GTE5VEBV.mjs";
9
9
  export {
10
10
  FavoriteSwitch,
11
11
  Switch