@crowdstrike/glide-core 0.9.6 → 0.10.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 +17 -53
- package/dist/accordion.d.ts +10 -10
- package/dist/accordion.js +1 -1
- package/dist/accordion.stories.d.ts +0 -1
- package/dist/accordion.styles.js +36 -38
- package/dist/accordion.test.basics.js +13 -95
- package/dist/accordion.test.events.js +21 -33
- package/dist/accordion.test.focus.d.ts +1 -0
- package/dist/accordion.test.focus.js +11 -0
- package/dist/accordion.test.interactions.d.ts +1 -0
- package/dist/accordion.test.interactions.js +75 -0
- package/dist/button-group.button.d.ts +2 -4
- package/dist/button-group.button.js +1 -1
- package/dist/button-group.button.styles.js +6 -14
- package/dist/button-group.button.test.basics.js +8 -17
- package/dist/button-group.button.test.interactions.js +4 -4
- package/dist/button-group.d.ts +0 -2
- package/dist/button-group.test.basics.js +10 -10
- package/dist/button-group.test.events.js +2 -2
- package/dist/button-group.test.interactions.js +1 -1
- package/dist/button.d.ts +7 -10
- package/dist/button.js +1 -1
- package/dist/button.styles.js +4 -7
- package/dist/button.test.basics.js +10 -26
- package/dist/button.test.events.js +9 -9
- package/dist/checkbox-group.d.ts +3 -4
- package/dist/checkbox-group.js +1 -1
- package/dist/checkbox-group.styles.js +13 -1
- package/dist/checkbox-group.test.basics.js +8 -12
- package/dist/checkbox-group.test.focus.js +7 -7
- package/dist/checkbox-group.test.interactions.d.ts +1 -0
- package/dist/checkbox-group.test.interactions.js +82 -0
- package/dist/checkbox.d.ts +5 -4
- package/dist/checkbox.js +1 -1
- package/dist/checkbox.styles.js +35 -15
- package/dist/checkbox.test.basics.js +6 -15
- package/dist/checkbox.test.focus.js +4 -2
- package/dist/checkbox.test.interactions.js +11 -11
- package/dist/drawer.d.ts +2 -5
- package/dist/drawer.js +1 -1
- package/dist/drawer.test.accessibility.js +8 -8
- package/dist/drawer.test.basics.js +16 -16
- package/dist/drawer.test.closing.js +18 -16
- package/dist/drawer.test.events.js +13 -24
- package/dist/drawer.test.methods.js +22 -22
- package/dist/dropdown.d.ts +7 -5
- package/dist/dropdown.js +1 -1
- package/dist/dropdown.option.d.ts +1 -3
- package/dist/dropdown.option.js +1 -1
- package/dist/dropdown.option.styles.js +31 -19
- package/dist/dropdown.option.test.basics.js +4 -4
- package/dist/dropdown.styles.js +39 -3
- package/dist/dropdown.test.basics.js +8 -13
- package/dist/dropdown.test.basics.multiple.js +63 -31
- package/dist/dropdown.test.basics.single.js +49 -0
- package/dist/dropdown.test.focus.filterable.js +12 -3
- package/dist/dropdown.test.focus.js +18 -2
- package/dist/dropdown.test.interactions.filterable.js +121 -45
- package/dist/dropdown.test.interactions.multiple.js +71 -30
- package/dist/dropdown.test.interactions.single.js +26 -4
- package/dist/form-controls-layout.d.ts +0 -2
- package/dist/icon-button.d.ts +2 -4
- package/dist/icon-button.js +1 -1
- package/dist/icon-button.test.basics.js +14 -82
- package/dist/icon-button.test.focus.d.ts +1 -0
- package/dist/icon-button.test.focus.js +13 -0
- package/dist/input.d.ts +4 -5
- package/dist/input.js +1 -1
- package/dist/input.styles.js +4 -4
- package/dist/input.test.basics.js +0 -52
- package/dist/input.test.events.js +27 -27
- package/dist/input.test.focus.js +27 -26
- package/dist/input.test.form.js +6 -6
- package/dist/input.test.validity.js +130 -130
- package/dist/label.d.ts +1 -3
- package/dist/label.js +1 -1
- package/dist/label.styles.js +5 -6
- package/dist/label.test.basics.js +4 -4
- package/dist/library/ow.js +1 -1
- package/dist/menu.button.d.ts +0 -2
- package/dist/menu.button.test.basics.js +3 -3
- package/dist/menu.d.ts +1 -4
- package/dist/menu.js +1 -1
- package/dist/menu.link.d.ts +1 -2
- package/dist/menu.link.js +1 -1
- package/dist/menu.options.d.ts +0 -2
- package/dist/menu.test.events.js +6 -6
- package/dist/menu.test.focus.js +5 -18
- package/dist/menu.test.interactions.js +48 -24
- package/dist/modal.d.ts +6 -17
- package/dist/modal.icon-button.d.ts +0 -2
- package/dist/modal.icon-button.test.basics.js +3 -3
- package/dist/modal.js +1 -1
- package/dist/modal.styles.js +13 -19
- package/dist/modal.tertiary-icon.d.ts +0 -3
- package/dist/modal.tertiary-icon.test.basics.js +3 -3
- package/dist/modal.test.basics.js +9 -5
- package/dist/modal.test.close.js +2 -2
- package/dist/modal.test.events.js +2 -2
- package/dist/radio-group.d.ts +0 -3
- package/dist/radio-group.js +1 -1
- package/dist/radio-group.test.basics.js +61 -61
- package/dist/radio-group.test.events.js +13 -13
- package/dist/radio-group.test.focus.js +1 -1
- package/dist/radio-group.test.form.js +2 -2
- package/dist/radio-group.test.validity.js +12 -12
- package/dist/radio.d.ts +0 -3
- package/dist/radio.styles.js +4 -12
- package/dist/split-button.d.ts +8 -11
- package/dist/split-button.js +1 -1
- package/dist/split-button.primary-button.d.ts +21 -0
- package/dist/split-button.primary-button.js +1 -0
- package/dist/split-button.primary-button.styles.js +96 -0
- package/dist/split-button.primary-button.test.basics.d.ts +1 -0
- package/dist/split-button.primary-button.test.basics.js +31 -0
- package/dist/split-button.primary-button.test.focus.d.ts +1 -0
- package/dist/split-button.primary-button.test.focus.js +14 -0
- package/dist/split-button.primary-link.d.ts +19 -0
- package/dist/split-button.primary-link.js +1 -0
- package/dist/split-button.primary-link.test.basics.d.ts +1 -0
- package/dist/split-button.primary-link.test.basics.js +30 -0
- package/dist/split-button.primary-link.test.focus.d.ts +1 -0
- package/dist/split-button.primary-link.test.focus.js +15 -0
- package/dist/split-button.secondary-button.d.ts +25 -0
- package/dist/split-button.secondary-button.js +1 -0
- package/dist/split-button.secondary-button.styles.js +103 -0
- package/dist/split-button.secondary-button.test.basics.d.ts +1 -0
- package/dist/split-button.secondary-button.test.basics.js +58 -0
- package/dist/split-button.secondary-button.test.focus.d.ts +1 -0
- package/dist/split-button.secondary-button.test.focus.js +14 -0
- package/dist/split-button.secondary-button.test.interactions.d.ts +2 -0
- package/dist/split-button.secondary-button.test.interactions.js +30 -0
- package/dist/split-button.stories.d.ts +4 -3
- package/dist/split-button.styles.js +1 -94
- package/dist/split-button.test.basics.d.ts +2 -1
- package/dist/split-button.test.basics.js +67 -80
- package/dist/split-button.test.interactions.d.ts +4 -0
- package/dist/split-button.test.interactions.js +51 -0
- package/dist/styles/opacity-and-scale-animation.js +2 -6
- package/dist/styles/variables.css +1 -1
- package/dist/tab.d.ts +2 -11
- package/dist/tab.group.d.ts +2 -5
- package/dist/tab.group.styles.js +12 -15
- package/dist/tab.group.test.basics.js +49 -34
- package/dist/tab.group.test.interactions.js +17 -14
- package/dist/tab.panel.d.ts +0 -3
- package/dist/tab.test.basics.js +6 -5
- package/dist/tag.d.ts +6 -4
- package/dist/tag.js +1 -1
- package/dist/tag.styles.js +36 -36
- package/dist/tag.test.basics.js +16 -109
- package/dist/tag.test.events.js +12 -8
- package/dist/tag.test.focus.js +2 -3
- package/dist/tag.test.interactions.d.ts +1 -0
- package/dist/tag.test.interactions.js +34 -0
- package/dist/textarea.d.ts +2 -3
- package/dist/textarea.js +2 -2
- package/dist/textarea.test.basics.js +8 -8
- package/dist/textarea.test.events.js +55 -55
- package/dist/textarea.test.form.js +9 -9
- package/dist/textarea.test.validity.js +167 -135
- package/dist/toasts.d.ts +1 -5
- package/dist/toasts.test.basics.js +2 -1
- package/dist/toasts.toast.d.ts +1 -4
- package/dist/toasts.toast.js +1 -1
- package/dist/toasts.toast.styles.js +12 -0
- package/dist/toggle.d.ts +0 -2
- package/dist/toggle.styles.js +1 -5
- package/dist/toggle.test.basics.js +2 -2
- package/dist/toggle.test.interactions.js +7 -7
- package/dist/tooltip.d.ts +2 -1
- package/dist/tooltip.js +1 -1
- package/dist/tooltip.styles.js +36 -13
- package/dist/tooltip.test.basics.d.ts +1 -1
- package/dist/tooltip.test.basics.js +19 -19
- package/dist/tree.d.ts +0 -2
- package/dist/tree.item.d.ts +5 -7
- package/dist/tree.item.icon-button.d.ts +1 -4
- package/dist/tree.item.js +1 -1
- package/dist/tree.item.menu.d.ts +0 -2
- package/dist/tree.item.menu.test.basics.js +9 -9
- package/dist/tree.item.styles.js +4 -3
- package/dist/tree.item.test.basics.js +43 -31
- package/dist/tree.test.basics.js +29 -29
- package/dist/tree.test.focus.js +77 -74
- package/package.json +12 -14
- package/dist/split-container.d.ts +0 -31
- package/dist/split-container.js +0 -1
- package/dist/split-container.styles.js +0 -132
- package/dist/split-container.test.basics.d.ts +0 -3
- package/dist/split-container.test.basics.js +0 -445
- package/dist/split-container.test.interactions.d.ts +0 -1
- package/dist/split-container.test.interactions.js +0 -20
- package/dist/split-link.d.ts +0 -25
- package/dist/split-link.js +0 -1
- package/dist/split-link.test.basics.d.ts +0 -1
- package/dist/split-link.test.basics.js +0 -93
- package/dist/split-link.test.interactions.d.ts +0 -1
- package/dist/split-link.test.interactions.js +0 -20
- package/dist/status-indicator.d.ts +0 -30
- package/dist/status-indicator.js +0 -1
- package/dist/status-indicator.stories.d.ts +0 -5
- package/dist/status-indicator.styles.js +0 -58
- package/dist/status-indicator.test.basics.d.ts +0 -1
- package/dist/status-indicator.test.basics.js +0 -102
- /package/dist/{split-container.styles.d.ts → split-button.primary-button.styles.d.ts} +0 -0
- /package/dist/{status-indicator.styles.d.ts → split-button.secondary-button.styles.d.ts} +0 -0
@@ -2,6 +2,7 @@
|
|
2
2
|
import './tab.group.js';
|
3
3
|
import './tab.js';
|
4
4
|
import './tab.panel.js';
|
5
|
+
import { emulateMedia } from '@web/test-runner-commands';
|
5
6
|
import { expect, fixture, html, waitUntil } from '@open-wc/testing';
|
6
7
|
import { sendKeys } from '@web/test-runner-commands';
|
7
8
|
import GlideCoreTabGroup from './tab.group.js';
|
@@ -129,6 +130,7 @@ it('renders a disabled end-overflow button when there is only overflow at the st
|
|
129
130
|
expect(startOverflowButton?.disabled).to.be.false;
|
130
131
|
});
|
131
132
|
it('scrolls tabs when overflow buttons are clicked', async () => {
|
133
|
+
await emulateMedia({ reducedMotion: 'reduce' });
|
132
134
|
const spy = sinon.spy();
|
133
135
|
const component = await fixture(html `
|
134
136
|
<div style="width:23rem">
|
@@ -170,6 +172,7 @@ it('scrolls tabs when overflow buttons are clicked', async () => {
|
|
170
172
|
expect(spy.callCount).to.equal(1);
|
171
173
|
expect(startOverflowButton?.disabled).to.be.true;
|
172
174
|
expect(endOverflowButton?.disabled).to.be.false;
|
175
|
+
await emulateMedia({ reducedMotion: 'no-preference' });
|
173
176
|
});
|
174
177
|
it('removes overflow buttons when the component is resized and there is no overflow', async () => {
|
175
178
|
const component = await fixture(html `
|
@@ -234,7 +237,7 @@ it('renders overflow buttons when the component is resized and there is overflow
|
|
234
237
|
tabGroup?.shadowRoot?.querySelector('[data-test="overflow-end-button"]') !== null);
|
235
238
|
});
|
236
239
|
it('has only one active tab that is tabbable after pressing the Enter key', async () => {
|
237
|
-
const
|
240
|
+
const component = await fixture(html `
|
238
241
|
<glide-core-tab-group>
|
239
242
|
<glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
|
240
243
|
<glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
|
@@ -247,7 +250,7 @@ it('has only one active tab that is tabbable after pressing the Enter key', asyn
|
|
247
250
|
<glide-core-tab-panel name="4">Content for Tab 4</glide-core-tab-panel>
|
248
251
|
</glide-core-tab-group>
|
249
252
|
`);
|
250
|
-
const [firstTab, secondTab, thirdTab, fourthTab] =
|
253
|
+
const [firstTab, secondTab, thirdTab, fourthTab] = component.tabElements;
|
251
254
|
expect(firstTab.active).to.be.true;
|
252
255
|
expect(secondTab.active).to.be.false;
|
253
256
|
expect(thirdTab.active).to.be.false;
|
@@ -299,7 +302,7 @@ it('has only one active tab that is tabbable after pressing the Enter key', asyn
|
|
299
302
|
expect(fourthTab.tabIndex).to.equal(-1);
|
300
303
|
});
|
301
304
|
it('has only one active tab that is tabbable when clicked', async () => {
|
302
|
-
const
|
305
|
+
const component = await fixture(html `
|
303
306
|
<glide-core-tab-group>
|
304
307
|
<glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
|
305
308
|
<glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
|
@@ -310,7 +313,7 @@ it('has only one active tab that is tabbable when clicked', async () => {
|
|
310
313
|
<glide-core-tab-panel name="3">Content for Tab 3</glide-core-tab-panel>
|
311
314
|
</glide-core-tab-group>
|
312
315
|
`);
|
313
|
-
const [firstTab, secondTab, thirdTab] =
|
316
|
+
const [firstTab, secondTab, thirdTab] = component.tabElements;
|
314
317
|
expect(firstTab.active).to.be.true;
|
315
318
|
expect(secondTab.active).to.be.false;
|
316
319
|
expect(thirdTab.active).to.be.false;
|
@@ -333,7 +336,7 @@ it('has only one active tab that is tabbable when clicked', async () => {
|
|
333
336
|
expect(thirdTab.tabIndex).to.equal(0);
|
334
337
|
});
|
335
338
|
it('has only one tab panel that is active and tabbable when a tab is clicked', async () => {
|
336
|
-
const
|
339
|
+
const component = await fixture(html `
|
337
340
|
<glide-core-tab-group>
|
338
341
|
<glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
|
339
342
|
<glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
|
@@ -342,8 +345,8 @@ it('has only one tab panel that is active and tabbable when a tab is clicked', a
|
|
342
345
|
<glide-core-tab-panel name="2">Content for Tab 2</glide-core-tab-panel>
|
343
346
|
</glide-core-tab-group>
|
344
347
|
`);
|
345
|
-
const [, secondTab] =
|
346
|
-
const [firstPanel, secondPanel] =
|
348
|
+
const [, secondTab] = component.tabElements;
|
349
|
+
const [firstPanel, secondPanel] = component.panelElements;
|
347
350
|
expect(firstPanel.isActive).to.be.true;
|
348
351
|
expect(secondPanel.isActive).to.be.false;
|
349
352
|
expect(firstPanel.tabIndex).to.equal(0);
|
@@ -355,7 +358,7 @@ it('has only one tab panel that is active and tabbable when a tab is clicked', a
|
|
355
358
|
expect(secondPanel.tabIndex).to.equal(0);
|
356
359
|
});
|
357
360
|
it('has only one tab panel that is active and tabbable when using the keyboard to make selections', async () => {
|
358
|
-
const
|
361
|
+
const component = await fixture(html `
|
359
362
|
<glide-core-tab-group>
|
360
363
|
<glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
|
361
364
|
<glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
|
@@ -364,8 +367,8 @@ it('has only one tab panel that is active and tabbable when using the keyboard t
|
|
364
367
|
<glide-core-tab-panel name="2">Content for Tab 2</glide-core-tab-panel>
|
365
368
|
</glide-core-tab-group>
|
366
369
|
`);
|
367
|
-
const [firstTab] =
|
368
|
-
const [firstPanel, secondPanel] =
|
370
|
+
const [firstTab] = component.tabElements;
|
371
|
+
const [firstPanel, secondPanel] = component.panelElements;
|
369
372
|
expect(firstPanel.isActive).to.be.true;
|
370
373
|
expect(secondPanel.isActive).to.be.false;
|
371
374
|
expect(firstPanel.tabIndex).to.equal(0);
|
@@ -379,7 +382,7 @@ it('has only one tab panel that is active and tabbable when using the keyboard t
|
|
379
382
|
expect(secondPanel.tabIndex).to.equal(0);
|
380
383
|
});
|
381
384
|
it('sets the last keyboard focused tab as tabbable ', async () => {
|
382
|
-
const
|
385
|
+
const component = await fixture(html `
|
383
386
|
<glide-core-tab-group>
|
384
387
|
<glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
|
385
388
|
<glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
|
@@ -388,7 +391,7 @@ it('sets the last keyboard focused tab as tabbable ', async () => {
|
|
388
391
|
<glide-core-tab-panel name="2">Content for Tab 2</glide-core-tab-panel>
|
389
392
|
</glide-core-tab-group>
|
390
393
|
`);
|
391
|
-
const [firstTab, secondTab] =
|
394
|
+
const [firstTab, secondTab] = component.tabElements;
|
392
395
|
expect(firstTab.active).to.be.true;
|
393
396
|
expect(secondTab.active).to.be.false;
|
394
397
|
expect(firstTab.tabIndex).to.equal(0);
|
@@ -403,7 +406,7 @@ it('sets the last keyboard focused tab as tabbable ', async () => {
|
|
403
406
|
it('sets the active tab as tabbable on tab blur', async () => {
|
404
407
|
// This behavior is to ensure that the last active tab is the first tabbable
|
405
408
|
// element in the component.
|
406
|
-
const
|
409
|
+
const component = await fixture(html `
|
407
410
|
<glide-core-tab-group>
|
408
411
|
<glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
|
409
412
|
<glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
|
@@ -412,7 +415,7 @@ it('sets the active tab as tabbable on tab blur', async () => {
|
|
412
415
|
<glide-core-tab-panel name="2">Content for Tab 2</glide-core-tab-panel>
|
413
416
|
</glide-core-tab-group>
|
414
417
|
`);
|
415
|
-
const [firstTab, secondTab] =
|
418
|
+
const [firstTab, secondTab] = component.tabElements;
|
416
419
|
expect(firstTab.active).to.be.true;
|
417
420
|
expect(secondTab.active).to.be.false;
|
418
421
|
expect(firstTab.tabIndex).to.equal(0);
|
package/dist/tab.panel.d.ts
CHANGED
package/dist/tab.test.basics.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
1
2
|
import './tab.js';
|
2
3
|
import { expect, fixture, html } from '@open-wc/testing';
|
3
4
|
import GlideCoreTab from './tab.js';
|
@@ -10,8 +11,8 @@ it('renders correct markup and sets correct attributes for the default case', as
|
|
10
11
|
<glide-core-tab>Tab</glide-core-tab>
|
11
12
|
`);
|
12
13
|
await expect(component).to.not.be.accessible();
|
13
|
-
expect(component.active).to.
|
14
|
-
expect(component.disabled).to.
|
14
|
+
expect(component.active).to.be.false;
|
15
|
+
expect(component.disabled).to.be.false;
|
15
16
|
expect(component.getAttribute('aria-disabled')).to.equal(null, 'does not set aria-disabled');
|
16
17
|
expect([...component.shadowRoot.firstElementChild.classList]).to.deep.equal(['component']);
|
17
18
|
});
|
@@ -25,14 +26,14 @@ it('sets the active attribute', async () => {
|
|
25
26
|
const component = await fixture(html `
|
26
27
|
<glide-core-tab active>Tab</glide-core-tab>
|
27
28
|
`);
|
28
|
-
expect(component.active).to.
|
29
|
+
expect(component.active).to.be.true;
|
29
30
|
});
|
30
31
|
it('sets the disabled attribute', async () => {
|
31
32
|
const component = await fixture(html `
|
32
33
|
<glide-core-tab disabled>Tab</glide-core-tab>
|
33
34
|
`);
|
34
|
-
expect(component.disabled).to.
|
35
|
-
expect(component
|
35
|
+
expect(component.disabled).to.be.true;
|
36
|
+
expect(component?.getAttribute('aria-disabled')).to.equal('true');
|
36
37
|
});
|
37
38
|
it('renders the icon slot', async () => {
|
38
39
|
const component = await fixture(html `
|
package/dist/tag.d.ts
CHANGED
@@ -5,18 +5,20 @@ declare global {
|
|
5
5
|
}
|
6
6
|
}
|
7
7
|
/**
|
8
|
-
* @event remove -
|
8
|
+
* @event remove - `(event: Event) => void`
|
9
9
|
*
|
10
|
-
* @slot
|
11
|
-
* @slot prefix - A slot for an optional icon.
|
10
|
+
* @slot icon
|
12
11
|
*/
|
13
12
|
export default class GlideCoreTag extends LitElement {
|
14
13
|
#private;
|
15
14
|
static shadowRootOptions: ShadowRootInit;
|
16
15
|
static styles: import("lit").CSSResult[];
|
16
|
+
label?: string;
|
17
|
+
removable: boolean;
|
17
18
|
size: 'small' | 'medium' | 'large';
|
18
|
-
removableLabel?: string | undefined;
|
19
19
|
click(): void;
|
20
20
|
firstUpdated(): void;
|
21
21
|
render(): import("lit").TemplateResult<1>;
|
22
|
+
get textContent(): string;
|
23
|
+
set textContent(label: string);
|
22
24
|
}
|
package/dist/tag.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,o,l){var i,r=arguments.length,s=r<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,o):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,l);else for(var
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,l){var i,r=arguments.length,s=r<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,o):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,l);else for(var n=e.length-1;n>=0;n--)(i=e[n])&&(s=(r<3?i(s):r>3?i(t,o,s):i(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s};import{LitElement,html}from"lit";import{LocalizeController}from"./library/localize.js";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property}from"lit/decorators.js";import{when}from"lit/directives/when.js";import styles from"./tag.styles.js";let GlideCoreTag=class GlideCoreTag extends LitElement{constructor(){super(...arguments),this.removable=!1,this.size="medium",this.#e=createRef(),this.#t=createRef(),this.#o=createRef(),this.#l=new LocalizeController(this),this.#i=()=>{setTimeout((()=>{this.remove()}),200),this.#t.value?.classList.add("removed"),this.dispatchEvent(new Event("remove",{bubbles:!0}))}}static{this.shadowRootOptions={...LitElement.shadowRootOptions,delegatesFocus:!0,mode:"closed"}}static{this.styles=styles}click(){this.#e.value?.click()}firstUpdated(){this.#t.value?.addEventListener("animationend",(()=>{this.#t.value?.classList.remove("added")}),{once:!0})}render(){return html`<div class="${classMap({component:!0,added:!0,[this.size]:!0})}" data-test="component" ${ref(this.#t)}><slot class="${classMap({"icon-slot":!0,[this.size]:!0})}" name="icon" ${ref(this.#o)}></slot>${this.label} ${when(this.removable,(()=>html`<button aria-label="${this.#l.term("removeTag",this.label)}" class="${classMap({[this.size]:!0})}" data-test="button" type="button" @click="${this.#i}" ${ref(this.#e)}><svg width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M6 6L18 18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M18 6L6 18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>`))}</div>`}get textContent(){return this.label??""}set textContent(e){this.label=e}#e;#t;#o;#l;#i};__decorate([property({reflect:!0})],GlideCoreTag.prototype,"label",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreTag.prototype,"removable",void 0),__decorate([property({reflect:!0})],GlideCoreTag.prototype,"size",void 0),GlideCoreTag=__decorate([customElement("glide-core-tag")],GlideCoreTag);export default GlideCoreTag;
|
package/dist/tag.styles.js
CHANGED
@@ -6,7 +6,7 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
6
6
|
background: var(--glide-core-surface-base);
|
7
7
|
border-radius: var(--glide-core-border-radius-round);
|
8
8
|
color: var(--glide-core-text-body-1);
|
9
|
-
display:
|
9
|
+
display: flex;
|
10
10
|
font-family: var(--glide-core-body-xs-font-family);
|
11
11
|
font-size: var(--glide-core-body-xs-font-size);
|
12
12
|
font-style: var(--glide-core-body-xs-font-variant);
|
@@ -14,6 +14,7 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
14
14
|
justify-content: center;
|
15
15
|
line-height: 1;
|
16
16
|
margin: 0;
|
17
|
+
max-inline-size: max-content;
|
17
18
|
min-block-size: var(--glide-core-spacing-md);
|
18
19
|
opacity: 1;
|
19
20
|
overflow: hidden;
|
@@ -30,47 +31,14 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
30
31
|
padding: 0 var(--glide-core-spacing-xs);
|
31
32
|
}
|
32
33
|
|
33
|
-
&.
|
34
|
+
&.added {
|
34
35
|
animation: fade-in 100ms ease-in-out;
|
35
36
|
}
|
36
37
|
|
37
|
-
&.
|
38
|
+
&.removed {
|
38
39
|
animation: fade-out 200ms ease-in-out;
|
39
40
|
animation-fill-mode: forwards;
|
40
41
|
}
|
41
|
-
|
42
|
-
& ::slotted([slot='prefix']) {
|
43
|
-
--size: var(--glide-core-spacing-sm);
|
44
|
-
|
45
|
-
align-items: center;
|
46
|
-
block-size: var(--glide-core-spacing-sm);
|
47
|
-
display: flex;
|
48
|
-
inline-size: var(--glide-core-spacing-sm);
|
49
|
-
justify-content: center;
|
50
|
-
margin-inline-end: 0.375rem;
|
51
|
-
}
|
52
|
-
|
53
|
-
&.small ::slotted([slot='prefix']) {
|
54
|
-
--size: 0.625rem;
|
55
|
-
|
56
|
-
align-items: center;
|
57
|
-
block-size: 0.625rem;
|
58
|
-
display: flex;
|
59
|
-
inline-size: 0.625rem;
|
60
|
-
justify-content: center;
|
61
|
-
margin-inline-end: var(--glide-core-spacing-xxs);
|
62
|
-
}
|
63
|
-
|
64
|
-
&.large ::slotted([slot='prefix']) {
|
65
|
-
--size: 0.875rem;
|
66
|
-
|
67
|
-
align-items: center;
|
68
|
-
block-size: 0.875rem;
|
69
|
-
display: flex;
|
70
|
-
inline-size: 0.875rem;
|
71
|
-
justify-content: center;
|
72
|
-
margin-inline-end: var(--glide-core-spacing-xs);
|
73
|
-
}
|
74
42
|
}
|
75
43
|
|
76
44
|
@keyframes fade-in {
|
@@ -129,4 +97,36 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
129
97
|
outline: none;
|
130
98
|
}
|
131
99
|
}
|
100
|
+
|
101
|
+
.icon-slot {
|
102
|
+
&.large {
|
103
|
+
&::slotted(*) {
|
104
|
+
block-size: 0.875rem;
|
105
|
+
inline-size: 0.875rem;
|
106
|
+
margin-inline-end: var(--glide-core-spacing-xs);
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
&.medium {
|
111
|
+
&::slotted(*) {
|
112
|
+
block-size: 0.75rem;
|
113
|
+
inline-size: 0.75rem;
|
114
|
+
margin-inline-end: 0.375rem;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
&.small {
|
119
|
+
&::slotted(*) {
|
120
|
+
block-size: 0.625rem;
|
121
|
+
inline-size: 0.625rem;
|
122
|
+
margin-inline-end: var(--glide-core-spacing-xxs);
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
&::slotted(*) {
|
127
|
+
align-items: center;
|
128
|
+
display: flex;
|
129
|
+
justify-content: center;
|
130
|
+
}
|
131
|
+
}
|
132
132
|
`];
|
package/dist/tag.test.basics.js
CHANGED
@@ -1,120 +1,27 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
2
|
-
import {
|
3
|
-
import { aTimeout, expect, fixture, html } from '@open-wc/testing';
|
2
|
+
import { aTimeout, elementUpdated, expect, fixture, html, } from '@open-wc/testing';
|
4
3
|
import GlideCoreTag from './tag.js';
|
5
|
-
import sinon from 'sinon';
|
6
4
|
GlideCoreTag.shadowRootOptions.mode = 'open';
|
7
5
|
it('registers', async () => {
|
8
6
|
expect(window.customElements.get('glide-core-tag')).to.equal(GlideCoreTag);
|
9
7
|
});
|
10
8
|
it('is accessible', async () => {
|
11
|
-
const component = await fixture(html `<glide-core-tag
|
12
|
-
// Wait for the animation to complete
|
13
|
-
await aTimeout(
|
9
|
+
const component = await fixture(html `<glide-core-tag label="Label"></glide-core-tag>`);
|
10
|
+
// Wait for the animation to complete.
|
11
|
+
await aTimeout(100);
|
12
|
+
await expect(component).to.be.accessible();
|
13
|
+
component.removable = true;
|
14
|
+
await elementUpdated(component);
|
14
15
|
await expect(component).to.be.accessible();
|
15
16
|
});
|
16
|
-
it('
|
17
|
-
const component = await fixture(html `<glide-core-tag
|
18
|
-
expect(component).to.be.
|
19
|
-
|
20
|
-
expect(container).to.be.not.null;
|
21
|
-
const contentRendered = component.querySelector('[data-content]');
|
22
|
-
expect(contentRendered).to.be.not.null;
|
23
|
-
expect(contentRendered?.textContent).to.be.equal('Tag');
|
24
|
-
});
|
25
|
-
it('does not render an icon button when "removable-label" attribute is not set', async () => {
|
26
|
-
const component = await fixture(html `<glide-core-tag><span data-content>Tag</span></glide-core-tag>`);
|
27
|
-
expect(component).to.not.have.attribute('removable-label');
|
28
|
-
const iconButton = component.shadowRoot?.querySelector('[data-test="button"]');
|
29
|
-
expect(iconButton).to.be.null;
|
30
|
-
});
|
31
|
-
it('renders an icon button with aria-label when "removable-label" attribute is set', async () => {
|
32
|
-
const component = await fixture(html `<glide-core-tag removable-label="test-aria-label"
|
33
|
-
><span slot="prefix">Prefix</span
|
34
|
-
><span data-content>Tag</span></glide-core-tag
|
35
|
-
>`);
|
36
|
-
expect(component).to.be.not.null;
|
37
|
-
expect(component).to.have.attribute('removable-label', 'test-aria-label');
|
38
|
-
const iconButton = component.shadowRoot?.querySelector('[data-test="button"]');
|
39
|
-
expect(iconButton).to.be.not.null;
|
40
|
-
expect(iconButton).to.have.attribute('aria-label', `Remove tag: test-aria-label`);
|
41
|
-
expect(iconButton).to.have.attribute('type', 'button');
|
42
|
-
});
|
43
|
-
it('renders the "prefix" slot and its content', async () => {
|
44
|
-
const component = await fixture(html `<glide-core-tag
|
45
|
-
><span slot="prefix" data-prefix>test-prefix</span>Tag</glide-core-tag
|
46
|
-
>`);
|
47
|
-
const prefixSlot = component.shadowRoot?.querySelector('slot[name="prefix"]');
|
48
|
-
expect(prefixSlot?.assignedNodes()?.length).to.be.equal(1);
|
49
|
-
expect(document.querySelector('[data-prefix]')).to.be.not.null;
|
50
|
-
expect(document.querySelector('[data-prefix]')?.textContent).to.be.equal('test-prefix');
|
51
|
-
});
|
52
|
-
it('renders correctly when the "size" attribute is set to "small"', async () => {
|
53
|
-
const component = await fixture(html `<glide-core-tag removable-label="test-aria-label" size="small"
|
54
|
-
><span slot="prefix">Prefix</span
|
55
|
-
><span data-content>Tag</span></glide-core-tag
|
56
|
-
>`);
|
57
|
-
const container = component.shadowRoot?.querySelector('[data-test="component"]');
|
58
|
-
const iconButton = component.shadowRoot?.querySelector('[data-test="button"]');
|
59
|
-
expect(container).to.have.class('small');
|
60
|
-
expect(iconButton).to.have.class('small');
|
61
|
-
});
|
62
|
-
it('renders correctly when the "size" attribute is set to "large"', async () => {
|
63
|
-
const component = await fixture(html `<glide-core-tag removable-label="test-aria-label" size="large"
|
64
|
-
><span slot="prefix">Prefix</span
|
65
|
-
><span data-content>Tag</span></glide-core-tag
|
66
|
-
>`);
|
67
|
-
const container = component.shadowRoot?.querySelector('[data-test="component"]');
|
68
|
-
const iconButton = component.shadowRoot?.querySelector('[data-test="button"]');
|
69
|
-
expect(container).to.have.class('large');
|
70
|
-
expect(iconButton).to.have.class('large');
|
71
|
-
});
|
72
|
-
it('throws an error when the default slot is empty', async () => {
|
73
|
-
const spy = sinon.spy();
|
74
|
-
try {
|
75
|
-
await fixture(html `<glide-core-tag></glide-core-tag>`);
|
76
|
-
}
|
77
|
-
catch (error) {
|
78
|
-
if (error instanceof ArgumentError) {
|
79
|
-
spy();
|
80
|
-
}
|
81
|
-
}
|
82
|
-
expect(spy.callCount).to.equal(1);
|
83
|
-
});
|
84
|
-
it('does not throw an error when the default slot is non-empty', async () => {
|
85
|
-
const spy = sinon.spy();
|
86
|
-
try {
|
87
|
-
await fixture(html `<glide-core-tag>Tag</glide-core-tag>`);
|
88
|
-
}
|
89
|
-
catch (error) {
|
90
|
-
if (error instanceof ArgumentError) {
|
91
|
-
spy();
|
92
|
-
}
|
93
|
-
}
|
94
|
-
expect(spy.callCount).to.equal(0);
|
95
|
-
});
|
96
|
-
it('toggles the "activate" and "deactivate" clases when the button is clicked', async () => {
|
97
|
-
const component = await fixture(html `<glide-core-tag removable-label="test-aria-label"
|
98
|
-
><span slot="prefix">Prefix</span>Tag</glide-core-tag
|
99
|
-
>`);
|
100
|
-
const container = component.shadowRoot?.querySelector('[data-test="component"]');
|
101
|
-
const iconButton = component.shadowRoot?.querySelector('[data-test="button"]');
|
102
|
-
expect(container).to.have.class('activate');
|
103
|
-
iconButton?.click();
|
104
|
-
expect(container).to.have.class('deactivate');
|
17
|
+
it('has defaults', async () => {
|
18
|
+
const component = await fixture(html `<glide-core-tag label="Label"></glide-core-tag>`);
|
19
|
+
expect(component.removable).to.be.false;
|
20
|
+
expect(component.size).to.equal('medium');
|
105
21
|
});
|
106
|
-
it('
|
107
|
-
const component = await fixture(html `<glide-core-tag
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
expect(component.shadowRoot?.querySelector('[data-test="component"]')).to.be
|
112
|
-
.not.null;
|
113
|
-
expect(document.querySelector('[data-content]')).to.be.not.null;
|
114
|
-
component?.click();
|
115
|
-
// Wait for the animation to complete
|
116
|
-
await aTimeout(300);
|
117
|
-
// the tag and its contents should be removed
|
118
|
-
expect(document.querySelector('glide-core-tag')).to.be.null;
|
119
|
-
expect(document.querySelector('[data-content]')).to.be.null;
|
22
|
+
it('can be removed', async () => {
|
23
|
+
const component = await fixture(html `<glide-core-tag label="Label" removable></glide-core-tag>`);
|
24
|
+
const button = component.shadowRoot?.querySelector('[data-test="button"]');
|
25
|
+
expect(button?.checkVisibility()).to.be.true;
|
26
|
+
expect(button?.getAttribute('aria-label')).to.equal('Remove tag: Label');
|
120
27
|
});
|
package/dist/tag.test.events.js
CHANGED
@@ -1,16 +1,20 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
1
2
|
import './tag.js';
|
2
3
|
import { expect, fixture, html, oneEvent } from '@open-wc/testing';
|
3
4
|
import GlideCoreTag from './tag.js';
|
5
|
+
import sinon from 'sinon';
|
4
6
|
GlideCoreTag.shadowRootOptions.mode = 'open';
|
5
|
-
it('dispatches
|
6
|
-
const component = await fixture(html `<glide-core-tag
|
7
|
-
|
8
|
-
|
9
|
-
>`);
|
10
|
-
const iconButton = component.shadowRoot?.querySelector('[data-test="button"]');
|
7
|
+
it('dispatches one "remove" event', async () => {
|
8
|
+
const component = await fixture(html `<glide-core-tag label="Label" removable></glide-core-tag>`);
|
9
|
+
const spy = sinon.spy();
|
10
|
+
component.addEventListener('remove', spy);
|
11
11
|
setTimeout(() => {
|
12
|
-
|
12
|
+
component.shadowRoot
|
13
|
+
?.querySelector('[data-test="button"]')
|
14
|
+
?.click();
|
13
15
|
});
|
14
16
|
const event = await oneEvent(component, 'remove');
|
15
|
-
expect(event
|
17
|
+
expect(event instanceof Event).to.be.true;
|
18
|
+
expect(event.bubbles).to.be.true;
|
19
|
+
expect(spy.callCount).to.equal(1);
|
16
20
|
});
|
package/dist/tag.test.focus.js
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
1
2
|
import { expect, fixture, html } from '@open-wc/testing';
|
2
3
|
import GlideCoreTag from './tag.js';
|
3
4
|
GlideCoreTag.shadowRootOptions.mode = 'open';
|
4
5
|
it('calling `focus()` focuses the button', async () => {
|
5
|
-
const component = await fixture(html `<glide-core-tag
|
6
|
-
>Tag</glide-core-tag
|
7
|
-
>`);
|
6
|
+
const component = await fixture(html `<glide-core-tag label="Label" removable></glide-core-tag>`);
|
8
7
|
component.focus();
|
9
8
|
const button = component.shadowRoot?.querySelector('[data-test="button"]');
|
10
9
|
expect(component.shadowRoot?.activeElement).to.equal(button);
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
2
|
+
import { aTimeout, expect, fixture, html } from '@open-wc/testing';
|
3
|
+
import { sendKeys } from '@web/test-runner-commands';
|
4
|
+
import GlideCoreTag from './tag.js';
|
5
|
+
GlideCoreTag.shadowRootOptions.mode = 'open';
|
6
|
+
it('removes itself on click', async () => {
|
7
|
+
const component = await fixture(html `<glide-core-tag label="Label" removable></glide-core-tag>`);
|
8
|
+
component.click();
|
9
|
+
// Wait for the animation to complete.
|
10
|
+
await aTimeout(200);
|
11
|
+
expect(document.querySelector('glide-core-tag')).to.be.null;
|
12
|
+
});
|
13
|
+
it('removes itself on Space', async () => {
|
14
|
+
const component = await fixture(html `<glide-core-tag label="Label" removable></glide-core-tag>`);
|
15
|
+
component.focus();
|
16
|
+
await sendKeys({ press: ' ' });
|
17
|
+
// Wait for the animation to complete.
|
18
|
+
await aTimeout(200);
|
19
|
+
expect(document.querySelector('glide-core-tag')).to.be.null;
|
20
|
+
});
|
21
|
+
it('removes itself on Enter', async () => {
|
22
|
+
const component = await fixture(html `<glide-core-tag label="Label" removable></glide-core-tag>`);
|
23
|
+
component.focus();
|
24
|
+
await sendKeys({ press: 'Enter' });
|
25
|
+
// Wait for the animation to complete.
|
26
|
+
await aTimeout(200);
|
27
|
+
expect(document.querySelector('glide-core-tag')).to.be.null;
|
28
|
+
});
|
29
|
+
it('supports `textContent`', async () => {
|
30
|
+
const component = await fixture(html `<glide-core-tag label="One"></glide-core-tag>`);
|
31
|
+
expect(component.textContent).to.equal('One');
|
32
|
+
component.textContent = 'Two';
|
33
|
+
expect(component.label).to.equal('Two');
|
34
|
+
});
|
package/dist/textarea.d.ts
CHANGED
@@ -6,8 +6,6 @@ declare global {
|
|
6
6
|
}
|
7
7
|
}
|
8
8
|
/**
|
9
|
-
* @description A text area with a label and optional description and tooltip. Participates in forms and validation via `FormData` and various methods.
|
10
|
-
*
|
11
9
|
* @event change - `(event: Event) => void`
|
12
10
|
* @event input - `(event: Event) => void`
|
13
11
|
* @event invalid - `(event: Event) => void`
|
@@ -30,9 +28,10 @@ export default class GlideCoreTextarea extends LitElement {
|
|
30
28
|
readonly: boolean;
|
31
29
|
disabled: boolean;
|
32
30
|
maxlength?: number;
|
33
|
-
name
|
31
|
+
name: string;
|
34
32
|
spellcheck: boolean;
|
35
33
|
autocapitalize: 'on' | 'off' | 'none' | 'sentences' | 'words' | 'characters';
|
34
|
+
autocomplete: 'on' | 'off';
|
36
35
|
privateSplit?: 'left' | 'middle';
|
37
36
|
blur(): void;
|
38
37
|
checkValidity(): boolean;
|
package/dist/textarea.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,i,a){var r,o=arguments.length,l=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,i,a);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(l=(o<3?r(l):o>3?r(t,i,l):r(t,i))||l);return o>3&&l&&Object.defineProperty(t,i,l),l};import"./label.js";import{LitElement,html,nothing}from"lit";import{LocalizeController}from"./library/localize.js";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import ow from"./library/ow.js";import styles from"./textarea.styles.js";let GlideCoreTextarea=class GlideCoreTextarea extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed",delegatesFocus:!0}}static{this.styles=styles}blur(){this.#e.value?.blur()}checkValidity(){this.isCheckingValidity=!0;const e=this.#t.checkValidity();return this.isCheckingValidity=!1,e}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#i)}get form(){return this.#t.form}get validity(){return!this.required||this.value||this.disabled?this.#a?this.#t.setValidity({tooLong:!0}," ",this.#e.value):this.#t.setValidity({}):this.#t.setValidity({valueMissing:!0}," ",this.#e.value),this.#t.validity}get willValidate(){return this.#t.willValidate}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#i)}formResetCallback(){this.value=this.getAttribute("value")??""}render(){return html`<glide-core-private-label split="${ifDefined(this.privateSplit??void 0)}" orientation="${this.orientation}" ?disabled="${this.disabled}" ?error="${this.#r||this.#a}" ?hide="${this.hideLabel}" ?required="${this.required}"><slot name="tooltip" slot="tooltip"></slot><label class="label" for="textarea">${this.label}</label><div class="textarea-container" slot="control"><textarea aria-describedby="meta" aria-invalid="${this.#r||this.#a}" class="${classMap({error:this.#r||this.#a})}" id="textarea" name="${ifDefined(this.name)}" placeholder="${ifDefined(this.placeholder)}" rows="${this.rows}" autocapitalize="${
|
2
|
-
</textarea></div><div class="meta" id="meta" slot="description"><slot class="description" name="description"></slot>${this.maxlength?html`<div class="${classMap({"character-count":!0,error:this.#a})}" data-test="character-count-container"><span aria-hidden="true" data-test="character-count-text">${this.#d.term("displayedCharacterCount",this.#n,this.maxlength)} </span><span class="hidden" data-test="character-count-announcement">${this.#d.term("announcedCharacterCount",this.#n,this.maxlength)}</span></div>`:nothing}</div></glide-core-private-label>`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#t.reportValidity();return this.requestUpdate(),e}constructor(){super(),this.value="",this.label="",this.hideLabel=!1,this.orientation="horizontal",this.placeholder="",this.rows=2,this.required=!1,this.readonly=!1,this.disabled=!1,this.spellcheck=!1,this.autocapitalize="on",this.isBlurring=!1,this.isCheckingValidity=!1,this.isReportValidityOrSubmit=!1,this.#d=new LocalizeController(this),this.#e=createRef(),this.#i=({formData:e})=>{this.name&&this.value&&!this.disabled&&e.append(this.name,this.value)},this.#t=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.isReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#t;#d;#e;#i;get#r(){return!this.disabled&&!this.readonly&&!this.validity.valid&&this.isReportValidityOrSubmit}get#n(){return this.value.length}get#a(){return Boolean(!this.disabled&&!this.readonly&&this.maxlength&&this.#n>this.maxlength)}#s(){this.isBlurring=!0,this.reportValidity(),this.isBlurring=!1}#l(e){ow(this.#e.value,ow.object.instanceOf(HTMLTextAreaElement)),this.value=this.#e.value.value,this.dispatchEvent(new Event(e.type,e))}#o(){ow(this.#e.value,ow.object.instanceOf(HTMLTextAreaElement)),this.value=this.#e.value.value}};__decorate([property()],GlideCoreTextarea.prototype,"value",void 0),__decorate([property()],GlideCoreTextarea.prototype,"label",void 0),__decorate([property({attribute:"hide-label",type:Boolean})],GlideCoreTextarea.prototype,"hideLabel",void 0),__decorate([property({reflect:!0})],GlideCoreTextarea.prototype,"orientation",void 0),__decorate([property()],GlideCoreTextarea.prototype,"placeholder",void 0),__decorate([property({reflect:!0,type:Number})],GlideCoreTextarea.prototype,"rows",void 0),__decorate([property({type:Boolean})],GlideCoreTextarea.prototype,"required",void 0),__decorate([property({type:Boolean})],GlideCoreTextarea.prototype,"readonly",void 0),__decorate([property({type:Boolean})],GlideCoreTextarea.prototype,"disabled",void 0),__decorate([property({type:Number,converter:e=>e&&Number.parseInt(e,10)})],GlideCoreTextarea.prototype,"maxlength",void 0),__decorate([property({reflect:!0})],GlideCoreTextarea.prototype,"name",void 0),__decorate([property({type:Boolean})],GlideCoreTextarea.prototype,"spellcheck",void 0),__decorate([property()],GlideCoreTextarea.prototype,"autocapitalize",void 0),__decorate([property()],GlideCoreTextarea.prototype,"privateSplit",void 0),__decorate([state()],GlideCoreTextarea.prototype,"isBlurring",void 0),__decorate([state()],GlideCoreTextarea.prototype,"isCheckingValidity",void 0),__decorate([state()],GlideCoreTextarea.prototype,"isReportValidityOrSubmit",void 0),GlideCoreTextarea=__decorate([customElement("glide-core-textarea")],GlideCoreTextarea);export default GlideCoreTextarea;
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,i,a){var r,o=arguments.length,l=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,i,a);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(l=(o<3?r(l):o>3?r(t,i,l):r(t,i))||l);return o>3&&l&&Object.defineProperty(t,i,l),l};import"./label.js";import{LitElement,html,nothing}from"lit";import{LocalizeController}from"./library/localize.js";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import ow from"./library/ow.js";import styles from"./textarea.styles.js";let GlideCoreTextarea=class GlideCoreTextarea extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed",delegatesFocus:!0}}static{this.styles=styles}blur(){this.#e.value?.blur()}checkValidity(){this.isCheckingValidity=!0;const e=this.#t.checkValidity();return this.isCheckingValidity=!1,e}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#i)}get form(){return this.#t.form}get validity(){return!this.required||this.value||this.disabled?this.#a?this.#t.setValidity({tooLong:!0}," ",this.#e.value):this.#t.setValidity({}):this.#t.setValidity({valueMissing:!0}," ",this.#e.value),this.#t.validity}get willValidate(){return this.#t.willValidate}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#i)}formResetCallback(){this.value=this.getAttribute("value")??""}render(){return html`<glide-core-private-label split="${ifDefined(this.privateSplit??void 0)}" orientation="${this.orientation}" ?disabled="${this.disabled}" ?error="${this.#r||this.#a}" ?hide="${this.hideLabel}" ?required="${this.required}"><slot name="tooltip" slot="tooltip"></slot><label class="label" for="textarea">${this.label}</label><div class="textarea-container" slot="control"><textarea aria-describedby="meta" aria-invalid="${this.#r||this.#a}" class="${classMap({error:this.#r||this.#a})}" id="textarea" name="${ifDefined(this.name)}" placeholder="${ifDefined(this.placeholder)}" rows="${this.rows}" autocapitalize="${this.autocapitalize}" autocomplete="${this.autocomplete}" spellcheck="${this.spellcheck}" .value="${this.value}" ?required="${this.required}" ?readonly="${this.readonly}" ?disabled="${this.disabled}" ${ref(this.#e)} @input="${this.#o}" @change="${this.#l}" @blur="${this.#s}">
|
2
|
+
</textarea></div><div class="meta" id="meta" slot="description"><slot class="description" name="description"></slot>${this.maxlength?html`<div class="${classMap({"character-count":!0,error:this.#a})}" data-test="character-count-container"><span aria-hidden="true" data-test="character-count-text">${this.#d.term("displayedCharacterCount",this.#n,this.maxlength)} </span><span class="hidden" data-test="character-count-announcement">${this.#d.term("announcedCharacterCount",this.#n,this.maxlength)}</span></div>`:nothing}</div></glide-core-private-label>`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#t.reportValidity();return this.requestUpdate(),e}constructor(){super(),this.value="",this.label="",this.hideLabel=!1,this.orientation="horizontal",this.placeholder="",this.rows=2,this.required=!1,this.readonly=!1,this.disabled=!1,this.name="",this.spellcheck=!1,this.autocapitalize="on",this.autocomplete="on",this.isBlurring=!1,this.isCheckingValidity=!1,this.isReportValidityOrSubmit=!1,this.#d=new LocalizeController(this),this.#e=createRef(),this.#i=({formData:e})=>{this.name&&this.value&&!this.disabled&&e.append(this.name,this.value)},this.#t=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.isReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#t;#d;#e;#i;get#r(){return!this.disabled&&!this.readonly&&!this.validity.valid&&this.isReportValidityOrSubmit}get#n(){return this.value.length}get#a(){return Boolean(!this.disabled&&!this.readonly&&this.maxlength&&this.#n>this.maxlength)}#s(){this.isBlurring=!0,this.reportValidity(),this.isBlurring=!1}#l(e){ow(this.#e.value,ow.object.instanceOf(HTMLTextAreaElement)),this.value=this.#e.value.value,this.dispatchEvent(new Event(e.type,e))}#o(){ow(this.#e.value,ow.object.instanceOf(HTMLTextAreaElement)),this.value=this.#e.value.value}};__decorate([property()],GlideCoreTextarea.prototype,"value",void 0),__decorate([property({reflect:!0})],GlideCoreTextarea.prototype,"label",void 0),__decorate([property({attribute:"hide-label",reflect:!0,type:Boolean})],GlideCoreTextarea.prototype,"hideLabel",void 0),__decorate([property({reflect:!0})],GlideCoreTextarea.prototype,"orientation",void 0),__decorate([property({reflect:!0})],GlideCoreTextarea.prototype,"placeholder",void 0),__decorate([property({reflect:!0,type:Number})],GlideCoreTextarea.prototype,"rows",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreTextarea.prototype,"required",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreTextarea.prototype,"readonly",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreTextarea.prototype,"disabled",void 0),__decorate([property({type:Number,converter:e=>e&&Number.parseInt(e,10),reflect:!0})],GlideCoreTextarea.prototype,"maxlength",void 0),__decorate([property({reflect:!0})],GlideCoreTextarea.prototype,"name",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreTextarea.prototype,"spellcheck",void 0),__decorate([property({reflect:!0})],GlideCoreTextarea.prototype,"autocapitalize",void 0),__decorate([property({reflect:!0})],GlideCoreTextarea.prototype,"autocomplete",void 0),__decorate([property()],GlideCoreTextarea.prototype,"privateSplit",void 0),__decorate([state()],GlideCoreTextarea.prototype,"isBlurring",void 0),__decorate([state()],GlideCoreTextarea.prototype,"isCheckingValidity",void 0),__decorate([state()],GlideCoreTextarea.prototype,"isReportValidityOrSubmit",void 0),GlideCoreTextarea=__decorate([customElement("glide-core-textarea")],GlideCoreTextarea);export default GlideCoreTextarea;
|