@rockshin/tao-ui 0.0.42 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +7 -1
  2. package/component-manifest.json +34 -17
  3. package/dist/components/alert/alert.css +1 -0
  4. package/dist/components/avatar/avatar.js +1 -1
  5. package/dist/components/calendar/calendar.css +10 -60
  6. package/dist/components/calendar/calendar.js +46 -43
  7. package/dist/components/card/card.css +1 -1
  8. package/dist/components/carousel/carousel.css +1 -0
  9. package/dist/components/carousel/carousel.js +62 -7
  10. package/dist/components/collapse/collapse-panels.d.ts +4 -0
  11. package/dist/components/collapse/collapse-panels.js +413 -0
  12. package/dist/components/collapse/collapse.css +199 -0
  13. package/dist/components/collapse/collapse.d.ts +77 -0
  14. package/dist/components/{collapsible/collapsible.js → collapse/collapse.js} +26 -10
  15. package/dist/components/color-picker/color-picker.css +8 -42
  16. package/dist/components/color-picker/color-picker.js +220 -145
  17. package/dist/components/date-picker/date-picker.css +18 -56
  18. package/dist/components/date-picker/date-picker.d.ts +2 -0
  19. package/dist/components/date-picker/date-picker.js +11 -6
  20. package/dist/components/date-picker/presets.js +5 -2
  21. package/dist/components/date-picker/range-picker.d.ts +2 -0
  22. package/dist/components/date-picker/range-picker.js +3 -1
  23. package/dist/components/form/form-item.js +1 -0
  24. package/dist/components/form/form.css +15 -0
  25. package/dist/components/form/form.js +1 -0
  26. package/dist/components/form-field/form-field-view.d.ts +3 -1
  27. package/dist/components/form-field/form-field-view.js +109 -84
  28. package/dist/components/input/base-input.d.ts +25 -0
  29. package/dist/components/input/base-input.js +104 -0
  30. package/dist/components/input/input-shared.css +75 -0
  31. package/dist/components/input/input-shared.d.ts +59 -0
  32. package/dist/components/input/input-shared.js +152 -0
  33. package/dist/components/input/input.css +99 -4
  34. package/dist/components/input/input.d.ts +12 -16
  35. package/dist/components/input/input.js +11 -154
  36. package/dist/components/input/otp.d.ts +29 -0
  37. package/dist/components/input/otp.js +335 -0
  38. package/dist/components/input/password.d.ts +12 -0
  39. package/dist/components/input/password.js +117 -0
  40. package/dist/components/input/search.d.ts +16 -0
  41. package/dist/components/input/search.js +99 -0
  42. package/dist/components/input-number/input-number.d.ts +2 -2
  43. package/dist/components/input-number/input-number.js +2 -2
  44. package/dist/components/list/list-pagination.css +5 -5
  45. package/dist/components/list/list-pagination.js +1 -0
  46. package/dist/components/mentions/mentions.css +7 -0
  47. package/dist/components/modal/modal.css +1 -0
  48. package/dist/components/radio/radio.d.ts +1 -1
  49. package/dist/components/radio/radio.js +78 -73
  50. package/dist/components/select/mobile-select.css +1 -16
  51. package/dist/components/select/mobile-select.d.ts +2 -1
  52. package/dist/components/select/mobile-select.js +68 -63
  53. package/dist/components/select/select-types.d.ts +2 -0
  54. package/dist/components/select/select.css +19 -0
  55. package/dist/components/select/select.js +31 -17
  56. package/dist/components/spinner/spinner.css +1 -1
  57. package/dist/components/steps/steps.css +53 -3
  58. package/dist/components/table/table.css +0 -5
  59. package/dist/components/table/table.js +21 -22
  60. package/dist/components/textarea/textarea.css +20 -0
  61. package/dist/components/textarea/textarea.d.ts +12 -6
  62. package/dist/components/textarea/textarea.js +120 -219
  63. package/dist/components/time-picker/time-picker.css +7 -0
  64. package/dist/components/tree/tree-check.d.ts +1 -0
  65. package/dist/components/tree/tree-check.js +36 -0
  66. package/dist/components/tree/tree.css +13 -18
  67. package/dist/components/tree/tree.js +2 -3
  68. package/dist/components/tree-select/select-engine.css +7 -0
  69. package/dist/components/tree-select/tree-select.js +2 -3
  70. package/dist/components/upload/upload.css +0 -11
  71. package/dist/components/upload/upload.js +13 -3
  72. package/dist/docs/component-docs.js +2 -2
  73. package/dist/docs/components/{collapsible.doc.d.ts → collapse.doc.d.ts} +1 -1
  74. package/dist/docs/components/collapse.doc.js +47 -0
  75. package/dist/docs/components/input.doc.js +11 -4
  76. package/dist/docs/components/textarea.doc.js +4 -2
  77. package/dist/entries/collapse.d.ts +3 -0
  78. package/dist/entries/{collapsible.js → collapse.js} +1 -1
  79. package/dist/entries/input.d.ts +1 -1
  80. package/dist/entries/textarea.d.ts +1 -1
  81. package/dist/index.d.ts +3 -3
  82. package/dist/index.js +1 -1
  83. package/dist/provider/locale.d.ts +6 -0
  84. package/dist/provider/locale.js +10 -0
  85. package/dist/provider/tao-provider.js +1 -0
  86. package/dist/theme/control.css +2 -2
  87. package/dist/theme/theme.css +3 -1
  88. package/dist/theme/tokens.d.ts +2 -2
  89. package/dist/theme/tokens.js +1 -0
  90. package/dist/utils/field-label.d.ts +4 -0
  91. package/dist/utils/field-label.js +7 -0
  92. package/llms.txt +18 -15
  93. package/package.json +7 -4
  94. package/dist/components/collapsible/collapsible.css +0 -49
  95. package/dist/components/collapsible/collapsible.d.ts +0 -39
  96. package/dist/docs/components/collapsible.doc.js +0 -39
  97. package/dist/entries/collapsible.d.ts +0 -3
