@spectrum-web-components/dialog 0.11.0 → 0.11.1
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/package.json +4 -4
- package/sp-dialog-wrapper.dev.js +1 -0
- package/sp-dialog-wrapper.dev.js.map +1 -1
- package/sp-dialog-wrapper.js +1 -1
- package/sp-dialog-wrapper.js.map +2 -2
- package/sp-dialog.dev.js +1 -0
- package/sp-dialog.dev.js.map +1 -1
- package/sp-dialog.js +1 -1
- package/sp-dialog.js.map +2 -2
- package/src/Dialog.dev.js +46 -17
- package/src/Dialog.dev.js.map +1 -1
- package/src/Dialog.js +10 -10
- package/src/Dialog.js.map +2 -2
- package/src/DialogWrapper.dev.js +41 -24
- package/src/DialogWrapper.dev.js.map +2 -2
- package/src/DialogWrapper.js +9 -9
- package/src/DialogWrapper.js.map +3 -3
- package/src/dialog.css.dev.js +1 -0
- package/src/dialog.css.dev.js.map +1 -1
- package/src/dialog.css.js +1 -1
- package/src/dialog.css.js.map +2 -2
- package/src/index.dev.js +1 -0
- package/src/index.dev.js.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/spectrum-dialog.css.dev.js +1 -0
- package/src/spectrum-dialog.css.dev.js.map +1 -1
- package/src/spectrum-dialog.css.js +1 -1
- package/src/spectrum-dialog.css.js.map +2 -2
- package/stories/dialog-wrapper.stories.js +202 -47
- package/stories/dialog-wrapper.stories.js.map +2 -2
- package/stories/dialog.stories.js +61 -14
- package/stories/dialog.stories.js.map +1 -1
- package/stories/images.js +3 -1
- package/stories/images.js.map +1 -1
- package/test/benchmark/basic-test.js +5 -1
- package/test/benchmark/basic-test.js.map +1 -1
- package/test/dialog-wrapper.test-vrt.js +4 -1
- package/test/dialog-wrapper.test-vrt.js.map +1 -1
- package/test/dialog-wrapper.test.js +191 -3
- package/test/dialog-wrapper.test.js.map +1 -1
- package/test/dialog.test-vrt.js +4 -1
- package/test/dialog.test-vrt.js.map +1 -1
- package/test/dialog.test.js +149 -13
- package/test/dialog.test.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/dialog",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
],
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@spectrum-web-components/base": "^0.7.0",
|
|
69
|
-
"@spectrum-web-components/button": "^0.19.
|
|
69
|
+
"@spectrum-web-components/button": "^0.19.1",
|
|
70
70
|
"@spectrum-web-components/button-group": "^0.9.0",
|
|
71
|
-
"@spectrum-web-components/divider": "^0.5.
|
|
71
|
+
"@spectrum-web-components/divider": "^0.5.1",
|
|
72
72
|
"@spectrum-web-components/icons-workflow": "^0.9.0",
|
|
73
73
|
"@spectrum-web-components/modal": "^0.7.0",
|
|
74
74
|
"@spectrum-web-components/shared": "^0.15.0",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"./sp-*.js",
|
|
85
85
|
"./**/*.dev.js"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "1cfea66c39440232b9982509573801b8e3a9f692"
|
|
88
88
|
}
|
package/sp-dialog-wrapper.dev.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-dialog-wrapper.ts"],
|
|
4
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 { DialogWrapper } from './src/DialogWrapper.dev.js'\n\ncustomElements.define('sp-dialog-wrapper', DialogWrapper);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-dialog-wrapper': DialogWrapper;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAWA;
|
|
5
|
+
"mappings": ";AAWA,SAAS,qBAAqB;AAE9B,eAAe,OAAO,qBAAqB,aAAa;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/sp-dialog-wrapper.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DialogWrapper as e}from"./src/DialogWrapper.js";customElements.define("sp-dialog-wrapper",e);
|
|
1
|
+
"use strict";import{DialogWrapper as e}from"./src/DialogWrapper.js";customElements.define("sp-dialog-wrapper",e);
|
|
2
2
|
//# sourceMappingURL=sp-dialog-wrapper.js.map
|
package/sp-dialog-wrapper.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-dialog-wrapper.ts"],
|
|
4
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 { DialogWrapper } from './src/DialogWrapper.js';\n\ncustomElements.define('sp-dialog-wrapper', DialogWrapper);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-dialog-wrapper': DialogWrapper;\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "aAWA,OAAS,iBAAAA,MAAqB,yBAE9B,eAAe,OAAO,oBAAqBA,CAAa",
|
|
6
|
+
"names": ["DialogWrapper"]
|
|
7
7
|
}
|
package/sp-dialog.dev.js
CHANGED
package/sp-dialog.dev.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-dialog.ts"],
|
|
4
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 { Dialog } from './src/Dialog.dev.js'\n\ncustomElements.define('sp-dialog', Dialog);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-dialog': Dialog;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAWA;
|
|
5
|
+
"mappings": ";AAWA,SAAS,cAAc;AAEvB,eAAe,OAAO,aAAa,MAAM;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/sp-dialog.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Dialog as e}from"./src/Dialog.js";customElements.define("sp-dialog",e);
|
|
1
|
+
"use strict";import{Dialog as e}from"./src/Dialog.js";customElements.define("sp-dialog",e);
|
|
2
2
|
//# sourceMappingURL=sp-dialog.js.map
|
package/sp-dialog.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-dialog.ts"],
|
|
4
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 { Dialog } from './src/Dialog.js';\n\ncustomElements.define('sp-dialog', Dialog);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-dialog': Dialog;\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "aAWA,OAAS,UAAAA,MAAc,kBAEvB,eAAe,OAAO,YAAaA,CAAM",
|
|
6
|
+
"names": ["Dialog"]
|
|
7
7
|
}
|
package/src/Dialog.dev.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -43,11 +44,13 @@ function gatherAppliedIdsFromSlottedChildren(slot, idBase) {
|
|
|
43
44
|
});
|
|
44
45
|
return ids;
|
|
45
46
|
}
|
|
46
|
-
const _Dialog = class extends FocusVisiblePolyfillMixin(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
]
|
|
47
|
+
const _Dialog = class extends FocusVisiblePolyfillMixin(
|
|
48
|
+
ObserveSlotPresence(SpectrumElement, [
|
|
49
|
+
'[slot="hero"]',
|
|
50
|
+
'[slot="footer"]',
|
|
51
|
+
'[slot="button"]'
|
|
52
|
+
])
|
|
53
|
+
) {
|
|
51
54
|
constructor() {
|
|
52
55
|
super(...arguments);
|
|
53
56
|
this.error = false;
|
|
@@ -77,11 +80,13 @@ const _Dialog = class extends FocusVisiblePolyfillMixin(ObserveSlotPresence(Spec
|
|
|
77
80
|
return this.getSlotContentPresence('[slot="hero"]');
|
|
78
81
|
}
|
|
79
82
|
close() {
|
|
80
|
-
this.dispatchEvent(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
this.dispatchEvent(
|
|
84
|
+
new Event("close", {
|
|
85
|
+
bubbles: true,
|
|
86
|
+
composed: true,
|
|
87
|
+
cancelable: true
|
|
88
|
+
})
|
|
89
|
+
);
|
|
85
90
|
}
|
|
86
91
|
renderHero() {
|
|
87
92
|
return html`
|
|
@@ -166,9 +171,16 @@ const _Dialog = class extends FocusVisiblePolyfillMixin(ObserveSlotPresence(Spec
|
|
|
166
171
|
this.conditionLabelledby();
|
|
167
172
|
delete this.conditionLabelledby;
|
|
168
173
|
}
|
|
169
|
-
const ids = gatherAppliedIdsFromSlottedChildren(
|
|
174
|
+
const ids = gatherAppliedIdsFromSlottedChildren(
|
|
175
|
+
target,
|
|
176
|
+
this.labelledbyId
|
|
177
|
+
);
|
|
170
178
|
if (ids.length) {
|
|
171
|
-
this.conditionLabelledby = conditionAttributeWithId(
|
|
179
|
+
this.conditionLabelledby = conditionAttributeWithId(
|
|
180
|
+
this,
|
|
181
|
+
"aria-labelledby",
|
|
182
|
+
ids
|
|
183
|
+
);
|
|
172
184
|
}
|
|
173
185
|
}
|
|
174
186
|
onContentSlotChange({
|
|
@@ -178,14 +190,25 @@ const _Dialog = class extends FocusVisiblePolyfillMixin(ObserveSlotPresence(Spec
|
|
|
178
190
|
this.conditionDescribedby();
|
|
179
191
|
delete this.conditionDescribedby;
|
|
180
192
|
}
|
|
181
|
-
const ids = gatherAppliedIdsFromSlottedChildren(
|
|
193
|
+
const ids = gatherAppliedIdsFromSlottedChildren(
|
|
194
|
+
target,
|
|
195
|
+
this.describedbyId
|
|
196
|
+
);
|
|
182
197
|
if (ids.length && ids.length < 4) {
|
|
183
|
-
this.conditionDescribedby = conditionAttributeWithId(
|
|
198
|
+
this.conditionDescribedby = conditionAttributeWithId(
|
|
199
|
+
this,
|
|
200
|
+
"aria-describedby",
|
|
201
|
+
ids
|
|
202
|
+
);
|
|
184
203
|
} else if (!ids.length) {
|
|
185
204
|
const idProvided = !!this.id;
|
|
186
205
|
if (!idProvided)
|
|
187
206
|
this.id = this.describedbyId;
|
|
188
|
-
const conditionDescribedby = conditionAttributeWithId(
|
|
207
|
+
const conditionDescribedby = conditionAttributeWithId(
|
|
208
|
+
this,
|
|
209
|
+
"aria-describedby",
|
|
210
|
+
this.id
|
|
211
|
+
);
|
|
189
212
|
this.conditionDescribedby = () => {
|
|
190
213
|
conditionDescribedby();
|
|
191
214
|
if (!idProvided) {
|
|
@@ -197,10 +220,16 @@ const _Dialog = class extends FocusVisiblePolyfillMixin(ObserveSlotPresence(Spec
|
|
|
197
220
|
connectedCallback() {
|
|
198
221
|
super.connectedCallback();
|
|
199
222
|
this.tabIndex = 0;
|
|
200
|
-
window.addEventListener(
|
|
223
|
+
window.addEventListener(
|
|
224
|
+
"resize",
|
|
225
|
+
this.shouldManageTabOrderForScrolling
|
|
226
|
+
);
|
|
201
227
|
}
|
|
202
228
|
disconnectedCallback() {
|
|
203
|
-
window.removeEventListener(
|
|
229
|
+
window.removeEventListener(
|
|
230
|
+
"resize",
|
|
231
|
+
this.shouldManageTabOrderForScrolling
|
|
232
|
+
);
|
|
204
233
|
super.disconnectedCallback();
|
|
205
234
|
}
|
|
206
235
|
};
|
package/src/Dialog.dev.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Dialog.ts"],
|
|
4
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\nimport {\n CSSResultArray,\n html,\n nothing,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { classMap } from '@spectrum-web-components/base/src/directives.js';\nimport { conditionAttributeWithId } from '@spectrum-web-components/base/src/condition-attribute-with-id.js';\n\nimport '@spectrum-web-components/divider/sp-divider.js';\nimport '@spectrum-web-components/button/sp-close-button.js';\nimport '@spectrum-web-components/button-group/sp-button-group.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';\nimport {\n FocusVisiblePolyfillMixin,\n ObserveSlotPresence,\n} from '@spectrum-web-components/shared';\n\nimport styles from './dialog.css.js';\nimport type { CloseButton } from '@spectrum-web-components/button';\n\nfunction gatherAppliedIdsFromSlottedChildren(\n slot: HTMLSlotElement,\n idBase: string\n): string[] {\n const assignedElements = slot.assignedElements();\n const ids: string[] = [];\n assignedElements.forEach((el, i) => {\n if (el.id) {\n ids.push(el.id);\n } else {\n const id = idBase + `-${i}`;\n el.id = id;\n ids.push(id);\n }\n });\n return ids;\n}\n\n/**\n * @element sp-dialog\n *\n * @slot hero - Accepts a hero image to display at the top of the dialog\n * @slot heading - Acts as the heading of the dialog. This should be an actual heading tag `<h1-6 />`\n * @slot - Content not addressed to a specific slot will be interpreted as the main content of the dialog\n * @slot footer - Content addressed to the `footer` will be placed below the main content and to the side of any `[slot='button']` content\n * @slot button - Button elements addressed to this slot may be placed below the content when not delivered in a fullscreen mode\n * @fires close - Announces that the dialog has been closed.\n */\nexport class Dialog extends FocusVisiblePolyfillMixin(\n ObserveSlotPresence(SpectrumElement, [\n '[slot=\"hero\"]',\n '[slot=\"footer\"]',\n '[slot=\"button\"]',\n ])\n) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @query('.close-button')\n closeButton?: CloseButton;\n\n @query('.content')\n private contentElement!: HTMLDivElement;\n\n @property({ type: Boolean, reflect: true })\n public error = false;\n\n @property({ type: Boolean, reflect: true })\n public dismissable = false;\n\n protected get hasFooter(): boolean {\n return this.getSlotContentPresence('[slot=\"footer\"]');\n }\n\n protected get hasButtons(): boolean {\n return this.getSlotContentPresence('[slot=\"button\"]');\n }\n\n protected get hasHero(): boolean {\n return this.getSlotContentPresence('[slot=\"hero\"]');\n }\n\n @property({ type: Boolean, reflect: true, attribute: 'no-divider' })\n public noDivider = false;\n\n @property({ type: String, reflect: true })\n public mode?: 'fullscreen' | 'fullscreenTakeover';\n\n @property({ type: String, reflect: true })\n public size?: 's' | 'm' | 'l';\n\n public close(): void {\n this.dispatchEvent(\n new Event('close', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n }\n\n protected renderHero(): TemplateResult {\n return html`\n <slot name=\"hero\"></slot>\n `;\n }\n\n protected renderHeading(): TemplateResult {\n return html`\n <slot name=\"heading\" @slotchange=${this.onHeadingSlotchange}></slot>\n `;\n }\n\n protected renderContent(): TemplateResult {\n return html`\n <div class=\"content\">\n <slot @slotchange=${this.onContentSlotChange}></slot>\n </div>\n `;\n }\n\n protected renderFooter(): TemplateResult {\n return html`\n <div class=\"footer\">\n <slot name=\"footer\"></slot>\n </div>\n `;\n }\n\n protected renderButtons(): TemplateResult {\n const classes = {\n 'button-group': true,\n 'button-group--noFooter': !this.hasFooter,\n };\n return html`\n <sp-button-group class=${classMap(classes)}>\n <slot name=\"button\"></slot>\n </sp-button-group>\n `;\n }\n\n protected renderDismiss(): TemplateResult {\n return html`\n <sp-close-button\n class=\"close-button\"\n label=\"Close\"\n quiet\n size=\"m\"\n @click=${this.close}\n ></sp-close-button>\n `;\n }\n\n protected override render(): TemplateResult {\n return html`\n <div class=\"grid\">\n ${this.renderHero()} ${this.renderHeading()}\n ${this.error\n ? html`\n <sp-icon-alert class=\"type-icon\"></sp-icon-alert>\n `\n : nothing}\n ${this.noDivider\n ? nothing\n : html`\n <sp-divider size=\"m\" class=\"divider\"></sp-divider>\n `}\n ${this.renderContent()}\n ${this.hasFooter ? this.renderFooter() : nothing}\n ${this.hasButtons ? this.renderButtons() : nothing}\n ${this.dismissable ? this.renderDismiss() : nothing}\n </div>\n `;\n }\n\n public shouldManageTabOrderForScrolling = (): void => {\n const { offsetHeight, scrollHeight } = this.contentElement;\n if (offsetHeight < scrollHeight) {\n this.contentElement.tabIndex = 0;\n } else {\n this.contentElement.removeAttribute('tabindex');\n }\n };\n\n protected override shouldUpdate(changes: PropertyValues): boolean {\n if (changes.has('mode') && !!this.mode) {\n this.dismissable = false;\n }\n if (changes.has('dismissable') && this.dismissable) {\n this.dismissable = !this.mode;\n }\n return super.shouldUpdate(changes);\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n this.setAttribute('role', 'dialog');\n }\n\n static instanceCount = 0;\n private labelledbyId = `sp-dialog-label-${Dialog.instanceCount++}`;\n private conditionLabelledby?: () => void;\n private conditionDescribedby?: () => void;\n\n private onHeadingSlotchange({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n if (this.conditionLabelledby) {\n this.conditionLabelledby();\n delete this.conditionLabelledby;\n }\n const ids = gatherAppliedIdsFromSlottedChildren(\n target,\n this.labelledbyId\n );\n if (ids.length) {\n this.conditionLabelledby = conditionAttributeWithId(\n this,\n 'aria-labelledby',\n ids\n );\n }\n }\n\n private describedbyId = `sp-dialog-description-${Dialog.instanceCount++}`;\n\n protected onContentSlotChange({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n if (this.conditionDescribedby) {\n this.conditionDescribedby();\n delete this.conditionDescribedby;\n }\n const ids = gatherAppliedIdsFromSlottedChildren(\n target,\n this.describedbyId\n );\n if (ids.length && ids.length < 4) {\n this.conditionDescribedby = conditionAttributeWithId(\n this,\n 'aria-describedby',\n ids\n );\n } else if (!ids.length) {\n const idProvided = !!this.id;\n if (!idProvided) this.id = this.describedbyId;\n const conditionDescribedby = conditionAttributeWithId(\n this,\n 'aria-describedby',\n this.id\n );\n this.conditionDescribedby = () => {\n conditionDescribedby();\n if (!idProvided) {\n this.removeAttribute('id');\n }\n };\n }\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.tabIndex = 0;\n window.addEventListener(\n 'resize',\n this.shouldManageTabOrderForScrolling\n );\n }\n\n public override disconnectedCallback(): void {\n window.removeEventListener(\n 'resize',\n this.shouldManageTabOrderForScrolling\n );\n super.disconnectedCallback();\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EACA;AAAA,EAEA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,gBAAgB;AACzB,SAAS,gCAAgC;AAEzC,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AAEP,OAAO,YAAY;AAGnB,SAAS,oCACL,MACA,QACQ;AACR,QAAM,mBAAmB,KAAK,iBAAiB;AAC/C,QAAM,MAAgB,CAAC;AACvB,mBAAiB,QAAQ,CAAC,IAAI,MAAM;AAChC,QAAI,GAAG,IAAI;AACP,UAAI,KAAK,GAAG,EAAE;AAAA,IAClB,OAAO;AACH,YAAM,KAAK,SAAS,IAAI;AACxB,SAAG,KAAK;AACR,UAAI,KAAK,EAAE;AAAA,IACf;AAAA,EACJ,CAAC;AACD,SAAO;AACX;AAYO,MAAM,UAAN,cAAqB;AAAA,EACxB,oBAAoB,iBAAiB;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,EACJ,CAAC;AACL,EAAE;AAAA,EANK;AAAA;AAkBH,SAAO,QAAQ;AAGf,SAAO,cAAc;AAerB,SAAO,YAAY;AA4FnB,SAAO,mCAAmC,MAAY;AAClD,YAAM,EAAE,cAAc,aAAa,IAAI,KAAK;AAC5C,UAAI,eAAe,cAAc;AAC7B,aAAK,eAAe,WAAW;AAAA,MACnC,OAAO;AACH,aAAK,eAAe,gBAAgB,UAAU;AAAA,MAClD;AAAA,IACJ;AAkBA,SAAQ,eAAe,mBAAmB,QAAO;AAwBjD,SAAQ,gBAAgB,yBAAyB,QAAO;AAAA;AAAA,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;AACA,WAAK,uBAAuB,MAAM;AAC9B,6BAAqB;AACrB,YAAI,CAAC,YAAY;AACb,eAAK,gBAAgB,IAAI;AAAA,QAC7B;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AAAA,EAEgB,oBAA0B;AACtC,UAAM,kBAAkB;AACxB,SAAK,WAAW;AAChB,WAAO;AAAA,MACH;AAAA,MACA,KAAK;AAAA,IACT;AAAA,EACJ;AAAA,EAEgB,uBAA6B;AACzC,WAAO;AAAA,MACH;AAAA,MACA,KAAK;AAAA,IACT;AACA,UAAM,qBAAqB;AAAA,EAC/B;AACJ;AArOO,WAAM,SAAN;AAAM,OAwJF,gBAAgB;AA5IvB;AAAA,EADC,MAAM,eAAe;AAAA,GAXb,OAYT;AAGQ;AAAA,EADP,MAAM,UAAU;AAAA,GAdR,OAeD;AAGD;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GAjBjC,OAkBF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GApBjC,OAqBF;AAeA;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,aAAa,CAAC;AAAA,GAnC1D,OAoCF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAtChC,OAuCF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAzChC,OA0CF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/Dialog.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var m=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var i=(a,r,e,t)=>{for(var o=t>1?void 0:t?v(r,e):r,n=a.length-1,l;n>=0;n--)(l=a[n])&&(o=(t?l(r,e,o):l(o))||o);return t&&o&&m(r,e,o),o};import{html as s,nothing as d,SpectrumElement as f}from"@spectrum-web-components/base";import{property as c,query as p}from"@spectrum-web-components/base/src/decorators.js";import{classMap as g}from"@spectrum-web-components/base/src/directives.js";import{conditionAttributeWithId as u}from"@spectrum-web-components/base/src/condition-attribute-with-id.js";import"@spectrum-web-components/divider/sp-divider.js";import"@spectrum-web-components/button/sp-close-button.js";import"@spectrum-web-components/button-group/sp-button-group.js";import"@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js";import{FocusVisiblePolyfillMixin as y,ObserveSlotPresence as C}from"@spectrum-web-components/shared";import S from"./dialog.css.js";function h(a,r){const e=a.assignedElements(),t=[];return e.forEach((o,n)=>{if(o.id)t.push(o.id);else{const l=r+`-${n}`;o.id=l,t.push(l)}}),t}const b=class extends y(C(f,['[slot="hero"]','[slot="footer"]','[slot="button"]'])){constructor(){super(...arguments);this.error=!1;this.dismissable=!1;this.noDivider=!1;this.shouldManageTabOrderForScrolling=()=>{const{offsetHeight:e,scrollHeight:t}=this.contentElement;e<t?this.contentElement.tabIndex=0:this.contentElement.removeAttribute("tabindex")};this.labelledbyId=`sp-dialog-label-${b.instanceCount++}`;this.describedbyId=`sp-dialog-description-${b.instanceCount++}`}static get styles(){return[S]}get hasFooter(){return this.getSlotContentPresence('[slot="footer"]')}get hasButtons(){return this.getSlotContentPresence('[slot="button"]')}get hasHero(){return this.getSlotContentPresence('[slot="hero"]')}close(){this.dispatchEvent(new Event("close",{bubbles:!0,composed:!0,cancelable:!0}))}renderHero(){return s`
|
|
2
2
|
<slot name="hero"></slot>
|
|
3
|
-
`}renderHeading(){return
|
|
3
|
+
`}renderHeading(){return s`
|
|
4
4
|
<slot name="heading" @slotchange=${this.onHeadingSlotchange}></slot>
|
|
5
|
-
`}renderContent(){return
|
|
5
|
+
`}renderContent(){return s`
|
|
6
6
|
<div class="content">
|
|
7
7
|
<slot @slotchange=${this.onContentSlotChange}></slot>
|
|
8
8
|
</div>
|
|
9
|
-
`}renderFooter(){return
|
|
9
|
+
`}renderFooter(){return s`
|
|
10
10
|
<div class="footer">
|
|
11
11
|
<slot name="footer"></slot>
|
|
12
12
|
</div>
|
|
13
|
-
`}renderButtons(){const e={"button-group":!0,"button-group--noFooter":!this.hasFooter};return
|
|
13
|
+
`}renderButtons(){const e={"button-group":!0,"button-group--noFooter":!this.hasFooter};return s`
|
|
14
14
|
<sp-button-group class=${g(e)}>
|
|
15
15
|
<slot name="button"></slot>
|
|
16
16
|
</sp-button-group>
|
|
17
|
-
`}renderDismiss(){return
|
|
17
|
+
`}renderDismiss(){return s`
|
|
18
18
|
<sp-close-button
|
|
19
19
|
class="close-button"
|
|
20
20
|
label="Close"
|
|
@@ -22,13 +22,13 @@ var m=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var r=(a,e,t,s
|
|
|
22
22
|
size="m"
|
|
23
23
|
@click=${this.close}
|
|
24
24
|
></sp-close-button>
|
|
25
|
-
`}render(){return
|
|
25
|
+
`}render(){return s`
|
|
26
26
|
<div class="grid">
|
|
27
27
|
${this.renderHero()} ${this.renderHeading()}
|
|
28
|
-
${this.error?
|
|
28
|
+
${this.error?s`
|
|
29
29
|
<sp-icon-alert class="type-icon"></sp-icon-alert>
|
|
30
30
|
`:d}
|
|
31
|
-
${this.noDivider?d:
|
|
31
|
+
${this.noDivider?d:s`
|
|
32
32
|
<sp-divider size="m" class="divider"></sp-divider>
|
|
33
33
|
`}
|
|
34
34
|
${this.renderContent()}
|
|
@@ -36,5 +36,5 @@ var m=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var r=(a,e,t,s
|
|
|
36
36
|
${this.hasButtons?this.renderButtons():d}
|
|
37
37
|
${this.dismissable?this.renderDismiss():d}
|
|
38
38
|
</div>
|
|
39
|
-
`}shouldUpdate(e){return e.has("mode")&&!!this.mode&&(this.dismissable=!1),e.has("dismissable")&&this.dismissable&&(this.dismissable=!this.mode),super.shouldUpdate(e)}firstUpdated(e){super.firstUpdated(e),this.setAttribute("role","dialog")}onHeadingSlotchange({target:e}){this.conditionLabelledby&&(this.conditionLabelledby(),delete this.conditionLabelledby);const t=h(e,this.labelledbyId);t.length&&(this.conditionLabelledby=u(this,"aria-labelledby",t))}onContentSlotChange({target:e}){this.conditionDescribedby&&(this.conditionDescribedby(),delete this.conditionDescribedby);const t=h(e,this.describedbyId);if(t.length&&t.length<4)this.conditionDescribedby=u(this,"aria-describedby",t);else if(!t.length){const
|
|
39
|
+
`}shouldUpdate(e){return e.has("mode")&&!!this.mode&&(this.dismissable=!1),e.has("dismissable")&&this.dismissable&&(this.dismissable=!this.mode),super.shouldUpdate(e)}firstUpdated(e){super.firstUpdated(e),this.setAttribute("role","dialog")}onHeadingSlotchange({target:e}){this.conditionLabelledby&&(this.conditionLabelledby(),delete this.conditionLabelledby);const t=h(e,this.labelledbyId);t.length&&(this.conditionLabelledby=u(this,"aria-labelledby",t))}onContentSlotChange({target:e}){this.conditionDescribedby&&(this.conditionDescribedby(),delete this.conditionDescribedby);const t=h(e,this.describedbyId);if(t.length&&t.length<4)this.conditionDescribedby=u(this,"aria-describedby",t);else if(!t.length){const o=!!this.id;o||(this.id=this.describedbyId);const n=u(this,"aria-describedby",this.id);this.conditionDescribedby=()=>{n(),o||this.removeAttribute("id")}}}connectedCallback(){super.connectedCallback(),this.tabIndex=0,window.addEventListener("resize",this.shouldManageTabOrderForScrolling)}disconnectedCallback(){window.removeEventListener("resize",this.shouldManageTabOrderForScrolling),super.disconnectedCallback()}};export let Dialog=b;Dialog.instanceCount=0,i([p(".close-button")],Dialog.prototype,"closeButton",2),i([p(".content")],Dialog.prototype,"contentElement",2),i([c({type:Boolean,reflect:!0})],Dialog.prototype,"error",2),i([c({type:Boolean,reflect:!0})],Dialog.prototype,"dismissable",2),i([c({type:Boolean,reflect:!0,attribute:"no-divider"})],Dialog.prototype,"noDivider",2),i([c({type:String,reflect:!0})],Dialog.prototype,"mode",2),i([c({type:String,reflect:!0})],Dialog.prototype,"size",2);
|
|
40
40
|
//# sourceMappingURL=Dialog.js.map
|
package/src/Dialog.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Dialog.ts"],
|
|
4
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\nimport {\n CSSResultArray,\n html,\n nothing,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { classMap } from '@spectrum-web-components/base/src/directives.js';\nimport { conditionAttributeWithId } from '@spectrum-web-components/base/src/condition-attribute-with-id.js';\n\nimport '@spectrum-web-components/divider/sp-divider.js';\nimport '@spectrum-web-components/button/sp-close-button.js';\nimport '@spectrum-web-components/button-group/sp-button-group.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';\nimport {\n FocusVisiblePolyfillMixin,\n ObserveSlotPresence,\n} from '@spectrum-web-components/shared';\n\nimport styles from './dialog.css.js';\nimport type { CloseButton } from '@spectrum-web-components/button';\n\nfunction gatherAppliedIdsFromSlottedChildren(\n slot: HTMLSlotElement,\n idBase: string\n): string[] {\n const assignedElements = slot.assignedElements();\n const ids: string[] = [];\n assignedElements.forEach((el, i) => {\n if (el.id) {\n ids.push(el.id);\n } else {\n const id = idBase + `-${i}`;\n el.id = id;\n ids.push(id);\n }\n });\n return ids;\n}\n\n/**\n * @element sp-dialog\n *\n * @slot hero - Accepts a hero image to display at the top of the dialog\n * @slot heading - Acts as the heading of the dialog. This should be an actual heading tag `<h1-6 />`\n * @slot - Content not addressed to a specific slot will be interpreted as the main content of the dialog\n * @slot footer - Content addressed to the `footer` will be placed below the main content and to the side of any `[slot='button']` content\n * @slot button - Button elements addressed to this slot may be placed below the content when not delivered in a fullscreen mode\n * @fires close - Announces that the dialog has been closed.\n */\nexport class Dialog extends FocusVisiblePolyfillMixin(\n ObserveSlotPresence(SpectrumElement, [\n '[slot=\"hero\"]',\n '[slot=\"footer\"]',\n '[slot=\"button\"]',\n ])\n) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @query('.close-button')\n closeButton?: CloseButton;\n\n @query('.content')\n private contentElement!: HTMLDivElement;\n\n @property({ type: Boolean, reflect: true })\n public error = false;\n\n @property({ type: Boolean, reflect: true })\n public dismissable = false;\n\n protected get hasFooter(): boolean {\n return this.getSlotContentPresence('[slot=\"footer\"]');\n }\n\n protected get hasButtons(): boolean {\n return this.getSlotContentPresence('[slot=\"button\"]');\n }\n\n protected get hasHero(): boolean {\n return this.getSlotContentPresence('[slot=\"hero\"]');\n }\n\n @property({ type: Boolean, reflect: true, attribute: 'no-divider' })\n public noDivider = false;\n\n @property({ type: String, reflect: true })\n public mode?: 'fullscreen' | 'fullscreenTakeover';\n\n @property({ type: String, reflect: true })\n public size?: 's' | 'm' | 'l';\n\n public close(): void {\n this.dispatchEvent(\n new Event('close', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n }\n\n protected renderHero(): TemplateResult {\n return html`\n <slot name=\"hero\"></slot>\n `;\n }\n\n protected renderHeading(): TemplateResult {\n return html`\n <slot name=\"heading\" @slotchange=${this.onHeadingSlotchange}></slot>\n `;\n }\n\n protected renderContent(): TemplateResult {\n return html`\n <div class=\"content\">\n <slot @slotchange=${this.onContentSlotChange}></slot>\n </div>\n `;\n }\n\n protected renderFooter(): TemplateResult {\n return html`\n <div class=\"footer\">\n <slot name=\"footer\"></slot>\n </div>\n `;\n }\n\n protected renderButtons(): TemplateResult {\n const classes = {\n 'button-group': true,\n 'button-group--noFooter': !this.hasFooter,\n };\n return html`\n <sp-button-group class=${classMap(classes)}>\n <slot name=\"button\"></slot>\n </sp-button-group>\n `;\n }\n\n protected renderDismiss(): TemplateResult {\n return html`\n <sp-close-button\n class=\"close-button\"\n label=\"Close\"\n quiet\n size=\"m\"\n @click=${this.close}\n ></sp-close-button>\n `;\n }\n\n protected override render(): TemplateResult {\n return html`\n <div class=\"grid\">\n ${this.renderHero()} ${this.renderHeading()}\n ${this.error\n ? html`\n <sp-icon-alert class=\"type-icon\"></sp-icon-alert>\n `\n : nothing}\n ${this.noDivider\n ? nothing\n : html`\n <sp-divider size=\"m\" class=\"divider\"></sp-divider>\n `}\n ${this.renderContent()}\n ${this.hasFooter ? this.renderFooter() : nothing}\n ${this.hasButtons ? this.renderButtons() : nothing}\n ${this.dismissable ? this.renderDismiss() : nothing}\n </div>\n `;\n }\n\n public shouldManageTabOrderForScrolling = (): void => {\n const { offsetHeight, scrollHeight } = this.contentElement;\n if (offsetHeight < scrollHeight) {\n this.contentElement.tabIndex = 0;\n } else {\n this.contentElement.removeAttribute('tabindex');\n }\n };\n\n protected override shouldUpdate(changes: PropertyValues): boolean {\n if (changes.has('mode') && !!this.mode) {\n this.dismissable = false;\n }\n if (changes.has('dismissable') && this.dismissable) {\n this.dismissable = !this.mode;\n }\n return super.shouldUpdate(changes);\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n this.setAttribute('role', 'dialog');\n }\n\n static instanceCount = 0;\n private labelledbyId = `sp-dialog-label-${Dialog.instanceCount++}`;\n private conditionLabelledby?: () => void;\n private conditionDescribedby?: () => void;\n\n private onHeadingSlotchange({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n if (this.conditionLabelledby) {\n this.conditionLabelledby();\n delete this.conditionLabelledby;\n }\n const ids = gatherAppliedIdsFromSlottedChildren(\n target,\n this.labelledbyId\n );\n if (ids.length) {\n this.conditionLabelledby = conditionAttributeWithId(\n this,\n 'aria-labelledby',\n ids\n );\n }\n }\n\n private describedbyId = `sp-dialog-description-${Dialog.instanceCount++}`;\n\n protected onContentSlotChange({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n if (this.conditionDescribedby) {\n this.conditionDescribedby();\n delete this.conditionDescribedby;\n }\n const ids = gatherAppliedIdsFromSlottedChildren(\n target,\n this.describedbyId\n );\n if (ids.length && ids.length < 4) {\n this.conditionDescribedby = conditionAttributeWithId(\n this,\n 'aria-describedby',\n ids\n );\n } else if (!ids.length) {\n const idProvided = !!this.id;\n if (!idProvided) this.id = this.describedbyId;\n const conditionDescribedby = conditionAttributeWithId(\n this,\n 'aria-describedby',\n this.id\n );\n this.conditionDescribedby = () => {\n conditionDescribedby();\n if (!idProvided) {\n this.removeAttribute('id');\n }\n };\n }\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.tabIndex = 0;\n window.addEventListener(\n 'resize',\n this.shouldManageTabOrderForScrolling\n );\n }\n\n public override disconnectedCallback(): void {\n window.removeEventListener(\n 'resize',\n this.shouldManageTabOrderForScrolling\n );\n super.disconnectedCallback();\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "qNAYA,OAEI,QAAAA,EACA,WAAAC,EAEA,mBAAAC,MAEG,gCACP,OACI,YAAAC,EACA,SAAAC,MACG,kDACP,OAAS,YAAAC,MAAgB,kDACzB,OAAS,4BAAAC,MAAgC,mEAEzC,MAAO,iDACP,MAAO,qDACP,MAAO,2DACP,MAAO,iEACP,OACI,6BAAAC,EACA,uBAAAC,MACG,kCAEP,OAAOC,MAAY,kBAGnB,SAASC,EACLC,EACAC,EACQ,CACR,MAAMC,EAAmBF,EAAK,iBAAiB,EACzCG,EAAgB,CAAC,EACvB,OAAAD,EAAiB,QAAQ,CAACE,EAAIC,IAAM,CAChC,GAAID,EAAG,GACHD,EAAI,KAAKC,EAAG,EAAE,MACX,CACH,MAAME,EAAKL,EAAS,IAAII,IACxBD,EAAG,GAAKE,EACRH,EAAI,KAAKG,CAAE,CACf,CACJ,CAAC,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,EAChBD,GACD,KAAK,gBAAgB,IAAI,CAEjC,CACJ,CACJ,CAEgB,mBAA0B,CACtC,MAAM,kBAAkB,EACxB,KAAK,SAAW,EAChB,OAAO,iBACH,SACA,KAAK,gCACT,CACJ,CAEgB,sBAA6B,CACzC,OAAO,oBACH,SACA,KAAK,gCACT,EACA,MAAM,qBAAqB,CAC/B,CACJ,EArOO,WAAM,OAANN,EAAM,OAwJF,cAAgB,EA5IvBQ,EAAA,CADCtB,EAAM,eAAe,GAXb,OAYT,2BAGQsB,EAAA,CADPtB,EAAM,UAAU,GAdR,OAeD,8BAGDsB,EAAA,CADNvB,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GAjBjC,OAkBF,qBAGAuB,EAAA,CADNvB,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GApBjC,OAqBF,2BAeAuB,EAAA,CADNvB,EAAS,CAAE,KAAM,QAAS,QAAS,GAAM,UAAW,YAAa,CAAC,GAnC1D,OAoCF,yBAGAuB,EAAA,CADNvB,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAtChC,OAuCF,oBAGAuB,EAAA,CADNvB,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAzChC,OA0CF",
|
|
6
|
+
"names": ["html", "nothing", "SpectrumElement", "property", "query", "classMap", "conditionAttributeWithId", "FocusVisiblePolyfillMixin", "ObserveSlotPresence", "styles", "gatherAppliedIdsFromSlottedChildren", "slot", "idBase", "assignedElements", "ids", "el", "i", "id", "_Dialog", "offsetHeight", "scrollHeight", "classes", "changes", "target", "idProvided", "conditionDescribedby", "__decorateClass"]
|
|
7
7
|
}
|
package/src/DialogWrapper.dev.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -54,7 +55,9 @@ export class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
|
54
55
|
const firstFocusable = firstFocusableIn(this.dialog);
|
|
55
56
|
if (firstFocusable) {
|
|
56
57
|
if (firstFocusable.updateComplete) {
|
|
57
|
-
firstFocusable.updateComplete.then(() =>
|
|
58
|
+
firstFocusable.updateComplete.then(() => {
|
|
59
|
+
firstFocusable.focus();
|
|
60
|
+
});
|
|
58
61
|
} else {
|
|
59
62
|
firstFocusable.focus();
|
|
60
63
|
}
|
|
@@ -79,19 +82,25 @@ export class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
|
79
82
|
this.close();
|
|
80
83
|
}
|
|
81
84
|
clickSecondary() {
|
|
82
|
-
this.dispatchEvent(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
this.dispatchEvent(
|
|
86
|
+
new Event("secondary", {
|
|
87
|
+
bubbles: true
|
|
88
|
+
})
|
|
89
|
+
);
|
|
85
90
|
}
|
|
86
91
|
clickCancel() {
|
|
87
|
-
this.dispatchEvent(
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
this.dispatchEvent(
|
|
93
|
+
new Event("cancel", {
|
|
94
|
+
bubbles: true
|
|
95
|
+
})
|
|
96
|
+
);
|
|
90
97
|
}
|
|
91
98
|
clickConfirm() {
|
|
92
|
-
this.dispatchEvent(
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
this.dispatchEvent(
|
|
100
|
+
new Event("confirm", {
|
|
101
|
+
bubbles: true
|
|
102
|
+
})
|
|
103
|
+
);
|
|
95
104
|
}
|
|
96
105
|
handleClose(event) {
|
|
97
106
|
event.stopPropagation();
|
|
@@ -101,9 +110,11 @@ export class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
|
101
110
|
this.open = false;
|
|
102
111
|
}
|
|
103
112
|
dispatchClosed() {
|
|
104
|
-
this.dispatchEvent(
|
|
105
|
-
|
|
106
|
-
|
|
113
|
+
this.dispatchEvent(
|
|
114
|
+
new Event("close", {
|
|
115
|
+
bubbles: true
|
|
116
|
+
})
|
|
117
|
+
);
|
|
107
118
|
}
|
|
108
119
|
handleUnderlayTransitionend(event) {
|
|
109
120
|
if (!this.open && event.propertyName === "visibility") {
|
|
@@ -121,7 +132,9 @@ export class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
|
121
132
|
}
|
|
122
133
|
update(changes) {
|
|
123
134
|
if (changes.has("open") && changes.get("open") !== void 0) {
|
|
124
|
-
this.transitionPromise = new Promise(
|
|
135
|
+
this.transitionPromise = new Promise(
|
|
136
|
+
(res) => this.resolveTransitionPromise = res
|
|
137
|
+
);
|
|
125
138
|
}
|
|
126
139
|
super.update(changes);
|
|
127
140
|
}
|
|
@@ -150,8 +163,12 @@ export class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
|
150
163
|
<img
|
|
151
164
|
src="${this.hero}"
|
|
152
165
|
slot="hero"
|
|
153
|
-
aria-hidden=${ifDefined(
|
|
154
|
-
|
|
166
|
+
aria-hidden=${ifDefined(
|
|
167
|
+
this.heroLabel ? void 0 : "true"
|
|
168
|
+
)}
|
|
169
|
+
alt=${ifDefined(
|
|
170
|
+
this.heroLabel ? this.heroLabel : void 0
|
|
171
|
+
)}
|
|
155
172
|
/>
|
|
156
173
|
` : html``}
|
|
157
174
|
${this.headline ? html`
|
|
@@ -161,24 +178,24 @@ export class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
|
161
178
|
${this.footer ? html`
|
|
162
179
|
<div slot="footer">${this.footer}</div>
|
|
163
180
|
` : html``}
|
|
164
|
-
${this.
|
|
181
|
+
${this.cancelLabel ? html`
|
|
165
182
|
<sp-button
|
|
166
|
-
variant="
|
|
183
|
+
variant="secondary"
|
|
167
184
|
treatment="outline"
|
|
168
185
|
slot="button"
|
|
169
|
-
@click=${this.
|
|
186
|
+
@click=${this.clickCancel}
|
|
170
187
|
>
|
|
171
|
-
${this.
|
|
188
|
+
${this.cancelLabel}
|
|
172
189
|
</sp-button>
|
|
173
190
|
` : html``}
|
|
174
|
-
${this.
|
|
191
|
+
${this.secondaryLabel ? html`
|
|
175
192
|
<sp-button
|
|
176
|
-
variant="
|
|
193
|
+
variant="primary"
|
|
177
194
|
treatment="outline"
|
|
178
195
|
slot="button"
|
|
179
|
-
@click=${this.
|
|
196
|
+
@click=${this.clickSecondary}
|
|
180
197
|
>
|
|
181
|
-
${this.
|
|
198
|
+
${this.secondaryLabel}
|
|
182
199
|
</sp-button>
|
|
183
200
|
` : html``}
|
|
184
201
|
${this.confirmLabel ? html`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["DialogWrapper.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\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nimport '@spectrum-web-components/underlay/sp-underlay.js';\nimport '@spectrum-web-components/button/sp-button.js';\n\nimport '../sp-dialog.dev.js'\nimport modalWrapperStyles from '@spectrum-web-components/modal/src/modal-wrapper.css.js';\nimport modalStyles from '@spectrum-web-components/modal/src/modal.css.js';\nimport { Dialog } from './Dialog.dev.js'\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\n\n/**\n * @element sp-dialog-wrapper\n *\n * @slot - content for the dialog\n * @fires secondary - Announces that the \"secondary\" button has been clicked.\n * @fires cancel - Announces that the \"cancel\" button has been clicked.\n * @fires confirm - Announces that the \"confirm\" button has been clicked.\n * @fires close - Announces that the dialog has been closed.\n */\nexport class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {\n public static override get styles(): CSSResultArray {\n return [modalWrapperStyles, modalStyles];\n }\n\n @property({ type: Boolean, reflect: true })\n public error = false;\n\n @property({ attribute: 'cancel-label' })\n public cancelLabel = '';\n\n @property({ attribute: 'confirm-label' })\n public confirmLabel = '';\n\n @property({ type: Boolean, reflect: true })\n public dismissable = false;\n\n @property()\n public footer = '';\n\n @property()\n public hero = '';\n\n @property({ attribute: 'hero-label' })\n public heroLabel = '';\n\n @property({ type: Boolean, reflect: true, attribute: 'no-divider' })\n public noDivider = false;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @property({ type: String, reflect: true })\n public mode?: 'fullscreen' | 'fullscreenTakeover';\n\n @property({ type: String, reflect: true })\n public size?: 's' | 'm' | 'l';\n\n @property({ attribute: 'secondary-label' })\n public secondaryLabel = '';\n\n @property()\n public headline = '';\n\n /**\n * When set to true, fills screens smaller than 350px high and 400px wide with the full dialog.\n */\n @property({ type: Boolean })\n public responsive = false;\n\n private transitionPromise = Promise.resolve();\n\n private resolveTransitionPromise = (): void => {\n return;\n };\n\n @property({ type: Boolean })\n public underlay = false;\n\n @query('sp-dialog')\n private dialog!: Dialog;\n\n public override focus(): void {\n if (this.shadowRoot) {\n const firstFocusable = firstFocusableIn(this.dialog);\n if (firstFocusable) {\n if (firstFocusable.updateComplete) {\n firstFocusable.updateComplete.then(() =>\n firstFocusable.focus()\n );\n /* c8 ignore next 3 */\n } else {\n firstFocusable.focus();\n }\n this.removeAttribute('tabindex');\n } else {\n this.dialog.focus();\n }\n /* c8 ignore next 3 */\n } else {\n super.focus();\n }\n }\n\n public overlayWillCloseCallback(): boolean {\n if (!this.open) return false;\n this.close();\n return true;\n }\n\n private dismiss(): void {\n if (!this.dismissable) {\n return;\n }\n this.close();\n }\n\n private clickSecondary(): void {\n this.dispatchEvent(\n new Event('secondary', {\n bubbles: true,\n })\n );\n }\n\n private clickCancel(): void {\n this.dispatchEvent(\n new Event('cancel', {\n bubbles: true,\n })\n );\n }\n\n private clickConfirm(): void {\n this.dispatchEvent(\n new Event('confirm', {\n bubbles: true,\n })\n );\n }\n\n protected handleClose(event: Event): void {\n event.stopPropagation();\n this.close();\n }\n\n public close(): void {\n this.open = false;\n }\n\n private dispatchClosed(): void {\n this.dispatchEvent(\n new Event('close', {\n bubbles: true,\n })\n );\n }\n\n protected handleUnderlayTransitionend(event: TransitionEvent): void {\n if (!this.open && event.propertyName === 'visibility') {\n this.dispatchClosed();\n this.resolveTransitionPromise();\n }\n }\n\n protected handleModalTransitionend(): void {\n if (this.open || !this.underlay) {\n this.resolveTransitionPromise();\n if (!this.open) {\n this.dispatchClosed();\n }\n }\n }\n\n protected override update(changes: PropertyValues<this>): void {\n if (changes.has('open') && changes.get('open') !== undefined) {\n this.transitionPromise = new Promise(\n (res) => (this.resolveTransitionPromise = res)\n );\n }\n super.update(changes);\n }\n\n protected override render(): TemplateResult {\n return html`\n ${this.underlay\n ? html`\n <sp-underlay\n ?open=${this.open}\n @click=${this.dismiss}\n @transitionend=${this.handleUnderlayTransitionend}\n ></sp-underlay>\n `\n : html``}\n <div\n class=\"modal ${this.mode}\"\n @transitionend=${this.handleModalTransitionend}\n >\n <sp-dialog\n ?dismissable=${this.dismissable}\n ?no-divider=${this.noDivider}\n ?error=${this.error}\n mode=${ifDefined(this.mode ? this.mode : undefined)}\n size=${ifDefined(this.size ? this.size : undefined)}\n @close=${this.handleClose}\n >\n ${this.hero\n ? html`\n <img\n src=\"${this.hero}\"\n slot=\"hero\"\n aria-hidden=${ifDefined(\n this.heroLabel ? undefined : 'true'\n )}\n alt=${ifDefined(\n this.heroLabel\n ? this.heroLabel\n : undefined\n )}\n />\n `\n : html``}\n ${this.headline\n ? html`\n <h2 slot=\"heading\">${this.headline}</h2>\n `\n : html``}\n <slot></slot>\n ${this.footer\n ? html`\n <div slot=\"footer\">${this.footer}</div>\n `\n : html``}\n ${this.secondaryLabel\n ? html`\n <sp-button\n variant=\"primary\"\n treatment=\"outline\"\n slot=\"button\"\n @click=${this.clickSecondary}\n >\n ${this.secondaryLabel}\n </sp-button>\n `\n : html``}\n ${this.cancelLabel\n ? html`\n <sp-button\n variant=\"secondary\"\n treatment=\"outline\"\n slot=\"button\"\n @click=${this.clickCancel}\n >\n ${this.cancelLabel}\n </sp-button>\n `\n : html``}\n ${this.confirmLabel\n ? html`\n <sp-button\n variant=\"accent\"\n slot=\"button\"\n @click=${this.clickConfirm}\n >\n ${this.confirmLabel}\n </sp-button>\n `\n : html``}\n </sp-dialog>\n </div>\n `;\n }\n\n protected override updated(changes: PropertyValues<this>): void {\n if (changes.has('open')) {\n if (this.open) {\n this.dialog.updateComplete.then(() => {\n this.dialog.shouldManageTabOrderForScrolling();\n });\n } else {\n this.tabIndex = 0;\n }\n }\n }\n\n /**\n * Bind the open/close transition into the update complete lifecycle so\n * that the overlay system can wait for it to be \"visibly ready\" before\n * attempting to throw focus into the content contained herein. Not\n * waiting for this can cause small amounts of page scroll to happen\n * while opening the Tray when focusable content is included: e.g. Menu\n * elements whose selected Menu Item is not the first Menu Item.\n */\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.transitionPromise;\n return complete;\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
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\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nimport '@spectrum-web-components/underlay/sp-underlay.js';\nimport '@spectrum-web-components/button/sp-button.js';\n\nimport '../sp-dialog.dev.js'\nimport modalWrapperStyles from '@spectrum-web-components/modal/src/modal-wrapper.css.js';\nimport modalStyles from '@spectrum-web-components/modal/src/modal.css.js';\nimport { Dialog } from './Dialog.dev.js'\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\n\n/**\n * @element sp-dialog-wrapper\n *\n * @slot - content for the dialog\n * @fires secondary - Announces that the \"secondary\" button has been clicked.\n * @fires cancel - Announces that the \"cancel\" button has been clicked.\n * @fires confirm - Announces that the \"confirm\" button has been clicked.\n * @fires close - Announces that the dialog has been closed.\n */\nexport class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {\n public static override get styles(): CSSResultArray {\n return [modalWrapperStyles, modalStyles];\n }\n\n @property({ type: Boolean, reflect: true })\n public error = false;\n\n @property({ attribute: 'cancel-label' })\n public cancelLabel = '';\n\n @property({ attribute: 'confirm-label' })\n public confirmLabel = '';\n\n @property({ type: Boolean, reflect: true })\n public dismissable = false;\n\n @property()\n public footer = '';\n\n @property()\n public hero = '';\n\n @property({ attribute: 'hero-label' })\n public heroLabel = '';\n\n @property({ type: Boolean, reflect: true, attribute: 'no-divider' })\n public noDivider = false;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @property({ type: String, reflect: true })\n public mode?: 'fullscreen' | 'fullscreenTakeover';\n\n @property({ type: String, reflect: true })\n public size?: 's' | 'm' | 'l';\n\n @property({ attribute: 'secondary-label' })\n public secondaryLabel = '';\n\n @property()\n public headline = '';\n\n /**\n * When set to true, fills screens smaller than 350px high and 400px wide with the full dialog.\n */\n @property({ type: Boolean })\n public responsive = false;\n\n private transitionPromise = Promise.resolve();\n\n private resolveTransitionPromise = (): void => {\n return;\n };\n\n @property({ type: Boolean })\n public underlay = false;\n\n @query('sp-dialog')\n private dialog!: Dialog;\n\n public override focus(): void {\n if (this.shadowRoot) {\n const firstFocusable = firstFocusableIn(this.dialog);\n if (firstFocusable) {\n if (firstFocusable.updateComplete) {\n firstFocusable.updateComplete.then(() => {\n firstFocusable.focus();\n });\n /* c8 ignore next 3 */\n } else {\n firstFocusable.focus();\n }\n this.removeAttribute('tabindex');\n } else {\n this.dialog.focus();\n }\n /* c8 ignore next 3 */\n } else {\n super.focus();\n }\n }\n\n public overlayWillCloseCallback(): boolean {\n if (!this.open) return false;\n this.close();\n return true;\n }\n\n private dismiss(): void {\n if (!this.dismissable) {\n return;\n }\n this.close();\n }\n\n private clickSecondary(): void {\n this.dispatchEvent(\n new Event('secondary', {\n bubbles: true,\n })\n );\n }\n\n private clickCancel(): void {\n this.dispatchEvent(\n new Event('cancel', {\n bubbles: true,\n })\n );\n }\n\n private clickConfirm(): void {\n this.dispatchEvent(\n new Event('confirm', {\n bubbles: true,\n })\n );\n }\n\n protected handleClose(event: Event): void {\n event.stopPropagation();\n this.close();\n }\n\n public close(): void {\n this.open = false;\n }\n\n private dispatchClosed(): void {\n this.dispatchEvent(\n new Event('close', {\n bubbles: true,\n })\n );\n }\n\n protected handleUnderlayTransitionend(event: TransitionEvent): void {\n if (!this.open && event.propertyName === 'visibility') {\n this.dispatchClosed();\n this.resolveTransitionPromise();\n }\n }\n\n protected handleModalTransitionend(): void {\n if (this.open || !this.underlay) {\n this.resolveTransitionPromise();\n if (!this.open) {\n this.dispatchClosed();\n }\n }\n }\n\n protected override update(changes: PropertyValues<this>): void {\n if (changes.has('open') && changes.get('open') !== undefined) {\n this.transitionPromise = new Promise(\n (res) => (this.resolveTransitionPromise = res)\n );\n }\n super.update(changes);\n }\n\n protected override render(): TemplateResult {\n return html`\n ${this.underlay\n ? html`\n <sp-underlay\n ?open=${this.open}\n @click=${this.dismiss}\n @transitionend=${this.handleUnderlayTransitionend}\n ></sp-underlay>\n `\n : html``}\n <div\n class=\"modal ${this.mode}\"\n @transitionend=${this.handleModalTransitionend}\n >\n <sp-dialog\n ?dismissable=${this.dismissable}\n ?no-divider=${this.noDivider}\n ?error=${this.error}\n mode=${ifDefined(this.mode ? this.mode : undefined)}\n size=${ifDefined(this.size ? this.size : undefined)}\n @close=${this.handleClose}\n >\n ${this.hero\n ? html`\n <img\n src=\"${this.hero}\"\n slot=\"hero\"\n aria-hidden=${ifDefined(\n this.heroLabel ? undefined : 'true'\n )}\n alt=${ifDefined(\n this.heroLabel\n ? this.heroLabel\n : undefined\n )}\n />\n `\n : html``}\n ${this.headline\n ? html`\n <h2 slot=\"heading\">${this.headline}</h2>\n `\n : html``}\n <slot></slot>\n ${this.footer\n ? html`\n <div slot=\"footer\">${this.footer}</div>\n `\n : html``}\n ${this.cancelLabel\n ? html`\n <sp-button\n variant=\"secondary\"\n treatment=\"outline\"\n slot=\"button\"\n @click=${this.clickCancel}\n >\n ${this.cancelLabel}\n </sp-button>\n `\n : html``}\n ${this.secondaryLabel\n ? html`\n <sp-button\n variant=\"primary\"\n treatment=\"outline\"\n slot=\"button\"\n @click=${this.clickSecondary}\n >\n ${this.secondaryLabel}\n </sp-button>\n `\n : html``}\n ${this.confirmLabel\n ? html`\n <sp-button\n variant=\"accent\"\n slot=\"button\"\n @click=${this.clickConfirm}\n >\n ${this.confirmLabel}\n </sp-button>\n `\n : html``}\n </sp-dialog>\n </div>\n `;\n }\n\n protected override updated(changes: PropertyValues<this>): void {\n if (changes.has('open')) {\n if (this.open) {\n this.dialog.updateComplete.then(() => {\n this.dialog.shouldManageTabOrderForScrolling();\n });\n } else {\n this.tabIndex = 0;\n }\n }\n }\n\n /**\n * Bind the open/close transition into the update complete lifecycle so\n * that the overlay system can wait for it to be \"visibly ready\" before\n * attempting to throw focus into the content contained herein. Not\n * waiting for this can cause small amounts of page scroll to happen\n * while opening the Tray when focusable content is included: e.g. Menu\n * elements whose selected Menu Item is not the first Menu Item.\n */\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.transitionPromise;\n return complete;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EAEA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,iBAAiB;AAE1B,OAAO;AACP,OAAO;AAEP,OAAO;AACP,OAAO,wBAAwB;AAC/B,OAAO,iBAAiB;AAExB,SAAS,iCAAiC;AAC1C,SAAS,wBAAwB;AAW1B,aAAM,sBAAsB,0BAA0B,eAAe,EAAE;AAAA,EAAvE;AAAA;AAMH,SAAO,QAAQ;AAGf,SAAO,cAAc;AAGrB,SAAO,eAAe;AAGtB,SAAO,cAAc;AAGrB,SAAO,SAAS;AAGhB,SAAO,OAAO;AAGd,SAAO,YAAY;AAGnB,SAAO,YAAY;AAGnB,SAAO,OAAO;AASd,SAAO,iBAAiB;AAGxB,SAAO,WAAW;AAMlB,SAAO,aAAa;AAEpB,SAAQ,oBAAoB,QAAQ,QAAQ;AAE5C,SAAQ,2BAA2B,MAAY;AAC3C;AAAA,IACJ;AAGA,SAAO,WAAW;AAAA;AAAA,EAxDlB,WAA2B,SAAyB;AAChD,WAAO,CAAC,oBAAoB,WAAW;AAAA,EAC3C;AAAA,EA2DgB,QAAc;AAC1B,QAAI,KAAK,YAAY;AACjB,YAAM,iBAAiB,iBAAiB,KAAK,MAAM;AACnD,UAAI,gBAAgB;AAChB,YAAI,eAAe,gBAAgB;AAC/B,yBAAe,eAAe,KAAK,MAAM;AACrC,2BAAe,MAAM;AAAA,UACzB,CAAC;AAAA,QAEL,OAAO;AACH,yBAAe,MAAM;AAAA,QACzB;AACA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