@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
@@ -36,39 +36,149 @@ __export(select_exports, {
36
36
  module.exports = __toCommonJS(select_exports);
37
37
 
38
38
  // src/ui/inputs/select/select.tsx
39
- var import_react = __toESM(require("react"));
39
+ var import_react3 = __toESM(require("react"));
40
40
  var import_select = require("@heroui/select");
41
+ var import_tailwind_variants = require("tailwind-variants");
42
+
43
+ // src/ui/inputs/clear-button.tsx
44
+ var import_react = __toESM(require("react"));
45
+ var import_button = require("@heroui/button");
46
+ var import_lucide_react = require("lucide-react");
41
47
  var import_jsx_runtime = require("react/jsx-runtime");
42
- var Select = import_react.default.forwardRef(
43
- ({ value, items, onChange, selectionMode, ...props }, ref) => {
44
- const isMultiple = selectionMode === "multiple";
45
- const selectedKeys = import_react.default.useMemo(() => {
46
- if (value == null) return /* @__PURE__ */ new Set();
47
- return new Set(Array.isArray(value) ? value : [value]);
48
- }, [value]);
49
- const handleSelectionChange = import_react.default.useCallback(
50
- (keys) => {
51
- var _a;
52
- if (keys === "all") return;
53
- const selected = Array.from(keys).filter((key) => typeof key === "string");
54
- if (isMultiple) {
55
- onChange == null ? void 0 : onChange(selected);
56
- } else {
57
- onChange == null ? void 0 : onChange((_a = selected[0]) != null ? _a : null);
58
- }
59
- },
60
- [onChange, isMultiple]
61
- );
48
+ var ClearButton = import_react.default.forwardRef(
49
+ ({ onClear }, ref) => {
62
50
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
51
+ import_button.Button,
52
+ {
53
+ ref,
54
+ isIconOnly: true,
55
+ "aria-label": "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C",
56
+ as: "span",
57
+ className: "opacity-0 transition-opacity group-hover:opacity-100",
58
+ color: "default",
59
+ radius: "full",
60
+ size: "sm",
61
+ tabIndex: 0,
62
+ variant: "light",
63
+ onPress: onClear,
64
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.XIcon, { className: "size-4 text-default-500" })
65
+ }
66
+ );
67
+ }
68
+ );
69
+ ClearButton.displayName = "TeachInUI.ClearButton";
70
+
71
+ // src/ui/inputs/select/use-select.ts
72
+ var import_react2 = require("react");
73
+ function useSelect({
74
+ value,
75
+ onChange,
76
+ onClear,
77
+ selectionMode,
78
+ isClearable = true
79
+ }) {
80
+ const isMultiple = selectionMode === "multiple";
81
+ const [internalValue, setInternalValue] = (0, import_react2.useState)(
82
+ isMultiple ? [] : null
83
+ );
84
+ const isControlled = value !== void 0;
85
+ const currentValue = isControlled ? value : internalValue;
86
+ const hasValue = currentValue != null && (Array.isArray(currentValue) ? currentValue.length > 0 : currentValue !== "");
87
+ const handleChange = (0, import_react2.useCallback)(
88
+ (newValue) => {
89
+ if (!isControlled) {
90
+ setInternalValue(newValue);
91
+ }
92
+ if (isMultiple) {
93
+ onChange == null ? void 0 : onChange(newValue);
94
+ } else {
95
+ onChange == null ? void 0 : onChange(newValue);
96
+ }
97
+ },
98
+ [isControlled, onChange, isMultiple]
99
+ );
100
+ const handleClear = (0, import_react2.useCallback)(() => {
101
+ onClear == null ? void 0 : onClear();
102
+ handleChange(isMultiple ? [] : null);
103
+ }, [onClear, handleChange, isMultiple]);
104
+ const selectedKeys = (0, import_react2.useMemo)(() => {
105
+ if (currentValue == null) return /* @__PURE__ */ new Set();
106
+ return new Set(Array.isArray(currentValue) ? currentValue : [currentValue]);
107
+ }, [currentValue]);
108
+ const handleSelectionChange = (0, import_react2.useCallback)(
109
+ (keys) => {
110
+ var _a;
111
+ if (keys === "all") return;
112
+ const selected = Array.from(keys).filter((key) => typeof key === "string");
113
+ handleChange(isMultiple ? selected : (_a = selected[0]) != null ? _a : null);
114
+ },
115
+ [handleChange, isMultiple]
116
+ );
117
+ const showClearButton = hasValue && isClearable;
118
+ return {
119
+ currentValue,
120
+ hasValue,
121
+ selectedKeys,
122
+ handleSelectionChange,
123
+ handleClear,
124
+ showClearButton
125
+ };
126
+ }
127
+
128
+ // src/ui/inputs/select/select.tsx
129
+ var import_jsx_runtime2 = require("react/jsx-runtime");
130
+ var selectWrapperVariants = (0, import_tailwind_variants.tv)({
131
+ variants: {
132
+ variant: {
133
+ flat: "",
134
+ underlined: "",
135
+ bordered: "border-1",
136
+ faded: "border-1"
137
+ }
138
+ }
139
+ });
140
+ var Select = import_react3.default.forwardRef(
141
+ ({
142
+ value,
143
+ defaultSelectedKeys,
144
+ items,
145
+ onChange,
146
+ selectionMode,
147
+ onClear,
148
+ variant,
149
+ classNames,
150
+ endContent,
151
+ isClearable,
152
+ ...props
153
+ }, ref) => {
154
+ const { selectedKeys, handleSelectionChange, handleClear, showClearButton } = useSelect({
155
+ value,
156
+ onChange,
157
+ onClear,
158
+ selectionMode,
159
+ isClearable
160
+ });
161
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
63
162
  import_select.Select,
64
163
  {
65
164
  ref,
165
+ classNames: {
166
+ ...classNames,
167
+ trigger: selectWrapperVariants({ variant }),
168
+ innerWrapper: "group"
169
+ },
170
+ defaultSelectedKeys,
171
+ endContent: (endContent || showClearButton) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-1", children: [
172
+ endContent,
173
+ showClearButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ClearButton, { onClear: handleClear })
174
+ ] }),
66
175
  items,
67
176
  selectedKeys,
68
177
  selectionMode,
178
+ variant,
69
179
  onSelectionChange: handleSelectionChange,
70
180
  ...props,
71
- children: (item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectItem, { children: item.label }, item.key)
181
+ children: (item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_select.SelectItem, { children: item.label }, item.key)
72
182
  }
