@teach-in/react 1.4.0 → 1.6.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/dist/{chunk-2UHA3DYG.mjs → chunk-6BWSC6ZH.mjs} +3 -10
- package/dist/chunk-7WIZONLU.mjs +81 -0
- package/dist/chunk-ALGSVEUS.mjs +1 -0
- package/dist/chunk-BHOCYKBI.mjs +81 -0
- package/dist/{chunk-VXYV37IM.mjs → chunk-C5FQB2UN.mjs} +16 -8
- package/dist/{chunk-CKJ5U5Q4.mjs → chunk-DEKPRZIQ.mjs} +1 -1
- package/dist/chunk-GEPCSZCU.mjs +71 -0
- package/dist/chunk-GTE5VEBV.mjs +68 -0
- package/dist/{chunk-UFYLYN5Z.mjs → chunk-QFWSQOF6.mjs} +20 -2
- package/dist/chunk-VDPROXMN.mjs +57 -0
- package/dist/{chunk-J3OZNLTZ.mjs → chunk-WG4IPOHE.mjs} +5 -5
- package/dist/{chunk-R46SWVWL.mjs → chunk-ZK6VZMUJ.mjs} +1 -1
- package/dist/index.js +536 -253
- package/dist/index.mjs +140 -132
- package/dist/ui/data/index.js +56 -7
- package/dist/ui/data/index.mjs +12 -10
- package/dist/ui/data/user/index.js +51 -2
- package/dist/ui/data/user/index.mjs +3 -1
- package/dist/ui/data/user/user.d.ts +24 -2
- package/dist/ui/data/user/user.js +52 -2
- package/dist/ui/data/user/user.mjs +4 -1
- package/dist/ui/feedback/index.mjs +7 -7
- package/dist/ui/form/index.js +76 -18
- package/dist/ui/form/index.mjs +25 -20
- package/dist/ui/form/rhf/fields/autocomplete-field.mjs +20 -15
- package/dist/ui/form/rhf/fields/checkbox-field.mjs +20 -15
- package/dist/ui/form/rhf/fields/date-picker-field.mjs +20 -15
- package/dist/ui/form/rhf/fields/email-field.js +58 -3
- package/dist/ui/form/rhf/fields/email-field.mjs +21 -16
- package/dist/ui/form/rhf/fields/index.js +76 -18
- package/dist/ui/form/rhf/fields/index.mjs +22 -17
- package/dist/ui/form/rhf/fields/input-field.mjs +20 -15
- package/dist/ui/form/rhf/fields/radio-field.mjs +20 -15
- package/dist/ui/form/rhf/fields/search-field.mjs +20 -15
- package/dist/ui/form/rhf/fields/select-field.js +18 -15
- package/dist/ui/form/rhf/fields/select-field.mjs +21 -16
- package/dist/ui/form/rhf/fields/switch-field.mjs +20 -15
- package/dist/ui/form/rhf/fields/text-field.mjs +20 -15
- package/dist/ui/form/rhf/fields/textarea-field.mjs +20 -15
- package/dist/ui/form/rhf/index.js +76 -18
- package/dist/ui/form/rhf/index.mjs +22 -17
- package/dist/ui/format/index.mjs +12 -12
- package/dist/ui/index.js +536 -253
- package/dist/ui/index.mjs +140 -132
- package/dist/ui/inputs/checkbox/index.mjs +3 -3
- package/dist/ui/inputs/email/email.js +58 -3
- package/dist/ui/inputs/email/email.mjs +1 -1
- package/dist/ui/inputs/email/index.js +58 -3
- package/dist/ui/inputs/email/index.mjs +1 -1
- package/dist/ui/inputs/index.d.ts +1 -0
- package/dist/ui/inputs/index.js +305 -69
- package/dist/ui/inputs/index.mjs +35 -25
- package/dist/ui/inputs/number/index.d.ts +1 -0
- package/dist/ui/inputs/number/index.js +218 -0
- package/dist/ui/inputs/number/index.mjs +12 -0
- package/dist/ui/inputs/number/number.d.ts +12 -0
- package/dist/ui/inputs/number/number.js +219 -0
- package/dist/ui/inputs/number/number.mjs +13 -0
- package/dist/ui/inputs/number/use-number.d.ts +20 -0
- package/dist/ui/inputs/number/use-number.js +104 -0
- package/dist/ui/inputs/number/use-number.mjs +7 -0
- package/dist/ui/inputs/select/index.d.ts +1 -1
- package/dist/ui/inputs/select/index.js +23 -17
- package/dist/ui/inputs/select/index.mjs +8 -4
- package/dist/ui/inputs/select/select.d.ts +11 -22
- package/dist/ui/inputs/select/select.js +23 -17
- package/dist/ui/inputs/select/select.mjs +8 -4
- package/dist/ui/inputs/select/use-select.d.ts +0 -1
- package/dist/ui/inputs/select/use-select.js +2 -9
- package/dist/ui/inputs/select/use-select.mjs +1 -1
- package/dist/ui/inputs/switch/favorite-switch.d.ts +23 -2
- package/dist/ui/inputs/switch/favorite-switch.js +34 -4
- package/dist/ui/inputs/switch/favorite-switch.mjs +1 -1
- package/dist/ui/inputs/switch/index.js +34 -4
- package/dist/ui/inputs/switch/index.mjs +1 -1
- package/dist/ui/layout/container/container.mjs +67 -64
- package/dist/ui/layout/container/index.mjs +67 -64
- package/dist/ui/layout/index.js +7 -7
- package/dist/ui/layout/index.mjs +71 -68
- package/dist/ui/layout/page/index.mjs +4 -4
- package/dist/ui/layout/page/page-loading.mjs +4 -4
- package/dist/ui/layout/page/section-loading.mjs +4 -4
- package/dist/ui/navigation/index.mjs +5 -5
- package/dist/ui/overlays/index.mjs +4 -4
- package/dist/ui/provider/index.mjs +4 -4
- package/dist/ui/provider/ui-provider.mjs +4 -4
- package/dist/ui/surface/bento/bento.d.ts +2 -2
- package/dist/ui/surface/bento/bento.js +5 -5
- package/dist/ui/surface/bento/bento.mjs +1 -1
- package/dist/ui/surface/bento/index.js +5 -5
- package/dist/ui/surface/bento/index.mjs +1 -1
- package/dist/ui/surface/card/card.d.ts +2427 -5
- package/dist/ui/surface/card/card.js +29 -2
- package/dist/ui/surface/card/card.mjs +5 -1
- package/dist/ui/surface/card/index.js +29 -2
- package/dist/ui/surface/card/index.mjs +5 -1
- package/dist/ui/surface/index.js +34 -7
- package/dist/ui/surface/index.mjs +9 -5
- package/dist/ui/theme/colors/index.mjs +1 -1
- package/dist/ui/theme/colors.mjs +1 -1
- package/dist/ui/theme/index.mjs +1 -1
- package/dist/ui/theme/theme.d.ts +2 -1
- package/dist/ui/theme/theme.mjs +1 -1
- package/package.json +13 -9
- package/LICENSE +0 -21
- package/dist/chunk-46SKVFMZ.mjs +0 -16
- package/dist/chunk-E5QSNLSR.mjs +0 -38
- package/dist/chunk-XHCXM5MU.mjs +0 -14
- /package/dist/{chunk-UQAG7TKJ.mjs → chunk-37MCHF7U.mjs} +0 -0
|
@@ -31,7 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/ui/inputs/select/index.ts
|
|
32
32
|
var select_exports = {};
|
|
33
33
|
__export(select_exports, {
|
|
34
|
-
Select: () => Select
|
|
34
|
+
Select: () => Select,
|
|
35
|
+
SelectItem: () => SelectItem
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(select_exports);
|
|
37
38
|
|
|
@@ -68,6 +69,13 @@ var ClearButton = import_react.default.forwardRef(
|
|
|
68
69
|
);
|
|
69
70
|
ClearButton.displayName = "TeachInUI.ClearButton";
|
|
70
71
|
|
|
72
|
+
// src/ui/style/css.ts
|
|
73
|
+
var import_clsx = require("clsx");
|
|
74
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
75
|
+
function cn(...inputs) {
|
|
76
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
77
|
+
}
|
|
78
|
+
|
|
71
79
|
// src/ui/inputs/select/use-select.ts
|
|
72
80
|
var import_react2 = require("react");
|
|
73
81
|
function useSelect({
|
|
@@ -78,24 +86,17 @@ function useSelect({
|
|
|
78
86
|
isClearable = true
|
|
79
87
|
}) {
|
|
80
88
|
const isMultiple = selectionMode === "multiple";
|
|
81
|
-
const [
|
|
82
|
-
isMultiple ? [] : null
|
|
83
|
-
);
|
|
84
|
-
const isControlled = value !== void 0;
|
|
85
|
-
const currentValue = isControlled ? value : internalValue;
|
|
89
|
+
const currentValue = value != null ? value : isMultiple ? [] : null;
|
|
86
90
|
const hasValue = currentValue != null && (Array.isArray(currentValue) ? currentValue.length > 0 : currentValue !== "");
|
|
87
91
|
const handleChange = (0, import_react2.useCallback)(
|
|
88
92
|
(newValue) => {
|
|
89
|
-
if (!isControlled) {
|
|
90
|
-
setInternalValue(newValue);
|
|
91
|
-
}
|
|
92
93
|
if (isMultiple) {
|
|
93
94
|
onChange == null ? void 0 : onChange(newValue);
|
|
94
95
|
} else {
|
|
95
96
|
onChange == null ? void 0 : onChange(newValue);
|
|
96
97
|
}
|
|
97
98
|
},
|
|
98
|
-
[
|
|
99
|
+
[onChange, isMultiple]
|
|
99
100
|
);
|
|
100
101
|
const handleClear = (0, import_react2.useCallback)(() => {
|
|
101
102
|
onClear == null ? void 0 : onClear();
|
|
@@ -140,9 +141,11 @@ var selectWrapperVariants = (0, import_tailwind_variants.tv)({
|
|
|
140
141
|
var Select = import_react3.default.forwardRef(
|
|
141
142
|
({
|
|
142
143
|
value,
|
|
143
|
-
defaultSelectedKeys,
|
|
144
144
|
items,
|
|
145
|
+
children,
|
|
146
|
+
selectedKeys: selectedKeysProp,
|
|
145
147
|
onChange,
|
|
148
|
+
onSelectionChange,
|
|
146
149
|
selectionMode,
|
|
147
150
|
onClear,
|
|
148
151
|
variant,
|
|
@@ -151,6 +154,8 @@ var Select = import_react3.default.forwardRef(
|
|
|
151
154
|
isClearable,
|
|
152
155
|
...props
|
|
153
156
|
}, ref) => {
|
|
157
|
+
const usesExternalSelectionControl = selectedKeysProp !== void 0 || onSelectionChange !== void 0;
|
|
158
|
+
const selectChildren = children != null ? children : (item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_select.SelectItem, { children: item.label }, item.key);
|
|
154
159
|
const { selectedKeys, handleSelectionChange, handleClear, showClearButton } = useSelect({
|
|
155
160
|
value,
|
|
156
161
|
onChange,
|
|
@@ -164,27 +169,28 @@ var Select = import_react3.default.forwardRef(
|
|
|
164
169
|
ref,
|
|
165
170
|
classNames: {
|
|
166
171
|
...classNames,
|
|
167
|
-
trigger: selectWrapperVariants({ variant }),
|
|
172
|
+
trigger: cn(selectWrapperVariants({ variant }), classNames == null ? void 0 : classNames.trigger),
|
|
168
173
|
innerWrapper: "group"
|
|
169
174
|
},
|
|
170
|
-
defaultSelectedKeys,
|
|
171
175
|
endContent: (endContent || showClearButton) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
172
176
|
endContent,
|
|
173
177
|
showClearButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ClearButton, { onClear: handleClear })
|
|
174
178
|
] }),
|
|
175
179
|
items,
|
|
176
|
-
selectedKeys,
|
|
180
|
+
selectedKeys: usesExternalSelectionControl ? selectedKeysProp : selectedKeys,
|
|
177
181
|
selectionMode,
|
|
178
182
|
variant,
|
|
179
|
-
onSelectionChange: handleSelectionChange,
|
|
183
|
+
onSelectionChange: usesExternalSelectionControl ? onSelectionChange : handleSelectionChange,
|
|
180
184
|
...props,
|
|
181
|
-
children:
|
|
185
|
+
children: selectChildren
|
|
182
186
|
}
|
|
183
187
|
);
|
|
184
188
|
}
|
|
185
189
|
);
|
|
186
190
|
Select.displayName = "TeachInUI.Select";
|
|
191
|
+
var SelectItem = import_select.SelectItem;
|
|
187
192
|
// Annotate the CommonJS export names for ESM import in node:
|
|
188
193
|
0 && (module.exports = {
|
|
189
|
-
Select
|
|
194
|
+
Select,
|
|
195
|
+
SelectItem
|
|
190
196
|
});
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../../../chunk-AQ3ISJKU.mjs";
|
|
3
3
|
import {
|
|
4
|
-
Select
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
Select,
|
|
5
|
+
SelectItem
|
|
6
|
+
} from "../../../chunk-C5FQB2UN.mjs";
|
|
7
|
+
import "../../../chunk-6BWSC6ZH.mjs";
|
|
7
8
|
import "../../../chunk-TUIN5YJW.mjs";
|
|
9
|
+
import "../../../chunk-Q6XJI7Q2.mjs";
|
|
10
|
+
import "../../../chunk-LOMRTWX5.mjs";
|
|
8
11
|
export {
|
|
9
|
-
Select
|
|
12
|
+
Select,
|
|
13
|
+
SelectItem
|
|
10
14
|
};
|
|
@@ -4,27 +4,16 @@ interface Item {
|
|
|
4
4
|
key: string;
|
|
5
5
|
label: string;
|
|
6
6
|
}
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
type SelectChildren = NonNullable<HeroUISelectProps<Item>["children"]>;
|
|
8
|
+
type BaseSelectProps = Omit<HeroUISelectProps<Item>, "children" | "defaultSelectedKeys" | "onChange">;
|
|
9
|
+
export interface SelectProps extends Omit<BaseSelectProps, "selectionMode"> {
|
|
10
|
+
selectionMode?: "single" | "multiple";
|
|
11
|
+
value?: string | string[];
|
|
12
|
+
onChange?: ((value: string | null) => void) | ((value: string[]) => void);
|
|
12
13
|
onClear?: () => void;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
export declare const Select: React.ForwardRefExoticComponent<(Omit<BaseSelectProps & {
|
|
20
|
-
selectionMode?: "single";
|
|
21
|
-
value?: string;
|
|
22
|
-
onChange?: (value: string | null) => void;
|
|
23
|
-
onClear?: () => void;
|
|
24
|
-
}, "ref"> | Omit<BaseSelectProps & {
|
|
25
|
-
selectionMode: "multiple";
|
|
26
|
-
value?: string[];
|
|
27
|
-
onChange?: (value: string[]) => void;
|
|
28
|
-
onClear?: () => void;
|
|
29
|
-
}, "ref">) & React.RefAttributes<HTMLSelectElement>>;
|
|
14
|
+
items?: Item[];
|
|
15
|
+
children?: SelectChildren;
|
|
16
|
+
}
|
|
17
|
+
export declare const Select: React.ForwardRefExoticComponent<Omit<SelectProps, "ref"> & React.RefAttributes<HTMLSelectElement>>;
|
|
18
|
+
export declare const SelectItem: <T extends object>(props: Omit<import("@heroui/autocomplete").AutocompleteItemProps<T>, "value">) => JSX.Element;
|
|
30
19
|
export {};
|
|
@@ -31,7 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/ui/inputs/select/select.tsx
|
|
32
32
|
var select_exports = {};
|
|
33
33
|
__export(select_exports, {
|
|
34
|
-
Select: () => Select
|
|
34
|
+
Select: () => Select,
|
|
35
|
+
SelectItem: () => SelectItem
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(select_exports);
|
|
37
38
|
var import_react3 = __toESM(require("react"));
|
|
@@ -66,6 +67,13 @@ var ClearButton = import_react.default.forwardRef(
|
|
|
66
67
|
);
|
|
67
68
|
ClearButton.displayName = "TeachInUI.ClearButton";
|
|
68
69
|
|
|
70
|
+
// src/ui/style/css.ts
|
|
71
|
+
var import_clsx = require("clsx");
|
|
72
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
73
|
+
function cn(...inputs) {
|
|
74
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
75
|
+
}
|
|
76
|
+
|
|
69
77
|
// src/ui/inputs/select/use-select.ts
|
|
70
78
|
var import_react2 = require("react");
|
|
71
79
|
function useSelect({
|
|
@@ -76,24 +84,17 @@ function useSelect({
|
|
|
76
84
|
isClearable = true
|
|
77
85
|
}) {
|
|
78
86
|
const isMultiple = selectionMode === "multiple";
|
|
79
|
-
const [
|
|
80
|
-
isMultiple ? [] : null
|
|
81
|
-
);
|
|
82
|
-
const isControlled = value !== void 0;
|
|
83
|
-
const currentValue = isControlled ? value : internalValue;
|
|
87
|
+
const currentValue = value != null ? value : isMultiple ? [] : null;
|
|
84
88
|
const hasValue = currentValue != null && (Array.isArray(currentValue) ? currentValue.length > 0 : currentValue !== "");
|
|
85
89
|
const handleChange = (0, import_react2.useCallback)(
|
|
86
90
|
(newValue) => {
|
|
87
|
-
if (!isControlled) {
|
|
88
|
-
setInternalValue(newValue);
|
|
89
|
-
}
|
|
90
91
|
if (isMultiple) {
|
|
91
92
|
onChange == null ? void 0 : onChange(newValue);
|
|
92
93
|
} else {
|
|
93
94
|
onChange == null ? void 0 : onChange(newValue);
|
|
94
95
|
}
|
|
95
96
|
},
|
|
96
|
-
[
|
|
97
|
+
[onChange, isMultiple]
|
|
97
98
|
);
|
|
98
99
|
const handleClear = (0, import_react2.useCallback)(() => {
|
|
99
100
|
onClear == null ? void 0 : onClear();
|
|
@@ -138,9 +139,11 @@ var selectWrapperVariants = (0, import_tailwind_variants.tv)({
|
|
|
138
139
|
var Select = import_react3.default.forwardRef(
|
|
139
140
|
({
|
|
140
141
|
value,
|
|
141
|
-
defaultSelectedKeys,
|
|
142
142
|
items,
|
|
143
|
+
children,
|
|
144
|
+
selectedKeys: selectedKeysProp,
|
|
143
145
|
onChange,
|
|
146
|
+
onSelectionChange,
|
|
144
147
|
selectionMode,
|
|
145
148
|
onClear,
|
|
146
149
|
variant,
|
|
@@ -149,6 +152,8 @@ var Select = import_react3.default.forwardRef(
|
|
|
149
152
|
isClearable,
|
|
150
153
|
...props
|
|
151
154
|
}, ref) => {
|
|
155
|
+
const usesExternalSelectionControl = selectedKeysProp !== void 0 || onSelectionChange !== void 0;
|
|
156
|
+
const selectChildren = children != null ? children : (item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_select.SelectItem, { children: item.label }, item.key);
|
|
152
157
|
const { selectedKeys, handleSelectionChange, handleClear, showClearButton } = useSelect({
|
|
153
158
|
value,
|
|
154
159
|
onChange,
|
|
@@ -162,27 +167,28 @@ var Select = import_react3.default.forwardRef(
|
|
|
162
167
|
ref,
|
|
163
168
|
classNames: {
|
|
164
169
|
...classNames,
|
|
165
|
-
trigger: selectWrapperVariants({ variant }),
|
|
170
|
+
trigger: cn(selectWrapperVariants({ variant }), classNames == null ? void 0 : classNames.trigger),
|
|
166
171
|
innerWrapper: "group"
|
|
167
172
|
},
|
|
168
|
-
defaultSelectedKeys,
|
|
169
173
|
endContent: (endContent || showClearButton) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
170
174
|
endContent,
|
|
171
175
|
showClearButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ClearButton, { onClear: handleClear })
|
|
172
176
|
] }),
|
|
173
177
|
items,
|
|
174
|
-
selectedKeys,
|
|
178
|
+
selectedKeys: usesExternalSelectionControl ? selectedKeysProp : selectedKeys,
|
|
175
179
|
selectionMode,
|
|
176
180
|
variant,
|
|
177
|
-
onSelectionChange: handleSelectionChange,
|
|
181
|
+
onSelectionChange: usesExternalSelectionControl ? onSelectionChange : handleSelectionChange,
|
|
178
182
|
...props,
|
|
179
|
-
children:
|
|
183
|
+
children: selectChildren
|
|
180
184
|
}
|
|
181
185
|
);
|
|
182
186
|
}
|
|
183
187
|
);
|
|
184
188
|
Select.displayName = "TeachInUI.Select";
|
|
189
|
+
var SelectItem = import_select.SelectItem;
|
|
185
190
|
// Annotate the CommonJS export names for ESM import in node:
|
|
186
191
|
0 && (module.exports = {
|
|
187
|
-
Select
|
|
192
|
+
Select,
|
|
193
|
+
SelectItem
|
|
188
194
|
});
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
Select
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Select,
|
|
4
|
+
SelectItem
|
|
5
|
+
} from "../../../chunk-C5FQB2UN.mjs";
|
|
6
|
+
import "../../../chunk-6BWSC6ZH.mjs";
|
|
6
7
|
import "../../../chunk-TUIN5YJW.mjs";
|
|
8
|
+
import "../../../chunk-Q6XJI7Q2.mjs";
|
|
9
|
+
import "../../../chunk-LOMRTWX5.mjs";
|
|
7
10
|
export {
|
|
8
|
-
Select
|
|
11
|
+
Select,
|
|
12
|
+
SelectItem
|
|
9
13
|
};
|
|
@@ -33,24 +33,17 @@ function useSelect({
|
|
|
33
33
|
isClearable = true
|
|
34
34
|
}) {
|
|
35
35
|
const isMultiple = selectionMode === "multiple";
|
|
36
|
-
const [
|
|
37
|
-
isMultiple ? [] : null
|
|
38
|
-
);
|
|
39
|
-
const isControlled = value !== void 0;
|
|
40
|
-
const currentValue = isControlled ? value : internalValue;
|
|
36
|
+
const currentValue = value != null ? value : isMultiple ? [] : null;
|
|
41
37
|
const hasValue = currentValue != null && (Array.isArray(currentValue) ? currentValue.length > 0 : currentValue !== "");
|
|
42
38
|
const handleChange = (0, import_react.useCallback)(
|
|
43
39
|
(newValue) => {
|
|
44
|
-
if (!isControlled) {
|
|
45
|
-
setInternalValue(newValue);
|
|
46
|
-
}
|
|
47
40
|
if (isMultiple) {
|
|
48
41
|
onChange == null ? void 0 : onChange(newValue);
|
|
49
42
|
} else {
|
|
50
43
|
onChange == null ? void 0 : onChange(newValue);
|
|
51
44
|
}
|
|
52
45
|
},
|
|
53
|
-
[
|
|
46
|
+
[onChange, isMultiple]
|
|
54
47
|
);
|
|
55
48
|
const handleClear = (0, import_react.useCallback)(() => {
|
|
56
49
|
onClear == null ? void 0 : onClear();
|
|
@@ -1,6 +1,27 @@
|
|
|
1
|
+
import type { VariantProps } from "tailwind-variants";
|
|
1
2
|
import React from "react";
|
|
2
|
-
|
|
3
|
+
declare const wrapperVariants: import("tailwind-variants").TVReturnType<{
|
|
4
|
+
size: {
|
|
5
|
+
sm: string;
|
|
6
|
+
md: string;
|
|
7
|
+
lg: string;
|
|
8
|
+
};
|
|
9
|
+
}, undefined, "flex cursor-pointer items-center justify-center rounded-sm bg-transparent!", {
|
|
10
|
+
size: {
|
|
11
|
+
sm: string;
|
|
12
|
+
md: string;
|
|
13
|
+
lg: string;
|
|
14
|
+
};
|
|
15
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
16
|
+
size: {
|
|
17
|
+
sm: string;
|
|
18
|
+
md: string;
|
|
19
|
+
lg: string;
|
|
20
|
+
};
|
|
21
|
+
}, undefined, "flex cursor-pointer items-center justify-center rounded-sm bg-transparent!", unknown, unknown, undefined>>;
|
|
22
|
+
export interface Props extends VariantProps<typeof wrapperVariants> {
|
|
3
23
|
isSelected: boolean;
|
|
4
24
|
onValueChange?: (isSelected: boolean) => void;
|
|
5
25
|
}
|
|
6
|
-
export declare function FavoriteSwitch({ isSelected, onValueChange }: Props): React.JSX.Element;
|
|
26
|
+
export declare function FavoriteSwitch({ isSelected, onValueChange, size }: Props): React.JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -30,14 +30,35 @@ var import_lucide_react = require("lucide-react");
|
|
|
30
30
|
var import_tailwind_variants = require("tailwind-variants");
|
|
31
31
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
32
|
var bookmarkVariants = (0, import_tailwind_variants.tv)({
|
|
33
|
-
base: "
|
|
33
|
+
base: "stroke-default-400 group-hover:fill-primary-100 group-hover:stroke-default-400",
|
|
34
34
|
variants: {
|
|
35
|
+
size: {
|
|
36
|
+
sm: "size-6",
|
|
37
|
+
md: "size-8",
|
|
38
|
+
lg: "size-10"
|
|
39
|
+
},
|
|
35
40
|
isSelected: {
|
|
36
41
|
true: "stroke-primary fill-primary-100"
|
|
37
42
|
}
|
|
43
|
+
},
|
|
44
|
+
defaultVariants: {
|
|
45
|
+
size: "md"
|
|
38
46
|
}
|
|
39
47
|
});
|
|
40
|
-
|
|
48
|
+
var wrapperVariants = (0, import_tailwind_variants.tv)({
|
|
49
|
+
base: "flex cursor-pointer items-center justify-center rounded-sm bg-transparent!",
|
|
50
|
+
variants: {
|
|
51
|
+
size: {
|
|
52
|
+
sm: "h-8 w-8",
|
|
53
|
+
md: "h-10 w-10",
|
|
54
|
+
lg: "h-12 w-12"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
defaultVariants: {
|
|
58
|
+
size: "md"
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
function FavoriteSwitch({ isSelected, onValueChange, size }) {
|
|
41
62
|
const { Component, slots, getBaseProps, getInputProps, getWrapperProps } = (0, import_switch.useSwitch)({
|
|
42
63
|
isSelected,
|
|
43
64
|
onValueChange
|
|
@@ -49,9 +70,18 @@ function FavoriteSwitch({ isSelected, onValueChange }) {
|
|
|
49
70
|
{
|
|
50
71
|
...getWrapperProps(),
|
|
51
72
|
className: slots.wrapper({
|
|
52
|
-
class:
|
|
73
|
+
class: wrapperVariants({ size })
|
|
53
74
|
}),
|
|
54
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
75
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
76
|
+
import_lucide_react.BookmarkIcon,
|
|
77
|
+
{
|
|
78
|
+
absoluteStrokeWidth: true,
|
|
79
|
+
className: bookmarkVariants({ isSelected, size }),
|
|
80
|
+
strokeLinecap: "round",
|
|
81
|
+
strokeLinejoin: "round",
|
|
82
|
+
strokeWidth: 1.5
|
|
83
|
+
}
|
|
84
|
+
)
|
|
55
85
|
}
|
|
56
86
|
)
|
|
57
87
|
] });
|
|
@@ -51,14 +51,35 @@ var import_lucide_react = require("lucide-react");
|
|
|
51
51
|
var import_tailwind_variants = require("tailwind-variants");
|
|
52
52
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
53
53
|
var bookmarkVariants = (0, import_tailwind_variants.tv)({
|
|
54
|
-
base: "
|
|
54
|
+
base: "stroke-default-400 group-hover:fill-primary-100 group-hover:stroke-default-400",
|
|
55
55
|
variants: {
|
|
56
|
+
size: {
|
|
57
|
+
sm: "size-6",
|
|
58
|
+
md: "size-8",
|
|
59
|
+
lg: "size-10"
|
|
60
|
+
},
|
|
56
61
|
isSelected: {
|
|
57
62
|
true: "stroke-primary fill-primary-100"
|
|
58
63
|
}
|
|
64
|
+
},
|
|
65
|
+
defaultVariants: {
|
|
66
|
+
size: "md"
|
|
59
67
|
}
|
|
60
68
|
});
|
|
61
|
-
|
|
69
|
+
var wrapperVariants = (0, import_tailwind_variants.tv)({
|
|
70
|
+
base: "flex cursor-pointer items-center justify-center rounded-sm bg-transparent!",
|
|
71
|
+
variants: {
|
|
72
|
+
size: {
|
|
73
|
+
sm: "h-8 w-8",
|
|
74
|
+
md: "h-10 w-10",
|
|
75
|
+
lg: "h-12 w-12"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
defaultVariants: {
|
|
79
|
+
size: "md"
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
function FavoriteSwitch({ isSelected, onValueChange, size }) {
|
|
62
83
|
const { Component, slots, getBaseProps, getInputProps, getWrapperProps } = (0, import_switch2.useSwitch)({
|
|
63
84
|
isSelected,
|
|
64
85
|
onValueChange
|
|
@@ -70,9 +91,18 @@ function FavoriteSwitch({ isSelected, onValueChange }) {
|
|
|
70
91
|
{
|
|
71
92
|
...getWrapperProps(),
|
|
72
93
|
className: slots.wrapper({
|
|
73
|
-
class:
|
|
94
|
+
class: wrapperVariants({ size })
|
|
74
95
|
}),
|
|
75
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
96
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
97
|
+
import_lucide_react.BookmarkIcon,
|
|
98
|
+
{
|
|
99
|
+
absoluteStrokeWidth: true,
|
|
100
|
+
className: bookmarkVariants({ isSelected, size }),
|
|
101
|
+
strokeLinecap: "round",
|
|
102
|
+
strokeLinejoin: "round",
|
|
103
|
+
strokeWidth: 1.5
|
|
104
|
+
}
|
|
105
|
+
)
|
|
76
106
|
}
|
|
77
107
|
)
|
|
78
108
|
] });
|