@rockshin/tao-ui 0.0.42 → 0.0.44
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/README.md +8 -2
- package/component-manifest.json +37 -18
- package/dist/components/alert/alert.css +1 -0
- package/dist/components/avatar/avatar.js +1 -1
- package/dist/components/calendar/calendar.css +10 -60
- package/dist/components/calendar/calendar.js +46 -43
- package/dist/components/card/card.css +1 -1
- package/dist/components/carousel/carousel.css +1 -0
- package/dist/components/carousel/carousel.js +62 -7
- package/dist/components/collapse/collapse-panels.d.ts +4 -0
- package/dist/components/collapse/collapse-panels.js +413 -0
- package/dist/components/collapse/collapse.css +199 -0
- package/dist/components/collapse/collapse.d.ts +77 -0
- package/dist/components/{collapsible/collapsible.js → collapse/collapse.js} +26 -10
- package/dist/components/color-picker/color-picker.css +8 -42
- package/dist/components/color-picker/color-picker.js +220 -145
- package/dist/components/date-picker/date-picker.css +18 -56
- package/dist/components/date-picker/date-picker.d.ts +2 -0
- package/dist/components/date-picker/date-picker.js +11 -6
- package/dist/components/date-picker/presets.js +5 -2
- package/dist/components/date-picker/range-picker.d.ts +2 -0
- package/dist/components/date-picker/range-picker.js +3 -1
- package/dist/components/form/field-control.d.ts +6 -0
- package/dist/components/form/field-control.js +42 -0
- package/dist/components/form/form-context.d.ts +3 -0
- package/dist/components/form/form-item.d.ts +2 -1
- package/dist/components/form/form-item.js +56 -42
- package/dist/components/form/form.css +15 -0
- package/dist/components/form/form.d.ts +5 -5
- package/dist/components/form/form.js +87 -68
- package/dist/components/form/index.d.ts +1 -0
- package/dist/components/form/use-form.d.ts +16 -0
- package/dist/components/form/use-form.js +69 -0
- package/dist/components/form-field/form-field-view.d.ts +6 -2
- package/dist/components/form-field/form-field-view.js +116 -84
- package/dist/components/input/base-input.d.ts +25 -0
- package/dist/components/input/base-input.js +104 -0
- package/dist/components/input/input-shared.css +75 -0
- package/dist/components/input/input-shared.d.ts +59 -0
- package/dist/components/input/input-shared.js +152 -0
- package/dist/components/input/input.css +99 -4
- package/dist/components/input/input.d.ts +12 -16
- package/dist/components/input/input.js +11 -154
- package/dist/components/input/otp.d.ts +29 -0
- package/dist/components/input/otp.js +335 -0
- package/dist/components/input/password.d.ts +12 -0
- package/dist/components/input/password.js +117 -0
- package/dist/components/input/search.d.ts +16 -0
- package/dist/components/input/search.js +99 -0
- package/dist/components/input-number/input-number.d.ts +2 -2
- package/dist/components/input-number/input-number.js +2 -2
- package/dist/components/list/list-pagination.css +5 -5
- package/dist/components/list/list-pagination.js +1 -0
- package/dist/components/mentions/mentions.css +7 -0
- package/dist/components/modal/modal.css +1 -0
- package/dist/components/radio/radio.d.ts +1 -1
- package/dist/components/radio/radio.js +78 -73
- package/dist/components/select/mobile-select.css +1 -16
- package/dist/components/select/mobile-select.d.ts +2 -1
- package/dist/components/select/mobile-select.js +68 -63
- package/dist/components/select/select-types.d.ts +2 -0
- package/dist/components/select/select.css +19 -0
- package/dist/components/select/select.js +31 -17
- package/dist/components/spinner/spinner.css +1 -1
- package/dist/components/steps/steps.css +53 -3
- package/dist/components/table/table.css +0 -5
- package/dist/components/table/table.js +21 -22
- package/dist/components/textarea/textarea.css +20 -0
- package/dist/components/textarea/textarea.d.ts +12 -6
- package/dist/components/textarea/textarea.js +120 -219
- package/dist/components/time-picker/time-picker.css +7 -0
- package/dist/components/tree/tree-check.d.ts +1 -0
- package/dist/components/tree/tree-check.js +36 -0
- package/dist/components/tree/tree.css +13 -18
- package/dist/components/tree/tree.js +2 -3
- package/dist/components/tree-select/select-engine.css +7 -0
- package/dist/components/tree-select/tree-select.js +2 -3
- package/dist/components/upload/upload.css +0 -11
- package/dist/components/upload/upload.js +13 -3
- package/dist/docs/component-docs.js +2 -2
- package/dist/docs/components/{collapsible.doc.d.ts → collapse.doc.d.ts} +1 -1
- package/dist/docs/components/collapse.doc.js +47 -0
- package/dist/docs/components/form.doc.js +3 -1
- package/dist/docs/components/input.doc.js +11 -4
- package/dist/docs/components/textarea.doc.js +4 -2
- package/dist/entries/collapse.d.ts +3 -0
- package/dist/entries/{collapsible.js → collapse.js} +1 -1
- package/dist/entries/form.d.ts +2 -2
- package/dist/entries/input.d.ts +1 -1
- package/dist/entries/textarea.d.ts +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/provider/locale.d.ts +6 -0
- package/dist/provider/locale.js +10 -0
- package/dist/provider/tao-provider.js +1 -0
- package/dist/theme/control.css +2 -2
- package/dist/theme/theme.css +3 -1
- package/dist/theme/tokens.d.ts +2 -2
- package/dist/theme/tokens.js +1 -0
- package/dist/utils/field-label.d.ts +4 -0
- package/dist/utils/field-label.js +7 -0
- package/llms.txt +19 -16
- package/package.json +10 -5
- package/dist/components/collapsible/collapsible.css +0 -49
- package/dist/components/collapsible/collapsible.d.ts +0 -39
- package/dist/docs/components/collapsible.doc.js +0 -39
- package/dist/entries/collapsible.d.ts +0 -3
|
@@ -1,155 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
let disabled;
|
|
12
|
-
let error;
|
|
13
|
-
let prefix;
|
|
14
|
-
let rest;
|
|
15
|
-
let size;
|
|
16
|
-
let status;
|
|
17
|
-
let style;
|
|
18
|
-
let styles;
|
|
19
|
-
let suffix;
|
|
20
|
-
let variant;
|
|
21
|
-
if ($[0] !== t0) {
|
|
22
|
-
({ size, variant, prefix, suffix, error, status, disabled, className, style, classNames, styles, ...rest } = t0);
|
|
23
|
-
$[0] = t0;
|
|
24
|
-
$[1] = className;
|
|
25
|
-
$[2] = classNames;
|
|
26
|
-
$[3] = disabled;
|
|
27
|
-
$[4] = error;
|
|
28
|
-
$[5] = prefix;
|
|
29
|
-
$[6] = rest;
|
|
30
|
-
$[7] = size;
|
|
31
|
-
$[8] = status;
|
|
32
|
-
$[9] = style;
|
|
33
|
-
$[10] = styles;
|
|
34
|
-
$[11] = suffix;
|
|
35
|
-
$[12] = variant;
|
|
36
|
-
} else {
|
|
37
|
-
className = $[1];
|
|
38
|
-
classNames = $[2];
|
|
39
|
-
disabled = $[3];
|
|
40
|
-
error = $[4];
|
|
41
|
-
prefix = $[5];
|
|
42
|
-
rest = $[6];
|
|
43
|
-
size = $[7];
|
|
44
|
-
status = $[8];
|
|
45
|
-
style = $[9];
|
|
46
|
-
styles = $[10];
|
|
47
|
-
suffix = $[11];
|
|
48
|
-
variant = $[12];
|
|
49
|
-
}
|
|
50
|
-
const ctx = useTaoConfig();
|
|
51
|
-
const resolvedSize = size ?? ctx.size;
|
|
52
|
-
const resolvedVariant = variant ?? ctx.variant;
|
|
53
|
-
const resolvedDisabled = disabled ?? ctx.disabled;
|
|
54
|
-
const t1 = classNames?.root;
|
|
55
|
-
let t2;
|
|
56
|
-
if ($[13] !== className || $[14] !== t1) {
|
|
57
|
-
t2 = cx(t1, className);
|
|
58
|
-
$[13] = className;
|
|
59
|
-
$[14] = t1;
|
|
60
|
-
$[15] = t2;
|
|
61
|
-
} else t2 = $[15];
|
|
62
|
-
const t3 = styles?.root;
|
|
63
|
-
let t4;
|
|
64
|
-
if ($[16] !== style || $[17] !== t3) {
|
|
65
|
-
t4 = {
|
|
66
|
-
...t3,
|
|
67
|
-
...style
|
|
68
|
-
};
|
|
69
|
-
$[16] = style;
|
|
70
|
-
$[17] = t3;
|
|
71
|
-
$[18] = t4;
|
|
72
|
-
} else t4 = $[18];
|
|
73
|
-
const t5 = "error" === status || error || void 0;
|
|
74
|
-
const t6 = "warning" === status || void 0;
|
|
75
|
-
let t7;
|
|
76
|
-
if ($[19] !== classNames?.prefix || $[20] !== prefix || $[21] !== styles?.prefix) {
|
|
77
|
-
t7 = null != prefix && /*#__PURE__*/ jsx("span", {
|
|
78
|
-
className: classNames?.prefix,
|
|
79
|
-
style: styles?.prefix,
|
|
80
|
-
"data-tao-prefix": "",
|
|
81
|
-
children: prefix
|
|
82
|
-
});
|
|
83
|
-
$[19] = classNames?.prefix;
|
|
84
|
-
$[20] = prefix;
|
|
85
|
-
$[21] = styles?.prefix;
|
|
86
|
-
$[22] = t7;
|
|
87
|
-
} else t7 = $[22];
|
|
88
|
-
const t8 = "value" in rest ? rest.value ?? "" : void 0;
|
|
89
|
-
const t9 = classNames?.input;
|
|
90
|
-
const t10 = styles?.input;
|
|
91
|
-
const t11 = "error" === status || error ? true : rest["aria-invalid"];
|
|
92
|
-
let t12;
|
|
93
|
-
if ($[23] !== ref || $[24] !== resolvedDisabled || $[25] !== rest || $[26] !== t10 || $[27] !== t11 || $[28] !== t8 || $[29] !== t9) {
|
|
94
|
-
t12 = /*#__PURE__*/ jsx("input", {
|
|
95
|
-
...rest,
|
|
96
|
-
value: t8,
|
|
97
|
-
ref: ref,
|
|
98
|
-
className: t9,
|
|
99
|
-
style: t10,
|
|
100
|
-
disabled: resolvedDisabled,
|
|
101
|
-
"aria-invalid": t11
|
|
102
|
-
});
|
|
103
|
-
$[23] = ref;
|
|
104
|
-
$[24] = resolvedDisabled;
|
|
105
|
-
$[25] = rest;
|
|
106
|
-
$[26] = t10;
|
|
107
|
-
$[27] = t11;
|
|
108
|
-
$[28] = t8;
|
|
109
|
-
$[29] = t9;
|
|
110
|
-
$[30] = t12;
|
|
111
|
-
} else t12 = $[30];
|
|
112
|
-
let t13;
|
|
113
|
-
if ($[31] !== classNames?.suffix || $[32] !== styles?.suffix || $[33] !== suffix) {
|
|
114
|
-
t13 = null != suffix && /*#__PURE__*/ jsx("span", {
|
|
115
|
-
className: classNames?.suffix,
|
|
116
|
-
style: styles?.suffix,
|
|
117
|
-
"data-tao-suffix": "",
|
|
118
|
-
children: suffix
|
|
119
|
-
});
|
|
120
|
-
$[31] = classNames?.suffix;
|
|
121
|
-
$[32] = styles?.suffix;
|
|
122
|
-
$[33] = suffix;
|
|
123
|
-
$[34] = t13;
|
|
124
|
-
} else t13 = $[34];
|
|
125
|
-
let t14;
|
|
126
|
-
if ($[35] !== resolvedSize || $[36] !== resolvedVariant || $[37] !== t12 || $[38] !== t13 || $[39] !== t2 || $[40] !== t4 || $[41] !== t5 || $[42] !== t6 || $[43] !== t7) {
|
|
127
|
-
t14 = /*#__PURE__*/ jsxs("div", {
|
|
128
|
-
className: t2,
|
|
129
|
-
style: t4,
|
|
130
|
-
"data-tao-control": "",
|
|
131
|
-
"data-tao-input": "",
|
|
132
|
-
"data-tao-size": resolvedSize,
|
|
133
|
-
"data-tao-variant": resolvedVariant,
|
|
134
|
-
"data-tao-error": t5,
|
|
135
|
-
"data-tao-warning": t6,
|
|
136
|
-
children: [
|
|
137
|
-
t7,
|
|
138
|
-
t12,
|
|
139
|
-
t13
|
|
140
|
-
]
|
|
141
|
-
});
|
|
142
|
-
$[35] = resolvedSize;
|
|
143
|
-
$[36] = resolvedVariant;
|
|
144
|
-
$[37] = t12;
|
|
145
|
-
$[38] = t13;
|
|
146
|
-
$[39] = t2;
|
|
147
|
-
$[40] = t4;
|
|
148
|
-
$[41] = t5;
|
|
149
|
-
$[42] = t6;
|
|
150
|
-
$[43] = t7;
|
|
151
|
-
$[44] = t14;
|
|
152
|
-
} else t14 = $[44];
|
|
153
|
-
return t14;
|
|
1
|
+
import { Textarea } from "../textarea/textarea.js";
|
|
2
|
+
import { BaseInput } from "./base-input.js";
|
|
3
|
+
import { OTP } from "./otp.js";
|
|
4
|
+
import { Password } from "./password.js";
|
|
5
|
+
import { Search } from "./search.js";
|
|
6
|
+
const Input = Object.assign(BaseInput, {
|
|
7
|
+
Password: Password,
|
|
8
|
+
Search: Search,
|
|
9
|
+
TextArea: Textarea,
|
|
10
|
+
OTP: OTP
|
|
154
11
|
});
|
|
155
|
-
export {
|
|
12
|
+
export { Input };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type HTMLAttributes, type HTMLInputTypeAttribute, type ReactNode } from 'react';
|
|
2
|
+
import { type TaoSize, type TaoStatus } from '../../provider/tao-provider.js';
|
|
3
|
+
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
|
|
4
|
+
import type { InputSemanticValue, InputVariant } from './input-shared.js';
|
|
5
|
+
export type OTPSemanticPart = 'root' | 'input' | 'separator';
|
|
6
|
+
export interface OTPRef {
|
|
7
|
+
focus: () => void;
|
|
8
|
+
blur: () => void;
|
|
9
|
+
nativeElement: HTMLDivElement;
|
|
10
|
+
}
|
|
11
|
+
export interface OTPProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'onInput'> {
|
|
12
|
+
value?: string;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
length?: number;
|
|
15
|
+
formatter?: (value: string) => string;
|
|
16
|
+
separator?: ReactNode | ((index: number) => ReactNode);
|
|
17
|
+
mask?: boolean | string;
|
|
18
|
+
type?: HTMLInputTypeAttribute;
|
|
19
|
+
autoComplete?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
status?: TaoStatus;
|
|
22
|
+
size?: TaoSize;
|
|
23
|
+
variant?: InputVariant;
|
|
24
|
+
onChange?: (value: string) => void;
|
|
25
|
+
onInput?: (value: string[]) => void;
|
|
26
|
+
classNames?: InputSemanticValue<SemanticClassNames<OTPSemanticPart>, OTPProps>;
|
|
27
|
+
styles?: InputSemanticValue<SemanticStyles<OTPSemanticPart>, OTPProps>;
|
|
28
|
+
}
|
|
29
|
+
export declare const OTP: import("react").ForwardRefExoticComponent<OTPProps & import("react").RefAttributes<OTPRef>>;
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { Fragment, forwardRef, useImperativeHandle, useRef, useState } from "react";
|
|
4
|
+
import { useTaoConfig } from "../../provider/tao-provider.js";
|
|
5
|
+
import { cx } from "../../utils/semantic.js";
|
|
6
|
+
import { BaseInput } from "./base-input.js";
|
|
7
|
+
const otp_OTP = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
8
|
+
const $ = c(81);
|
|
9
|
+
let autoComplete;
|
|
10
|
+
let autoFocus;
|
|
11
|
+
let className;
|
|
12
|
+
let customClassNames;
|
|
13
|
+
let customStyles;
|
|
14
|
+
let disabled;
|
|
15
|
+
let formatter;
|
|
16
|
+
let inputMode;
|
|
17
|
+
let onChange;
|
|
18
|
+
let onInput;
|
|
19
|
+
let rest;
|
|
20
|
+
let separator;
|
|
21
|
+
let size;
|
|
22
|
+
let status;
|
|
23
|
+
let style;
|
|
24
|
+
let t0;
|
|
25
|
+
let t1;
|
|
26
|
+
let t2;
|
|
27
|
+
let t3;
|
|
28
|
+
let value;
|
|
29
|
+
let variant;
|
|
30
|
+
if ($[0] !== props) {
|
|
31
|
+
({ value, defaultValue: t0, length: t1, formatter, separator, mask: t2, type: t3, autoComplete, disabled, status, size, variant, onChange, onInput, classNames: customClassNames, styles: customStyles, className, style, autoFocus, inputMode, ...rest } = props);
|
|
32
|
+
$[0] = props;
|
|
33
|
+
$[1] = autoComplete;
|
|
34
|
+
$[2] = autoFocus;
|
|
35
|
+
$[3] = className;
|
|
36
|
+
$[4] = customClassNames;
|
|
37
|
+
$[5] = customStyles;
|
|
38
|
+
$[6] = disabled;
|
|
39
|
+
$[7] = formatter;
|
|
40
|
+
$[8] = inputMode;
|
|
41
|
+
$[9] = onChange;
|
|
42
|
+
$[10] = onInput;
|
|
43
|
+
$[11] = rest;
|
|
44
|
+
$[12] = separator;
|
|
45
|
+
$[13] = size;
|
|
46
|
+
$[14] = status;
|
|
47
|
+
$[15] = style;
|
|
48
|
+
$[16] = t0;
|
|
49
|
+
$[17] = t1;
|
|
50
|
+
$[18] = t2;
|
|
51
|
+
$[19] = t3;
|
|
52
|
+
$[20] = value;
|
|
53
|
+
$[21] = variant;
|
|
54
|
+
} else {
|
|
55
|
+
autoComplete = $[1];
|
|
56
|
+
autoFocus = $[2];
|
|
57
|
+
className = $[3];
|
|
58
|
+
customClassNames = $[4];
|
|
59
|
+
customStyles = $[5];
|
|
60
|
+
disabled = $[6];
|
|
61
|
+
formatter = $[7];
|
|
62
|
+
inputMode = $[8];
|
|
63
|
+
onChange = $[9];
|
|
64
|
+
onInput = $[10];
|
|
65
|
+
rest = $[11];
|
|
66
|
+
separator = $[12];
|
|
67
|
+
size = $[13];
|
|
68
|
+
status = $[14];
|
|
69
|
+
style = $[15];
|
|
70
|
+
t0 = $[16];
|
|
71
|
+
t1 = $[17];
|
|
72
|
+
t2 = $[18];
|
|
73
|
+
t3 = $[19];
|
|
74
|
+
value = $[20];
|
|
75
|
+
variant = $[21];
|
|
76
|
+
}
|
|
77
|
+
const defaultValue = void 0 === t0 ? "" : t0;
|
|
78
|
+
const length = void 0 === t1 ? 6 : t1;
|
|
79
|
+
const mask = void 0 === t2 ? false : t2;
|
|
80
|
+
const type = void 0 === t3 ? "text" : t3;
|
|
81
|
+
if (!Number.isInteger(length) || length < 1) throw new RangeError("Input.OTP length must be a positive integer");
|
|
82
|
+
const ctx = useTaoConfig();
|
|
83
|
+
let t4;
|
|
84
|
+
if ($[22] !== formatter || $[23] !== length) {
|
|
85
|
+
t4 = (text)=>Array.from(formatter ? formatter(text) : text).slice(0, length);
|
|
86
|
+
$[22] = formatter;
|
|
87
|
+
$[23] = length;
|
|
88
|
+
$[24] = t4;
|
|
89
|
+
} else t4 = $[24];
|
|
90
|
+
const format = t4;
|
|
91
|
+
let t5;
|
|
92
|
+
if ($[25] !== defaultValue || $[26] !== format) {
|
|
93
|
+
t5 = ()=>format(defaultValue);
|
|
94
|
+
$[25] = defaultValue;
|
|
95
|
+
$[26] = format;
|
|
96
|
+
$[27] = t5;
|
|
97
|
+
} else t5 = $[27];
|
|
98
|
+
const [innerValue, setInnerValue] = useState(t5);
|
|
99
|
+
const [draft, setDraft] = useState(null);
|
|
100
|
+
let t6;
|
|
101
|
+
if ($[28] !== format || $[29] !== innerValue || $[30] !== value) {
|
|
102
|
+
t6 = void 0 !== value ? format(value) : innerValue;
|
|
103
|
+
$[28] = format;
|
|
104
|
+
$[29] = innerValue;
|
|
105
|
+
$[30] = value;
|
|
106
|
+
$[31] = t6;
|
|
107
|
+
} else t6 = $[31];
|
|
108
|
+
const cells = t6;
|
|
109
|
+
let t7;
|
|
110
|
+
if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
|
|
111
|
+
t7 = [];
|
|
112
|
+
$[32] = t7;
|
|
113
|
+
} else t7 = $[32];
|
|
114
|
+
const inputs = useRef(t7);
|
|
115
|
+
const root = useRef(null);
|
|
116
|
+
const composing = useRef(false);
|
|
117
|
+
let t8;
|
|
118
|
+
if ($[33] !== customClassNames || $[34] !== props) {
|
|
119
|
+
t8 = "function" == typeof customClassNames ? customClassNames({
|
|
120
|
+
props
|
|
121
|
+
}) : customClassNames;
|
|
122
|
+
$[33] = customClassNames;
|
|
123
|
+
$[34] = props;
|
|
124
|
+
$[35] = t8;
|
|
125
|
+
} else t8 = $[35];
|
|
126
|
+
const classNames = t8;
|
|
127
|
+
let t9;
|
|
128
|
+
if ($[36] !== customStyles || $[37] !== props) {
|
|
129
|
+
t9 = "function" == typeof customStyles ? customStyles({
|
|
130
|
+
props
|
|
131
|
+
}) : customStyles;
|
|
132
|
+
$[36] = customStyles;
|
|
133
|
+
$[37] = props;
|
|
134
|
+
$[38] = t9;
|
|
135
|
+
} else t9 = $[38];
|
|
136
|
+
const styles = t9;
|
|
137
|
+
let t10;
|
|
138
|
+
if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
|
|
139
|
+
t10 = (index)=>{
|
|
140
|
+
inputs.current[index]?.focus();
|
|
141
|
+
inputs.current[index]?.select();
|
|
142
|
+
};
|
|
143
|
+
$[39] = t10;
|
|
144
|
+
} else t10 = $[39];
|
|
145
|
+
const focus = t10;
|
|
146
|
+
let t11;
|
|
147
|
+
if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
|
|
148
|
+
t11 = ()=>({
|
|
149
|
+
focus: ()=>focus(0),
|
|
150
|
+
blur: ()=>inputs.current.forEach(_temp),
|
|
151
|
+
nativeElement: root.current
|
|
152
|
+
});
|
|
153
|
+
$[40] = t11;
|
|
154
|
+
} else t11 = $[40];
|
|
155
|
+
useImperativeHandle(ref, t11);
|
|
156
|
+
let t12;
|
|
157
|
+
if ($[41] !== cells || $[42] !== format || $[43] !== length || $[44] !== onChange || $[45] !== onInput || $[46] !== value) {
|
|
158
|
+
t12 = (index_0, text_0)=>{
|
|
159
|
+
const chars = format(text_0);
|
|
160
|
+
const next = Array.from({
|
|
161
|
+
length
|
|
162
|
+
}, (_, i)=>cells[i] ?? "");
|
|
163
|
+
if (chars.length) chars.forEach((char, offset)=>{
|
|
164
|
+
if (index_0 + offset < length) next[index_0 + offset] = char;
|
|
165
|
+
});
|
|
166
|
+
else next[index_0] = "";
|
|
167
|
+
while(next.length && !next[next.length - 1])next.pop();
|
|
168
|
+
if (next.length !== cells.length || next.some((char_0, i_0)=>char_0 !== cells[i_0])) {
|
|
169
|
+
if (void 0 === value) setInnerValue(next);
|
|
170
|
+
onInput?.(next);
|
|
171
|
+
if (next.length === length && next.every(Boolean)) onChange?.(next.join(""));
|
|
172
|
+
}
|
|
173
|
+
if (chars.length) focus(Math.min(index_0 + chars.length, length - 1));
|
|
174
|
+
};
|
|
175
|
+
$[41] = cells;
|
|
176
|
+
$[42] = format;
|
|
177
|
+
$[43] = length;
|
|
178
|
+
$[44] = onChange;
|
|
179
|
+
$[45] = onInput;
|
|
180
|
+
$[46] = value;
|
|
181
|
+
$[47] = t12;
|
|
182
|
+
} else t12 = $[47];
|
|
183
|
+
const update = t12;
|
|
184
|
+
const t13 = rest.role ?? "group";
|
|
185
|
+
const t14 = classNames?.root;
|
|
186
|
+
let t15;
|
|
187
|
+
if ($[48] !== className || $[49] !== t14) {
|
|
188
|
+
t15 = cx(t14, className);
|
|
189
|
+
$[48] = className;
|
|
190
|
+
$[49] = t14;
|
|
191
|
+
$[50] = t15;
|
|
192
|
+
} else t15 = $[50];
|
|
193
|
+
const t16 = styles?.root;
|
|
194
|
+
let t17;
|
|
195
|
+
if ($[51] !== style || $[52] !== t16) {
|
|
196
|
+
t17 = {
|
|
197
|
+
...t16,
|
|
198
|
+
...style
|
|
199
|
+
};
|
|
200
|
+
$[51] = style;
|
|
201
|
+
$[52] = t16;
|
|
202
|
+
$[53] = t17;
|
|
203
|
+
} else t17 = $[53];
|
|
204
|
+
let t18;
|
|
205
|
+
if ($[54] !== autoComplete || $[55] !== autoFocus || $[56] !== cells || $[57] !== classNames?.input || $[58] !== classNames?.separator || $[59] !== ctx || $[60] !== disabled || $[61] !== draft || $[62] !== inputMode || $[63] !== length || $[64] !== mask || $[65] !== rest || $[66] !== separator || $[67] !== size || $[68] !== status || $[69] !== styles?.input || $[70] !== styles?.separator || $[71] !== type || $[72] !== update || $[73] !== variant) {
|
|
206
|
+
t18 = Array.from({
|
|
207
|
+
length
|
|
208
|
+
}, (__0, index_1)=>/*#__PURE__*/ jsxs(Fragment, {
|
|
209
|
+
children: [
|
|
210
|
+
/*#__PURE__*/ jsxs("div", {
|
|
211
|
+
"data-tao-otp-cell": "",
|
|
212
|
+
"data-tao-otp-masked": "string" == typeof mask && cells[index_1] ? "" : void 0,
|
|
213
|
+
children: [
|
|
214
|
+
/*#__PURE__*/ jsx(BaseInput, {
|
|
215
|
+
ref: (node)=>{
|
|
216
|
+
inputs.current[index_1] = node;
|
|
217
|
+
},
|
|
218
|
+
value: draft?.index === index_1 ? draft.value : cells[index_1] ?? "",
|
|
219
|
+
autoFocus: autoFocus && 0 === index_1,
|
|
220
|
+
type: true === mask ? "password" : type,
|
|
221
|
+
inputMode: inputMode,
|
|
222
|
+
autoComplete: autoComplete,
|
|
223
|
+
disabled: disabled,
|
|
224
|
+
status: status,
|
|
225
|
+
size: size,
|
|
226
|
+
variant: variant,
|
|
227
|
+
"aria-label": ctx.locale.otpLabel?.(index_1 + 1, length) ?? `Character ${index_1 + 1} of ${length}`,
|
|
228
|
+
"aria-describedby": rest["aria-describedby"],
|
|
229
|
+
"aria-invalid": rest["aria-invalid"],
|
|
230
|
+
classNames: {
|
|
231
|
+
input: classNames?.input
|
|
232
|
+
},
|
|
233
|
+
styles: {
|
|
234
|
+
input: styles?.input
|
|
235
|
+
},
|
|
236
|
+
onFocus: _temp2,
|
|
237
|
+
onChange: (event_0)=>{
|
|
238
|
+
if (composing.current) setDraft({
|
|
239
|
+
index: index_1,
|
|
240
|
+
value: event_0.target.value
|
|
241
|
+
});
|
|
242
|
+
else update(index_1, event_0.target.value);
|
|
243
|
+
},
|
|
244
|
+
onCompositionStart: ()=>{
|
|
245
|
+
composing.current = true;
|
|
246
|
+
},
|
|
247
|
+
onCompositionEnd: (event_1)=>{
|
|
248
|
+
composing.current = false;
|
|
249
|
+
setDraft(null);
|
|
250
|
+
update(index_1, event_1.currentTarget.value);
|
|
251
|
+
},
|
|
252
|
+
onPaste: (event_2)=>{
|
|
253
|
+
event_2.preventDefault();
|
|
254
|
+
update(index_1, event_2.clipboardData.getData("text"));
|
|
255
|
+
},
|
|
256
|
+
onKeyDown: (event_3)=>{
|
|
257
|
+
if (composing.current || event_3.nativeEvent.isComposing) return;
|
|
258
|
+
if ("ArrowLeft" === event_3.key || "ArrowRight" === event_3.key) {
|
|
259
|
+
event_3.preventDefault();
|
|
260
|
+
const direction = "rtl" === getComputedStyle(root.current).direction ? -1 : 1;
|
|
261
|
+
focus(Math.min(length - 1, Math.max(0, index_1 + ("ArrowRight" === event_3.key ? direction : -direction))));
|
|
262
|
+
} else if ("Backspace" === event_3.key && !cells[index_1] && index_1 > 0) {
|
|
263
|
+
event_3.preventDefault();
|
|
264
|
+
update(index_1 - 1, "");
|
|
265
|
+
focus(index_1 - 1);
|
|
266
|
+
} else if ("Delete" === event_3.key) {
|
|
267
|
+
event_3.preventDefault();
|
|
268
|
+
update(index_1, "");
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}),
|
|
272
|
+
"string" == typeof mask && cells[index_1] && /*#__PURE__*/ jsx("span", {
|
|
273
|
+
"data-tao-otp-mask": "",
|
|
274
|
+
"aria-hidden": "true",
|
|
275
|
+
children: mask
|
|
276
|
+
})
|
|
277
|
+
]
|
|
278
|
+
}),
|
|
279
|
+
index_1 < length - 1 && null != separator && /*#__PURE__*/ jsx("span", {
|
|
280
|
+
"data-tao-otp-separator": "",
|
|
281
|
+
className: classNames?.separator,
|
|
282
|
+
style: styles?.separator,
|
|
283
|
+
children: "function" == typeof separator ? separator(index_1) : separator
|
|
284
|
+
})
|
|
285
|
+
]
|
|
286
|
+
}, `otp-${index_1}`));
|
|
287
|
+
$[54] = autoComplete;
|
|
288
|
+
$[55] = autoFocus;
|
|
289
|
+
$[56] = cells;
|
|
290
|
+
$[57] = classNames?.input;
|
|
291
|
+
$[58] = classNames?.separator;
|
|
292
|
+
$[59] = ctx;
|
|
293
|
+
$[60] = disabled;
|
|
294
|
+
$[61] = draft;
|
|
295
|
+
$[62] = inputMode;
|
|
296
|
+
$[63] = length;
|
|
297
|
+
$[64] = mask;
|
|
298
|
+
$[65] = rest;
|
|
299
|
+
$[66] = separator;
|
|
300
|
+
$[67] = size;
|
|
301
|
+
$[68] = status;
|
|
302
|
+
$[69] = styles?.input;
|
|
303
|
+
$[70] = styles?.separator;
|
|
304
|
+
$[71] = type;
|
|
305
|
+
$[72] = update;
|
|
306
|
+
$[73] = variant;
|
|
307
|
+
$[74] = t18;
|
|
308
|
+
} else t18 = $[74];
|
|
309
|
+
let t19;
|
|
310
|
+
if ($[75] !== rest || $[76] !== t13 || $[77] !== t15 || $[78] !== t17 || $[79] !== t18) {
|
|
311
|
+
t19 = /*#__PURE__*/ jsx("div", {
|
|
312
|
+
...rest,
|
|
313
|
+
ref: root,
|
|
314
|
+
role: t13,
|
|
315
|
+
"data-tao-input-otp": "",
|
|
316
|
+
className: t15,
|
|
317
|
+
style: t17,
|
|
318
|
+
children: t18
|
|
319
|
+
});
|
|
320
|
+
$[75] = rest;
|
|
321
|
+
$[76] = t13;
|
|
322
|
+
$[77] = t15;
|
|
323
|
+
$[78] = t17;
|
|
324
|
+
$[79] = t18;
|
|
325
|
+
$[80] = t19;
|
|
326
|
+
} else t19 = $[80];
|
|
327
|
+
return t19;
|
|
328
|
+
});
|
|
329
|
+
function _temp(input) {
|
|
330
|
+
input?.blur();
|
|
331
|
+
}
|
|
332
|
+
function _temp2(event) {
|
|
333
|
+
return event.currentTarget.select();
|
|
334
|
+
}
|
|
335
|
+
export { otp_OTP as OTP };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type InputProps } from './base-input.js';
|
|
3
|
+
export interface VisibilityToggle {
|
|
4
|
+
visible?: boolean;
|
|
5
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
6
|
+
tabIndex?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface PasswordProps extends InputProps {
|
|
9
|
+
visibilityToggle?: boolean | VisibilityToggle;
|
|
10
|
+
iconRender?: (visible: boolean) => ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare const Password: import("react").ForwardRefExoticComponent<PasswordProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { forwardRef, useState } from "react";
|
|
4
|
+
import { useTaoConfig } from "../../provider/tao-provider.js";
|
|
5
|
+
import { BaseInput } from "./base-input.js";
|
|
6
|
+
const password_Password = /*#__PURE__*/ forwardRef(function(t0, ref) {
|
|
7
|
+
const $ = c(24);
|
|
8
|
+
let disabled;
|
|
9
|
+
let iconRender;
|
|
10
|
+
let props;
|
|
11
|
+
let suffix;
|
|
12
|
+
let t1;
|
|
13
|
+
if ($[0] !== t0) {
|
|
14
|
+
({ visibilityToggle: t1, iconRender, suffix, disabled, ...props } = t0);
|
|
15
|
+
$[0] = t0;
|
|
16
|
+
$[1] = disabled;
|
|
17
|
+
$[2] = iconRender;
|
|
18
|
+
$[3] = props;
|
|
19
|
+
$[4] = suffix;
|
|
20
|
+
$[5] = t1;
|
|
21
|
+
} else {
|
|
22
|
+
disabled = $[1];
|
|
23
|
+
iconRender = $[2];
|
|
24
|
+
props = $[3];
|
|
25
|
+
suffix = $[4];
|
|
26
|
+
t1 = $[5];
|
|
27
|
+
}
|
|
28
|
+
const visibilityToggle = void 0 === t1 ? true : t1;
|
|
29
|
+
const ctx = useTaoConfig();
|
|
30
|
+
const [innerVisible, setVisible] = useState(false);
|
|
31
|
+
let t2;
|
|
32
|
+
if ($[6] !== visibilityToggle) {
|
|
33
|
+
t2 = "object" == typeof visibilityToggle ? visibilityToggle : {};
|
|
34
|
+
$[6] = visibilityToggle;
|
|
35
|
+
$[7] = t2;
|
|
36
|
+
} else t2 = $[7];
|
|
37
|
+
const config = t2;
|
|
38
|
+
const visible = config.visible ?? innerVisible;
|
|
39
|
+
const resolvedDisabled = disabled ?? ctx.disabled;
|
|
40
|
+
const t3 = visible ? "text" : "password";
|
|
41
|
+
let t4;
|
|
42
|
+
if ($[8] !== config || $[9] !== ctx || $[10] !== iconRender || $[11] !== resolvedDisabled || $[12] !== visibilityToggle || $[13] !== visible) {
|
|
43
|
+
t4 = visibilityToggle && /*#__PURE__*/ jsx("button", {
|
|
44
|
+
type: "button",
|
|
45
|
+
"data-tao-input-action": "",
|
|
46
|
+
"aria-label": visible ? ctx.locale.hidePassword ?? "Hide password" : ctx.locale.showPassword ?? "Show password",
|
|
47
|
+
"aria-pressed": visible,
|
|
48
|
+
tabIndex: config.tabIndex,
|
|
49
|
+
disabled: resolvedDisabled,
|
|
50
|
+
onMouseDown: _temp,
|
|
51
|
+
onClick: ()=>{
|
|
52
|
+
if (void 0 === config.visible) setVisible(!visible);
|
|
53
|
+
config.onVisibleChange?.(!visible);
|
|
54
|
+
},
|
|
55
|
+
children: iconRender ? iconRender(visible) : /*#__PURE__*/ jsxs("svg", {
|
|
56
|
+
viewBox: "0 0 24 24",
|
|
57
|
+
fill: "none",
|
|
58
|
+
stroke: "currentColor",
|
|
59
|
+
strokeWidth: "1.8",
|
|
60
|
+
"aria-hidden": "true",
|
|
61
|
+
children: [
|
|
62
|
+
/*#__PURE__*/ jsx("path", {
|
|
63
|
+
d: "M2 12s3-7 10-7 10 7 10 7-3 7-10 7S2 12 2 12Z"
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ jsx("circle", {
|
|
66
|
+
cx: "12",
|
|
67
|
+
cy: "12",
|
|
68
|
+
r: "3"
|
|
69
|
+
}),
|
|
70
|
+
!visible && /*#__PURE__*/ jsx("path", {
|
|
71
|
+
d: "m3 3 18 18"
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
$[8] = config;
|
|
77
|
+
$[9] = ctx;
|
|
78
|
+
$[10] = iconRender;
|
|
79
|
+
$[11] = resolvedDisabled;
|
|
80
|
+
$[12] = visibilityToggle;
|
|
81
|
+
$[13] = visible;
|
|
82
|
+
$[14] = t4;
|
|
83
|
+
} else t4 = $[14];
|
|
84
|
+
let t5;
|
|
85
|
+
if ($[15] !== suffix || $[16] !== t4) {
|
|
86
|
+
t5 = /*#__PURE__*/ jsxs(Fragment, {
|
|
87
|
+
children: [
|
|
88
|
+
suffix,
|
|
89
|
+
t4
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
$[15] = suffix;
|
|
93
|
+
$[16] = t4;
|
|
94
|
+
$[17] = t5;
|
|
95
|
+
} else t5 = $[17];
|
|
96
|
+
let t6;
|
|
97
|
+
if ($[18] !== props || $[19] !== ref || $[20] !== resolvedDisabled || $[21] !== t3 || $[22] !== t5) {
|
|
98
|
+
t6 = /*#__PURE__*/ jsx(BaseInput, {
|
|
99
|
+
...props,
|
|
100
|
+
disabled: resolvedDisabled,
|
|
101
|
+
ref: ref,
|
|
102
|
+
type: t3,
|
|
103
|
+
suffix: t5
|
|
104
|
+
});
|
|
105
|
+
$[18] = props;
|
|
106
|
+
$[19] = ref;
|
|
107
|
+
$[20] = resolvedDisabled;
|
|
108
|
+
$[21] = t3;
|
|
109
|
+
$[22] = t5;
|
|
110
|
+
$[23] = t6;
|
|
111
|
+
} else t6 = $[23];
|
|
112
|
+
return t6;
|
|
113
|
+
});
|
|
114
|
+
function _temp(event) {
|
|
115
|
+
return event.preventDefault();
|
|
116
|
+
}
|
|
117
|
+
export { password_Password as Password };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ChangeEvent, type KeyboardEvent, type MouseEvent, type ReactNode } from 'react';
|
|
2
|
+
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
|
|
3
|
+
import { type InputProps, type InputSemanticPart } from './base-input.js';
|
|
4
|
+
import type { InputSemanticValue } from './input-shared.js';
|
|
5
|
+
export type SearchSemanticPart = InputSemanticPart | 'button';
|
|
6
|
+
export interface SearchProps extends Omit<InputProps, 'onSearch' | 'classNames' | 'styles'> {
|
|
7
|
+
enterButton?: ReactNode;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
searchIcon?: ReactNode;
|
|
10
|
+
onSearch?: (value: string, event?: ChangeEvent<HTMLInputElement> | MouseEvent<HTMLElement> | KeyboardEvent<HTMLInputElement>, info?: {
|
|
11
|
+
source: 'input' | 'clear';
|
|
12
|
+
}) => void;
|
|
13
|
+
classNames?: InputSemanticValue<SemanticClassNames<SearchSemanticPart>, SearchProps>;
|
|
14
|
+
styles?: InputSemanticValue<SemanticStyles<SearchSemanticPart>, SearchProps>;
|
|
15
|
+
}
|
|
16
|
+
export declare const Search: import("react").ForwardRefExoticComponent<SearchProps & import("react").RefAttributes<HTMLInputElement>>;
|