@teach-in/react 1.0.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.
Files changed (120) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +9 -9
  3. package/dist/{chunk-AMNORHD6.mjs → chunk-2ASQXBDD.mjs} +1 -1
  4. package/dist/{chunk-3VAZY2QK.mjs → chunk-2CEZXLZR.mjs} +1 -1
  5. package/dist/chunk-2UHA3DYG.mjs +62 -0
  6. package/dist/{chunk-LJIVY6GU.mjs → chunk-46SKVFMZ.mjs} +1 -1
  7. package/dist/{chunk-JDFRAN4S.mjs → chunk-5FFWQB7D.mjs} +12 -2
  8. package/dist/chunk-C2VWADF5.mjs +34 -0
  9. package/dist/{chunk-NLHQDWUK.mjs → chunk-CKJ5U5Q4.mjs} +1 -1
  10. package/dist/chunk-CUEG2BFV.mjs +34 -0
  11. package/dist/{chunk-CETCW7DS.mjs → chunk-IU2JYI7W.mjs} +1 -1
  12. package/dist/{chunk-KTUGFQWJ.mjs → chunk-KTWHCUYV.mjs} +1 -1
  13. package/dist/chunk-M5G6RR4Q.mjs +39 -0
  14. package/dist/chunk-MCQGBAUS.mjs +73 -0
  15. package/dist/chunk-NSU66J5E.mjs +59 -0
  16. package/dist/{chunk-CFG5V7VB.mjs → chunk-QCLLPJMB.mjs} +2 -2
  17. package/dist/{chunk-R7LDL5CU.mjs → chunk-R46SWVWL.mjs} +1 -1
  18. package/dist/chunk-SEJXJZSK.mjs +64 -0
  19. package/dist/chunk-TUIN5YJW.mjs +33 -0
  20. package/dist/chunk-UQAG7TKJ.mjs +1 -0
  21. package/dist/chunk-VXYV37IM.mjs +74 -0
  22. package/dist/index.js +609 -228
  23. package/dist/index.mjs +106 -86
  24. package/dist/ui/data/index.mjs +10 -10
  25. package/dist/ui/feedback/index.mjs +8 -8
  26. package/dist/ui/form/index.js +447 -106
  27. package/dist/ui/form/index.mjs +25 -15
  28. package/dist/ui/form/rhf/fields/autocomplete-field.mjs +16 -10
  29. package/dist/ui/form/rhf/fields/checkbox-field.mjs +16 -10
  30. package/dist/ui/form/rhf/fields/date-picker-field.mjs +16 -10
  31. package/dist/ui/form/rhf/fields/email-field.js +147 -10
  32. package/dist/ui/form/rhf/fields/email-field.mjs +17 -11
  33. package/dist/ui/form/rhf/fields/index.d.ts +1 -0
  34. package/dist/ui/form/rhf/fields/index.js +443 -102
  35. package/dist/ui/form/rhf/fields/index.mjs +25 -15
  36. package/dist/ui/form/rhf/fields/input-field.js +153 -6
  37. package/dist/ui/form/rhf/fields/input-field.mjs +17 -11
  38. package/dist/ui/form/rhf/fields/radio-field.mjs +16 -10
  39. package/dist/ui/form/rhf/fields/search-field.d.ts +10 -0
  40. package/dist/ui/form/rhf/fields/search-field.js +296 -0
  41. package/dist/ui/form/rhf/fields/search-field.mjs +37 -0
  42. package/dist/ui/form/rhf/fields/select-field.js +136 -26
  43. package/dist/ui/form/rhf/fields/select-field.mjs +17 -11
  44. package/dist/ui/form/rhf/fields/switch-field.mjs +16 -10
  45. package/dist/ui/form/rhf/fields/text-field.js +147 -10
  46. package/dist/ui/form/rhf/fields/text-field.mjs +17 -11
  47. package/dist/ui/form/rhf/fields/textarea-field.mjs +16 -10
  48. package/dist/ui/form/rhf/index.js +443 -102
  49. package/dist/ui/form/rhf/index.mjs +25 -15
  50. package/dist/ui/format/index.d.ts +1 -0
  51. package/dist/ui/format/index.js +41 -5
  52. package/dist/ui/format/index.mjs +15 -11
  53. package/dist/ui/format/uuid.d.ts +12 -0
  54. package/dist/ui/format/uuid.js +62 -0
  55. package/dist/ui/format/uuid.mjs +7 -0
  56. package/dist/ui/index.js +609 -228
  57. package/dist/ui/index.mjs +106 -86
  58. package/dist/ui/inputs/clear-button.d.ts +5 -0
  59. package/dist/ui/inputs/clear-button.js +67 -0
  60. package/dist/ui/inputs/clear-button.mjs +8 -0
  61. package/dist/ui/inputs/email/email.js +144 -7
  62. package/dist/ui/inputs/email/email.mjs +4 -2
  63. package/dist/ui/inputs/email/index.js +144 -7
  64. package/dist/ui/inputs/email/index.mjs +4 -2
  65. package/dist/ui/inputs/index.d.ts +2 -0
  66. package/dist/ui/inputs/index.js +363 -56
  67. package/dist/ui/inputs/index.mjs +27 -15
  68. package/dist/ui/inputs/input/index.js +140 -3
  69. package/dist/ui/inputs/input/index.mjs +3 -1
  70. package/dist/ui/inputs/input/input.d.ts +1 -0
  71. package/dist/ui/inputs/input/input.js +140 -3
  72. package/dist/ui/inputs/input/input.mjs +3 -1
  73. package/dist/ui/inputs/input/use-input.d.ts +19 -0
  74. package/dist/ui/inputs/input/use-input.js +82 -0
  75. package/dist/ui/inputs/input/use-input.mjs +7 -0
  76. package/dist/ui/inputs/radio/index.mjs +3 -3
  77. package/dist/ui/inputs/search/index.d.ts +1 -0
  78. package/dist/ui/inputs/search/index.js +270 -0
  79. package/dist/ui/inputs/search/index.mjs +13 -0
  80. package/dist/ui/inputs/search/search.d.ts +7 -0
  81. package/dist/ui/inputs/search/search.js +268 -0
  82. package/dist/ui/inputs/search/search.mjs +12 -0
  83. package/dist/ui/inputs/search/use-search.d.ts +12 -0
  84. package/dist/ui/inputs/search/use-search.js +57 -0
  85. package/dist/ui/inputs/search/use-search.mjs +7 -0
  86. package/dist/ui/inputs/select/index.js +132 -22
  87. package/dist/ui/inputs/select/index.mjs +3 -1
  88. package/dist/ui/inputs/select/select.d.ts +4 -0
  89. package/dist/ui/inputs/select/select.js +132 -22
  90. package/dist/ui/inputs/select/select.mjs +3 -1
  91. package/dist/ui/inputs/select/use-select.d.ts +17 -0
  92. package/dist/ui/inputs/select/use-select.js +85 -0
  93. package/dist/ui/inputs/select/use-select.mjs +7 -0
  94. package/dist/ui/inputs/text/index.js +144 -7
  95. package/dist/ui/inputs/text/index.mjs +4 -2
  96. package/dist/ui/inputs/text/text.js +144 -7
  97. package/dist/ui/inputs/text/text.mjs +4 -2
  98. package/dist/ui/layout/container/container.mjs +56 -48
  99. package/dist/ui/layout/container/index.mjs +56 -48
  100. package/dist/ui/layout/index.mjs +62 -54
  101. package/dist/ui/layout/page/index.mjs +4 -4
  102. package/dist/ui/layout/page/page-loading.mjs +4 -4
  103. package/dist/ui/layout/page/section-loading.mjs +4 -4
  104. package/dist/ui/navigation/index.mjs +8 -8
  105. package/dist/ui/overlays/index.mjs +5 -5
  106. package/dist/ui/provider/index.mjs +4 -4
  107. package/dist/ui/provider/ui-provider.mjs +4 -4
  108. package/dist/ui/theme/colors/common.mjs +5 -5
  109. package/dist/ui/theme/colors/index.mjs +8 -8
  110. package/dist/ui/theme/colors/semantic.mjs +6 -6
  111. package/dist/ui/theme/colors.mjs +8 -8
  112. package/dist/ui/theme/index.mjs +8 -8
  113. package/dist/ui/theme/theme.mjs +8 -8
  114. package/package.json +1 -1
  115. package/dist/chunk-3YOW5DEZ.mjs +0 -45
  116. package/dist/chunk-V2G5QHZZ.mjs +0 -14
  117. package/dist/{chunk-5IHVMMCK.mjs → chunk-5N3SIZHF.mjs} +0 -0
  118. package/dist/{chunk-CZEO3U25.mjs → chunk-5RNCFTW5.mjs} +0 -0
  119. package/dist/{chunk-STVN4B47.mjs → chunk-IXPMUODA.mjs} +12 -12
  120. /package/dist/{chunk-Q6JSJOU4.mjs → chunk-PTCNYQVY.mjs} +0 -0
