@teach-in/react 1.2.0 → 1.3.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 (113) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +9 -9
  3. package/dist/chunk-3YOW5DEZ.mjs +45 -0
  4. package/dist/{chunk-QCLLPJMB.mjs → chunk-544SDU73.mjs} +2 -2
  5. package/dist/{chunk-2CEZXLZR.mjs → chunk-AFVGHUW2.mjs} +1 -1
  6. package/dist/{chunk-IU2JYI7W.mjs → chunk-CETCW7DS.mjs} +1 -1
  7. package/dist/{chunk-5FFWQB7D.mjs → chunk-JDFRAN4S.mjs} +2 -12
  8. package/dist/{chunk-KTWHCUYV.mjs → chunk-KTUGFQWJ.mjs} +1 -1
  9. package/dist/{chunk-46SKVFMZ.mjs → chunk-LJIVY6GU.mjs} +1 -1
  10. package/dist/{chunk-CKJ5U5Q4.mjs → chunk-NLHQDWUK.mjs} +1 -1
  11. package/dist/{chunk-R46SWVWL.mjs → chunk-R7LDL5CU.mjs} +1 -1
  12. package/dist/chunk-V2G5QHZZ.mjs +14 -0
  13. package/dist/{chunk-2ASQXBDD.mjs → chunk-WFNNN6WU.mjs} +1 -1
  14. package/dist/index.js +230 -575
  15. package/dist/index.mjs +125 -141
  16. package/dist/ui/data/index.mjs +8 -8
  17. package/dist/ui/feedback/index.mjs +14 -14
  18. package/dist/ui/form/index.js +106 -447
  19. package/dist/ui/form/index.mjs +21 -31
  20. package/dist/ui/form/rhf/fields/autocomplete-field.mjs +14 -20
  21. package/dist/ui/form/rhf/fields/checkbox-field.mjs +14 -20
  22. package/dist/ui/form/rhf/fields/date-picker-field.mjs +14 -20
  23. package/dist/ui/form/rhf/fields/email-field.js +10 -147
  24. package/dist/ui/form/rhf/fields/email-field.mjs +15 -21
  25. package/dist/ui/form/rhf/fields/index.d.ts +0 -1
  26. package/dist/ui/form/rhf/fields/index.js +102 -443
  27. package/dist/ui/form/rhf/fields/index.mjs +21 -31
  28. package/dist/ui/form/rhf/fields/input-field.js +6 -153
  29. package/dist/ui/form/rhf/fields/input-field.mjs +15 -21
  30. package/dist/ui/form/rhf/fields/radio-field.mjs +14 -20
  31. package/dist/ui/form/rhf/fields/select-field.js +26 -136
  32. package/dist/ui/form/rhf/fields/select-field.mjs +15 -21
  33. package/dist/ui/form/rhf/fields/switch-field.mjs +14 -20
  34. package/dist/ui/form/rhf/fields/text-field.js +10 -147
  35. package/dist/ui/form/rhf/fields/text-field.mjs +15 -21
  36. package/dist/ui/form/rhf/fields/textarea-field.mjs +14 -20
  37. package/dist/ui/form/rhf/index.js +102 -443
  38. package/dist/ui/form/rhf/index.mjs +21 -31
  39. package/dist/ui/format/index.mjs +3 -3
  40. package/dist/ui/index.js +230 -575
  41. package/dist/ui/index.mjs +125 -141
  42. package/dist/ui/inputs/checkbox/index.mjs +3 -3
  43. package/dist/ui/inputs/email/email.js +7 -144
  44. package/dist/ui/inputs/email/email.mjs +2 -4
  45. package/dist/ui/inputs/email/index.js +7 -144
  46. package/dist/ui/inputs/email/index.mjs +2 -4
  47. package/dist/ui/inputs/index.d.ts +0 -2
  48. package/dist/ui/inputs/index.js +56 -363
  49. package/dist/ui/inputs/index.mjs +25 -37
  50. package/dist/ui/inputs/input/index.js +3 -140
  51. package/dist/ui/inputs/input/index.mjs +1 -3
  52. package/dist/ui/inputs/input/input.d.ts +0 -1
  53. package/dist/ui/inputs/input/input.js +3 -140
  54. package/dist/ui/inputs/input/input.mjs +1 -3
  55. package/dist/ui/inputs/select/index.js +22 -132
  56. package/dist/ui/inputs/select/index.mjs +1 -3
  57. package/dist/ui/inputs/select/select.d.ts +0 -4
  58. package/dist/ui/inputs/select/select.js +22 -132
  59. package/dist/ui/inputs/select/select.mjs +1 -3
  60. package/dist/ui/inputs/text/index.js +7 -144
  61. package/dist/ui/inputs/text/index.mjs +2 -4
  62. package/dist/ui/inputs/text/text.js +7 -144
  63. package/dist/ui/inputs/text/text.mjs +2 -4
  64. package/dist/ui/layout/container/container.mjs +64 -71
  65. package/dist/ui/layout/container/index.mjs +64 -71
  66. package/dist/ui/layout/index.mjs +69 -76
  67. package/dist/ui/layout/page/index.mjs +3 -3
  68. package/dist/ui/layout/page/page-loading.mjs +3 -3
  69. package/dist/ui/layout/page/section-loading.mjs +3 -3
  70. package/dist/ui/navigation/index.mjs +5 -5
  71. package/dist/ui/overlays/index.mjs +4 -4
  72. package/dist/ui/provider/index.mjs +3 -3
  73. package/dist/ui/provider/ui-provider.mjs +3 -3
  74. package/dist/ui/theme/colors/common.mjs +3 -3
  75. package/dist/ui/theme/colors/index.mjs +6 -6
  76. package/dist/ui/theme/colors/semantic.mjs +4 -4
  77. package/dist/ui/theme/colors.mjs +6 -6
  78. package/dist/ui/theme/index.mjs +6 -6
  79. package/dist/ui/theme/theme.mjs +6 -6
  80. package/package.json +1 -1
  81. package/dist/chunk-2UHA3DYG.mjs +0 -62
  82. package/dist/chunk-C2VWADF5.mjs +0 -34
  83. package/dist/chunk-CUEG2BFV.mjs +0 -34
  84. package/dist/chunk-MCQGBAUS.mjs +0 -73
  85. package/dist/chunk-NSU66J5E.mjs +0 -59
  86. package/dist/chunk-SEJXJZSK.mjs +0 -64
  87. package/dist/chunk-TUIN5YJW.mjs +0 -33
  88. package/dist/chunk-UQAG7TKJ.mjs +0 -1
  89. package/dist/chunk-VXYV37IM.mjs +0 -74
  90. package/dist/ui/form/rhf/fields/search-field.d.ts +0 -10
  91. package/dist/ui/form/rhf/fields/search-field.js +0 -296
  92. package/dist/ui/form/rhf/fields/search-field.mjs +0 -37
  93. package/dist/ui/inputs/clear-button.d.ts +0 -5
  94. package/dist/ui/inputs/clear-button.js +0 -67
  95. package/dist/ui/inputs/clear-button.mjs +0 -8
  96. package/dist/ui/inputs/input/use-input.d.ts +0 -19
  97. package/dist/ui/inputs/input/use-input.js +0 -82
  98. package/dist/ui/inputs/input/use-input.mjs +0 -7
  99. package/dist/ui/inputs/search/index.d.ts +0 -1
  100. package/dist/ui/inputs/search/index.js +0 -270
  101. package/dist/ui/inputs/search/index.mjs +0 -13
  102. package/dist/ui/inputs/search/search.d.ts +0 -7
  103. package/dist/ui/inputs/search/search.js +0 -268
  104. package/dist/ui/inputs/search/search.mjs +0 -12
  105. package/dist/ui/inputs/search/use-search.d.ts +0 -12
  106. package/dist/ui/inputs/search/use-search.js +0 -57
  107. package/dist/ui/inputs/search/use-search.mjs +0 -7
  108. package/dist/ui/inputs/select/use-select.d.ts +0 -17
  109. package/dist/ui/inputs/select/use-select.js +0 -85
  110. package/dist/ui/inputs/select/use-select.mjs +0 -7
  111. package/dist/{chunk-IXPMUODA.mjs → chunk-5WDV3PDI.mjs} +6 -6
  112. /package/dist/{chunk-5RNCFTW5.mjs → chunk-CZEO3U25.mjs} +0 -0
  113. /package/dist/{chunk-PTCNYQVY.mjs → chunk-Q6JSJOU4.mjs} +0 -0
