@teach-in/react 1.1.0 → 1.2.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.
- package/LICENSE +21 -21
- package/README.md +9 -9
- package/dist/{chunk-AMNORHD6.mjs → chunk-2ASQXBDD.mjs} +1 -1
- package/dist/{chunk-3VAZY2QK.mjs → chunk-2CEZXLZR.mjs} +1 -1
- package/dist/chunk-2UHA3DYG.mjs +62 -0
- package/dist/{chunk-LJIVY6GU.mjs → chunk-46SKVFMZ.mjs} +1 -1
- package/dist/{chunk-JDFRAN4S.mjs → chunk-5FFWQB7D.mjs} +12 -2
- package/dist/chunk-C2VWADF5.mjs +34 -0
- package/dist/{chunk-NLHQDWUK.mjs → chunk-CKJ5U5Q4.mjs} +1 -1
- package/dist/chunk-CUEG2BFV.mjs +34 -0
- package/dist/{chunk-CETCW7DS.mjs → chunk-IU2JYI7W.mjs} +1 -1
- package/dist/{chunk-KTUGFQWJ.mjs → chunk-KTWHCUYV.mjs} +1 -1
- package/dist/chunk-MCQGBAUS.mjs +73 -0
- package/dist/chunk-NSU66J5E.mjs +59 -0
- package/dist/{chunk-CFG5V7VB.mjs → chunk-QCLLPJMB.mjs} +2 -2
- package/dist/{chunk-R7LDL5CU.mjs → chunk-R46SWVWL.mjs} +1 -1
- package/dist/chunk-SEJXJZSK.mjs +64 -0
- package/dist/chunk-TUIN5YJW.mjs +33 -0
- package/dist/chunk-UQAG7TKJ.mjs +1 -0
- package/dist/chunk-VXYV37IM.mjs +74 -0
- package/dist/index.js +575 -230
- package/dist/index.mjs +163 -147
- package/dist/ui/data/index.mjs +4 -4
- package/dist/ui/feedback/index.mjs +5 -5
- package/dist/ui/form/index.js +447 -106
- package/dist/ui/form/index.mjs +31 -21
- package/dist/ui/form/rhf/fields/autocomplete-field.mjs +20 -14
- package/dist/ui/form/rhf/fields/checkbox-field.mjs +20 -14
- package/dist/ui/form/rhf/fields/date-picker-field.mjs +20 -14
- package/dist/ui/form/rhf/fields/email-field.js +147 -10
- package/dist/ui/form/rhf/fields/email-field.mjs +21 -15
- package/dist/ui/form/rhf/fields/index.d.ts +1 -0
- package/dist/ui/form/rhf/fields/index.js +443 -102
- package/dist/ui/form/rhf/fields/index.mjs +31 -21
- package/dist/ui/form/rhf/fields/input-field.js +153 -6
- package/dist/ui/form/rhf/fields/input-field.mjs +21 -15
- package/dist/ui/form/rhf/fields/radio-field.mjs +20 -14
- package/dist/ui/form/rhf/fields/search-field.d.ts +10 -0
- package/dist/ui/form/rhf/fields/search-field.js +296 -0
- package/dist/ui/form/rhf/fields/search-field.mjs +37 -0
- package/dist/ui/form/rhf/fields/select-field.js +136 -26
- package/dist/ui/form/rhf/fields/select-field.mjs +21 -15
- package/dist/ui/form/rhf/fields/switch-field.mjs +20 -14
- package/dist/ui/form/rhf/fields/text-field.js +147 -10
- package/dist/ui/form/rhf/fields/text-field.mjs +21 -15
- package/dist/ui/form/rhf/fields/textarea-field.mjs +20 -14
- package/dist/ui/form/rhf/index.js +443 -102
- package/dist/ui/form/rhf/index.mjs +31 -21
- package/dist/ui/format/index.mjs +15 -15
- package/dist/ui/index.js +575 -230
- package/dist/ui/index.mjs +161 -145
- package/dist/ui/inputs/checkbox/index.mjs +3 -3
- package/dist/ui/inputs/clear-button.d.ts +5 -0
- package/dist/ui/inputs/clear-button.js +67 -0
- package/dist/ui/inputs/clear-button.mjs +8 -0
- package/dist/ui/inputs/email/email.js +144 -7
- package/dist/ui/inputs/email/email.mjs +4 -2
- package/dist/ui/inputs/email/index.js +144 -7
- package/dist/ui/inputs/email/index.mjs +4 -2
- package/dist/ui/inputs/index.d.ts +2 -0
- package/dist/ui/inputs/index.js +363 -56
- package/dist/ui/inputs/index.mjs +35 -23
- package/dist/ui/inputs/input/index.js +140 -3
- package/dist/ui/inputs/input/index.mjs +3 -1
- package/dist/ui/inputs/input/input.d.ts +1 -0
- package/dist/ui/inputs/input/input.js +140 -3
- package/dist/ui/inputs/input/input.mjs +3 -1
- package/dist/ui/inputs/input/use-input.d.ts +19 -0
- package/dist/ui/inputs/input/use-input.js +82 -0
- package/dist/ui/inputs/input/use-input.mjs +7 -0
- package/dist/ui/inputs/radio/index.mjs +3 -3
- package/dist/ui/inputs/search/index.d.ts +1 -0
- package/dist/ui/inputs/search/index.js +270 -0
- package/dist/ui/inputs/search/index.mjs +13 -0
- package/dist/ui/inputs/search/search.d.ts +7 -0
- package/dist/ui/inputs/search/search.js +268 -0
- package/dist/ui/inputs/search/search.mjs +12 -0
- package/dist/ui/inputs/search/use-search.d.ts +12 -0
- package/dist/ui/inputs/search/use-search.js +57 -0
- package/dist/ui/inputs/search/use-search.mjs +7 -0
- package/dist/ui/inputs/select/index.js +132 -22
- package/dist/ui/inputs/select/index.mjs +3 -1
- package/dist/ui/inputs/select/select.d.ts +4 -0
- package/dist/ui/inputs/select/select.js +132 -22
- package/dist/ui/inputs/select/select.mjs +3 -1
- package/dist/ui/inputs/select/use-select.d.ts +17 -0
- package/dist/ui/inputs/select/use-select.js +85 -0
- package/dist/ui/inputs/select/use-select.mjs +7 -0
- package/dist/ui/inputs/text/index.js +144 -7
- package/dist/ui/inputs/text/index.mjs +4 -2
- package/dist/ui/inputs/text/text.js +144 -7
- package/dist/ui/inputs/text/text.mjs +4 -2
- package/dist/ui/layout/container/container.mjs +81 -74
- package/dist/ui/layout/container/index.mjs +81 -74
- package/dist/ui/layout/index.mjs +84 -77
- package/dist/ui/layout/page/index.mjs +4 -4
- package/dist/ui/layout/page/page-loading.mjs +3 -3
- package/dist/ui/layout/page/section-loading.mjs +3 -3
- package/dist/ui/navigation/index.mjs +11 -11
- package/dist/ui/overlays/index.mjs +5 -5
- package/dist/ui/provider/index.mjs +3 -3
- package/dist/ui/provider/ui-provider.mjs +3 -3
- package/dist/ui/surface/index.mjs +3 -3
- package/dist/ui/theme/colors/common.mjs +5 -5
- package/dist/ui/theme/colors/index.mjs +7 -7
- package/dist/ui/theme/colors/semantic.mjs +6 -6
- package/dist/ui/theme/colors.mjs +7 -7
- package/dist/ui/theme/index.mjs +8 -8
- package/dist/ui/theme/theme.mjs +8 -8
- package/package.json +1 -1
- package/dist/chunk-3YOW5DEZ.mjs +0 -45
- package/dist/chunk-V2G5QHZZ.mjs +0 -14
- package/dist/{chunk-CZEO3U25.mjs → chunk-5RNCFTW5.mjs} +0 -0
- package/dist/{chunk-STVN4B47.mjs → chunk-IXPMUODA.mjs} +12 -12
- /package/dist/{chunk-Q6JSJOU4.mjs → chunk-PTCNYQVY.mjs} +0 -0
package/dist/ui/inputs/index.js
CHANGED
|
@@ -34,12 +34,14 @@ __export(inputs_exports, {
|
|
|
34
34
|
Autocomplete: () => Autocomplete,
|
|
35
35
|
Checkbox: () => Checkbox,
|
|
36
36
|
CheckboxGroup: () => CheckboxGroup,
|
|
37
|
+
ClearButton: () => ClearButton,
|
|
37
38
|
DatePicker: () => DatePicker,
|
|
38
39
|
Email: () => Email,
|
|
39
40
|
FavoriteSwitch: () => FavoriteSwitch,
|
|
40
41
|
Input: () => Input,
|
|
41
42
|
Radio: () => Radio,
|
|
42
43
|
RadioGroup: () => RadioGroup,
|
|
44
|
+
Search: () => Search,
|
|
43
45
|
Select: () => Select,
|
|
44
46
|
Switch: () => Switch,
|
|
45
47
|
Text: () => Text,
|
|
@@ -89,58 +91,361 @@ var DatePicker = import_react4.default.forwardRef(
|
|
|
89
91
|
DatePicker.displayName = "TeachInUI.DatePicker";
|
|
90
92
|
|
|
91
93
|
// src/ui/inputs/email/email.tsx
|
|
92
|
-
var
|
|
94
|
+
var import_react8 = __toESM(require("react"));
|
|
93
95
|
|
|
94
96
|
// src/ui/inputs/input/input.tsx
|
|
95
|
-
var
|
|
97
|
+
var import_react7 = __toESM(require("react"));
|
|
96
98
|
var import_input = require("@heroui/input");
|
|
99
|
+
var import_tailwind_variants = require("tailwind-variants");
|
|
100
|
+
|
|
101
|
+
// src/ui/inputs/clear-button.tsx
|
|
102
|
+
var import_react5 = __toESM(require("react"));
|
|
103
|
+
var import_button = require("@heroui/button");
|
|
104
|
+
var import_lucide_react = require("lucide-react");
|
|
97
105
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
98
|
-
var
|
|
99
|
-
|
|
106
|
+
var ClearButton = import_react5.default.forwardRef(
|
|
107
|
+
({ onClear }, ref) => {
|
|
108
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
109
|
+
import_button.Button,
|
|
110
|
+
{
|
|
111
|
+
ref,
|
|
112
|
+
isIconOnly: true,
|
|
113
|
+
"aria-label": "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C",
|
|
114
|
+
as: "span",
|
|
115
|
+
className: "opacity-0 transition-opacity group-hover:opacity-100",
|
|
116
|
+
color: "default",
|
|
117
|
+
radius: "full",
|
|
118
|
+
size: "sm",
|
|
119
|
+
tabIndex: 0,
|
|
120
|
+
variant: "light",
|
|
121
|
+
onPress: onClear,
|
|
122
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react.XIcon, { className: "size-4 text-default-500" })
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
ClearButton.displayName = "TeachInUI.ClearButton";
|
|
128
|
+
|
|
129
|
+
// src/ui/inputs/input/use-input.ts
|
|
130
|
+
var import_react6 = require("react");
|
|
131
|
+
function useInput({
|
|
132
|
+
value,
|
|
133
|
+
defaultValue,
|
|
134
|
+
onValueChange,
|
|
135
|
+
onClear,
|
|
136
|
+
isReadOnly,
|
|
137
|
+
isClearable = true,
|
|
138
|
+
ref
|
|
139
|
+
}) {
|
|
140
|
+
const inputRef = (0, import_react6.useRef)(null);
|
|
141
|
+
const [internalValue, setInternalValue] = (0, import_react6.useState)(defaultValue != null ? defaultValue : "");
|
|
142
|
+
const isControlled = value !== void 0;
|
|
143
|
+
const currentValue = isControlled ? value : internalValue;
|
|
144
|
+
const hasValue = String(currentValue).length > 0;
|
|
145
|
+
const handleValueChange = (0, import_react6.useCallback)(
|
|
146
|
+
(newValue) => {
|
|
147
|
+
if (!isControlled) {
|
|
148
|
+
setInternalValue(newValue);
|
|
149
|
+
}
|
|
150
|
+
onValueChange == null ? void 0 : onValueChange(newValue);
|
|
151
|
+
},
|
|
152
|
+
[isControlled, onValueChange]
|
|
153
|
+
);
|
|
154
|
+
const handleClear = (0, import_react6.useCallback)(() => {
|
|
155
|
+
var _a;
|
|
156
|
+
onClear == null ? void 0 : onClear();
|
|
157
|
+
handleValueChange("");
|
|
158
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
159
|
+
}, [onClear, handleValueChange]);
|
|
160
|
+
const mergedRef = (0, import_react6.useCallback)(
|
|
161
|
+
(node) => {
|
|
162
|
+
inputRef.current = node;
|
|
163
|
+
if (typeof ref === "function") {
|
|
164
|
+
ref(node);
|
|
165
|
+
} else if (ref) {
|
|
166
|
+
ref.current = node;
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
[ref]
|
|
170
|
+
);
|
|
171
|
+
const showClearButton = hasValue && !isReadOnly && isClearable;
|
|
172
|
+
return {
|
|
173
|
+
inputRef,
|
|
174
|
+
currentValue,
|
|
175
|
+
hasValue,
|
|
176
|
+
handleValueChange,
|
|
177
|
+
handleClear,
|
|
178
|
+
mergedRef,
|
|
179
|
+
showClearButton
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// src/ui/inputs/input/input.tsx
|
|
184
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
185
|
+
var inputWrapperVariants = (0, import_tailwind_variants.tv)({
|
|
186
|
+
variants: {
|
|
187
|
+
variant: {
|
|
188
|
+
flat: "",
|
|
189
|
+
underlined: "",
|
|
190
|
+
bordered: "border-1",
|
|
191
|
+
faded: "border-1"
|
|
192
|
+
}
|
|
193
|
+
}
|
|
100
194
|
});
|
|
195
|
+
var Input = import_react7.default.forwardRef(
|
|
196
|
+
({
|
|
197
|
+
value,
|
|
198
|
+
defaultValue,
|
|
199
|
+
onClear,
|
|
200
|
+
onValueChange,
|
|
201
|
+
variant,
|
|
202
|
+
classNames,
|
|
203
|
+
endContent,
|
|
204
|
+
isReadOnly,
|
|
205
|
+
isClearable,
|
|
206
|
+
...props
|
|
207
|
+
}, ref) => {
|
|
208
|
+
const { currentValue, handleValueChange, handleClear, mergedRef, showClearButton } = useInput({
|
|
209
|
+
value,
|
|
210
|
+
defaultValue,
|
|
211
|
+
onValueChange,
|
|
212
|
+
onClear,
|
|
213
|
+
isReadOnly,
|
|
214
|
+
isClearable,
|
|
215
|
+
ref
|
|
216
|
+
});
|
|
217
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
218
|
+
import_input.Input,
|
|
219
|
+
{
|
|
220
|
+
ref: mergedRef,
|
|
221
|
+
classNames: {
|
|
222
|
+
...classNames,
|
|
223
|
+
inputWrapper: inputWrapperVariants({ variant }),
|
|
224
|
+
innerWrapper: "group"
|
|
225
|
+
},
|
|
226
|
+
defaultValue,
|
|
227
|
+
endContent: (endContent || showClearButton) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
228
|
+
endContent,
|
|
229
|
+
showClearButton && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ClearButton, { onClear: handleClear })
|
|
230
|
+
] }),
|
|
231
|
+
isReadOnly,
|
|
232
|
+
value: currentValue,
|
|
233
|
+
variant,
|
|
234
|
+
onValueChange: handleValueChange,
|
|
235
|
+
...props
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
);
|
|
101
240
|
Input.displayName = "TeachInUI.Input";
|
|
102
241
|
|
|
103
242
|
// src/ui/inputs/email/email.tsx
|
|
104
|
-
var
|
|
105
|
-
var Email =
|
|
106
|
-
return /* @__PURE__ */ (0,
|
|
243
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
244
|
+
var Email = import_react8.default.forwardRef(({ ...props }, ref) => {
|
|
245
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Input, { ref, autoComplete: "email", type: "email", ...props });
|
|
107
246
|
});
|
|
108
247
|
Email.displayName = "TeachInUI.Email";
|
|
109
248
|
|
|
249
|
+
// src/ui/inputs/search/search.tsx
|
|
250
|
+
var import_react10 = __toESM(require("react"));
|
|
251
|
+
var import_lucide_react2 = require("lucide-react");
|
|
252
|
+
var import_button2 = require("@heroui/button");
|
|
253
|
+
var import_tailwind_variants2 = require("tailwind-variants");
|
|
254
|
+
|
|
255
|
+
// src/ui/inputs/search/use-search.ts
|
|
256
|
+
var import_react9 = require("react");
|
|
257
|
+
function useSearch({ value, onSearch, onCancel, onKeyDown }) {
|
|
258
|
+
const handleKeyDown = (0, import_react9.useCallback)(
|
|
259
|
+
(event) => {
|
|
260
|
+
if (event.key === "Enter") {
|
|
261
|
+
event.preventDefault();
|
|
262
|
+
onSearch == null ? void 0 : onSearch(event.target.value);
|
|
263
|
+
} else if (event.key === "Escape") {
|
|
264
|
+
event.preventDefault();
|
|
265
|
+
onCancel == null ? void 0 : onCancel();
|
|
266
|
+
}
|
|
267
|
+
onKeyDown == null ? void 0 : onKeyDown(event);
|
|
268
|
+
},
|
|
269
|
+
[onSearch, onCancel, onKeyDown]
|
|
270
|
+
);
|
|
271
|
+
const hasValue = value !== void 0 && String(value).length > 0;
|
|
272
|
+
const handleSearchClick = (0, import_react9.useCallback)(() => {
|
|
273
|
+
if (hasValue) {
|
|
274
|
+
onSearch == null ? void 0 : onSearch(value);
|
|
275
|
+
}
|
|
276
|
+
}, [value, onSearch]);
|
|
277
|
+
return {
|
|
278
|
+
handleKeyDown,
|
|
279
|
+
handleSearchClick,
|
|
280
|
+
hasValue
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// src/ui/inputs/search/search.tsx
|
|
285
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
286
|
+
var searchIconVariants = (0, import_tailwind_variants2.tv)({
|
|
287
|
+
base: "size-5 shrink-0",
|
|
288
|
+
variants: {
|
|
289
|
+
variant: {
|
|
290
|
+
faded: "text-default-400",
|
|
291
|
+
flat: "text-default-foreground",
|
|
292
|
+
bordered: "text-default-400",
|
|
293
|
+
underlined: "text-default-foreground"
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
var Search = import_react10.default.forwardRef(
|
|
298
|
+
({ variant = "bordered", radius = "full", value, onSearch, onCancel, onKeyDown, ...props }, ref) => {
|
|
299
|
+
const { handleKeyDown, handleSearchClick, hasValue } = useSearch({
|
|
300
|
+
value,
|
|
301
|
+
onSearch,
|
|
302
|
+
onCancel,
|
|
303
|
+
onKeyDown
|
|
304
|
+
});
|
|
305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
306
|
+
Input,
|
|
307
|
+
{
|
|
308
|
+
ref,
|
|
309
|
+
radius,
|
|
310
|
+
startContent: onSearch ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
311
|
+
import_button2.Button,
|
|
312
|
+
{
|
|
313
|
+
isIconOnly: true,
|
|
314
|
+
"aria-label": "\u041F\u043E\u0438\u0441\u043A",
|
|
315
|
+
isDisabled: !hasValue,
|
|
316
|
+
radius: "full",
|
|
317
|
+
size: "sm",
|
|
318
|
+
variant: "light",
|
|
319
|
+
onPress: handleSearchClick,
|
|
320
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.SearchIcon, { className: searchIconVariants({ variant }) })
|
|
321
|
+
}
|
|
322
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.SearchIcon, { className: searchIconVariants({ variant }) }),
|
|
323
|
+
value,
|
|
324
|
+
variant,
|
|
325
|
+
onKeyDown: handleKeyDown,
|
|
326
|
+
...props
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
Search.displayName = "TeachInUI.Search";
|
|
332
|
+
|
|
110
333
|
// src/ui/inputs/select/select.tsx
|
|
111
|
-
var
|
|
334
|
+
var import_react12 = __toESM(require("react"));
|
|
112
335
|
var import_select = require("@heroui/select");
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
336
|
+
var import_tailwind_variants3 = require("tailwind-variants");
|
|
337
|
+
|
|
338
|
+
// src/ui/inputs/select/use-select.ts
|
|
339
|
+
var import_react11 = require("react");
|
|
340
|
+
function useSelect({
|
|
341
|
+
value,
|
|
342
|
+
onChange,
|
|
343
|
+
onClear,
|
|
344
|
+
selectionMode,
|
|
345
|
+
isClearable = true
|
|
346
|
+
}) {
|
|
347
|
+
const isMultiple = selectionMode === "multiple";
|
|
348
|
+
const [internalValue, setInternalValue] = (0, import_react11.useState)(
|
|
349
|
+
isMultiple ? [] : null
|
|
350
|
+
);
|
|
351
|
+
const isControlled = value !== void 0;
|
|
352
|
+
const currentValue = isControlled ? value : internalValue;
|
|
353
|
+
const hasValue = currentValue != null && (Array.isArray(currentValue) ? currentValue.length > 0 : currentValue !== "");
|
|
354
|
+
const handleChange = (0, import_react11.useCallback)(
|
|
355
|
+
(newValue) => {
|
|
356
|
+
if (!isControlled) {
|
|
357
|
+
setInternalValue(newValue);
|
|
358
|
+
}
|
|
359
|
+
if (isMultiple) {
|
|
360
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
361
|
+
} else {
|
|
362
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
[isControlled, onChange, isMultiple]
|
|
366
|
+
);
|
|
367
|
+
const handleClear = (0, import_react11.useCallback)(() => {
|
|
368
|
+
onClear == null ? void 0 : onClear();
|
|
369
|
+
handleChange(isMultiple ? [] : null);
|
|
370
|
+
}, [onClear, handleChange, isMultiple]);
|
|
371
|
+
const selectedKeys = (0, import_react11.useMemo)(() => {
|
|
372
|
+
if (currentValue == null) return /* @__PURE__ */ new Set();
|
|
373
|
+
return new Set(Array.isArray(currentValue) ? currentValue : [currentValue]);
|
|
374
|
+
}, [currentValue]);
|
|
375
|
+
const handleSelectionChange = (0, import_react11.useCallback)(
|
|
376
|
+
(keys) => {
|
|
377
|
+
var _a;
|
|
378
|
+
if (keys === "all") return;
|
|
379
|
+
const selected = Array.from(keys).filter((key) => typeof key === "string");
|
|
380
|
+
handleChange(isMultiple ? selected : (_a = selected[0]) != null ? _a : null);
|
|
381
|
+
},
|
|
382
|
+
[handleChange, isMultiple]
|
|
383
|
+
);
|
|
384
|
+
const showClearButton = hasValue && isClearable;
|
|
385
|
+
return {
|
|
386
|
+
currentValue,
|
|
387
|
+
hasValue,
|
|
388
|
+
selectedKeys,
|
|
389
|
+
handleSelectionChange,
|
|
390
|
+
handleClear,
|
|
391
|
+
showClearButton
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// src/ui/inputs/select/select.tsx
|
|
396
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
397
|
+
var selectWrapperVariants = (0, import_tailwind_variants3.tv)({
|
|
398
|
+
variants: {
|
|
399
|
+
variant: {
|
|
400
|
+
flat: "",
|
|
401
|
+
underlined: "",
|
|
402
|
+
bordered: "border-1",
|
|
403
|
+
faded: "border-1"
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
var Select = import_react12.default.forwardRef(
|
|
408
|
+
({
|
|
409
|
+
value,
|
|
410
|
+
defaultSelectedKeys,
|
|
411
|
+
items,
|
|
412
|
+
onChange,
|
|
413
|
+
selectionMode,
|
|
414
|
+
onClear,
|
|
415
|
+
variant,
|
|
416
|
+
classNames,
|
|
417
|
+
endContent,
|
|
418
|
+
isClearable,
|
|
419
|
+
...props
|
|
420
|
+
}, ref) => {
|
|
421
|
+
const { selectedKeys, handleSelectionChange, handleClear, showClearButton } = useSelect({
|
|
422
|
+
value,
|
|
423
|
+
onChange,
|
|
424
|
+
onClear,
|
|
425
|
+
selectionMode,
|
|
426
|
+
isClearable
|
|
427
|
+
});
|
|
428
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
135
429
|
import_select.Select,
|
|
136
430
|
{
|
|
137
431
|
ref,
|
|
432
|
+
classNames: {
|
|
433
|
+
...classNames,
|
|
434
|
+
trigger: selectWrapperVariants({ variant }),
|
|
435
|
+
innerWrapper: "group"
|
|
436
|
+
},
|
|
437
|
+
defaultSelectedKeys,
|
|
438
|
+
endContent: (endContent || showClearButton) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
439
|
+
endContent,
|
|
440
|
+
showClearButton && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ClearButton, { onClear: handleClear })
|
|
441
|
+
] }),
|
|
138
442
|
items,
|
|
139
443
|
selectedKeys,
|
|
140
444
|
selectionMode,
|
|
445
|
+
variant,
|
|
141
446
|
onSelectionChange: handleSelectionChange,
|
|
142
447
|
...props,
|
|
143
|
-
children: (item) => /* @__PURE__ */ (0,
|
|
448
|
+
children: (item) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_select.SelectItem, { children: item.label }, item.key)
|
|
144
449
|
}
|
|
145
450
|
);
|
|
146
451
|
}
|
|
@@ -148,20 +453,20 @@ var Select = import_react7.default.forwardRef(
|
|
|
148
453
|
Select.displayName = "TeachInUI.Select";
|
|
149
454
|
|
|
150
455
|
// src/ui/inputs/switch/switch.tsx
|
|
151
|
-
var
|
|
456
|
+
var import_react13 = __toESM(require("react"));
|
|
152
457
|
var import_switch = require("@heroui/switch");
|
|
153
|
-
var
|
|
154
|
-
var Switch =
|
|
155
|
-
return /* @__PURE__ */ (0,
|
|
458
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
459
|
+
var Switch = import_react13.default.forwardRef(({ ...props }, ref) => {
|
|
460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_switch.Switch, { ref, ...props });
|
|
156
461
|
});
|
|
157
462
|
Switch.displayName = "TeachInUI.Switch";
|
|
158
463
|
|
|
159
464
|
// src/ui/inputs/switch/favorite-switch.tsx
|
|
160
465
|
var import_switch2 = require("@heroui/switch");
|
|
161
|
-
var
|
|
162
|
-
var
|
|
163
|
-
var
|
|
164
|
-
var bookmarkVariants = (0,
|
|
466
|
+
var import_lucide_react3 = require("lucide-react");
|
|
467
|
+
var import_tailwind_variants4 = require("tailwind-variants");
|
|
468
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
469
|
+
var bookmarkVariants = (0, import_tailwind_variants4.tv)({
|
|
165
470
|
base: "size-6 stroke-default-400 group-hover:fill-primary-100 group-hover:stroke-default-400",
|
|
166
471
|
variants: {
|
|
167
472
|
isSelected: {
|
|
@@ -174,16 +479,16 @@ function FavoriteSwitch({ isSelected, onValueChange }) {
|
|
|
174
479
|
isSelected,
|
|
175
480
|
onValueChange
|
|
176
481
|
});
|
|
177
|
-
return /* @__PURE__ */ (0,
|
|
178
|
-
/* @__PURE__ */ (0,
|
|
179
|
-
/* @__PURE__ */ (0,
|
|
482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Component, { ...getBaseProps(), children: [
|
|
483
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "sr-only", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { ...getInputProps() }) }),
|
|
484
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
180
485
|
"div",
|
|
181
486
|
{
|
|
182
487
|
...getWrapperProps(),
|
|
183
488
|
className: slots.wrapper({
|
|
184
489
|
class: "flex h-8 w-8 cursor-pointer items-center justify-center rounded-sm !bg-transparent"
|
|
185
490
|
}),
|
|
186
|
-
children: /* @__PURE__ */ (0,
|
|
491
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.Bookmark, { className: bookmarkVariants({ isSelected }) })
|
|
187
492
|
}
|
|
188
493
|
)
|
|
189
494
|
] });
|
|
@@ -194,31 +499,31 @@ var import_radio = require("@heroui/radio");
|
|
|
194
499
|
var Radio = Object.assign(import_radio.Radio, { displayName: "TeachInUI.Radio" });
|
|
195
500
|
|
|
196
501
|
// src/ui/inputs/radio/radio-group.tsx
|
|
197
|
-
var
|
|
502
|
+
var import_react14 = __toESM(require("react"));
|
|
198
503
|
var import_radio2 = require("@heroui/radio");
|
|
199
|
-
var
|
|
200
|
-
var RadioGroup =
|
|
504
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
505
|
+
var RadioGroup = import_react14.default.forwardRef(
|
|
201
506
|
(props, ref) => {
|
|
202
|
-
return /* @__PURE__ */ (0,
|
|
507
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_radio2.RadioGroup, { ref, ...props });
|
|
203
508
|
}
|
|
204
509
|
);
|
|
205
510
|
RadioGroup.displayName = "TeachInUI.RadioGroup";
|
|
206
511
|
|
|
207
512
|
// src/ui/inputs/text/text.tsx
|
|
208
|
-
var
|
|
209
|
-
var
|
|
210
|
-
var Text =
|
|
211
|
-
return /* @__PURE__ */ (0,
|
|
513
|
+
var import_react15 = __toESM(require("react"));
|
|
514
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
515
|
+
var Text = import_react15.default.forwardRef(({ ...props }, ref) => {
|
|
516
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Input, { ref, type: "text", ...props });
|
|
212
517
|
});
|
|
213
518
|
Text.displayName = "TeachInUI.Text";
|
|
214
519
|
|
|
215
520
|
// src/ui/inputs/textarea/textarea.tsx
|
|
216
|
-
var
|
|
217
|
-
var
|
|
218
|
-
var
|
|
219
|
-
var Textarea =
|
|
521
|
+
var import_input6 = require("@heroui/input");
|
|
522
|
+
var import_react16 = __toESM(require("react"));
|
|
523
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
524
|
+
var Textarea = import_react16.default.forwardRef(
|
|
220
525
|
({ minRows = 4, ...props }, ref) => {
|
|
221
|
-
return /* @__PURE__ */ (0,
|
|
526
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_input6.Textarea, { ref, minRows, ...props });
|
|
222
527
|
}
|
|
223
528
|
);
|
|
224
529
|
Textarea.displayName = "TeachInUI.Textarea";
|
|
@@ -227,12 +532,14 @@ Textarea.displayName = "TeachInUI.Textarea";
|
|
|
227
532
|
Autocomplete,
|
|
228
533
|
Checkbox,
|
|
229
534
|
CheckboxGroup,
|
|
535
|
+
ClearButton,
|
|
230
536
|
DatePicker,
|
|
231
537
|
Email,
|
|
232
538
|
FavoriteSwitch,
|
|
233
539
|
Input,
|
|
234
540
|
Radio,
|
|
235
541
|
RadioGroup,
|
|
542
|
+
Search,
|
|
236
543
|
Select,
|
|
237
544
|
Switch,
|
|
238
545
|
Text,
|
package/dist/ui/inputs/index.mjs
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import "../../chunk-
|
|
2
|
+
import "../../chunk-UQAG7TKJ.mjs";
|
|
3
3
|
import "../../chunk-DUQFM3QS.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Text
|
|
6
|
-
} from "../../chunk-
|
|
7
|
-
import "../../chunk-5HK7HRTR.mjs";
|
|
8
|
-
import {
|
|
9
|
-
Textarea
|
|
10
|
-
} from "../../chunk-HJUZTISD.mjs";
|
|
11
|
-
import "../../chunk-V2HNFTTX.mjs";
|
|
12
|
-
import {
|
|
13
|
-
DatePicker
|
|
14
|
-
} from "../../chunk-IAJ6G633.mjs";
|
|
15
|
-
import "../../chunk-AQ3ISJKU.mjs";
|
|
16
|
-
import {
|
|
17
|
-
Select
|
|
18
|
-
} from "../../chunk-3YOW5DEZ.mjs";
|
|
6
|
+
} from "../../chunk-KTWHCUYV.mjs";
|
|
19
7
|
import "../../chunk-LLP2PTPK.mjs";
|
|
20
8
|
import {
|
|
21
9
|
FavoriteSwitch
|
|
@@ -23,25 +11,41 @@ import {
|
|
|
23
11
|
import {
|
|
24
12
|
Switch
|
|
25
13
|
} from "../../chunk-N3EAW6UO.mjs";
|
|
26
|
-
import "../../chunk-
|
|
14
|
+
import "../../chunk-5HK7HRTR.mjs";
|
|
27
15
|
import {
|
|
28
|
-
|
|
29
|
-
} from "../../chunk-
|
|
16
|
+
Textarea
|
|
17
|
+
} from "../../chunk-HJUZTISD.mjs";
|
|
30
18
|
import "../../chunk-V3KKDSQP.mjs";
|
|
31
19
|
import {
|
|
32
20
|
Email
|
|
33
|
-
} from "../../chunk-
|
|
34
|
-
import "../../chunk-
|
|
21
|
+
} from "../../chunk-46SKVFMZ.mjs";
|
|
22
|
+
import "../../chunk-AQ3ISJKU.mjs";
|
|
35
23
|
import {
|
|
36
|
-
|
|
37
|
-
} from "../../chunk-
|
|
24
|
+
Select
|
|
25
|
+
} from "../../chunk-VXYV37IM.mjs";
|
|
26
|
+
import "../../chunk-2UHA3DYG.mjs";
|
|
27
|
+
import "../../chunk-5RNCFTW5.mjs";
|
|
28
|
+
import {
|
|
29
|
+
Search
|
|
30
|
+
} from "../../chunk-SEJXJZSK.mjs";
|
|
31
|
+
import "../../chunk-C2VWADF5.mjs";
|
|
32
|
+
import "../../chunk-UUKS7JYX.mjs";
|
|
33
|
+
import "../../chunk-V2HNFTTX.mjs";
|
|
34
|
+
import {
|
|
35
|
+
DatePicker
|
|
36
|
+
} from "../../chunk-IAJ6G633.mjs";
|
|
38
37
|
import "../../chunk-RRA7GWP2.mjs";
|
|
38
|
+
import {
|
|
39
|
+
RadioGroup
|
|
40
|
+
} from "../../chunk-NOXFF2KJ.mjs";
|
|
39
41
|
import {
|
|
40
42
|
Radio
|
|
41
43
|
} from "../../chunk-2SNKT7I4.mjs";
|
|
44
|
+
import "../../chunk-ZRHEFEFS.mjs";
|
|
42
45
|
import {
|
|
43
|
-
|
|
44
|
-
} from "../../chunk-
|
|
46
|
+
Input
|
|
47
|
+
} from "../../chunk-MCQGBAUS.mjs";
|
|
48
|
+
import "../../chunk-NSU66J5E.mjs";
|
|
45
49
|
import "../../chunk-WYJW5NNA.mjs";
|
|
46
50
|
import {
|
|
47
51
|
Autocomplete
|
|
@@ -49,16 +53,24 @@ import {
|
|
|
49
53
|
import {
|
|
50
54
|
CheckboxGroup
|
|
51
55
|
} from "../../chunk-C4PCTOGM.mjs";
|
|
56
|
+
import {
|
|
57
|
+
Checkbox
|
|
58
|
+
} from "../../chunk-N3QOXWJI.mjs";
|
|
59
|
+
import {
|
|
60
|
+
ClearButton
|
|
61
|
+
} from "../../chunk-TUIN5YJW.mjs";
|
|
52
62
|
export {
|
|
53
63
|
Autocomplete,
|
|
54
64
|
Checkbox,
|
|
55
65
|
CheckboxGroup,
|
|
66
|
+
ClearButton,
|
|
56
67
|
DatePicker,
|
|
57
68
|
Email,
|
|
58
69
|
FavoriteSwitch,
|
|
59
70
|
Input,
|
|
60
71
|
Radio,
|
|
61
72
|
RadioGroup,
|
|
73
|
+
Search,
|
|
62
74
|
Select,
|
|
63
75
|
Switch,
|
|
64
76
|
Text,
|