@@ -1,20 +1,23 @@
1
1
  "use client";
2
- import "../../../../chunk-Q6JSJOU4.mjs";
2
+ import "../../../../chunk-PTCNYQVY.mjs";
3
3
  import {
4
4
  InputField
5
- } from "../../../../chunk-JDFRAN4S.mjs";
5
+ } from "../../../../chunk-5FFWQB7D.mjs";
6
6
  import {
7
7
  RadioField
8
8
  } from "../../../../chunk-W2A6C27Y.mjs";
9
+ import {
10
+ SearchField
11
+ } from "../../../../chunk-CUEG2BFV.mjs";
9
12
  import {
10
13
  SelectField
11
- } from "../../../../chunk-NLHQDWUK.mjs";
14
+ } from "../../../../chunk-CKJ5U5Q4.mjs";
12
15
  import {
13
16
  SwitchField
14
17
  } from "../../../../chunk-EC3NSPHR.mjs";
15
18
  import {
16
19
  TextField
17
- } from "../../../../chunk-CETCW7DS.mjs";
20
+ } from "../../../../chunk-IU2JYI7W.mjs";
18
21
  import {
19
22
  TextareaField
20
23
  } from "../../../../chunk-V4HKGJYK.mjs";
@@ -29,31 +32,37 @@ import {
29
32
  } from "../../../../chunk-7GHK5XYK.mjs";
