@getflip/swirl-components 0.442.0 → 0.443.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components.json +32 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-dialog.cjs.entry.js +17 -1
- package/dist/collection/components/swirl-dialog/swirl-dialog.js +41 -1
- package/dist/collection/components/swirl-dialog/swirl-dialog.stories.js +6 -0
- package/dist/components/assets/pdfjs/pdf.worker.min.mjs +1 -1
- package/dist/components/swirl-dialog.js +18 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-dialog.entry.js +17 -1
- package/dist/swirl-components/p-4e496744.entry.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-dialog/swirl-dialog.d.ts +2 -0
- package/dist/types/components/swirl-dialog/swirl-dialog.stories.d.ts +6 -0
- package/dist/types/components.d.ts +2 -0
- package/package.json +1 -1
- package/vscode-data.json +4 -0
- package/dist/swirl-components/p-73baa905.entry.js +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { h, Host, } from "@stencil/core";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
+
import { tabbable } from "tabbable";
|
|
3
4
|
/**
|
|
4
5
|
* @slot slot - The dialog content
|
|
5
6
|
* @slot left-controls - Controls displayed on the left side of the default ones
|
|
@@ -76,12 +77,27 @@ export class SwirlDialog {
|
|
|
76
77
|
this.closing = true;
|
|
77
78
|
setTimeout(() => {
|
|
78
79
|
this.dialogEl.close();
|
|
80
|
+
if (this.returnFocusTo) {
|
|
81
|
+
this.customFocusReturn();
|
|
82
|
+
}
|
|
79
83
|
}, 150);
|
|
80
84
|
}
|
|
85
|
+
customFocusReturn() {
|
|
86
|
+
const element = typeof this.returnFocusTo === "string"
|
|
87
|
+
? document.querySelector(this.returnFocusTo)
|
|
88
|
+
: this.returnFocusTo;
|
|
89
|
+
const focusableElements = tabbable(element, {
|
|
90
|
+
includeContainer: true,
|
|
91
|
+
getShadowRoot: true,
|
|
92
|
+
});
|
|
93
|
+
if (focusableElements.length > 0) {
|
|
94
|
+
focusableElements[0].focus();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
81
97
|
render() {
|
|
82
98
|
const className = classnames("dialog", { "dialog--closing": this.closing });
|
|
83
99
|
const hasLeftControls = Boolean(this.el.querySelector('[slot="left-controls"]'));
|
|
84
|
-
return (h(Host, { key: '
|
|
100
|
+
return (h(Host, { key: '96dda6293b1d08c47f87f939eacfb089f21f8e85' }, h("dialog", { key: '792f1f6afd587fae84fc52a62449a794e3f03e33', "aria-describedby": "content", "aria-labelledby": this.hideLabel ? undefined : "label", "aria-label": this.hideLabel ? this.label : undefined, class: className, onClose: this.onClose, onKeyDown: this.onKeyDown, onToggle: this.onToggle, role: "alertdialog", ref: (el) => (this.dialogEl = el) }, h("div", { key: '2bca81bc4a2e538f7e080a7d77dc648657938659', class: "dialog__backdrop", onClick: this.onBackdropClick }), h("div", { key: 'f65ff30e4e5b968beb4173e80998a03e1ca39fca', class: "dialog__body", part: "dialog__body", role: "document" }, !this.hideLabel && (h("h2", { key: 'e1f6baa4050471e29eec852df3a6e8e71925bd9c', class: "dialog__heading", part: "dialog__heading", id: "label" }, this.label)), h("div", { key: 'd8f4cc8d93de3aad7d45d3699aa49b73ec5efdcb', class: "dialog__content", part: "dialog__content", id: "content" }, h("slot", { key: '729e24ecc1de0624279a38723a58ccd7e92f119f' })), h("div", { key: '5340b93042e36af091648b0893a4090d124e7f95', class: "dialog__controls" }, hasLeftControls && (h("div", { key: 'd7064763e1a2f3cd7e7b64f9c36cb0ccb72c595e', class: "dialog__left_controls" }, h("slot", { key: '52525262d65555376b3dc911265dc35f7c801cdb', name: "left-controls" }))), this.secondaryActionLabel && (h("swirl-button", { key: '9adbe0bf902960014f25adcd8ab203a3e2e3a773', label: this.secondaryActionLabel, onClick: this.onSecondaryAction })), this.primaryActionLabel && (h("swirl-button", { key: '842263d779c24ecd30928d040cdaa4600eab3fc6', intent: this.intent, label: this.primaryActionLabel, onClick: this.onPrimaryAction, variant: "flat" })))))));
|
|
85
101
|
}
|
|
86
102
|
static get is() { return "swirl-dialog"; }
|
|
87
103
|
static get encapsulation() { return "shadow"; }
|
|
@@ -180,6 +196,30 @@ export class SwirlDialog {
|
|
|
180
196
|
"setter": false,
|
|
181
197
|
"reflect": false
|
|
182
198
|
},
|
|
199
|
+
"returnFocusTo": {
|
|
200
|
+
"type": "string",
|
|
201
|
+
"attribute": "return-focus-to",
|
|
202
|
+
"mutable": false,
|
|
203
|
+
"complexType": {
|
|
204
|
+
"original": "HTMLElement | string",
|
|
205
|
+
"resolved": "HTMLElement | string",
|
|
206
|
+
"references": {
|
|
207
|
+
"HTMLElement": {
|
|
208
|
+
"location": "global",
|
|
209
|
+
"id": "global::HTMLElement"
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"required": false,
|
|
214
|
+
"optional": true,
|
|
215
|
+
"docs": {
|
|
216
|
+
"tags": [],
|
|
217
|
+
"text": ""
|
|
218
|
+
},
|
|
219
|
+
"getter": false,
|
|
220
|
+
"setter": false,
|
|
221
|
+
"reflect": false
|
|
222
|
+
},
|
|
183
223
|
"secondaryActionLabel": {
|
|
184
224
|
"type": "string",
|
|
185
225
|
"attribute": "secondary-action-label",
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { generateStoryElement } from "../../utils";
|
|
2
2
|
import Docs from "./swirl-dialog.mdx";
|
|
3
3
|
export default {
|
|
4
|
+
argTypes: {
|
|
5
|
+
returnFocusTo: {
|
|
6
|
+
control: "text",
|
|
7
|
+
description: "Use when dialog trigger element is unmounted before the dialog is closed.",
|
|
8
|
+
},
|
|
9
|
+
},
|
|
4
10
|
component: "swirl-dialog",
|
|
5
11
|
tags: ["autodocs"],
|
|
6
12
|
parameters: {
|