@teach-in/react 1.3.0 → 1.5.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 +62 -0
- package/dist/{chunk-LJIVY6GU.mjs → chunk-46SKVFMZ.mjs} +1 -1
- package/dist/{chunk-JDFRAN4S.mjs → chunk-5FFWQB7D.mjs} +12 -2
- package/dist/{chunk-544SDU73.mjs → chunk-BBUPZCY6.mjs} +1 -1
- package/dist/chunk-C2VWADF5.mjs +34 -0
- package/dist/{chunk-NLHQDWUK.mjs → chunk-CKJ5U5Q4.mjs} +1 -1
- package/dist/chunk-CUEG2BFV.mjs +34 -0
- package/dist/chunk-GTE5VEBV.mjs +68 -0
- package/dist/{chunk-CETCW7DS.mjs → chunk-IU2JYI7W.mjs} +1 -1
- package/dist/{chunk-KTUGFQWJ.mjs → chunk-KTWHCUYV.mjs} +1 -1
- package/dist/chunk-MCQGBAUS.mjs +73 -0
- package/dist/chunk-NSU66J5E.mjs +59 -0
- package/dist/{chunk-UFYLYN5Z.mjs → chunk-QFWSQOF6.mjs} +20 -2
- package/dist/{chunk-R7LDL5CU.mjs → chunk-R46SWVWL.mjs} +1 -1
- package/dist/{chunk-WFNNN6WU.mjs → chunk-RPIOTLYT.mjs} +1 -1
- package/dist/chunk-SEJXJZSK.mjs +64 -0
- package/dist/chunk-TUIN5YJW.mjs +33 -0
- package/dist/chunk-UQAG7TKJ.mjs +1 -0
- package/dist/chunk-VXYV37IM.mjs +74 -0
- package/dist/{chunk-J3OZNLTZ.mjs → chunk-WG4IPOHE.mjs} +5 -5
- package/dist/{chunk-AFVGHUW2.mjs → chunk-YZB4VBX7.mjs} +24 -2
- package/dist/index.js +658 -247
- package/dist/index.mjs +200 -184
- package/dist/ui/data/index.mjs +8 -8
- package/dist/ui/feedback/index.mjs +11 -11
- package/dist/ui/feedback/progress/index.mjs +3 -3
- package/dist/ui/form/index.js +447 -106
- package/dist/ui/form/index.mjs +30 -20
- package/dist/ui/form/rhf/fields/autocomplete-field.mjs +19 -13
- package/dist/ui/form/rhf/fields/checkbox-field.mjs +19 -13
- package/dist/ui/form/rhf/fields/date-picker-field.mjs +19 -13
- package/dist/ui/form/rhf/fields/email-field.js +147 -10
- package/dist/ui/form/rhf/fields/email-field.mjs +20 -14
- package/dist/ui/form/rhf/fields/index.d.ts +1 -0
- package/dist/ui/form/rhf/fields/index.js +443 -102
- package/dist/ui/form/rhf/fields/index.mjs +30 -20
- package/dist/ui/form/rhf/fields/input-field.js +153 -6
- package/dist/ui/form/rhf/fields/input-field.mjs +20 -14
- package/dist/ui/form/rhf/fields/radio-field.mjs +19 -13
- package/dist/ui/form/rhf/fields/search-field.d.ts +10 -0
- package/dist/ui/form/rhf/fields/search-field.js +296 -0
- package/dist/ui/form/rhf/fields/search-field.mjs +37 -0
- package/dist/ui/form/rhf/fields/select-field.js +136 -26
- package/dist/ui/form/rhf/fields/select-field.mjs +20 -14
- package/dist/ui/form/rhf/fields/switch-field.mjs +19 -13
- package/dist/ui/form/rhf/fields/text-field.js +147 -10
- package/dist/ui/form/rhf/fields/text-field.mjs +20 -14
- package/dist/ui/form/rhf/fields/textarea-field.mjs +19 -13
- package/dist/ui/form/rhf/index.js +443 -102
- package/dist/ui/form/rhf/index.mjs +30 -20
- package/dist/ui/format/index.mjs +6 -6
- package/dist/ui/index.js +658 -247
- package/dist/ui/index.mjs +199 -183
- package/dist/ui/inputs/clear-button.d.ts +5 -0
- package/dist/ui/inputs/clear-button.js +67 -0
- package/dist/ui/inputs/clear-button.mjs +8 -0
- package/dist/ui/inputs/email/email.js +144 -7
- package/dist/ui/inputs/email/email.mjs +4 -2
- package/dist/ui/inputs/email/index.js +144 -7
- package/dist/ui/inputs/email/index.mjs +4 -2
- package/dist/ui/inputs/index.d.ts +2 -0
- package/dist/ui/inputs/index.js +396 -59
- package/dist/ui/inputs/index.mjs +33 -21
- package/dist/ui/inputs/input/index.js +140 -3
- package/dist/ui/inputs/input/index.mjs +3 -1
- package/dist/ui/inputs/input/input.d.ts +1 -0
- package/dist/ui/inputs/input/input.js +140 -3
- package/dist/ui/inputs/input/input.mjs +3 -1
- package/dist/ui/inputs/input/use-input.d.ts +19 -0
- package/dist/ui/inputs/input/use-input.js +82 -0
- package/dist/ui/inputs/input/use-input.mjs +7 -0
- package/dist/ui/inputs/radio/index.mjs +3 -3
- package/dist/ui/inputs/search/index.d.ts +1 -0
- package/dist/ui/inputs/search/index.js +270 -0
- package/dist/ui/inputs/search/index.mjs +13 -0
- package/dist/ui/inputs/search/search.d.ts +7 -0
- package/dist/ui/inputs/search/search.js +268 -0
- package/dist/ui/inputs/search/search.mjs +12 -0
- package/dist/ui/inputs/search/use-search.d.ts +12 -0
- package/dist/ui/inputs/search/use-search.js +57 -0
- package/dist/ui/inputs/search/use-search.mjs +7 -0
- package/dist/ui/inputs/select/index.js +132 -22
- package/dist/ui/inputs/select/index.mjs +3 -1
- package/dist/ui/inputs/select/select.d.ts +4 -0
- package/dist/ui/inputs/select/select.js +132 -22
- package/dist/ui/inputs/select/select.mjs +3 -1
- package/dist/ui/inputs/select/use-select.d.ts +17 -0
- package/dist/ui/inputs/select/use-select.js +85 -0
- package/dist/ui/inputs/select/use-select.mjs +7 -0
- package/dist/ui/inputs/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 +3 -3
- package/dist/ui/inputs/text/index.js +144 -7
- package/dist/ui/inputs/text/index.mjs +4 -2
- package/dist/ui/inputs/text/text.js +144 -7
- package/dist/ui/inputs/text/text.mjs +4 -2
- package/dist/ui/layout/container/container.mjs +96 -89
- package/dist/ui/layout/container/index.mjs +96 -89
- package/dist/ui/layout/index.mjs +101 -94
- package/dist/ui/layout/page/index.mjs +7 -7
- package/dist/ui/layout/page/page-loading.mjs +6 -6
- package/dist/ui/layout/page/section-loading.mjs +6 -6
- package/dist/ui/navigation/index.mjs +9 -9
- package/dist/ui/overlays/index.mjs +8 -8
- package/dist/ui/provider/index.mjs +6 -6
- package/dist/ui/provider/ui-provider.mjs +6 -6
- 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 +7 -3
- package/dist/ui/theme/colors/index.js +24 -2
- package/dist/ui/theme/colors/index.mjs +2 -2
- package/dist/ui/theme/colors/semantic.js +24 -2
- package/dist/ui/theme/colors/semantic.mjs +1 -1
- package/dist/ui/theme/colors/types.d.ts +2 -0
- package/dist/ui/theme/colors.js +24 -2
- package/dist/ui/theme/colors.mjs +2 -2
- package/dist/ui/theme/index.js +24 -2
- package/dist/ui/theme/index.mjs +3 -3
- package/dist/ui/theme/theme.js +24 -2
- package/dist/ui/theme/theme.mjs +3 -3
- package/package.json +1 -1
- package/dist/chunk-3YOW5DEZ.mjs +0 -45
- package/dist/chunk-E5QSNLSR.mjs +0 -38
- package/dist/chunk-V2G5QHZZ.mjs +0 -14
- /package/dist/{chunk-CZEO3U25.mjs → chunk-5RNCFTW5.mjs} +0 -0
- /package/dist/{chunk-Q6JSJOU4.mjs → chunk-PTCNYQVY.mjs} +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/ui/inputs/select/use-select.ts
|
|
4
|
+
import { useCallback, useMemo, useState } from "react";
|
|
5
|
+
function useSelect({
|
|
6
|
+
value,
|
|
7
|
+
onChange,
|
|
8
|
+
onClear,
|
|
9
|
+
selectionMode,
|
|
10
|
+
isClearable = true
|
|
11
|
+
}) {
|
|
12
|
+
const isMultiple = selectionMode === "multiple";
|
|
13
|
+
const [internalValue, setInternalValue] = useState(
|
|
14
|
+
isMultiple ? [] : null
|
|
15
|
+
);
|
|
16
|
+
const isControlled = value !== void 0;
|
|
17
|
+
const currentValue = isControlled ? value : internalValue;
|
|
18
|
+
const hasValue = currentValue != null && (Array.isArray(currentValue) ? currentValue.length > 0 : currentValue !== "");
|
|
19
|
+
const handleChange = useCallback(
|
|
20
|
+
(newValue) => {
|
|
21
|
+
if (!isControlled) {
|
|
22
|
+
setInternalValue(newValue);
|
|
23
|
+
}
|
|
24
|
+
if (isMultiple) {
|
|
25
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
26
|
+
} else {
|
|
27
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
[isControlled, onChange, isMultiple]
|
|
31
|
+
);
|
|
32
|
+
const handleClear = useCallback(() => {
|
|
33
|
+
onClear == null ? void 0 : onClear();
|
|
34
|
+
handleChange(isMultiple ? [] : null);
|
|
35
|
+
}, [onClear, handleChange, isMultiple]);
|
|
36
|
+
const selectedKeys = useMemo(() => {
|
|
37
|
+
if (currentValue == null) return /* @__PURE__ */ new Set();
|
|
38
|
+
return new Set(Array.isArray(currentValue) ? currentValue : [currentValue]);
|
|
39
|
+
}, [currentValue]);
|
|
40
|
+
const handleSelectionChange = useCallback(
|
|
41
|
+
(keys) => {
|
|
42
|
+
var _a;
|
|
43
|
+
if (keys === "all") return;
|
|
44
|
+
const selected = Array.from(keys).filter((key) => typeof key === "string");
|
|
45
|
+
handleChange(isMultiple ? selected : (_a = selected[0]) != null ? _a : null);
|
|
46
|
+
},
|
|
47
|
+
[handleChange, isMultiple]
|
|
48
|
+
);
|
|
49
|
+
const showClearButton = hasValue && isClearable;
|
|
50
|
+
return {
|
|
51
|
+
currentValue,
|
|
52
|
+
hasValue,
|
|
53
|
+
selectedKeys,
|
|
54
|
+
handleSelectionChange,
|
|
55
|
+
handleClear,
|
|
56
|
+
showClearButton
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
useSelect
|
|
62
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
Input
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MCQGBAUS.mjs";
|
|
5
5
|
|
|
6
6
|
// src/ui/form/rhf/fields/input-field.tsx
|
|
7
7
|
import { Controller, useFormContext } from "react-hook-form";
|
|
@@ -13,7 +13,17 @@ function InputField({ name, ...props }) {
|
|
|
13
13
|
{
|
|
14
14
|
control,
|
|
15
15
|
name,
|
|
16
|
-
render: ({ field: { ref, ...field }, fieldState: { error } }) => /* @__PURE__ */ jsx(
|
|
16
|
+
render: ({ field: { ref, ...field }, fieldState: { error } }) => /* @__PURE__ */ jsx(
|
|
17
|
+
Input,
|
|
18
|
+
{
|
|
19
|
+
...props,
|
|
20
|
+
...field,
|
|
21
|
+
ref,
|
|
22
|
+
errorMessage: error == null ? void 0 : error.message,
|
|
23
|
+
isInvalid: !!error,
|
|
24
|
+
onValueChange: field.onChange
|
|
25
|
+
}
|
|
26
|
+
)
|
|
17
27
|
}
|
|
18
28
|
);
|
|
19
29
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/ui/inputs/search/use-search.ts
|
|
4
|
+
import { useCallback } from "react";
|
|
5
|
+
function useSearch({ value, onSearch, onCancel, onKeyDown }) {
|
|
6
|
+
const handleKeyDown = useCallback(
|
|
7
|
+
(event) => {
|
|
8
|
+
if (event.key === "Enter") {
|
|
9
|
+
event.preventDefault();
|
|
10
|
+
onSearch == null ? void 0 : onSearch(event.target.value);
|
|
11
|
+
} else if (event.key === "Escape") {
|
|
12
|
+
event.preventDefault();
|
|
13
|
+
onCancel == null ? void 0 : onCancel();
|
|
14
|
+
}
|
|
15
|
+
onKeyDown == null ? void 0 : onKeyDown(event);
|
|
16
|
+
},
|
|
17
|
+
[onSearch, onCancel, onKeyDown]
|
|
18
|
+
);
|
|
19
|
+
const hasValue = value !== void 0 && String(value).length > 0;
|
|
20
|
+
const handleSearchClick = useCallback(() => {
|
|
21
|
+
if (hasValue) {
|
|
22
|
+
onSearch == null ? void 0 : onSearch(value);
|
|
23
|
+
}
|
|
24
|
+
}, [value, onSearch]);
|
|
25
|
+
return {
|
|
26
|
+
handleKeyDown,
|
|
27
|
+
handleSearchClick,
|
|
28
|
+
hasValue
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
useSearch
|
|
34
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Search
|
|
4
|
+
} from "./chunk-SEJXJZSK.mjs";
|
|
5
|
+
|
|
6
|
+
// src/ui/form/rhf/fields/search-field.tsx
|
|
7
|
+
import { Controller, useFormContext } from "react-hook-form";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
function SearchField({ name, ...props }) {
|
|
10
|
+
const { control } = useFormContext();
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
Controller,
|
|
13
|
+
{
|
|
14
|
+
control,
|
|
15
|
+
name,
|
|
16
|
+
render: ({ field: { ref, ...field }, fieldState: { error } }) => /* @__PURE__ */ jsx(
|
|
17
|
+
Search,
|
|
18
|
+
{
|
|
19
|
+
...props,
|
|
20
|
+
...field,
|
|
21
|
+
ref,
|
|
22
|
+
errorMessage: error == null ? void 0 : error.message,
|
|
23
|
+
isInvalid: !!error,
|
|
24
|
+
onValueChange: field.onChange
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
SearchField.displayName = "TeachInUI.SearchField";
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
SearchField
|
|
34
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/ui/inputs/switch/favorite-switch.tsx
|
|
4
|
+
import { useSwitch } from "@heroui/switch";
|
|
5
|
+
import { BookmarkIcon } from "lucide-react";
|
|
6
|
+
import { tv } from "tailwind-variants";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
var bookmarkVariants = tv({
|
|
9
|
+
base: "stroke-default-400 group-hover:fill-primary-100 group-hover:stroke-default-400",
|
|
10
|
+
variants: {
|
|
11
|
+
size: {
|
|
12
|
+
sm: "size-6",
|
|
13
|
+
md: "size-8",
|
|
14
|
+
lg: "size-10"
|
|
15
|
+
},
|
|
16
|
+
isSelected: {
|
|
17
|
+
true: "stroke-primary fill-primary-100"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
size: "md"
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var wrapperVariants = tv({
|
|
25
|
+
base: "flex cursor-pointer items-center justify-center rounded-sm bg-transparent!",
|
|
26
|
+
variants: {
|
|
27
|
+
size: {
|
|
28
|
+
sm: "h-8 w-8",
|
|
29
|
+
md: "h-10 w-10",
|
|
30
|
+
lg: "h-12 w-12"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
size: "md"
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
function FavoriteSwitch({ isSelected, onValueChange, size }) {
|
|
38
|
+
const { Component, slots, getBaseProps, getInputProps, getWrapperProps } = useSwitch({
|
|
39
|
+
isSelected,
|
|
40
|
+
onValueChange
|
|
41
|
+
});
|
|
42
|
+
return /* @__PURE__ */ jsxs(Component, { ...getBaseProps(), children: [
|
|
43
|
+
/* @__PURE__ */ jsx("div", { className: "sr-only", children: /* @__PURE__ */ jsx("input", { ...getInputProps() }) }),
|
|
44
|
+
/* @__PURE__ */ jsx(
|
|
45
|
+
"div",
|
|
46
|
+
{
|
|
47
|
+
...getWrapperProps(),
|
|
48
|
+
className: slots.wrapper({
|
|
49
|
+
class: wrapperVariants({ size })
|
|
50
|
+
}),
|
|
51
|
+
children: /* @__PURE__ */ jsx(
|
|
52
|
+
BookmarkIcon,
|
|
53
|
+
{
|
|
54
|
+
absoluteStrokeWidth: true,
|
|
55
|
+
className: bookmarkVariants({ isSelected, size }),
|
|
56
|
+
strokeLinecap: "round",
|
|
57
|
+
strokeLinejoin: "round",
|
|
58
|
+
strokeWidth: 1.5
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
] });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
FavoriteSwitch
|
|
68
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useInput
|
|
4
|
+
} from "./chunk-NSU66J5E.mjs";
|
|
5
|
+
import {
|
|
6
|
+
ClearButton
|
|
7
|
+
} from "./chunk-TUIN5YJW.mjs";
|
|
8
|
+
|
|
9
|
+
// src/ui/inputs/input/input.tsx
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { Input as HeroUIInput } from "@heroui/input";
|
|
12
|
+
import { tv } from "tailwind-variants";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
var inputWrapperVariants = tv({
|
|
15
|
+
variants: {
|
|
16
|
+
variant: {
|
|
17
|
+
flat: "",
|
|
18
|
+
underlined: "",
|
|
19
|
+
bordered: "border-1",
|
|
20
|
+
faded: "border-1"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var Input = React.forwardRef(
|
|
25
|
+
({
|
|
26
|
+
value,
|
|
27
|
+
defaultValue,
|
|
28
|
+
onClear,
|
|
29
|
+
onValueChange,
|
|
30
|
+
variant,
|
|
31
|
+
classNames,
|
|
32
|
+
endContent,
|
|
33
|
+
isReadOnly,
|
|
34
|
+
isClearable,
|
|
35
|
+
...props
|
|
36
|
+
}, ref) => {
|
|
37
|
+
const { currentValue, handleValueChange, handleClear, mergedRef, showClearButton } = useInput({
|
|
38
|
+
value,
|
|
39
|
+
defaultValue,
|
|
40
|
+
onValueChange,
|
|
41
|
+
onClear,
|
|
42
|
+
isReadOnly,
|
|
43
|
+
isClearable,
|
|
44
|
+
ref
|
|
45
|
+
});
|
|
46
|
+
return /* @__PURE__ */ jsx(
|
|
47
|
+
HeroUIInput,
|
|
48
|
+
{
|
|
49
|
+
ref: mergedRef,
|
|
50
|
+
classNames: {
|
|
51
|
+
...classNames,
|
|
52
|
+
inputWrapper: inputWrapperVariants({ variant }),
|
|
53
|
+
innerWrapper: "group"
|
|
54
|
+
},
|
|
55
|
+
defaultValue,
|
|
56
|
+
endContent: (endContent || showClearButton) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
57
|
+
endContent,
|
|
58
|
+
showClearButton && /* @__PURE__ */ jsx(ClearButton, { onClear: handleClear })
|
|
59
|
+
] }),
|
|
60
|
+
isReadOnly,
|
|
61
|
+
value: currentValue,
|
|
62
|
+
variant,
|
|
63
|
+
onValueChange: handleValueChange,
|
|
64
|
+
...props
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
Input.displayName = "TeachInUI.Input";
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
Input
|
|
73
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/ui/inputs/input/use-input.ts
|
|
4
|
+
import { useCallback, useRef, useState } from "react";
|
|
5
|
+
function useInput({
|
|
6
|
+
value,
|
|
7
|
+
defaultValue,
|
|
8
|
+
onValueChange,
|
|
9
|
+
onClear,
|
|
10
|
+
isReadOnly,
|
|
11
|
+
isClearable = true,
|
|
12
|
+
ref
|
|
13
|
+
}) {
|
|
14
|
+
const inputRef = useRef(null);
|
|
15
|
+
const [internalValue, setInternalValue] = useState(defaultValue != null ? defaultValue : "");
|
|
16
|
+
const isControlled = value !== void 0;
|
|
17
|
+
const currentValue = isControlled ? value : internalValue;
|
|
18
|
+
const hasValue = String(currentValue).length > 0;
|
|
19
|
+
const handleValueChange = useCallback(
|
|
20
|
+
(newValue) => {
|
|
21
|
+
if (!isControlled) {
|
|
22
|
+
setInternalValue(newValue);
|
|
23
|
+
}
|
|
24
|
+
onValueChange == null ? void 0 : onValueChange(newValue);
|
|
25
|
+
},
|
|
26
|
+
[isControlled, onValueChange]
|
|
27
|
+
);
|
|
28
|
+
const handleClear = useCallback(() => {
|
|
29
|
+
var _a;
|
|
30
|
+
onClear == null ? void 0 : onClear();
|
|
31
|
+
handleValueChange("");
|
|
32
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
33
|
+
}, [onClear, handleValueChange]);
|
|
34
|
+
const mergedRef = useCallback(
|
|
35
|
+
(node) => {
|
|
36
|
+
inputRef.current = node;
|
|
37
|
+
if (typeof ref === "function") {
|
|
38
|
+
ref(node);
|
|
39
|
+
} else if (ref) {
|
|
40
|
+
ref.current = node;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
[ref]
|
|
44
|
+
);
|
|
45
|
+
const showClearButton = hasValue && !isReadOnly && isClearable;
|
|
46
|
+
return {
|
|
47
|
+
inputRef,
|
|
48
|
+
currentValue,
|
|
49
|
+
hasValue,
|
|
50
|
+
handleValueChange,
|
|
51
|
+
handleClear,
|
|
52
|
+
mergedRef,
|
|
53
|
+
showClearButton
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
useInput
|
|
59
|
+
};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cn
|
|
4
|
+
} from "./chunk-LOMRTWX5.mjs";
|
|
5
|
+
import {
|
|
6
|
+
extendVariants
|
|
7
|
+
} from "./chunk-7BTEKEON.mjs";
|
|
2
8
|
|
|
3
9
|
// src/ui/surface/card/card.tsx
|
|
4
10
|
import React from "react";
|
|
@@ -9,8 +15,20 @@ import {
|
|
|
9
15
|
CardFooter as HeroUICardFooter
|
|
10
16
|
} from "@heroui/card";
|
|
11
17
|
import { jsx } from "react/jsx-runtime";
|
|
12
|
-
var
|
|
13
|
-
|
|
18
|
+
var CardBase = extendVariants(HeroUICard, {
|
|
19
|
+
variants: {
|
|
20
|
+
radius: {
|
|
21
|
+
sm: { base: "rounded-lg" },
|
|
22
|
+
md: { base: "rounded-2xl" },
|
|
23
|
+
lg: { base: "rounded-3xl" }
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
shadow: "none"
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var Root = React.forwardRef(({ children, className, ...props }, ref) => {
|
|
31
|
+
return /* @__PURE__ */ jsx(CardBase, { ref, className: cn("bg-default-100", className), ...props, children });
|
|
14
32
|
});
|
|
15
33
|
Root.displayName = "TeachInUI.Card.Root";
|
|
16
34
|
var Header = React.forwardRef(({ children, ...props }, ref) => {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useSearch
|
|
4
|
+
} from "./chunk-C2VWADF5.mjs";
|
|
5
|
+
import {
|
|
6
|
+
Input
|
|
7
|
+
} from "./chunk-MCQGBAUS.mjs";
|
|
8
|
+
|
|
9
|
+
// src/ui/inputs/search/search.tsx
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { SearchIcon } from "lucide-react";
|
|
12
|
+
import { Button } from "@heroui/button";
|
|
13
|
+
import { tv } from "tailwind-variants";
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
15
|
+
var searchIconVariants = tv({
|
|
16
|
+
base: "size-5 shrink-0",
|
|
17
|
+
variants: {
|
|
18
|
+
variant: {
|
|
19
|
+
faded: "text-default-400",
|
|
20
|
+
flat: "text-default-foreground",
|
|
21
|
+
bordered: "text-default-400",
|
|
22
|
+
underlined: "text-default-foreground"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
var Search = React.forwardRef(
|
|
27
|
+
({ variant = "bordered", radius = "full", value, onSearch, onCancel, onKeyDown, ...props }, ref) => {
|
|
28
|
+
const { handleKeyDown, handleSearchClick, hasValue } = useSearch({
|
|
29
|
+
value,
|
|
30
|
+
onSearch,
|
|
31
|
+
onCancel,
|
|
32
|
+
onKeyDown
|
|
33
|
+
});
|
|
34
|
+
return /* @__PURE__ */ jsx(
|
|
35
|
+
Input,
|
|
36
|
+
{
|
|
37
|
+
ref,
|
|
38
|
+
radius,
|
|
39
|
+
startContent: onSearch ? /* @__PURE__ */ jsx(
|
|
40
|
+
Button,
|
|
41
|
+
{
|
|
42
|
+
isIconOnly: true,
|
|
43
|
+
"aria-label": "\u041F\u043E\u0438\u0441\u043A",
|
|
44
|
+
isDisabled: !hasValue,
|
|
45
|
+
radius: "full",
|
|
46
|
+
size: "sm",
|
|
47
|
+
variant: "light",
|
|
48
|
+
onPress: handleSearchClick,
|
|
49
|
+
children: /* @__PURE__ */ jsx(SearchIcon, { className: searchIconVariants({ variant }) })
|
|
50
|
+
}
|
|
51
|
+
) : /* @__PURE__ */ jsx(SearchIcon, { className: searchIconVariants({ variant }) }),
|
|
52
|
+
value,
|
|
53
|
+
variant,
|
|
54
|
+
onKeyDown: handleKeyDown,
|
|
55
|
+
...props
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
Search.displayName = "TeachInUI.Search";
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
Search
|
|
64
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/ui/inputs/clear-button.tsx
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { Button } from "@heroui/button";
|
|
6
|
+
import { XIcon } from "lucide-react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var ClearButton = React.forwardRef(
|
|
9
|
+
({ onClear }, ref) => {
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
Button,
|
|
12
|
+
{
|
|
13
|
+
ref,
|
|
14
|
+
isIconOnly: true,
|
|
15
|
+
"aria-label": "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C",
|
|
16
|
+
as: "span",
|
|
17
|
+
className: "opacity-0 transition-opacity group-hover:opacity-100",
|
|
18
|
+
color: "default",
|
|
19
|
+
radius: "full",
|
|
20
|
+
size: "sm",
|
|
21
|
+
tabIndex: 0,
|
|
22
|
+
variant: "light",
|
|
23
|
+
onPress: onClear,
|
|
24
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "size-4 text-default-500" })
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
ClearButton.displayName = "TeachInUI.ClearButton";
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
ClearButton
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useSelect
|
|
4
|
+
} from "./chunk-2UHA3DYG.mjs";
|
|
5
|
+
import {
|
|
6
|
+
ClearButton
|
|
7
|
+
} from "./chunk-TUIN5YJW.mjs";
|
|
8
|
+
|
|
9
|
+
// src/ui/inputs/select/select.tsx
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { Select as HeroUISelect, SelectItem as HeroUISelectItem } from "@heroui/select";
|
|
12
|
+
import { tv } from "tailwind-variants";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
var selectWrapperVariants = tv({
|
|
15
|
+
variants: {
|
|
16
|
+
variant: {
|
|
17
|
+
flat: "",
|
|
18
|
+
underlined: "",
|
|
19
|
+
bordered: "border-1",
|
|
20
|
+
faded: "border-1"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var Select = React.forwardRef(
|
|
25
|
+
({
|
|
26
|
+
value,
|
|
27
|
+
defaultSelectedKeys,
|
|
28
|
+
items,
|
|
29
|
+
onChange,
|
|
30
|
+
selectionMode,
|
|
31
|
+
onClear,
|
|
32
|
+
variant,
|
|
33
|
+
classNames,
|
|
34
|
+
endContent,
|
|
35
|
+
isClearable,
|
|
36
|
+
...props
|
|
37
|
+
}, ref) => {
|
|
38
|
+
const { selectedKeys, handleSelectionChange, handleClear, showClearButton } = useSelect({
|
|
39
|
+
value,
|
|
40
|
+
onChange,
|
|
41
|
+
onClear,
|
|
42
|
+
selectionMode,
|
|
43
|
+
isClearable
|
|
44
|
+
});
|
|
45
|
+
return /* @__PURE__ */ jsx(
|
|
46
|
+
HeroUISelect,
|
|
47
|
+
{
|
|
48
|
+
ref,
|
|
49
|
+
classNames: {
|
|
50
|
+
...classNames,
|
|
51
|
+
trigger: selectWrapperVariants({ variant }),
|
|
52
|
+
innerWrapper: "group"
|
|
53
|
+
},
|
|
54
|
+
defaultSelectedKeys,
|
|
55
|
+
endContent: (endContent || showClearButton) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
56
|
+
endContent,
|
|
57
|
+
showClearButton && /* @__PURE__ */ jsx(ClearButton, { onClear: handleClear })
|
|
58
|
+
] }),
|
|
59
|
+
items,
|
|
60
|
+
selectedKeys,
|
|
61
|
+
selectionMode,
|
|
62
|
+
variant,
|
|
63
|
+
onSelectionChange: handleSelectionChange,
|
|
64
|
+
...props,
|
|
65
|
+
children: (item) => /* @__PURE__ */ jsx(HeroUISelectItem, { children: item.label }, item.key)
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
Select.displayName = "TeachInUI.Select";
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
Select
|
|
74
|
+
};
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
import { tv } from "tailwind-variants";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
var bento = tv({
|
|
7
|
-
base: "
|
|
7
|
+
base: "p-8 transition-colors",
|
|
8
8
|
variants: {
|
|
9
9
|
color: {
|
|
10
|
-
default: "bg-
|
|
10
|
+
default: "bg-content1 text-foreground",
|
|
11
11
|
primary: "bg-primary-50 text-primary-700",
|
|
12
12
|
secondary: "bg-secondary-50 text-secondary-700",
|
|
13
13
|
success: "bg-success-50 text-success-700",
|
|
@@ -16,9 +16,9 @@ var bento = tv({
|
|
|
16
16
|
},
|
|
17
17
|
radius: {
|
|
18
18
|
none: "rounded-none",
|
|
19
|
-
sm: "rounded-
|
|
20
|
-
md: "rounded-
|
|
21
|
-
lg: "rounded-
|
|
19
|
+
sm: "rounded-lg",
|
|
20
|
+
md: "rounded-2xl",
|
|
21
|
+
lg: "rounded-3xl",
|
|
22
22
|
full: "rounded-full"
|
|
23
23
|
},
|
|
24
24
|
shadow: {
|