30
33
  import {
31
34
  EmailField
32
- } from "../../../../chunk-R7LDL5CU.mjs";
33
- import "../../../../chunk-CZEO3U25.mjs";
35
+ } from "../../../../chunk-R46SWVWL.mjs";
36
+ import "../../../../chunk-UQAG7TKJ.mjs";
34
37
  import "../../../../chunk-DUQFM3QS.mjs";
35
- import "../../../../chunk-KTUGFQWJ.mjs";
38
+ import "../../../../chunk-KTWHCUYV.mjs";
36
39
  import "../../../../chunk-LLP2PTPK.mjs";
37
40
  import "../../../../chunk-E5QSNLSR.mjs";
38
41
  import "../../../../chunk-N3EAW6UO.mjs";
39
42
  import "../../../../chunk-5HK7HRTR.mjs";
40
43
  import "../../../../chunk-HJUZTISD.mjs";
41
44
  import "../../../../chunk-V3KKDSQP.mjs";
42
- import "../../../../chunk-LJIVY6GU.mjs";
43
- import "../../../../chunk-ZRHEFEFS.mjs";
44
- import "../../../../chunk-V2G5QHZZ.mjs";
45
+ import "../../../../chunk-46SKVFMZ.mjs";
45
46
  import "../../../../chunk-AQ3ISJKU.mjs";
46
- import "../../../../chunk-3YOW5DEZ.mjs";
47
+ import "../../../../chunk-VXYV37IM.mjs";
48
+ import "../../../../chunk-2UHA3DYG.mjs";
49
+ import "../../../../chunk-5RNCFTW5.mjs";
50
+ import "../../../../chunk-SEJXJZSK.mjs";
51
+ import "../../../../chunk-C2VWADF5.mjs";
52
+ import "../../../../chunk-UUKS7JYX.mjs";
53
+ import "../../../../chunk-V2HNFTTX.mjs";
54
+ import "../../../../chunk-IAJ6G633.mjs";
47
55
  import "../../../../chunk-RRA7GWP2.mjs";
48
- import "../../../../chunk-2SNKT7I4.mjs";
49
56
  import "../../../../chunk-NOXFF2KJ.mjs";
57
+ import "../../../../chunk-2SNKT7I4.mjs";
58
+ import "../../../../chunk-ZRHEFEFS.mjs";
59
+ import "../../../../chunk-MCQGBAUS.mjs";
60
+ import "../../../../chunk-NSU66J5E.mjs";
50
61
  import "../../../../chunk-WYJW5NNA.mjs";
51
62
  import "../../../../chunk-C3MURCMZ.mjs";
52
- import "../../../../chunk-V2HNFTTX.mjs";
53
- import "../../../../chunk-IAJ6G633.mjs";
54
- import "../../../../chunk-UUKS7JYX.mjs";
55
63
  import "../../../../chunk-C4PCTOGM.mjs";
56
64
  import "../../../../chunk-N3QOXWJI.mjs";
