@metamask-previews/design-system-react 0.23.1-preview.620b9f3 → 0.24.0-preview.a0fe3894
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/CHANGELOG.md +9 -1
- package/dist/components/Icon/icons/FlashFilled.cjs +32 -0
- package/dist/components/Icon/icons/FlashFilled.cjs.map +1 -0
- package/dist/components/Icon/icons/FlashFilled.d.cts +4 -0
- package/dist/components/Icon/icons/FlashFilled.d.cts.map +1 -0
- package/dist/components/Icon/icons/FlashFilled.d.mts +4 -0
- package/dist/components/Icon/icons/FlashFilled.d.mts.map +1 -0
- package/dist/components/Icon/icons/FlashFilled.mjs +7 -0
- package/dist/components/Icon/icons/FlashFilled.mjs.map +1 -0
- package/dist/components/Icon/icons/index.cjs +2 -0
- package/dist/components/Icon/icons/index.cjs.map +1 -1
- package/dist/components/Icon/icons/index.d.cts +1 -0
- package/dist/components/Icon/icons/index.d.cts.map +1 -1
- package/dist/components/Icon/icons/index.d.mts +1 -0
- package/dist/components/Icon/icons/index.d.mts.map +1 -1
- package/dist/components/Icon/icons/index.mjs +2 -0
- package/dist/components/Icon/icons/index.mjs.map +1 -1
- package/dist/components/TextField/TextField.cjs +77 -0
- package/dist/components/TextField/TextField.cjs.map +1 -0
- package/dist/components/TextField/TextField.d.cts +324 -0
- package/dist/components/TextField/TextField.d.cts.map +1 -0
- package/dist/components/TextField/TextField.d.mts +324 -0
- package/dist/components/TextField/TextField.d.mts.map +1 -0
- package/dist/components/TextField/TextField.mjs +58 -0
- package/dist/components/TextField/TextField.mjs.map +1 -0
- package/dist/components/TextField/TextField.types.cjs +26 -0
- package/dist/components/TextField/TextField.types.cjs.map +1 -0
- package/dist/components/TextField/TextField.types.d.cts +102 -0
- package/dist/components/TextField/TextField.types.d.cts.map +1 -0
- package/dist/components/TextField/TextField.types.d.mts +102 -0
- package/dist/components/TextField/TextField.types.d.mts.map +1 -0
- package/dist/components/TextField/TextField.types.mjs +23 -0
- package/dist/components/TextField/TextField.types.mjs.map +1 -0
- package/dist/components/TextField/index.cjs +9 -0
- package/dist/components/TextField/index.cjs.map +1 -0
- package/dist/components/TextField/index.d.cts +4 -0
- package/dist/components/TextField/index.d.cts.map +1 -0
- package/dist/components/TextField/index.d.mts +4 -0
- package/dist/components/TextField/index.d.mts.map +1 -0
- package/dist/components/TextField/index.mjs +3 -0
- package/dist/components/TextField/index.mjs.map +1 -0
- package/dist/components/Toast/Toast.cjs +74 -0
- package/dist/components/Toast/Toast.cjs.map +1 -0
- package/dist/components/Toast/Toast.constants.cjs +25 -0
- package/dist/components/Toast/Toast.constants.cjs.map +1 -0
- package/dist/components/Toast/Toast.constants.d.cts +16 -0
- package/dist/components/Toast/Toast.constants.d.cts.map +1 -0
- package/dist/components/Toast/Toast.constants.d.mts +16 -0
- package/dist/components/Toast/Toast.constants.d.mts.map +1 -0
- package/dist/components/Toast/Toast.constants.mjs +20 -0
- package/dist/components/Toast/Toast.constants.mjs.map +1 -0
- package/dist/components/Toast/Toast.d.cts +4 -0
- package/dist/components/Toast/Toast.d.cts.map +1 -0
- package/dist/components/Toast/Toast.d.mts +4 -0
- package/dist/components/Toast/Toast.d.mts.map +1 -0
- package/dist/components/Toast/Toast.mjs +55 -0
- package/dist/components/Toast/Toast.mjs.map +1 -0
- package/dist/components/Toast/Toast.types.cjs +3 -0
- package/dist/components/Toast/Toast.types.cjs.map +1 -0
- package/dist/components/Toast/Toast.types.d.cts +60 -0
- package/dist/components/Toast/Toast.types.d.cts.map +1 -0
- package/dist/components/Toast/Toast.types.d.mts +60 -0
- package/dist/components/Toast/Toast.types.d.mts.map +1 -0
- package/dist/components/Toast/Toast.types.mjs +2 -0
- package/dist/components/Toast/Toast.types.mjs.map +1 -0
- package/dist/components/Toast/Toaster.cjs +174 -0
- package/dist/components/Toast/Toaster.cjs.map +1 -0
- package/dist/components/Toast/Toaster.d.cts +11 -0
- package/dist/components/Toast/Toaster.d.cts.map +1 -0
- package/dist/components/Toast/Toaster.d.mts +11 -0
- package/dist/components/Toast/Toaster.d.mts.map +1 -0
- package/dist/components/Toast/Toaster.mjs +155 -0
- package/dist/components/Toast/Toaster.mjs.map +1 -0
- package/dist/components/Toast/index.cjs +11 -0
- package/dist/components/Toast/index.cjs.map +1 -0
- package/dist/components/Toast/index.d.cts +5 -0
- package/dist/components/Toast/index.d.cts.map +1 -0
- package/dist/components/Toast/index.d.mts +5 -0
- package/dist/components/Toast/index.d.mts.map +1 -0
- package/dist/components/Toast/index.mjs +4 -0
- package/dist/components/Toast/index.mjs.map +1 -0
- package/dist/components/index.cjs +10 -1
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +4 -0
- package/dist/components/index.d.cts.map +1 -1
- package/dist/components/index.d.mts +4 -0
- package/dist/components/index.d.mts.map +1 -1
- package/dist/components/index.mjs +2 -0
- package/dist/components/index.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TextFieldSize, TextFieldType } from "./TextField.types.mjs";
|
|
3
|
+
export declare const TextField: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "onFocus" | "onBlur" | "onChange" | "onClick"> & Omit<import("@metamask-previews/design-system-shared").InputPropsShared, "isStateStylesDisabled" | "textVariant"> & {
|
|
4
|
+
isError?: boolean | undefined;
|
|
5
|
+
startAccessory?: React.ReactNode;
|
|
6
|
+
endAccessory?: React.ReactNode;
|
|
7
|
+
inputElement?: React.ReactNode;
|
|
8
|
+
} & {
|
|
9
|
+
size?: TextFieldSize | undefined;
|
|
10
|
+
type?: TextFieldType | undefined;
|
|
11
|
+
truncate?: boolean | undefined;
|
|
12
|
+
maxLength?: number | undefined;
|
|
13
|
+
name?: string | undefined;
|
|
14
|
+
id?: string | undefined;
|
|
15
|
+
required?: boolean | undefined;
|
|
16
|
+
inputProps?: {
|
|
17
|
+
max?: string | number | undefined;
|
|
18
|
+
key?: React.Key | null | undefined;
|
|
19
|
+
height?: string | number | undefined;
|
|
20
|
+
width?: string | number | undefined;
|
|
21
|
+
min?: string | number | undefined;
|
|
22
|
+
color?: string | undefined;
|
|
23
|
+
content?: string | undefined;
|
|
24
|
+
translate?: "yes" | "no" | undefined;
|
|
25
|
+
hidden?: boolean | undefined;
|
|
26
|
+
form?: string | undefined;
|
|
27
|
+
slot?: string | undefined;
|
|
28
|
+
style?: React.CSSProperties | undefined;
|
|
29
|
+
title?: string | undefined;
|
|
30
|
+
dir?: string | undefined;
|
|
31
|
+
pattern?: string | undefined;
|
|
32
|
+
rel?: string | undefined;
|
|
33
|
+
accessKey?: string | undefined;
|
|
34
|
+
draggable?: (boolean | "false" | "true") | undefined;
|
|
35
|
+
inert?: boolean | undefined;
|
|
36
|
+
lang?: string | undefined;
|
|
37
|
+
popover?: "" | "auto" | "manual" | "hint" | undefined;
|
|
38
|
+
className?: string | undefined;
|
|
39
|
+
part?: string | undefined;
|
|
40
|
+
prefix?: string | undefined;
|
|
41
|
+
role?: React.AriaRole | undefined;
|
|
42
|
+
children?: React.ReactNode;
|
|
43
|
+
contentEditable?: "inherit" | (boolean | "false" | "true") | "plaintext-only" | undefined;
|
|
44
|
+
enterKeyHint?: "search" | "next" | "done" | "enter" | "go" | "previous" | "send" | undefined;
|
|
45
|
+
inputMode?: "search" | "numeric" | "none" | "url" | "text" | "email" | "tel" | "decimal" | undefined;
|
|
46
|
+
nonce?: string | undefined;
|
|
47
|
+
tabIndex?: number | undefined;
|
|
48
|
+
multiple?: boolean | undefined;
|
|
49
|
+
size?: number | undefined;
|
|
50
|
+
accept?: string | undefined;
|
|
51
|
+
alt?: string | undefined;
|
|
52
|
+
autoComplete?: React.HTMLInputAutoCompleteAttribute | undefined;
|
|
53
|
+
capture?: boolean | "environment" | "user" | undefined;
|
|
54
|
+
checked?: boolean | undefined;
|
|
55
|
+
formAction?: string | ((formData: FormData) => void | Promise<void>) | undefined;
|
|
56
|
+
formEncType?: string | undefined;
|
|
57
|
+
formMethod?: string | undefined;
|
|
58
|
+
formNoValidate?: boolean | undefined;
|
|
59
|
+
formTarget?: string | undefined;
|
|
60
|
+
list?: string | undefined;
|
|
61
|
+
minLength?: number | undefined;
|
|
62
|
+
src?: string | undefined;
|
|
63
|
+
step?: string | number | undefined;
|
|
64
|
+
defaultChecked?: boolean | undefined;
|
|
65
|
+
suppressContentEditableWarning?: boolean | undefined;
|
|
66
|
+
suppressHydrationWarning?: boolean | undefined;
|
|
67
|
+
autoCapitalize?: "none" | "off" | "on" | (string & {}) | "words" | "sentences" | "characters" | undefined;
|
|
68
|
+
contextMenu?: string | undefined;
|
|
69
|
+
spellCheck?: (boolean | "false" | "true") | undefined;
|
|
70
|
+
radioGroup?: string | undefined;
|
|
71
|
+
about?: string | undefined;
|
|
72
|
+
datatype?: string | undefined;
|
|
73
|
+
inlist?: any;
|
|
74
|
+
property?: string | undefined;
|
|
75
|
+
resource?: string | undefined;
|
|
76
|
+
rev?: string | undefined;
|
|
77
|
+
typeof?: string | undefined;
|
|
78
|
+
vocab?: string | undefined;
|
|
79
|
+
autoCorrect?: string | undefined;
|
|
80
|
+
autoSave?: string | undefined;
|
|
81
|
+
itemProp?: string | undefined;
|
|
82
|
+
itemScope?: boolean | undefined;
|
|
83
|
+
itemType?: string | undefined;
|
|
84
|
+
itemID?: string | undefined;
|
|
85
|
+
itemRef?: string | undefined;
|
|
86
|
+
results?: number | undefined;
|
|
87
|
+
security?: string | undefined;
|
|
88
|
+
unselectable?: "off" | "on" | undefined;
|
|
89
|
+
popoverTargetAction?: "hide" | "show" | "toggle" | undefined;
|
|
90
|
+
popoverTarget?: string | undefined;
|
|
91
|
+
is?: string | undefined;
|
|
92
|
+
exportparts?: string | undefined;
|
|
93
|
+
"aria-activedescendant"?: string | undefined;
|
|
94
|
+
"aria-atomic"?: (boolean | "false" | "true") | undefined;
|
|
95
|
+
"aria-autocomplete"?: "inline" | "both" | "none" | "list" | undefined;
|
|
96
|
+
"aria-braillelabel"?: string | undefined;
|
|
97
|
+
"aria-brailleroledescription"?: string | undefined;
|
|
98
|
+
"aria-busy"?: (boolean | "false" | "true") | undefined;
|
|
99
|
+
"aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
|
|
100
|
+
"aria-colcount"?: number | undefined;
|
|
101
|
+
"aria-colindex"?: number | undefined;
|
|
102
|
+
"aria-colindextext"?: string | undefined;
|
|
103
|
+
"aria-colspan"?: number | undefined;
|
|
104
|
+
"aria-controls"?: string | undefined;
|
|
105
|
+
"aria-current"?: boolean | "false" | "time" | "location" | "page" | "true" | "step" | "date" | undefined;
|
|
106
|
+
"aria-describedby"?: string | undefined;
|
|
107
|
+
"aria-description"?: string | undefined;
|
|
108
|
+
"aria-details"?: string | undefined;
|
|
109
|
+
"aria-disabled"?: (boolean | "false" | "true") | undefined;
|
|
110
|
+
"aria-dropeffect"?: "link" | "none" | "copy" | "move" | "execute" | "popup" | undefined;
|
|
111
|
+
"aria-errormessage"?: string | undefined;
|
|
112
|
+
"aria-expanded"?: (boolean | "false" | "true") | undefined;
|
|
113
|
+
"aria-flowto"?: string | undefined;
|
|
114
|
+
"aria-grabbed"?: (boolean | "false" | "true") | undefined;
|
|
115
|
+
"aria-haspopup"?: boolean | "false" | "grid" | "dialog" | "menu" | "listbox" | "true" | "tree" | undefined;
|
|
116
|
+
"aria-hidden"?: (boolean | "false" | "true") | undefined;
|
|
117
|
+
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
|
|
118
|
+
"aria-keyshortcuts"?: string | undefined;
|
|
119
|
+
"aria-label"?: string | undefined;
|
|
120
|
+
"aria-labelledby"?: string | undefined;
|
|
121
|
+
"aria-level"?: number | undefined;
|
|
122
|
+
"aria-live"?: "off" | "assertive" | "polite" | undefined;
|
|
123
|
+
"aria-modal"?: (boolean | "false" | "true") | undefined;
|
|
124
|
+
"aria-multiline"?: (boolean | "false" | "true") | undefined;
|
|
125
|
+
"aria-multiselectable"?: (boolean | "false" | "true") | undefined;
|
|
126
|
+
"aria-orientation"?: "horizontal" | "vertical" | undefined;
|
|
127
|
+
"aria-owns"?: string | undefined;
|
|
128
|
+
"aria-placeholder"?: string | undefined;
|
|
129
|
+
"aria-posinset"?: number | undefined;
|
|
130
|
+
"aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
|
|
131
|
+
"aria-readonly"?: (boolean | "false" | "true") | undefined;
|
|
132
|
+
"aria-relevant"?: "all" | "text" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
|
|
133
|
+
"aria-required"?: (boolean | "false" | "true") | undefined;
|
|
134
|
+
"aria-roledescription"?: string | undefined;
|
|
135
|
+
"aria-rowcount"?: number | undefined;
|
|
136
|
+
"aria-rowindex"?: number | undefined;
|
|
137
|
+
"aria-rowindextext"?: string | undefined;
|
|
138
|
+
"aria-rowspan"?: number | undefined;
|
|
139
|
+
"aria-selected"?: (boolean | "false" | "true") | undefined;
|
|
140
|
+
"aria-setsize"?: number | undefined;
|
|
141
|
+
"aria-sort"?: "none" | "other" | "ascending" | "descending" | undefined;
|
|
142
|
+
"aria-valuemax"?: number | undefined;
|
|
143
|
+
"aria-valuemin"?: number | undefined;
|
|
144
|
+
"aria-valuenow"?: number | undefined;
|
|
145
|
+
"aria-valuetext"?: string | undefined;
|
|
146
|
+
dangerouslySetInnerHTML?: {
|
|
147
|
+
__html: string | TrustedHTML;
|
|
148
|
+
} | undefined;
|
|
149
|
+
onCopy?: React.ClipboardEventHandler<HTMLInputElement> | undefined;
|
|
150
|
+
onCopyCapture?: React.ClipboardEventHandler<HTMLInputElement> | undefined;
|
|
151
|
+
onCut?: React.ClipboardEventHandler<HTMLInputElement> | undefined;
|
|
152
|
+
onCutCapture?: React.ClipboardEventHandler<HTMLInputElement> | undefined;
|
|
153
|
+
onPaste?: React.ClipboardEventHandler<HTMLInputElement> | undefined;
|
|
154
|
+
onPasteCapture?: React.ClipboardEventHandler<HTMLInputElement> | undefined;
|
|
155
|
+
onCompositionEnd?: React.CompositionEventHandler<HTMLInputElement> | undefined;
|
|
156
|
+
onCompositionEndCapture?: React.CompositionEventHandler<HTMLInputElement> | undefined;
|
|
157
|
+
onCompositionStart?: React.CompositionEventHandler<HTMLInputElement> | undefined;
|
|
158
|
+
onCompositionStartCapture?: React.CompositionEventHandler<HTMLInputElement> | undefined;
|
|
159
|
+
onCompositionUpdate?: React.CompositionEventHandler<HTMLInputElement> | undefined;
|
|
160
|
+
onCompositionUpdateCapture?: React.CompositionEventHandler<HTMLInputElement> | undefined;
|
|
161
|
+
onFocusCapture?: React.FocusEventHandler<HTMLInputElement> | undefined;
|
|
162
|
+
onBlurCapture?: React.FocusEventHandler<HTMLInputElement> | undefined;
|
|
163
|
+
onChangeCapture?: React.ChangeEventHandler<HTMLInputElement, Element> | undefined;
|
|
164
|
+
onBeforeInput?: React.InputEventHandler<HTMLInputElement> | undefined;
|
|
165
|
+
onBeforeInputCapture?: React.InputEventHandler<HTMLInputElement> | undefined;
|
|
166
|
+
onInput?: React.InputEventHandler<HTMLInputElement> | undefined;
|
|
167
|
+
onInputCapture?: React.InputEventHandler<HTMLInputElement> | undefined;
|
|
168
|
+
onReset?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
169
|
+
onResetCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
170
|
+
onSubmit?: React.SubmitEventHandler<HTMLInputElement> | undefined;
|
|
171
|
+
onSubmitCapture?: React.SubmitEventHandler<HTMLInputElement> | undefined;
|
|
172
|
+
onInvalid?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
173
|
+
onInvalidCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
174
|
+
onLoad?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
175
|
+
onLoadCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
176
|
+
onError?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
177
|
+
onErrorCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
178
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLInputElement> | undefined;
|
|
179
|
+
onKeyDownCapture?: React.KeyboardEventHandler<HTMLInputElement> | undefined;
|
|
180
|
+
onKeyPress?: React.KeyboardEventHandler<HTMLInputElement> | undefined;
|
|
181
|
+
onKeyPressCapture?: React.KeyboardEventHandler<HTMLInputElement> | undefined;
|
|
182
|
+
onKeyUp?: React.KeyboardEventHandler<HTMLInputElement> | undefined;
|
|
183
|
+
onKeyUpCapture?: React.KeyboardEventHandler<HTMLInputElement> | undefined;
|
|
184
|
+
onAbort?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
185
|
+
onAbortCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
186
|
+
onCanPlay?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
187
|
+
onCanPlayCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
188
|
+
onCanPlayThrough?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
189
|
+
onCanPlayThroughCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
190
|
+
onDurationChange?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
191
|
+
onDurationChangeCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
192
|
+
onEmptied?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
193
|
+
onEmptiedCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
194
|
+
onEncrypted?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
195
|
+
onEncryptedCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
196
|
+
onEnded?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
197
|
+
onEndedCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
198
|
+
onLoadedData?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
199
|
+
onLoadedDataCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
200
|
+
onLoadedMetadata?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
201
|
+
onLoadedMetadataCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
202
|
+
onLoadStart?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
203
|
+
onLoadStartCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
204
|
+
onPause?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
205
|
+
onPauseCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
206
|
+
onPlay?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
207
|
+
onPlayCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
208
|
+
onPlaying?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
209
|
+
onPlayingCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
210
|
+
onProgress?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
211
|
+
onProgressCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
212
|
+
onRateChange?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
213
|
+
onRateChangeCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
214
|
+
onSeeked?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
215
|
+
onSeekedCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
216
|
+
onSeeking?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
217
|
+
onSeekingCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
218
|
+
onStalled?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
219
|
+
onStalledCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
220
|
+
onSuspend?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
221
|
+
onSuspendCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
222
|
+
onTimeUpdate?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
223
|
+
onTimeUpdateCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
224
|
+
onVolumeChange?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
225
|
+
onVolumeChangeCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
226
|
+
onWaiting?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
227
|
+
onWaitingCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
228
|
+
onAuxClick?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
229
|
+
onAuxClickCapture?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
230
|
+
onClick?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
231
|
+
onClickCapture?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
232
|
+
onContextMenu?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
233
|
+
onContextMenuCapture?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
234
|
+
onDoubleClick?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
235
|
+
onDoubleClickCapture?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
236
|
+
onDrag?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
237
|
+
onDragCapture?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
238
|
+
onDragEnd?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
239
|
+
onDragEndCapture?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
240
|
+
onDragEnter?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
241
|
+
onDragEnterCapture?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
242
|
+
onDragExit?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
243
|
+
onDragExitCapture?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
244
|
+
onDragLeave?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
245
|
+
onDragLeaveCapture?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
246
|
+
onDragOver?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
247
|
+
onDragOverCapture?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
248
|
+
onDragStart?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
249
|
+
onDragStartCapture?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
250
|
+
onDrop?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
251
|
+
onDropCapture?: React.DragEventHandler<HTMLInputElement> | undefined;
|
|
252
|
+
onMouseDown?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
253
|
+
onMouseDownCapture?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
254
|
+
onMouseEnter?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
255
|
+
onMouseLeave?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
256
|
+
onMouseMove?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
257
|
+
onMouseMoveCapture?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
258
|
+
onMouseOut?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
259
|
+
onMouseOutCapture?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
260
|
+
onMouseOver?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
261
|
+
onMouseOverCapture?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
262
|
+
onMouseUp?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
263
|
+
onMouseUpCapture?: React.MouseEventHandler<HTMLInputElement> | undefined;
|
|
264
|
+
onSelect?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
265
|
+
onSelectCapture?: React.ReactEventHandler<HTMLInputElement> | undefined;
|
|
266
|
+
onTouchCancel?: React.TouchEventHandler<HTMLInputElement> | undefined;
|
|
267
|
+
onTouchCancelCapture?: React.TouchEventHandler<HTMLInputElement> | undefined;
|
|
268
|
+
onTouchEnd?: React.TouchEventHandler<HTMLInputElement> | undefined;
|
|
269
|
+
onTouchEndCapture?: React.TouchEventHandler<HTMLInputElement> | undefined;
|
|
270
|
+
onTouchMove?: React.TouchEventHandler<HTMLInputElement> | undefined;
|
|
271
|
+
onTouchMoveCapture?: React.TouchEventHandler<HTMLInputElement> | undefined;
|
|
272
|
+
onTouchStart?: React.TouchEventHandler<HTMLInputElement> | undefined;
|
|
273
|
+
onTouchStartCapture?: React.TouchEventHandler<HTMLInputElement> | undefined;
|
|
274
|
+
onPointerDown?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
275
|
+
onPointerDownCapture?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
276
|
+
onPointerMove?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
277
|
+
onPointerMoveCapture?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
278
|
+
onPointerUp?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
279
|
+
onPointerUpCapture?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
280
|
+
onPointerCancel?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
281
|
+
onPointerCancelCapture?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
282
|
+
onPointerEnter?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
283
|
+
onPointerLeave?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
284
|
+
onPointerOver?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
285
|
+
onPointerOverCapture?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
286
|
+
onPointerOut?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
287
|
+
onPointerOutCapture?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
288
|
+
onGotPointerCapture?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
289
|
+
onGotPointerCaptureCapture?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
290
|
+
onLostPointerCapture?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
291
|
+
onLostPointerCaptureCapture?: React.PointerEventHandler<HTMLInputElement> | undefined;
|
|
292
|
+
onScroll?: React.UIEventHandler<HTMLInputElement> | undefined;
|
|
293
|
+
onScrollCapture?: React.UIEventHandler<HTMLInputElement> | undefined;
|
|
294
|
+
onScrollEnd?: React.UIEventHandler<HTMLInputElement> | undefined;
|
|
295
|
+
onScrollEndCapture?: React.UIEventHandler<HTMLInputElement> | undefined;
|
|
296
|
+
onWheel?: React.WheelEventHandler<HTMLInputElement> | undefined;
|
|
297
|
+
onWheelCapture?: React.WheelEventHandler<HTMLInputElement> | undefined;
|
|
298
|
+
onAnimationStart?: React.AnimationEventHandler<HTMLInputElement> | undefined;
|
|
299
|
+
onAnimationStartCapture?: React.AnimationEventHandler<HTMLInputElement> | undefined;
|
|
300
|
+
onAnimationEnd?: React.AnimationEventHandler<HTMLInputElement> | undefined;
|
|
301
|
+
onAnimationEndCapture?: React.AnimationEventHandler<HTMLInputElement> | undefined;
|
|
302
|
+
onAnimationIteration?: React.AnimationEventHandler<HTMLInputElement> | undefined;
|
|
303
|
+
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLInputElement> | undefined;
|
|
304
|
+
onToggle?: React.ToggleEventHandler<HTMLInputElement> | undefined;
|
|
305
|
+
onBeforeToggle?: React.ToggleEventHandler<HTMLInputElement> | undefined;
|
|
306
|
+
onTransitionCancel?: React.TransitionEventHandler<HTMLInputElement> | undefined;
|
|
307
|
+
onTransitionCancelCapture?: React.TransitionEventHandler<HTMLInputElement> | undefined;
|
|
308
|
+
onTransitionEnd?: React.TransitionEventHandler<HTMLInputElement> | undefined;
|
|
309
|
+
onTransitionEndCapture?: React.TransitionEventHandler<HTMLInputElement> | undefined;
|
|
310
|
+
onTransitionRun?: React.TransitionEventHandler<HTMLInputElement> | undefined;
|
|
311
|
+
onTransitionRunCapture?: React.TransitionEventHandler<HTMLInputElement> | undefined;
|
|
312
|
+
onTransitionStart?: React.TransitionEventHandler<HTMLInputElement> | undefined;
|
|
313
|
+
onTransitionStartCapture?: React.TransitionEventHandler<HTMLInputElement> | undefined;
|
|
314
|
+
textVariant?: import("@metamask-previews/design-system-shared").TextVariant | undefined;
|
|
315
|
+
} | undefined;
|
|
316
|
+
inputRef?: React.Ref<HTMLInputElement> | undefined;
|
|
317
|
+
onChange?: ((event: React.ChangeEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
318
|
+
onFocus?: ((event: React.FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
319
|
+
onBlur?: ((event: React.FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
320
|
+
onClick?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
|
|
321
|
+
className?: string | undefined;
|
|
322
|
+
style?: React.CSSProperties | undefined;
|
|
323
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
324
|
+
//# sourceMappingURL=TextField.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.d.mts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,cAAc;AAKf,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,8BAA0B;AASjE,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCA2IrB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function $importDefault(module) {
|
|
2
|
+
if (module?.__esModule) {
|
|
3
|
+
return module.default;
|
|
4
|
+
}
|
|
5
|
+
return module;
|
|
6
|
+
}
|
|
7
|
+
import $React, { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
8
|
+
const React = $importDefault($React);
|
|
9
|
+
import { twMerge } from "../../utils/tw-merge.mjs";
|
|
10
|
+
import { Input } from "../Input/index.mjs";
|
|
11
|
+
import { TextFieldSize, TextFieldType } from "./TextField.types.mjs";
|
|
12
|
+
const SIZE_CLASS = {
|
|
13
|
+
[TextFieldSize.Sm]: 'h-8',
|
|
14
|
+
[TextFieldSize.Md]: 'h-10',
|
|
15
|
+
[TextFieldSize.Lg]: 'h-12',
|
|
16
|
+
};
|
|
17
|
+
export const TextField = forwardRef(({ autoFocus = false, className, id, inputElement, inputProps, inputRef, isDisabled = false, isError = false, isReadOnly = false, maxLength, name, onBlur, onChange, onClick, onFocus, placeholder, required, size = TextFieldSize.Md, startAccessory, endAccessory, style, truncate = true, type = TextFieldType.Text, value, ...rest }, ref) => {
|
|
18
|
+
const internalInputRef = useRef(null);
|
|
19
|
+
const [isFocused, setIsFocused] = useState(autoFocus);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (isDisabled) {
|
|
22
|
+
setIsFocused(false);
|
|
23
|
+
}
|
|
24
|
+
}, [isDisabled]);
|
|
25
|
+
const handleClick = useCallback((event) => {
|
|
26
|
+
if (isDisabled) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
internalInputRef.current?.focus();
|
|
30
|
+
onClick?.(event);
|
|
31
|
+
}, [isDisabled, onClick]);
|
|
32
|
+
const handleFocus = useCallback((event) => {
|
|
33
|
+
setIsFocused(true);
|
|
34
|
+
onFocus?.(event);
|
|
35
|
+
}, [onFocus]);
|
|
36
|
+
const handleBlur = useCallback((event) => {
|
|
37
|
+
setIsFocused(false);
|
|
38
|
+
onBlur?.(event);
|
|
39
|
+
}, [onBlur]);
|
|
40
|
+
const handleInputRef = useCallback((node) => {
|
|
41
|
+
internalInputRef.current = node;
|
|
42
|
+
if (typeof inputRef === 'function') {
|
|
43
|
+
inputRef(node);
|
|
44
|
+
}
|
|
45
|
+
else if (inputRef && 'current' in inputRef) {
|
|
46
|
+
inputRef.current = node;
|
|
47
|
+
}
|
|
48
|
+
}, [inputRef]);
|
|
49
|
+
const { className: inputClassNameFromProps, ...inputRest } = inputProps ?? {};
|
|
50
|
+
const containerClassName = twMerge('inline-flex items-center rounded-lg border bg-default transition-colors', SIZE_CLASS[size], startAccessory ? 'pl-4' : 'pl-0', endAccessory ? 'pr-4' : 'pr-0', isDisabled && 'cursor-not-allowed border-muted opacity-50', !isDisabled && isError && 'border-error-default', !isDisabled && !isError && isFocused && 'border-default', !isDisabled && !isError && !isFocused && 'border-muted', className);
|
|
51
|
+
const innerInputClassName = twMerge('m-0 h-full min-w-0 flex-1 border-0 bg-transparent p-0', startAccessory ? 'pl-2' : 'pl-4', endAccessory ? 'pr-2' : 'pr-4', truncate && 'truncate', inputClassNameFromProps);
|
|
52
|
+
return (React.createElement("div", { ref: ref, className: containerClassName, style: style, onClick: handleClick, ...rest },
|
|
53
|
+
startAccessory,
|
|
54
|
+
inputElement ?? (React.createElement(Input, { ...inputRest, ref: handleInputRef, id: id, name: name, type: type, value: value, placeholder: placeholder, autoFocus: autoFocus, isDisabled: isDisabled, isReadOnly: isReadOnly, isStateStylesDisabled: true, maxLength: maxLength, required: required, "aria-invalid": isError || undefined, onChange: onChange, onFocus: handleFocus, onBlur: handleBlur, className: innerInputClassName })),
|
|
55
|
+
endAccessory));
|
|
56
|
+
});
|
|
57
|
+
TextField.displayName = 'TextField';
|
|
58
|
+
//# sourceMappingURL=TextField.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.mjs","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,QAAO,EACZ,UAAU,EACV,WAAW,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AAU,IAAI,CAAC,OAAO,IAAI,SAAS,IAAI,gBAAgB,EACxD,CAAC,UAAU,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,IAAI,cAAc,EACvD,SAAS,CACV,CAAC;IAEF,MAAM,mBAAmB,GAAG,OAAO,CACjC,uDAAuD,EACvD,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAChC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAC9B,QAAQ,IAAI,UAAU,EACtB,uBAAuB,CACxB,CAAC;IAEF,OAAO,CACL,6BACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,kBAAkB,EAC7B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,WAAW,KAChB,IAAI;QAEP,cAAc;QACd,YAAY,IAAI,CACf,oBAAC,KAAK,OACA,SAAS,EACb,GAAG,EAAE,cAAc,EACnB,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,qBAAqB,QACrB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,kBACJ,OAAO,IAAI,SAAS,EAClC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,mBAAmB,GAC9B,CACH;QACA,YAAY,CACT,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC","sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { Input } from '../Input';\n\nimport { TextFieldSize, TextFieldType } from './TextField.types';\nimport type { TextFieldProps } from './TextField.types';\n\nconst SIZE_CLASS: Record<TextFieldSize, string> = {\n [TextFieldSize.Sm]: 'h-8',\n [TextFieldSize.Md]: 'h-10',\n [TextFieldSize.Lg]: 'h-12',\n};\n\nexport const TextField = forwardRef<HTMLDivElement, TextFieldProps>(\n (\n {\n autoFocus = false,\n className,\n id,\n inputElement,\n inputProps,\n inputRef,\n isDisabled = false,\n isError = false,\n isReadOnly = false,\n maxLength,\n name,\n onBlur,\n onChange,\n onClick,\n onFocus,\n placeholder,\n required,\n size = TextFieldSize.Md,\n startAccessory,\n endAccessory,\n style,\n truncate = true,\n type = TextFieldType.Text,\n value,\n ...rest\n },\n ref,\n ) => {\n const internalInputRef = useRef<HTMLInputElement | null>(null);\n const [isFocused, setIsFocused] = useState(autoFocus);\n\n useEffect(() => {\n if (isDisabled) {\n setIsFocused(false);\n }\n }, [isDisabled]);\n\n const handleClick = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n if (isDisabled) {\n return;\n }\n internalInputRef.current?.focus();\n onClick?.(event);\n },\n [isDisabled, onClick],\n );\n\n const handleFocus = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n setIsFocused(true);\n onFocus?.(event);\n },\n [onFocus],\n );\n\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n setIsFocused(false);\n onBlur?.(event);\n },\n [onBlur],\n );\n\n const handleInputRef = useCallback(\n (node: HTMLInputElement | null) => {\n internalInputRef.current = node;\n if (typeof inputRef === 'function') {\n inputRef(node);\n } else if (inputRef && 'current' in inputRef) {\n (\n inputRef as React.MutableRefObject<HTMLInputElement | null>\n ).current = node;\n }\n },\n [inputRef],\n );\n\n const { className: inputClassNameFromProps, ...inputRest } =\n inputProps ?? {};\n\n const containerClassName = twMerge(\n 'inline-flex items-center rounded-lg border bg-default transition-colors',\n SIZE_CLASS[size],\n startAccessory ? 'pl-4' : 'pl-0',\n endAccessory ? 'pr-4' : 'pr-0',\n isDisabled && 'cursor-not-allowed border-muted opacity-50',\n !isDisabled && isError && 'border-error-default',\n !isDisabled && !isError && isFocused && 'border-default',\n !isDisabled && !isError && !isFocused && 'border-muted',\n className,\n );\n\n const innerInputClassName = twMerge(\n 'm-0 h-full min-w-0 flex-1 border-0 bg-transparent p-0',\n startAccessory ? 'pl-2' : 'pl-4',\n endAccessory ? 'pr-2' : 'pr-4',\n truncate && 'truncate',\n inputClassNameFromProps,\n );\n\n return (\n <div\n ref={ref}\n className={containerClassName}\n style={style}\n onClick={handleClick}\n {...rest}\n >\n {startAccessory}\n {inputElement ?? (\n <Input\n {...inputRest}\n ref={handleInputRef}\n id={id}\n name={name}\n type={type}\n value={value}\n placeholder={placeholder}\n autoFocus={autoFocus}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isStateStylesDisabled\n maxLength={maxLength}\n required={required}\n aria-invalid={isError || undefined}\n onChange={onChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n className={innerInputClassName}\n />\n )}\n {endAccessory}\n </div>\n );\n },\n);\n\nTextField.displayName = 'TextField';\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextFieldType = exports.TextFieldSize = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* TextField size variants (web-only, ADR-0003).
|
|
6
|
+
*
|
|
7
|
+
* The React Native `TextField` ships a fixed height and intentionally does not
|
|
8
|
+
* expose a size prop, so this const object lives in the web package only.
|
|
9
|
+
*/
|
|
10
|
+
exports.TextFieldSize = {
|
|
11
|
+
Sm: 'sm',
|
|
12
|
+
Md: 'md',
|
|
13
|
+
Lg: 'lg',
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Native input `type` attribute values supported by the web TextField
|
|
17
|
+
* (ADR-0003). React Native consumers use `inputProps.keyboardType` /
|
|
18
|
+
* `inputProps.secureTextEntry` instead, so this is web-only.
|
|
19
|
+
*/
|
|
20
|
+
exports.TextFieldType = {
|
|
21
|
+
Text: 'text',
|
|
22
|
+
Number: 'number',
|
|
23
|
+
Password: 'password',
|
|
24
|
+
Search: 'search',
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=TextField.types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.types.cjs","sourceRoot":"","sources":["../../../src/components/TextField/TextField.types.ts"],"names":[],"mappings":";;;AAKA;;;;;GAKG;AACU,QAAA,aAAa,GAAG;IAC3B,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;CACA,CAAC;AAGX;;;;GAIG;AACU,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;CACR,CAAC","sourcesContent":["import type { TextFieldPropsShared } from '@metamask-previews/design-system-shared';\nimport type { ComponentPropsWithoutRef, Ref } from 'react';\n\nimport type { InputProps } from '../Input/Input.types';\n\n/**\n * TextField size variants (web-only, ADR-0003).\n *\n * The React Native `TextField` ships a fixed height and intentionally does not\n * expose a size prop, so this const object lives in the web package only.\n */\nexport const TextFieldSize = {\n Sm: 'sm',\n Md: 'md',\n Lg: 'lg',\n} as const;\nexport type TextFieldSize = (typeof TextFieldSize)[keyof typeof TextFieldSize];\n\n/**\n * Native input `type` attribute values supported by the web TextField\n * (ADR-0003). React Native consumers use `inputProps.keyboardType` /\n * `inputProps.secureTextEntry` instead, so this is web-only.\n */\nexport const TextFieldType = {\n Text: 'text',\n Number: 'number',\n Password: 'password',\n Search: 'search',\n} as const;\nexport type TextFieldType = (typeof TextFieldType)[keyof typeof TextFieldType];\n\ntype TextFieldInputProps = Omit<\n InputProps,\n | 'autoFocus'\n | 'id'\n | 'isDisabled'\n | 'isReadOnly'\n | 'isStateStylesDisabled'\n | 'maxLength'\n | 'name'\n | 'onBlur'\n | 'onChange'\n | 'onFocus'\n | 'placeholder'\n | 'required'\n | 'type'\n | 'value'\n>;\n\nexport type TextFieldProps = Omit<\n ComponentPropsWithoutRef<'div'>,\n 'onBlur' | 'onChange' | 'onFocus' | 'onClick'\n> &\n TextFieldPropsShared & {\n /**\n * The size of the text field. Controls the height.\n *\n * @default TextFieldSize.Md\n */\n size?: TextFieldSize;\n /**\n * The native input `type` attribute.\n *\n * @default TextFieldType.Text\n */\n type?: TextFieldType;\n /**\n * If true, truncates overflowing input text with an ellipsis.\n *\n * @default true\n */\n truncate?: boolean;\n /**\n * Max number of characters to allow.\n */\n maxLength?: number;\n /**\n * Name attribute of the inner `input` element.\n */\n name?: string;\n /**\n * `id` of the inner `input` element.\n */\n id?: string;\n /**\n * If true, the inner input is marked as required.\n */\n required?: boolean;\n /**\n * Additional props for the inner `Input`. Do not pass `value`,\n * `placeholder`, `isDisabled`, `isReadOnly`, `onFocus`, `onBlur`,\n * `onChange`, `id`, `name`, `type`, `maxLength`, or `required` here;\n * use the TextField-level props above.\n */\n inputProps?: TextFieldInputProps;\n /**\n * Ref to the inner `input` element. The component `ref` targets the\n * root `div`.\n */\n inputRef?: Ref<HTMLInputElement>;\n /**\n * Called when the inner input value changes.\n */\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n /**\n * Called when the inner input receives focus.\n */\n onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;\n /**\n * Called when the inner input loses focus.\n */\n onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;\n /**\n * Called when the root container is clicked. Focuses the inner input.\n */\n onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;\n /**\n * Optional additional CSS classes for the root container.\n */\n className?: string;\n /**\n * Optional inline styles for the root container.\n */\n style?: React.CSSProperties;\n };\n"]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { TextFieldPropsShared } from "@metamask-previews/design-system-shared";
|
|
2
|
+
import type { ComponentPropsWithoutRef, Ref } from "react";
|
|
3
|
+
import type { InputProps } from "../Input/Input.types.cjs";
|
|
4
|
+
/**
|
|
5
|
+
* TextField size variants (web-only, ADR-0003).
|
|
6
|
+
*
|
|
7
|
+
* The React Native `TextField` ships a fixed height and intentionally does not
|
|
8
|
+
* expose a size prop, so this const object lives in the web package only.
|
|
9
|
+
*/
|
|
10
|
+
export declare const TextFieldSize: {
|
|
11
|
+
readonly Sm: "sm";
|
|
12
|
+
readonly Md: "md";
|
|
13
|
+
readonly Lg: "lg";
|
|
14
|
+
};
|
|
15
|
+
export type TextFieldSize = (typeof TextFieldSize)[keyof typeof TextFieldSize];
|
|
16
|
+
/**
|
|
17
|
+
* Native input `type` attribute values supported by the web TextField
|
|
18
|
+
* (ADR-0003). React Native consumers use `inputProps.keyboardType` /
|
|
19
|
+
* `inputProps.secureTextEntry` instead, so this is web-only.
|
|
20
|
+
*/
|
|
21
|
+
export declare const TextFieldType: {
|
|
22
|
+
readonly Text: "text";
|
|
23
|
+
readonly Number: "number";
|
|
24
|
+
readonly Password: "password";
|
|
25
|
+
readonly Search: "search";
|
|
26
|
+
};
|
|
27
|
+
export type TextFieldType = (typeof TextFieldType)[keyof typeof TextFieldType];
|
|
28
|
+
type TextFieldInputProps = Omit<InputProps, 'autoFocus' | 'id' | 'isDisabled' | 'isReadOnly' | 'isStateStylesDisabled' | 'maxLength' | 'name' | 'onBlur' | 'onChange' | 'onFocus' | 'placeholder' | 'required' | 'type' | 'value'>;
|
|
29
|
+
export type TextFieldProps = Omit<ComponentPropsWithoutRef<'div'>, 'onBlur' | 'onChange' | 'onFocus' | 'onClick'> & TextFieldPropsShared & {
|
|
30
|
+
/**
|
|
31
|
+
* The size of the text field. Controls the height.
|
|
32
|
+
*
|
|
33
|
+
* @default TextFieldSize.Md
|
|
34
|
+
*/
|
|
35
|
+
size?: TextFieldSize;
|
|
36
|
+
/**
|
|
37
|
+
* The native input `type` attribute.
|
|
38
|
+
*
|
|
39
|
+
* @default TextFieldType.Text
|
|
40
|
+
*/
|
|
41
|
+
type?: TextFieldType;
|
|
42
|
+
/**
|
|
43
|
+
* If true, truncates overflowing input text with an ellipsis.
|
|
44
|
+
*
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
truncate?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Max number of characters to allow.
|
|
50
|
+
*/
|
|
51
|
+
maxLength?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Name attribute of the inner `input` element.
|
|
54
|
+
*/
|
|
55
|
+
name?: string;
|
|
56
|
+
/**
|
|
57
|
+
* `id` of the inner `input` element.
|
|
58
|
+
*/
|
|
59
|
+
id?: string;
|
|
60
|
+
/**
|
|
61
|
+
* If true, the inner input is marked as required.
|
|
62
|
+
*/
|
|
63
|
+
required?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Additional props for the inner `Input`. Do not pass `value`,
|
|
66
|
+
* `placeholder`, `isDisabled`, `isReadOnly`, `onFocus`, `onBlur`,
|
|
67
|
+
* `onChange`, `id`, `name`, `type`, `maxLength`, or `required` here;
|
|
68
|
+
* use the TextField-level props above.
|
|
69
|
+
*/
|
|
70
|
+
inputProps?: TextFieldInputProps;
|
|
71
|
+
/**
|
|
72
|
+
* Ref to the inner `input` element. The component `ref` targets the
|
|
73
|
+
* root `div`.
|
|
74
|
+
*/
|
|
75
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
76
|
+
/**
|
|
77
|
+
* Called when the inner input value changes.
|
|
78
|
+
*/
|
|
79
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Called when the inner input receives focus.
|
|
82
|
+
*/
|
|
83
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Called when the inner input loses focus.
|
|
86
|
+
*/
|
|
87
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Called when the root container is clicked. Focuses the inner input.
|
|
90
|
+
*/
|
|
91
|
+
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Optional additional CSS classes for the root container.
|
|
94
|
+
*/
|
|
95
|
+
className?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Optional inline styles for the root container.
|
|
98
|
+
*/
|
|
99
|
+
style?: React.CSSProperties;
|
|
100
|
+
};
|
|
101
|
+
export {};
|
|
102
|
+
//# sourceMappingURL=TextField.types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.types.d.cts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,gDAAgD;AACpF,OAAO,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,cAAc;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,iCAA6B;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;CAIhB,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE/E;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE/E,KAAK,mBAAmB,GAAG,IAAI,CAC7B,UAAU,EACR,WAAW,GACX,IAAI,GACJ,YAAY,GACZ,YAAY,GACZ,uBAAuB,GACvB,WAAW,GACX,MAAM,GACN,QAAQ,GACR,UAAU,GACV,SAAS,GACT,aAAa,GACb,UAAU,GACV,MAAM,GACN,OAAO,CACV,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,wBAAwB,CAAC,KAAK,CAAC,EAC/B,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAC9C,GACC,oBAAoB,GAAG;IACrB;;;;OAIG;IACH,IAAI,CAAC,EAAE,aAAa,C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