@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
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/ui/inputs/search/index.ts
|
|
32
|
+
var search_exports = {};
|
|
33
|
+
__export(search_exports, {
|
|
34
|
+
Search: () => Search
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(search_exports);
|
|
37
|
+
|
|
38
|
+
// src/ui/inputs/search/search.tsx
|
|
39
|
+
var import_react5 = __toESM(require("react"));
|
|
40
|
+
var import_lucide_react2 = require("lucide-react");
|
|
41
|
+
var import_button2 = require("@heroui/button");
|
|
42
|
+
var import_tailwind_variants2 = require("tailwind-variants");
|
|
43
|
+
|
|
44
|
+
// src/ui/inputs/input/input.tsx
|
|
45
|
+
var import_react3 = __toESM(require("react"));
|
|
46
|
+
var import_input = require("@heroui/input");
|
|
47
|
+
var import_tailwind_variants = require("tailwind-variants");
|
|
48
|
+
|
|
49
|
+
// src/ui/inputs/clear-button.tsx
|
|
50
|
+
var import_react = __toESM(require("react"));
|
|
51
|
+
var import_button = require("@heroui/button");
|
|
52
|
+
var import_lucide_react = require("lucide-react");
|
|
53
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
54
|
+
var ClearButton = import_react.default.forwardRef(
|
|
55
|
+
({ onClear }, ref) => {
|
|
56
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
57
|
+
import_button.Button,
|
|
58
|
+
{
|
|
59
|
+
ref,
|
|
60
|
+
isIconOnly: true,
|
|
61
|
+
"aria-label": "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C",
|
|
62
|
+
as: "span",
|
|
63
|
+
className: "opacity-0 transition-opacity group-hover:opacity-100",
|
|
64
|
+
color: "default",
|
|
65
|
+
radius: "full",
|
|
66
|
+
size: "sm",
|
|
67
|
+
tabIndex: 0,
|
|
68
|
+
variant: "light",
|
|
69
|
+
onPress: onClear,
|
|
70
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.XIcon, { className: "size-4 text-default-500" })
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
ClearButton.displayName = "TeachInUI.ClearButton";
|
|
76
|
+
|
|
77
|
+
// src/ui/inputs/input/use-input.ts
|
|
78
|
+
var import_react2 = require("react");
|
|
79
|
+
function useInput({
|
|
80
|
+
value,
|
|
81
|
+
defaultValue,
|
|
82
|
+
onValueChange,
|
|
83
|
+
onClear,
|
|
84
|
+
isReadOnly,
|
|
85
|
+
isClearable = true,
|
|
86
|
+
ref
|
|
87
|
+
}) {
|
|
88
|
+
const inputRef = (0, import_react2.useRef)(null);
|
|
89
|
+
const [internalValue, setInternalValue] = (0, import_react2.useState)(defaultValue != null ? defaultValue : "");
|
|
90
|
+
const isControlled = value !== void 0;
|
|
91
|
+
const currentValue = isControlled ? value : internalValue;
|
|
92
|
+
const hasValue = String(currentValue).length > 0;
|
|
93
|
+
const handleValueChange = (0, import_react2.useCallback)(
|
|
94
|
+
(newValue) => {
|
|
95
|
+
if (!isControlled) {
|
|
96
|
+
setInternalValue(newValue);
|
|
97
|
+
}
|
|
98
|
+
onValueChange == null ? void 0 : onValueChange(newValue);
|
|
99
|
+
},
|
|
100
|
+
[isControlled, onValueChange]
|
|
101
|
+
);
|
|
102
|
+
const handleClear = (0, import_react2.useCallback)(() => {
|
|
103
|
+
var _a;
|
|
104
|
+
onClear == null ? void 0 : onClear();
|
|
105
|
+
handleValueChange("");
|
|
106
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
107
|
+
}, [onClear, handleValueChange]);
|
|
108
|
+
const mergedRef = (0, import_react2.useCallback)(
|
|
109
|
+
(node) => {
|
|
110
|
+
inputRef.current = node;
|
|
111
|
+
if (typeof ref === "function") {
|
|
112
|
+
ref(node);
|
|
113
|
+
} else if (ref) {
|
|
114
|
+
ref.current = node;
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
[ref]
|
|
118
|
+
);
|
|
119
|
+
const showClearButton = hasValue && !isReadOnly && isClearable;
|
|
120
|
+
return {
|
|
121
|
+
inputRef,
|
|
122
|
+
currentValue,
|
|
123
|
+
hasValue,
|
|
124
|
+
handleValueChange,
|
|
125
|
+
handleClear,
|
|
126
|
+
mergedRef,
|
|
127
|
+
showClearButton
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/ui/inputs/input/input.tsx
|
|
132
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
133
|
+
var inputWrapperVariants = (0, import_tailwind_variants.tv)({
|
|
134
|
+
variants: {
|
|
135
|
+
variant: {
|
|
136
|
+
flat: "",
|
|
137
|
+
underlined: "",
|
|
138
|
+
bordered: "border-1",
|
|
139
|
+
faded: "border-1"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
var Input = import_react3.default.forwardRef(
|
|
144
|
+
({
|
|
145
|
+
value,
|
|
146
|
+
defaultValue,
|
|
147
|
+
onClear,
|
|
148
|
+
onValueChange,
|
|
149
|
+
variant,
|
|
150
|
+
classNames,
|
|
151
|
+
endContent,
|
|
152
|
+
isReadOnly,
|
|
153
|
+
isClearable,
|
|
154
|
+
...props
|
|
155
|
+
}, ref) => {
|
|
156
|
+
const { currentValue, handleValueChange, handleClear, mergedRef, showClearButton } = useInput({
|
|
157
|
+
value,
|
|
158
|
+
defaultValue,
|
|
159
|
+
onValueChange,
|
|
160
|
+
onClear,
|
|
161
|
+
isReadOnly,
|
|
162
|
+
isClearable,
|
|
163
|
+
ref
|
|
164
|
+
});
|
|
165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
166
|
+
import_input.Input,
|
|
167
|
+
{
|
|
168
|
+
ref: mergedRef,
|
|
169
|
+
classNames: {
|
|
170
|
+
...classNames,
|
|
171
|
+
inputWrapper: inputWrapperVariants({ variant }),
|
|
172
|
+
innerWrapper: "group"
|
|
173
|
+
},
|
|
174
|
+
defaultValue,
|
|
175
|
+
endContent: (endContent || showClearButton) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
176
|
+
endContent,
|
|
177
|
+
showClearButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ClearButton, { onClear: handleClear })
|
|
178
|
+
] }),
|
|
179
|
+
isReadOnly,
|
|
180
|
+
value: currentValue,
|
|
181
|
+
variant,
|
|
182
|
+
onValueChange: handleValueChange,
|
|
183
|
+
...props
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
Input.displayName = "TeachInUI.Input";
|
|
189
|
+
|
|
190
|
+
// src/ui/inputs/search/use-search.ts
|
|
191
|
+
var import_react4 = require("react");
|
|
192
|
+
function useSearch({ value, onSearch, onCancel, onKeyDown }) {
|
|
193
|
+
const handleKeyDown = (0, import_react4.useCallback)(
|
|
194
|
+
(event) => {
|
|
195
|
+
if (event.key === "Enter") {
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
onSearch == null ? void 0 : onSearch(event.target.value);
|
|
198
|
+
} else if (event.key === "Escape") {
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
onCancel == null ? void 0 : onCancel();
|
|
201
|
+
}
|
|
202
|
+
onKeyDown == null ? void 0 : onKeyDown(event);
|
|
203
|
+
},
|
|
204
|
+
[onSearch, onCancel, onKeyDown]
|
|
205
|
+
);
|
|
206
|
+
const hasValue = value !== void 0 && String(value).length > 0;
|
|
207
|
+
const handleSearchClick = (0, import_react4.useCallback)(() => {
|
|
208
|
+
if (hasValue) {
|
|
209
|
+
onSearch == null ? void 0 : onSearch(value);
|
|
210
|
+
}
|
|
211
|
+
}, [value, onSearch]);
|
|
212
|
+
return {
|
|
213
|
+
handleKeyDown,
|
|
214
|
+
handleSearchClick,
|
|
215
|
+
hasValue
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// src/ui/inputs/search/search.tsx
|
|
220
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
221
|
+
var searchIconVariants = (0, import_tailwind_variants2.tv)({
|
|
222
|
+
base: "size-5 shrink-0",
|
|
223
|
+
variants: {
|
|
224
|
+
variant: {
|
|
225
|
+
faded: "text-default-400",
|
|
226
|
+
flat: "text-default-foreground",
|
|
227
|
+
bordered: "text-default-400",
|
|
228
|
+
underlined: "text-default-foreground"
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
var Search = import_react5.default.forwardRef(
|
|
233
|
+
({ variant = "bordered", radius = "full", value, onSearch, onCancel, onKeyDown, ...props }, ref) => {
|
|
234
|
+
const { handleKeyDown, handleSearchClick, hasValue } = useSearch({
|
|
235
|
+
value,
|
|
236
|
+
onSearch,
|
|
237
|
+
onCancel,
|
|
238
|
+
onKeyDown
|
|
239
|
+
});
|
|
240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
241
|
+
Input,
|
|
242
|
+
{
|
|
243
|
+
ref,
|
|
244
|
+
radius,
|
|
245
|
+
startContent: onSearch ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
246
|
+
import_button2.Button,
|
|
247
|
+
{
|
|
248
|
+
isIconOnly: true,
|
|
249
|
+
"aria-label": "\u041F\u043E\u0438\u0441\u043A",
|
|
250
|
+
isDisabled: !hasValue,
|
|
251
|
+
radius: "full",
|
|
252
|
+
size: "sm",
|
|
253
|
+
variant: "light",
|
|
254
|
+
onPress: handleSearchClick,
|
|
255
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.SearchIcon, { className: searchIconVariants({ variant }) })
|
|
256
|
+
}
|
|
257
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.SearchIcon, { className: searchIconVariants({ variant }) }),
|
|
258
|
+
value,
|
|
259
|
+
variant,
|
|
260
|
+
onKeyDown: handleKeyDown,
|
|
261
|
+
...props
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
);
|
|
266
|
+
Search.displayName = "TeachInUI.Search";
|
|
267
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
268
|
+
0 && (module.exports = {
|
|
269
|
+
Search
|
|
270
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-5RNCFTW5.mjs";
|
|
3
|
+
import {
|
|
4
|
+
Search
|
|
5
|
+
} from "../../../chunk-SEJXJZSK.mjs";
|
|
6
|
+
import "../../../chunk-C2VWADF5.mjs";
|
|
7
|
+
import "../../../chunk-ZRHEFEFS.mjs";
|
|
8
|
+
import "../../../chunk-MCQGBAUS.mjs";
|
|
9
|
+
import "../../../chunk-NSU66J5E.mjs";
|
|
10
|
+
import "../../../chunk-TUIN5YJW.mjs";
|
|
11
|
+
export {
|
|
12
|
+
Search
|
|
13
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InputProps } from "../input";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export interface SearchProps extends Omit<InputProps, "type" | "startContent"> {
|
|
4
|
+
onSearch?: (value: string) => void;
|
|
5
|
+
onCancel?: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const Search: React.ForwardRefExoticComponent<Omit<SearchProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/ui/inputs/search/search.tsx
|
|
32
|
+
var search_exports = {};
|
|
33
|
+
__export(search_exports, {
|
|
34
|
+
Search: () => Search
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(search_exports);
|
|
37
|
+
var import_react5 = __toESM(require("react"));
|
|
38
|
+
var import_lucide_react2 = require("lucide-react");
|
|
39
|
+
var import_button2 = require("@heroui/button");
|
|
40
|
+
var import_tailwind_variants2 = require("tailwind-variants");
|
|
41
|
+
|
|
42
|
+
// src/ui/inputs/input/input.tsx
|
|
43
|
+
var import_react3 = __toESM(require("react"));
|
|
44
|
+
var import_input = require("@heroui/input");
|
|
45
|
+
var import_tailwind_variants = require("tailwind-variants");
|
|
46
|
+
|
|
47
|
+
// src/ui/inputs/clear-button.tsx
|
|
48
|
+
var import_react = __toESM(require("react"));
|
|
49
|
+
var import_button = require("@heroui/button");
|
|
50
|
+
var import_lucide_react = require("lucide-react");
|
|
51
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
|
+
var ClearButton = import_react.default.forwardRef(
|
|
53
|
+
({ onClear }, ref) => {
|
|
54
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
55
|
+
import_button.Button,
|
|
56
|
+
{
|
|
57
|
+
ref,
|
|
58
|
+
isIconOnly: true,
|
|
59
|
+
"aria-label": "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C",
|
|
60
|
+
as: "span",
|
|
61
|
+
className: "opacity-0 transition-opacity group-hover:opacity-100",
|
|
62
|
+
color: "default",
|
|
63
|
+
radius: "full",
|
|
64
|
+
size: "sm",
|
|
65
|
+
tabIndex: 0,
|
|
66
|
+
variant: "light",
|
|
67
|
+
onPress: onClear,
|
|
68
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.XIcon, { className: "size-4 text-default-500" })
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
ClearButton.displayName = "TeachInUI.ClearButton";
|
|
74
|
+
|
|
75
|
+
// src/ui/inputs/input/use-input.ts
|
|
76
|
+
var import_react2 = require("react");
|
|
77
|
+
function useInput({
|
|
78
|
+
value,
|
|
79
|
+
defaultValue,
|
|
80
|
+
onValueChange,
|
|
81
|
+
onClear,
|
|
82
|
+
isReadOnly,
|
|
83
|
+
isClearable = true,
|
|
84
|
+
ref
|
|
85
|
+
}) {
|
|
86
|
+
const inputRef = (0, import_react2.useRef)(null);
|
|
87
|
+
const [internalValue, setInternalValue] = (0, import_react2.useState)(defaultValue != null ? defaultValue : "");
|
|
88
|
+
const isControlled = value !== void 0;
|
|
89
|
+
const currentValue = isControlled ? value : internalValue;
|
|
90
|
+
const hasValue = String(currentValue).length > 0;
|
|
91
|
+
const handleValueChange = (0, import_react2.useCallback)(
|
|
92
|
+
(newValue) => {
|
|
93
|
+
if (!isControlled) {
|
|
94
|
+
setInternalValue(newValue);
|
|
95
|
+
}
|
|
96
|
+
onValueChange == null ? void 0 : onValueChange(newValue);
|
|
97
|
+
},
|
|
98
|
+
[isControlled, onValueChange]
|
|
99
|
+
);
|
|
100
|
+
const handleClear = (0, import_react2.useCallback)(() => {
|
|
101
|
+
var _a;
|
|
102
|
+
onClear == null ? void 0 : onClear();
|
|
103
|
+
handleValueChange("");
|
|
104
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
105
|
+
}, [onClear, handleValueChange]);
|
|
106
|
+
const mergedRef = (0, import_react2.useCallback)(
|
|
107
|
+
(node) => {
|
|
108
|
+
inputRef.current = node;
|
|
109
|
+
if (typeof ref === "function") {
|
|
110
|
+
ref(node);
|
|
111
|
+
} else if (ref) {
|
|
112
|
+
ref.current = node;
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
[ref]
|
|
116
|
+
);
|
|
117
|
+
const showClearButton = hasValue && !isReadOnly && isClearable;
|
|
118
|
+
return {
|
|
119
|
+
inputRef,
|
|
120
|
+
currentValue,
|
|
121
|
+
hasValue,
|
|
122
|
+
handleValueChange,
|
|
123
|
+
handleClear,
|
|
124
|
+
mergedRef,
|
|
125
|
+
showClearButton
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// src/ui/inputs/input/input.tsx
|
|
130
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
131
|
+
var inputWrapperVariants = (0, import_tailwind_variants.tv)({
|
|
132
|
+
variants: {
|
|
133
|
+
variant: {
|
|
134
|
+
flat: "",
|
|
135
|
+
underlined: "",
|
|
136
|
+
bordered: "border-1",
|
|
137
|
+
faded: "border-1"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
var Input = import_react3.default.forwardRef(
|
|
142
|
+
({
|
|
143
|
+
value,
|
|
144
|
+
defaultValue,
|
|
145
|
+
onClear,
|
|
146
|
+
onValueChange,
|
|
147
|
+
variant,
|
|
148
|
+
classNames,
|
|
149
|
+
endContent,
|
|
150
|
+
isReadOnly,
|
|
151
|
+
isClearable,
|
|
152
|
+
...props
|
|
153
|
+
}, ref) => {
|
|
154
|
+
const { currentValue, handleValueChange, handleClear, mergedRef, showClearButton } = useInput({
|
|
155
|
+
value,
|
|
156
|
+
defaultValue,
|
|
157
|
+
onValueChange,
|
|
158
|
+
onClear,
|
|
159
|
+
isReadOnly,
|
|
160
|
+
isClearable,
|
|
161
|
+
ref
|
|
162
|
+
});
|
|
163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
164
|
+
import_input.Input,
|
|
165
|
+
{
|
|
166
|
+
ref: mergedRef,
|
|
167
|
+
classNames: {
|
|
168
|
+
...classNames,
|
|
169
|
+
inputWrapper: inputWrapperVariants({ variant }),
|
|
170
|
+
innerWrapper: "group"
|
|
171
|
+
},
|
|
172
|
+
defaultValue,
|
|
173
|
+
endContent: (endContent || showClearButton) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
174
|
+
endContent,
|
|
175
|
+
showClearButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ClearButton, { onClear: handleClear })
|
|
176
|
+
] }),
|
|
177
|
+
isReadOnly,
|
|
178
|
+
value: currentValue,
|
|
179
|
+
variant,
|
|
180
|
+
onValueChange: handleValueChange,
|
|
181
|
+
...props
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
Input.displayName = "TeachInUI.Input";
|
|
187
|
+
|
|
188
|
+
// src/ui/inputs/search/use-search.ts
|
|
189
|
+
var import_react4 = require("react");
|
|
190
|
+
function useSearch({ value, onSearch, onCancel, onKeyDown }) {
|
|
191
|
+
const handleKeyDown = (0, import_react4.useCallback)(
|
|
192
|
+
(event) => {
|
|
193
|
+
if (event.key === "Enter") {
|
|
194
|
+
event.preventDefault();
|
|
195
|
+
onSearch == null ? void 0 : onSearch(event.target.value);
|
|
196
|
+
} else if (event.key === "Escape") {
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
onCancel == null ? void 0 : onCancel();
|
|
199
|
+
}
|
|
200
|
+
onKeyDown == null ? void 0 : onKeyDown(event);
|
|
201
|
+
},
|
|
202
|
+
[onSearch, onCancel, onKeyDown]
|
|
203
|
+
);
|
|
204
|
+
const hasValue = value !== void 0 && String(value).length > 0;
|
|
205
|
+
const handleSearchClick = (0, import_react4.useCallback)(() => {
|
|
206
|
+
if (hasValue) {
|
|
207
|
+
onSearch == null ? void 0 : onSearch(value);
|
|
208
|
+
}
|
|
209
|
+
}, [value, onSearch]);
|
|
210
|
+
return {
|
|
211
|
+
handleKeyDown,
|
|
212
|
+
handleSearchClick,
|
|
213
|
+
hasValue
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/ui/inputs/search/search.tsx
|
|
218
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
219
|
+
var searchIconVariants = (0, import_tailwind_variants2.tv)({
|
|
220
|
+
base: "size-5 shrink-0",
|
|
221
|
+
variants: {
|
|
222
|
+
variant: {
|
|
223
|
+
faded: "text-default-400",
|
|
224
|
+
flat: "text-default-foreground",
|
|
225
|
+
bordered: "text-default-400",
|
|
226
|
+
underlined: "text-default-foreground"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
var Search = import_react5.default.forwardRef(
|
|
231
|
+
({ variant = "bordered", radius = "full", value, onSearch, onCancel, onKeyDown, ...props }, ref) => {
|
|
232
|
+
const { handleKeyDown, handleSearchClick, hasValue } = useSearch({
|
|
233
|
+
value,
|
|
234
|
+
onSearch,
|
|
235
|
+
onCancel,
|
|
236
|
+
onKeyDown
|
|
237
|
+
});
|
|
238
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
239
|
+
Input,
|
|
240
|
+
{
|
|
241
|
+
ref,
|
|
242
|
+
radius,
|
|
243
|
+
startContent: onSearch ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
244
|
+
import_button2.Button,
|
|
245
|
+
{
|
|
246
|
+
isIconOnly: true,
|
|
247
|
+
"aria-label": "\u041F\u043E\u0438\u0441\u043A",
|
|
248
|
+
isDisabled: !hasValue,
|
|
249
|
+
radius: "full",
|
|
250
|
+
size: "sm",
|
|
251
|
+
variant: "light",
|
|
252
|
+
onPress: handleSearchClick,
|
|
253
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.SearchIcon, { className: searchIconVariants({ variant }) })
|
|
254
|
+
}
|
|
255
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.SearchIcon, { className: searchIconVariants({ variant }) }),
|
|
256
|
+
value,
|
|
257
|
+
variant,
|
|
258
|
+
onKeyDown: handleKeyDown,
|
|
259
|
+
...props
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
Search.displayName = "TeachInUI.Search";
|
|
265
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
266
|
+
0 && (module.exports = {
|
|
267
|
+
Search
|
|
268
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Search
|
|
4
|
+
} from "../../../chunk-SEJXJZSK.mjs";
|
|
5
|
+
import "../../../chunk-C2VWADF5.mjs";
|
|
6
|
+
import "../../../chunk-ZRHEFEFS.mjs";
|
|
7
|
+
import "../../../chunk-MCQGBAUS.mjs";
|
|
8
|
+
import "../../../chunk-NSU66J5E.mjs";
|
|
9
|
+
import "../../../chunk-TUIN5YJW.mjs";
|
|
10
|
+
export {
|
|
11
|
+
Search
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface UseSearchProps {
|
|
2
|
+
value?: string;
|
|
3
|
+
onSearch?: (value: string) => void;
|
|
4
|
+
onCancel?: () => void;
|
|
5
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function useSearch({ value, onSearch, onCancel, onKeyDown }: UseSearchProps): {
|
|
8
|
+
handleKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
9
|
+
handleSearchClick: () => void;
|
|
10
|
+
hasValue: boolean;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
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/search/use-search.ts
|
|
22
|
+
var use_search_exports = {};
|
|
23
|
+
__export(use_search_exports, {
|
|
24
|
+
useSearch: () => useSearch
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(use_search_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
function useSearch({ value, onSearch, onCancel, onKeyDown }) {
|
|
29
|
+
const handleKeyDown = (0, import_react.useCallback)(
|
|
30
|
+
(event) => {
|
|
31
|
+
if (event.key === "Enter") {
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
onSearch == null ? void 0 : onSearch(event.target.value);
|
|
34
|
+
} else if (event.key === "Escape") {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
onCancel == null ? void 0 : onCancel();
|
|
37
|
+
}
|
|
38
|
+
onKeyDown == null ? void 0 : onKeyDown(event);
|
|
39
|
+
},
|
|
40
|
+
[onSearch, onCancel, onKeyDown]
|
|
41
|
+
);
|
|
42
|
+
const hasValue = value !== void 0 && String(value).length > 0;
|
|
43
|
+
const handleSearchClick = (0, import_react.useCallback)(() => {
|
|
44
|
+
if (hasValue) {
|
|
45
|
+
onSearch == null ? void 0 : onSearch(value);
|
|
46
|
+
}
|
|
47
|
+
}, [value, onSearch]);
|
|
48
|
+
return {
|
|
49
|
+
handleKeyDown,
|
|
50
|
+
handleSearchClick,
|
|
51
|
+
hasValue
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
useSearch
|
|
57
|
+
});
|