65
+ import "../../../../chunk-TUIN5YJW.mjs";
57
66
  export {
58
67
  AutocompleteField,
59
68
  CheckboxField,
@@ -61,6 +70,7 @@ export {
61
70
  EmailField,
62
71
  InputField,
63
72
  RadioField,
73
+ SearchField,
64
74
  SelectField,
65
75
  SwitchField,
66
76
  TextField,
@@ -37,24 +37,171 @@ module.exports = __toCommonJS(input_field_exports);
37
37
  var import_react_hook_form = require("react-hook-form");
38
38
 
39
39
  // src/ui/inputs/input/input.tsx
40
- var import_react = __toESM(require("react"));
40
+ var import_react3 = __toESM(require("react"));
41
41
  var import_input = require("@heroui/input");
42
+ var import_tailwind_variants = require("tailwind-variants");
43
+
44
+ // src/ui/inputs/clear-button.tsx
45
+ var import_react = __toESM(require("react"));
46
+ var import_button = require("@heroui/button");
47
+ var import_lucide_react = require("lucide-react");
42
48
  var import_jsx_runtime = require("react/jsx-runtime");
43
- var Input = import_react.default.forwardRef(({ ...props }, ref) => {
44
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_input.Input, { ref, ...props });
49
+ var ClearButton = import_react.default.forwardRef(
50
+ ({ onClear }, ref) => {
51
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
52
+ import_button.Button,
53
+ {
54
+ ref,
55
+ isIconOnly: true,
56
+ "aria-label": "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C",
57
+ as: "span",
58
+ className: "opacity-0 transition-opacity group-hover:opacity-100",
59
+ color: "default",
60
+ radius: "full",
61
+ size: "sm",
62
+ tabIndex: 0,
63
+ variant: "light",
64
+ onPress: onClear,
65
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.XIcon, { className: "size-4 text-default-500" })
66
+ }
67
+ );
68
+ }
69
+ );
70
+ ClearButton.displayName = "TeachInUI.ClearButton";
71
+
72
+ // src/ui/inputs/input/use-input.ts
73
+ var import_react2 = require("react");
74
+ function useInput({
75
+ value,
76
+ defaultValue,
77
+ onValueChange,
78
+ onClear,
79
+ isReadOnly,
80
+ isClearable = true,
81
+ ref
82
+ }) {
83
+ const inputRef = (0, import_react2.useRef)(null);
84
+ const [internalValue, setInternalValue] = (0, import_react2.useState)(defaultValue != null ? defaultValue : "");
85
+ const isControlled = value !== void 0;
86
+ const currentValue = isControlled ? value : internalValue;
87
+ const hasValue = String(currentValue).length > 0;
88
+ const handleValueChange = (0, import_react2.useCallback)(
89
+ (newValue) => {
90
+ if (!isControlled) {
91
+ setInternalValue(newValue);
92
+ }
93
+ onValueChange == null ? void 0 : onValueChange(newValue);
94
+ },
95
+ [isControlled, onValueChange]
96
+ );
97
+ const handleClear = (0, import_react2.useCallback)(() => {
98
+ var _a;
99
+ onClear == null ? void 0 : onClear();
100
+ handleValueChange("");
101
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
102
+ }, [onClear, handleValueChange]);
103
+ const mergedRef = (0, import_react2.useCallback)(
104
+ (node) => {
105
+ inputRef.current = node;
106
+ if (typeof ref === "function") {
107
+ ref(node);
108
+ } else if (ref) {
109
+ ref.current = node;
110
+ }
111
+ },
112
+ [ref]
113
+ );
114
+ const showClearButton = hasValue && !isReadOnly && isClearable;
115
+ return {
116
+ inputRef,
117
+ currentValue,
118
+ hasValue,
119
+ handleValueChange,
120
+ handleClear,
121
+ mergedRef,
122
+ showClearButton
123
+ };
124
+ }
125
+
126
+ // src/ui/inputs/input/input.tsx
127
+ var import_jsx_runtime2 = require("react/jsx-runtime");
128
+ var inputWrapperVariants = (0, import_tailwind_variants.tv)({
129
+ variants: {
130
+ variant: {
131
+ flat: "",
132
+ underlined: "",
133
+ bordered: "border-1",
134
+ faded: "border-1"
135
+ }
136
+ }
45
137
  });
138
+ var Input = import_react3.default.forwardRef(
139
+ ({
140
+ value,
141
+ defaultValue,
142
+ onClear,
143
+ onValueChange,
144
+ variant,
145
+ classNames,
146
+ endContent,
147
+ isReadOnly,
148
+ isClearable,
149
+ ...props
150
+ }, ref) => {
151
+ const { currentValue, handleValueChange, handleClear, mergedRef, showClearButton } = useInput({
152
+ value,
153
+ defaultValue,
154
+ onValueChange,
155
+ onClear,
156
+ isReadOnly,
157
+ isClearable,
158
+ ref
159
+ });
160
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
161
+ import_input.Input,
162
+ {
163
+ ref: mergedRef,
164
+ classNames: {
165
+ ...classNames,
166
+ inputWrapper: inputWrapperVariants({ variant }),
167
+ innerWrapper: "group"
168
+ },
169
+ defaultValue,
170
+ endContent: (endContent || showClearButton) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-1", children: [
171
+ endContent,
172
+ showClearButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ClearButton, { onClear: handleClear })
173
+ ] }),
174
+ isReadOnly,
175
+ value: currentValue,
176
+ variant,
177
+ onValueChange: handleValueChange,
178
+ ...props
179
+ }
180
+ );
181
+ }
182
+ );
46
183
  Input.displayName = "TeachInUI.Input";
