@purpurds/text-field 4.0.0 → 4.0.2
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/dist/LICENSE.txt +5 -5
- package/dist/styles.css +1 -1
- package/dist/text-field.cjs.js +8 -8
- package/dist/text-field.cjs.js.map +1 -1
- package/dist/text-field.d.ts +2 -2
- package/dist/text-field.d.ts.map +1 -1
- package/dist/text-field.es.js +184 -181
- package/dist/text-field.es.js.map +1 -1
- package/package.json +7 -7
- package/src/text-field.module.scss +18 -8
- package/src/text-field.tsx +9 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purpurds/text-field",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "./dist/text-field.cjs.js",
|
|
6
6
|
"types": "./dist/text-field.d.ts",
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"source": "src/text-field.tsx",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"classnames": "~2.5.0",
|
|
18
|
-
"@purpurds/field-error-text": "4.0.
|
|
19
|
-
"@purpurds/field-helper-text": "4.0.
|
|
20
|
-
"@purpurds/icon": "4.0.
|
|
21
|
-
"@purpurds/
|
|
22
|
-
"@purpurds/
|
|
23
|
-
"@purpurds/tokens": "4.0.
|
|
18
|
+
"@purpurds/field-error-text": "4.0.2",
|
|
19
|
+
"@purpurds/field-helper-text": "4.0.2",
|
|
20
|
+
"@purpurds/icon": "4.0.2",
|
|
21
|
+
"@purpurds/spinner": "4.0.2",
|
|
22
|
+
"@purpurds/label": "4.0.2",
|
|
23
|
+
"@purpurds/tokens": "4.0.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@rushstack/eslint-patch": "~1.7.0",
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
border-radius: var(--purpur-border-radius-sm);
|
|
39
39
|
background: var(--purpur-color-background-primary);
|
|
40
40
|
|
|
41
|
+
&:has(:-internal-autofill-previewed),
|
|
42
|
+
&:has(:-internal-autofill-selected) {
|
|
43
|
+
background-color: var(--purpur-color-background-tone-on-tone-secondary) !important;
|
|
44
|
+
}
|
|
45
|
+
|
|
41
46
|
&--disabled {
|
|
42
47
|
background: var(--purpur-color-background-interactive-disabled);
|
|
43
48
|
}
|
|
@@ -79,7 +84,7 @@
|
|
|
79
84
|
background: transparent;
|
|
80
85
|
|
|
81
86
|
&:hover {
|
|
82
|
-
|
|
87
|
+
~#{$root}__frame {
|
|
83
88
|
border-width: var(--purpur-border-width-sm);
|
|
84
89
|
border-color: var(--purpur-color-border-interactive-subtle-hover);
|
|
85
90
|
}
|
|
@@ -87,7 +92,7 @@
|
|
|
87
92
|
|
|
88
93
|
&:active:not(:disabled):not(:read-only),
|
|
89
94
|
&:focus:not(:disabled):not(:read-only) {
|
|
90
|
-
|
|
95
|
+
~#{$root}__frame {
|
|
91
96
|
outline: var(--purpur-border-width-sm) solid var(--purpur-color-border-interactive-focus);
|
|
92
97
|
outline-offset: calc(var(--purpur-spacing-10) * 2);
|
|
93
98
|
border-width: var(--purpur-border-width-xs);
|
|
@@ -98,7 +103,7 @@
|
|
|
98
103
|
&:disabled {
|
|
99
104
|
color: var(--purpur-color-text-weak);
|
|
100
105
|
|
|
101
|
-
|
|
106
|
+
~#{$root}__frame {
|
|
102
107
|
border-width: var(--purpur-border-width-xs);
|
|
103
108
|
border-color: var(--purpur-color-border-medium);
|
|
104
109
|
}
|
|
@@ -107,25 +112,30 @@
|
|
|
107
112
|
&:read-only:not(:disabled) {
|
|
108
113
|
color: var(--purpur-color-text-default);
|
|
109
114
|
|
|
110
|
-
|
|
115
|
+
~#{$root}__frame {
|
|
111
116
|
border-width: var(--purpur-border-width-xs);
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
&:not(#{$inputRoot}--valid):not(#{$inputRoot}--error) {
|
|
115
|
-
|
|
120
|
+
~#{$root}__frame {
|
|
116
121
|
border-color: var(--purpur-color-border-medium);
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
}
|
|
120
125
|
|
|
126
|
+
&:-internal-autofill-previewed,
|
|
127
|
+
&:-internal-autofill-selected {
|
|
128
|
+
box-shadow: inset 0 0 0 1px transparent, inset 0 0 0 100px var(--purpur-color-background-tone-on-tone-secondary);
|
|
129
|
+
}
|
|
130
|
+
|
|
121
131
|
&#{$inputRoot}--valid {
|
|
122
|
-
|
|
132
|
+
~#{$root}__frame {
|
|
123
133
|
border-color: var(--purpur-color-border-status-success);
|
|
124
134
|
}
|
|
125
135
|
}
|
|
126
136
|
|
|
127
137
|
&#{$inputRoot}--error:not(:hover) {
|
|
128
|
-
|
|
138
|
+
~#{$root}__frame {
|
|
129
139
|
border-color: var(--purpur-color-border-status-error);
|
|
130
140
|
}
|
|
131
141
|
}
|
|
@@ -140,4 +150,4 @@
|
|
|
140
150
|
&__valid-icon {
|
|
141
151
|
color: var(--purpur-color-text-status-success-medium);
|
|
142
152
|
}
|
|
143
|
-
}
|
|
153
|
+
}
|
package/src/text-field.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import React, {
|
|
|
4
4
|
forwardRef,
|
|
5
5
|
HTMLInputTypeAttribute,
|
|
6
6
|
ReactNode,
|
|
7
|
+
useId,
|
|
7
8
|
} from "react";
|
|
8
9
|
import { FieldErrorText } from "@purpurds/field-error-text";
|
|
9
10
|
import { FieldHelperText } from "@purpurds/field-helper-text";
|
|
@@ -15,7 +16,7 @@ import c from "classnames";
|
|
|
15
16
|
import styles from "./text-field.module.scss";
|
|
16
17
|
|
|
17
18
|
export type TextFieldProps = ComponentPropsWithoutRef<"input"> & {
|
|
18
|
-
id: string;
|
|
19
|
+
id: string | undefined;
|
|
19
20
|
["data-testid"]?: string;
|
|
20
21
|
className?: string;
|
|
21
22
|
/**
|
|
@@ -84,15 +85,18 @@ const TextFieldComponent = (
|
|
|
84
85
|
}: TextFieldProps,
|
|
85
86
|
ref: ForwardedRef<HTMLInputElement>
|
|
86
87
|
) => {
|
|
88
|
+
const randomId = useId();
|
|
89
|
+
const inputId = inputProps.id ?? randomId;
|
|
87
90
|
const getTestId = (name: string) => (dataTestId ? `${dataTestId}-${name}` : undefined);
|
|
88
91
|
const isValid = valid && !errorText;
|
|
89
|
-
const helperTextId = helperText ? `${
|
|
92
|
+
const helperTextId = helperText ? `${inputId}-helper-text` : undefined;
|
|
90
93
|
|
|
91
94
|
const startAdornments: ReactNode[] = [startAdornment].filter((adornment) => !!adornment);
|
|
92
95
|
|
|
93
96
|
const endAdornments: ReactNode[] = [
|
|
94
97
|
loading && (
|
|
95
98
|
<Spinner
|
|
99
|
+
key="spinner"
|
|
96
100
|
variant={inputProps.disabled ? "disabled" : "primary"}
|
|
97
101
|
size="xs"
|
|
98
102
|
data-testid={getTestId("spinner")}
|
|
@@ -100,6 +104,7 @@ const TextFieldComponent = (
|
|
|
100
104
|
),
|
|
101
105
|
isValid && (
|
|
102
106
|
<Icon
|
|
107
|
+
key="valid-icon"
|
|
103
108
|
data-testid={getTestId("valid-icon")}
|
|
104
109
|
className={styles[`${rootClassName}__valid-icon`]}
|
|
105
110
|
svg={checkCircleFilled}
|
|
@@ -124,7 +129,7 @@ const TextFieldComponent = (
|
|
|
124
129
|
<div className={c(className, styles[rootClassName])}>
|
|
125
130
|
{label && (
|
|
126
131
|
<Label
|
|
127
|
-
htmlFor={
|
|
132
|
+
htmlFor={inputId}
|
|
128
133
|
className={styles[`${rootClassName}__label`]}
|
|
129
134
|
data-testid={getTestId("label")}
|
|
130
135
|
disabled={inputProps.disabled}
|
|
@@ -144,6 +149,7 @@ const TextFieldComponent = (
|
|
|
144
149
|
)}
|
|
145
150
|
<input
|
|
146
151
|
{...inputProps}
|
|
152
|
+
id={inputId}
|
|
147
153
|
ref={ref}
|
|
148
154
|
data-testid={getTestId("input")}
|
|
149
155
|
aria-describedby={inputProps["aria-describedby"] || helperTextId}
|