@spectrum-web-components/picker 1.8.0 → 1.9.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/custom-elements.json +26 -24
- package/package.json +15 -15
- package/src/InteractionController.d.ts +1 -1
- package/src/InteractionController.dev.js.map +1 -1
- package/src/InteractionController.js.map +1 -1
- package/src/Picker.d.ts +6 -13
- package/src/Picker.dev.js +39 -16
- package/src/Picker.dev.js.map +2 -2
- package/src/Picker.js +34 -18
- package/src/Picker.js.map +3 -3
- package/src/picker.css.dev.js +1 -1
- package/src/picker.css.dev.js.map +1 -1
- package/src/picker.css.js +1 -1
- package/src/picker.css.js.map +1 -1
- package/src/spectrum-picker.css.dev.js +1 -1
- package/src/spectrum-picker.css.dev.js.map +1 -1
- package/src/spectrum-picker.css.js +1 -1
- package/src/spectrum-picker.css.js.map +1 -1
package/custom-elements.json
CHANGED
|
@@ -1081,7 +1081,7 @@
|
|
|
1081
1081
|
"text": "object"
|
|
1082
1082
|
},
|
|
1083
1083
|
"static": true,
|
|
1084
|
-
"default": "{
|
|
1084
|
+
"default": "{ ...SpectrumElement.shadowRootOptions, delegatesFocus: true, }"
|
|
1085
1085
|
},
|
|
1086
1086
|
{
|
|
1087
1087
|
"kind": "field",
|
|
@@ -1335,15 +1335,6 @@
|
|
|
1335
1335
|
},
|
|
1336
1336
|
"privacy": "public"
|
|
1337
1337
|
},
|
|
1338
|
-
{
|
|
1339
|
-
"kind": "field",
|
|
1340
|
-
"name": "pendingStateController",
|
|
1341
|
-
"type": {
|
|
1342
|
-
"text": "PendingStateController<this>"
|
|
1343
|
-
},
|
|
1344
|
-
"privacy": "public",
|
|
1345
|
-
"default": "new PendingStateController(this)"
|
|
1346
|
-
},
|
|
1347
1338
|
{
|
|
1348
1339
|
"kind": "field",
|
|
1349
1340
|
"name": "_selectedItem",
|
|
@@ -1657,6 +1648,16 @@
|
|
|
1657
1648
|
}
|
|
1658
1649
|
]
|
|
1659
1650
|
},
|
|
1651
|
+
{
|
|
1652
|
+
"kind": "method",
|
|
1653
|
+
"name": "renderLoader",
|
|
1654
|
+
"privacy": "protected",
|
|
1655
|
+
"return": {
|
|
1656
|
+
"type": {
|
|
1657
|
+
"text": "TemplateResult"
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
},
|
|
1660
1661
|
{
|
|
1661
1662
|
"kind": "field",
|
|
1662
1663
|
"name": "buttonContent",
|
|
@@ -2099,7 +2100,7 @@
|
|
|
2099
2100
|
"text": "object"
|
|
2100
2101
|
},
|
|
2101
2102
|
"static": true,
|
|
2102
|
-
"default": "{
|
|
2103
|
+
"default": "{ ...SpectrumElement.shadowRootOptions, delegatesFocus: true, }",
|
|
2103
2104
|
"inheritedFrom": {
|
|
2104
2105
|
"name": "PickerBase",
|
|
2105
2106
|
"module": "src/Picker.js"
|
|
@@ -2465,19 +2466,6 @@
|
|
|
2465
2466
|
"module": "src/Picker.js"
|
|
2466
2467
|
}
|
|
2467
2468
|
},
|
|
2468
|
-
{
|
|
2469
|
-
"kind": "field",
|
|
2470
|
-
"name": "pendingStateController",
|
|
2471
|
-
"type": {
|
|
2472
|
-
"text": "PendingStateController<this>"
|
|
2473
|
-
},
|
|
2474
|
-
"privacy": "public",
|
|
2475
|
-
"default": "new PendingStateController(this)",
|
|
2476
|
-
"inheritedFrom": {
|
|
2477
|
-
"name": "PickerBase",
|
|
2478
|
-
"module": "src/Picker.js"
|
|
2479
|
-
}
|
|
2480
|
-
},
|
|
2481
2469
|
{
|
|
2482
2470
|
"kind": "field",
|
|
2483
2471
|
"name": "_selectedItem",
|
|
@@ -2873,6 +2861,20 @@
|
|
|
2873
2861
|
"module": "src/Picker.js"
|
|
2874
2862
|
}
|
|
2875
2863
|
},
|
|
2864
|
+
{
|
|
2865
|
+
"kind": "method",
|
|
2866
|
+
"name": "renderLoader",
|
|
2867
|
+
"privacy": "protected",
|
|
2868
|
+
"return": {
|
|
2869
|
+
"type": {
|
|
2870
|
+
"text": "TemplateResult"
|
|
2871
|
+
}
|
|
2872
|
+
},
|
|
2873
|
+
"inheritedFrom": {
|
|
2874
|
+
"name": "PickerBase",
|
|
2875
|
+
"module": "src/Picker.js"
|
|
2876
|
+
}
|
|
2877
|
+
},
|
|
2876
2878
|
{
|
|
2877
2879
|
"kind": "field",
|
|
2878
2880
|
"name": "buttonContent",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/picker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -88,20 +88,20 @@
|
|
|
88
88
|
"css"
|
|
89
89
|
],
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@spectrum-web-components/base": "1.
|
|
92
|
-
"@spectrum-web-components/button": "1.
|
|
93
|
-
"@spectrum-web-components/field-label": "1.
|
|
94
|
-
"@spectrum-web-components/icon": "1.
|
|
95
|
-
"@spectrum-web-components/icons-ui": "1.
|
|
96
|
-
"@spectrum-web-components/icons-workflow": "1.
|
|
97
|
-
"@spectrum-web-components/menu": "1.
|
|
98
|
-
"@spectrum-web-components/overlay": "1.
|
|
99
|
-
"@spectrum-web-components/popover": "1.
|
|
100
|
-
"@spectrum-web-components/progress-circle": "1.
|
|
101
|
-
"@spectrum-web-components/reactive-controllers": "1.
|
|
102
|
-
"@spectrum-web-components/shared": "1.
|
|
103
|
-
"@spectrum-web-components/tooltip": "1.
|
|
104
|
-
"@spectrum-web-components/tray": "1.
|
|
91
|
+
"@spectrum-web-components/base": "1.9.0",
|
|
92
|
+
"@spectrum-web-components/button": "1.9.0",
|
|
93
|
+
"@spectrum-web-components/field-label": "1.9.0",
|
|
94
|
+
"@spectrum-web-components/icon": "1.9.0",
|
|
95
|
+
"@spectrum-web-components/icons-ui": "1.9.0",
|
|
96
|
+
"@spectrum-web-components/icons-workflow": "1.9.0",
|
|
97
|
+
"@spectrum-web-components/menu": "1.9.0",
|
|
98
|
+
"@spectrum-web-components/overlay": "1.9.0",
|
|
99
|
+
"@spectrum-web-components/popover": "1.9.0",
|
|
100
|
+
"@spectrum-web-components/progress-circle": "1.9.0",
|
|
101
|
+
"@spectrum-web-components/reactive-controllers": "1.9.0",
|
|
102
|
+
"@spectrum-web-components/shared": "1.9.0",
|
|
103
|
+
"@spectrum-web-components/tooltip": "1.9.0",
|
|
104
|
+
"@spectrum-web-components/tray": "1.9.0"
|
|
105
105
|
},
|
|
106
106
|
"types": "./src/index.d.ts",
|
|
107
107
|
"customElements": "custom-elements.json",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
import { ReactiveController, TemplateResult } from '@spectrum-web-components/base';
|
|
13
|
-
import { AbstractOverlay } from '@spectrum-web-components/overlay/src/AbstractOverlay';
|
|
13
|
+
import { AbstractOverlay } from '@spectrum-web-components/overlay/src/AbstractOverlay.js';
|
|
14
14
|
import { Overlay } from '@spectrum-web-components/overlay/src/Overlay.js';
|
|
15
15
|
import { PickerBase } from './Picker.js';
|
|
16
16
|
export declare enum InteractionTypes {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["InteractionController.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n ReactiveController,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { AbstractOverlay } from '@spectrum-web-components/overlay/src/AbstractOverlay';\nimport { Overlay } from '@spectrum-web-components/overlay/src/Overlay.js';\nimport { PickerBase } from './Picker.dev.js'\n\nexport enum InteractionTypes {\n 'desktop',\n 'mobile',\n}\nexport const SAFARI_FOCUS_RING_CLASS = 'remove-focus-ring-safari-hack';\n\nexport class InteractionController implements ReactiveController {\n abortController!: AbortController;\n\n public preventNextToggle: 'no' | 'maybe' | 'yes' = 'no';\n public pointerdownState = false;\n public enterKeydownOn: EventTarget | null = null;\n\n public container!: TemplateResult;\n\n get activelyOpening(): boolean {\n return false;\n }\n\n private _open = false;\n\n public get open(): boolean {\n return this._open;\n }\n\n /**\n * Set `open`\n */\n public set open(open: boolean) {\n if (this._open === open) return;\n this._open = open;\n\n if (this.overlay) {\n this.host.open = open;\n return;\n }\n\n // When there is no Overlay and `open` is moving to `true`, lazily import/create\n // an Overlay and apply that state to it.\n customElements\n .whenDefined('sp-overlay')\n .then(async (): Promise<void> => {\n const { Overlay } = await import(\n '@spectrum-web-components/overlay/src/Overlay.js'\n );\n this.overlay = new Overlay();\n this.host.open = true;\n this.host.requestUpdate();\n });\n import('@spectrum-web-components/overlay/sp-overlay.js');\n }\n\n private _overlay!: AbstractOverlay;\n\n public get overlay(): AbstractOverlay {\n return this._overlay;\n }\n\n public set overlay(overlay: AbstractOverlay | undefined) {\n if (!overlay) return;\n if (this.overlay === overlay) return;\n this._overlay = overlay;\n this.initOverlay();\n }\n\n type!: InteractionTypes;\n\n constructor(\n public target: HTMLElement,\n public host: PickerBase\n ) {\n this.target = target;\n this.host = host;\n this.host.addController(this);\n this.init();\n }\n\n releaseDescription(): void {}\n\n protected handleBeforetoggle(\n event: Event & {\n target: Overlay;\n newState: 'open' | 'closed';\n }\n ): void {\n if (event.composedPath()[0] !== event.target) {\n return;\n }\n if (event.newState === 'closed') {\n if (this.preventNextToggle === 'no') {\n this.open = false;\n } else if (!this.pointerdownState) {\n // Prevent browser driven closure while opening the Picker\n // and the expected event series has not completed.\n this.overlay?.manuallyKeepOpen();\n }\n }\n if (!this.open) {\n this.host.optionsMenu.updateSelectedItemIndex();\n this.host.optionsMenu.closeDescendentOverlays();\n }\n }\n\n initOverlay(): void {\n if (this.overlay) {\n this.overlay.addEventListener('beforetoggle', (event: Event) => {\n this.handleBeforetoggle(\n event as Event & {\n target: Overlay;\n newState: 'open' | 'closed';\n }\n );\n });\n this.overlay.type =\n this.host.isMobile.matches && !this.host.forcePopover\n ? 'modal'\n : 'auto';\n this.overlay.triggerElement = this.host as HTMLElement;\n this.overlay.placement =\n this.host.isMobile.matches && !this.host.forcePopover\n ? undefined\n : this.host.placement;\n // We should not be applying open is set programmatically via the picker's open.property.\n // Focus should only be applied if a user action causes the menu to open. Otherwise,\n // we could be pulling focus from a user when an picker with an open menu loads.\n this.overlay.receivesFocus = 'false';\n this.overlay.willPreventClose =\n this.preventNextToggle !== 'no' && this.open;\n this.overlay.addEventListener(\n 'slottable-request',\n this.host.handleSlottableRequest\n );\n }\n }\n\n public handlePointerdown(_event: PointerEvent): void {}\n\n public handleButtonFocus(event: FocusEvent): void {\n // When focus comes from a pointer event, and the related target is the Menu,\n // we don't want to reopen the Menu.\n if (\n this.preventNextToggle === 'maybe' &&\n event.relatedTarget === this.host.optionsMenu\n ) {\n this.preventNextToggle = 'yes';\n }\n if (this.preventNextToggle === 'no') this.host.close();\n }\n\n public handleActivate(_event: Event): void {}\n\n /* c8 ignore next 3 */\n init(): void {}\n\n abort(): void {\n this.releaseDescription();\n this.abortController?.abort();\n }\n\n hostConnected(): void {\n this.init();\n this.host.addEventListener('sp-opened', () => {\n /**\n * set shouldSupportDragAndSelect to false for mobile\n * to prevent click event being captured behind the menu-tray\n * we do this here because the menu gets reinitialized on overlay open\n */\n this.host.optionsMenu.shouldSupportDragAndSelect =\n !this.host.isMobile.matches;\n });\n this.host.addEventListener('sp-closed', () => {\n if (\n !this.open &&\n this.host.optionsMenu.matches(':focus-within') &&\n !this.host.button.matches(':focus')\n ) {\n this.host.button.focus();\n }\n });\n }\n\n hostDisconnected(): void {\n this.abortController?.abort();\n }\n\n public hostUpdated(): void {\n if (\n this.overlay &&\n this.host.dependencyManager.loaded &&\n this.host.open !== this.overlay.open\n ) {\n this.overlay.willPreventClose = this.preventNextToggle !== 'no';\n this.overlay.open = this.host.open;\n }\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n ReactiveController,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { AbstractOverlay } from '@spectrum-web-components/overlay/src/AbstractOverlay.js';\nimport { Overlay } from '@spectrum-web-components/overlay/src/Overlay.js';\nimport { PickerBase } from './Picker.dev.js'\n\nexport enum InteractionTypes {\n 'desktop',\n 'mobile',\n}\nexport const SAFARI_FOCUS_RING_CLASS = 'remove-focus-ring-safari-hack';\n\nexport class InteractionController implements ReactiveController {\n abortController!: AbortController;\n\n public preventNextToggle: 'no' | 'maybe' | 'yes' = 'no';\n public pointerdownState = false;\n public enterKeydownOn: EventTarget | null = null;\n\n public container!: TemplateResult;\n\n get activelyOpening(): boolean {\n return false;\n }\n\n private _open = false;\n\n public get open(): boolean {\n return this._open;\n }\n\n /**\n * Set `open`\n */\n public set open(open: boolean) {\n if (this._open === open) return;\n this._open = open;\n\n if (this.overlay) {\n this.host.open = open;\n return;\n }\n\n // When there is no Overlay and `open` is moving to `true`, lazily import/create\n // an Overlay and apply that state to it.\n customElements\n .whenDefined('sp-overlay')\n .then(async (): Promise<void> => {\n const { Overlay } = await import(\n '@spectrum-web-components/overlay/src/Overlay.js'\n );\n this.overlay = new Overlay();\n this.host.open = true;\n this.host.requestUpdate();\n });\n import('@spectrum-web-components/overlay/sp-overlay.js');\n }\n\n private _overlay!: AbstractOverlay;\n\n public get overlay(): AbstractOverlay {\n return this._overlay;\n }\n\n public set overlay(overlay: AbstractOverlay | undefined) {\n if (!overlay) return;\n if (this.overlay === overlay) return;\n this._overlay = overlay;\n this.initOverlay();\n }\n\n type!: InteractionTypes;\n\n constructor(\n public target: HTMLElement,\n public host: PickerBase\n ) {\n this.target = target;\n this.host = host;\n this.host.addController(this);\n this.init();\n }\n\n releaseDescription(): void {}\n\n protected handleBeforetoggle(\n event: Event & {\n target: Overlay;\n newState: 'open' | 'closed';\n }\n ): void {\n if (event.composedPath()[0] !== event.target) {\n return;\n }\n if (event.newState === 'closed') {\n if (this.preventNextToggle === 'no') {\n this.open = false;\n } else if (!this.pointerdownState) {\n // Prevent browser driven closure while opening the Picker\n // and the expected event series has not completed.\n this.overlay?.manuallyKeepOpen();\n }\n }\n if (!this.open) {\n this.host.optionsMenu.updateSelectedItemIndex();\n this.host.optionsMenu.closeDescendentOverlays();\n }\n }\n\n initOverlay(): void {\n if (this.overlay) {\n this.overlay.addEventListener('beforetoggle', (event: Event) => {\n this.handleBeforetoggle(\n event as Event & {\n target: Overlay;\n newState: 'open' | 'closed';\n }\n );\n });\n this.overlay.type =\n this.host.isMobile.matches && !this.host.forcePopover\n ? 'modal'\n : 'auto';\n this.overlay.triggerElement = this.host as HTMLElement;\n this.overlay.placement =\n this.host.isMobile.matches && !this.host.forcePopover\n ? undefined\n : this.host.placement;\n // We should not be applying open is set programmatically via the picker's open.property.\n // Focus should only be applied if a user action causes the menu to open. Otherwise,\n // we could be pulling focus from a user when an picker with an open menu loads.\n this.overlay.receivesFocus = 'false';\n this.overlay.willPreventClose =\n this.preventNextToggle !== 'no' && this.open;\n this.overlay.addEventListener(\n 'slottable-request',\n this.host.handleSlottableRequest\n );\n }\n }\n\n public handlePointerdown(_event: PointerEvent): void {}\n\n public handleButtonFocus(event: FocusEvent): void {\n // When focus comes from a pointer event, and the related target is the Menu,\n // we don't want to reopen the Menu.\n if (\n this.preventNextToggle === 'maybe' &&\n event.relatedTarget === this.host.optionsMenu\n ) {\n this.preventNextToggle = 'yes';\n }\n if (this.preventNextToggle === 'no') this.host.close();\n }\n\n public handleActivate(_event: Event): void {}\n\n /* c8 ignore next 3 */\n init(): void {}\n\n abort(): void {\n this.releaseDescription();\n this.abortController?.abort();\n }\n\n hostConnected(): void {\n this.init();\n this.host.addEventListener('sp-opened', () => {\n /**\n * set shouldSupportDragAndSelect to false for mobile\n * to prevent click event being captured behind the menu-tray\n * we do this here because the menu gets reinitialized on overlay open\n */\n this.host.optionsMenu.shouldSupportDragAndSelect =\n !this.host.isMobile.matches;\n });\n this.host.addEventListener('sp-closed', () => {\n if (\n !this.open &&\n this.host.optionsMenu.matches(':focus-within') &&\n !this.host.button.matches(':focus')\n ) {\n this.host.button.focus();\n }\n });\n }\n\n hostDisconnected(): void {\n this.abortController?.abort();\n }\n\n public hostUpdated(): void {\n if (\n this.overlay &&\n this.host.dependencyManager.loaded &&\n this.host.open !== this.overlay.open\n ) {\n this.overlay.willPreventClose = this.preventNextToggle !== 'no';\n this.overlay.open = this.host.open;\n }\n }\n}\n"],
|
|
5
5
|
"mappings": ";AAoBO,WAAK,mBAAL,kBAAKA,sBAAL;AACH,EAAAA,oCAAA;AACA,EAAAA,oCAAA;AAFQ,SAAAA;AAAA,GAAA;AAIL,aAAM,0BAA0B;AAEhC,aAAM,sBAAoD;AAAA,EA6D7D,YACW,QACA,MACT;AAFS;AACA;AA5DX,SAAO,oBAA4C;AACnD,SAAO,mBAAmB;AAC1B,SAAO,iBAAqC;AAQ5C,SAAQ,QAAQ;AAoDZ,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,KAAK,cAAc,IAAI;AAC5B,SAAK,KAAK;AAAA,EACd;AAAA,EA5DA,IAAI,kBAA2B;AAC3B,WAAO;AAAA,EACX;AAAA,EAIA,IAAW,OAAgB;AAC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C5B,KAAK,KAAK,SAAS,KAAK,QAAQ,MAClC;AACE,WAAK,QAAQ,mBAAmB,KAAK,sBAAsB;AAC3D,WAAK,QAAQ,OAAO,KAAK,KAAK;AAAA,IAClC;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": ["InteractionTypes", "Overlay"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["InteractionController.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n ReactiveController,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { AbstractOverlay } from '@spectrum-web-components/overlay/src/AbstractOverlay';\nimport { Overlay } from '@spectrum-web-components/overlay/src/Overlay.js';\nimport { PickerBase } from './Picker.js';\n\nexport enum InteractionTypes {\n 'desktop',\n 'mobile',\n}\nexport const SAFARI_FOCUS_RING_CLASS = 'remove-focus-ring-safari-hack';\n\nexport class InteractionController implements ReactiveController {\n abortController!: AbortController;\n\n public preventNextToggle: 'no' | 'maybe' | 'yes' = 'no';\n public pointerdownState = false;\n public enterKeydownOn: EventTarget | null = null;\n\n public container!: TemplateResult;\n\n get activelyOpening(): boolean {\n return false;\n }\n\n private _open = false;\n\n public get open(): boolean {\n return this._open;\n }\n\n /**\n * Set `open`\n */\n public set open(open: boolean) {\n if (this._open === open) return;\n this._open = open;\n\n if (this.overlay) {\n this.host.open = open;\n return;\n }\n\n // When there is no Overlay and `open` is moving to `true`, lazily import/create\n // an Overlay and apply that state to it.\n customElements\n .whenDefined('sp-overlay')\n .then(async (): Promise<void> => {\n const { Overlay } = await import(\n '@spectrum-web-components/overlay/src/Overlay.js'\n );\n this.overlay = new Overlay();\n this.host.open = true;\n this.host.requestUpdate();\n });\n import('@spectrum-web-components/overlay/sp-overlay.js');\n }\n\n private _overlay!: AbstractOverlay;\n\n public get overlay(): AbstractOverlay {\n return this._overlay;\n }\n\n public set overlay(overlay: AbstractOverlay | undefined) {\n if (!overlay) return;\n if (this.overlay === overlay) return;\n this._overlay = overlay;\n this.initOverlay();\n }\n\n type!: InteractionTypes;\n\n constructor(\n public target: HTMLElement,\n public host: PickerBase\n ) {\n this.target = target;\n this.host = host;\n this.host.addController(this);\n this.init();\n }\n\n releaseDescription(): void {}\n\n protected handleBeforetoggle(\n event: Event & {\n target: Overlay;\n newState: 'open' | 'closed';\n }\n ): void {\n if (event.composedPath()[0] !== event.target) {\n return;\n }\n if (event.newState === 'closed') {\n if (this.preventNextToggle === 'no') {\n this.open = false;\n } else if (!this.pointerdownState) {\n // Prevent browser driven closure while opening the Picker\n // and the expected event series has not completed.\n this.overlay?.manuallyKeepOpen();\n }\n }\n if (!this.open) {\n this.host.optionsMenu.updateSelectedItemIndex();\n this.host.optionsMenu.closeDescendentOverlays();\n }\n }\n\n initOverlay(): void {\n if (this.overlay) {\n this.overlay.addEventListener('beforetoggle', (event: Event) => {\n this.handleBeforetoggle(\n event as Event & {\n target: Overlay;\n newState: 'open' | 'closed';\n }\n );\n });\n this.overlay.type =\n this.host.isMobile.matches && !this.host.forcePopover\n ? 'modal'\n : 'auto';\n this.overlay.triggerElement = this.host as HTMLElement;\n this.overlay.placement =\n this.host.isMobile.matches && !this.host.forcePopover\n ? undefined\n : this.host.placement;\n // We should not be applying open is set programmatically via the picker's open.property.\n // Focus should only be applied if a user action causes the menu to open. Otherwise,\n // we could be pulling focus from a user when an picker with an open menu loads.\n this.overlay.receivesFocus = 'false';\n this.overlay.willPreventClose =\n this.preventNextToggle !== 'no' && this.open;\n this.overlay.addEventListener(\n 'slottable-request',\n this.host.handleSlottableRequest\n );\n }\n }\n\n public handlePointerdown(_event: PointerEvent): void {}\n\n public handleButtonFocus(event: FocusEvent): void {\n // When focus comes from a pointer event, and the related target is the Menu,\n // we don't want to reopen the Menu.\n if (\n this.preventNextToggle === 'maybe' &&\n event.relatedTarget === this.host.optionsMenu\n ) {\n this.preventNextToggle = 'yes';\n }\n if (this.preventNextToggle === 'no') this.host.close();\n }\n\n public handleActivate(_event: Event): void {}\n\n /* c8 ignore next 3 */\n init(): void {}\n\n abort(): void {\n this.releaseDescription();\n this.abortController?.abort();\n }\n\n hostConnected(): void {\n this.init();\n this.host.addEventListener('sp-opened', () => {\n /**\n * set shouldSupportDragAndSelect to false for mobile\n * to prevent click event being captured behind the menu-tray\n * we do this here because the menu gets reinitialized on overlay open\n */\n this.host.optionsMenu.shouldSupportDragAndSelect =\n !this.host.isMobile.matches;\n });\n this.host.addEventListener('sp-closed', () => {\n if (\n !this.open &&\n this.host.optionsMenu.matches(':focus-within') &&\n !this.host.button.matches(':focus')\n ) {\n this.host.button.focus();\n }\n });\n }\n\n hostDisconnected(): void {\n this.abortController?.abort();\n }\n\n public hostUpdated(): void {\n if (\n this.overlay &&\n this.host.dependencyManager.loaded &&\n this.host.open !== this.overlay.open\n ) {\n this.overlay.willPreventClose = this.preventNextToggle !== 'no';\n this.overlay.open = this.host.open;\n }\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n ReactiveController,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { AbstractOverlay } from '@spectrum-web-components/overlay/src/AbstractOverlay.js';\nimport { Overlay } from '@spectrum-web-components/overlay/src/Overlay.js';\nimport { PickerBase } from './Picker.js';\n\nexport enum InteractionTypes {\n 'desktop',\n 'mobile',\n}\nexport const SAFARI_FOCUS_RING_CLASS = 'remove-focus-ring-safari-hack';\n\nexport class InteractionController implements ReactiveController {\n abortController!: AbortController;\n\n public preventNextToggle: 'no' | 'maybe' | 'yes' = 'no';\n public pointerdownState = false;\n public enterKeydownOn: EventTarget | null = null;\n\n public container!: TemplateResult;\n\n get activelyOpening(): boolean {\n return false;\n }\n\n private _open = false;\n\n public get open(): boolean {\n return this._open;\n }\n\n /**\n * Set `open`\n */\n public set open(open: boolean) {\n if (this._open === open) return;\n this._open = open;\n\n if (this.overlay) {\n this.host.open = open;\n return;\n }\n\n // When there is no Overlay and `open` is moving to `true`, lazily import/create\n // an Overlay and apply that state to it.\n customElements\n .whenDefined('sp-overlay')\n .then(async (): Promise<void> => {\n const { Overlay } = await import(\n '@spectrum-web-components/overlay/src/Overlay.js'\n );\n this.overlay = new Overlay();\n this.host.open = true;\n this.host.requestUpdate();\n });\n import('@spectrum-web-components/overlay/sp-overlay.js');\n }\n\n private _overlay!: AbstractOverlay;\n\n public get overlay(): AbstractOverlay {\n return this._overlay;\n }\n\n public set overlay(overlay: AbstractOverlay | undefined) {\n if (!overlay) return;\n if (this.overlay === overlay) return;\n this._overlay = overlay;\n this.initOverlay();\n }\n\n type!: InteractionTypes;\n\n constructor(\n public target: HTMLElement,\n public host: PickerBase\n ) {\n this.target = target;\n this.host = host;\n this.host.addController(this);\n this.init();\n }\n\n releaseDescription(): void {}\n\n protected handleBeforetoggle(\n event: Event & {\n target: Overlay;\n newState: 'open' | 'closed';\n }\n ): void {\n if (event.composedPath()[0] !== event.target) {\n return;\n }\n if (event.newState === 'closed') {\n if (this.preventNextToggle === 'no') {\n this.open = false;\n } else if (!this.pointerdownState) {\n // Prevent browser driven closure while opening the Picker\n // and the expected event series has not completed.\n this.overlay?.manuallyKeepOpen();\n }\n }\n if (!this.open) {\n this.host.optionsMenu.updateSelectedItemIndex();\n this.host.optionsMenu.closeDescendentOverlays();\n }\n }\n\n initOverlay(): void {\n if (this.overlay) {\n this.overlay.addEventListener('beforetoggle', (event: Event) => {\n this.handleBeforetoggle(\n event as Event & {\n target: Overlay;\n newState: 'open' | 'closed';\n }\n );\n });\n this.overlay.type =\n this.host.isMobile.matches && !this.host.forcePopover\n ? 'modal'\n : 'auto';\n this.overlay.triggerElement = this.host as HTMLElement;\n this.overlay.placement =\n this.host.isMobile.matches && !this.host.forcePopover\n ? undefined\n : this.host.placement;\n // We should not be applying open is set programmatically via the picker's open.property.\n // Focus should only be applied if a user action causes the menu to open. Otherwise,\n // we could be pulling focus from a user when an picker with an open menu loads.\n this.overlay.receivesFocus = 'false';\n this.overlay.willPreventClose =\n this.preventNextToggle !== 'no' && this.open;\n this.overlay.addEventListener(\n 'slottable-request',\n this.host.handleSlottableRequest\n );\n }\n }\n\n public handlePointerdown(_event: PointerEvent): void {}\n\n public handleButtonFocus(event: FocusEvent): void {\n // When focus comes from a pointer event, and the related target is the Menu,\n // we don't want to reopen the Menu.\n if (\n this.preventNextToggle === 'maybe' &&\n event.relatedTarget === this.host.optionsMenu\n ) {\n this.preventNextToggle = 'yes';\n }\n if (this.preventNextToggle === 'no') this.host.close();\n }\n\n public handleActivate(_event: Event): void {}\n\n /* c8 ignore next 3 */\n init(): void {}\n\n abort(): void {\n this.releaseDescription();\n this.abortController?.abort();\n }\n\n hostConnected(): void {\n this.init();\n this.host.addEventListener('sp-opened', () => {\n /**\n * set shouldSupportDragAndSelect to false for mobile\n * to prevent click event being captured behind the menu-tray\n * we do this here because the menu gets reinitialized on overlay open\n */\n this.host.optionsMenu.shouldSupportDragAndSelect =\n !this.host.isMobile.matches;\n });\n this.host.addEventListener('sp-closed', () => {\n if (\n !this.open &&\n this.host.optionsMenu.matches(':focus-within') &&\n !this.host.button.matches(':focus')\n ) {\n this.host.button.focus();\n }\n });\n }\n\n hostDisconnected(): void {\n this.abortController?.abort();\n }\n\n public hostUpdated(): void {\n if (\n this.overlay &&\n this.host.dependencyManager.loaded &&\n this.host.open !== this.overlay.open\n ) {\n this.overlay.willPreventClose = this.preventNextToggle !== 'no';\n this.overlay.open = this.host.open;\n }\n }\n}\n"],
|
|
5
5
|
"mappings": "aAoBO,WAAK,kBAAAA,IACRA,IAAA,qBACAA,IAAA,mBAFQA,IAAA,sBAIL,aAAM,wBAA0B,gCAEhC,aAAM,qBAAoD,CA6D7D,YACWC,EACAC,EACT,CAFS,YAAAD,EACA,UAAAC,EA5DX,KAAO,kBAA4C,KACnD,KAAO,iBAAmB,GAC1B,KAAO,eAAqC,KAQ5C,KAAQ,MAAQ,GAoDZ,KAAK,OAASD,EACd,KAAK,KAAOC,EACZ,KAAK,KAAK,cAAc,IAAI,EAC5B,KAAK,KAAK,CACd,CA5DA,IAAI,iBAA2B,CAC3B,MAAO,EACX,CAIA,IAAW,MAAgB,CACvB,OAAO,KAAK,KAChB,CAKA,IAAW,KAAKC,EAAe,CAC3B,GAAI,KAAK,QAAUA,EAGnB,IAFA,KAAK,MAAQA,EAET,KAAK,QAAS,CACd,KAAK,KAAK,KAAOA,EACjB,MACJ,CAIA,eACK,YAAY,YAAY,EACxB,KAAK,SAA2B,CAC7B,KAAM,CAAE,QAAAC,CAAQ,EAAI,KAAM,QACtB,iDACJ,EACA,KAAK,QAAU,IAAIA,EACnB,KAAK,KAAK,KAAO,GACjB,KAAK,KAAK,cAAc,CAC5B,CAAC,EACL,OAAO,gDAAgD,EAC3D,CAIA,IAAW,SAA2B,CAClC,OAAO,KAAK,QAChB,CAEA,IAAW,QAAQC,EAAsC,CAChDA,GACD,KAAK,UAAYA,IACrB,KAAK,SAAWA,EAChB,KAAK,YAAY,EACrB,CAcA,oBAA2B,CAAC,CAElB,mBACNC,EAII,CAxGZ,IAAAC,EAyGYD,EAAM,aAAa,EAAE,CAAC,IAAMA,E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AAQ,QAAQ,GAElC,KAAK,KAAK,OAAO,MAAM,CAE/B,CAAC,CACL,CAEA,kBAAyB,CAzM7B,IAAAA,GA0MQA,EAAA,KAAK,kBAAL,MAAAA,EAAsB,OAC1B,CAEO,aAAoB,CAEnB,KAAK,SACL,KAAK,KAAK,kBAAkB,QAC5B,KAAK,KAAK,OAAS,KAAK,QAAQ,OAEhC,KAAK,QAAQ,iBAAmB,KAAK,oBAAsB,KAC3D,KAAK,QAAQ,KAAO,KAAK,KAAK,KAEtC,CACJ",
|
|
6
6
|
"names": ["InteractionTypes", "target", "host", "open", "Overlay", "overlay", "event", "_a", "_event"]
|
|
7
7
|
}
|
package/src/Picker.d.ts
CHANGED
|
@@ -11,19 +11,17 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
|
|
13
13
|
import { StyleInfo } from '@spectrum-web-components/base/src/directives.js';
|
|
14
|
-
import type {
|
|
14
|
+
import type { FieldLabel } from '@spectrum-web-components/field-label';
|
|
15
15
|
import '@spectrum-web-components/icons-ui/icons/sp-icon-chevron100.js';
|
|
16
16
|
import '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';
|
|
17
|
+
import type { Menu, MenuItem, MenuItemChildren, MenuItemKeydownEvent } from '@spectrum-web-components/menu';
|
|
17
18
|
import '@spectrum-web-components/menu/sp-menu.js';
|
|
18
|
-
import type { Menu, MenuItem, MenuItemChildren } from '@spectrum-web-components/menu';
|
|
19
|
-
import type { MenuItemKeydownEvent } from '@spectrum-web-components/menu';
|
|
20
19
|
import { Placement } from '@spectrum-web-components/overlay';
|
|
21
|
-
import { MatchMediaController } from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';
|
|
22
|
-
import { DependencyManagerController } from '@spectrum-web-components/reactive-controllers/src/DependencyManger.js';
|
|
23
|
-
import { PendingStateController } from '@spectrum-web-components/reactive-controllers/src/PendingState.js';
|
|
24
20
|
import { Overlay } from '@spectrum-web-components/overlay/src/Overlay.js';
|
|
25
21
|
import type { SlottableRequestEvent } from '@spectrum-web-components/overlay/src/slottable-request-event.js';
|
|
26
|
-
import
|
|
22
|
+
import { DependencyManagerController } from '@spectrum-web-components/reactive-controllers/src/DependencyManger.js';
|
|
23
|
+
import { MatchMediaController } from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';
|
|
24
|
+
import type { Tooltip } from '@spectrum-web-components/tooltip';
|
|
27
25
|
import { DesktopController } from './DesktopController.js';
|
|
28
26
|
import { MobileController } from './MobileController.js';
|
|
29
27
|
export declare const DESCRIPTION_ID = "option-picker";
|
|
@@ -87,12 +85,6 @@ export declare class PickerBase extends PickerBase_base {
|
|
|
87
85
|
quiet: boolean;
|
|
88
86
|
value: string;
|
|
89
87
|
get selectedItem(): MenuItem | undefined;
|
|
90
|
-
pendingStateController: PendingStateController<this>;
|
|
91
|
-
/**
|
|
92
|
-
* Initializes the `PendingStateController` for the Picker component.
|
|
93
|
-
* The `PendingStateController` manages the pending state of the Picker.
|
|
94
|
-
*/
|
|
95
|
-
constructor();
|
|
96
88
|
set selectedItem(selectedItem: MenuItem | undefined);
|
|
97
89
|
_selectedItem?: MenuItem;
|
|
98
90
|
protected listRole: 'listbox' | 'menu';
|
|
@@ -126,6 +118,7 @@ export declare class PickerBase extends PickerBase_base {
|
|
|
126
118
|
}): void;
|
|
127
119
|
handleSlottableRequest: (_event: SlottableRequestEvent) => void;
|
|
128
120
|
protected renderLabelContent(content: Node[]): TemplateResult | Node[];
|
|
121
|
+
protected renderLoader(): TemplateResult;
|
|
129
122
|
protected get buttonContent(): TemplateResult[];
|
|
130
123
|
applyFocusElementLabel: (value: string, labelElement: FieldLabel) => void;
|
|
131
124
|
protected hasAccessibleLabel(): boolean;
|
package/src/Picker.dev.js
CHANGED
|
@@ -16,27 +16,26 @@ import {
|
|
|
16
16
|
SizedMixin,
|
|
17
17
|
SpectrumElement
|
|
18
18
|
} from "@spectrum-web-components/base";
|
|
19
|
-
import {
|
|
20
|
-
classMap,
|
|
21
|
-
ifDefined,
|
|
22
|
-
styleMap
|
|
23
|
-
} from "@spectrum-web-components/base/src/directives.js";
|
|
24
19
|
import {
|
|
25
20
|
property,
|
|
26
21
|
query,
|
|
27
22
|
state
|
|
28
23
|
} from "@spectrum-web-components/base/src/decorators.js";
|
|
29
|
-
import
|
|
24
|
+
import {
|
|
25
|
+
classMap,
|
|
26
|
+
ifDefined,
|
|
27
|
+
styleMap
|
|
28
|
+
} from "@spectrum-web-components/base/src/directives.js";
|
|
30
29
|
import chevronStyles from "@spectrum-web-components/icon/src/spectrum-icon-chevron.css.js";
|
|
31
30
|
import "@spectrum-web-components/icons-ui/icons/sp-icon-chevron100.js";
|
|
32
31
|
import "@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js";
|
|
33
32
|
import "@spectrum-web-components/menu/sp-menu.js";
|
|
33
|
+
import { DependencyManagerController } from "@spectrum-web-components/reactive-controllers/src/DependencyManger.js";
|
|
34
34
|
import {
|
|
35
35
|
IS_MOBILE,
|
|
36
36
|
MatchMediaController
|
|
37
37
|
} from "@spectrum-web-components/reactive-controllers/src/MatchMedia.js";
|
|
38
|
-
import
|
|
39
|
-
import { PendingStateController } from "@spectrum-web-components/reactive-controllers/src/PendingState.js";
|
|
38
|
+
import pickerStyles from "./picker.css.js";
|
|
40
39
|
import { strategies } from "./strategies.dev.js";
|
|
41
40
|
const chevronClass = {
|
|
42
41
|
s: "spectrum-UIIcon-ChevronDown75",
|
|
@@ -48,12 +47,8 @@ export const DESCRIPTION_ID = "option-picker";
|
|
|
48
47
|
export class PickerBase extends SizedMixin(SpectrumElement, {
|
|
49
48
|
noDefaultSize: true
|
|
50
49
|
}) {
|
|
51
|
-
/**
|
|
52
|
-
* Initializes the `PendingStateController` for the Picker component.
|
|
53
|
-
* The `PendingStateController` manages the pending state of the Picker.
|
|
54
|
-
*/
|
|
55
50
|
constructor() {
|
|
56
|
-
super();
|
|
51
|
+
super(...arguments);
|
|
57
52
|
this.isMobile = new MatchMediaController(this, IS_MOBILE);
|
|
58
53
|
this.dependencyManager = new DependencyManagerController(this);
|
|
59
54
|
this.deprecatedMenu = null;
|
|
@@ -132,7 +127,6 @@ export class PickerBase extends SizedMixin(SpectrumElement, {
|
|
|
132
127
|
{ once: true }
|
|
133
128
|
);
|
|
134
129
|
};
|
|
135
|
-
this.pendingStateController = new PendingStateController(this);
|
|
136
130
|
}
|
|
137
131
|
get menuItems() {
|
|
138
132
|
return this.optionsMenu.childItems;
|
|
@@ -315,7 +309,16 @@ export class PickerBase extends SizedMixin(SpectrumElement, {
|
|
|
315
309
|
this.requestUpdate("selectedItemContent", oldContent);
|
|
316
310
|
}
|
|
317
311
|
handleTooltipSlotchange(event) {
|
|
312
|
+
var _a;
|
|
318
313
|
this.tooltipEl = event.target.assignedElements()[0];
|
|
314
|
+
if ((_a = this.tooltipEl) == null ? void 0 : _a.selfManaged) {
|
|
315
|
+
this.updateComplete.then(() => {
|
|
316
|
+
var _a2;
|
|
317
|
+
if (((_a2 = this.tooltipEl) == null ? void 0 : _a2.overlayElement) && this.button) {
|
|
318
|
+
this.tooltipEl.overlayElement.triggerElement = this.button;
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
319
322
|
}
|
|
320
323
|
renderLabelContent(content) {
|
|
321
324
|
if (this.value && this.selectedItem) {
|
|
@@ -333,6 +336,17 @@ export class PickerBase extends SizedMixin(SpectrumElement, {
|
|
|
333
336
|
</slot>
|
|
334
337
|
`;
|
|
335
338
|
}
|
|
339
|
+
renderLoader() {
|
|
340
|
+
import("@spectrum-web-components/progress-circle/sp-progress-circle.js");
|
|
341
|
+
return html`
|
|
342
|
+
<sp-progress-circle
|
|
343
|
+
size="s"
|
|
344
|
+
indeterminate
|
|
345
|
+
role="presentation"
|
|
346
|
+
class="progress-circle"
|
|
347
|
+
></sp-progress-circle>
|
|
348
|
+
`;
|
|
349
|
+
}
|
|
336
350
|
get buttonContent() {
|
|
337
351
|
const labelClasses = {
|
|
338
352
|
"visually-hidden": this.icons === "only" && !!this.value,
|
|
@@ -370,7 +384,16 @@ export class PickerBase extends SizedMixin(SpectrumElement, {
|
|
|
370
384
|
class="validation-icon"
|
|
371
385
|
></sp-icon-alert>
|
|
372
386
|
` : nothing}
|
|
373
|
-
${this.
|
|
387
|
+
${this.pending ? html`
|
|
388
|
+
${this.renderLoader()}
|
|
389
|
+
<span
|
|
390
|
+
aria-hidden="true"
|
|
391
|
+
class="visually-hidden"
|
|
392
|
+
id="pending-label"
|
|
393
|
+
>
|
|
394
|
+
${this.pendingLabel}
|
|
395
|
+
</span>
|
|
396
|
+
` : nothing}
|
|
374
397
|
<sp-icon-chevron100
|
|
375
398
|
class="picker ${chevronClass[this.size]}"
|
|
376
399
|
></sp-icon-chevron100>
|
|
@@ -428,7 +451,7 @@ export class PickerBase extends SizedMixin(SpectrumElement, {
|
|
|
428
451
|
aria-describedby="tooltip ${DESCRIPTION_ID}"
|
|
429
452
|
aria-expanded=${this.open ? "true" : "false"}
|
|
430
453
|
aria-haspopup="true"
|
|
431
|
-
aria-labelledby="
|
|
454
|
+
aria-labelledby="icon label applied-label pending-label"
|
|
432
455
|
id="button"
|
|
433
456
|
class=${ifDefined(
|
|
434
457
|
this.labelAlignment ? `label-${this.labelAlignment}` : void 0
|