@@ -34,149 +34,39 @@ __export(select_exports, {
34
34
  Select: () => Select
35
35
  });
36
36
  module.exports = __toCommonJS(select_exports);
37
- var import_react3 = __toESM(require("react"));
38
- var import_select = require("@heroui/select");
39
- var import_tailwind_variants = require("tailwind-variants");
40
-
41
- // src/ui/inputs/clear-button.tsx
42
37
  var import_react = __toESM(require("react"));
43
- var import_button = require("@heroui/button");
44
- var import_lucide_react = require("lucide-react");
38
+ var import_select = require("@heroui/select");
45
39
  var import_jsx_runtime = require("react/jsx-runtime");
46
- var ClearButton = import_react.default.forwardRef(
47
- ({ onClear }, ref) => {
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
- }
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]
64
59
  );
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)(
60
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
160
61
  import_select.Select,
161
62
  {
162
63
  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
- ] }),
173
64
  items,
174
65
  selectedKeys,
175
66
  selectionMode,
176
- variant,
177
67
  onSelectionChange: handleSelectionChange,
178
68
  ...props,
179
- children: (item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_select.SelectItem, { children: item.label }, item.key)
69
+ children: (item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectItem, { children: item.label }, item.key)
180
70
  }
181
71
  );
182
72
  }
