@salmonui/inputs 0.3.0 → 0.4.0
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/color-picker.css +28 -4
- package/dist/form-renderer.css +39 -4
- package/dist/internal/input-group/input-group.d.ts +8 -1
- package/dist/internal/input-group/input-group.d.ts.map +1 -1
- package/dist/internal/input-group/input-group.js +2 -2
- package/dist/internal/input-group/input-group.js.map +1 -1
- package/dist/masked-field.css +28 -4
- package/dist/number-field.css +28 -4
- package/dist/styles.css +39 -4
- package/dist/text-field/TextField.d.ts +9 -3
- package/dist/text-field/TextField.d.ts.map +1 -1
- package/dist/text-field/TextField.js +17 -8
- package/dist/text-field/TextField.js.map +1 -1
- package/dist/text-field.css +39 -4
- package/package.json +4 -4
package/dist/color-picker.css
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
|
|
52
52
|
}
|
|
53
53
|
@layer salmon.b {
|
|
54
|
-
/* Input group: bordered box, adornments, clear
|
|
54
|
+
/* Input group: bordered box, adornments, clear and password reveal buttons.
|
|
55
55
|
Button heights and inline padding per
|
|
56
56
|
size (the density control metrics), md radius, a 16px clear glyph whose edge sits at
|
|
57
57
|
the text inset. */
|
|
@@ -122,14 +122,16 @@
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
.salmon-input-group-adornment,
|
|
125
|
-
.salmon-input-group-clear
|
|
125
|
+
.salmon-input-group-clear,
|
|
126
|
+
.salmon-input-group-reveal {
|
|
126
127
|
display: inline-flex;
|
|
127
128
|
align-items: center;
|
|
128
129
|
flex: none;
|
|
129
130
|
color: var(--salmon-text-secondary);
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
.salmon-input-group-clear
|
|
133
|
+
.salmon-input-group-clear,
|
|
134
|
+
.salmon-input-group-reveal {
|
|
133
135
|
justify-content: center;
|
|
134
136
|
inline-size: 24px;
|
|
135
137
|
block-size: 24px;
|
|
@@ -148,7 +150,29 @@
|
|
|
148
150
|
background: linear-gradient(45deg, transparent 45%, currentColor 0 55%, transparent 0), linear-gradient(-45deg, transparent 45%, currentColor 0 55%, transparent 0);
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
.salmon-input-group-clear
|
|
153
|
+
.salmon-input-group-clear + .salmon-input-group-reveal {
|
|
154
|
+
margin-inline-start: calc(-1 * var(--salmon-space-3) + 4px);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.salmon-input-group-reveal:focus-visible {
|
|
158
|
+
outline: var(--salmon-state-focus-ring-width) solid var(--salmon-state-focus-ring);
|
|
159
|
+
outline-offset: var(--salmon-state-focus-ring-offset);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* Eye while the characters are hidden, struck-through eye while they show. */
|
|
163
|
+
.salmon-input-group-reveal-icon {
|
|
164
|
+
inline-size: 16px;
|
|
165
|
+
block-size: 16px;
|
|
166
|
+
background: currentColor;
|
|
167
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4'%3E%3Cpath d='M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2.2'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.salmon-input-group-reveal[aria-pressed='true'] .salmon-input-group-reveal-icon {
|
|
171
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2.2'/%3E%3Cpath d='M2.5 2.5l11 11'/%3E%3C/svg%3E");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.salmon-input-group-clear:hover,
|
|
175
|
+
.salmon-input-group-reveal:hover {
|
|
152
176
|
background: var(--salmon-surface-hover);
|
|
153
177
|
color: var(--salmon-text-primary);
|
|
154
178
|
}
|
package/dist/form-renderer.css
CHANGED
|
@@ -866,7 +866,7 @@ mark.salmon-dropdown__match {
|
|
|
866
866
|
|
|
867
867
|
}
|
|
868
868
|
@layer salmon.b {
|
|
869
|
-
/* Input group: bordered box, adornments, clear
|
|
869
|
+
/* Input group: bordered box, adornments, clear and password reveal buttons.
|
|
870
870
|
Button heights and inline padding per
|
|
871
871
|
size (the density control metrics), md radius, a 16px clear glyph whose edge sits at
|
|
872
872
|
the text inset. */
|
|
@@ -937,14 +937,16 @@ mark.salmon-dropdown__match {
|
|
|
937
937
|
}
|
|
938
938
|
|
|
939
939
|
.salmon-input-group-adornment,
|
|
940
|
-
.salmon-input-group-clear
|
|
940
|
+
.salmon-input-group-clear,
|
|
941
|
+
.salmon-input-group-reveal {
|
|
941
942
|
display: inline-flex;
|
|
942
943
|
align-items: center;
|
|
943
944
|
flex: none;
|
|
944
945
|
color: var(--salmon-text-secondary);
|
|
945
946
|
}
|
|
946
947
|
|
|
947
|
-
.salmon-input-group-clear
|
|
948
|
+
.salmon-input-group-clear,
|
|
949
|
+
.salmon-input-group-reveal {
|
|
948
950
|
justify-content: center;
|
|
949
951
|
inline-size: 24px;
|
|
950
952
|
block-size: 24px;
|
|
@@ -963,7 +965,29 @@ mark.salmon-dropdown__match {
|
|
|
963
965
|
background: linear-gradient(45deg, transparent 45%, currentColor 0 55%, transparent 0), linear-gradient(-45deg, transparent 45%, currentColor 0 55%, transparent 0);
|
|
964
966
|
}
|
|
965
967
|
|
|
966
|
-
.salmon-input-group-clear
|
|
968
|
+
.salmon-input-group-clear + .salmon-input-group-reveal {
|
|
969
|
+
margin-inline-start: calc(-1 * var(--salmon-space-3) + 4px);
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
.salmon-input-group-reveal:focus-visible {
|
|
973
|
+
outline: var(--salmon-state-focus-ring-width) solid var(--salmon-state-focus-ring);
|
|
974
|
+
outline-offset: var(--salmon-state-focus-ring-offset);
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
/* Eye while the characters are hidden, struck-through eye while they show. */
|
|
978
|
+
.salmon-input-group-reveal-icon {
|
|
979
|
+
inline-size: 16px;
|
|
980
|
+
block-size: 16px;
|
|
981
|
+
background: currentColor;
|
|
982
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4'%3E%3Cpath d='M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2.2'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
.salmon-input-group-reveal[aria-pressed='true'] .salmon-input-group-reveal-icon {
|
|
986
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2.2'/%3E%3Cpath d='M2.5 2.5l11 11'/%3E%3C/svg%3E");
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
.salmon-input-group-clear:hover,
|
|
990
|
+
.salmon-input-group-reveal:hover {
|
|
967
991
|
background: var(--salmon-surface-hover);
|
|
968
992
|
color: var(--salmon-text-primary);
|
|
969
993
|
}
|
|
@@ -1285,6 +1309,17 @@ mark.salmon-dropdown__match {
|
|
|
1285
1309
|
overflow: hidden;
|
|
1286
1310
|
}
|
|
1287
1311
|
|
|
1312
|
+
.salmon-text-area-count {
|
|
1313
|
+
align-self: flex-end;
|
|
1314
|
+
font-size: var(--salmon-font-size-sm);
|
|
1315
|
+
font-variant-numeric: tabular-nums;
|
|
1316
|
+
color: var(--salmon-text-secondary);
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
.salmon-text-area-count[data-limit] {
|
|
1320
|
+
color: var(--salmon-color-warning-text);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1288
1323
|
}
|
|
1289
1324
|
@layer salmon.c {
|
|
1290
1325
|
/*
|
|
@@ -10,10 +10,17 @@ export interface InputGroupProps {
|
|
|
10
10
|
readonly label: string;
|
|
11
11
|
readonly onClear: () => void;
|
|
12
12
|
} | null | undefined;
|
|
13
|
+
/** Shows the password reveal toggle when set; `controls` is the input id. */
|
|
14
|
+
readonly reveal?: {
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly pressed: boolean;
|
|
17
|
+
readonly controls: string;
|
|
18
|
+
readonly onToggle: () => void;
|
|
19
|
+
} | null | undefined;
|
|
13
20
|
readonly multiline?: boolean | undefined;
|
|
14
21
|
readonly className?: string | undefined;
|
|
15
22
|
}
|
|
16
|
-
export declare function InputGroup({ children, size, start, end, clear, multiline, className }: InputGroupProps): ReactNode;
|
|
23
|
+
export declare function InputGroup({ children, size, start, end, clear, reveal, multiline, className }: InputGroupProps): ReactNode;
|
|
17
24
|
/** Escape clears a clearable field with a value; returns true when it did. */
|
|
18
25
|
export declare function clearOnEscape(event: KeyboardEvent, enabled: boolean, onClear: () => void): boolean;
|
|
19
26
|
//# sourceMappingURL=input-group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-group.d.ts","sourceRoot":"","sources":["../../../src/internal/input-group/input-group.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"input-group.d.ts","sourceRoot":"","sources":["../../../src/internal/input-group/input-group.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,M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!== null && node !== false;
|
|
4
|
-
export function InputGroup({ children, size, start, end, clear, multiline, className }) {
|
|
5
|
-
return (_jsxs("div", { className: className ? `salmon-input-group ${className}` : 'salmon-input-group', "data-size": size ?? 'md', "data-multiline": multiline ? '' : undefined, children: [present(start) ? _jsx("span", { className: "salmon-input-group-adornment", "data-position": "start", children: start }) : null, children, clear ? (_jsx("button", { type: "button", className: "salmon-input-group-clear", tabIndex: -1, "aria-label": clear.label, onPointerDown: (event) => event.preventDefault(), onClick: clear.onClear, children: _jsx("span", { className: "salmon-input-group-clear-icon", "aria-hidden": "true" }) })) : null, present(end) ? _jsx("span", { className: "salmon-input-group-adornment", "data-position": "end", children: end }) : null] }));
|
|
4
|
+
export function InputGroup({ children, size, start, end, clear, reveal, multiline, className }) {
|
|
5
|
+
return (_jsxs("div", { className: className ? `salmon-input-group ${className}` : 'salmon-input-group', "data-size": size ?? 'md', "data-multiline": multiline ? '' : undefined, children: [present(start) ? _jsx("span", { className: "salmon-input-group-adornment", "data-position": "start", children: start }) : null, children, clear ? (_jsx("button", { type: "button", className: "salmon-input-group-clear", tabIndex: -1, "aria-label": clear.label, onPointerDown: (event) => event.preventDefault(), onClick: clear.onClear, children: _jsx("span", { className: "salmon-input-group-clear-icon", "aria-hidden": "true" }) })) : null, reveal ? (_jsx("button", { type: "button", className: "salmon-input-group-reveal", "aria-label": reveal.label, "aria-pressed": reveal.pressed, "aria-controls": reveal.controls, onPointerDown: (event) => event.preventDefault(), onClick: reveal.onToggle, children: _jsx("span", { className: "salmon-input-group-reveal-icon", "aria-hidden": "true" }) })) : null, present(end) ? _jsx("span", { className: "salmon-input-group-adornment", "data-position": "end", children: end }) : null] }));
|
|
6
6
|
}
|
|
7
7
|
/** Escape clears a clearable field with a value; returns true when it did. */
|
|
8
8
|
export function clearOnEscape(event, enabled, onClear) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-group.js","sourceRoot":"","sources":["../../../src/internal/input-group/input-group.tsx"],"names":[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,EAC9B,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,EAChD,OAAO,EAAE,MAAM,CAAC,QAAQ,YAExB,eAAM,SAAS,EAAC,gCAAgC,iBAAa,MAAM,GAAG,GAC/D,CACV,CAAC,CAAC,CAAC,IAAI,EACP,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,8BAA8B,mBAAe,KAAK,YAAE,GAAG,GAAQ,CAAC,CAAC,CAAC,IAAI,IAClG,CACP,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,aAAa,CAAC,KAAoB,EAAE,OAAgB,EAAE,OAAmB;IACvF,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,gBAAgB;QAAE,OAAO,KAAK,CAAC;IAC/E,KAAK,CAAC,cAAc,EAAE,CAAC;IACvB,OAAO,EAAE,CAAC;IACV,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/masked-field.css
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
|
|
52
52
|
}
|
|
53
53
|
@layer salmon.b {
|
|
54
|
-
/* Input group: bordered box, adornments, clear
|
|
54
|
+
/* Input group: bordered box, adornments, clear and password reveal buttons.
|
|
55
55
|
Button heights and inline padding per
|
|
56
56
|
size (the density control metrics), md radius, a 16px clear glyph whose edge sits at
|
|
57
57
|
the text inset. */
|
|
@@ -122,14 +122,16 @@
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
.salmon-input-group-adornment,
|
|
125
|
-
.salmon-input-group-clear
|
|
125
|
+
.salmon-input-group-clear,
|
|
126
|
+
.salmon-input-group-reveal {
|
|
126
127
|
display: inline-flex;
|
|
127
128
|
align-items: center;
|
|
128
129
|
flex: none;
|
|
129
130
|
color: var(--salmon-text-secondary);
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
.salmon-input-group-clear
|
|
133
|
+
.salmon-input-group-clear,
|
|
134
|
+
.salmon-input-group-reveal {
|
|
133
135
|
justify-content: center;
|
|
134
136
|
inline-size: 24px;
|
|
135
137
|
block-size: 24px;
|
|
@@ -148,7 +150,29 @@
|
|
|
148
150
|
background: linear-gradient(45deg, transparent 45%, currentColor 0 55%, transparent 0), linear-gradient(-45deg, transparent 45%, currentColor 0 55%, transparent 0);
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
.salmon-input-group-clear
|
|
153
|
+
.salmon-input-group-clear + .salmon-input-group-reveal {
|
|
154
|
+
margin-inline-start: calc(-1 * var(--salmon-space-3) + 4px);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.salmon-input-group-reveal:focus-visible {
|
|
158
|
+
outline: var(--salmon-state-focus-ring-width) solid var(--salmon-state-focus-ring);
|
|
159
|
+
outline-offset: var(--salmon-state-focus-ring-offset);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* Eye while the characters are hidden, struck-through eye while they show. */
|
|
163
|
+
.salmon-input-group-reveal-icon {
|
|
164
|
+
inline-size: 16px;
|
|
165
|
+
block-size: 16px;
|
|
166
|
+
background: currentColor;
|
|
167
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4'%3E%3Cpath d='M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2.2'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.salmon-input-group-reveal[aria-pressed='true'] .salmon-input-group-reveal-icon {
|
|
171
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2.2'/%3E%3Cpath d='M2.5 2.5l11 11'/%3E%3C/svg%3E");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.salmon-input-group-clear:hover,
|
|
175
|
+
.salmon-input-group-reveal:hover {
|
|
152
176
|
background: var(--salmon-surface-hover);
|
|
153
177
|
color: var(--salmon-text-primary);
|
|
154
178
|
}
|
package/dist/number-field.css
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
|
|
52
52
|
}
|
|
53
53
|
@layer salmon.b {
|
|
54
|
-
/* Input group: bordered box, adornments, clear
|
|
54
|
+
/* Input group: bordered box, adornments, clear and password reveal buttons.
|
|
55
55
|
Button heights and inline padding per
|
|
56
56
|
size (the density control metrics), md radius, a 16px clear glyph whose edge sits at
|
|
57
57
|
the text inset. */
|
|
@@ -122,14 +122,16 @@
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
.salmon-input-group-adornment,
|
|
125
|
-
.salmon-input-group-clear
|
|
125
|
+
.salmon-input-group-clear,
|
|
126
|
+
.salmon-input-group-reveal {
|
|
126
127
|
display: inline-flex;
|
|
127
128
|
align-items: center;
|
|
128
129
|
flex: none;
|
|
129
130
|
color: var(--salmon-text-secondary);
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
.salmon-input-group-clear
|
|
133
|
+
.salmon-input-group-clear,
|
|
134
|
+
.salmon-input-group-reveal {
|
|
133
135
|
justify-content: center;
|
|
134
136
|
inline-size: 24px;
|
|
135
137
|
block-size: 24px;
|
|
@@ -148,7 +150,29 @@
|
|
|
148
150
|
background: linear-gradient(45deg, transparent 45%, currentColor 0 55%, transparent 0), linear-gradient(-45deg, transparent 45%, currentColor 0 55%, transparent 0);
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
.salmon-input-group-clear
|
|
153
|
+
.salmon-input-group-clear + .salmon-input-group-reveal {
|
|
154
|
+
margin-inline-start: calc(-1 * var(--salmon-space-3) + 4px);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.salmon-input-group-reveal:focus-visible {
|
|
158
|
+
outline: var(--salmon-state-focus-ring-width) solid var(--salmon-state-focus-ring);
|
|
159
|
+
outline-offset: var(--salmon-state-focus-ring-offset);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* Eye while the characters are hidden, struck-through eye while they show. */
|
|
163
|
+
.salmon-input-group-reveal-icon {
|
|
164
|
+
inline-size: 16px;
|
|
165
|
+
block-size: 16px;
|
|
166
|
+
background: currentColor;
|
|
167
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4'%3E%3Cpath d='M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2.2'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.salmon-input-group-reveal[aria-pressed='true'] .salmon-input-group-reveal-icon {
|
|
171
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2.2'/%3E%3Cpath d='M2.5 2.5l11 11'/%3E%3C/svg%3E");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.salmon-input-group-clear:hover,
|
|
175
|
+
.salmon-input-group-reveal:hover {
|
|
152
176
|
background: var(--salmon-surface-hover);
|
|
153
177
|
color: var(--salmon-text-primary);
|
|
154
178
|
}
|
package/dist/styles.css
CHANGED
|
@@ -724,7 +724,7 @@ mark.salmon-dropdown__match {
|
|
|
724
724
|
|
|
725
725
|
}
|
|
726
726
|
@layer salmon.b {
|
|
727
|
-
/* Input group: bordered box, adornments, clear
|
|
727
|
+
/* Input group: bordered box, adornments, clear and password reveal buttons.
|
|
728
728
|
Button heights and inline padding per
|
|
729
729
|
size (the density control metrics), md radius, a 16px clear glyph whose edge sits at
|
|
730
730
|
the text inset. */
|
|
@@ -795,14 +795,16 @@ mark.salmon-dropdown__match {
|
|
|
795
795
|
}
|
|
796
796
|
|
|
797
797
|
.salmon-input-group-adornment,
|
|
798
|
-
.salmon-input-group-clear
|
|
798
|
+
.salmon-input-group-clear,
|
|
799
|
+
.salmon-input-group-reveal {
|
|
799
800
|
display: inline-flex;
|
|
800
801
|
align-items: center;
|
|
801
802
|
flex: none;
|
|
802
803
|
color: var(--salmon-text-secondary);
|
|
803
804
|
}
|
|
804
805
|
|
|
805
|
-
.salmon-input-group-clear
|
|
806
|
+
.salmon-input-group-clear,
|
|
807
|
+
.salmon-input-group-reveal {
|
|
806
808
|
justify-content: center;
|
|
807
809
|
inline-size: 24px;
|
|
808
810
|
block-size: 24px;
|
|
@@ -821,7 +823,29 @@ mark.salmon-dropdown__match {
|
|
|
821
823
|
background: linear-gradient(45deg, transparent 45%, currentColor 0 55%, transparent 0), linear-gradient(-45deg, transparent 45%, currentColor 0 55%, transparent 0);
|
|
822
824
|
}
|
|
823
825
|
|
|
824
|
-
.salmon-input-group-clear
|
|
826
|
+
.salmon-input-group-clear + .salmon-input-group-reveal {
|
|
827
|
+
margin-inline-start: calc(-1 * var(--salmon-space-3) + 4px);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
.salmon-input-group-reveal:focus-visible {
|
|
831
|
+
outline: var(--salmon-state-focus-ring-width) solid var(--salmon-state-focus-ring);
|
|
832
|
+
outline-offset: var(--salmon-state-focus-ring-offset);
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/* Eye while the characters are hidden, struck-through eye while they show. */
|
|
836
|
+
.salmon-input-group-reveal-icon {
|
|
837
|
+
inline-size: 16px;
|
|
838
|
+
block-size: 16px;
|
|
839
|
+
background: currentColor;
|
|
840
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4'%3E%3Cpath d='M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2.2'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
.salmon-input-group-reveal[aria-pressed='true'] .salmon-input-group-reveal-icon {
|
|
844
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2.2'/%3E%3Cpath d='M2.5 2.5l11 11'/%3E%3C/svg%3E");
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
.salmon-input-group-clear:hover,
|
|
848
|
+
.salmon-input-group-reveal:hover {
|
|
825
849
|
background: var(--salmon-surface-hover);
|
|
826
850
|
color: var(--salmon-text-primary);
|
|
827
851
|
}
|
|
@@ -1676,6 +1700,17 @@ mark.salmon-dropdown__match {
|
|
|
1676
1700
|
overflow: hidden;
|
|
1677
1701
|
}
|
|
1678
1702
|
|
|
1703
|
+
.salmon-text-area-count {
|
|
1704
|
+
align-self: flex-end;
|
|
1705
|
+
font-size: var(--salmon-font-size-sm);
|
|
1706
|
+
font-variant-numeric: tabular-nums;
|
|
1707
|
+
color: var(--salmon-text-secondary);
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
.salmon-text-area-count[data-limit] {
|
|
1711
|
+
color: var(--salmon-color-warning-text);
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1679
1714
|
}
|
|
1680
1715
|
@layer salmon.c {
|
|
1681
1716
|
/*
|
|
@@ -6,9 +6,10 @@ export interface TextChangeDetails {
|
|
|
6
6
|
/** `'input'` typing or paste, `'clear'` clear button or Escape, `'reset'` form reset. */
|
|
7
7
|
readonly reason: 'input' | 'clear' | 'reset';
|
|
8
8
|
}
|
|
9
|
-
/** User-visible strings: `clear` names the clear button; `validation*` keys override rule messages. */
|
|
9
|
+
/** User-visible strings: `clear` names the clear button, `showPassword` the password reveal button; `validation*` keys override rule messages. */
|
|
10
10
|
export type TextFieldLocaleText = FieldValidationText & {
|
|
11
11
|
readonly clear?: string;
|
|
12
|
+
readonly showPassword?: string;
|
|
12
13
|
};
|
|
13
14
|
export type {} from '@salmonui/core/locale';
|
|
14
15
|
declare module '@salmonui/core/locale' {
|
|
@@ -42,6 +43,8 @@ type NativeTextArea = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'
|
|
|
42
43
|
export interface TextFieldProps extends TextBaseProps, NativeInput {
|
|
43
44
|
/** Input type; numbers use `NumberField`. Default `'text'`. */
|
|
44
45
|
readonly type?: 'text' | 'password' | 'email' | 'tel' | 'url' | 'search' | undefined;
|
|
46
|
+
/** With `type="password"`, a button that shows and hides the characters. Default `true`; other types ignore it. */
|
|
47
|
+
readonly reveal?: boolean | undefined;
|
|
45
48
|
/** The native `<input>`. */
|
|
46
49
|
readonly ref?: Ref<HTMLInputElement> | undefined;
|
|
47
50
|
}
|
|
@@ -50,13 +53,16 @@ export interface TextAreaProps extends TextBaseProps, NativeTextArea {
|
|
|
50
53
|
readonly resize?: 'vertical' | 'horizontal' | 'both' | 'none' | undefined;
|
|
51
54
|
/** Grows with its content: `field-sizing: content`, one `scrollHeight` read per input where unsupported. */
|
|
52
55
|
readonly autoResize?: boolean | undefined;
|
|
56
|
+
/** Shows the length below the field, `12 / 100` with a `maxLength`; counted in UTF-16 code units like `maxLength`. */
|
|
57
|
+
readonly showCount?: boolean | undefined;
|
|
53
58
|
/** The native `<textarea>`. */
|
|
54
59
|
readonly ref?: Ref<HTMLTextAreaElement> | undefined;
|
|
55
60
|
}
|
|
56
61
|
/**
|
|
57
62
|
* Single-line text input: a native `<input>` with label,
|
|
58
|
-
* description, validation, adornments
|
|
59
|
-
*
|
|
63
|
+
* description, validation, adornments, an optional clear button and, for
|
|
64
|
+
* passwords, a show / hide button. `ref` is the input; unknown props go to
|
|
65
|
+
* the input, `className` / `style` to the root.
|
|
60
66
|
*/
|
|
61
67
|
export declare function TextField(props: TextFieldProps): ReactNode;
|
|
62
68
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../src/text-field/TextField.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../src/text-field/TextField.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAuE,KAAK,aAAa,EAAmB,KAAK,mBAAmB,EAAsB,KAAK,SAAS,EAAE,KAAK,GAAG,EAAE,KAAK,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAItO,OAAO,EAA0D,KAAK,gBAAgB,EAAE,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGrJ,0CAA0C;AAC1C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,KAAK,CAAC;IAChD,yFAAyF;IACzF,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;CAC9C;AAED,kJAAkJ;AAClJ,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,GAAG;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpH,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,QAAQ,uBAAuB,CAAC;IACrC,UAAU,aAAa;QACrB,QAAQ,CAAC,SAAS,CAAC,E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} from 'react';
|
|
4
4
|
import { useControllableState } from '@salmonui/core/internal/controllable';
|
|
5
5
|
import { assignRef, useFormReset } from '@salmonui/core/internal/form';
|
|
6
|
-
import { useLocaleText } from '@salmonui/core/internal/locale';
|
|
6
|
+
import { useLocale, useLocaleText } from '@salmonui/core/internal/locale';
|
|
7
7
|
import { cx, FieldHelp, FieldLabel, FieldStateContext, useField } from '../internal/field/field.js';
|
|
8
8
|
import { clearOnEscape, InputGroup } from '../internal/input-group/input-group.js';
|
|
9
9
|
function useTextField(props) {
|
|
@@ -42,7 +42,7 @@ function useTextField(props) {
|
|
|
42
42
|
};
|
|
43
43
|
return { field, value, control, canClear, clear, inputRef, localeText };
|
|
44
44
|
}
|
|
45
|
-
const OWN = ['label', 'description', 'errorMessage', 'invalid', 'validation', 'validateOn', 'size', 'value', 'defaultValue', 'onValueChange', 'clearable', 'startAdornment', 'endAdornment', 'localeText', 'className', 'style', 'classNames', 'ref', 'onChange', 'onBlur', 'onKeyDown', 'type', 'resize', 'autoResize'];
|
|
45
|
+
const OWN = ['label', 'description', 'errorMessage', 'invalid', 'validation', 'validateOn', 'size', 'value', 'defaultValue', 'onValueChange', 'clearable', 'startAdornment', 'endAdornment', 'localeText', 'className', 'style', 'classNames', 'ref', 'onChange', 'onBlur', 'onKeyDown', 'type', 'reveal', 'resize', 'autoResize', 'showCount'];
|
|
46
46
|
/** Props that go to the native element: everything the component does not own. */
|
|
47
47
|
function nativeOf(props) {
|
|
48
48
|
const out = {};
|
|
@@ -53,16 +53,20 @@ function nativeOf(props) {
|
|
|
53
53
|
}
|
|
54
54
|
function Frame(props) {
|
|
55
55
|
const { state, classNames } = props;
|
|
56
|
-
return (_jsx(FieldStateContext, { value: state.field, children: _jsxs("div", { className: cx('salmon-field salmon-text-field', props.className), style: props.style, "data-size": props.size ?? 'md', ...state.field.rootProps, children: [_jsx(FieldLabel, { field: state.field, className: classNames?.label, children: props.label }), _jsx(InputGroup, { size: props.size, start: props.startAdornment, end: props.endAdornment, clear: state.canClear ? { label: state.localeText?.clear ?? 'Clear', onClear: state.clear } : null, multiline: props.multiline, className: classNames?.group, children: props.children }), _jsx(FieldHelp, { field: state.field, description: props.description, classNames: classNames })] }) }));
|
|
56
|
+
return (_jsx(FieldStateContext, { value: state.field, children: _jsxs("div", { className: cx('salmon-field salmon-text-field', props.className), style: props.style, "data-size": props.size ?? 'md', ...state.field.rootProps, children: [_jsx(FieldLabel, { field: state.field, className: classNames?.label, children: props.label }), _jsx(InputGroup, { size: props.size, start: props.startAdornment, end: props.endAdornment, clear: state.canClear ? { label: state.localeText?.clear ?? 'Clear', onClear: state.clear } : null, reveal: props.revealButton ? { ...props.revealButton, label: state.localeText?.showPassword ?? 'Show password', controls: state.field.inputId } : null, multiline: props.multiline, className: classNames?.group, children: props.children }), props.count, _jsx(FieldHelp, { field: state.field, description: props.description, classNames: classNames })] }) }));
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Single-line text input: a native `<input>` with label,
|
|
60
|
-
* description, validation, adornments
|
|
61
|
-
*
|
|
60
|
+
* description, validation, adornments, an optional clear button and, for
|
|
61
|
+
* passwords, a show / hide button. `ref` is the input; unknown props go to
|
|
62
|
+
* the input, `className` / `style` to the root.
|
|
62
63
|
*/
|
|
63
64
|
export function TextField(props) {
|
|
64
65
|
const state = useTextField(props);
|
|
65
|
-
|
|
66
|
+
const [visible, setVisible] = useState(false);
|
|
67
|
+
// Hidden when disabled, like the clear button; read-only fields keep it (viewing changes nothing).
|
|
68
|
+
const revealButton = props.type === 'password' && props.reveal !== false && !props.disabled ? { pressed: visible, onToggle: () => setVisible((v) => !v) } : null;
|
|
69
|
+
return (_jsx(Frame, { ...props, state: state, revealButton: revealButton, children: _jsx("input", { ...nativeOf(props), ...state.control, type: revealButton && visible ? 'text' : (props.type ?? 'text'), className: cx('salmon-input', props.classNames?.input) }) }));
|
|
66
70
|
}
|
|
67
71
|
/**
|
|
68
72
|
* Multi-line text input (TextBox `multiline`): a native
|
|
@@ -80,6 +84,11 @@ export function TextArea(props) {
|
|
|
80
84
|
el.style.blockSize = 'auto';
|
|
81
85
|
el.style.blockSize = `${el.scrollHeight + el.offsetHeight - el.clientHeight}px`;
|
|
82
86
|
}, [autoResize, value, inputRef]);
|
|
83
|
-
|
|
87
|
+
const countId = `${useId()}count`;
|
|
88
|
+
const locale = useLocale(undefined) ?? 'en-US';
|
|
89
|
+
const nf = useMemo(() => new Intl.NumberFormat(locale), [locale]);
|
|
90
|
+
const max = props.maxLength !== undefined && props.maxLength >= 0 ? props.maxLength : undefined;
|
|
91
|
+
const count = props.showCount ? (_jsx("div", { className: "salmon-text-area-count", id: countId, "data-limit": max !== undefined && value.length >= max ? '' : undefined, children: max === undefined ? nf.format(value.length) : `${nf.format(value.length)} / ${nf.format(max)}` })) : null;
|
|
92
|
+
return (_jsx(Frame, { ...props, state: state, multiline: true, count: count, children: _jsx("textarea", { ...nativeOf(props), ...state.control, "aria-describedby": props.showCount ? cx(state.control['aria-describedby'], countId) : state.control['aria-describedby'], className: cx('salmon-input salmon-text-area', props.classNames?.input), "data-resize": props.resize ?? 'both', "data-auto-resize": autoResize ? '' : undefined }) }));
|
|
84
93
|
}
|
|
85
94
|
//# sourceMappingURL=TextField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.js","sourceRoot":"","sources":["../../src/text-field/TextField.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,eAAe,EAAE,MAAM,EAA8J,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TextField.js","sourceRoot":"","sources":["../../src/text-field/TextField.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAA8J,MAAM,OAAO,CAAC;AACtO,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,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51,7 @@
|
|
|
51
51
|
|
|
52
52
|
}
|
|
53
53
|
@layer salmon.b {
|
|
54
|
-
/* Input group: bordered box, adornments, clear
|
|
54
|
+
/* Input group: bordered box, adornments, clear and password reveal buttons.
|
|
55
55
|
Button heights and inline padding per
|
|
56
56
|
size (the density control metrics), md radius, a 16px clear glyph whose edge sits at
|
|
57
57
|
the text inset. */
|
|
@@ -122,14 +122,16 @@
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
.salmon-input-group-adornment,
|
|
125
|
-
.salmon-input-group-clear
|
|
125
|
+
.salmon-input-group-clear,
|
|
126
|
+
.salmon-input-group-reveal {
|
|
126
127
|
display: inline-flex;
|
|
127
128
|
align-items: center;
|
|
128
129
|
flex: none;
|
|
129
130
|
color: var(--salmon-text-secondary);
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
.salmon-input-group-clear
|
|
133
|
+
.salmon-input-group-clear,
|
|
134
|
+
.salmon-input-group-reveal {
|
|
133
135
|
justify-content: center;
|
|
134
136
|
inline-size: 24px;
|
|
135
137
|
block-size: 24px;
|
|
@@ -148,7 +150,29 @@
|
|
|
148
150
|
background: linear-gradient(45deg, transparent 45%, currentColor 0 55%, transparent 0), linear-gradient(-45deg, transparent 45%, currentColor 0 55%, transparent 0);
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
.salmon-input-group-clear
|
|
153
|
+
.salmon-input-group-clear + .salmon-input-group-reveal {
|
|
154
|
+
margin-inline-start: calc(-1 * var(--salmon-space-3) + 4px);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.salmon-input-group-reveal:focus-visible {
|
|
158
|
+
outline: var(--salmon-state-focus-ring-width) solid var(--salmon-state-focus-ring);
|
|
159
|
+
outline-offset: var(--salmon-state-focus-ring-offset);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* Eye while the characters are hidden, struck-through eye while they show. */
|
|
163
|
+
.salmon-input-group-reveal-icon {
|
|
164
|
+
inline-size: 16px;
|
|
165
|
+
block-size: 16px;
|
|
166
|
+
background: currentColor;
|
|
167
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4'%3E%3Cpath d='M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2.2'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.salmon-input-group-reveal[aria-pressed='true'] .salmon-input-group-reveal-icon {
|
|
171
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2.2'/%3E%3Cpath d='M2.5 2.5l11 11'/%3E%3C/svg%3E");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.salmon-input-group-clear:hover,
|
|
175
|
+
.salmon-input-group-reveal:hover {
|
|
152
176
|
background: var(--salmon-surface-hover);
|
|
153
177
|
color: var(--salmon-text-primary);
|
|
154
178
|
}
|
|
@@ -191,4 +215,15 @@
|
|
|
191
215
|
overflow: hidden;
|
|
192
216
|
}
|
|
193
217
|
|
|
218
|
+
.salmon-text-area-count {
|
|
219
|
+
align-self: flex-end;
|
|
220
|
+
font-size: var(--salmon-font-size-sm);
|
|
221
|
+
font-variant-numeric: tabular-nums;
|
|
222
|
+
color: var(--salmon-text-secondary);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.salmon-text-area-count[data-limit] {
|
|
226
|
+
color: var(--salmon-color-warning-text);
|
|
227
|
+
}
|
|
228
|
+
|
|
194
229
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salmonui/inputs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Form, text, masked and number fields, FileUpload, Checkbox, RadioGroup, Switch, Rating, OtpField, Slider, SignaturePad, ColorPicker, SpeechToText and FormRenderer for Salmon UI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -109,9 +109,9 @@
|
|
|
109
109
|
"LICENSE"
|
|
110
110
|
],
|
|
111
111
|
"dependencies": {
|
|
112
|
-
"@salmonui/core": "0.
|
|
113
|
-
"@salmonui/buttons": "0.
|
|
114
|
-
"@salmonui/dropdowns": "0.
|
|
112
|
+
"@salmonui/core": "0.4.0",
|
|
113
|
+
"@salmonui/buttons": "0.4.0",
|
|
114
|
+
"@salmonui/dropdowns": "0.4.0"
|
|
115
115
|
},
|
|
116
116
|
"peerDependencies": {
|
|
117
117
|
"react": ">=19",
|