73
183
  );
74
184
  }
@@ -2,7 +2,9 @@
2
2
  import "../../../chunk-AQ3ISJKU.mjs";
3
3
  import {
4
4
  Select
5
- } from "../../../chunk-3YOW5DEZ.mjs";
5
+ } from "../../../chunk-VXYV37IM.mjs";
6
+ import "../../../chunk-2UHA3DYG.mjs";
7
+ import "../../../chunk-TUIN5YJW.mjs";
6
8
  export {
7
9
  Select
8
10
  };
@@ -9,18 +9,22 @@ export type SelectProps = (BaseSelectProps & {
9
9
  selectionMode?: "single";
10
10
  value?: string;
11
11
  onChange?: (value: string | null) => void;
12
+ onClear?: () => void;
12
13
  }) | (BaseSelectProps & {
13
14
  selectionMode: "multiple";
14
15
  value?: string[];
15
16
  onChange?: (value: string[]) => void;
17
+ onClear?: () => void;
16
18
  });
17
19
  export declare const Select: React.ForwardRefExoticComponent<(Omit<BaseSelectProps & {
18
20
  selectionMode?: "single";
19
21
  value?: string;
20
22
  onChange?: (value: string | null) => void;
23
+ onClear?: () => void;
21
24
  }, "ref"> | Omit<BaseSelectProps & {
22
25
  selectionMode: "multiple";
23
26
  value?: string[];
24
27
  onChange?: (value: string[]) => void;
28
+ onClear?: () => void;
25
29
  }, "ref">) & React.RefAttributes<HTMLSelectElement>>;
26
30
  export {};
@@ -34,39 +34,149 @@ __export(select_exports, {
34
34
  Select: () => Select
35
35
  });
36
36
  module.exports = __toCommonJS(select_exports);