47
184
 
48
185
  // src/ui/form/rhf/fields/input-field.tsx
49
- var import_jsx_runtime2 = require("react/jsx-runtime");
186
+ var import_jsx_runtime3 = require("react/jsx-runtime");
50
187
  function InputField({ name, ...props }) {
51
188
  const { control } = (0, import_react_hook_form.useFormContext)();
52
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
189
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
53
190
  import_react_hook_form.Controller,
54
191
  {
55
192
  control,
56
193
  name,
57
- render: ({ field: { ref, ...field }, fieldState: { error } }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Input, { ...props, ...field, ref, errorMessage: error == null ? void 0 : error.message, isInvalid: !!error })
194
+ render: ({ field: { ref, ...field }, fieldState: { error } }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
195
+ Input,
196
+ {
197
+ ...props,
198
+ ...field,
199
+ ref,
200
+ errorMessage: error == null ? void 0 : error.message,
201
+ isInvalid: !!error,
202
+ onValueChange: field.onChange
203
+ }
204
+ )
58
205
  }
59
206
  );
60
207
  }
@@ -1,31 +1,37 @@
1
1
  "use client";
2
2
  import {
3
3
  InputField
4
- } from "../../../../chunk-JDFRAN4S.mjs";
5
- import "../../../../chunk-CZEO3U25.mjs";
4
+ } from "../../../../chunk-5FFWQB7D.mjs";
5
+ import "../../../../chunk-UQAG7TKJ.mjs";
6
6
  import "../../../../chunk-DUQFM3QS.mjs";
7
- import "../../../../chunk-KTUGFQWJ.mjs";
7
+ import "../../../../chunk-KTWHCUYV.mjs";
8
8
  import "../../../../chunk-LLP2PTPK.mjs";
9
9
  import "../../../../chunk-E5QSNLSR.mjs";
10
10
  import "../../../../chunk-N3EAW6UO.mjs";
11
11
  import "../../../../chunk-5HK7HRTR.mjs";
12
12
  import "../../../../chunk-HJUZTISD.mjs";
13
13
  import "../../../../chunk-V3KKDSQP.mjs";
14
- import "../../../../chunk-LJIVY6GU.mjs";
15
- import "../../../../chunk-ZRHEFEFS.mjs";
16
- import "../../../../chunk-V2G5QHZZ.mjs";
14
+ import "../../../../chunk-46SKVFMZ.mjs";
17
15
  import "../../../../chunk-AQ3ISJKU.mjs";
18
- import "../../../../chunk-3YOW5DEZ.mjs";
16
+ import "../../../../chunk-VXYV37IM.mjs";
17
+ import "../../../../chunk-2UHA3DYG.mjs";
18
+ import "../../../../chunk-5RNCFTW5.mjs";
19
+ import "../../../../chunk-SEJXJZSK.mjs";
20
+ import "../../../../chunk-C2VWADF5.mjs";
21
+ import "../../../../chunk-UUKS7JYX.mjs";
22
+ import "../../../../chunk-V2HNFTTX.mjs";
23
+ import "../../../../chunk-IAJ6G633.mjs";
19
24
  import "../../../../chunk-RRA7GWP2.mjs";
20
- import "../../../../chunk-2SNKT7I4.mjs";
21
25
  import "../../../../chunk-NOXFF2KJ.mjs";
