@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.
- package/LICENSE +21 -21
- package/README.md +9 -9
- package/dist/{chunk-AMNORHD6.mjs → chunk-2ASQXBDD.mjs} +1 -1
- package/dist/{chunk-3VAZY2QK.mjs → chunk-2CEZXLZR.mjs} +1 -1
- 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-C2VWADF5.mjs +34 -0
- package/dist/{chunk-NLHQDWUK.mjs → chunk-CKJ5U5Q4.mjs} +1 -1
- package/dist/chunk-CUEG2BFV.mjs +34 -0
- package/dist/{chunk-CETCW7DS.mjs → chunk-IU2JYI7W.mjs} +1 -1
- package/dist/{chunk-KTUGFQWJ.mjs → chunk-KTWHCUYV.mjs} +1 -1
- package/dist/chunk-M5G6RR4Q.mjs +39 -0
- package/dist/chunk-MCQGBAUS.mjs +73 -0
- package/dist/chunk-NSU66J5E.mjs +59 -0
- package/dist/{chunk-CFG5V7VB.mjs → chunk-QCLLPJMB.mjs} +2 -2
- package/dist/{chunk-R7LDL5CU.mjs → chunk-R46SWVWL.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/index.js +609 -228
- package/dist/index.mjs +106 -86
- package/dist/ui/data/index.mjs +10 -10
- package/dist/ui/feedback/index.mjs +8 -8
- package/dist/ui/form/index.js +447 -106
- package/dist/ui/form/index.mjs +25 -15
- package/dist/ui/form/rhf/fields/autocomplete-field.mjs +16 -10
- package/dist/ui/form/rhf/fields/checkbox-field.mjs +16 -10
- package/dist/ui/form/rhf/fields/date-picker-field.mjs +16 -10
- package/dist/ui/form/rhf/fields/email-field.js +147 -10
- package/dist/ui/form/rhf/fields/email-field.mjs +17 -11
- 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 +25 -15
- package/dist/ui/form/rhf/fields/input-field.js +153 -6
- package/dist/ui/form/rhf/fields/input-field.mjs +17 -11
- package/dist/ui/form/rhf/fields/radio-field.mjs +16 -10
- 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 +17 -11
- package/dist/ui/form/rhf/fields/switch-field.mjs +16 -10
- package/dist/ui/form/rhf/fields/text-field.js +147 -10
- package/dist/ui/form/rhf/fields/text-field.mjs +17 -11
- package/dist/ui/form/rhf/fields/textarea-field.mjs +16 -10
- package/dist/ui/form/rhf/index.js +443 -102
- package/dist/ui/form/rhf/index.mjs +25 -15
- package/dist/ui/format/index.d.ts +1 -0
- package/dist/ui/format/index.js +41 -5
- package/dist/ui/format/index.mjs +15 -11
- package/dist/ui/format/uuid.d.ts +12 -0
- package/dist/ui/format/uuid.js +62 -0
- package/dist/ui/format/uuid.mjs +7 -0
- package/dist/ui/index.js +609 -228
- package/dist/ui/index.mjs +106 -86
- 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 +363 -56
- package/dist/ui/inputs/index.mjs +27 -15
- 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/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 +56 -48
- package/dist/ui/layout/container/index.mjs +56 -48
- package/dist/ui/layout/index.mjs +62 -54
- 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 +8 -8
- package/dist/ui/overlays/index.mjs +5 -5
- package/dist/ui/provider/index.mjs +4 -4
- package/dist/ui/provider/ui-provider.mjs +4 -4
- package/dist/ui/theme/colors/common.mjs +5 -5
- package/dist/ui/theme/colors/index.mjs +8 -8
- package/dist/ui/theme/colors/semantic.mjs +6 -6
- package/dist/ui/theme/colors.mjs +8 -8
- package/dist/ui/theme/index.mjs +8 -8
- package/dist/ui/theme/theme.mjs +8 -8
- package/package.json +1 -1
- package/dist/chunk-3YOW5DEZ.mjs +0 -45
- package/dist/chunk-V2G5QHZZ.mjs +0 -14
- package/dist/{chunk-5IHVMMCK.mjs → chunk-5N3SIZHF.mjs} +0 -0
- package/dist/{chunk-CZEO3U25.mjs → chunk-5RNCFTW5.mjs} +0 -0
- package/dist/{chunk-STVN4B47.mjs → chunk-IXPMUODA.mjs} +12 -12
- /package/dist/{chunk-Q6JSJOU4.mjs → chunk-PTCNYQVY.mjs} +0 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Next UI Inc.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Next UI Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# @teach-in/react
|
|
2
|
-
|
|
3
|
-
## Installation
|
|
4
|
-
|
|
5
|
-
```sh
|
|
6
|
-
yarn add @teach-in/react
|
|
7
|
-
# or
|
|
8
|
-
npm i @teach-in/react
|
|
9
|
-
```
|
|
1
|
+
# @teach-in/react
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
yarn add @teach-in/react
|
|
7
|
+
# or
|
|
8
|
+
npm i @teach-in/react
|
|
9
|
+
```
|
|
@@ -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,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/ui/format/uuid.tsx
|
|
4
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
5
|
+
var uuidHyphenatedRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/;
|
|
6
|
+
function normalizeUuid(value) {
|
|
7
|
+
const trimmed = value.trim();
|
|
8
|
+
if (trimmed.length === 0) return null;
|
|
9
|
+
const withoutPrefix = trimmed.toLowerCase().startsWith("urn:uuid:") ? trimmed.slice("urn:uuid:".length) : trimmed;
|
|
10
|
+
const withoutBraces = withoutPrefix.startsWith("{") && withoutPrefix.endsWith("}") ? withoutPrefix.slice(1, -1) : withoutPrefix;
|
|
11
|
+
if (uuidHyphenatedRegex.test(withoutBraces)) return withoutBraces.toLowerCase();
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
function detectUuidVersion(normalizedUuid) {
|
|
15
|
+
var _a;
|
|
16
|
+
const versionChar = (_a = normalizedUuid.split("-")[2]) == null ? void 0 : _a[0];
|
|
17
|
+
if (!versionChar) return null;
|
|
18
|
+
const parsed = Number.parseInt(versionChar, 16);
|
|
19
|
+
return Number.isNaN(parsed) ? null : parsed;
|
|
20
|
+
}
|
|
21
|
+
function Uuid({
|
|
22
|
+
value,
|
|
23
|
+
case: letterCase = "lower",
|
|
24
|
+
showVersion = false,
|
|
25
|
+
invalidFallback = "\u2014"
|
|
26
|
+
}) {
|
|
27
|
+
if (!value) return /* @__PURE__ */ jsx(Fragment, { children: invalidFallback });
|
|
28
|
+
const normalized = normalizeUuid(value);
|
|
29
|
+
if (!normalized) return /* @__PURE__ */ jsx(Fragment, { children: invalidFallback });
|
|
30
|
+
const formatted = letterCase === "upper" ? normalized.toUpperCase() : normalized;
|
|
31
|
+
if (!showVersion) return /* @__PURE__ */ jsx(Fragment, { children: formatted });
|
|
32
|
+
const version = detectUuidVersion(normalized);
|
|
33
|
+
return /* @__PURE__ */ jsx(Fragment, { children: version !== null ? `${formatted} (v${version})` : formatted });
|
|
34
|
+
}
|
|
35
|
+
Uuid.displayName = "TeachInUI.FormatUUID";
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
Uuid
|
|
39
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -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
|
+
};
|