37
- var import_react = __toESM(require("react"));
37
+ var import_react3 = __toESM(require("react"));
38
38
  var import_select = require("@heroui/select");
39
+ var import_tailwind_variants = require("tailwind-variants");
40
+
41
+ // src/ui/inputs/clear-button.tsx
42
+ var import_react = __toESM(require("react"));
43
+ var import_button = require("@heroui/button");
44
+ var import_lucide_react = require("lucide-react");
39
45
  var import_jsx_runtime = require("react/jsx-runtime");
40
- var Select = import_react.default.forwardRef(
41
- ({ value, items, onChange, selectionMode, ...props }, ref) => {
42
- const isMultiple = selectionMode === "multiple";
43
- const selectedKeys = import_react.default.useMemo(() => {
44
- if (value == null) return /* @__PURE__ */ new Set();
45
- return new Set(Array.isArray(value) ? value : [value]);
46
- }, [value]);
47
- const handleSelectionChange = import_react.default.useCallback(
48
- (keys) => {
49
- var _a;
50
- if (keys === "all") return;
51
- const selected = Array.from(keys).filter((key) => typeof key === "string");
52
- if (isMultiple) {
53
- onChange == null ? void 0 : onChange(selected);
54
- } else {
55
- onChange == null ? void 0 : onChange((_a = selected[0]) != null ? _a : null);
56
- }
57
- },
58
- [onChange, isMultiple]
59
- );
46
+ var ClearButton = import_react.default.forwardRef(
47
+ ({ onClear }, ref) => {
60
48
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49
+ import_button.Button,
50
+ {
51
+ ref,
52
+ isIconOnly: true,
53
+ "aria-label": "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C",
54
+ as: "span",
55
+ className: "opacity-0 transition-opacity group-hover:opacity-100",
56
+ color: "default",
57
+ radius: "full",
58
+ size: "sm",
59
+ tabIndex: 0,
60
+ variant: "light",
61
+ onPress: onClear,
62
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.XIcon, { className: "size-4 text-default-500" })
63
+ }
64
+ );
65
+ }
66
+ );
67
+ ClearButton.displayName = "TeachInUI.ClearButton";
68
+
69
+ // src/ui/inputs/select/use-select.ts
70
+ var import_react2 = require("react");
71
+ function useSelect({
72
+ value,
73
+ onChange,
74
+ onClear,
75
+ selectionMode,
76
+ isClearable = true
77
+ }) {
78
+ const isMultiple = selectionMode === "multiple";
79
+ const [internalValue, setInternalValue] = (0, import_react2.useState)(
80
+ isMultiple ? [] : null
81
+ );
82
+ const isControlled = value !== void 0;
83
+ const currentValue = isControlled ? value : internalValue;
84
+ const hasValue = currentValue != null && (Array.isArray(currentValue) ? currentValue.length > 0 : currentValue !== "");
85
+ const handleChange = (0, import_react2.useCallback)(
86
+ (newValue) => {
87
+ if (!isControlled) {
88
+ setInternalValue(newValue);
89
+ }
90
+ if (isMultiple) {
91
+ onChange == null ? void 0 : onChange(newValue);
92
+ } else {
93
+ onChange == null ? void 0 : onChange(newValue);
94
+ }
95
+ },
96
+ [isControlled, onChange, isMultiple]
97
+ );
98
+ const handleClear = (0, import_react2.useCallback)(() => {
99
+ onClear == null ? void 0 : onClear();
100
+ handleChange(isMultiple ? [] : null);
101
+ }, [onClear, handleChange, isMultiple]);
102
+ const selectedKeys = (0, import_react2.useMemo)(() => {
103
+ if (currentValue == null) return /* @__PURE__ */ new Set();
104
+ return new Set(Array.isArray(currentValue) ? currentValue : [currentValue]);
105
+ }, [currentValue]);
106
+ const handleSelectionChange = (0, import_react2.useCallback)(
107
+ (keys) => {
108
+ var _a;
109
+ if (keys === "all") return;
110
+ const selected = Array.from(keys).filter((key) => typeof key === "string");
111
+ handleChange(isMultiple ? selected : (_a = selected[0]) != null ? _a : null);
112
+ },
113
+ [handleChange, isMultiple]
114
+ );
115
+ const showClearButton = hasValue && isClearable;
116
+ return {
117
+ currentValue,
118
+ hasValue,
119
+ selectedKeys,
120
+ handleSelectionChange,
121
+ handleClear,
122
+ showClearButton
123
+ };
124
+ }
125
+
126
+ // src/ui/inputs/select/select.tsx
127
+ var import_jsx_runtime2 = require("react/jsx-runtime");
128
+ var selectWrapperVariants = (0, import_tailwind_variants.tv)({
129
+ variants: {
130
+ variant: {
131
+ flat: "",
132
+ underlined: "",
133
+ bordered: "border-1",
134
+ faded: "border-1"
135
+ }
136
+ }
137
+ });
138
+ var Select = import_react3.default.forwardRef(
139
+ ({
140
+ value,
141
+ defaultSelectedKeys,
142
+ items,
143
+ onChange,
144
+ selectionMode,
145
+ onClear,
146
+ variant,
147
+ classNames,
148
+ endContent,
149
+ isClearable,
150
+ ...props
151
+ }, ref) => {
152
+ const { selectedKeys, handleSelectionChange, handleClear, showClearButton } = useSelect({
153
+ value,
154
+ onChange,
155
+ onClear,
156
+ selectionMode,
157
+ isClearable
158
+ });
159
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
61
160
  import_select.Select,
62
161
  {
63
162
  ref,
163
+ classNames: {
164
+ ...classNames,
165
+ trigger: selectWrapperVariants({ variant }),
166
+ innerWrapper: "group"
167
+ },
168
+ defaultSelectedKeys,
169
+ endContent: (endContent || showClearButton) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-1", children: [
170
+ endContent,
171
+ showClearButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ClearButton, { onClear: handleClear })
172
+ ] }),
64
173
  items,