@@ -1,9 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  Select
4
- } from "../../../chunk-VXYV37IM.mjs";
5
- import "../../../chunk-2UHA3DYG.mjs";
6
- import "../../../chunk-TUIN5YJW.mjs";
4
+ } from "../../../chunk-3YOW5DEZ.mjs";
7
5
  export {
8
6
  Select
9
7
  };
@@ -36,158 +36,21 @@ __export(text_exports, {
36
36
  module.exports = __toCommonJS(text_exports);
37
37
 
38
38
  // src/ui/inputs/text/text.tsx
39
- var import_react4 = __toESM(require("react"));
39
+ var import_react2 = __toESM(require("react"));
40
40
 
41
41
  // src/ui/inputs/input/input.tsx
42
- var import_react3 = __toESM(require("react"));
43
- var import_input = require("@heroui/input");
44
- var import_tailwind_variants = require("tailwind-variants");
45
-
46
- // src/ui/inputs/clear-button.tsx
47
42
  var import_react = __toESM(require("react"));
48
- var import_button = require("@heroui/button");
49
- var import_lucide_react = require("lucide-react");
43
+ var import_input = require("@heroui/input");
50
44
  var import_jsx_runtime = require("react/jsx-runtime");
51
- var ClearButton = import_react.default.forwardRef(
52
- ({ onClear }, ref) => {
53
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
54
- import_button.Button,
55
- {
56
- ref,
57
- isIconOnly: true,
58
- "aria-label": "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C",
59
- as: "span",
60
- className: "opacity-0 transition-opacity group-hover:opacity-100",
61
- color: "default",
62
- radius: "full",
63
- size: "sm",
64
- tabIndex: 0,
65
- variant: "light",
66
- onPress: onClear,
67
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.XIcon, { className: "size-4 text-default-500" })
68
- }
69
- );
70
- }
71
- );
72
- ClearButton.displayName = "TeachInUI.ClearButton";
73
-
74
- // src/ui/inputs/input/use-input.ts
75
- var import_react2 = require("react");
76
- function useInput({
77
- value,
78
- defaultValue,
79
- onValueChange,
80
- onClear,
81
- isReadOnly,
82
- isClearable = true,
83
- ref
84
- }) {
85
- const inputRef = (0, import_react2.useRef)(null);
86
- const [internalValue, setInternalValue] = (0, import_react2.useState)(defaultValue != null ? defaultValue : "");
87
- const isControlled = value !== void 0;
88
- const currentValue = isControlled ? value : internalValue;
89
- const hasValue = String(currentValue).length > 0;
90
- const handleValueChange = (0, import_react2.useCallback)(
91
- (newValue) => {
92
- if (!isControlled) {
93
- setInternalValue(newValue);
94
- }
95
- onValueChange == null ? void 0 : onValueChange(newValue);
96
- },
97
- [isControlled, onValueChange]
98
- );
99
- const handleClear = (0, import_react2.useCallback)(() => {
100
- var _a;
101
- onClear == null ? void 0 : onClear();
102
- handleValueChange("");
103
- (_a = inputRef.current) == null ? void 0 : _a.focus();
104
- }, [onClear, handleValueChange]);
105
- const mergedRef = (0, import_react2.useCallback)(
106
- (node) => {
107
- inputRef.current = node;
108
- if (typeof ref === "function") {
109
- ref(node);
110
- } else if (ref) {
111
- ref.current = node;
112
- }
113
- },
114
- [ref]
115
- );
116
- const showClearButton = hasValue && !isReadOnly && isClearable;
117
- return {
118
- inputRef,
119
- currentValue,
120
- hasValue,
121
- handleValueChange,
122
- handleClear,
123
- mergedRef,
124
- showClearButton
125
- };
126
- }
127
-
128
- // src/ui/inputs/input/input.tsx
129
- var import_jsx_runtime2 = require("react/jsx-runtime");
130
- var inputWrapperVariants = (0, import_tailwind_variants.tv)({
131
- variants: {
132
- variant: {
133
- flat: "",
134
- underlined: "",
135
- bordered: "border-1",
136
- faded: "border-1"
137
- }
138
- }
45
+ var Input = import_react.default.forwardRef(({ ...props }, ref) => {
46
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_input.Input, { ref, ...props });
139
47
  });
140
- var Input = import_react3.default.forwardRef(
141
- ({
142
- value,
143
- defaultValue,
144
- onClear,
145
- onValueChange,
146
- variant,
147
- classNames,
148
- endContent,
149
- isReadOnly,
150
- isClearable,
151
- ...props
152
- }, ref) => {
153
- const { currentValue, handleValueChange, handleClear, mergedRef, showClearButton } = useInput({
154
- value,
155
- defaultValue,
156
- onValueChange,
157
- onClear,
158
- isReadOnly,
159
- isClearable,
160
- ref
161
- });
162
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
163
- import_input.Input,
164
- {
165
- ref: mergedRef,
166
- classNames: {
167
- ...classNames,
168
- inputWrapper: inputWrapperVariants({ variant }),
169
- innerWrapper: "group"
170
- },
171
- defaultValue,
172
- endContent: (endContent || showClearButton) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-1", children: [
173
- endContent,
174
- showClearButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ClearButton, { onClear: handleClear })
175
- ] }),
176
- isReadOnly,
177
- value: currentValue,
178
- variant,
179
- onValueChange: handleValueChange,
180
- ...props
181
- }
182
- );
183
- }
184
- );
185
48
  Input.displayName = "TeachInUI.Input";
