@spectrum-web-components/shared 0.0.0-20241209155954

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.
Files changed (72) hide show
  1. package/README.md +132 -0
  2. package/package.json +112 -0
  3. package/src/first-focusable-in.d.ts +3 -0
  4. package/src/first-focusable-in.dev.js +15 -0
  5. package/src/first-focusable-in.dev.js.map +7 -0
  6. package/src/first-focusable-in.js +2 -0
  7. package/src/first-focusable-in.js.map +7 -0
  8. package/src/focus-visible.d.ts +29 -0
  9. package/src/focus-visible.dev.js +77 -0
  10. package/src/focus-visible.dev.js.map +7 -0
  11. package/src/focus-visible.js +2 -0
  12. package/src/focus-visible.js.map +7 -0
  13. package/src/focusable-selectors.d.ts +2 -0
  14. package/src/focusable-selectors.dev.js +15 -0
  15. package/src/focusable-selectors.dev.js.map +7 -0
  16. package/src/focusable-selectors.js +2 -0
  17. package/src/focusable-selectors.js.map +7 -0
  18. package/src/focusable.d.ts +56 -0
  19. package/src/focusable.dev.js +245 -0
  20. package/src/focusable.dev.js.map +7 -0
  21. package/src/focusable.js +2 -0
  22. package/src/focusable.js.map +7 -0
  23. package/src/get-active-element.d.ts +1 -0
  24. package/src/get-active-element.dev.js +5 -0
  25. package/src/get-active-element.dev.js.map +7 -0
  26. package/src/get-active-element.js +2 -0
  27. package/src/get-active-element.js.map +7 -0
  28. package/src/get-deep-element-from-point.d.ts +1 -0
  29. package/src/get-deep-element-from-point.dev.js +13 -0
  30. package/src/get-deep-element-from-point.dev.js.map +7 -0
  31. package/src/get-deep-element-from-point.js +2 -0
  32. package/src/get-deep-element-from-point.js.map +7 -0
  33. package/src/get-label-from-slot.d.ts +1 -0
  34. package/src/get-label-from-slot.dev.js +17 -0
  35. package/src/get-label-from-slot.dev.js.map +7 -0
  36. package/src/get-label-from-slot.js +2 -0
  37. package/src/get-label-from-slot.js.map +7 -0
  38. package/src/index.d.ts +12 -0
  39. package/src/index.dev.js +14 -0
  40. package/src/index.dev.js.map +7 -0
  41. package/src/index.js +2 -0
  42. package/src/index.js.map +7 -0
  43. package/src/like-anchor.d.ts +23 -0
  44. package/src/like-anchor.dev.js +63 -0
  45. package/src/like-anchor.dev.js.map +7 -0
  46. package/src/like-anchor.js +14 -0
  47. package/src/like-anchor.js.map +7 -0
  48. package/src/observe-slot-presence.d.ts +12 -0
  49. package/src/observe-slot-presence.dev.js +63 -0
  50. package/src/observe-slot-presence.dev.js.map +7 -0
  51. package/src/observe-slot-presence.js +2 -0
  52. package/src/observe-slot-presence.js.map +7 -0
  53. package/src/observe-slot-text.d.ts +11 -0
  54. package/src/observe-slot-text.dev.js +95 -0
  55. package/src/observe-slot-text.dev.js.map +7 -0
  56. package/src/observe-slot-text.js +2 -0
  57. package/src/observe-slot-text.js.map +7 -0
  58. package/src/platform.d.ts +10 -0
  59. package/src/platform.dev.js +39 -0
  60. package/src/platform.dev.js.map +7 -0
  61. package/src/platform.js +2 -0
  62. package/src/platform.js.map +7 -0
  63. package/src/random-id.d.ts +1 -0
  64. package/src/random-id.dev.js +8 -0
  65. package/src/random-id.dev.js.map +7 -0
  66. package/src/random-id.js +2 -0
  67. package/src/random-id.js.map +7 -0
  68. package/src/reparent-children.d.ts +4 -0
  69. package/src/reparent-children.dev.js +57 -0
  70. package/src/reparent-children.dev.js.map +7 -0
  71. package/src/reparent-children.js +2 -0
  72. package/src/reparent-children.js.map +7 -0
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __decorateClass = (decorators, target, key, kind) => {
5
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
6
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
7
+ if (decorator = decorators[i])
8
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
+ if (kind && result) __defProp(target, key, result);
10
+ return result;
11
+ };
12
+ import { SpectrumElement } from "@spectrum-web-components/base";
13
+ import { property } from "@spectrum-web-components/base/src/decorators.js";
14
+ import { FocusVisiblePolyfillMixin } from "./focus-visible.dev.js";
15
+ function nextFrame() {
16
+ return new Promise((res) => requestAnimationFrame(() => res()));
17
+ }
18
+ export class Focusable extends FocusVisiblePolyfillMixin(SpectrumElement) {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.disabled = false;
22
+ this.autofocus = false;
23
+ this._tabIndex = 0;
24
+ this.manipulatingTabindex = false;
25
+ this.autofocusReady = Promise.resolve();
26
+ }
27
+ get tabIndex() {
28
+ if (this.focusElement === this) {
29
+ const tabindex = this.hasAttribute("tabindex") ? Number(this.getAttribute("tabindex")) : NaN;
30
+ return !isNaN(tabindex) ? tabindex : -1;
31
+ }
32
+ const tabIndexAttribute = parseFloat(
33
+ this.hasAttribute("tabindex") ? this.getAttribute("tabindex") || "0" : "0"
34
+ );
35
+ if (this.disabled || tabIndexAttribute < 0) {
36
+ return -1;
37
+ }
38
+ if (!this.focusElement) {
39
+ return tabIndexAttribute;
40
+ }
41
+ return this._tabIndex;
42
+ }
43
+ set tabIndex(tabIndex) {
44
+ var _a;
45
+ if (this.manipulatingTabindex) {
46
+ this.manipulatingTabindex = false;
47
+ return;
48
+ }
49
+ if (this.focusElement === this) {
50
+ if (this.disabled) {
51
+ this._tabIndex = tabIndex;
52
+ } else if (tabIndex !== this._tabIndex) {
53
+ this._tabIndex = tabIndex;
54
+ const tabindex = "" + tabIndex;
55
+ this.manipulatingTabindex = true;
56
+ this.setAttribute("tabindex", tabindex);
57
+ }
58
+ return;
59
+ }
60
+ if (tabIndex === -1) {
61
+ this.addEventListener(
62
+ "pointerdown",
63
+ this.onPointerdownManagementOfTabIndex
64
+ );
65
+ } else {
66
+ this.manipulatingTabindex = true;
67
+ this.removeEventListener(
68
+ "pointerdown",
69
+ this.onPointerdownManagementOfTabIndex
70
+ );
71
+ }
72
+ if (tabIndex === -1 || this.disabled) {
73
+ this.manipulatingTabindex = true;
74
+ this.setAttribute("tabindex", "-1");
75
+ this.removeAttribute("focusable");
76
+ if (this.selfManageFocusElement) {
77
+ return;
78
+ }
79
+ if (tabIndex !== -1) {
80
+ this._tabIndex = tabIndex;
81
+ this.manageFocusElementTabindex(tabIndex);
82
+ } else {
83
+ (_a = this.focusElement) == null ? void 0 : _a.removeAttribute("tabindex");
84
+ }
85
+ return;
86
+ }
87
+ this.setAttribute("focusable", "");
88
+ if (this.hasAttribute("tabindex")) {
89
+ this.removeAttribute("tabindex");
90
+ } else {
91
+ this.manipulatingTabindex = false;
92
+ }
93
+ this._tabIndex = tabIndex;
94
+ this.manageFocusElementTabindex(tabIndex);
95
+ }
96
+ onPointerdownManagementOfTabIndex() {
97
+ if (this.tabIndex === -1) {
98
+ setTimeout(() => {
99
+ this.tabIndex = 0;
100
+ this.focus({ preventScroll: true });
101
+ this.tabIndex = -1;
102
+ });
103
+ }
104
+ }
105
+ async manageFocusElementTabindex(tabIndex) {
106
+ if (!this.focusElement) {
107
+ await this.updateComplete;
108
+ }
109
+ if (tabIndex === null) {
110
+ this.focusElement.removeAttribute("tabindex");
111
+ } else {
112
+ if (this.focusElement !== this) {
113
+ this.focusElement.tabIndex = tabIndex;
114
+ }
115
+ }
116
+ }
117
+ /**
118
+ * @private
119
+ */
120
+ get focusElement() {
121
+ throw new Error("Must implement focusElement getter!");
122
+ }
123
+ /**
124
+ * @public
125
+ * @returns {boolean} whether the component should manage its focusElement tab-index or not
126
+ * Needed for action-menu to be supported in action-group in an accessible way
127
+ */
128
+ get selfManageFocusElement() {
129
+ return false;
130
+ }
131
+ focus(options) {
132
+ if (this.disabled || !this.focusElement) {
133
+ return;
134
+ }
135
+ if (this.focusElement !== this) {
136
+ this.focusElement.focus(options);
137
+ } else {
138
+ HTMLElement.prototype.focus.apply(this, [options]);
139
+ }
140
+ }
141
+ blur() {
142
+ const focusElement = this.focusElement || this;
143
+ if (focusElement !== this) {
144
+ focusElement.blur();
145
+ } else {
146
+ HTMLElement.prototype.blur.apply(this);
147
+ }
148
+ }
149
+ click() {
150
+ if (this.disabled) {
151
+ return;
152
+ }
153
+ const focusElement = this.focusElement || this;
154
+ if (focusElement !== this) {
155
+ focusElement.click();
156
+ } else {
157
+ HTMLElement.prototype.click.apply(this);
158
+ }
159
+ }
160
+ manageAutoFocus() {
161
+ if (this.autofocus) {
162
+ this.dispatchEvent(
163
+ new KeyboardEvent("keydown", {
164
+ code: "Tab"
165
+ })
166
+ );
167
+ this.focusElement.focus();
168
+ }
169
+ }
170
+ firstUpdated(changes) {
171
+ super.firstUpdated(changes);
172
+ if (!this.hasAttribute("tabindex") || this.getAttribute("tabindex") !== "-1") {
173
+ this.setAttribute("focusable", "");
174
+ }
175
+ }
176
+ update(changedProperties) {
177
+ if (changedProperties.has("disabled")) {
178
+ this.handleDisabledChanged(
179
+ this.disabled,
180
+ changedProperties.get("disabled")
181
+ );
182
+ }
183
+ super.update(changedProperties);
184
+ }
185
+ updated(changedProperties) {
186
+ super.updated(changedProperties);
187
+ if (changedProperties.has("disabled") && this.disabled) {
188
+ this.blur();
189
+ }
190
+ }
191
+ async handleDisabledChanged(disabled, oldDisabled) {
192
+ const canSetDisabled = () => this.focusElement !== this && typeof this.focusElement.disabled !== "undefined";
193
+ if (disabled) {
194
+ this.manipulatingTabindex = true;
195
+ this.setAttribute("tabindex", "-1");
196
+ await this.updateComplete;
197
+ if (canSetDisabled()) {
198
+ this.focusElement.disabled = true;
199
+ } else {
200
+ this.setAttribute("aria-disabled", "true");
201
+ }
202
+ } else if (oldDisabled) {
203
+ this.manipulatingTabindex = true;
204
+ if (this.focusElement === this) {
205
+ this.setAttribute("tabindex", "" + this._tabIndex);
206
+ } else {
207
+ this.removeAttribute("tabindex");
208
+ }
209
+ await this.updateComplete;
210
+ if (canSetDisabled()) {
211
+ this.focusElement.disabled = false;
212
+ } else {
213
+ this.removeAttribute("aria-disabled");
214
+ }
215
+ }
216
+ }
217
+ async getUpdateComplete() {
218
+ const complete = await super.getUpdateComplete();
219
+ await this.autofocusReady;
220
+ return complete;
221
+ }
222
+ connectedCallback() {
223
+ super.connectedCallback();
224
+ if (this.autofocus) {
225
+ this.autofocusReady = new Promise(async (res) => {
226
+ await nextFrame();
227
+ await nextFrame();
228
+ res();
229
+ });
230
+ this.updateComplete.then(() => {
231
+ this.manageAutoFocus();
232
+ });
233
+ }
234
+ }
235
+ }
236
+ __decorateClass([
237
+ property({ type: Boolean, reflect: true })
238
+ ], Focusable.prototype, "disabled", 2);
239
+ __decorateClass([
240
+ property({ type: Boolean })
241
+ ], Focusable.prototype, "autofocus", 2);
242
+ __decorateClass([
243
+ property({ type: Number })
244
+ ], Focusable.prototype, "tabIndex", 1);
245
+ //# sourceMappingURL=focusable.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["focusable.ts"],
4
+ "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*/\nimport { PropertyValues, SpectrumElement } from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { FocusVisiblePolyfillMixin } from './focus-visible.dev.js'\n\ntype DisableableElement = HTMLElement & { disabled?: boolean };\n\nfunction nextFrame(): Promise<void> {\n return new Promise((res) => requestAnimationFrame(() => res()));\n}\n\n/**\n * Focusable base class handles tabindex setting into shadowed elements automatically.\n *\n * This implementation is based heavily on the aybolit delegate-focus-mixin at\n * https://github.com/web-padawan/aybolit/blob/master/packages/core/src/mixins/delegate-focus-mixin.js\n */\nexport class Focusable extends FocusVisiblePolyfillMixin(SpectrumElement) {\n /**\n * Disable this control. It will not receive focus or events\n */\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n /**\n * When this control is rendered, focus it automatically\n * @private\n */\n @property({ type: Boolean })\n public override autofocus = false;\n\n /**\n * The tab index to apply to this control. See general documentation about\n * the tabindex HTML property\n *\n * @private\n */\n @property({ type: Number })\n public override get tabIndex(): number {\n if (this.focusElement === this) {\n const tabindex = this.hasAttribute('tabindex')\n ? Number(this.getAttribute('tabindex'))\n : NaN;\n return !isNaN(tabindex) ? tabindex : -1;\n }\n const tabIndexAttribute = parseFloat(\n this.hasAttribute('tabindex')\n ? (this.getAttribute('tabindex') as string) || '0'\n : '0'\n );\n // When `disabled` tabindex is -1.\n // When host tabindex -1, use that as the cache.\n if (this.disabled || tabIndexAttribute < 0) {\n return -1;\n }\n // When `focusElement` isn't available yet,\n // use host tabindex as the cache.\n if (!this.focusElement) {\n return tabIndexAttribute;\n }\n // All other times, use the tabindex of `focusElement`\n // as the cache for this value.\n // return this.focusElement.tabIndex;\n return this._tabIndex;\n }\n public override set tabIndex(tabIndex: number) {\n // Flipping `manipulatingTabindex` to true before a change\n // allows for that change NOT to effect the cached value of tabindex\n if (this.manipulatingTabindex) {\n this.manipulatingTabindex = false;\n return;\n }\n\n if (this.focusElement === this) {\n if (this.disabled) {\n this._tabIndex = tabIndex;\n } else if (tabIndex !== this._tabIndex) {\n this._tabIndex = tabIndex;\n const tabindex = '' + tabIndex;\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', tabindex);\n }\n return;\n }\n\n if (tabIndex === -1) {\n this.addEventListener(\n 'pointerdown',\n this.onPointerdownManagementOfTabIndex\n );\n } else {\n // All code paths are about to address the host tabindex without side effect.\n this.manipulatingTabindex = true;\n this.removeEventListener(\n 'pointerdown',\n this.onPointerdownManagementOfTabIndex\n );\n }\n\n if (tabIndex === -1 || this.disabled) {\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', '-1');\n this.removeAttribute('focusable');\n\n if (this.selfManageFocusElement) {\n return;\n }\n\n if (tabIndex !== -1) {\n this._tabIndex = tabIndex;\n this.manageFocusElementTabindex(tabIndex);\n } else {\n this.focusElement?.removeAttribute('tabindex');\n }\n return;\n }\n\n this.setAttribute('focusable', '');\n if (this.hasAttribute('tabindex')) {\n this.removeAttribute('tabindex');\n } else {\n // You can't remove an attribute that isn't there,\n // manually end the `manipulatingTabindex` guard.\n this.manipulatingTabindex = false;\n }\n\n this._tabIndex = tabIndex;\n this.manageFocusElementTabindex(tabIndex);\n }\n private _tabIndex = 0;\n\n private onPointerdownManagementOfTabIndex(): void {\n if (this.tabIndex === -1) {\n setTimeout(() => {\n // Ensure this happens _after_ WebKit attempts to focus the :host.\n this.tabIndex = 0;\n this.focus({ preventScroll: true });\n this.tabIndex = -1;\n });\n }\n }\n\n private async manageFocusElementTabindex(tabIndex: number): Promise<void> {\n if (!this.focusElement) {\n // allow setting these values to be async when needed.\n await this.updateComplete;\n }\n if (tabIndex === null) {\n this.focusElement.removeAttribute('tabindex');\n } else {\n if (this.focusElement !== this) {\n this.focusElement.tabIndex = tabIndex;\n }\n }\n }\n\n private manipulatingTabindex = false;\n\n /**\n * @private\n */\n public get focusElement(): DisableableElement {\n throw new Error('Must implement focusElement getter!');\n }\n\n /**\n * @public\n * @returns {boolean} whether the component should manage its focusElement tab-index or not\n * Needed for action-menu to be supported in action-group in an accessible way\n */\n public get selfManageFocusElement(): boolean {\n return false;\n }\n\n public override focus(options?: FocusOptions): void {\n if (this.disabled || !this.focusElement) {\n return;\n }\n\n if (this.focusElement !== this) {\n this.focusElement.focus(options);\n } else {\n HTMLElement.prototype.focus.apply(this, [options]);\n }\n }\n\n public override blur(): void {\n const focusElement = this.focusElement || this;\n if (focusElement !== this) {\n focusElement.blur();\n } else {\n HTMLElement.prototype.blur.apply(this);\n }\n }\n\n public override click(): void {\n if (this.disabled) {\n return;\n }\n\n const focusElement = this.focusElement || this;\n if (focusElement !== this) {\n focusElement.click();\n } else {\n HTMLElement.prototype.click.apply(this);\n }\n }\n\n protected manageAutoFocus(): void {\n if (this.autofocus) {\n /**\n * Trick :focus-visible polyfill into thinking keyboard based focus\n *\n * @private\n **/\n this.dispatchEvent(\n new KeyboardEvent('keydown', {\n code: 'Tab',\n })\n );\n this.focusElement.focus();\n }\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n if (\n !this.hasAttribute('tabindex') ||\n this.getAttribute('tabindex') !== '-1'\n ) {\n this.setAttribute('focusable', '');\n }\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (changedProperties.has('disabled')) {\n this.handleDisabledChanged(\n this.disabled,\n changedProperties.get('disabled') as boolean\n );\n }\n\n super.update(changedProperties);\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (changedProperties.has('disabled') && this.disabled) {\n this.blur();\n }\n }\n\n private async handleDisabledChanged(\n disabled: boolean,\n oldDisabled: boolean\n ): Promise<void> {\n const canSetDisabled = (): boolean =>\n this.focusElement !== this &&\n typeof this.focusElement.disabled !== 'undefined';\n if (disabled) {\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', '-1');\n await this.updateComplete;\n if (canSetDisabled()) {\n this.focusElement.disabled = true;\n } else {\n this.setAttribute('aria-disabled', 'true');\n }\n } else if (oldDisabled) {\n this.manipulatingTabindex = true;\n if (this.focusElement === this) {\n this.setAttribute('tabindex', '' + this._tabIndex);\n } else {\n this.removeAttribute('tabindex');\n }\n await this.updateComplete;\n if (canSetDisabled()) {\n this.focusElement.disabled = false;\n } else {\n this.removeAttribute('aria-disabled');\n }\n }\n }\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.autofocusReady;\n return complete;\n }\n\n private autofocusReady = Promise.resolve();\n\n public override connectedCallback(): void {\n super.connectedCallback();\n if (this.autofocus) {\n this.autofocusReady = new Promise(async (res) => {\n // If at connect time the [autofocus] content is placed within\n // content that needs to be \"hidden\" by default, it would need to wait\n // two rAFs for animations to be triggered on that content in\n // order for the [autofocus] to become \"visisble\" and have its\n // focus() capabilities enabled.\n //\n // Await this with `getUpdateComplete` so that the element cannot\n // become \"ready\" until `manageFocus` has occured.\n await nextFrame();\n await nextFrame();\n res();\n });\n this.updateComplete.then(() => {\n this.manageAutoFocus();\n });\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;AAWA,SAAyB,uBAAuB;AAChD,SAAS,gBAAgB;AAEzB,SAAS,iCAAiC;AAI1C,SAAS,YAA2B;AAChC,SAAO,IAAI,QAAQ,CAAC,QAAQ,sBAAsB,MAAM,IAAI,CAAC,CAAC;AAClE;AAQO,aAAM,kBAAkB,0BAA0B,eAAe,EAAE;AAAA,EAAnE;AAAA;AAKH,SAAO,WAAW;AAOlB,SAAgB,YAAY;AAoG5B,SAAQ,YAAY;AA2BpB,SAAQ,uBAAuB;AAuI/B,SAAQ,iBAAiB,QAAQ,QAAQ;AAAA;AAAA,EA7PzC,IAAoB,WAAmB;AACnC,QAAI,KAAK,iBAAiB,MAAM;AAC5B,YAAM,WAAW,KAAK,aAAa,UAAU,IACvC,OAAO,KAAK,aAAa,UAAU,CAAC,IACpC;AACN,aAAO,CAAC,MAAM,QAAQ,IAAI,WAAW;AAAA,IACzC;AACA,UAAM,oBAAoB;AAAA,MACtB,KAAK,aAAa,UAAU,IACrB,KAAK,aAAa,UAAU,KAAgB,MAC7C;AAAA,IACV;AAGA,QAAI,KAAK,YAAY,oBAAoB,GAAG;AACxC,aAAO;AAAA,IACX;AAGA,QAAI,CAAC,KAAK,cAAc;AACpB,aAAO;AAAA,IACX;AAIA,WAAO,KAAK;AAAA,EAChB;AAAA,EACA,IAAoB,SAAS,UAAkB;AA5EnD;AA+EQ,QAAI,KAAK,sBAAsB;AAC3B,WAAK,uBAAuB;AAC5B;AAAA,IACJ;AAEA,QAAI,KAAK,iBAAiB,MAAM;AAC5B,UAAI,KAAK,UAAU;AACf,aAAK,YAAY;AAAA,MACrB,WAAW,aAAa,KAAK,WAAW;AACpC,aAAK,YAAY;AACjB,cAAM,WAAW,KAAK;AACt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AAA,MACzB,CAAC;AAAA,IACL;AAAA,EACJ;AACJ;AApSW;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GAJjC,UAKF;AAOS;AAAA,EADf,SAAS,EAAE,MAAM,QAAQ,CAAC;AAAA,GAXlB,UAYO;AASI;AAAA,EADnB,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GApBjB,UAqBW;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var d=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var n=(s,a,e,t)=>{for(var i=t>1?void 0:t?b(a,e):a,o=s.length-1,r;o>=0;o--)(r=s[o])&&(i=(t?r(a,e,i):r(i))||i);return t&&i&&d(a,e,i),i};import{SpectrumElement as h}from"@spectrum-web-components/base";import{property as l}from"@spectrum-web-components/base/src/decorators.js";import{FocusVisiblePolyfillMixin as m}from"./focus-visible.js";function u(){return new Promise(s=>requestAnimationFrame(()=>s()))}export class Focusable extends m(h){constructor(){super(...arguments);this.disabled=!1;this.autofocus=!1;this._tabIndex=0;this.manipulatingTabindex=!1;this.autofocusReady=Promise.resolve()}get tabIndex(){if(this.focusElement===this){const t=this.hasAttribute("tabindex")?Number(this.getAttribute("tabindex")):NaN;return isNaN(t)?-1:t}const e=parseFloat(this.hasAttribute("tabindex")&&this.getAttribute("tabindex")||"0");return this.disabled||e<0?-1:this.focusElement?this._tabIndex:e}set tabIndex(e){var t;if(this.manipulatingTabindex){this.manipulatingTabindex=!1;return}if(this.focusElement===this){if(this.disabled)this._tabIndex=e;else if(e!==this._tabIndex){this._tabIndex=e;const i=""+e;this.manipulatingTabindex=!0,this.setAttribute("tabindex",i)}return}if(e===-1?this.addEventListener("pointerdown",this.onPointerdownManagementOfTabIndex):(this.manipulatingTabindex=!0,this.removeEventListener("pointerdown",this.onPointerdownManagementOfTabIndex)),e===-1||this.disabled){if(this.manipulatingTabindex=!0,this.setAttribute("tabindex","-1"),this.removeAttribute("focusable"),this.selfManageFocusElement)return;e!==-1?(this._tabIndex=e,this.manageFocusElementTabindex(e)):(t=this.focusElement)==null||t.removeAttribute("tabindex");return}this.setAttribute("focusable",""),this.hasAttribute("tabindex")?this.removeAttribute("tabindex"):this.manipulatingTabindex=!1,this._tabIndex=e,this.manageFocusElementTabindex(e)}onPointerdownManagementOfTabIndex(){this.tabIndex===-1&&setTimeout(()=>{this.tabIndex=0,this.focus({preventScroll:!0}),this.tabIndex=-1})}async manageFocusElementTabindex(e){this.focusElement||await this.updateComplete,e===null?this.focusElement.removeAttribute("tabindex"):this.focusElement!==this&&(this.focusElement.tabIndex=e)}get focusElement(){throw new Error("Must implement focusElement getter!")}get selfManageFocusElement(){return!1}focus(e){this.disabled||!this.focusElement||(this.focusElement!==this?this.focusElement.focus(e):HTMLElement.prototype.focus.apply(this,[e]))}blur(){const e=this.focusElement||this;e!==this?e.blur():HTMLElement.prototype.blur.apply(this)}click(){if(this.disabled)return;const e=this.focusElement||this;e!==this?e.click():HTMLElement.prototype.click.apply(this)}manageAutoFocus(){this.autofocus&&(this.dispatchEvent(new KeyboardEvent("keydown",{code:"Tab"})),this.focusElement.focus())}firstUpdated(e){super.firstUpdated(e),(!this.hasAttribute("tabindex")||this.getAttribute("tabindex")!=="-1")&&this.setAttribute("focusable","")}update(e){e.has("disabled")&&this.handleDisabledChanged(this.disabled,e.get("disabled")),super.update(e)}updated(e){super.updated(e),e.has("disabled")&&this.disabled&&this.blur()}async handleDisabledChanged(e,t){const i=()=>this.focusElement!==this&&typeof this.focusElement.disabled!="undefined";e?(this.manipulatingTabindex=!0,this.setAttribute("tabindex","-1"),await this.updateComplete,i()?this.focusElement.disabled=!0:this.setAttribute("aria-disabled","true")):t&&(this.manipulatingTabindex=!0,this.focusElement===this?this.setAttribute("tabindex",""+this._tabIndex):this.removeAttribute("tabindex"),await this.updateComplete,i()?this.focusElement.disabled=!1:this.removeAttribute("aria-disabled"))}async getUpdateComplete(){const e=await super.getUpdateComplete();return await this.autofocusReady,e}connectedCallback(){super.connectedCallback(),this.autofocus&&(this.autofocusReady=new Promise(async e=>{await u(),await u(),e()}),this.updateComplete.then(()=>{this.manageAutoFocus()}))}}n([l({type:Boolean,reflect:!0})],Focusable.prototype,"disabled",2),n([l({type:Boolean})],Focusable.prototype,"autofocus",2),n([l({type:Number})],Focusable.prototype,"tabIndex",1);
2
+ //# sourceMappingURL=focusable.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["focusable.ts"],
4
+ "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*/\nimport { PropertyValues, SpectrumElement } from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { FocusVisiblePolyfillMixin } from './focus-visible.js';\n\ntype DisableableElement = HTMLElement & { disabled?: boolean };\n\nfunction nextFrame(): Promise<void> {\n return new Promise((res) => requestAnimationFrame(() => res()));\n}\n\n/**\n * Focusable base class handles tabindex setting into shadowed elements automatically.\n *\n * This implementation is based heavily on the aybolit delegate-focus-mixin at\n * https://github.com/web-padawan/aybolit/blob/master/packages/core/src/mixins/delegate-focus-mixin.js\n */\nexport class Focusable extends FocusVisiblePolyfillMixin(SpectrumElement) {\n /**\n * Disable this control. It will not receive focus or events\n */\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n /**\n * When this control is rendered, focus it automatically\n * @private\n */\n @property({ type: Boolean })\n public override autofocus = false;\n\n /**\n * The tab index to apply to this control. See general documentation about\n * the tabindex HTML property\n *\n * @private\n */\n @property({ type: Number })\n public override get tabIndex(): number {\n if (this.focusElement === this) {\n const tabindex = this.hasAttribute('tabindex')\n ? Number(this.getAttribute('tabindex'))\n : NaN;\n return !isNaN(tabindex) ? tabindex : -1;\n }\n const tabIndexAttribute = parseFloat(\n this.hasAttribute('tabindex')\n ? (this.getAttribute('tabindex') as string) || '0'\n : '0'\n );\n // When `disabled` tabindex is -1.\n // When host tabindex -1, use that as the cache.\n if (this.disabled || tabIndexAttribute < 0) {\n return -1;\n }\n // When `focusElement` isn't available yet,\n // use host tabindex as the cache.\n if (!this.focusElement) {\n return tabIndexAttribute;\n }\n // All other times, use the tabindex of `focusElement`\n // as the cache for this value.\n // return this.focusElement.tabIndex;\n return this._tabIndex;\n }\n public override set tabIndex(tabIndex: number) {\n // Flipping `manipulatingTabindex` to true before a change\n // allows for that change NOT to effect the cached value of tabindex\n if (this.manipulatingTabindex) {\n this.manipulatingTabindex = false;\n return;\n }\n\n if (this.focusElement === this) {\n if (this.disabled) {\n this._tabIndex = tabIndex;\n } else if (tabIndex !== this._tabIndex) {\n this._tabIndex = tabIndex;\n const tabindex = '' + tabIndex;\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', tabindex);\n }\n return;\n }\n\n if (tabIndex === -1) {\n this.addEventListener(\n 'pointerdown',\n this.onPointerdownManagementOfTabIndex\n );\n } else {\n // All code paths are about to address the host tabindex without side effect.\n this.manipulatingTabindex = true;\n this.removeEventListener(\n 'pointerdown',\n this.onPointerdownManagementOfTabIndex\n );\n }\n\n if (tabIndex === -1 || this.disabled) {\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', '-1');\n this.removeAttribute('focusable');\n\n if (this.selfManageFocusElement) {\n return;\n }\n\n if (tabIndex !== -1) {\n this._tabIndex = tabIndex;\n this.manageFocusElementTabindex(tabIndex);\n } else {\n this.focusElement?.removeAttribute('tabindex');\n }\n return;\n }\n\n this.setAttribute('focusable', '');\n if (this.hasAttribute('tabindex')) {\n this.removeAttribute('tabindex');\n } else {\n // You can't remove an attribute that isn't there,\n // manually end the `manipulatingTabindex` guard.\n this.manipulatingTabindex = false;\n }\n\n this._tabIndex = tabIndex;\n this.manageFocusElementTabindex(tabIndex);\n }\n private _tabIndex = 0;\n\n private onPointerdownManagementOfTabIndex(): void {\n if (this.tabIndex === -1) {\n setTimeout(() => {\n // Ensure this happens _after_ WebKit attempts to focus the :host.\n this.tabIndex = 0;\n this.focus({ preventScroll: true });\n this.tabIndex = -1;\n });\n }\n }\n\n private async manageFocusElementTabindex(tabIndex: number): Promise<void> {\n if (!this.focusElement) {\n // allow setting these values to be async when needed.\n await this.updateComplete;\n }\n if (tabIndex === null) {\n this.focusElement.removeAttribute('tabindex');\n } else {\n if (this.focusElement !== this) {\n this.focusElement.tabIndex = tabIndex;\n }\n }\n }\n\n private manipulatingTabindex = false;\n\n /**\n * @private\n */\n public get focusElement(): DisableableElement {\n throw new Error('Must implement focusElement getter!');\n }\n\n /**\n * @public\n * @returns {boolean} whether the component should manage its focusElement tab-index or not\n * Needed for action-menu to be supported in action-group in an accessible way\n */\n public get selfManageFocusElement(): boolean {\n return false;\n }\n\n public override focus(options?: FocusOptions): void {\n if (this.disabled || !this.focusElement) {\n return;\n }\n\n if (this.focusElement !== this) {\n this.focusElement.focus(options);\n } else {\n HTMLElement.prototype.focus.apply(this, [options]);\n }\n }\n\n public override blur(): void {\n const focusElement = this.focusElement || this;\n if (focusElement !== this) {\n focusElement.blur();\n } else {\n HTMLElement.prototype.blur.apply(this);\n }\n }\n\n public override click(): void {\n if (this.disabled) {\n return;\n }\n\n const focusElement = this.focusElement || this;\n if (focusElement !== this) {\n focusElement.click();\n } else {\n HTMLElement.prototype.click.apply(this);\n }\n }\n\n protected manageAutoFocus(): void {\n if (this.autofocus) {\n /**\n * Trick :focus-visible polyfill into thinking keyboard based focus\n *\n * @private\n **/\n this.dispatchEvent(\n new KeyboardEvent('keydown', {\n code: 'Tab',\n })\n );\n this.focusElement.focus();\n }\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n if (\n !this.hasAttribute('tabindex') ||\n this.getAttribute('tabindex') !== '-1'\n ) {\n this.setAttribute('focusable', '');\n }\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (changedProperties.has('disabled')) {\n this.handleDisabledChanged(\n this.disabled,\n changedProperties.get('disabled') as boolean\n );\n }\n\n super.update(changedProperties);\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (changedProperties.has('disabled') && this.disabled) {\n this.blur();\n }\n }\n\n private async handleDisabledChanged(\n disabled: boolean,\n oldDisabled: boolean\n ): Promise<void> {\n const canSetDisabled = (): boolean =>\n this.focusElement !== this &&\n typeof this.focusElement.disabled !== 'undefined';\n if (disabled) {\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', '-1');\n await this.updateComplete;\n if (canSetDisabled()) {\n this.focusElement.disabled = true;\n } else {\n this.setAttribute('aria-disabled', 'true');\n }\n } else if (oldDisabled) {\n this.manipulatingTabindex = true;\n if (this.focusElement === this) {\n this.setAttribute('tabindex', '' + this._tabIndex);\n } else {\n this.removeAttribute('tabindex');\n }\n await this.updateComplete;\n if (canSetDisabled()) {\n this.focusElement.disabled = false;\n } else {\n this.removeAttribute('aria-disabled');\n }\n }\n }\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.autofocusReady;\n return complete;\n }\n\n private autofocusReady = Promise.resolve();\n\n public override connectedCallback(): void {\n super.connectedCallback();\n if (this.autofocus) {\n this.autofocusReady = new Promise(async (res) => {\n // If at connect time the [autofocus] content is placed within\n // content that needs to be \"hidden\" by default, it would need to wait\n // two rAFs for animations to be triggered on that content in\n // order for the [autofocus] to become \"visisble\" and have its\n // focus() capabilities enabled.\n //\n // Await this with `getUpdateComplete` so that the element cannot\n // become \"ready\" until `manageFocus` has occured.\n await nextFrame();\n await nextFrame();\n res();\n });\n this.updateComplete.then(() => {\n this.manageAutoFocus();\n });\n }\n }\n}\n"],
5
+ "mappings": "qNAWA,OAAyB,m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AS,EAAK,CAAC,GAJjC,UAKF,wBAOSgB,EAAA,CADfhB,EAAS,CAAE,KAAM,OAAQ,CAAC,GAXlB,UAYO,yBASIgB,EAAA,CADnBhB,EAAS,CAAE,KAAM,MAAO,CAAC,GApBjB,UAqBW",
6
+ "names": ["SpectrumElement", "property", "FocusVisiblePolyfillMixin", "nextFrame", "res", "tabindex", "tabIndexAttribute", "tabIndex", "_a", "options", "focusElement", "changes", "changedProperties", "disabled", "oldDisabled", "canSetDisabled", "complete", "__decorateClass"]
7
+ }
@@ -0,0 +1 @@
1
+ export declare const getActiveElement: (el: Node) => Element | null;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ export const getActiveElement = (el) => {
3
+ return el.getRootNode().activeElement;
4
+ };
5
+ //# sourceMappingURL=get-active-element.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["get-active-element.ts"],
4
+ "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\n/* c8 ignore next 3 */\nexport const getActiveElement = (el: Node): Element | null => {\n return (el.getRootNode() as Document).activeElement;\n};\n"],
5
+ "mappings": ";AAaO,aAAM,mBAAmB,CAAC,OAA6B;AAC1D,SAAQ,GAAG,YAAY,EAAe;AAC1C;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";export const getActiveElement=e=>e.getRootNode().activeElement;
2
+ //# sourceMappingURL=get-active-element.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["get-active-element.ts"],
4
+ "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\n/* c8 ignore next 3 */\nexport const getActiveElement = (el: Node): Element | null => {\n return (el.getRootNode() as Document).activeElement;\n};\n"],
5
+ "mappings": "aAaO,aAAM,iBAAoBA,GACrBA,EAAG,YAAY,EAAe",
6
+ "names": ["el"]
7
+ }
@@ -0,0 +1 @@
1
+ export declare const getDeepElementFromPoint: (x: number, y: number) => Element | null;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ export const getDeepElementFromPoint = (x, y) => {
3
+ let target = document.elementFromPoint(x, y);
4
+ while (target == null ? void 0 : target.shadowRoot) {
5
+ const innerTarget = target.shadowRoot.elementFromPoint(x, y);
6
+ if (!innerTarget || innerTarget === target) {
7
+ break;
8
+ }
9
+ target = innerTarget;
10
+ }
11
+ return target;
12
+ };
13
+ //# sourceMappingURL=get-deep-element-from-point.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["get-deep-element-from-point.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2022 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 const getDeepElementFromPoint = (\n x: number,\n y: number\n): Element | null => {\n let target = document.elementFromPoint(x, y);\n while (target?.shadowRoot) {\n const innerTarget = (\n target.shadowRoot as unknown as {\n elementFromPoint: (x: number, y: number) => Element | null;\n }\n ).elementFromPoint(x, y);\n if (!innerTarget || innerTarget === target) {\n break;\n }\n target = innerTarget;\n }\n return target;\n};\n"],
5
+ "mappings": ";AAYO,aAAM,0BAA0B,CACnC,GACA,MACiB;AACjB,MAAI,SAAS,SAAS,iBAAiB,GAAG,CAAC;AAC3C,SAAO,iCAAQ,YAAY;AACvB,UAAM,cACF,OAAO,WAGT,iBAAiB,GAAG,CAAC;AACvB,QAAI,CAAC,eAAe,gBAAgB,QAAQ;AACxC;AAAA,IACJ;AACA,aAAS;AAAA,EACb;AACA,SAAO;AACX;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";export const getDeepElementFromPoint=(o,t)=>{let e=document.elementFromPoint(o,t);for(;e!=null&&e.shadowRoot;){const n=e.shadowRoot.elementFromPoint(o,t);if(!n||n===e)break;e=n}return e};
2
+ //# sourceMappingURL=get-deep-element-from-point.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["get-deep-element-from-point.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2022 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 const getDeepElementFromPoint = (\n x: number,\n y: number\n): Element | null => {\n let target = document.elementFromPoint(x, y);\n while (target?.shadowRoot) {\n const innerTarget = (\n target.shadowRoot as unknown as {\n elementFromPoint: (x: number, y: number) => Element | null;\n }\n ).elementFromPoint(x, y);\n if (!innerTarget || innerTarget === target) {\n break;\n }\n target = innerTarget;\n }\n return target;\n};\n"],
5
+ "mappings": "aAYO,aAAM,wBAA0B,CACnCA,EACAC,IACiB,CACjB,IAAIC,EAAS,SAAS,iBAAiBF,EAAGC,CAAC,EAC3C,KAAOC,GAAA,MAAAA,EAAQ,YAAY,CACvB,MAAMC,EACFD,EAAO,WAGT,iBAAiBF,EAAGC,CAAC,EACvB,GAAI,CAACE,GAAeA,IAAgBD,EAChC,MAEJA,EAASC,CACb,CACA,OAAOD,CACX",
6
+ "names": ["x", "y", "target", "innerTarget"]
7
+ }
@@ -0,0 +1 @@
1
+ export declare const getLabelFromSlot: (label: string, slotEl: HTMLSlotElement) => string | null;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ export const getLabelFromSlot = (label, slotEl) => {
3
+ if (label) return null;
4
+ const textContent = slotEl.assignedNodes().reduce((accumulator, node) => {
5
+ if (node.textContent) {
6
+ return accumulator + node.textContent;
7
+ } else {
8
+ return accumulator;
9
+ }
10
+ }, "");
11
+ if (textContent) {
12
+ return textContent.trim();
13
+ } else {
14
+ return null;
15
+ }
16
+ };
17
+ //# sourceMappingURL=get-label-from-slot.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["get-label-from-slot.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2022 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 const getLabelFromSlot = (\n label: string,\n slotEl: HTMLSlotElement\n): string | null => {\n if (label) return null;\n const textContent = slotEl\n .assignedNodes()\n .reduce((accumulator: string, node: Node) => {\n if (node.textContent) {\n return accumulator + node.textContent;\n } else {\n return accumulator;\n }\n }, '');\n if (textContent) {\n return textContent.trim();\n } else {\n return null;\n }\n};\n"],
5
+ "mappings": ";AAYO,aAAM,mBAAmB,CAC5B,OACA,WACgB;AAChB,MAAI,MAAO,QAAO;AAClB,QAAM,cAAc,OACf,cAAc,EACd,OAAO,CAAC,aAAqB,SAAe;AACzC,QAAI,KAAK,aAAa;AAClB,aAAO,cAAc,KAAK;AAAA,IAC9B,OAAO;AACH,aAAO;AAAA,IACX;AAAA,EACJ,GAAG,EAAE;AACT,MAAI,aAAa;AACb,WAAO,YAAY,KAAK;AAAA,EAC5B,OAAO;AACH,WAAO;AAAA,EACX;AACJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";export const getLabelFromSlot=(r,l)=>{if(r)return null;const t=l.assignedNodes().reduce((e,n)=>n.textContent?e+n.textContent:e,"");return t?t.trim():null};
2
+ //# sourceMappingURL=get-label-from-slot.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["get-label-from-slot.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2022 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 const getLabelFromSlot = (\n label: string,\n slotEl: HTMLSlotElement\n): string | null => {\n if (label) return null;\n const textContent = slotEl\n .assignedNodes()\n .reduce((accumulator: string, node: Node) => {\n if (node.textContent) {\n return accumulator + node.textContent;\n } else {\n return accumulator;\n }\n }, '');\n if (textContent) {\n return textContent.trim();\n } else {\n return null;\n }\n};\n"],
5
+ "mappings": "aAYO,aAAM,iBAAmB,CAC5BA,EACAC,IACgB,CAChB,GAAID,EAAO,OAAO,KAClB,MAAME,EAAcD,EACf,cAAc,EACd,OAAO,CAACE,EAAqBC,IACtBA,EAAK,YACED,EAAcC,EAAK,YAEnBD,EAEZ,EAAE,EACT,OAAID,EACOA,EAAY,KAAK,EAEjB,IAEf",
6
+ "names": ["label", "slotEl", "textContent", "accumulator", "node"]
7
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export * from './first-focusable-in.js';
2
+ export * from './focus-visible.js';
3
+ export * from './focusable.js';
4
+ export * from './focusable-selectors.js';
5
+ export * from './get-active-element.js';
6
+ export * from './like-anchor.js';
7
+ export * from './observe-slot-presence.js';
8
+ export * from './observe-slot-text.js';
9
+ export * from './platform.js';
10
+ export * from './reparent-children.js';
11
+ export * from './get-label-from-slot.js';
12
+ export * from './random-id.js';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ export * from "./first-focusable-in.dev.js";
3
+ export * from "./focus-visible.dev.js";
4
+ export * from "./focusable.dev.js";
5
+ export * from "./focusable-selectors.dev.js";
6
+ export * from "./get-active-element.dev.js";
7
+ export * from "./like-anchor.dev.js";
8
+ export * from "./observe-slot-presence.dev.js";
9
+ export * from "./observe-slot-text.dev.js";
10
+ export * from "./platform.dev.js";
11
+ export * from "./reparent-children.dev.js";
12
+ export * from "./get-label-from-slot.dev.js";
13
+ export * from "./random-id.dev.js";
14
+ //# sourceMappingURL=index.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["index.ts"],
4
+ "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 './first-focusable-in.dev.js'\nexport * from './focus-visible.dev.js'\nexport * from './focusable.dev.js'\nexport * from './focusable-selectors.dev.js'\nexport * from './get-active-element.dev.js'\nexport * from './like-anchor.dev.js'\nexport * from './observe-slot-presence.dev.js'\nexport * from './observe-slot-text.dev.js'\nexport * from './platform.dev.js'\nexport * from './reparent-children.dev.js'\nexport * from './get-label-from-slot.dev.js'\nexport * from './random-id.dev.js'\n"],
5
+ "mappings": ";AAYA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";export*from"./first-focusable-in.js";export*from"./focus-visible.js";export*from"./focusable.js";export*from"./focusable-selectors.js";export*from"./get-active-element.js";export*from"./like-anchor.js";export*from"./observe-slot-presence.js";export*from"./observe-slot-text.js";export*from"./platform.js";export*from"./reparent-children.js";export*from"./get-label-from-slot.js";export*from"./random-id.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["index.ts"],
4
+ "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 './first-focusable-in.js';\nexport * from './focus-visible.js';\nexport * from './focusable.js';\nexport * from './focusable-selectors.js';\nexport * from './get-active-element.js';\nexport * from './like-anchor.js';\nexport * from './observe-slot-presence.js';\nexport * from './observe-slot-text.js';\nexport * from './platform.js';\nexport * from './reparent-children.js';\nexport * from './get-label-from-slot.js';\nexport * from './random-id.js';\n"],
5
+ "mappings": "aAYA,WAAc,0BACd,WAAc,qBACd,WAAc,iBACd,WAAc,2BACd,WAAc,0BACd,WAAc,mBACd,WAAc,6BACd,WAAc,yBACd,WAAc,gBACd,WAAc,yBACd,WAAc,2BACd,WAAc",
6
+ "names": []
7
+ }
@@ -0,0 +1,23 @@
1
+ import { ReactiveElement, TemplateResult } from '@spectrum-web-components/base';
2
+ type Constructor<T = Record<string, unknown>> = {
3
+ new (...args: any[]): T;
4
+ prototype: T;
5
+ };
6
+ type RenderAnchorOptions = {
7
+ id: string;
8
+ className?: string;
9
+ ariaHidden?: boolean;
10
+ anchorContent?: TemplateResult | TemplateResult[];
11
+ labelledby?: string;
12
+ tabindex?: -1 | 0;
13
+ };
14
+ export interface LikeAnchorInterface {
15
+ download?: string;
16
+ label?: string;
17
+ href?: string;
18
+ rel?: string;
19
+ target?: '_blank' | '_parent' | '_self' | '_top';
20
+ renderAnchor(options: RenderAnchorOptions): TemplateResult;
21
+ }
22
+ export declare function LikeAnchor<T extends Constructor<ReactiveElement>>(constructor: T): T & Constructor<LikeAnchorInterface>;
23
+ export {};
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __decorateClass = (decorators, target, key, kind) => {
5
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
6
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
7
+ if (decorator = decorators[i])
8
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
+ if (kind && result) __defProp(target, key, result);
10
+ return result;
11
+ };
12
+ import {
13
+ html
14
+ } from "@spectrum-web-components/base";
15
+ import { property } from "@spectrum-web-components/base/src/decorators.js";
16
+ import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
17
+ export function LikeAnchor(constructor) {
18
+ class LikeAnchorElement extends constructor {
19
+ renderAnchor({
20
+ id,
21
+ className,
22
+ ariaHidden,
23
+ labelledby,
24
+ tabindex,
25
+ // prettier-ignore
26
+ anchorContent = html`<slot></slot>`
27
+ }) {
28
+ return html`<a
29
+ id=${id}
30
+ class=${ifDefined(className)}
31
+ href=${ifDefined(this.href)}
32
+ download=${ifDefined(this.download)}
33
+ target=${ifDefined(this.target)}
34
+ aria-label=${ifDefined(this.label)}
35
+ aria-labelledby=${ifDefined(labelledby)}
36
+ aria-hidden=${ifDefined(ariaHidden ? "true" : void 0)}
37
+ tabindex=${ifDefined(tabindex)}
38
+ referrerpolicy=${ifDefined(this.referrerpolicy)}
39
+ rel=${ifDefined(this.rel)}
40
+ >${anchorContent}</a>`;
41
+ }
42
+ }
43
+ __decorateClass([
44
+ property()
45
+ ], LikeAnchorElement.prototype, "download", 2);
46
+ __decorateClass([
47
+ property()
48
+ ], LikeAnchorElement.prototype, "label", 2);
49
+ __decorateClass([
50
+ property()
51
+ ], LikeAnchorElement.prototype, "href", 2);
52
+ __decorateClass([
53
+ property()
54
+ ], LikeAnchorElement.prototype, "target", 2);
55
+ __decorateClass([
56
+ property()
57
+ ], LikeAnchorElement.prototype, "referrerpolicy", 2);
58
+ __decorateClass([
59
+ property()
60
+ ], LikeAnchorElement.prototype, "rel", 2);
61
+ return LikeAnchorElement;
62
+ }
63
+ //# sourceMappingURL=like-anchor.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["like-anchor.ts"],
4
+ "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*/\nimport {\n html,\n ReactiveElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\ntype RenderAnchorOptions = {\n id: string;\n className?: string;\n ariaHidden?: boolean;\n anchorContent?: TemplateResult | TemplateResult[];\n labelledby?: string;\n tabindex?: -1 | 0;\n};\n\nexport interface LikeAnchorInterface {\n download?: string;\n label?: string;\n href?: string;\n rel?: string;\n target?: '_blank' | '_parent' | '_self' | '_top';\n renderAnchor(options: RenderAnchorOptions): TemplateResult;\n}\n\nexport function LikeAnchor<T extends Constructor<ReactiveElement>>(\n constructor: T\n): T & Constructor<LikeAnchorInterface> {\n class LikeAnchorElement extends constructor {\n /**\n * Causes the browser to treat the linked URL as a download.\n */\n @property()\n public download?: string;\n\n /**\n * An accessible label that describes the component.\n * It will be applied to aria-label, but not visually rendered.\n */\n @property()\n public label?: string;\n\n /**\n * The URL that the hyperlink points to.\n */\n @property()\n public href?: string;\n\n /**\n * Where to display the linked URL, as the name for a browsing context (a tab, window, or &lt;iframe&gt;).\n */\n @property()\n public target?: '_blank' | '_parent' | '_self' | '_top';\n\n /**\n * How much of the referrer to send when following the link.\n */\n @property()\n public referrerpolicy?:\n | 'no-referrer'\n | 'no-referrer-when-downgrade'\n | 'origin'\n | 'origin-when-cross-origin'\n | 'same-origin'\n | 'strict-origin'\n | 'strict-origin-when-cross-origin'\n | 'unsafe-url';\n\n /**\n * The relationship of the linked URL as space-separated link types.\n */\n @property()\n public rel?: string;\n\n public renderAnchor({\n id,\n className,\n ariaHidden,\n labelledby,\n tabindex,\n // prettier-ignore\n anchorContent = html`<slot></slot>`,\n }: RenderAnchorOptions): TemplateResult {\n // prettier-ignore\n return html\n `<a\n id=${id}\n class=${ifDefined(className)}\n href=${ifDefined(this.href)}\n download=${ifDefined(this.download)}\n target=${ifDefined(this.target)}\n aria-label=${ifDefined(this.label)}\n aria-labelledby=${ifDefined(labelledby)}\n aria-hidden=${ifDefined(ariaHidden ? 'true' : undefined)}\n tabindex=${ifDefined(tabindex)}\n referrerpolicy=${ifDefined(this.referrerpolicy)}\n rel=${ifDefined(this.rel)}\n >${anchorContent}</a>`;\n }\n }\n return LikeAnchorElement;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;AAWA;AAAA,EACI;AAAA,OAGG;AACP,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AA0BnB,gBAAS,WACZ,aACoC;AAAA,EACpC,MAAM,0BAA0B,YAAY;AAAA,IA8CjC,aAAa;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA,gBAAgB;AAAA,IACpB,GAAwC;AAEpC,aAAO;AAAA,yBAEM,EAAE;AAAA,4BACC,UAAU,SAAS,CAAC;AAAA,2BACrB,UAAU,KAAK,IAAI,CAAC;AAAA,+BAChB,UAAU,KAAK,QAAQ,CAAC;AAAA,6BAC1B,UAAU,KAAK,MAAM,CAAC;AAAA,iCAClB,UAAU,KAAK,KAAK,CAAC;AAAA,sCAChB,UAAU,UAAU,CAAC;AAAA,kCACzB,UAAU,aAAa,SAAS,MAAS,CAAC;AAAA,+BAC7C,UAAU,QAAQ,CAAC;AAAA,qCACb,UAAU,KAAK,cAAc,CAAC;AAAA,0BACzC,UAAU,KAAK,GAAG,CAAC;AAAA,mBAC1B,aAAa;AAAA,IACxB;AAAA,EACJ;AAlEW;AAAA,IADN,SAAS;AAAA,KAJR,kBAKK;AAOA;AAAA,IADN,SAAS;AAAA,KAXR,kBAYK;AAMA;AAAA,IADN,SAAS;AAAA,KAjBR,kBAkBK;AAMA;AAAA,IADN,SAAS;AAAA,KAvBR,kBAwBK;AAMA;AAAA,IADN,SAAS;AAAA,KA7BR,kBA8BK;AAcA;AAAA,IADN,SAAS;AAAA,KA3CR,kBA4CK;AA4BX,SAAO;AACX;",
6
+ "names": []
7
+ }