26
+ import "../../../../chunk-2SNKT7I4.mjs";
27
+ import "../../../../chunk-ZRHEFEFS.mjs";
28
+ import "../../../../chunk-MCQGBAUS.mjs";
29
+ import "../../../../chunk-NSU66J5E.mjs";
22
30
  import "../../../../chunk-WYJW5NNA.mjs";
23
31
  import "../../../../chunk-C3MURCMZ.mjs";
24
- import "../../../../chunk-V2HNFTTX.mjs";
25
- import "../../../../chunk-IAJ6G633.mjs";
26
- import "../../../../chunk-UUKS7JYX.mjs";
27
32
  import "../../../../chunk-C4PCTOGM.mjs";
28
33
  import "../../../../chunk-N3QOXWJI.mjs";
34
+ import "../../../../chunk-TUIN5YJW.mjs";
29
35
  export {
30
36
  InputField
31
37
  };
@@ -2,30 +2,36 @@
2
2
  import {
3
3
  RadioField
4
4
  } from "../../../../chunk-W2A6C27Y.mjs";
5
- import "../../../../chunk-CZEO3U25.mjs";
5
+ import "../../../../chunk-UQAG7TKJ.mjs";
6
6
  import "../../../../chunk-DUQFM3QS.mjs";
7
- import "../../../../chunk-KTUGFQWJ.mjs";
7
+ import "../../../../chunk-KTWHCUYV.mjs";
8
8
  import "../../../../chunk-LLP2PTPK.mjs";
9
9
  import "../../../../chunk-E5QSNLSR.mjs";
10
10
  import "../../../../chunk-N3EAW6UO.mjs";
11
11
  import "../../../../chunk-5HK7HRTR.mjs";
12
12
  import "../../../../chunk-HJUZTISD.mjs";
13
13
  import "../../../../chunk-V3KKDSQP.mjs";
14
- import "../../../../chunk-LJIVY6GU.mjs";
15
- import "../../../../chunk-ZRHEFEFS.mjs";
16
- import "../../../../chunk-V2G5QHZZ.mjs";
14
+ import "../../../../chunk-46SKVFMZ.mjs";
17
15
  import "../../../../chunk-AQ3ISJKU.mjs";
18
- import "../../../../chunk-3YOW5DEZ.mjs";
16
+ import "../../../../chunk-VXYV37IM.mjs";
17
+ import "../../../../chunk-2UHA3DYG.mjs";
18
+ import "../../../../chunk-5RNCFTW5.mjs";
19
+ import "../../../../chunk-SEJXJZSK.mjs";
20
+ import "../../../../chunk-C2VWADF5.mjs";
21
+ import "../../../../chunk-UUKS7JYX.mjs";
22
+ import "../../../../chunk-V2HNFTTX.mjs";
23
+ import "../../../../chunk-IAJ6G633.mjs";
19
24
  import "../../../../chunk-RRA7GWP2.mjs";
20
- import "../../../../chunk-2SNKT7I4.mjs";
21
25
  import "../../../../chunk-NOXFF2KJ.mjs";
26
+ import "../../../../chunk-2SNKT7I4.mjs";
27
+ import "../../../../chunk-ZRHEFEFS.mjs";
28
+ import "../../../../chunk-MCQGBAUS.mjs";
29
+ import "../../../../chunk-NSU66J5E.mjs";
22
30
  import "../../../../chunk-WYJW5NNA.mjs";
23
31
  import "../../../../chunk-C3MURCMZ.mjs";
24
- import "../../../../chunk-V2HNFTTX.mjs";
25
- import "../../../../chunk-IAJ6G633.mjs";
26
- import "../../../../chunk-UUKS7JYX.mjs";
27
32
  import "../../../../chunk-C4PCTOGM.mjs";
28
33
  import "../../../../chunk-N3QOXWJI.mjs";
34
+ import "../../../../chunk-TUIN5YJW.mjs";
29
35
  export {
30
36
  RadioField
31
37
  };