186
49
 
187
50
  // src/ui/inputs/text/text.tsx
188
- var import_jsx_runtime3 = require("react/jsx-runtime");
189
- var Text = import_react4.default.forwardRef(({ ...props }, ref) => {
190
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Input, { ref, type: "text", ...props });
51
+ var import_jsx_runtime2 = require("react/jsx-runtime");
52
+ var Text = import_react2.default.forwardRef(({ ...props }, ref) => {
53
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Input, { ref, type: "text", ...props });
191
54
  });
192
55
  Text.displayName = "TeachInUI.Text";
193
56
  // Annotate the CommonJS export names for ESM import in node:
@@ -2,11 +2,9 @@
2
2
  import "../../../chunk-DUQFM3QS.mjs";
3
3
  import {
4
4
  Text
5
- } from "../../../chunk-KTWHCUYV.mjs";
5
+ } from "../../../chunk-KTUGFQWJ.mjs";
6
6
  import "../../../chunk-ZRHEFEFS.mjs";
7
- import "../../../chunk-MCQGBAUS.mjs";
8
- import "../../../chunk-NSU66J5E.mjs";
9
- import "../../../chunk-TUIN5YJW.mjs";
7
+ import "../../../chunk-V2G5QHZZ.mjs";
10
8
  export {
11
9
  Text
12
10
  };
@@ -34,158 +34,21 @@ __export(text_exports, {
34
34
  Text: () => Text
35
35
  });
36
36
  module.exports = __toCommonJS(text_exports);
37
- var import_react4 = __toESM(require("react"));
37
+ var import_react2 = __toESM(require("react"));
38
38
 
39
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
40
  var import_react = __toESM(require("react"));
46
- var import_button = require("@heroui/button");
47
- var import_lucide_react = require("lucide-react");
41
+ var import_input = require("@heroui/input");
48
42
  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
- }
43
+ var Input = import_react.default.forwardRef(({ ...props }, ref) => {
44
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_input.Input, { ref, ...props });
137
45
  });
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
46
  Input.displayName = "TeachInUI.Input";
184
47
 
185
48
  // src/ui/inputs/text/text.tsx
186
- var import_jsx_runtime3 = require("react/jsx-runtime");
187
- var Text = import_react4.default.forwardRef(({ ...props }, ref) => {
188
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Input, { ref, type: "text", ...props });
49
+ var import_jsx_runtime2 = require("react/jsx-runtime");
50
+ var Text = import_react2.default.forwardRef(({ ...props }, ref) => {
51
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Input, { ref, type: "text", ...props });
189
52
  });
190
53
  Text.displayName = "TeachInUI.Text";
191
54
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,11 +1,9 @@
1
1
  "use client";
2
2
  import {
3
3
  Text
4
- } from "../../../chunk-KTWHCUYV.mjs";
4
+ } from "../../../chunk-KTUGFQWJ.mjs";
5
5
  import "../../../chunk-ZRHEFEFS.mjs";
6
- import "../../../chunk-MCQGBAUS.mjs";
7
- import "../../../chunk-NSU66J5E.mjs";
8
- import "../../../chunk-TUIN5YJW.mjs";
6
+ import "../../../chunk-V2G5QHZZ.mjs";
9
7
  export {
10
8
  Text
11
9
  };