@@ -0,0 +1,75 @@
1
+ [data-tao-input-action] {
2
+ padding: var(--tao-padding-xxs);
3
+ color: var(--tao-color-text-tertiary);
4
+ cursor: pointer;
5
+ border-radius: var(--tao-radius-sm);
6
+ background: none;
7
+ border: 0;
8
+ flex-shrink: 0;
9
+ justify-content: center;
10
+ align-items: center;
11
+ display: inline-flex;
12
+ }
13
+
14
+ [data-tao-input-action]:hover {
15
+ color: var(--tao-color-text);
16
+ }
17
+
18
+ [data-tao-input-action]:disabled {
19
+ color: var(--tao-color-text-disabled);
20
+ cursor: not-allowed;
21
+ }
22
+
23
+ [data-tao-input-action]:focus-visible {
24
+ outline: 2px solid var(--tao-primary);
25
+ outline-offset: -2px;
26
+ }
27
+
28
+ [data-tao-input-action] svg {
29
+ width: 16px;
30
+ height: 16px;
31
+ }
32
+
33
+ [data-tao-input-count] {
34
+ color: var(--tao-color-text-tertiary);
35
+ font-size: var(--tao-font-size-sm);
36
+ white-space: nowrap;
37
+ font-variant-numeric: tabular-nums;
38
+ }
39
+
40
+ [data-tao-input-count][data-tao-exceeded] {
41
+ color: var(--tao-error);
42
+ }
43
+
44
+ @media (hover: hover) and (pointer: fine) {
45
+ :is([data-tao-input], [data-tao-textarea]):not(:hover):not(:focus-within) [data-tao-input-clear] {
46
+ opacity: 0;
47
+ }
48
+ }
49
+
50
+ :is([data-tao-input], [data-tao-textarea])[data-tao-control][data-tao-variant="underlined"] {
51
+ border: var(--tao-line-width) solid transparent;
52
+ border-block-end-color: var(--tao-color-border);
53
+ background: none;
54
+ border-radius: 0;
55
+ }
56
+
57
+ :is([data-tao-input], [data-tao-textarea])[data-tao-variant="underlined"]:not([data-disabled]):is(:hover, :focus-within) {
58
+ border-block-end-color: var(--tao-input-underline-status, var(--tao-primary));
59
+ }
60
+
61
+ :is([data-tao-input], [data-tao-textarea])[data-tao-variant="underlined"][data-tao-warning] {
62
+ --tao-input-underline-status: var(--tao-warning);
63
+ border-block-end-color: var(--tao-warning);
64
+ }
65
+
66
+ :is([data-tao-input], [data-tao-textarea])[data-tao-variant="underlined"][data-tao-error] {
67
+ --tao-input-underline-status: var(--tao-error);
68
+ border-block-end-color: var(--tao-error);
69
+ }
70
+
71
+ :is([data-tao-input], [data-tao-textarea])[data-tao-variant="underlined"][data-disabled] {
72
+ color: var(--tao-color-text-disabled);
73
+ cursor: not-allowed;
74
+ }
75
+
@@ -0,0 +1,59 @@
1
+ import { type ChangeEvent, type CSSProperties, type KeyboardEvent, type MouseEvent, type ReactNode, type Ref, type RefObject } from 'react';
2
+ import { type TaoVariant } from '../../provider/tao-provider.js';
3
+ import './input-shared.css';
4
+ export type InputVariant = TaoVariant | 'underlined';
5
+ export interface InputFocusOptions extends FocusOptions {
6
+ cursor?: 'start' | 'end' | 'all';
7
+ }
8
+ export interface CountConfig {
9
+ max?: number;
10
+ strategy?: (value: string) => number;
11
+ show?: boolean | ((info: CountInfo) => ReactNode);
12
+ exceedFormatter?: (value: string, config: {
13
+ max: number;
14
+ }) => string;
15
+ }
16
+ export interface CountInfo {
17
+ value: string;
18
+ count: number;
19
+ maxLength?: number;
20
+ }
21
+ export interface AllowClearConfig {
22
+ clearIcon?: ReactNode;
23
+ disabled?: boolean;
24
+ tabIndex?: number;
25
+ }
26
+ export interface TextControlProps<T extends HTMLInputElement | HTMLTextAreaElement> {
27
+ allowClear?: boolean | AllowClearConfig;
28
+ onClear?: () => void;
29
+ showCount?: boolean | {
30
+ formatter: (info: CountInfo) => ReactNode;
31
+ };
32
+ count?: CountConfig;
33
+ onPressEnter?: (event: KeyboardEvent<T>) => void;
34
+ }
35
+ export type InputSemanticValue<T, P> = T | ((info: {
36
+ props: P;
37
+ }) => T);
38
+ /** Keep native DOM refs compatible while adding the documented cursor options. */
39
+ export declare function useTextControlRef<T extends HTMLInputElement | HTMLTextAreaElement>(ref: Ref<T> | undefined, nodeRef: RefObject<T | null>, rootRef: RefObject<HTMLDivElement | null>): void;
40
+ export declare function useTextControl<T extends HTMLInputElement | HTMLTextAreaElement>(props: TextControlProps<T> & {
41
+ value?: string | number | readonly string[];
42
+ defaultValue?: string | number | readonly string[];
43
+ maxLength?: number;
44
+ onChange?: (event: ChangeEvent<T>) => void;
45
+ }, nodeRef: RefObject<T | null>): {
46
+ value: string;
47
+ composing: RefObject<boolean>;
48
+ change: (event: ChangeEvent<T>, next?: string) => void;
49
+ normalize: (next: string) => string;
50
+ clear: (event: MouseEvent<HTMLButtonElement>) => void;
51
+ counter: ReactNode;
52
+ exceeded: boolean;
53
+ };
54
+ export declare function InputClear({ config, onClick, className, style, }: {
55
+ config: boolean | AllowClearConfig;
56
+ onClick: (event: MouseEvent<HTMLButtonElement>) => void;
57
+ className?: string;
58
+ style?: CSSProperties;
59
+ }): import("react").JSX.Element;
@@ -0,0 +1,152 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { c } from "react-compiler-runtime";
3
+ import { useEffect, useImperativeHandle, useRef, useState } from "react";
4
+ import { useTaoConfig } from "../../provider/tao-provider.js";
5
+ import { mergeRefs } from "../../utils/refs.js";
6
+ import { CloseIcon } from "../select/select-icons.js";
7
+ import "./input-shared.css";
8
+ function useTextControlRef(ref, nodeRef, rootRef) {
9
+ const $ = c(5);
10
+ let t0;
11
+ if ($[0] !== ref) {
12
+ t0 = mergeRefs(ref);
13
+ $[0] = ref;
14
+ $[1] = t0;
15
+ } else t0 = $[1];
16
+ let t1;
17
+ if ($[2] !== nodeRef || $[3] !== rootRef) {
18
+ t1 = ()=>{
19
+ const node = nodeRef.current;
20
+ const nativeFocus = Object.getPrototypeOf(node).focus ?? HTMLElement.prototype.focus;
21
+ return Object.assign(node, {
22
+ input: node,
23
+ textArea: node,
24
+ nativeElement: rootRef.current,
25
+ focus (options) {
26
+ nativeFocus.call(node, options);
27
+ if (options?.cursor && (node instanceof HTMLTextAreaElement || [
28
+ "text",
29
+ "search",
30
+ "password",
31
+ "tel",
32
+ "url"
33
+ ].includes(node.type))) {
34
+ const end = node.value.length;
35
+ node.setSelectionRange("end" === options.cursor ? end : 0, "start" === options.cursor ? 0 : end);
36
+ }
37
+ }
38
+ });
39
+ };
40
+ $[2] = nodeRef;
41
+ $[3] = rootRef;
42
+ $[4] = t1;
43
+ } else t1 = $[4];
44
+ useImperativeHandle(t0, t1);
45
+ }
46
+ function useTextControl(props, nodeRef) {
47
+ const [innerValue, setInnerValue] = useState(String(props.defaultValue ?? ''));
48
+ const value = void 0 !== props.value ? String(props.value ?? '') : innerValue;
49
+ const composing = useRef(false);
50
+ const count = props.count?.strategy?.(value) ?? value.length;
51
+ const max = props.count?.max ?? props.maxLength;
52
+ const show = props.count?.show ?? props.showCount;
53
+ const info = {
54
+ value,
55
+ count,
56
+ maxLength: max
57
+ };
58
+ const counter = 'function' == typeof show ? show(info) : 'object' == typeof show ? show.formatter(info) : void 0 === max ? count : `${count} / ${max}`;
59
+ const normalize = (next)=>{
60
+ const config = props.count;
61
+ return config?.exceedFormatter && void 0 !== max && (config.strategy?.(next) ?? next.length) > max ? config.exceedFormatter(next, {
62
+ max
63
+ }) : next;
64
+ };
65
+ const change = (event, next_0 = event.target.value)=>{
66
+ const normalized = composing.current ? next_0 : normalize(next_0);
67
+ event.target.value = normalized;
68
+ if (void 0 === props.value) setInnerValue(normalized);
69
+ props.onChange?.(event);
70
+ };
71
+ useEffect(()=>{
72
+ const form = nodeRef.current?.form;
73
+ const reset = (event_0)=>{
74
+ queueMicrotask(()=>{
75
+ if (!event_0.defaultPrevented && void 0 === props.value) setInnerValue(String(props.defaultValue ?? ''));
76
+ });
77
+ };
78
+ form?.addEventListener('reset', reset);
79
+ return ()=>form?.removeEventListener('reset', reset);
80
+ }, [
81
+ nodeRef,
82
+ props.value,
83
+ props.defaultValue
84
+ ]);
85
+ const clear = (event_1)=>{
86
+ const target = nodeRef.current.cloneNode(true);
87
+ target.value = '';
88
+ change({
89
+ ...event_1,
90
+ target,
91
+ currentTarget: target
92
+ }, '');
93
+ props.onClear?.();
94
+ nodeRef.current?.focus();
95
+ };
96
+ return {
97
+ value,
98
+ composing,
99
+ change,
100
+ normalize,
101
+ clear,
102
+ counter: show ? counter : null,
103
+ exceeded: void 0 !== max && count > max
104
+ };
105
+ }
106
+ function InputClear(t0) {
107
+ const $ = c(12);
108
+ const { config, onClick, className, style } = t0;
109
+ const { locale } = useTaoConfig();
110
+ let t1;
111
+ if ($[0] !== config) {
112
+ t1 = "object" == typeof config ? config : {};
113
+ $[0] = config;
114
+ $[1] = t1;
115
+ } else t1 = $[1];
116
+ const options = t1;
117
+ let t2;
118
+ if ($[2] !== options.clearIcon) {
119
+ t2 = options.clearIcon ?? /*#__PURE__*/ jsx(CloseIcon, {});
120
+ $[2] = options.clearIcon;
121
+ $[3] = t2;
122
+ } else t2 = $[3];
123
+ let t3;
124
+ if ($[4] !== className || $[5] !== locale.clear || $[6] !== onClick || $[7] !== options.disabled || $[8] !== options.tabIndex || $[9] !== style || $[10] !== t2) {
125
+ t3 = /*#__PURE__*/ jsx("button", {
126
+ type: "button",
127
+ "data-tao-input-clear": "",
128
+ "data-tao-input-action": "",
129
+ className: className,
130
+ style: style,
131
+ "aria-label": locale.clear,
132
+ disabled: options.disabled,
133
+ tabIndex: options.tabIndex,
134
+ onMouseDown: _temp,
135
+ onClick: onClick,
136
+ children: t2
137
+ });
138
+ $[4] = className;
139
+ $[5] = locale.clear;
140
+ $[6] = onClick;
141
+ $[7] = options.disabled;
142
+ $[8] = options.tabIndex;
143
+ $[9] = style;
144
+ $[10] = t2;
145
+ $[11] = t3;
146
+ } else t3 = $[11];
147
+ return t3;
148
+ }
149
+ function _temp(event) {
150
+ return event.preventDefault();
151
+ }
152
+ export { InputClear, useTextControl, useTextControlRef };
@@ -85,18 +85,18 @@
85
85
  cursor: not-allowed;