@@ -0,0 +1,10 @@
1
+ import type { SearchProps } from "../../../inputs";
2
+ import React from "react";
3
+ interface Props extends Omit<SearchProps, "name" | "errorMessage" | "isInvalid"> {
4
+ readonly name: string;
5
+ }
6
+ export declare function SearchField({ name, ...props }: Props): React.JSX.Element;
7
+ export declare namespace SearchField {
8
+ var displayName: string;
9
+ }
10
+ export {};
@@ -0,0 +1,296 @@
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/form/rhf/fields/search-field.tsx
32
+ var search_field_exports = {};
33
+ __export(search_field_exports, {
34
+ SearchField: () => SearchField
35
+ });
36
+ module.exports = __toCommonJS(search_field_exports);
37
+ var import_react_hook_form = require("react-hook-form");
38
+
39
+ // src/ui/inputs/input/input.tsx
40
+ var import_react3 = __toESM(require("react"));
41
+ var import_input = require("@heroui/input");
42
+ var import_tailwind_variants = require("tailwind-variants");
43
+
44
+ // src/ui/inputs/clear-button.tsx
45
+ var import_react = __toESM(require("react"));
46
+ var import_button = require("@heroui/button");
47
+ var import_lucide_react = require("lucide-react");
48
+ var import_jsx_runtime = require("react/jsx-runtime");
49
+ var ClearButton = import_react.default.forwardRef(
50
+ ({ onClear }, ref) => {
51
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
52
+ import_button.Button,
53
+ {
54
+ ref,
55
+ isIconOnly: true,
56
+ "aria-label": "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C",
57
+ as: "span",
58
+ className: "opacity-0 transition-opacity group-hover:opacity-100",
59
+ color: "default",
60
+ radius: "full",
61
+ size: "sm",
62
+ tabIndex: 0,
63
+ variant: "light",
64
+ onPress: onClear,
65
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.XIcon, { className: "size-4 text-default-500" })
66
+ }
67
+ );
68
+ }
69
+ );
70
+ ClearButton.displayName = "TeachInUI.ClearButton";
71
+
72
+ // src/ui/inputs/input/use-input.ts
73
+ var import_react2 = require("react");
74
+ function useInput({
75
+ value,
76
+ defaultValue,
77
+ onValueChange,
78
+ onClear,
79
+ isReadOnly,
80
+ isClearable = true,
81
+ ref
82
+ }) {
83
+ const inputRef = (0, import_react2.useRef)(null);
84
+ const [internalValue, setInternalValue] = (0, import_react2.useState)(defaultValue != null ? defaultValue : "");
85
+ const isControlled = value !== void 0;
86
+ const currentValue = isControlled ? value : internalValue;
87
+ const hasValue = String(currentValue).length > 0;
88
+ const handleValueChange = (0, import_react2.useCallback)(
89
+ (newValue) => {
90
+ if (!isControlled) {
91
+ setInternalValue(newValue);
92
+ }
93
+ onValueChange == null ? void 0 : onValueChange(newValue);
94
+ },
95
+ [isControlled, onValueChange]
96
+ );
97
+ const handleClear = (0, import_react2.useCallback)(() => {
98
+ var _a;
99
+ onClear == null ? void 0 : onClear();
100
+ handleValueChange("");
101
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
102
+ }, [onClear, handleValueChange]);
103
+ const mergedRef = (0, import_react2.useCallback)(
104
+ (node) => {
105
+ inputRef.current = node;
106
+ if (typeof ref === "function") {
107
+ ref(node);
108
+ } else if (ref) {
109
+ ref.current = node;
110
+ }
111
+ },
112
+ [ref]
113
+ );
114
+ const showClearButton = hasValue && !isReadOnly && isClearable;
115
+ return {
116
+ inputRef,
117
+ currentValue,
118
+ hasValue,
119
+ handleValueChange,
120
+ handleClear,
121
+ mergedRef,
122
+ showClearButton
123
+ };
124
+ }
125
+
126
+ // src/ui/inputs/input/input.tsx
127
+ var import_jsx_runtime2 = require("react/jsx-runtime");
128
+ var inputWrapperVariants = (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 Input = import_react3.default.forwardRef(
139
+ ({
140
+ value,
141
+ defaultValue,
142
+ onClear,
143
+ onValueChange,
144
+ variant,
145
+ classNames,
146
+ endContent,
147
+ isReadOnly,
148
+ isClearable,
149
+ ...props
150
+ }, ref) => {
151
+ const { currentValue, handleValueChange, handleClear, mergedRef, showClearButton } = useInput({
152
+ value,
153
+ defaultValue,
154
+ onValueChange,
155
+ onClear,
156
+ isReadOnly,
157
+ isClearable,
158
+ ref
159
+ });
160
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
161
+ import_input.Input,
162
+ {
163
+ ref: mergedRef,
164
+ classNames: {
165
+ ...classNames,
166
+ inputWrapper: inputWrapperVariants({ variant }),
167
+ innerWrapper: "group"
168
+ },
169
+ defaultValue,
170
+ endContent: (endContent || showClearButton) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-1", children: [
171
+ endContent,
172
+ showClearButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ClearButton, { onClear: handleClear })
173
+ ] }),
174
+ isReadOnly,
175
+ value: currentValue,
176
+ variant,
177
+ onValueChange: handleValueChange,
178
+ ...props
179
+ }
180
+ );
181
+ }
182
+ );
183
+ Input.displayName = "TeachInUI.Input";
184
+
185
+ // src/ui/inputs/search/search.tsx
186
+ var import_react5 = __toESM(require("react"));
187
+ var import_lucide_react2 = require("lucide-react");
188
+ var import_button2 = require("@heroui/button");
189
+ var import_tailwind_variants2 = require("tailwind-variants");
190
+
191
+ // src/ui/inputs/search/use-search.ts
192
+ var import_react4 = require("react");
193
+ function useSearch({ value, onSearch, onCancel, onKeyDown }) {
194
+ const handleKeyDown = (0, import_react4.useCallback)(
195
+ (event) => {
196
+ if (event.key === "Enter") {
197
+ event.preventDefault();
198
+ onSearch == null ? void 0 : onSearch(event.target.value);
199
+ } else if (event.key === "Escape") {
200
+ event.preventDefault();
201
+ onCancel == null ? void 0 : onCancel();
202
+ }
203
+ onKeyDown == null ? void 0 : onKeyDown(event);
204
+ },
205
+ [onSearch, onCancel, onKeyDown]
206
+ );
207
+ const hasValue = value !== void 0 && String(value).length > 0;
208
+ const handleSearchClick = (0, import_react4.useCallback)(() => {
209
+ if (hasValue) {
210
+ onSearch == null ? void 0 : onSearch(value);
211
+ }
212
+ }, [value, onSearch]);
213
+ return {
214
+ handleKeyDown,
215
+ handleSearchClick,
216
+ hasValue
217
+ };
218
+ }
219
+
220
+ // src/ui/inputs/search/search.tsx
221
+ var import_jsx_runtime3 = require("react/jsx-runtime");
222
+ var searchIconVariants = (0, import_tailwind_variants2.tv)({
223
+ base: "size-5 shrink-0",
224
+ variants: {
225
+ variant: {
226
+ faded: "text-default-400",
227
+ flat: "text-default-foreground",
228
+ bordered: "text-default-400",
229
+ underlined: "text-default-foreground"
230
+ }
231
+ }
232
+ });
233
+ var Search = import_react5.default.forwardRef(
234
+ ({ variant = "bordered", radius = "full", value, onSearch, onCancel, onKeyDown, ...props }, ref) => {
235
+ const { handleKeyDown, handleSearchClick, hasValue } = useSearch({
236
+ value,
237
+ onSearch,
238
+ onCancel,
239
+ onKeyDown
240
+ });
241
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
242
+ Input,
243
+ {
244
+ ref,
245
+ radius,
246
+ startContent: onSearch ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
247
+ import_button2.Button,
248
+ {
249
+ isIconOnly: true,
250
+ "aria-label": "\u041F\u043E\u0438\u0441\u043A",
251
+ isDisabled: !hasValue,
252
+ radius: "full",
253
+ size: "sm",
254
+ variant: "light",
255
+ onPress: handleSearchClick,
256
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.SearchIcon, { className: searchIconVariants({ variant }) })
257
+ }
258
+ ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.SearchIcon, { className: searchIconVariants({ variant }) }),
259
+ value,
260
+ variant,
261
+ onKeyDown: handleKeyDown,
262
+ ...props
263
+ }
264
+ );
265
+ }
266
+ );
267
+ Search.displayName = "TeachInUI.Search";
268
+
269
+ // src/ui/form/rhf/fields/search-field.tsx
270
+ var import_jsx_runtime4 = require("react/jsx-runtime");
271
+ function SearchField({ name, ...props }) {
272
+ const { control } = (0, import_react_hook_form.useFormContext)();
273
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
274
+ import_react_hook_form.Controller,
275
+ {
276
+ control,
277
+ name,
278
+ render: ({ field: { ref, ...field }, fieldState: { error } }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
279
+ Search,
280
+ {
281
+ ...props,
282
+ ...field,
283
+ ref,
284
+ errorMessage: error == null ? void 0 : error.message,
285
+ isInvalid: !!error,
286
+ onValueChange: field.onChange
287
+ }
288
+ )
289
+ }
290
+ );
291
+ }
292
+ SearchField.displayName = "TeachInUI.SearchField";
293
+ // Annotate the CommonJS export names for ESM import in node:
294
+ 0 && (module.exports = {
295
+ SearchField
296
+ });