@crowdstrike/glide-core 0.29.1 → 0.30.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/accordion.js +240 -1
- package/dist/accordion.styles.js +13 -7
- package/dist/button-group.button.js +143 -1
- package/dist/button-group.button.styles.js +43 -15
- package/dist/button-group.js +249 -1
- package/dist/button-group.styles.js +10 -5
- package/dist/button.js +206 -1
- package/dist/button.styles.js +12 -7
- package/dist/checkbox-group.js +479 -14
- package/dist/checkbox-group.styles.js +5 -2
- package/dist/checkbox.js +519 -32
- package/dist/checkbox.styles.js +10 -5
- package/dist/drawer.js +168 -1
- package/dist/drawer.styles.js +5 -2
- package/dist/dropdown.js +2423 -123
- package/dist/dropdown.option.js +536 -1
- package/dist/dropdown.option.styles.js +5 -2
- package/dist/dropdown.styles.js +14 -7
- package/dist/form-controls-layout.js +102 -1
- package/dist/form-controls-layout.styles.js +5 -2
- package/dist/icon-button.js +139 -1
- package/dist/icon-button.styles.js +19 -7
- package/dist/icons/checked.js +28 -1
- package/dist/icons/chevron.js +21 -1
- package/dist/icons/magnifying-glass.js +23 -1
- package/dist/icons/pencil.js +21 -1
- package/dist/icons/severity-critical.js +20 -1
- package/dist/icons/severity-informational.js +20 -1
- package/dist/icons/severity-medium.js +20 -1
- package/dist/icons/x.js +21 -1
- package/dist/inline-alert.js +118 -1
- package/dist/inline-alert.styles.js +5 -2
- package/dist/input.d.ts +8 -2
- package/dist/input.js +505 -41
- package/dist/input.styles.js +25 -4
- package/dist/label.js +303 -1
- package/dist/label.styles.js +11 -5
- package/dist/library/assert-slot.js +136 -1
- package/dist/library/expect-unhandled-rejection.js +14 -1
- package/dist/library/expect-window-error.js +26 -1
- package/dist/library/final.js +18 -1
- package/dist/library/form-control.js +1 -1
- package/dist/library/localize.js +10 -1
- package/dist/library/mouse.js +35 -1
- package/dist/library/on-resize.js +24 -1
- package/dist/library/required.js +35 -1
- package/dist/library/shadow-root-mode.js +4 -1
- package/dist/library/unique-id.js +3 -1
- package/dist/link.js +92 -1
- package/dist/link.styles.js +10 -5
- package/dist/menu.d.ts +3 -2
- package/dist/menu.js +1259 -1
- package/dist/menu.styles.js +34 -17
- package/dist/modal.d.ts +4 -0
- package/dist/modal.icon-button.js +60 -1
- package/dist/modal.icon-button.styles.js +5 -2
- package/dist/modal.js +473 -1
- package/dist/modal.styles.js +71 -22
- package/dist/option.d.ts +74 -0
- package/dist/option.js +498 -0
- package/dist/option.styles.js +140 -0
- package/dist/{menu.options.d.ts → options.d.ts} +5 -6
- package/dist/options.js +130 -0
- package/dist/options.styles.js +21 -0
- package/dist/popover.js +620 -1
- package/dist/popover.styles.js +11 -5
- package/dist/radio-group.js +624 -17
- package/dist/radio-group.radio.js +211 -1
- package/dist/radio-group.radio.styles.js +9 -4
- package/dist/radio-group.styles.js +5 -2
- package/dist/slider.js +1040 -61
- package/dist/slider.styles.js +9 -4
- package/dist/spinner.js +60 -1
- package/dist/spinner.styles.js +5 -2
- package/dist/split-button.js +116 -1
- package/dist/split-button.primary-button.js +100 -1
- package/dist/split-button.primary-button.styles.js +13 -6
- package/dist/split-button.primary-link.js +102 -1
- package/dist/split-button.secondary-button.d.ts +2 -3
- package/dist/split-button.secondary-button.js +121 -1
- package/dist/split-button.secondary-button.styles.js +12 -7
- package/dist/split-button.styles.js +9 -4
- package/dist/styles/focus-outline.js +9 -3
- package/dist/styles/fonts.css +6 -1
- package/dist/styles/opacity-and-scale-animation.js +6 -3
- package/dist/styles/skeleton.js +6 -3
- package/dist/styles/variables.css +410 -1
- package/dist/styles/visually-hidden.js +6 -3
- package/dist/tab.group.js +386 -1
- package/dist/tab.group.styles.js +5 -2
- package/dist/tab.js +133 -1
- package/dist/tab.panel.js +93 -1
- package/dist/tab.panel.styles.js +11 -5
- package/dist/tab.styles.js +9 -4
- package/dist/tag.js +207 -1
- package/dist/tag.styles.js +10 -5
- package/dist/textarea.js +353 -19
- package/dist/textarea.styles.js +23 -4
- package/dist/toast.js +130 -1
- package/dist/toast.toasts.js +248 -25
- package/dist/toast.toasts.styles.js +9 -4
- package/dist/toggle.js +178 -1
- package/dist/toggle.styles.js +25 -5
- package/dist/tooltip.container.d.ts +2 -0
- package/dist/tooltip.container.js +130 -1
- package/dist/tooltip.container.styles.js +18 -4
- package/dist/tooltip.d.ts +6 -0
- package/dist/tooltip.js +484 -1
- package/dist/tooltip.styles.js +21 -5
- package/dist/translations/en.js +36 -1
- package/dist/translations/fr.js +37 -1
- package/dist/translations/ja.js +37 -1
- package/package.json +8 -12
- package/dist/menu.button.d.ts +0 -42
- package/dist/menu.button.js +0 -1
- package/dist/menu.button.styles.js +0 -32
- package/dist/menu.link.d.ts +0 -44
- package/dist/menu.link.js +0 -1
- package/dist/menu.link.styles.js +0 -35
- package/dist/menu.options.js +0 -1
- package/dist/menu.options.styles.d.ts +0 -2
- package/dist/menu.options.styles.js +0 -20
- /package/dist/{menu.button.styles.d.ts → option.styles.d.ts} +0 -0
- /package/dist/{menu.link.styles.d.ts → options.styles.d.ts} +0 -0
package/dist/textarea.js
CHANGED
@@ -1,10 +1,126 @@
|
|
1
|
-
var __decorate=this&&this.__decorate
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
import './label.js';
|
8
|
+
import { html, LitElement, nothing } from 'lit';
|
9
|
+
import { classMap } from 'lit/directives/class-map.js';
|
10
|
+
import { createRef, ref } from 'lit/directives/ref.js';
|
11
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
12
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
13
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
14
|
+
import { when } from 'lit/directives/when.js';
|
15
|
+
import packageJson from '../package.json' with { type: 'json' };
|
16
|
+
import { LocalizeController } from './library/localize.js';
|
17
|
+
import styles from './textarea.styles.js';
|
18
|
+
import shadowRootMode from './library/shadow-root-mode.js';
|
19
|
+
import final from './library/final.js';
|
20
|
+
import required from './library/required.js';
|
21
|
+
/**
|
22
|
+
* @attr {string} label
|
23
|
+
* @attr {'on'|'off'|'none'|'sentences'|'words'|'characters'} [autocapitalize='on']
|
24
|
+
* @attr {'on'|'off'} [autocomplete='on']
|
25
|
+
* @attr {boolean} [disabled=false]
|
26
|
+
* @attr {boolean} [hide-label=false]
|
27
|
+
* @attr {number} [maxlength]
|
28
|
+
* @attr {string} [name='']
|
29
|
+
* @attr {'horizontal'|'vertical'} [orientation='horizontal']
|
30
|
+
* @attr {string} [placeholder]
|
31
|
+
* @attr {boolean} [readonly=false]
|
32
|
+
* @attr {boolean} [required=false]
|
33
|
+
* @attr {boolean} [spellcheck=false]
|
34
|
+
* @attr {string} [tooltip]
|
35
|
+
* @attr {string} [value='']
|
36
|
+
*
|
37
|
+
* @readonly
|
38
|
+
* @attr {string} [version]
|
39
|
+
*
|
40
|
+
* @slot {Element | string} [description] - Additional information or context
|
41
|
+
*
|
42
|
+
* @fires {Event} change
|
43
|
+
* @fires {Event} invalid
|
44
|
+
*
|
45
|
+
* @readonly
|
46
|
+
* @prop {HTMLFormElement | null} form
|
47
|
+
*
|
48
|
+
* @readonly
|
49
|
+
* @prop {ValidityState} validity
|
50
|
+
*
|
51
|
+
* @method checkValidity
|
52
|
+
* @returns boolean
|
53
|
+
*
|
54
|
+
* @method formAssociatedCallback
|
55
|
+
* @method formResetCallback
|
56
|
+
*
|
57
|
+
* @method reportValidity
|
58
|
+
* @returns boolean
|
59
|
+
*
|
60
|
+
* @method resetValidityFeedback
|
61
|
+
*
|
62
|
+
* @method setCustomValidity
|
63
|
+
* @param {string} message
|
64
|
+
*
|
65
|
+
* @method setValidity
|
66
|
+
* @param {ValidityStateFlags} [flags]
|
67
|
+
* @param {string} [message]
|
68
|
+
*/
|
69
|
+
let Textarea = class Textarea extends LitElement {
|
70
|
+
static { this.formAssociated = true; }
|
71
|
+
static { this.shadowRootOptions = {
|
72
|
+
...LitElement.shadowRootOptions,
|
73
|
+
mode: shadowRootMode,
|
74
|
+
delegatesFocus: true,
|
75
|
+
}; }
|
76
|
+
static { this.styles = styles; }
|
77
|
+
checkValidity() {
|
78
|
+
this.isCheckingValidity = true;
|
79
|
+
const isValid = this.#internals.checkValidity();
|
80
|
+
this.isCheckingValidity = false;
|
81
|
+
return isValid;
|
82
|
+
}
|
83
|
+
disconnectedCallback() {
|
84
|
+
super.disconnectedCallback();
|
85
|
+
this.form?.removeEventListener('formdata', this.#onFormdata);
|
86
|
+
}
|
87
|
+
get form() {
|
88
|
+
return this.#internals.form;
|
89
|
+
}
|
90
|
+
get validity() {
|
91
|
+
if (this.required && !this.value && !this.disabled) {
|
92
|
+
// A validation message is required but unused because we disable native
|
93
|
+
// validation feedback. And an empty string isn't allowed. Thus a single space.
|
94
|
+
this.#internals.setValidity({ customError: Boolean(this.validityMessage), valueMissing: true }, ' ', this.#textareaElementRef.value);
|
95
|
+
return this.#internals.validity;
|
96
|
+
}
|
97
|
+
if (this.required && this.#internals.validity.valueMissing && this.value) {
|
98
|
+
this.#internals.setValidity({});
|
99
|
+
return this.#internals.validity;
|
100
|
+
}
|
101
|
+
if (!this.required &&
|
102
|
+
this.#internals.validity.valueMissing &&
|
103
|
+
!this.value) {
|
104
|
+
this.#internals.setValidity({});
|
105
|
+
return this.#internals.validity;
|
106
|
+
}
|
107
|
+
return this.#internals.validity;
|
108
|
+
}
|
109
|
+
formAssociatedCallback() {
|
110
|
+
this.form?.addEventListener('formdata', this.#onFormdata);
|
111
|
+
}
|
112
|
+
formResetCallback() {
|
113
|
+
this.value = this.getAttribute('value') ?? '';
|
114
|
+
}
|
115
|
+
render() {
|
116
|
+
return html `<glide-core-private-label
|
2
117
|
label=${ifDefined(this.label)}
|
3
|
-
split=${ifDefined(this.privateSplit??
|
118
|
+
split=${ifDefined(this.privateSplit ?? undefined)}
|
4
119
|
tooltip=${ifDefined(this.tooltip)}
|
5
120
|
orientation=${this.orientation}
|
6
121
|
?disabled=${this.disabled}
|
7
|
-
?error=${this.#
|
122
|
+
?error=${this.#isShowValidationFeedback ||
|
123
|
+
this.#isMaxCharacterCountExceeded}
|
8
124
|
?hide=${this.hideLabel}
|
9
125
|
?required=${this.required}
|
10
126
|
>
|
@@ -13,8 +129,12 @@ var __decorate=this&&this.__decorate||function(e,t,i,a){var r,s=arguments.length
|
|
13
129
|
<div class="textarea-container" slot="control">
|
14
130
|
<textarea
|
15
131
|
aria-describedby="meta"
|
16
|
-
aria-invalid=${this.#
|
17
|
-
|
132
|
+
aria-invalid=${this.#isShowValidationFeedback ||
|
133
|
+
this.#isMaxCharacterCountExceeded}
|
134
|
+
class=${classMap({
|
135
|
+
error: this.#isShowValidationFeedback ||
|
136
|
+
this.#isMaxCharacterCountExceeded,
|
137
|
+
})}
|
18
138
|
data-test="textarea"
|
19
139
|
id="textarea"
|
20
140
|
name=${ifDefined(this.name)}
|
@@ -26,18 +146,21 @@ var __decorate=this&&this.__decorate||function(e,t,i,a){var r,s=arguments.length
|
|
26
146
|
?required=${this.required}
|
27
147
|
?readonly=${this.readonly}
|
28
148
|
?disabled=${this.disabled}
|
29
|
-
${ref(this.#
|
30
|
-
@blur=${this.#
|
31
|
-
@change=${this.#
|
32
|
-
@input=${this.#
|
33
|
-
@keydown=${this.#
|
149
|
+
${ref(this.#textareaElementRef)}
|
150
|
+
@blur=${this.#onTextareaBlur}
|
151
|
+
@change=${this.#onTextareaChange}
|
152
|
+
@input=${this.#onTextareaInput}
|
153
|
+
@keydown=${this.#onTextareaKeydown}
|
34
154
|
>
|
35
155
|
</textarea>
|
36
156
|
</div>
|
37
157
|
|
38
158
|
<div class="meta" id="meta" slot="description">
|
39
159
|
<slot
|
40
|
-
class=${classMap({
|
160
|
+
class=${classMap({
|
161
|
+
description: true,
|
162
|
+
hidden: Boolean(this.#isShowValidationFeedback && this.validityMessage),
|
163
|
+
})}
|
41
164
|
name="description"
|
42
165
|
>
|
43
166
|
<!--
|
@@ -46,20 +169,231 @@ var __decorate=this&&this.__decorate||function(e,t,i,a){var r,s=arguments.length
|
|
46
169
|
-->
|
47
170
|
</slot>
|
48
171
|
|
49
|
-
${when(this.#
|
172
|
+
${when(this.#isShowValidationFeedback && this.validityMessage, () => html `<span class="validity-message" data-test="validity-message"
|
50
173
|
>${unsafeHTML(this.validityMessage)}</span
|
51
|
-
>`)
|
52
|
-
${this.maxlength
|
53
|
-
|
174
|
+
>`)}
|
175
|
+
${this.maxlength
|
176
|
+
? html `<div
|
177
|
+
class=${classMap({
|
178
|
+
'character-count': true,
|
179
|
+
error: this.#isMaxCharacterCountExceeded,
|
180
|
+
})}
|
54
181
|
data-test="character-count-container"
|
55
182
|
>
|
56
183
|
<span aria-hidden="true" data-test="character-count-text">
|
57
|
-
${this.#
|
184
|
+
${this.#localize.term('displayedCharacterCount', this.#valueCharacterCount, this.maxlength)}
|
58
185
|
</span>
|
59
186
|
|
60
187
|
<span class="hidden" data-test="character-count-announcement"
|
61
|
-
>${this.#
|
188
|
+
>${this.#localize.term('announcedCharacterCount', this.#valueCharacterCount, this.maxlength)}</span
|
62
189
|
>
|
63
|
-
</div
|
190
|
+
</div>`
|
191
|
+
: nothing}
|
64
192
|
</div></glide-core-private-label
|
65
|
-
|
193
|
+
>`;
|
194
|
+
}
|
195
|
+
reportValidity() {
|
196
|
+
this.isReportValidityOrSubmit = true;
|
197
|
+
const isValid = this.#internals.reportValidity();
|
198
|
+
// Ensures that getters referencing `this.validity.valid` are updated.
|
199
|
+
this.requestUpdate();
|
200
|
+
return isValid;
|
201
|
+
}
|
202
|
+
resetValidityFeedback() {
|
203
|
+
this.isReportValidityOrSubmit = false;
|
204
|
+
}
|
205
|
+
setCustomValidity(message) {
|
206
|
+
this.validityMessage = message;
|
207
|
+
if (message === '') {
|
208
|
+
this.#internals.setValidity({ customError: false }, '', this.#textareaElementRef.value);
|
209
|
+
}
|
210
|
+
else {
|
211
|
+
this.#internals.setValidity({
|
212
|
+
customError: true,
|
213
|
+
valueMissing: this.#internals.validity.valueMissing,
|
214
|
+
}, ' ', this.#textareaElementRef.value);
|
215
|
+
}
|
216
|
+
}
|
217
|
+
setValidity(flags, message) {
|
218
|
+
this.validityMessage = message;
|
219
|
+
this.#internals.setValidity(flags, ' ', this.#textareaElementRef.value);
|
220
|
+
}
|
221
|
+
constructor() {
|
222
|
+
super();
|
223
|
+
this.autocapitalize = 'on';
|
224
|
+
this.autocomplete = 'on';
|
225
|
+
this.disabled = false;
|
226
|
+
this.hideLabel = false;
|
227
|
+
this.name = '';
|
228
|
+
this.orientation = 'horizontal';
|
229
|
+
// It's typed by TypeScript as a boolean. But we treat it as a string throughout.
|
230
|
+
this.spellcheck = false;
|
231
|
+
this.required = false;
|
232
|
+
this.readonly = false;
|
233
|
+
// Intentionally not reflected to match native.
|
234
|
+
this.value = '';
|
235
|
+
this.version = packageJson.version;
|
236
|
+
this.isBlurring = false;
|
237
|
+
this.isCheckingValidity = false;
|
238
|
+
this.isReportValidityOrSubmit = false;
|
239
|
+
this.#localize = new LocalizeController(this);
|
240
|
+
this.#textareaElementRef = createRef();
|
241
|
+
// An arrow function field instead of a method so `this` is closed over and
|
242
|
+
// set to the component instead of `document`.
|
243
|
+
this.#onFormdata = ({ formData }) => {
|
244
|
+
if (this.name && this.value && !this.disabled) {
|
245
|
+
formData.append(this.name, this.value);
|
246
|
+
}
|
247
|
+
};
|
248
|
+
this.#internals = this.attachInternals();
|
249
|
+
// Event handlers on the host aren't great because consumers can remove them.
|
250
|
+
// Unfortunately, the host is the only thing on which this event is dispatched
|
251
|
+
// because it's the host that is form-associated.
|
252
|
+
this.addEventListener('invalid', (event) => {
|
253
|
+
event?.preventDefault(); // Canceled so a native validation message isn't shown.
|
254
|
+
// We only want to focus the input if the "invalid" event resulted from either:
|
255
|
+
//
|
256
|
+
// 1. A form submission.
|
257
|
+
// 2. A call of `reportValidity()` that did not result from the input's "blur"
|
258
|
+
// event.
|
259
|
+
if (this.isCheckingValidity || this.isBlurring) {
|
260
|
+
return;
|
261
|
+
}
|
262
|
+
this.isReportValidityOrSubmit = true;
|
263
|
+
const isFirstInvalidFormElement = this.form?.querySelector(':invalid') === this;
|
264
|
+
if (isFirstInvalidFormElement) {
|
265
|
+
// - `this.#internals.delegatesFocus` is preferred because it's declarative. But
|
266
|
+
// it's limited to focusing the first focusable element. That doesn't work for
|
267
|
+
// us because our first focusable element is the tooltip when it's present.
|
268
|
+
//
|
269
|
+
// - Canceling this event means the input won't get focus, even if we were to use
|
270
|
+
// `this.#internals.delegatesFocus`.
|
271
|
+
//
|
272
|
+
// - The browser will ignore this if Input isn't the first invalid form control.
|
273
|
+
//
|
274
|
+
// TODO
|
275
|
+
// Try passing `focusVisible` after browsers support it. It may prevent the issue
|
276
|
+
// where the input itself has a focus outline after this call.
|
277
|
+
//
|
278
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#focusvisible
|
279
|
+
this.focus();
|
280
|
+
}
|
281
|
+
});
|
282
|
+
}
|
283
|
+
#internals;
|
284
|
+
#localize;
|
285
|
+
#textareaElementRef;
|
286
|
+
// An arrow function field instead of a method so `this` is closed over and
|
287
|
+
// set to the component instead of `document`.
|
288
|
+
#onFormdata;
|
289
|
+
get #isShowValidationFeedback() {
|
290
|
+
return (!this.disabled &&
|
291
|
+
!this.readonly &&
|
292
|
+
!this.validity.valid &&
|
293
|
+
this.isReportValidityOrSubmit);
|
294
|
+
}
|
295
|
+
get #valueCharacterCount() {
|
296
|
+
return this.value.length;
|
297
|
+
}
|
298
|
+
get #isMaxCharacterCountExceeded() {
|
299
|
+
return Boolean(!this.disabled &&
|
300
|
+
!this.readonly &&
|
301
|
+
this.maxlength &&
|
302
|
+
this.#valueCharacterCount > this.maxlength);
|
303
|
+
}
|
304
|
+
#onTextareaBlur() {
|
305
|
+
this.isBlurring = true;
|
306
|
+
this.reportValidity();
|
307
|
+
this.isBlurring = false;
|
308
|
+
}
|
309
|
+
#onTextareaChange() {
|
310
|
+
if (this.#textareaElementRef.value) {
|
311
|
+
this.value = this.#textareaElementRef.value.value;
|
312
|
+
}
|
313
|
+
// Unlike "input" events, "change" events aren't composed. So we have to
|
314
|
+
// manually dispatch them.
|
315
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
316
|
+
}
|
317
|
+
#onTextareaInput() {
|
318
|
+
if (this.#textareaElementRef.value) {
|
319
|
+
this.value = this.#textareaElementRef.value.value;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
#onTextareaKeydown(event) {
|
323
|
+
if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {
|
324
|
+
this.form?.requestSubmit();
|
325
|
+
}
|
326
|
+
}
|
327
|
+
};
|
328
|
+
__decorate([
|
329
|
+
property({ reflect: true }),
|
330
|
+
required
|
331
|
+
], Textarea.prototype, "label", void 0);
|
332
|
+
__decorate([
|
333
|
+
property({ reflect: true, useDefault: true })
|
334
|
+
], Textarea.prototype, "autocapitalize", void 0);
|
335
|
+
__decorate([
|
336
|
+
property({ reflect: true, useDefault: true })
|
337
|
+
], Textarea.prototype, "autocomplete", void 0);
|
338
|
+
__decorate([
|
339
|
+
property({ reflect: true, type: Boolean })
|
340
|
+
], Textarea.prototype, "disabled", void 0);
|
341
|
+
__decorate([
|
342
|
+
property({ attribute: 'hide-label', reflect: true, type: Boolean })
|
343
|
+
], Textarea.prototype, "hideLabel", void 0);
|
344
|
+
__decorate([
|
345
|
+
property({
|
346
|
+
type: Number,
|
347
|
+
converter(value) {
|
348
|
+
return value && Number.parseInt(value, 10);
|
349
|
+
},
|
350
|
+
reflect: true,
|
351
|
+
})
|
352
|
+
], Textarea.prototype, "maxlength", void 0);
|
353
|
+
__decorate([
|
354
|
+
property({ reflect: true, useDefault: true })
|
355
|
+
], Textarea.prototype, "name", void 0);
|
356
|
+
__decorate([
|
357
|
+
property({ reflect: true, useDefault: true })
|
358
|
+
], Textarea.prototype, "orientation", void 0);
|
359
|
+
__decorate([
|
360
|
+
property({ reflect: true })
|
361
|
+
], Textarea.prototype, "placeholder", void 0);
|
362
|
+
__decorate([
|
363
|
+
property()
|
364
|
+
], Textarea.prototype, "privateSplit", void 0);
|
365
|
+
__decorate([
|
366
|
+
property({ reflect: true, type: Boolean, useDefault: true })
|
367
|
+
], Textarea.prototype, "spellcheck", void 0);
|
368
|
+
__decorate([
|
369
|
+
property({ reflect: true, type: Boolean })
|
370
|
+
], Textarea.prototype, "required", void 0);
|
371
|
+
__decorate([
|
372
|
+
property({ reflect: true, type: Boolean })
|
373
|
+
], Textarea.prototype, "readonly", void 0);
|
374
|
+
__decorate([
|
375
|
+
property({ reflect: true })
|
376
|
+
], Textarea.prototype, "tooltip", void 0);
|
377
|
+
__decorate([
|
378
|
+
property()
|
379
|
+
], Textarea.prototype, "value", void 0);
|
380
|
+
__decorate([
|
381
|
+
property({ reflect: true })
|
382
|
+
], Textarea.prototype, "version", void 0);
|
383
|
+
__decorate([
|
384
|
+
state()
|
385
|
+
], Textarea.prototype, "isBlurring", void 0);
|
386
|
+
__decorate([
|
387
|
+
state()
|
388
|
+
], Textarea.prototype, "isCheckingValidity", void 0);
|
389
|
+
__decorate([
|
390
|
+
state()
|
391
|
+
], Textarea.prototype, "isReportValidityOrSubmit", void 0);
|
392
|
+
__decorate([
|
393
|
+
state()
|
394
|
+
], Textarea.prototype, "validityMessage", void 0);
|
395
|
+
Textarea = __decorate([
|
396
|
+
customElement('glide-core-textarea'),
|
397
|
+
final
|
398
|
+
], Textarea);
|
399
|
+
export default Textarea;
|
package/dist/textarea.styles.js
CHANGED
@@ -1,6 +1,24 @@
|
|
1
|
-
import{css,unsafeCSS}
|
2
|
-
|
3
|
-
|
1
|
+
import { css, unsafeCSS } from 'lit';
|
2
|
+
import visuallyHidden from './styles/visually-hidden.js';
|
3
|
+
/*
|
4
|
+
`field-sizing` is only supported in Chrome and Edge
|
5
|
+
at the moment (https://caniuse.com/mdn-css_properties_field-sizing),
|
6
|
+
making this a progressive enhancement. This functionality is additive,
|
7
|
+
rather than required for use with our components.
|
8
|
+
|
9
|
+
`field-sizing` is also not recognized by lit-plugin, so we are seeing
|
10
|
+
https://github.com/runem/lit-analyzer/issues/157 when
|
11
|
+
attempting to use it directly in our CSS below. This use of unsafeCSS
|
12
|
+
is a workaround for that bug for the time being.
|
13
|
+
*/
|
14
|
+
const fieldSizingContent = unsafeCSS(`
|
15
|
+
field-sizing: content;
|
16
|
+
`);
|
17
|
+
export default [
|
18
|
+
css `
|
19
|
+
${visuallyHidden('.character-count .hidden')}
|
20
|
+
`,
|
21
|
+
css `
|
4
22
|
glide-core-private-label[orientation='horizontal']::part(private-tooltips) {
|
5
23
|
align-items: flex-start;
|
6
24
|
margin-block-start: var(--glide-core-spacing-base-sm);
|
@@ -107,4 +125,5 @@ import{css,unsafeCSS}from"lit";import visuallyHidden from"./styles/visually-hidd
|
|
107
125
|
font-weight: var(--glide-core-typography-weight-bold);
|
108
126
|
}
|
109
127
|
}
|
110
|
-
|
128
|
+
`,
|
129
|
+
];
|
package/dist/toast.js
CHANGED
@@ -1 +1,130 @@
|
|
1
|
-
var __decorate
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
import './icon-button.js';
|
8
|
+
import { LitElement, html } from 'lit';
|
9
|
+
import { customElement, property } from 'lit/decorators.js';
|
10
|
+
import packageJson from '../package.json' with { type: 'json' };
|
11
|
+
import Toasts from './toast.toasts.js';
|
12
|
+
import shadowRootMode from './library/shadow-root-mode.js';
|
13
|
+
import final from './library/final.js';
|
14
|
+
import required from './library/required.js';
|
15
|
+
import Link from './link.js';
|
16
|
+
import assertSlot from './library/assert-slot.js';
|
17
|
+
import uniqueId from './library/unique-id.js';
|
18
|
+
/**
|
19
|
+
* @attr {string} label
|
20
|
+
* @attr {number} [duration=5000] - Set to `Infinity` to make it persist until dismissed by the user
|
21
|
+
* @attr {'informational'|'success'|'error'} [variant='informational']
|
22
|
+
*
|
23
|
+
* @readonly
|
24
|
+
* @attr {string} [version]
|
25
|
+
*
|
26
|
+
* @slot {Link | string} - A description
|
27
|
+
*
|
28
|
+
* @fires {Event} dismiss
|
29
|
+
*
|
30
|
+
* @method dismiss
|
31
|
+
*/
|
32
|
+
let Toast = class Toast extends LitElement {
|
33
|
+
constructor() {
|
34
|
+
super(...arguments);
|
35
|
+
/**
|
36
|
+
* Set to `Infinity` to make it persist until dismissed by the user
|
37
|
+
**/
|
38
|
+
this.duration = 5000;
|
39
|
+
this.privateDismissing = false;
|
40
|
+
this.privateDismissingViaButton = false;
|
41
|
+
// `privateId` instead of `id` so consumers can specify their own `id` to
|
42
|
+
// determine, via `event.target.id`, which Toast was dismissed and then update
|
43
|
+
// whatever data structure they're using to render Toasts.
|
44
|
+
this.privateId = uniqueId();
|
45
|
+
this.privateShow = false;
|
46
|
+
this.variant = 'informational';
|
47
|
+
this.version = packageJson.version;
|
48
|
+
}
|
49
|
+
static { this.shadowRootOptions = {
|
50
|
+
...LitElement.shadowRootOptions,
|
51
|
+
mode: shadowRootMode,
|
52
|
+
}; }
|
53
|
+
dismiss() {
|
54
|
+
this.dispatchEvent(new Event('dismiss', { bubbles: true, composed: true }));
|
55
|
+
// It's a tough call whether we should remove Toast for the consumers or ask
|
56
|
+
// them should remove it themselves. It's never ideal to manipulate a consumer's
|
57
|
+
// DOM. But a stale element on the page is likely to cause confusion given some
|
58
|
+
// consumers are unlikely to remove it, whether they know they should or not.
|
59
|
+
// For those who do, removing it is an additional and clunky step.
|
60
|
+
this.remove();
|
61
|
+
}
|
62
|
+
// `firstUpdated()` instead of `connectedCallback()` so the Toast isn't shown
|
63
|
+
// before `assertSlot()` has had a chance to check the slot.
|
64
|
+
firstUpdated() {
|
65
|
+
(async () => {
|
66
|
+
// A workaround for a Glimmmer rendering quirk.
|
67
|
+
//
|
68
|
+
// When an attribute's value is dynamic, Glimmer doesn't render it immediately
|
69
|
+
// with the rest of a component's markup. Instead, it appears to schedule setting
|
70
|
+
// the attribute, delaying its render by a tick or so.
|
71
|
+
//
|
72
|
+
// In practice, this means Link receives its attributes sometime between its
|
73
|
+
// `connectedCallback()` and `firstUpdated()` lifecycle methods. So we wait
|
74
|
+
// for `firstUpdated()` via `updateComplete`. If we don't, Links will be rendered
|
75
|
+
// inside the Toasts component without their attributes.
|
76
|
+
//
|
77
|
+
// This workaround is, of course, dependent on Glimmmer not delaying attribute
|
78
|
+
// rendering past `firstUpdated()`. But it may be the best we can do. If Glimmmer
|
79
|
+
// does change how it renders dynamic attributes, it hopefully renders them sooner
|
80
|
+
// not later.
|
81
|
+
await this.querySelector('glide-core-link')?.updateComplete;
|
82
|
+
Toasts.show(this);
|
83
|
+
})();
|
84
|
+
}
|
85
|
+
render() {
|
86
|
+
// `hidden` is used to avoid a stylesheet for a single style.
|
87
|
+
return html `<slot hidden ${assertSlot([Link, Text], true)}>
|
88
|
+
<!--
|
89
|
+
A description
|
90
|
+
@type {Link | string}
|
91
|
+
-->
|
92
|
+
</slot>`;
|
93
|
+
}
|
94
|
+
};
|
95
|
+
__decorate([
|
96
|
+
property({ reflect: true }),
|
97
|
+
required
|
98
|
+
], Toast.prototype, "label", void 0);
|
99
|
+
__decorate([
|
100
|
+
property()
|
101
|
+
], Toast.prototype, "privateDescription", void 0);
|
102
|
+
__decorate([
|
103
|
+
property({ reflect: true, type: Number, useDefault: true })
|
104
|
+
], Toast.prototype, "duration", void 0);
|
105
|
+
__decorate([
|
106
|
+
property({ type: Boolean })
|
107
|
+
], Toast.prototype, "privateDismissing", void 0);
|
108
|
+
__decorate([
|
109
|
+
property({ type: Boolean })
|
110
|
+
], Toast.prototype, "privateDismissingViaButton", void 0);
|
111
|
+
__decorate([
|
112
|
+
property()
|
113
|
+
], Toast.prototype, "privateId", void 0);
|
114
|
+
__decorate([
|
115
|
+
property({ type: Boolean })
|
116
|
+
], Toast.prototype, "privateShow", void 0);
|
117
|
+
__decorate([
|
118
|
+
property({ attribute: false })
|
119
|
+
], Toast.prototype, "privateTimeoutId", void 0);
|
120
|
+
__decorate([
|
121
|
+
property({ reflect: true, useDefault: true })
|
122
|
+
], Toast.prototype, "variant", void 0);
|
123
|
+
__decorate([
|
124
|
+
property({ reflect: true })
|
125
|
+
], Toast.prototype, "version", void 0);
|
126
|
+
Toast = __decorate([
|
127
|
+
customElement('glide-core-toast'),
|
128
|
+
final
|
129
|
+
], Toast);
|
130
|
+
export default Toast;
|