@dxos/react-input 0.8.3 → 0.8.4-main.05e74ebcff
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 +102 -5
- package/dist/lib/browser/index.mjs +243 -171
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +243 -171
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/PinInput.d.ts +5 -10
- package/dist/types/src/PinInput.d.ts.map +1 -1
- package/dist/types/src/Root.d.ts +5 -5
- package/dist/types/src/Root.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -13
- package/src/InputMeta.tsx +15 -15
- package/src/PinInput.tsx +176 -45
- package/src/Root.tsx +2 -2
- package/dist/lib/node/index.cjs +0 -261
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
1
|
+
// src/InputMeta.tsx
|
|
3
2
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
3
|
import { Slot } from "@radix-ui/react-slot";
|
|
5
4
|
import React2, { forwardRef } from "react";
|
|
6
5
|
|
|
7
|
-
//
|
|
8
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
6
|
+
// src/Root.tsx
|
|
9
7
|
import { createContextScope } from "@radix-ui/react-context";
|
|
10
8
|
import React from "react";
|
|
11
9
|
import { useId } from "@dxos/react-hooks";
|
|
@@ -13,200 +11,275 @@ var INPUT_NAME = "Input";
|
|
|
13
11
|
var [createInputContext, createInputScope] = createContextScope(INPUT_NAME, []);
|
|
14
12
|
var [InputProvider, useInputContext] = createInputContext(INPUT_NAME);
|
|
15
13
|
var InputRoot = ({ __inputScope, id: propsId, descriptionId: propsDescriptionId, errorMessageId: propsErrorMessageId, validationValence = "neutral", children }) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
scope: __inputScope
|
|
27
|
-
}, children);
|
|
28
|
-
} finally {
|
|
29
|
-
_effect.f();
|
|
30
|
-
}
|
|
14
|
+
const id = useId("input", propsId);
|
|
15
|
+
const descriptionId = useId("input__description", propsDescriptionId);
|
|
16
|
+
const errorMessageId = useId("input__error-message", propsErrorMessageId);
|
|
17
|
+
return /* @__PURE__ */ React.createElement(InputProvider, {
|
|
18
|
+
id,
|
|
19
|
+
descriptionId,
|
|
20
|
+
errorMessageId,
|
|
21
|
+
validationValence,
|
|
22
|
+
scope: __inputScope
|
|
23
|
+
}, children);
|
|
31
24
|
};
|
|
32
25
|
InputRoot.displayName = INPUT_NAME;
|
|
33
26
|
|
|
34
|
-
//
|
|
27
|
+
// src/InputMeta.tsx
|
|
35
28
|
var Label = /* @__PURE__ */ forwardRef(({ __inputScope, asChild, children, ...props }, forwardedRef) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
ref: forwardedRef
|
|
44
|
-
}, children);
|
|
45
|
-
} finally {
|
|
46
|
-
_effect.f();
|
|
47
|
-
}
|
|
29
|
+
const { id } = useInputContext(INPUT_NAME, __inputScope);
|
|
30
|
+
const Comp = asChild ? Slot : Primitive.label;
|
|
31
|
+
return /* @__PURE__ */ React2.createElement(Comp, {
|
|
32
|
+
...props,
|
|
33
|
+
htmlFor: id,
|
|
34
|
+
ref: forwardedRef
|
|
35
|
+
}, children);
|
|
48
36
|
});
|
|
49
37
|
var Description = /* @__PURE__ */ forwardRef(({ __inputScope, asChild, children, ...props }, forwardedRef) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
ref: forwardedRef
|
|
60
|
-
}, children);
|
|
61
|
-
} finally {
|
|
62
|
-
_effect.f();
|
|
63
|
-
}
|
|
38
|
+
const { descriptionId, validationValence } = useInputContext(INPUT_NAME, __inputScope);
|
|
39
|
+
const Comp = asChild ? Slot : Primitive.span;
|
|
40
|
+
return /* @__PURE__ */ React2.createElement(Comp, {
|
|
41
|
+
...props,
|
|
42
|
+
...validationValence === "error" && {
|
|
43
|
+
id: descriptionId
|
|
44
|
+
},
|
|
45
|
+
ref: forwardedRef
|
|
46
|
+
}, children);
|
|
64
47
|
});
|
|
65
48
|
var ErrorMessage = /* @__PURE__ */ forwardRef(({ __inputScope, asChild, children, ...props }, forwardedRef) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
ref: forwardedRef
|
|
74
|
-
}, children);
|
|
75
|
-
} finally {
|
|
76
|
-
_effect.f();
|
|
77
|
-
}
|
|
49
|
+
const { errorMessageId } = useInputContext(INPUT_NAME, __inputScope);
|
|
50
|
+
const Comp = asChild ? Slot : Primitive.span;
|
|
51
|
+
return /* @__PURE__ */ React2.createElement(Comp, {
|
|
52
|
+
...props,
|
|
53
|
+
id: errorMessageId,
|
|
54
|
+
ref: forwardedRef
|
|
55
|
+
}, children);
|
|
78
56
|
});
|
|
79
57
|
var Validation = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (validationValence === "error") {
|
|
85
|
-
return /* @__PURE__ */ React2.createElement(ErrorMessage, {
|
|
86
|
-
...props,
|
|
87
|
-
ref: forwardedRef
|
|
88
|
-
});
|
|
89
|
-
} else {
|
|
90
|
-
const Root = asChild ? Slot : Primitive.span;
|
|
91
|
-
return /* @__PURE__ */ React2.createElement(Root, {
|
|
92
|
-
...otherProps,
|
|
93
|
-
ref: forwardedRef
|
|
94
|
-
}, children);
|
|
95
|
-
}
|
|
96
|
-
} finally {
|
|
97
|
-
_effect.f();
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
var DescriptionAndValidation = /* @__PURE__ */ forwardRef(({ __inputScope, asChild, children, ...props }, forwardedRef) => {
|
|
101
|
-
var _effect = _useSignals2();
|
|
102
|
-
try {
|
|
103
|
-
const { descriptionId, validationValence } = useInputContext(INPUT_NAME, __inputScope);
|
|
104
|
-
const Root = asChild ? Slot : Primitive.p;
|
|
105
|
-
return /* @__PURE__ */ React2.createElement(Root, {
|
|
58
|
+
const { __inputScope, asChild, children, ...otherProps } = props;
|
|
59
|
+
const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
|
|
60
|
+
if (validationValence === "error") {
|
|
61
|
+
return /* @__PURE__ */ React2.createElement(ErrorMessage, {
|
|
106
62
|
...props,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
63
|
+
ref: forwardedRef
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
const Comp = asChild ? Slot : Primitive.span;
|
|
67
|
+
return /* @__PURE__ */ React2.createElement(Comp, {
|
|
68
|
+
...otherProps,
|
|
110
69
|
ref: forwardedRef
|
|
111
70
|
}, children);
|
|
112
|
-
} finally {
|
|
113
|
-
_effect.f();
|
|
114
71
|
}
|
|
115
72
|
});
|
|
73
|
+
var DescriptionAndValidation = /* @__PURE__ */ forwardRef(({ __inputScope, asChild, children, ...props }, forwardedRef) => {
|
|
74
|
+
const { descriptionId, validationValence } = useInputContext(INPUT_NAME, __inputScope);
|
|
75
|
+
const Comp = asChild ? Slot : Primitive.p;
|
|
76
|
+
return /* @__PURE__ */ React2.createElement(Comp, {
|
|
77
|
+
...props,
|
|
78
|
+
...validationValence !== "error" && {
|
|
79
|
+
id: descriptionId
|
|
80
|
+
},
|
|
81
|
+
ref: forwardedRef
|
|
82
|
+
}, children);
|
|
83
|
+
});
|
|
116
84
|
|
|
117
|
-
//
|
|
118
|
-
import {
|
|
119
|
-
import { CodeInput, getSegmentCssWidth } from "rci";
|
|
120
|
-
import React3, { forwardRef as forwardRef2, useCallback } from "react";
|
|
85
|
+
// src/PinInput.tsx
|
|
86
|
+
import React3, { forwardRef as forwardRef2, useCallback, useEffect, useMemo, useState } from "react";
|
|
121
87
|
import { useForwardedRef, useIsFocused } from "@dxos/react-hooks";
|
|
122
|
-
var PinInput = /* @__PURE__ */ forwardRef2(({ __inputScope,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
88
|
+
var PinInput = /* @__PURE__ */ forwardRef2(({ __inputScope, className, disabled, segmentClassName, length = 6, pattern, value: controlledValue, onChange, onPaste, ...props }, forwardedRef) => {
|
|
89
|
+
const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);
|
|
90
|
+
const inputRef = useForwardedRef(forwardedRef);
|
|
91
|
+
const inputFocused = useIsFocused(inputRef);
|
|
92
|
+
const [internalValue, setInternalValue] = useState("");
|
|
93
|
+
const [cursorPosition, setCursorPosition] = useState(0);
|
|
94
|
+
const value = controlledValue != null ? String(controlledValue) : internalValue;
|
|
95
|
+
const charPattern = useMemo(() => {
|
|
96
|
+
if (!pattern) {
|
|
97
|
+
return void 0;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const base = pattern.replace(/[*+?]$|\{\d+,?\d*\}$/g, "");
|
|
101
|
+
return new RegExp(`^${base}$`);
|
|
102
|
+
} catch {
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
}, [
|
|
106
|
+
pattern
|
|
107
|
+
]);
|
|
108
|
+
const filterValue = useCallback((input) => {
|
|
109
|
+
if (!charPattern) {
|
|
110
|
+
return input;
|
|
111
|
+
}
|
|
112
|
+
return input.split("").filter((char) => charPattern.test(char)).join("");
|
|
113
|
+
}, [
|
|
114
|
+
charPattern
|
|
115
|
+
]);
|
|
116
|
+
const syncCursor = useCallback(() => {
|
|
117
|
+
const pos = inputRef.current?.selectionStart ?? value.length;
|
|
118
|
+
setCursorPosition(Math.min(pos, value.length));
|
|
119
|
+
}, [
|
|
120
|
+
inputRef,
|
|
121
|
+
value.length
|
|
122
|
+
]);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
setCursorPosition((prev) => Math.min(prev, value.length));
|
|
125
|
+
}, [
|
|
126
|
+
value.length
|
|
127
|
+
]);
|
|
128
|
+
const handleChange = useCallback((event) => {
|
|
129
|
+
const newValue = filterValue(event.target.value).slice(0, length);
|
|
130
|
+
if (controlledValue == null) {
|
|
131
|
+
setInternalValue(newValue);
|
|
132
|
+
}
|
|
133
|
+
setCursorPosition(event.target.selectionStart ?? newValue.length);
|
|
134
|
+
onChange?.(event);
|
|
135
|
+
}, [
|
|
136
|
+
length,
|
|
137
|
+
controlledValue,
|
|
138
|
+
onChange,
|
|
139
|
+
filterValue
|
|
140
|
+
]);
|
|
141
|
+
const handlePaste = useCallback((event) => {
|
|
142
|
+
onPaste?.(event);
|
|
143
|
+
if (event.defaultPrevented) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
const pasted = filterValue(event.clipboardData.getData("text/plain")).slice(0, length);
|
|
148
|
+
const input = inputRef.current;
|
|
149
|
+
if (!input) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set;
|
|
153
|
+
nativeInputValueSetter?.call(input, pasted);
|
|
154
|
+
input.dispatchEvent(new Event("input", {
|
|
155
|
+
bubbles: true
|
|
156
|
+
}));
|
|
157
|
+
}, [
|
|
158
|
+
length,
|
|
159
|
+
inputRef,
|
|
160
|
+
onPaste,
|
|
161
|
+
filterValue
|
|
162
|
+
]);
|
|
163
|
+
const handleKeyDown = useCallback((event) => {
|
|
164
|
+
if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
|
165
|
+
requestAnimationFrame(syncCursor);
|
|
166
|
+
} else if (event.key === "Backspace" && value.length === 0) {
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
} else if (event.key.length === 1 && !event.metaKey && !event.ctrlKey && !event.altKey) {
|
|
169
|
+
if (charPattern && !charPattern.test(event.key)) {
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
props.onKeyDown?.(event);
|
|
172
|
+
return;
|
|
139
173
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
174
|
+
const input = inputRef.current;
|
|
175
|
+
const pos = input?.selectionStart ?? value.length;
|
|
176
|
+
if (pos < value.length && input) {
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
const newValue = value.slice(0, pos) + event.key + value.slice(pos + 1);
|
|
179
|
+
const newPos = Math.min(pos + 1, length);
|
|
180
|
+
if (controlledValue == null) {
|
|
181
|
+
setInternalValue(newValue);
|
|
182
|
+
}
|
|
183
|
+
setCursorPosition(newPos);
|
|
184
|
+
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set;
|
|
185
|
+
nativeInputValueSetter?.call(input, newValue);
|
|
186
|
+
input.setSelectionRange(newPos, newPos);
|
|
187
|
+
onChange?.({
|
|
188
|
+
target: input,
|
|
189
|
+
currentTarget: input
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
props.onKeyDown?.(event);
|
|
194
|
+
}, [
|
|
195
|
+
value,
|
|
196
|
+
length,
|
|
197
|
+
props.onKeyDown,
|
|
198
|
+
syncCursor,
|
|
199
|
+
inputRef,
|
|
200
|
+
charPattern,
|
|
201
|
+
controlledValue,
|
|
202
|
+
onChange
|
|
203
|
+
]);
|
|
204
|
+
const handleSelect = useCallback(() => {
|
|
205
|
+
syncCursor();
|
|
206
|
+
}, [
|
|
207
|
+
syncCursor
|
|
208
|
+
]);
|
|
209
|
+
const activeIndex = Math.min(cursorPosition, value.length < length ? value.length : length - 1);
|
|
210
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
211
|
+
className: `relative inline-flex items-center gap-2 ${className ?? ""}`
|
|
212
|
+
}, /* @__PURE__ */ React3.createElement("input", {
|
|
213
|
+
ref: inputRef,
|
|
214
|
+
id,
|
|
215
|
+
type: "text",
|
|
216
|
+
value,
|
|
217
|
+
onChange: handleChange,
|
|
218
|
+
onPaste: handlePaste,
|
|
219
|
+
onKeyDown: handleKeyDown,
|
|
220
|
+
onSelect: handleSelect,
|
|
221
|
+
maxLength: length,
|
|
222
|
+
disabled,
|
|
223
|
+
spellCheck: false,
|
|
224
|
+
"aria-describedby": descriptionId,
|
|
225
|
+
...validationValence === "error" && {
|
|
226
|
+
"aria-invalid": "true",
|
|
227
|
+
"aria-errormessage": errorMessageId
|
|
228
|
+
},
|
|
229
|
+
...props,
|
|
230
|
+
pattern,
|
|
231
|
+
className: "dx-fullscreen opacity-0",
|
|
232
|
+
style: {
|
|
233
|
+
caretColor: "transparent",
|
|
234
|
+
...props.style
|
|
235
|
+
}
|
|
236
|
+
}), Array.from({
|
|
237
|
+
length
|
|
238
|
+
}, (_, index) => {
|
|
239
|
+
const char = value[index] || "\xA0";
|
|
240
|
+
const isCursor = !!(inputFocused && index === activeIndex);
|
|
241
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
242
|
+
key: index,
|
|
243
|
+
className: segmentClassName,
|
|
244
|
+
...isCursor && {
|
|
245
|
+
"data-focused": ""
|
|
157
246
|
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
});
|
|
162
|
-
} finally {
|
|
163
|
-
_effect.f();
|
|
164
|
-
}
|
|
247
|
+
"aria-hidden": "true"
|
|
248
|
+
}, char);
|
|
249
|
+
}));
|
|
165
250
|
});
|
|
166
251
|
|
|
167
|
-
//
|
|
168
|
-
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
252
|
+
// src/TextInput.tsx
|
|
169
253
|
import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
|
|
170
254
|
import React4, { forwardRef as forwardRef3 } from "react";
|
|
171
255
|
var TextInput = /* @__PURE__ */ forwardRef3(({ __inputScope, ...props }, forwardedRef) => {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
"aria-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
ref: forwardedRef
|
|
184
|
-
});
|
|
185
|
-
} finally {
|
|
186
|
-
_effect.f();
|
|
187
|
-
}
|
|
256
|
+
const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);
|
|
257
|
+
return /* @__PURE__ */ React4.createElement(Primitive2.input, {
|
|
258
|
+
...props,
|
|
259
|
+
id,
|
|
260
|
+
"aria-describedby": descriptionId,
|
|
261
|
+
...validationValence === "error" && {
|
|
262
|
+
"aria-invalid": "true",
|
|
263
|
+
"aria-errormessage": errorMessageId
|
|
264
|
+
},
|
|
265
|
+
ref: forwardedRef
|
|
266
|
+
});
|
|
188
267
|
});
|
|
189
268
|
|
|
190
|
-
//
|
|
191
|
-
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
269
|
+
// src/TextArea.tsx
|
|
192
270
|
import React5, { forwardRef as forwardRef4 } from "react";
|
|
193
271
|
var TextArea = /* @__PURE__ */ forwardRef4(({ __inputScope, ...props }, forwardedRef) => {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
"aria-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
ref: forwardedRef
|
|
206
|
-
});
|
|
207
|
-
} finally {
|
|
208
|
-
_effect.f();
|
|
209
|
-
}
|
|
272
|
+
const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);
|
|
273
|
+
return /* @__PURE__ */ React5.createElement("textarea", {
|
|
274
|
+
...props,
|
|
275
|
+
id,
|
|
276
|
+
"aria-describedby": descriptionId,
|
|
277
|
+
...validationValence === "error" && {
|
|
278
|
+
"aria-invalid": "true",
|
|
279
|
+
"aria-errormessage": errorMessageId
|
|
280
|
+
},
|
|
281
|
+
ref: forwardedRef
|
|
282
|
+
});
|
|
210
283
|
});
|
|
211
284
|
export {
|
|
212
285
|
Description,
|
|
@@ -216,7 +289,6 @@ export {
|
|
|
216
289
|
InputRoot,
|
|
217
290
|
Label,
|
|
218
291
|
PinInput,
|
|
219
|
-
InputRoot as Root,
|
|
220
292
|
TextArea,
|
|
221
293
|
TextInput,
|
|
222
294
|
Validation,
|