@spectrum-web-components/picker 0.10.1 → 0.10.3

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/src/Picker.js DELETED
@@ -1,529 +0,0 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- var _a;
13
- import { __decorate } from "tslib";
14
- import { html, nothing, render, SizedMixin, } from '@spectrum-web-components/base';
15
- import { classMap } from '@spectrum-web-components/base/src/directives.js';
16
- import { property, query, } from '@spectrum-web-components/base/src/decorators.js';
17
- import pickerStyles from './picker.css.js';
18
- import chevronStyles from '@spectrum-web-components/icon/src/spectrum-icon-chevron.css.js';
19
- import { Focusable } from '@spectrum-web-components/shared/src/focusable.js';
20
- import { reparentChildren } from '@spectrum-web-components/shared/src/reparent-children.js';
21
- import '@spectrum-web-components/icons-ui/icons/sp-icon-chevron100.js';
22
- import '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';
23
- import '@spectrum-web-components/menu/sp-menu.js';
24
- import '@spectrum-web-components/tray/sp-tray.js';
25
- import '@spectrum-web-components/popover/sp-popover.js';
26
- import { openOverlay, } from '@spectrum-web-components/overlay';
27
- import { IS_MOBILE, MatchMediaController, } from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';
28
- const chevronClass = {
29
- s: 'spectrum-UIIcon-ChevronDown75',
30
- m: 'spectrum-UIIcon-ChevronDown100',
31
- l: 'spectrum-UIIcon-ChevronDown200',
32
- xl: 'spectrum-UIIcon-ChevronDown300',
33
- };
34
- /**
35
- * @element sp-picker
36
- *
37
- * @slot label - The placeholder content for the Picker
38
- * @slot - menu items to be listed in the Picker
39
- * @fires change - Announces that the `value` of the element has changed
40
- * @fires sp-opened - Announces that the overlay has been opened
41
- * @fires sp-closed - Announces that the overlay has been closed
42
- */
43
- export class PickerBase extends SizedMixin(Focusable) {
44
- constructor() {
45
- super();
46
- this.isMobile = new MatchMediaController(this, IS_MOBILE);
47
- this.disabled = false;
48
- this.focused = false;
49
- this.invalid = false;
50
- this.open = false;
51
- this.readonly = false;
52
- this.selects = 'single';
53
- this.menuItems = [];
54
- /**
55
- * @type {"auto" | "auto-start" | "auto-end" | "top" | "bottom" | "right" | "left" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end" | "none"}
56
- * @attr
57
- */
58
- this.placement = 'bottom-start';
59
- this.quiet = false;
60
- this.value = '';
61
- this.listRole = 'listbox';
62
- this.itemRole = 'option';
63
- this.onKeydown = (event) => {
64
- this.focused = true;
65
- if (event.code !== 'ArrowDown' && event.code !== 'ArrowUp') {
66
- return;
67
- }
68
- event.preventDefault();
69
- this.toggle(true);
70
- };
71
- this.overlayCloseCallback = () => {
72
- this.open = false;
73
- };
74
- this._willUpdateItems = false;
75
- this.itemsUpdated = Promise.resolve();
76
- this.menuStatePromise = Promise.resolve();
77
- this.onKeydown = this.onKeydown.bind(this);
78
- }
79
- get target() {
80
- return this.button;
81
- }
82
- get focusElement() {
83
- if (this.open) {
84
- return this.optionsMenu;
85
- }
86
- return this.button;
87
- }
88
- forceFocusVisible() {
89
- this.focused = true;
90
- }
91
- onButtonBlur() {
92
- this.focused = false;
93
- this.target.removeEventListener('keydown', this.onKeydown);
94
- }
95
- onButtonClick() {
96
- this.toggle();
97
- }
98
- focus(options) {
99
- super.focus(options);
100
- if (!this.disabled && this.focusElement) {
101
- this.focused = this.hasVisibleFocusInTree();
102
- }
103
- }
104
- onHelperFocus() {
105
- // set focused to true here instead of onButtonFocus so clicks don't flash a focus outline
106
- this.focused = true;
107
- this.button.focus();
108
- }
109
- onButtonFocus() {
110
- this.target.addEventListener('keydown', this.onKeydown);
111
- }
112
- handleChange(event) {
113
- event.stopPropagation();
114
- const target = event.target;
115
- const [selected] = target.selectedItems;
116
- this.setValueFromItem(selected, event);
117
- }
118
- async setValueFromItem(item, menuChangeEvent) {
119
- const oldSelectedItem = this.selectedItem;
120
- const oldValue = this.value;
121
- this.selectedItem = item;
122
- this.value = item.value;
123
- this.open = false;
124
- await this.updateComplete;
125
- const applyDefault = this.dispatchEvent(new Event('change', {
126
- bubbles: true,
127
- cancelable: true,
128
- composed: true,
129
- }));
130
- if (!applyDefault) {
131
- if (menuChangeEvent) {
132
- menuChangeEvent.preventDefault();
133
- }
134
- this.selectedItem.selected = false;
135
- if (oldSelectedItem) {
136
- oldSelectedItem.selected = true;
137
- }
138
- this.selectedItem = oldSelectedItem;
139
- this.value = oldValue;
140
- this.open = true;
141
- return;
142
- }
143
- if (oldSelectedItem) {
144
- oldSelectedItem.selected = false;
145
- }
146
- item.selected = !!this.selects;
147
- }
148
- toggle(target) {
149
- if (this.readonly) {
150
- return;
151
- }
152
- this.open = typeof target !== 'undefined' ? target : !this.open;
153
- }
154
- close() {
155
- if (this.readonly) {
156
- return;
157
- }
158
- this.open = false;
159
- }
160
- onOverlayClosed() {
161
- this.close();
162
- if (this.restoreChildren) {
163
- this.restoreChildren();
164
- this.restoreChildren = undefined;
165
- }
166
- this.menuStateResolver();
167
- }
168
- async generatePopover(deprecatedMenu) {
169
- if (!this.popoverFragment) {
170
- this.popoverFragment = document.createDocumentFragment();
171
- }
172
- render(this.renderPopover, this.popoverFragment, { host: this });
173
- this.popover = this.popoverFragment.children[0];
174
- this.optionsMenu = this.popover.children[1];
175
- if (deprecatedMenu) {
176
- console.warn(`Deprecation Notice: You no longer need to provide an sp-menu child to ${this.tagName.toLowerCase()}. Any styling or attributes on the sp-menu will be ignored.`);
177
- }
178
- }
179
- async openMenu() {
180
- /* c8 ignore next 9 */
181
- let reparentableChildren = [];
182
- const deprecatedMenu = this.querySelector('sp-menu');
183
- await this.generatePopover(deprecatedMenu);
184
- if (deprecatedMenu) {
185
- reparentableChildren = Array.from(deprecatedMenu.children);
186
- }
187
- else {
188
- reparentableChildren = Array.from(this.children).filter((element) => {
189
- return !element.hasAttribute('slot');
190
- });
191
- }
192
- if (reparentableChildren.length === 0) {
193
- this.menuStateResolver();
194
- return;
195
- }
196
- this.restoreChildren = reparentChildren(reparentableChildren, this.optionsMenu, () => {
197
- return (el) => {
198
- if (typeof el.focused !== 'undefined') {
199
- el.focused = false;
200
- }
201
- };
202
- });
203
- this.sizePopover(this.popover);
204
- this.addEventListener('sp-opened', async () => {
205
- this.updateMenuItems();
206
- await Promise.all([
207
- this.itemsUpdated,
208
- this.optionsMenu.updateComplete,
209
- ]);
210
- this.menuStateResolver();
211
- }, { once: true });
212
- this.closeOverlay = Picker.openOverlay(this, 'modal', this.popover, {
213
- placement: this.isMobile.matches ? 'none' : this.placement,
214
- receivesFocus: 'auto',
215
- });
216
- }
217
- sizePopover(popover) {
218
- if (this.isMobile.matches) {
219
- popover.style.setProperty('--swc-menu-width', `100%`);
220
- return;
221
- }
222
- if (this.quiet)
223
- return;
224
- // only use `this.offsetWidth` when Standard variant
225
- popover.style.setProperty('min-width', `${this.offsetWidth}px`);
226
- }
227
- async closeMenu() {
228
- if (this.closeOverlay) {
229
- const closeOverlay = this.closeOverlay;
230
- delete this.closeOverlay;
231
- (await closeOverlay)();
232
- }
233
- }
234
- get selectedItemContent() {
235
- if (this.selectedItem) {
236
- return this.selectedItem.itemChildren;
237
- }
238
- return { icon: [], content: [] };
239
- }
240
- renderLabelContent(content) {
241
- if (this.value && this.selectedItem) {
242
- return content;
243
- }
244
- return html `
245
- <slot name="label">${this.label}</slot>
246
- `;
247
- }
248
- get buttonContent() {
249
- const labelClasses = {
250
- 'visually-hidden': this.icons === 'only' && !!this.value,
251
- placeholder: !this.value,
252
- };
253
- return [
254
- html `
255
- <span id="icon" ?hidden=${this.icons === 'none'}>
256
- ${this.selectedItemContent.icon}
257
- </span>
258
- <span id="label" class=${classMap(labelClasses)}>
259
- ${this.renderLabelContent(this.selectedItemContent.content)}
260
- </span>
261
- ${this.invalid
262
- ? html `
263
- <sp-icon-alert
264
- class="validation-icon"
265
- ></sp-icon-alert>
266
- `
267
- : nothing}
268
- <sp-icon-chevron100
269
- class="picker ${chevronClass[this.size]}"
270
- ></sp-icon-chevron100>
271
- `,
272
- ];
273
- }
274
- // a helper to throw focus to the button is needed because Safari
275
- // won't include buttons in the tab order even with tabindex="0"
276
- render() {
277
- return html `
278
- <span
279
- id="focus-helper"
280
- tabindex="${this.focused ? '-1' : '0'}"
281
- @focus=${this.onHelperFocus}
282
- ></span>
283
- <button
284
- aria-haspopup="true"
285
- aria-expanded=${this.open ? 'true' : 'false'}
286
- aria-labelledby="button icon label"
287
- id="button"
288
- class="button"
289
- @blur=${this.onButtonBlur}
290
- @click=${this.onButtonClick}
291
- @focus=${this.onButtonFocus}
292
- ?disabled=${this.disabled}
293
- tabindex="-1"
294
- >
295
- ${this.buttonContent}
296
- </button>
297
- `;
298
- }
299
- update(changes) {
300
- if (this.selects) {
301
- // Always force `selects` to "single" when set.
302
- // TODO: Add support functionally and visually for "multiple"
303
- this.selects = 'single';
304
- }
305
- super.update(changes);
306
- }
307
- get dismissHelper() {
308
- return html `
309
- <div class="visually-hidden">
310
- <button
311
- tabindex="-1"
312
- arial-label="Dismiss"
313
- @click=${this.close}
314
- ></button>
315
- </div>
316
- `;
317
- }
318
- get renderPopover() {
319
- const content = html `
320
- ${this.dismissHelper}
321
- <sp-menu
322
- id="menu"
323
- role="${this.listRole}"
324
- @change=${this.handleChange}
325
- .selects=${this.selects}
326
- ></sp-menu>
327
- ${this.dismissHelper}
328
- `;
329
- if (this.isMobile.matches) {
330
- return html `
331
- <sp-tray
332
- id="popover"
333
- role="dialog"
334
- @sp-menu-item-added-or-updated=${this.updateMenuItems}
335
- @sp-overlay-closed=${this.onOverlayClosed}
336
- .overlayCloseCallback=${this.overlayCloseCallback}
337
- >
338
- ${content}
339
- </sp-tray>
340
- `;
341
- }
342
- return html `
343
- <sp-popover
344
- id="popover"
345
- role="dialog"
346
- @sp-menu-item-added-or-updated=${this.updateMenuItems}
347
- @sp-overlay-closed=${this.onOverlayClosed}
348
- .overlayCloseCallback=${this.overlayCloseCallback}
349
- >
350
- ${content}
351
- </sp-popover>
352
- `;
353
- }
354
- /**
355
- * Acquire the available MenuItems in the Picker by
356
- * direct element query or by assuming the list managed
357
- * by the Menu within the open options overlay.
358
- */
359
- updateMenuItems(event) {
360
- if (this.open && (event === null || event === void 0 ? void 0 : event.type) === 'sp-menu-item-removed')
361
- return;
362
- if (this._willUpdateItems)
363
- return;
364
- this._willUpdateItems = true;
365
- if ((event === null || event === void 0 ? void 0 : event.item) === this.selectedItem) {
366
- this.requestUpdate();
367
- }
368
- let resolve = () => {
369
- return;
370
- };
371
- this.itemsUpdated = new Promise((res) => (resolve = res));
372
- // Debounce the update so we only update once
373
- // if multiple items have changed
374
- window.requestAnimationFrame(async () => {
375
- if (this.open) {
376
- await this.optionsMenu.updateComplete;
377
- this.menuItems = this.optionsMenu.childItems;
378
- }
379
- else {
380
- this.menuItems = [
381
- ...this.querySelectorAll('sp-menu-item'),
382
- ];
383
- }
384
- this.manageSelection();
385
- resolve();
386
- this._willUpdateItems = false;
387
- });
388
- }
389
- updated(changedProperties) {
390
- super.updated(changedProperties);
391
- if (changedProperties.has('value') &&
392
- !changedProperties.has('selectedItem')) {
393
- this.updateMenuItems();
394
- }
395
- if (changedProperties.has('disabled') && this.disabled) {
396
- this.open = false;
397
- }
398
- if (changedProperties.has('open') &&
399
- (this.open || typeof changedProperties.get('open') !== 'undefined')) {
400
- this.menuStatePromise = new Promise((res) => (this.menuStateResolver = res));
401
- if (this.open) {
402
- this.openMenu();
403
- }
404
- else {
405
- this.closeMenu();
406
- }
407
- }
408
- }
409
- manageSelection() {
410
- let selectedItem;
411
- this.menuItems.forEach((item) => {
412
- if (this.value === item.value && !item.disabled) {
413
- selectedItem = item;
414
- }
415
- else {
416
- item.selected = false;
417
- }
418
- });
419
- if (selectedItem) {
420
- selectedItem.selected = !!this.selects;
421
- this.selectedItem = selectedItem;
422
- }
423
- else {
424
- this.value = '';
425
- this.selectedItem = undefined;
426
- }
427
- if (this.open) {
428
- this.optionsMenu.updateComplete.then(() => {
429
- this.optionsMenu.updateSelectedItemIndex();
430
- });
431
- }
432
- }
433
- async getUpdateComplete() {
434
- const complete = (await super.getUpdateComplete());
435
- await this.menuStatePromise;
436
- await this.itemsUpdated;
437
- return complete;
438
- }
439
- connectedCallback() {
440
- this.updateMenuItems();
441
- this.addEventListener('sp-menu-item-added-or-updated', this.updateMenuItems);
442
- this.addEventListener('sp-menu-item-removed', this.updateMenuItems);
443
- super.connectedCallback();
444
- }
445
- disconnectedCallback() {
446
- this.open = false;
447
- super.disconnectedCallback();
448
- }
449
- }
450
- _a = PickerBase;
451
- /**
452
- * @private
453
- */
454
- PickerBase.openOverlay = async (target, interaction, content, options) => {
455
- return await openOverlay(target, interaction, content, options);
456
- };
457
- __decorate([
458
- query('#button')
459
- ], PickerBase.prototype, "button", void 0);
460
- __decorate([
461
- property({ type: Boolean, reflect: true })
462
- ], PickerBase.prototype, "disabled", void 0);
463
- __decorate([
464
- property({ type: Boolean, reflect: true })
465
- ], PickerBase.prototype, "focused", void 0);
466
- __decorate([
467
- property({ type: String, reflect: true })
468
- ], PickerBase.prototype, "icons", void 0);
469
- __decorate([
470
- property({ type: Boolean, reflect: true })
471
- ], PickerBase.prototype, "invalid", void 0);
472
- __decorate([
473
- property()
474
- ], PickerBase.prototype, "label", void 0);
475
- __decorate([
476
- property({ type: Boolean, reflect: true })
477
- ], PickerBase.prototype, "open", void 0);
478
- __decorate([
479
- property({ type: Boolean, reflect: true })
480
- ], PickerBase.prototype, "readonly", void 0);
481
- __decorate([
482
- property()
483
- ], PickerBase.prototype, "placement", void 0);
484
- __decorate([
485
- property({ type: Boolean, reflect: true })
486
- ], PickerBase.prototype, "quiet", void 0);
487
- __decorate([
488
- property({ type: String })
489
- ], PickerBase.prototype, "value", void 0);
490
- __decorate([
491
- property({ attribute: false })
492
- ], PickerBase.prototype, "selectedItem", void 0);
493
- export class Picker extends PickerBase {
494
- constructor() {
495
- super(...arguments);
496
- this.onKeydown = (event) => {
497
- const { code } = event;
498
- this.focused = true;
499
- if (!code.startsWith('Arrow') || this.readonly) {
500
- return;
501
- }
502
- event.preventDefault();
503
- if (code === 'ArrowUp' || code === 'ArrowDown') {
504
- this.toggle(true);
505
- return;
506
- }
507
- const selectedIndex = this.selectedItem
508
- ? this.menuItems.indexOf(this.selectedItem)
509
- : -1;
510
- // use a positive offset to find the first non-disabled item when no selection is available.
511
- const nextOffset = !this.value || code === 'ArrowRight' ? 1 : -1;
512
- let nextIndex = selectedIndex + nextOffset;
513
- while (this.menuItems[nextIndex] &&
514
- this.menuItems[nextIndex].disabled) {
515
- nextIndex += nextOffset;
516
- }
517
- if (!this.menuItems[nextIndex] || this.menuItems[nextIndex].disabled) {
518
- return;
519
- }
520
- if (!this.value || nextIndex !== selectedIndex) {
521
- this.setValueFromItem(this.menuItems[nextIndex]);
522
- }
523
- };
524
- }
525
- static get styles() {
526
- return [pickerStyles, chevronStyles];
527
- }
528
- }
529
- //# sourceMappingURL=Picker.js.map
package/src/Picker.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"Picker.js","sourceRoot":"","sources":["Picker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;;AAEF,OAAO,EAGH,IAAI,EACJ,OAAO,EAEP,MAAM,EACN,UAAU,GAEb,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAC3E,OAAO,EACH,QAAQ,EACR,KAAK,GACR,MAAM,iDAAiD,CAAC;AAEzD,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,aAAa,MAAM,gEAAgE,CAAC;AAE3F,OAAO,EA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ACpB,OAAO,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IACzC,CAAC;CAgCJ","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n DefaultElementSize,\n html,\n nothing,\n PropertyValues,\n render,\n SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { classMap } from '@spectrum-web-components/base/src/directives.js';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\n\nimport pickerStyles from './picker.css.js';\nimport chevronStyles from '@spectrum-web-components/icon/src/spectrum-icon-chevron.css.js';\n\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport { reparentChildren } from '@spectrum-web-components/shared/src/reparent-children.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-chevron100.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';\nimport '@spectrum-web-components/menu/sp-menu.js';\nimport type {\n Menu,\n MenuItem,\n MenuItemAddedOrUpdatedEvent,\n MenuItemChildren,\n MenuItemRemovedEvent,\n} from '@spectrum-web-components/menu';\nimport '@spectrum-web-components/tray/sp-tray.js';\nimport '@spectrum-web-components/popover/sp-popover.js';\nimport type { Popover } from '@spectrum-web-components/popover';\nimport {\n openOverlay,\n OverlayOptions,\n Placement,\n TriggerInteractions,\n} from '@spectrum-web-components/overlay';\nimport {\n IS_MOBILE,\n MatchMediaController,\n} from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';\n\nconst chevronClass = {\n s: 'spectrum-UIIcon-ChevronDown75',\n m: 'spectrum-UIIcon-ChevronDown100',\n l: 'spectrum-UIIcon-ChevronDown200',\n xl: 'spectrum-UIIcon-ChevronDown300',\n};\n\n/**\n * @element sp-picker\n *\n * @slot label - The placeholder content for the Picker\n * @slot - menu items to be listed in the Picker\n * @fires change - Announces that the `value` of the element has changed\n * @fires sp-opened - Announces that the overlay has been opened\n * @fires sp-closed - Announces that the overlay has been closed\n */\nexport class PickerBase extends SizedMixin(Focusable) {\n /**\n * @private\n */\n public static openOverlay = async (\n target: HTMLElement,\n interaction: TriggerInteractions,\n content: HTMLElement,\n options: OverlayOptions\n ): Promise<() => void> => {\n return await openOverlay(target, interaction, content, options);\n };\n\n protected isMobile = new MatchMediaController(this, IS_MOBILE);\n\n @query('#button')\n public button!: HTMLButtonElement;\n\n public get target(): HTMLButtonElement | this {\n return this.button;\n }\n\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n @property({ type: Boolean, reflect: true })\n public focused = false;\n\n @property({ type: String, reflect: true })\n public icons?: 'only' | 'none';\n\n @property({ type: Boolean, reflect: true })\n public invalid = false;\n\n @property()\n public label?: string;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @property({ type: Boolean, reflect: true })\n public readonly = false;\n\n public selects: undefined | 'single' = 'single';\n\n public menuItems: MenuItem[] = [];\n private restoreChildren?: () => void;\n\n public optionsMenu!: Menu;\n\n /**\n * @type {\"auto\" | \"auto-start\" | \"auto-end\" | \"top\" | \"bottom\" | \"right\" | \"left\" | \"top-start\" | \"top-end\" | \"bottom-start\" | \"bottom-end\" | \"right-start\" | \"right-end\" | \"left-start\" | \"left-end\" | \"none\"}\n * @attr\n */\n\n @property()\n public placement: Placement = 'bottom-start';\n\n @property({ type: Boolean, reflect: true })\n public quiet = false;\n\n @property({ type: String })\n public value = '';\n\n @property({ attribute: false })\n public selectedItem?: MenuItem;\n\n private closeOverlay?: Promise<() => void>;\n\n private popover!: Popover;\n\n protected listRole: 'listbox' | 'menu' = 'listbox';\n protected itemRole = 'option';\n\n public constructor() {\n super();\n this.onKeydown = this.onKeydown.bind(this);\n }\n\n public get focusElement(): HTMLElement {\n if (this.open) {\n return this.optionsMenu;\n }\n return this.button;\n }\n\n public forceFocusVisible(): void {\n this.focused = true;\n }\n\n public onButtonBlur(): void {\n this.focused = false;\n (this.target as HTMLButtonElement).removeEventListener(\n 'keydown',\n this.onKeydown\n );\n }\n\n protected onButtonClick(): void {\n this.toggle();\n }\n\n public focus(options?: FocusOptions): void {\n super.focus(options);\n\n if (!this.disabled && this.focusElement) {\n this.focused = this.hasVisibleFocusInTree();\n }\n }\n\n public onHelperFocus(): void {\n // set focused to true here instead of onButtonFocus so clicks don't flash a focus outline\n this.focused = true;\n this.button.focus();\n }\n\n public onButtonFocus(): void {\n (this.target as HTMLButtonElement).addEventListener(\n 'keydown',\n this.onKeydown\n );\n }\n\n public handleChange(event: Event): void {\n event.stopPropagation();\n const target = event.target as Menu;\n const [selected] = target.selectedItems;\n this.setValueFromItem(selected, event);\n }\n\n protected onKeydown = (event: KeyboardEvent): void => {\n this.focused = true;\n if (event.code !== 'ArrowDown' && event.code !== 'ArrowUp') {\n return;\n }\n event.preventDefault();\n this.toggle(true);\n };\n\n public async setValueFromItem(\n item: MenuItem,\n menuChangeEvent?: Event\n ): Promise<void> {\n const oldSelectedItem = this.selectedItem;\n const oldValue = this.value;\n this.selectedItem = item;\n this.value = item.value;\n this.open = false;\n await this.updateComplete;\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n cancelable: true,\n composed: true,\n })\n );\n if (!applyDefault) {\n if (menuChangeEvent) {\n menuChangeEvent.preventDefault();\n }\n this.selectedItem.selected = false;\n if (oldSelectedItem) {\n oldSelectedItem.selected = true;\n }\n this.selectedItem = oldSelectedItem;\n this.value = oldValue;\n this.open = true;\n return;\n }\n if (oldSelectedItem) {\n oldSelectedItem.selected = false;\n }\n item.selected = !!this.selects;\n }\n\n public toggle(target?: boolean): void {\n if (this.readonly) {\n return;\n }\n this.open = typeof target !== 'undefined' ? target : !this.open;\n }\n\n public close(): void {\n if (this.readonly) {\n return;\n }\n this.open = false;\n }\n\n public overlayCloseCallback = (): void => {\n this.open = false;\n };\n\n protected onOverlayClosed(): void {\n this.close();\n if (this.restoreChildren) {\n this.restoreChildren();\n this.restoreChildren = undefined;\n }\n\n this.menuStateResolver();\n }\n\n private popoverFragment!: DocumentFragment;\n\n private async generatePopover(deprecatedMenu: Menu | null): Promise<void> {\n if (!this.popoverFragment) {\n this.popoverFragment = document.createDocumentFragment();\n }\n render(this.renderPopover, this.popoverFragment, { host: this });\n this.popover = this.popoverFragment.children[0] as Popover;\n this.optionsMenu = this.popover.children[1] as Menu;\n\n if (deprecatedMenu) {\n console.warn(\n `Deprecation Notice: You no longer need to provide an sp-menu child to ${this.tagName.toLowerCase()}. Any styling or attributes on the sp-menu will be ignored.`\n );\n }\n }\n\n private async openMenu(): Promise<void> {\n /* c8 ignore next 9 */\n let reparentableChildren: Element[] = [];\n const deprecatedMenu = this.querySelector('sp-menu');\n\n await this.generatePopover(deprecatedMenu);\n if (deprecatedMenu) {\n reparentableChildren = Array.from(deprecatedMenu.children);\n } else {\n reparentableChildren = Array.from(this.children).filter(\n (element) => {\n return !element.hasAttribute('slot');\n }\n );\n }\n\n if (reparentableChildren.length === 0) {\n this.menuStateResolver();\n return;\n }\n\n this.restoreChildren = reparentChildren<\n Element & { focused?: boolean }\n >(reparentableChildren, this.optionsMenu, () => {\n return (el) => {\n if (typeof el.focused !== 'undefined') {\n el.focused = false;\n }\n };\n });\n\n this.sizePopover(this.popover);\n this.addEventListener(\n 'sp-opened',\n async () => {\n this.updateMenuItems();\n await Promise.all([\n this.itemsUpdated,\n this.optionsMenu.updateComplete,\n ]);\n this.menuStateResolver();\n },\n { once: true }\n );\n this.closeOverlay = Picker.openOverlay(this, 'modal', this.popover, {\n placement: this.isMobile.matches ? 'none' : this.placement,\n receivesFocus: 'auto',\n });\n }\n\n protected sizePopover(popover: HTMLElement): void {\n if (this.isMobile.matches) {\n popover.style.setProperty('--swc-menu-width', `100%`);\n return;\n }\n if (this.quiet) return;\n // only use `this.offsetWidth` when Standard variant\n popover.style.setProperty('min-width', `${this.offsetWidth}px`);\n }\n\n private async closeMenu(): Promise<void> {\n if (this.closeOverlay) {\n const closeOverlay = this.closeOverlay;\n delete this.closeOverlay;\n (await closeOverlay)();\n }\n }\n\n protected get selectedItemContent(): MenuItemChildren {\n if (this.selectedItem) {\n return this.selectedItem.itemChildren;\n }\n return { icon: [], content: [] };\n }\n\n protected renderLabelContent(content: Node[]): TemplateResult | Node[] {\n if (this.value && this.selectedItem) {\n return content;\n }\n return html`\n <slot name=\"label\">${this.label}</slot>\n `;\n }\n\n protected get buttonContent(): TemplateResult[] {\n const labelClasses = {\n 'visually-hidden': this.icons === 'only' && !!this.value,\n placeholder: !this.value,\n };\n return [\n html`\n <span id=\"icon\" ?hidden=${this.icons === 'none'}>\n ${this.selectedItemContent.icon}\n </span>\n <span id=\"label\" class=${classMap(labelClasses)}>\n ${this.renderLabelContent(this.selectedItemContent.content)}\n </span>\n ${this.invalid\n ? html`\n <sp-icon-alert\n class=\"validation-icon\"\n ></sp-icon-alert>\n `\n : nothing}\n <sp-icon-chevron100\n class=\"picker ${chevronClass[\n this.size as DefaultElementSize\n ]}\"\n ></sp-icon-chevron100>\n `,\n ];\n }\n\n // a helper to throw focus to the button is needed because Safari\n // won't include buttons in the tab order even with tabindex=\"0\"\n protected render(): TemplateResult {\n return html`\n <span\n id=\"focus-helper\"\n tabindex=\"${this.focused ? '-1' : '0'}\"\n @focus=${this.onHelperFocus}\n ></span>\n <button\n aria-haspopup=\"true\"\n aria-expanded=${this.open ? 'true' : 'false'}\n aria-labelledby=\"button icon label\"\n id=\"button\"\n class=\"button\"\n @blur=${this.onButtonBlur}\n @click=${this.onButtonClick}\n @focus=${this.onButtonFocus}\n ?disabled=${this.disabled}\n tabindex=\"-1\"\n >\n ${this.buttonContent}\n </button>\n `;\n }\n\n protected update(changes: PropertyValues<this>): void {\n if (this.selects) {\n // Always force `selects` to \"single\" when set.\n // TODO: Add support functionally and visually for \"multiple\"\n this.selects = 'single';\n }\n super.update(changes);\n }\n\n protected get dismissHelper(): TemplateResult {\n return html`\n <div class=\"visually-hidden\">\n <button\n tabindex=\"-1\"\n arial-label=\"Dismiss\"\n @click=${this.close}\n ></button>\n </div>\n `;\n }\n\n protected get renderPopover(): TemplateResult {\n const content = html`\n ${this.dismissHelper}\n <sp-menu\n id=\"menu\"\n role=\"${this.listRole}\"\n @change=${this.handleChange}\n .selects=${this.selects}\n ></sp-menu>\n ${this.dismissHelper}\n `;\n if (this.isMobile.matches) {\n return html`\n <sp-tray\n id=\"popover\"\n role=\"dialog\"\n @sp-menu-item-added-or-updated=${this.updateMenuItems}\n @sp-overlay-closed=${this.onOverlayClosed}\n .overlayCloseCallback=${this.overlayCloseCallback}\n >\n ${content}\n </sp-tray>\n `;\n }\n return html`\n <sp-popover\n id=\"popover\"\n role=\"dialog\"\n @sp-menu-item-added-or-updated=${this.updateMenuItems}\n @sp-overlay-closed=${this.onOverlayClosed}\n .overlayCloseCallback=${this.overlayCloseCallback}\n >\n ${content}\n </sp-popover>\n `;\n }\n\n private _willUpdateItems = false;\n protected itemsUpdated: Promise<void> = Promise.resolve();\n\n /**\n * Acquire the available MenuItems in the Picker by\n * direct element query or by assuming the list managed\n * by the Menu within the open options overlay.\n */\n protected updateMenuItems(\n event?: MenuItemAddedOrUpdatedEvent | MenuItemRemovedEvent\n ): void {\n if (this.open && event?.type === 'sp-menu-item-removed') return;\n if (this._willUpdateItems) return;\n this._willUpdateItems = true;\n if (event?.item === this.selectedItem) {\n this.requestUpdate();\n }\n\n let resolve = (): void => {\n return;\n };\n this.itemsUpdated = new Promise((res) => (resolve = res));\n // Debounce the update so we only update once\n // if multiple items have changed\n window.requestAnimationFrame(async () => {\n if (this.open) {\n await this.optionsMenu.updateComplete;\n this.menuItems = this.optionsMenu.childItems;\n } else {\n this.menuItems = [\n ...this.querySelectorAll('sp-menu-item'),\n ] as MenuItem[];\n }\n this.manageSelection();\n resolve();\n this._willUpdateItems = false;\n });\n }\n\n protected updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n if (\n changedProperties.has('value') &&\n !changedProperties.has('selectedItem')\n ) {\n this.updateMenuItems();\n }\n if (changedProperties.has('disabled') && this.disabled) {\n this.open = false;\n }\n if (\n changedProperties.has('open') &&\n (this.open || typeof changedProperties.get('open') !== 'undefined')\n ) {\n this.menuStatePromise = new Promise(\n (res) => (this.menuStateResolver = res)\n );\n if (this.open) {\n this.openMenu();\n } else {\n this.closeMenu();\n }\n }\n }\n\n protected manageSelection(): void {\n let selectedItem: MenuItem | undefined;\n this.menuItems.forEach((item) => {\n if (this.value === item.value && !item.disabled) {\n selectedItem = item;\n } else {\n item.selected = false;\n }\n });\n if (selectedItem) {\n selectedItem.selected = !!this.selects;\n this.selectedItem = selectedItem;\n } else {\n this.value = '';\n this.selectedItem = undefined;\n }\n if (this.open) {\n this.optionsMenu.updateComplete.then(() => {\n this.optionsMenu.updateSelectedItemIndex();\n });\n }\n }\n\n private menuStatePromise = Promise.resolve();\n private menuStateResolver!: () => void;\n\n protected async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.menuStatePromise;\n await this.itemsUpdated;\n return complete;\n }\n\n public connectedCallback(): void {\n this.updateMenuItems();\n this.addEventListener(\n 'sp-menu-item-added-or-updated',\n this.updateMenuItems\n );\n this.addEventListener('sp-menu-item-removed', this.updateMenuItems);\n super.connectedCallback();\n }\n\n public disconnectedCallback(): void {\n this.open = false;\n\n super.disconnectedCallback();\n }\n}\n\nexport class Picker extends PickerBase {\n public static get styles(): CSSResultArray {\n return [pickerStyles, chevronStyles];\n }\n\n protected onKeydown = (event: KeyboardEvent): void => {\n const { code } = event;\n this.focused = true;\n if (!code.startsWith('Arrow') || this.readonly) {\n return;\n }\n event.preventDefault();\n if (code === 'ArrowUp' || code === 'ArrowDown') {\n this.toggle(true);\n return;\n }\n const selectedIndex = this.selectedItem\n ? this.menuItems.indexOf(this.selectedItem)\n : -1;\n // use a positive offset to find the first non-disabled item when no selection is available.\n const nextOffset = !this.value || code === 'ArrowRight' ? 1 : -1;\n let nextIndex = selectedIndex + nextOffset;\n while (\n this.menuItems[nextIndex] &&\n this.menuItems[nextIndex].disabled\n ) {\n nextIndex += nextOffset;\n }\n if (!this.menuItems[nextIndex] || this.menuItems[nextIndex].disabled) {\n return;\n }\n if (!this.value || nextIndex !== selectedIndex) {\n this.setValueFromItem(this.menuItems[nextIndex]);\n }\n };\n}\n"]}
package/src/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './Picker.js';
package/src/index.js DELETED
@@ -1,13 +0,0 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- export * from './Picker.js';
13
- //# sourceMappingURL=index.js.map
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,cAAc,aAAa,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nexport * from './Picker.js';\n"]}
@@ -1,2 +0,0 @@
1
- declare const styles: import("@spectrum-web-components/base").CSSResult;
2
- export default styles;