86
86
  }
87
87
 
88
- [data-tao-prefix], [data-tao-suffix] {
88
+ [data-tao-input] > [data-tao-prefix], [data-tao-input] > [data-tao-suffix] {
89
89
  color: var(--tao-color-text-tertiary);
90
90
  flex-shrink: 0;
91
91
  align-items: center;
92
92
  display: flex;
93
93
  }
94
94
 
95
- [data-tao-prefix], [data-tao-input] [data-tao-prefix] + input {
95
+ [data-tao-input] > [data-tao-prefix], [data-tao-input] [data-tao-prefix] + input {
96
96
  padding-inline-start: var(--tao-input-affix-padding);
97
97
  }
98
98
 
99
- [data-tao-prefix] svg, [data-tao-suffix] svg {
99
+ [data-tao-input] > [data-tao-prefix] svg, [data-tao-input] > [data-tao-suffix] svg {
100
100
  width: 16px;
101
101
  height: 16px;
102
102
  }
@@ -120,7 +120,102 @@
120
120
  var(--tao-input-affix-padding));
121
121
  }
122
122
 
123
- [data-tao-suffix] {
123
+ [data-tao-input] > [data-tao-suffix] {
124
124
  padding-inline-end: var(--tao-input-affix-padding);
125
125
  }
126
126
 
127
+ [data-tao-input-addon] {
128
+ padding-inline: var(--tao-padding-xs);
129
+ background: var(--tao-color-fill-quaternary);
130
+ font-size: var(--tao-font-size-base);
131
+ color: var(--tao-color-text);
132
+ align-self: stretch;
133
+ align-items: center;
134
+ display: inline-flex;
135
+ }
136
+
137
+ [data-tao-input-addon]:first-child {
138
+ border-inline-end: var(--tao-line-width) solid var(--tao-color-border);
139
+ }
140
+
141
+ [data-tao-input-addon]:last-child {
142
+ border-inline-start: var(--tao-line-width) solid var(--tao-color-border);
143
+ }
144
+
145
+ [data-tao-input]:has([data-tao-input-addon]) [data-tao-prefix] {
146
+ padding-inline-start: var(--tao-input-affix-padding);
147
+ position: static;
148
+ transform: none;
149
+ }
150
+
151
+ [data-tao-input]:has([data-tao-input-addon]) input {
152
+ padding-inline-start: var(--tao-input-affix-padding);
153
+ }
154
+
155
+ [data-tao-input] > [data-tao-input-count] {
156
+ padding-inline-end: var(--tao-input-affix-padding);
157
+ }
158
+
159
+ [data-tao-input] > [data-tao-input-action]:last-child {
160
+ margin-inline-end: var(--tao-padding-xxs);
161
+ }
162
+
163
+ [data-tao-input-search] {
164
+ align-items: stretch;
165
+ width: 100%;
166
+ min-width: 0;
167
+ display: flex;
168
+ }
169
+
170
+ [data-tao-input-search] > [data-tao-input] {
171
+ border-start-end-radius: 0;
172
+ border-end-end-radius: 0;
173
+ flex: 1;
174
+ min-width: 0;
175
+ }
176
+
177
+ [data-tao-input-search] > button {
178
+ border-start-start-radius: 0;
179
+ border-end-start-radius: 0;
180
+ flex-shrink: 0;
181
+ margin-inline-start: calc(-1 * var(--tao-line-width));
182
+ }
183
+
184
+ [data-tao-input-otp] {
185
+ gap: var(--tao-padding-xs);
186
+ align-items: center;
187
+ max-width: 100%;
188
+ display: inline-flex;
189
+ }
190
+
191
+ [data-tao-otp-cell] {
192
+ flex: 0 1 var(--tao-control-height-lg);
193
+ min-width: 0;
194
+ width: var(--tao-control-height-lg);
195
+ position: relative;
196
+ }
197
+
198
+ [data-tao-otp-cell] [data-tao-input] input {
199
+ text-align: center;
200
+ padding-inline: var(--tao-padding-xxs);
201
+ }
202
+
203
+ [data-tao-otp-masked] input {
204
+ color: #0000;
205
+ caret-color: var(--tao-color-text);
206
+ }
207
+
208
+ [data-tao-otp-mask] {
209
+ pointer-events: none;
210
+ color: var(--tao-color-text);
211
+ justify-content: center;
212
+ align-items: center;
213
+ display: flex;
214
+ position: absolute;
215
+ inset: 0;
216
+ }
217
+
218
+ [data-tao-otp-separator] {
219
+ color: var(--tao-color-text-secondary);
220
+ }
221
+
@@ -1,16 +1,12 @@
1
- import { type InputHTMLAttributes, type ReactNode } from 'react';
2
- import { type TaoSize, type TaoStatus, type TaoVariant } from '../../provider/tao-provider.js';
3
- import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
4
- import './input.css';
5
- export type InputSemanticPart = 'root' | 'input' | 'prefix' | 'suffix';
6
- export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix'> {
7
- size?: TaoSize;
8
- variant?: TaoVariant;
9
- prefix?: ReactNode;
10
- suffix?: ReactNode;
11
- error?: boolean;
12
- status?: TaoStatus;
13
- classNames?: SemanticClassNames<InputSemanticPart>;
14
- styles?: SemanticStyles<InputSemanticPart>;
15
- }
16
- export declare const Input: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<HTMLInputElement>>;
1
+ export type { TextareaProps as TextAreaProps, TextareaRef as TextAreaRef, } from '../textarea/textarea.js';
2
+ export type { InputProps, InputRef, InputSemanticPart } from './base-input.js';
3
+ export type { AllowClearConfig, CountConfig, CountInfo, InputFocusOptions, InputVariant, } from './input-shared.js';
4
+ export type { OTPProps, OTPRef, OTPSemanticPart } from './otp.js';
5
+ export type { PasswordProps, VisibilityToggle } from './password.js';
6
+ export type { SearchProps, SearchSemanticPart } from './search.js';
7
+ export declare const Input: import("react").ForwardRefExoticComponent<import("./base-input.js").InputProps & import("react").RefAttributes<HTMLInputElement>> & {
8
+ Password: import("react").ForwardRefExoticComponent<import("./password.js").PasswordProps & import("react").RefAttributes<HTMLInputElement>>;
9
+ Search: import("react").ForwardRefExoticComponent<import("./search.js").SearchProps & import("react").RefAttributes<HTMLInputElement>>;
10
+ TextArea: import("react").ForwardRefExoticComponent<Omit<import("./input.js").TextAreaProps, "ref"> & import("react").RefAttributes<HTMLTextAreaElement>>;
11
+ OTP: import("react").ForwardRefExoticComponent<import("./otp.js").OTPProps & import("react").RefAttributes<import("./otp.js").OTPRef>>;
12
+ };
@@ -1,155 +1,12 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { c } from "react-compiler-runtime";
3
- import { forwardRef } from "react";
4
- import { useTaoConfig } from "../../provider/tao-provider.js";
5
- import { cx } from "../../utils/semantic.js";
6
- import "./input.css";
7
- const input_Input = /*#__PURE__*/ forwardRef(function(t0, ref) {
8
- const $ = c(45);
9
- let className;
10
- let classNames;
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 { input_Input as Input };
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>>;