65
174
  selectedKeys,
66
175
  selectionMode,
176
+ variant,
67
177
  onSelectionChange: handleSelectionChange,
68
178
  ...props,
69
- children: (item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectItem, { children: item.label }, item.key)
179
+ children: (item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_select.SelectItem, { children: item.label }, item.key)
70
180
  }
71
181
  );
72
182
  }
@@ -1,7 +1,9 @@
1
1
  "use client";
2
2
  import {
3
3
  Select
4
- } from "../../../chunk-3YOW5DEZ.mjs";
4
+ } from "../../../chunk-VXYV37IM.mjs";
5
+ import "../../../chunk-2UHA3DYG.mjs";
6
+ import "../../../chunk-TUIN5YJW.mjs";
5
7
  export {
6
8
  Select
7
9
  };
@@ -0,0 +1,17 @@
1
+ interface UseSelectProps {
2
+ value?: string | string[];
3
+ defaultSelectedKeys?: "all" | Iterable<React.Key>;
4
+ onChange?: ((value: string | null) => void) | ((value: string[]) => void);
5
+ onClear?: () => void;
6
+ selectionMode?: "single" | "multiple";
7
+ isClearable?: boolean;
8
+ }
9
+ export declare function useSelect({ value, onChange, onClear, selectionMode, isClearable, }: UseSelectProps): {
10
+ currentValue: string | string[] | null;
11
+ hasValue: boolean;
12
+ selectedKeys: Set<string>;
13
+ handleSelectionChange: (keys: "all" | Set<React.Key>) => void;
14
+ handleClear: () => void;
15
+ showClearButton: boolean;
16
+ };
17
+ export {};
@@ -0,0 +1,85 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/ui/inputs/select/use-select.ts
22
+ var use_select_exports = {};
23
+ __export(use_select_exports, {
24
+ useSelect: () => useSelect
25
+ });
26
+ module.exports = __toCommonJS(use_select_exports);
27
+ var import_react = require("react");
28
+ function useSelect({
29
+ value,
30
+ onChange,
31
+ onClear,
32
+ selectionMode,
33
+ isClearable = true
34
+ }) {
35
+ const isMultiple = selectionMode === "multiple";
36
+ const [internalValue, setInternalValue] = (0, import_react.useState)(
37
+ isMultiple ? [] : null
38
+ );
39
+ const isControlled = value !== void 0;
40
+ const currentValue = isControlled ? value : internalValue;
41
+ const hasValue = currentValue != null && (Array.isArray(currentValue) ? currentValue.length > 0 : currentValue !== "");
42
+ const handleChange = (0, import_react.useCallback)(
43
+ (newValue) => {
44
+ if (!isControlled) {
45
+ setInternalValue(newValue);
46
+ }
47
+ if (isMultiple) {
48
+ onChange == null ? void 0 : onChange(newValue);
49
+ } else {
50
+ onChange == null ? void 0 : onChange(newValue);
51
+ }
52
+ },
53
+ [isControlled, onChange, isMultiple]
54
+ );
55
+ const handleClear = (0, import_react.useCallback)(() => {
56
+ onClear == null ? void 0 : onClear();
57
+ handleChange(isMultiple ? [] : null);
58
+ }, [onClear, handleChange, isMultiple]);
59
+ const selectedKeys = (0, import_react.useMemo)(() => {
60
+ if (currentValue == null) return /* @__PURE__ */ new Set();
61
+ return new Set(Array.isArray(currentValue) ? currentValue : [currentValue]);
62
+ }, [currentValue]);
63
+ const handleSelectionChange = (0, import_react.useCallback)(
64
+ (keys) => {
65
+ var _a;
66
+ if (keys === "all") return;
67
+ const selected = Array.from(keys).filter((key) => typeof key === "string");
68
+ handleChange(isMultiple ? selected : (_a = selected[0]) != null ? _a : null);
69
+ },
70
+ [handleChange, isMultiple]
71
+ );
72
+ const showClearButton = hasValue && isClearable;
73
+ return {
74
+ currentValue,
75
+ hasValue,
76
+ selectedKeys,
77
+ handleSelectionChange,
78
+ handleClear,
79
+ showClearButton
80
+ };
81
+ }
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ useSelect
85
+ });
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import {
3
+ useSelect
4
+ } from "../../../chunk-2UHA3DYG.mjs";
5
+ export {
6
+ useSelect
7
+ };
@@ -36,21 +36,158 @@ __export(text_exports, {
36
36
  module.exports = __toCommonJS(text_exports);
37
37
 
38
38
  // src/ui/inputs/text/text.tsx
39
- var import_react2 = __toESM(require("react"));
39
+ var import_react4 = __toESM(require("react"));
40
40
 
41
41
  // src/ui/inputs/input/input.tsx
42
- var import_react = __toESM(require("react"));
42
+ var import_react3 = __toESM(require("react"));
43
43
  var import_input = require("@heroui/input");
44
+ var import_tailwind_variants = require("tailwind-variants");
45
+
46
+ // src/ui/inputs/clear-button.tsx
47
+ var import_react = __toESM(require("react"));
48
+ var import_button = require("@heroui/button");
49
+ var import_lucide_react = require("lucide-react");
44
50
  var import_jsx_runtime = require("react/jsx-runtime");
45
- var Input = import_react.default.forwardRef(({ ...props }, ref) => {
46
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_input.Input, { ref, ...props });
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
+ }
47
139
  });
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
+ );
48
185
  Input.displayName = "TeachInUI.Input";
49
186
 
50
187
  // src/ui/inputs/text/text.tsx
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 });
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 });
54
191
  });
55
192
  Text.displayName = "TeachInUI.Text";
56
193
  // Annotate the CommonJS export names for ESM import in node:
@@ -2,9 +2,11 @@
2
2
  import "../../../chunk-DUQFM3QS.mjs";
3
3
  import {
4
4
  Text
5
- } from "../../../chunk-KTUGFQWJ.mjs";
5
+ } from "../../../chunk-KTWHCUYV.mjs";
6
6
  import "../../../chunk-ZRHEFEFS.mjs";
7
- import "../../../chunk-V2G5QHZZ.mjs";
7
+ import "../../../chunk-MCQGBAUS.mjs";
8
+ import "../../../chunk-NSU66J5E.mjs";
9
+ import "../../../chunk-TUIN5YJW.mjs";
8
10
  export {
9
11
  Text
10
12
  };