@sebgroup/green-core 1.38.1 → 1.39.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/README.md +1 -1
- package/chunks/{chunk.PC4VJLMM.js → chunk.F7VQ4QEE.js} +4 -4
- package/chunks/{chunk.6OJLIA73.js → chunk.FMJZDVMQ.js} +1 -1
- package/chunks/{chunk.V22RY2FP.js → chunk.GRJSXR6F.js} +1 -1
- package/chunks/chunk.HGTRTF3J.js +625 -0
- package/chunks/{chunk.D35VWG7Z.js → chunk.HXSX2352.js} +2 -2
- package/chunks/{chunk.ZEGPRNBY.js → chunk.JLTCEWS2.js} +1 -1
- package/chunks/{chunk.NMP7SICY.js → chunk.KALODFIV.js} +1 -1
- package/chunks/{chunk.HEEBT6PP.js → chunk.KC3QFSLY.js} +1 -1
- package/chunks/{chunk.J5IZQIXN.js → chunk.KMSRBHFR.js} +1 -1
- package/chunks/{chunk.SXLN3MMQ.js → chunk.N4OJZNL2.js} +1 -1
- package/chunks/{chunk.XKFWKMOP.js → chunk.N54HRIOT.js} +1 -1
- package/chunks/{chunk.TH5D3QVK.js → chunk.OZBL6IO2.js} +1 -1
- package/chunks/{chunk.REE5LG5I.js → chunk.P46R3OGN.js} +1 -1
- package/chunks/{chunk.Z3RX3OZJ.js → chunk.P4YC2BEI.js} +1 -1
- package/chunks/{chunk.R2RVGPT7.js → chunk.Q2QJ2KF2.js} +6 -31
- package/chunks/{chunk.PN4BONI4.js → chunk.QCDJEZMP.js} +2 -2
- package/chunks/{chunk.WBYZIT2A.js → chunk.QCGLT253.js} +1 -1
- package/chunks/{chunk.AP23QGB4.js → chunk.TUCS4UFR.js} +1 -1
- package/chunks/{chunk.OYCRDQFS.js → chunk.VGQTBRXA.js} +6 -6
- package/chunks/chunk.VOYMQ322.js +1 -1
- package/chunks/{chunk.WWR3VPSV.js → chunk.XOI3RMD2.js} +1 -1
- package/chunks/{chunk.IWTL7STV.js → chunk.YAGE2PRV.js} +1 -1
- package/chunks/chunk.YBOK7MI7.js +31 -0
- package/components/button/button.js +4 -3
- package/components/button/fab/fab.js +5 -4
- package/components/button/fab/index.js +5 -4
- package/components/button/index.js +4 -3
- package/components/calendar/calendar.js +2 -2
- package/components/calendar/index.js +2 -2
- package/components/content/divider/divider.js +2 -2
- package/components/content/divider/index.js +2 -2
- package/components/content/spacer/index.js +2 -2
- package/components/content/spacer/spacer.js +2 -2
- package/components/content/text/index.js +2 -2
- package/components/content/text/text.js +2 -2
- package/components/context-menu/context-menu.js +1 -1
- package/components/context-menu/index.js +1 -1
- package/components/datepicker/datepicker.js +9 -8
- package/components/datepicker/index.js +9 -8
- package/components/dropdown/dropdown.js +7 -6
- package/components/dropdown/index.js +7 -6
- package/components/filter-chips/filter-chip/filter-chip.js +4 -3
- package/components/filter-chips/filter-chip/index.js +4 -3
- package/components/filter-chips/filter-chips.js +4 -3
- package/components/filter-chips/index.js +4 -3
- package/components/form/index.js +5 -5
- package/components/form/summary/index.js +5 -5
- package/components/form/summary/summary.js +5 -5
- package/components/index.js +26 -25
- package/components/input/index.d.ts +1 -0
- package/components/input/index.js +18 -0
- package/components/input/input.d.ts +67 -0
- package/components/input/input.js +18 -0
- package/components/input/input.styles.d.ts +1 -0
- package/components/layout/card/card.js +4 -4
- package/components/layout/card/index.js +4 -4
- package/components/layout/container/container.js +2 -2
- package/components/layout/container/index.js +2 -2
- package/components/layout/flex/flex.js +3 -3
- package/components/layout/flex/index.js +3 -3
- package/components/layout/grid/grid.js +2 -2
- package/components/layout/grid/index.js +2 -2
- package/components/media/img/img.js +2 -2
- package/components/media/img/index.js +2 -2
- package/components/media/video/index.js +2 -2
- package/components/media/video/video.js +2 -2
- package/components/menu-button/index.js +2 -2
- package/components/menu-button/menu-button.js +2 -2
- package/components/popover/index.js +3 -3
- package/components/segmented-control/index.js +3 -3
- package/components/segmented-control/segment/index.js +2 -2
- package/components/segmented-control/segment/segment.js +2 -2
- package/components/segmented-control/segmented-control.js +3 -3
- package/index.js +26 -25
- package/package.json +3 -3
- package/primitives/listbox/index.js +2 -2
- package/primitives/listbox/listbox.js +2 -2
- package/primitives/listbox/option.js +2 -2
- package/primitives/ripple/index.js +2 -2
- package/primitives/ripple/ripple.js +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img width="600" alt="green-core" src="https://github.com/
|
|
2
|
+
<img width="600" alt="green-core" src="https://github.com/seb-oss/green/assets/11420341/5d4b25fd-0633-498c-b50f-70f07c01ac16">
|
|
3
3
|
<h1>@sebgroup/green-core</h1>
|
|
4
4
|
<p>Green Core is a carefully crafted set of Web Components that lays the foundation for the Green Design System.</p>
|
|
5
5
|
</div>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GdsContainer
|
|
3
|
+
} from "./chunk.P4YC2BEI.js";
|
|
1
4
|
import {
|
|
2
5
|
card_style_css_default
|
|
3
6
|
} from "./chunk.JTFG2VCZ.js";
|
|
4
|
-
import {
|
|
5
|
-
GdsContainer
|
|
6
|
-
} from "./chunk.Z3RX3OZJ.js";
|
|
7
7
|
import {
|
|
8
8
|
styleExpressionProperty
|
|
9
9
|
} from "./chunk.ADPMTWTS.js";
|
|
10
10
|
import {
|
|
11
11
|
tokens
|
|
12
|
-
} from "./chunk.
|
|
12
|
+
} from "./chunk.VGQTBRXA.js";
|
|
13
13
|
import {
|
|
14
14
|
gdsCustomElement,
|
|
15
15
|
html
|
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardAttributes
|
|
3
|
+
} from "./chunk.YBOK7MI7.js";
|
|
4
|
+
import {
|
|
5
|
+
GdsFormControlElement
|
|
6
|
+
} from "./chunk.2BMJPIND.js";
|
|
7
|
+
import {
|
|
8
|
+
constrainSlots
|
|
9
|
+
} from "./chunk.KBYQYDL3.js";
|
|
10
|
+
import {
|
|
11
|
+
tokens
|
|
12
|
+
} from "./chunk.VGQTBRXA.js";
|
|
13
|
+
import {
|
|
14
|
+
watch
|
|
15
|
+
} from "./chunk.2WO4NHJ2.js";
|
|
16
|
+
import {
|
|
17
|
+
gdsCustomElement,
|
|
18
|
+
html
|
|
19
|
+
} from "./chunk.VOYMQ322.js";
|
|
20
|
+
import {
|
|
21
|
+
__decorateClass,
|
|
22
|
+
__privateAdd,
|
|
23
|
+
__privateGet,
|
|
24
|
+
__privateMethod,
|
|
25
|
+
__spreadProps,
|
|
26
|
+
__spreadValues
|
|
27
|
+
} from "./chunk.5VURDMKE.js";
|
|
28
|
+
|
|
29
|
+
// libs/core/src/components/input/input.ts
|
|
30
|
+
import { LitElement } from "lit";
|
|
31
|
+
import { property, query, queryAsync } from "lit/decorators.js";
|
|
32
|
+
import { until } from "lit/directives/until.js";
|
|
33
|
+
import { nothing } from "lit/html.js";
|
|
34
|
+
import { when } from "lit/directives/when.js";
|
|
35
|
+
import { choose } from "lit/directives/choose.js";
|
|
36
|
+
import { msg } from "@lit/localize";
|
|
37
|
+
|
|
38
|
+
// libs/core/src/components/input/input.styles.ts
|
|
39
|
+
import { css } from "lit";
|
|
40
|
+
var styles = css`
|
|
41
|
+
@layer tokens, a11y, base, simplified;
|
|
42
|
+
|
|
43
|
+
@layer tokens {
|
|
44
|
+
:host {
|
|
45
|
+
--_color-bg: var(--gds-sys-color-container-container);
|
|
46
|
+
|
|
47
|
+
--_color-border: var(--gds-sys-color-stroke-stroke-variant1);
|
|
48
|
+
--_border-radius: 0.5rem;
|
|
49
|
+
--_border-width: 0.0625rem;
|
|
50
|
+
--_border-width-hover: 0.125rem;
|
|
51
|
+
|
|
52
|
+
--_color-outline-alpha: 60%;
|
|
53
|
+
--_color-outline: color-mix(
|
|
54
|
+
in srgb,
|
|
55
|
+
var(--_color-border),
|
|
56
|
+
transparent var(--_color-outline-alpha)
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
--_transition: var(--gds-sys-transition);
|
|
60
|
+
--_lh: 1.25;
|
|
61
|
+
--_core-min-block-size: 3.5rem;
|
|
62
|
+
--_gap: 0.5rem;
|
|
63
|
+
--_padding-block: 0.625rem;
|
|
64
|
+
--_padding-inline: 1rem;
|
|
65
|
+
--_core-icon-size: 1.5rem;
|
|
66
|
+
--_inner-height: 2rem;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@layer a11y {
|
|
71
|
+
/* @media (prefers-color-scheme: dark) {
|
|
72
|
+
:host {
|
|
73
|
+
--_color-bg: var(--_color-bg-dark);
|
|
74
|
+
}
|
|
75
|
+
} */
|
|
76
|
+
|
|
77
|
+
@media (prefers-reduced-motion: reduce) {
|
|
78
|
+
:host {
|
|
79
|
+
--_transition: none;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
84
|
+
:host {
|
|
85
|
+
--_transparency: 1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* @media (prefers-contrast: more) {
|
|
90
|
+
:host {
|
|
91
|
+
--_color-bg: hsla(60, 4%, 96%, 1);
|
|
92
|
+
--_color-outline-alpha: 0%;
|
|
93
|
+
}
|
|
94
|
+
} */
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@layer base {
|
|
98
|
+
* {
|
|
99
|
+
box-sizing: border-box;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:host {
|
|
103
|
+
contain: layout;
|
|
104
|
+
display: block;
|
|
105
|
+
isolation: isolate;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.head {
|
|
109
|
+
align-items: center;
|
|
110
|
+
display: flex;
|
|
111
|
+
justify-content: space-between;
|
|
112
|
+
padding-inline-end: 1rem;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
label {
|
|
116
|
+
font-weight: 400;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.foot {
|
|
120
|
+
align-items: center;
|
|
121
|
+
display: flex;
|
|
122
|
+
justify-content: space-between;
|
|
123
|
+
padding-inline-end: 1rem;
|
|
124
|
+
|
|
125
|
+
gds-badge {
|
|
126
|
+
align-self: flex-end;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
:first-child {
|
|
130
|
+
flex-grow: 1;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.supporting-text,
|
|
135
|
+
.error-text {
|
|
136
|
+
font-size: 0.875rem;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
slot[name='extended-supporting-text'] {
|
|
140
|
+
background-color: #eee;
|
|
141
|
+
border: 1px solid #ccc;
|
|
142
|
+
border-radius: 0.5rem;
|
|
143
|
+
display: block;
|
|
144
|
+
font-size: 0.875rem;
|
|
145
|
+
margin-top: 0.5rem;
|
|
146
|
+
opacity: 0;
|
|
147
|
+
padding: 1rem;
|
|
148
|
+
transition: var(--_transition);
|
|
149
|
+
|
|
150
|
+
[aria-hidden='false'] & {
|
|
151
|
+
opacity: 1;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
div.extended-supporting-text {
|
|
156
|
+
display: grid;
|
|
157
|
+
grid-template-rows: 0fr;
|
|
158
|
+
transition: var(--_transition);
|
|
159
|
+
|
|
160
|
+
> * {
|
|
161
|
+
overflow: hidden;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&[aria-hidden='false'] {
|
|
165
|
+
grid-template-rows: 1fr;
|
|
166
|
+
opacity: 1;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
input[type='number']::-webkit-inner-spin-button {
|
|
171
|
+
display: none;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
input,
|
|
175
|
+
textarea {
|
|
176
|
+
appearance: none;
|
|
177
|
+
background-color: transparent;
|
|
178
|
+
border: 0;
|
|
179
|
+
box-sizing: border-box;
|
|
180
|
+
font-family: inherit;
|
|
181
|
+
font-size: var(--_fs);
|
|
182
|
+
line-height: var(--_lh);
|
|
183
|
+
margin: unset;
|
|
184
|
+
min-height: var(--_inner-height);
|
|
185
|
+
outline: none;
|
|
186
|
+
overflow: hidden;
|
|
187
|
+
padding: unset;
|
|
188
|
+
transition: var(--_transition);
|
|
189
|
+
width: 100%;
|
|
190
|
+
|
|
191
|
+
&:focus:not(:focus-visible) {
|
|
192
|
+
outline: none;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
&::-webkit-inner-spin-button,
|
|
196
|
+
&::-webkit-calendar-picker-indicator {
|
|
197
|
+
appearance: none;
|
|
198
|
+
background-color: rgb(195, 0, 255);
|
|
199
|
+
background-image: none;
|
|
200
|
+
height: 100%;
|
|
201
|
+
position: absolute;
|
|
202
|
+
right: 0;
|
|
203
|
+
top: 0;
|
|
204
|
+
width: 40px;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
textarea {
|
|
209
|
+
max-height: max(var(--_inner-height), calc(1lh * var(--_lines)));
|
|
210
|
+
min-height: max(var(--_inner-height), calc(1lh * var(--_lines)));
|
|
211
|
+
overflow: hidden;
|
|
212
|
+
resize: none;
|
|
213
|
+
transition: unset;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.field {
|
|
217
|
+
align-items: flex-start;
|
|
218
|
+
background-color: var(--_color-bg);
|
|
219
|
+
block-size: max-content;
|
|
220
|
+
border: var(--_border-width) solid var(--_color-border);
|
|
221
|
+
border-radius: var(--_border-radius);
|
|
222
|
+
cursor: text;
|
|
223
|
+
display: flex;
|
|
224
|
+
flex-direction: row;
|
|
225
|
+
gap: var(--_gap);
|
|
226
|
+
justify-content: center;
|
|
227
|
+
margin-block: var(--_gap);
|
|
228
|
+
min-block-size: var(--_core-min-block-size);
|
|
229
|
+
outline-color: transparent;
|
|
230
|
+
outline-offset: var(--_border-width);
|
|
231
|
+
outline-style: solid;
|
|
232
|
+
outline-width: var(--_border-width-hover);
|
|
233
|
+
padding-block: var(--_padding-block);
|
|
234
|
+
padding-inline: var(--_padding-inline);
|
|
235
|
+
position: relative;
|
|
236
|
+
transition: var(--_transition);
|
|
237
|
+
|
|
238
|
+
&:focus:not(:focus-visible) {
|
|
239
|
+
outline: none;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
&:hover {
|
|
243
|
+
--_color-bg: var(--gds-sys-color-container-container-dim2);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
&:has(input:focus, textarea:focus) {
|
|
247
|
+
/* --_border-width: var(--_border-width-hover); */
|
|
248
|
+
border: var(--_border-width) solid var(--_color-border);
|
|
249
|
+
border-radius: var(--_border-radius);
|
|
250
|
+
box-shadow: none;
|
|
251
|
+
outline-color: var(--_color-outline);
|
|
252
|
+
transition: var(--_transition);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
slot {
|
|
256
|
+
align-items: center;
|
|
257
|
+
display: flex;
|
|
258
|
+
height: var(--_inner-height);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
:host(:invalid) .field {
|
|
263
|
+
--_color-bg: var(--gds-sys-color-status-negative-negative-bright);
|
|
264
|
+
--_color-border: var(--gds-sys-color-stroke-stroke-negative);
|
|
265
|
+
--_color-outline: var(--gds-sys-color-stroke-stroke-negative);
|
|
266
|
+
color: var(--gds-sys-color-status-negative-on-negative-bright);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
:host(:invalid) .error-text {
|
|
270
|
+
color: var(--gds-sys-color-status-negative-on-negative-bright);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
:host(:invalid) label {
|
|
274
|
+
color: var(--gds-sys-color-status-negative-on-negative-bright);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
@layer simplified {
|
|
279
|
+
:host([variant='simplified']) label {
|
|
280
|
+
align-items: center;
|
|
281
|
+
background-color: transparent;
|
|
282
|
+
display: block;
|
|
283
|
+
height: max-content;
|
|
284
|
+
inset: 0;
|
|
285
|
+
width: 100%;
|
|
286
|
+
|
|
287
|
+
div {
|
|
288
|
+
line-height: var(--_lh);
|
|
289
|
+
position: absolute;
|
|
290
|
+
top: 50%;
|
|
291
|
+
transform: translateY(-50%);
|
|
292
|
+
transition: var(--_transition);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
:host([variant='simplified'])
|
|
297
|
+
label:has(
|
|
298
|
+
input:not(:placeholder-shown, [readonly]),
|
|
299
|
+
textarea:not(:placeholder-shown, [readonly])
|
|
300
|
+
),
|
|
301
|
+
:host([variant='simplified']) label:focus-within {
|
|
302
|
+
div {
|
|
303
|
+
font-size: 0.75rem;
|
|
304
|
+
font-weight: 500;
|
|
305
|
+
top: 0.375rem;
|
|
306
|
+
transform: translateY(
|
|
307
|
+
translateY(calc(0px - var(--gds-input-label-translate)))
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
input,
|
|
312
|
+
textarea {
|
|
313
|
+
margin-top: 0.75rem;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
`;
|
|
318
|
+
|
|
319
|
+
// libs/core/src/components/input/input.ts
|
|
320
|
+
var _renderDefault, renderDefault_fn, _renderSimplified, renderSimplified_fn, _forwardableAttrs, _handleOnInput, _handleOnChange, _handleFieldClick, _handleClearBtnClick, _handleSupportingTextBtnClick, _renderNativeInput, renderNativeInput_fn, _renderNativeTextarea, renderNativeTextarea_fn, _renderSupportingText, renderSupportingText_fn, _renderExtendedSupportingText, renderExtendedSupportingText_fn, _renderClearButton, renderClearButton_fn, _shouldShowRemainingChars, shouldShowRemainingChars_get, _renderRemainingCharsBadge, renderRemainingCharsBadge_fn, _asyncRenderExtendedSupportingTextButton, asyncRenderExtendedSupportingTextButton_fn;
|
|
321
|
+
var GdsInput = class extends GdsFormControlElement {
|
|
322
|
+
constructor() {
|
|
323
|
+
super();
|
|
324
|
+
// variant="default"
|
|
325
|
+
__privateAdd(this, _renderDefault);
|
|
326
|
+
// variant="simplified"
|
|
327
|
+
__privateAdd(this, _renderSimplified);
|
|
328
|
+
__privateAdd(this, _renderNativeInput);
|
|
329
|
+
__privateAdd(this, _renderNativeTextarea);
|
|
330
|
+
__privateAdd(this, _renderSupportingText);
|
|
331
|
+
__privateAdd(this, _renderExtendedSupportingText);
|
|
332
|
+
__privateAdd(this, _renderClearButton);
|
|
333
|
+
__privateAdd(this, _shouldShowRemainingChars);
|
|
334
|
+
__privateAdd(this, _renderRemainingCharsBadge);
|
|
335
|
+
/**
|
|
336
|
+
* Returns a promise that resolves when the DOM query for the extended supporting text slot has resolved.
|
|
337
|
+
* If the slot is empty, an empty template is returned, otherwise the support text toggle button is returned.
|
|
338
|
+
*/
|
|
339
|
+
__privateAdd(this, _asyncRenderExtendedSupportingTextButton);
|
|
340
|
+
this.value = "";
|
|
341
|
+
this.label = "";
|
|
342
|
+
this.supportingText = "";
|
|
343
|
+
this.showExtendedSupportingText = false;
|
|
344
|
+
this.clearable = false;
|
|
345
|
+
this.maxlength = Number.MAX_SAFE_INTEGER;
|
|
346
|
+
this.variant = "default";
|
|
347
|
+
this.multiline = false;
|
|
348
|
+
// Any attribute name added here will get forwarded to the native <input> element.
|
|
349
|
+
__privateAdd(this, _forwardableAttrs, (attr) => ["type", "placeholder", "required"].includes(attr.name));
|
|
350
|
+
__privateAdd(this, _handleOnInput, (e) => {
|
|
351
|
+
const element = e.target;
|
|
352
|
+
this.value = element.value;
|
|
353
|
+
});
|
|
354
|
+
__privateAdd(this, _handleOnChange, (e) => {
|
|
355
|
+
const element = e.target;
|
|
356
|
+
this.value = element.value;
|
|
357
|
+
this.dispatchEvent(
|
|
358
|
+
new Event("change", {
|
|
359
|
+
bubbles: true,
|
|
360
|
+
composed: true
|
|
361
|
+
})
|
|
362
|
+
);
|
|
363
|
+
});
|
|
364
|
+
__privateAdd(this, _handleFieldClick, () => {
|
|
365
|
+
this.elInputAsync.then((el) => el.focus());
|
|
366
|
+
});
|
|
367
|
+
__privateAdd(this, _handleClearBtnClick, () => {
|
|
368
|
+
this.value = "";
|
|
369
|
+
});
|
|
370
|
+
__privateAdd(this, _handleSupportingTextBtnClick, () => {
|
|
371
|
+
this.showExtendedSupportingText = !this.showExtendedSupportingText;
|
|
372
|
+
this.dispatchEvent(
|
|
373
|
+
new CustomEvent("gds-ui-state", {
|
|
374
|
+
bubbles: true,
|
|
375
|
+
composed: true,
|
|
376
|
+
detail: this.showExtendedSupportingText
|
|
377
|
+
})
|
|
378
|
+
);
|
|
379
|
+
});
|
|
380
|
+
constrainSlots(this);
|
|
381
|
+
}
|
|
382
|
+
connectedCallback() {
|
|
383
|
+
super.connectedCallback();
|
|
384
|
+
this._setAutoHeight();
|
|
385
|
+
}
|
|
386
|
+
render() {
|
|
387
|
+
return html`${choose(this.variant, [
|
|
388
|
+
["default", () => __privateMethod(this, _renderDefault, renderDefault_fn).call(this)],
|
|
389
|
+
["simplified", () => __privateMethod(this, _renderSimplified, renderSimplified_fn).call(this)]
|
|
390
|
+
])}`;
|
|
391
|
+
}
|
|
392
|
+
_getValidityAnchor() {
|
|
393
|
+
return this.elInput;
|
|
394
|
+
}
|
|
395
|
+
_setAutoHeight() {
|
|
396
|
+
if (!this.multiline)
|
|
397
|
+
return;
|
|
398
|
+
this.elInputAsync.then((element) => {
|
|
399
|
+
const lines = (element.value.split("\n").length || 1).toString();
|
|
400
|
+
element == null ? void 0 : element.style.setProperty("--_lines", lines.toString());
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
_renderDefault = new WeakSet();
|
|
405
|
+
renderDefault_fn = function() {
|
|
406
|
+
return html`
|
|
407
|
+
<div class="head">
|
|
408
|
+
<label for="input">${this.label}</label>
|
|
409
|
+
${until(__privateMethod(this, _asyncRenderExtendedSupportingTextButton, asyncRenderExtendedSupportingTextButton_fn).call(this), nothing)}
|
|
410
|
+
</div>
|
|
411
|
+
|
|
412
|
+
${__privateMethod(this, _renderSupportingText, renderSupportingText_fn).call(this)} ${__privateMethod(this, _renderExtendedSupportingText, renderExtendedSupportingText_fn).call(this)}
|
|
413
|
+
|
|
414
|
+
<div class="field" @click=${__privateGet(this, _handleFieldClick)}>
|
|
415
|
+
<slot name="lead"></slot>
|
|
416
|
+
${when(
|
|
417
|
+
this.multiline,
|
|
418
|
+
() => html`${__privateMethod(this, _renderNativeTextarea, renderNativeTextarea_fn).call(this)}`,
|
|
419
|
+
() => html`${__privateMethod(this, _renderNativeInput, renderNativeInput_fn).call(this)}`
|
|
420
|
+
)}
|
|
421
|
+
<slot name="trail" gds-allow="gds-badge"></slot>
|
|
422
|
+
${__privateMethod(this, _renderClearButton, renderClearButton_fn).call(this)}
|
|
423
|
+
</div>
|
|
424
|
+
|
|
425
|
+
<div class="foot">
|
|
426
|
+
<div>
|
|
427
|
+
${when(
|
|
428
|
+
this.invalid,
|
|
429
|
+
() => html`<span class="error-text">${this.validationMessage}</span>`
|
|
430
|
+
)}
|
|
431
|
+
</div>
|
|
432
|
+
${when(
|
|
433
|
+
__privateGet(this, _shouldShowRemainingChars, shouldShowRemainingChars_get),
|
|
434
|
+
() => __privateMethod(this, _renderRemainingCharsBadge, renderRemainingCharsBadge_fn).call(this)
|
|
435
|
+
)}
|
|
436
|
+
</div>
|
|
437
|
+
`;
|
|
438
|
+
};
|
|
439
|
+
_renderSimplified = new WeakSet();
|
|
440
|
+
renderSimplified_fn = function() {
|
|
441
|
+
return html`
|
|
442
|
+
<div class="field" @click=${__privateGet(this, _handleFieldClick)}>
|
|
443
|
+
<slot name="lead"></slot>
|
|
444
|
+
<label for="input">
|
|
445
|
+
<div>${this.label}</div>
|
|
446
|
+
${when(
|
|
447
|
+
this.multiline,
|
|
448
|
+
() => html`${__privateMethod(this, _renderNativeTextarea, renderNativeTextarea_fn).call(this)}`,
|
|
449
|
+
() => html`${__privateMethod(this, _renderNativeInput, renderNativeInput_fn).call(this)}`
|
|
450
|
+
)}
|
|
451
|
+
</label>
|
|
452
|
+
<slot name="trail" gds-allow="gds-badge"></slot>
|
|
453
|
+
${__privateMethod(this, _renderClearButton, renderClearButton_fn).call(this)}
|
|
454
|
+
</div>
|
|
455
|
+
|
|
456
|
+
<div class="foot">
|
|
457
|
+
${__privateMethod(this, _renderSupportingText, renderSupportingText_fn).call(this)}
|
|
458
|
+
${when(
|
|
459
|
+
__privateGet(this, _shouldShowRemainingChars, shouldShowRemainingChars_get),
|
|
460
|
+
() => __privateMethod(this, _renderRemainingCharsBadge, renderRemainingCharsBadge_fn).call(this)
|
|
461
|
+
)}
|
|
462
|
+
${until(__privateMethod(this, _asyncRenderExtendedSupportingTextButton, asyncRenderExtendedSupportingTextButton_fn).call(this), nothing)}
|
|
463
|
+
</div>
|
|
464
|
+
|
|
465
|
+
${__privateMethod(this, _renderExtendedSupportingText, renderExtendedSupportingText_fn).call(this)}
|
|
466
|
+
`;
|
|
467
|
+
};
|
|
468
|
+
_forwardableAttrs = new WeakMap();
|
|
469
|
+
_handleOnInput = new WeakMap();
|
|
470
|
+
_handleOnChange = new WeakMap();
|
|
471
|
+
_handleFieldClick = new WeakMap();
|
|
472
|
+
_handleClearBtnClick = new WeakMap();
|
|
473
|
+
_handleSupportingTextBtnClick = new WeakMap();
|
|
474
|
+
_renderNativeInput = new WeakSet();
|
|
475
|
+
renderNativeInput_fn = function() {
|
|
476
|
+
return html`
|
|
477
|
+
<input
|
|
478
|
+
@input=${__privateGet(this, _handleOnInput)}
|
|
479
|
+
@change=${__privateGet(this, _handleOnChange)}
|
|
480
|
+
.value=${this.value}
|
|
481
|
+
id="input"
|
|
482
|
+
aria-describedby="supporting-text"
|
|
483
|
+
placeholder=" "
|
|
484
|
+
${forwardAttributes(__privateGet(this, _forwardableAttrs))}
|
|
485
|
+
/>
|
|
486
|
+
`;
|
|
487
|
+
};
|
|
488
|
+
_renderNativeTextarea = new WeakSet();
|
|
489
|
+
renderNativeTextarea_fn = function() {
|
|
490
|
+
return html`
|
|
491
|
+
<textarea
|
|
492
|
+
@input=${__privateGet(this, _handleOnInput)}
|
|
493
|
+
@change=${__privateGet(this, _handleOnChange)}
|
|
494
|
+
.value=${this.value}
|
|
495
|
+
id="input"
|
|
496
|
+
aria-describedby="supporting-text"
|
|
497
|
+
placeholder=" "
|
|
498
|
+
${forwardAttributes(__privateGet(this, _forwardableAttrs))}
|
|
499
|
+
></textarea>
|
|
500
|
+
`;
|
|
501
|
+
};
|
|
502
|
+
_renderSupportingText = new WeakSet();
|
|
503
|
+
renderSupportingText_fn = function() {
|
|
504
|
+
return html`
|
|
505
|
+
<div class="supporting-text" id="supporting-text">
|
|
506
|
+
${this.supportingText}
|
|
507
|
+
</div>
|
|
508
|
+
`;
|
|
509
|
+
};
|
|
510
|
+
_renderExtendedSupportingText = new WeakSet();
|
|
511
|
+
renderExtendedSupportingText_fn = function() {
|
|
512
|
+
return html`
|
|
513
|
+
<div
|
|
514
|
+
class="extended-supporting-text"
|
|
515
|
+
aria-hidden="${!this.showExtendedSupportingText}"
|
|
516
|
+
?inert="${!this.showExtendedSupportingText}"
|
|
517
|
+
>
|
|
518
|
+
<div>
|
|
519
|
+
<slot name="message" @slotchange=${() => this.requestUpdate()}></slot>
|
|
520
|
+
</div>
|
|
521
|
+
</div>
|
|
522
|
+
`;
|
|
523
|
+
};
|
|
524
|
+
_renderClearButton = new WeakSet();
|
|
525
|
+
renderClearButton_fn = function() {
|
|
526
|
+
if (this.clearable && this.value.length > 0)
|
|
527
|
+
return html`
|
|
528
|
+
<gds-button
|
|
529
|
+
size="small"
|
|
530
|
+
variant="tertiary"
|
|
531
|
+
label="${msg("Clear input")}"
|
|
532
|
+
@click=${__privateGet(this, _handleClearBtnClick)}
|
|
533
|
+
>
|
|
534
|
+
<gds-icon-cross-small />
|
|
535
|
+
</gds-button>
|
|
536
|
+
`;
|
|
537
|
+
else
|
|
538
|
+
return nothing;
|
|
539
|
+
};
|
|
540
|
+
_shouldShowRemainingChars = new WeakSet();
|
|
541
|
+
shouldShowRemainingChars_get = function() {
|
|
542
|
+
return this.maxlength < Number.MAX_SAFE_INTEGER;
|
|
543
|
+
};
|
|
544
|
+
_renderRemainingCharsBadge = new WeakSet();
|
|
545
|
+
renderRemainingCharsBadge_fn = function() {
|
|
546
|
+
const remaining = this.maxlength - this.value.length;
|
|
547
|
+
let variant;
|
|
548
|
+
if (remaining < 0) {
|
|
549
|
+
variant = "error";
|
|
550
|
+
} else if (remaining < 20) {
|
|
551
|
+
variant = "warning";
|
|
552
|
+
} else {
|
|
553
|
+
variant = "success";
|
|
554
|
+
}
|
|
555
|
+
return html`<gds-badge variant="${variant}">${remaining}</gds-badge>`;
|
|
556
|
+
};
|
|
557
|
+
_asyncRenderExtendedSupportingTextButton = new WeakSet();
|
|
558
|
+
asyncRenderExtendedSupportingTextButton_fn = async function() {
|
|
559
|
+
return this.elExtendedSupportingTextSlot.then((slot) => {
|
|
560
|
+
if (slot.assignedElements().length > 0)
|
|
561
|
+
return html`
|
|
562
|
+
<gds-button
|
|
563
|
+
size="small"
|
|
564
|
+
variant="tertiary"
|
|
565
|
+
label="${msg("Show extended supporting text")}"
|
|
566
|
+
@click=${__privateGet(this, _handleSupportingTextBtnClick)}
|
|
567
|
+
>
|
|
568
|
+
<gds-icon-circle-info />
|
|
569
|
+
</gds-button>
|
|
570
|
+
`;
|
|
571
|
+
else
|
|
572
|
+
return nothing;
|
|
573
|
+
});
|
|
574
|
+
};
|
|
575
|
+
GdsInput.shadowRootOptions = __spreadProps(__spreadValues({}, LitElement.shadowRootOptions), {
|
|
576
|
+
delegatesFocus: true
|
|
577
|
+
});
|
|
578
|
+
GdsInput.styles = [tokens, styles];
|
|
579
|
+
__decorateClass([
|
|
580
|
+
property()
|
|
581
|
+
], GdsInput.prototype, "value", 2);
|
|
582
|
+
__decorateClass([
|
|
583
|
+
property()
|
|
584
|
+
], GdsInput.prototype, "label", 2);
|
|
585
|
+
__decorateClass([
|
|
586
|
+
property({ attribute: "supporting-text" })
|
|
587
|
+
], GdsInput.prototype, "supportingText", 2);
|
|
588
|
+
__decorateClass([
|
|
589
|
+
property({
|
|
590
|
+
attribute: "show-extended-supporting-text",
|
|
591
|
+
type: Boolean,
|
|
592
|
+
reflect: true
|
|
593
|
+
})
|
|
594
|
+
], GdsInput.prototype, "showExtendedSupportingText", 2);
|
|
595
|
+
__decorateClass([
|
|
596
|
+
property({ type: Boolean })
|
|
597
|
+
], GdsInput.prototype, "clearable", 2);
|
|
598
|
+
__decorateClass([
|
|
599
|
+
property({ type: Number })
|
|
600
|
+
], GdsInput.prototype, "maxlength", 2);
|
|
601
|
+
__decorateClass([
|
|
602
|
+
property({ type: String })
|
|
603
|
+
], GdsInput.prototype, "variant", 2);
|
|
604
|
+
__decorateClass([
|
|
605
|
+
property({ type: Boolean })
|
|
606
|
+
], GdsInput.prototype, "multiline", 2);
|
|
607
|
+
__decorateClass([
|
|
608
|
+
queryAsync("input, textarea")
|
|
609
|
+
], GdsInput.prototype, "elInputAsync", 2);
|
|
610
|
+
__decorateClass([
|
|
611
|
+
query("input, textarea")
|
|
612
|
+
], GdsInput.prototype, "elInput", 2);
|
|
613
|
+
__decorateClass([
|
|
614
|
+
queryAsync('slot[name="extended-supporting-text"]')
|
|
615
|
+
], GdsInput.prototype, "elExtendedSupportingTextSlot", 2);
|
|
616
|
+
__decorateClass([
|
|
617
|
+
watch("value")
|
|
618
|
+
], GdsInput.prototype, "_setAutoHeight", 1);
|
|
619
|
+
GdsInput = __decorateClass([
|
|
620
|
+
gdsCustomElement("gds-input")
|
|
621
|
+
], GdsInput);
|
|
622
|
+
|
|
623
|
+
export {
|
|
624
|
+
GdsInput
|
|
625
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GdsSegment
|
|
3
|
-
} from "./chunk.
|
|
3
|
+
} from "./chunk.TUCS4UFR.js";
|
|
4
4
|
import {
|
|
5
5
|
resizeObserver
|
|
6
6
|
} from "./chunk.VHN4JEZC.js";
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk.S7DYDS4E.js";
|
|
10
10
|
import {
|
|
11
11
|
tokens
|
|
12
|
-
} from "./chunk.
|
|
12
|
+
} from "./chunk.VGQTBRXA.js";
|
|
13
13
|
import {
|
|
14
14
|
watch
|
|
15
15
|
} from "./chunk.2WO4NHJ2.js";
|