@getflip/swirl-components 0.78.1 → 0.80.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 +140 -6
- package/dist/cjs/file-manager.cjs.entry.js +2 -1
- package/dist/cjs/index-506fe4ea.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-app-layout_7.cjs.entry.js +7 -4
- package/dist/cjs/swirl-button.cjs.entry.js +3 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-date-input.cjs.entry.js +1 -1
- package/dist/cjs/swirl-lightbox.cjs.entry.js +1 -1
- package/dist/cjs/swirl-pdf-reader.cjs.entry.js +2 -2
- package/dist/cjs/{swirl-popover.cjs.entry.js → swirl-popover_2.cjs.entry.js} +105 -18
- package/dist/cjs/swirl-select.cjs.entry.js +2 -2
- package/dist/collection/assets/pdfjs/pdf.worker.min.js +22 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/swirl-button/swirl-button.js +37 -1
- package/dist/collection/components/swirl-date-input/swirl-date-input.js +1 -1
- package/dist/collection/components/swirl-date-input/swirl-date-input.spec.js +6 -4
- package/dist/collection/components/swirl-lightbox/swirl-lightbox.js +1 -1
- package/dist/collection/components/swirl-lightbox/swirl-lightbox.spec.js +6 -4
- package/dist/collection/components/swirl-menu/swirl-menu.spec.js +38 -14
- package/dist/collection/components/swirl-menu/swirl-menu.stories.js +35 -33
- package/dist/collection/components/swirl-pdf-reader/swirl-pdf-reader.js +2 -2
- package/dist/collection/components/swirl-pdf-reader/swirl-pdf-reader.spec.js +4 -2
- package/dist/collection/components/swirl-popover/swirl-popover.js +53 -39
- package/dist/collection/components/swirl-popover/swirl-popover.spec.js +20 -11
- package/dist/collection/components/swirl-popover/swirl-popover.stories.js +8 -25
- package/dist/collection/components/swirl-popover-trigger/swirl-popover-trigger.css +3 -0
- package/dist/collection/components/swirl-popover-trigger/swirl-popover-trigger.js +132 -0
- package/dist/collection/components/swirl-popover-trigger/swirl-popover-trigger.spec.js +26 -0
- package/dist/collection/components/swirl-popover-trigger/swirl-popover-trigger.stories.js +48 -0
- package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.css +7 -0
- package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.js +7 -3
- package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.spec.js +1 -0
- package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.stories.js +29 -29
- package/dist/collection/components/swirl-select/swirl-select.js +2 -2
- package/dist/collection/components/swirl-select/swirl-select.spec.js +4 -2
- package/dist/collection/prototypes/file-manager/file-manager.js +4 -2
- package/dist/components/assets/pdfjs/pdf.worker.min.js +22 -0
- package/dist/components/file-manager.js +54 -46
- package/dist/components/swirl-button2.js +5 -1
- package/dist/components/swirl-date-input.js +13 -7
- package/dist/components/swirl-lightbox.js +21 -15
- package/dist/components/swirl-pdf-reader.js +48 -42
- package/dist/components/swirl-popover-trigger.d.ts +11 -0
- package/dist/components/swirl-popover-trigger.js +6 -0
- package/dist/components/swirl-popover-trigger2.js +99 -0
- package/dist/components/swirl-popover2.js +27 -19
- package/dist/components/swirl-resource-list-item2.js +19 -10
- package/dist/components/swirl-select.js +18 -12
- package/dist/esm/file-manager.entry.js +2 -1
- package/dist/esm/index-99d0060d.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-app-layout_7.entry.js +7 -4
- package/dist/esm/swirl-button.entry.js +3 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-date-input.entry.js +1 -1
- package/dist/esm/swirl-lightbox.entry.js +1 -1
- package/dist/esm/swirl-pdf-reader.entry.js +2 -2
- package/dist/esm/{swirl-popover.entry.js → swirl-popover_2.entry.js} +105 -19
- package/dist/esm/swirl-select.entry.js +2 -2
- package/dist/swirl-components/p-0fce283f.entry.js +1 -0
- package/dist/swirl-components/p-2278aeae.entry.js +1 -0
- package/dist/swirl-components/p-251884ec.entry.js +1 -0
- package/dist/swirl-components/{p-a16a6381.entry.js → p-30ae7d5c.entry.js} +1 -1
- package/dist/swirl-components/p-3abcd491.entry.js +1 -0
- package/dist/swirl-components/p-6832ee6c.entry.js +1 -0
- package/dist/swirl-components/p-794d25e2.entry.js +1 -0
- package/dist/swirl-components/p-ed921838.entry.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-button/swirl-button.d.ts +2 -0
- package/dist/types/components/swirl-popover/swirl-popover.d.ts +4 -5
- package/dist/types/components/swirl-popover/swirl-popover.stories.d.ts +0 -3
- package/dist/types/components/swirl-popover-trigger/swirl-popover-trigger.d.ts +13 -0
- package/dist/types/components/swirl-popover-trigger/swirl-popover-trigger.stories.d.ts +22 -0
- package/dist/types/components/swirl-resource-list-item/swirl-resource-list-item.d.ts +1 -0
- package/dist/types/components/swirl-resource-list-item/swirl-resource-list-item.stories.d.ts +8 -3
- package/dist/types/components.d.ts +26 -5
- package/dist/types/prototypes/file-manager/file-manager.d.ts +1 -0
- package/package.json +1 -1
- package/vscode-data.json +25 -0
- package/dist/swirl-components/p-8c507544.entry.js +0 -1
- package/dist/swirl-components/p-acd95936.entry.js +0 -1
- package/dist/swirl-components/p-b105d565.entry.js +0 -1
- package/dist/swirl-components/p-b28fadcf.entry.js +0 -1
- package/dist/swirl-components/p-d98edc75.entry.js +0 -1
- package/dist/swirl-components/p-ef50db1d.entry.js +0 -1
- package/dist/swirl-components/p-f990566c.entry.js +0 -1
- package/dist/typings.d.ts +0 -1
|
@@ -61,8 +61,8 @@ const SwirlPopover = class {
|
|
|
61
61
|
this.label = undefined;
|
|
62
62
|
this.maxHeight = "22rem";
|
|
63
63
|
this.offset = 8;
|
|
64
|
-
this.placement = "bottom-start";
|
|
65
64
|
this.popoverId = undefined;
|
|
65
|
+
this.placement = "bottom-start";
|
|
66
66
|
this.trigger = undefined;
|
|
67
67
|
this.triggerContainer = undefined;
|
|
68
68
|
this.useContainerWidth = undefined;
|
|
@@ -72,13 +72,16 @@ const SwirlPopover = class {
|
|
|
72
72
|
}
|
|
73
73
|
componentDidLoad() {
|
|
74
74
|
this.connectTrigger();
|
|
75
|
-
this.updateFocusableChildren();
|
|
76
75
|
this.updateTriggerAttributes();
|
|
76
|
+
if (Boolean(this.trigger)) {
|
|
77
|
+
console.warn('[Swirl] The "trigger" prop of swirl-popover is deprecated and will be removed with the next major release. Please use the swirl-popover-trigger component instead. https://swirl-storybook.flip-app.dev/?path=/docs/components-swirlpopovertrigger--docs');
|
|
78
|
+
}
|
|
77
79
|
}
|
|
78
80
|
disconnectedCallback() {
|
|
79
81
|
this.unlockBodyScroll();
|
|
80
82
|
}
|
|
81
83
|
onWindowFocusIn(event) {
|
|
84
|
+
var _a;
|
|
82
85
|
if (!this.active) {
|
|
83
86
|
return;
|
|
84
87
|
}
|
|
@@ -89,7 +92,7 @@ const SwirlPopover = class {
|
|
|
89
92
|
const popoverLostFocus = !this.el.contains(target) &&
|
|
90
93
|
!this.el.contains(activeElement) &&
|
|
91
94
|
target !== this.triggerEl &&
|
|
92
|
-
!this.triggerEl.contains(target) &&
|
|
95
|
+
!((_a = this.triggerEl) === null || _a === void 0 ? void 0 : _a.contains(target)) &&
|
|
93
96
|
(!isSafari ||
|
|
94
97
|
(isSafari &&
|
|
95
98
|
!this.el.contains(relatedTarget || target) &&
|
|
@@ -109,7 +112,7 @@ const SwirlPopover = class {
|
|
|
109
112
|
.some((el) => Boolean(el) && el instanceof Node
|
|
110
113
|
? this.el.contains(el)
|
|
111
114
|
: false);
|
|
112
|
-
const clickedTrigger =
|
|
115
|
+
const clickedTrigger = target === this.triggerEl;
|
|
113
116
|
if (!clickedChild && !clickedShadowChild && !clickedTrigger) {
|
|
114
117
|
this.close();
|
|
115
118
|
}
|
|
@@ -140,19 +143,20 @@ const SwirlPopover = class {
|
|
|
140
143
|
* Open the popover.
|
|
141
144
|
* @returns
|
|
142
145
|
*/
|
|
143
|
-
async open() {
|
|
144
|
-
|
|
146
|
+
async open(triggerEl) {
|
|
147
|
+
this.triggerEl = triggerEl || this.triggerEl;
|
|
148
|
+
if (this.active || !Boolean(this.triggerEl)) {
|
|
145
149
|
return;
|
|
146
150
|
}
|
|
147
151
|
this.adjustWidth();
|
|
148
152
|
this.active = true;
|
|
149
|
-
this.updateFocusableChildren();
|
|
150
153
|
this.updateTriggerAttributes();
|
|
154
|
+
const focusableChildren = this.getFocusableChildren();
|
|
151
155
|
requestAnimationFrame(async () => {
|
|
152
156
|
await this.reposition();
|
|
153
157
|
this.popoverOpen.emit({ position: this.position });
|
|
154
|
-
if (
|
|
155
|
-
|
|
158
|
+
if (focusableChildren.length > 0) {
|
|
159
|
+
focusableChildren[0].focus();
|
|
156
160
|
}
|
|
157
161
|
else {
|
|
158
162
|
this.contentContainer.focus();
|
|
@@ -160,12 +164,16 @@ const SwirlPopover = class {
|
|
|
160
164
|
if (this.disableAutoUpdate) {
|
|
161
165
|
this.disableAutoUpdate();
|
|
162
166
|
}
|
|
163
|
-
this.disableAutoUpdate = floatingUi_dom_esm.autoUpdate(this.triggerEl, this.contentContainer, this.reposition);
|
|
167
|
+
this.disableAutoUpdate = floatingUi_dom_esm.autoUpdate(this.triggerEl, this.contentContainer, () => this.reposition());
|
|
164
168
|
this.scrollContainer.scrollTop = 0;
|
|
165
169
|
this.lockBodyScroll();
|
|
166
170
|
});
|
|
167
171
|
}
|
|
168
172
|
connectTrigger() {
|
|
173
|
+
if (!Boolean(this.trigger)) {
|
|
174
|
+
this.triggerEl = undefined;
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
169
177
|
this.triggerEl =
|
|
170
178
|
typeof this.trigger === "string"
|
|
171
179
|
? utils.querySelectorAllDeep(this.triggerContainer || document.body, `#${this.trigger}`)[0]
|
|
@@ -178,10 +186,10 @@ const SwirlPopover = class {
|
|
|
178
186
|
});
|
|
179
187
|
}
|
|
180
188
|
getNativeTriggerElement() {
|
|
181
|
-
var _a, _b, _c;
|
|
182
|
-
return this.triggerEl.tagName.startsWith("SWIRL-")
|
|
183
|
-
? (((
|
|
184
|
-
((
|
|
189
|
+
var _a, _b, _c, _d;
|
|
190
|
+
return ((_a = this.triggerEl) === null || _a === void 0 ? void 0 : _a.tagName.startsWith("SWIRL-"))
|
|
191
|
+
? (((_b = this.triggerEl) === null || _b === void 0 ? void 0 : _b.children[0]) ||
|
|
192
|
+
((_d = (_c = this.triggerEl) === null || _c === void 0 ? void 0 : _c.shadowRoot) === null || _d === void 0 ? void 0 : _d.children[0]) ||
|
|
185
193
|
this.triggerEl)
|
|
186
194
|
: this.triggerEl;
|
|
187
195
|
}
|
|
@@ -190,12 +198,12 @@ const SwirlPopover = class {
|
|
|
190
198
|
return;
|
|
191
199
|
}
|
|
192
200
|
const nativeTriggerEl = this.getNativeTriggerElement();
|
|
193
|
-
nativeTriggerEl.setAttribute("aria-controls", this.
|
|
201
|
+
nativeTriggerEl.setAttribute("aria-controls", this.el.id);
|
|
194
202
|
nativeTriggerEl.setAttribute("aria-expanded", String(this.active));
|
|
195
203
|
nativeTriggerEl.setAttribute("aria-haspopup", "dialog");
|
|
196
204
|
}
|
|
197
|
-
|
|
198
|
-
|
|
205
|
+
getFocusableChildren() {
|
|
206
|
+
return utils.querySelectorAllDeep(this.el, '[role="menuitem"], [role="listbox"]');
|
|
199
207
|
}
|
|
200
208
|
adjustWidth() {
|
|
201
209
|
let useContainerWidth = this.useContainerWidth;
|
|
@@ -242,7 +250,7 @@ const SwirlPopover = class {
|
|
|
242
250
|
"popover--fullscreen-bottom-sheet": this.fullscreenBottomSheet,
|
|
243
251
|
"popover--inactive": !this.active,
|
|
244
252
|
});
|
|
245
|
-
return (index.h(index.Host,
|
|
253
|
+
return (index.h(index.Host, null, index.h("div", { class: className, onKeyDown: this.onKeydown }, index.h("div", { "aria-hidden": !this.active ? "true" : "false", "aria-label": this.label, class: "popover__content", id: this.popoverId, part: "popover__content", role: "dialog", ref: (el) => (this.contentContainer = el), style: {
|
|
246
254
|
top: Boolean(this.position) ? `${(_b = this.position) === null || _b === void 0 ? void 0 : _b.y}px` : "",
|
|
247
255
|
left: Boolean(this.position) ? `${(_c = this.position) === null || _c === void 0 ? void 0 : _c.x}px` : "",
|
|
248
256
|
}, tabindex: "-1" }, index.h("span", { class: "popover__handle" }), index.h("div", { class: "popover__scroll-container", ref: (el) => (this.scrollContainer = el), style: {
|
|
@@ -255,4 +263,83 @@ const SwirlPopover = class {
|
|
|
255
263
|
};
|
|
256
264
|
SwirlPopover.style = swirlPopoverCss;
|
|
257
265
|
|
|
266
|
+
const swirlPopoverTriggerCss = ".sc-swirl-popover-trigger-h{display:contents}";
|
|
267
|
+
|
|
268
|
+
const SwirlPopoverTrigger = class {
|
|
269
|
+
constructor(hostRef) {
|
|
270
|
+
index.registerInstance(this, hostRef);
|
|
271
|
+
this.popoverOpen = false;
|
|
272
|
+
this.onClick = (event) => {
|
|
273
|
+
event.stopPropagation();
|
|
274
|
+
const popoverEl = this.getPopoverEl();
|
|
275
|
+
if (!Boolean(popoverEl)) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (this.popoverOpen) {
|
|
279
|
+
popoverEl.close();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const triggerEl = this.getTriggerEl();
|
|
283
|
+
if (!Boolean(triggerEl)) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
popoverEl.open(triggerEl);
|
|
287
|
+
popoverEl.addEventListener("popoverOpen", () => {
|
|
288
|
+
this.popoverOpen = true;
|
|
289
|
+
this.updateTriggerElAriaAttributes(true);
|
|
290
|
+
}, { once: true });
|
|
291
|
+
popoverEl.addEventListener("popoverClose", () => {
|
|
292
|
+
this.popoverOpen = false;
|
|
293
|
+
this.updateTriggerElAriaAttributes(false);
|
|
294
|
+
}, { once: true });
|
|
295
|
+
};
|
|
296
|
+
this.updateTriggerElAriaAttributes = (open) => {
|
|
297
|
+
var _a;
|
|
298
|
+
if (!this.setAriaAttributes) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const triggerEl = this.getTriggerEl();
|
|
302
|
+
const popoverId = typeof this.popover === "string" ? this.popover : (_a = this.popover) === null || _a === void 0 ? void 0 : _a.id;
|
|
303
|
+
if (triggerEl.tagName.startsWith("SWIRL-")) {
|
|
304
|
+
triggerEl.setAttribute("swirl-aria-controls", popoverId);
|
|
305
|
+
triggerEl.setAttribute("swirl-aria-expanded", String(open || "false"));
|
|
306
|
+
triggerEl.setAttribute("swirl-aria-haspopup", "dialog");
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
triggerEl.setAttribute("aria-controls", popoverId);
|
|
310
|
+
triggerEl.setAttribute("aria-expanded", String(open || "false"));
|
|
311
|
+
triggerEl.setAttribute("aria-haspopup", "dialog");
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
this.popover = undefined;
|
|
315
|
+
this.setAriaAttributes = true;
|
|
316
|
+
}
|
|
317
|
+
componentDidLoad() {
|
|
318
|
+
this.updateTriggerElAriaAttributes();
|
|
319
|
+
}
|
|
320
|
+
watchPopover() {
|
|
321
|
+
this.updateTriggerElAriaAttributes();
|
|
322
|
+
}
|
|
323
|
+
getPopoverEl() {
|
|
324
|
+
return typeof this.popover === "string"
|
|
325
|
+
? document.querySelector(`#${this.popover}`)
|
|
326
|
+
: this.popover;
|
|
327
|
+
}
|
|
328
|
+
getTriggerEl() {
|
|
329
|
+
if (this.el.children.length !== 1) {
|
|
330
|
+
console.warn('[Swirl] The "swirl-popover-trigger" component expects exactly one child element.');
|
|
331
|
+
}
|
|
332
|
+
return this.el.children[0];
|
|
333
|
+
}
|
|
334
|
+
render() {
|
|
335
|
+
return (index.h(index.Host, { onClick: this.onClick }, index.h("slot", null)));
|
|
336
|
+
}
|
|
337
|
+
get el() { return index.getElement(this); }
|
|
338
|
+
static get watchers() { return {
|
|
339
|
+
"popover": ["watchPopover"]
|
|
340
|
+
}; }
|
|
341
|
+
};
|
|
342
|
+
SwirlPopoverTrigger.style = swirlPopoverTriggerCss;
|
|
343
|
+
|
|
258
344
|
exports.swirl_popover = SwirlPopover;
|
|
345
|
+
exports.swirl_popover_trigger = SwirlPopoverTrigger;
|
|
@@ -87,9 +87,9 @@ const SwirlSelect = class {
|
|
|
87
87
|
"select--inline": this.inline,
|
|
88
88
|
"select--multi": this.multiSelect,
|
|
89
89
|
});
|
|
90
|
-
return (index.h(index.Host, { onKeyDown: this.onKeyDown }, index.h("div", { class: className }, index.h("input", { "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, class: "select__input", disabled: this.disabled,
|
|
90
|
+
return (index.h(index.Host, { onKeyDown: this.onKeyDown }, index.h("div", { class: className }, index.h("swirl-popover-trigger", { popover: this.popover, setAriaAttributes: false }, index.h("input", { "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, class: "select__input", disabled: this.disabled, readOnly: true, type: "text", value: label })), index.h("span", { class: "select__multi-select-values" }, (_c = (_b = this.value) === null || _b === void 0 ? void 0 : _b.map((value) => this.options.find((option) => option.value === value))) === null || _c === void 0 ? void 0 : _c.map((option) => (index.h("swirl-tag", { "aria-hidden": "true", label: option === null || option === void 0 ? void 0 : option.label,
|
|
91
91
|
// eslint-disable-next-line react/jsx-no-bind
|
|
92
|
-
onRemove: () => this.unselectOption(option === null || option === void 0 ? void 0 : option.value), removable: !this.disabled && this.allowDeselect })))), index.h("span", { class: "select__indicator" }, this.open ? (index.h("swirl-icon-expand-less", null)) : (index.h("swirl-icon-expand-more", null))), index.h("swirl-popover", { animation: "scale-in-y", class: "select__popover", label: this.label, offset: [0, offset], onPopoverClose: this.onClose, onPopoverOpen: this.onOpen,
|
|
92
|
+
onRemove: () => this.unselectOption(option === null || option === void 0 ? void 0 : option.value), removable: !this.disabled && this.allowDeselect })))), index.h("span", { class: "select__indicator" }, this.open ? (index.h("swirl-icon-expand-less", null)) : (index.h("swirl-icon-expand-more", null))), index.h("swirl-popover", { animation: "scale-in-y", class: "select__popover", id: `select-options-${this.selectId}`, label: this.label, offset: [0, offset], onPopoverClose: this.onClose, onPopoverOpen: this.onOpen, ref: (el) => (this.popover = el), useContainerWidth: "swirl-form-control" }, index.h("swirl-option-list", { allowDeselect: this.allowDeselect, onValueChange: this.select, multiSelect: this.multiSelect, value: this.value }, index.h("slot", { onSlotchange: this.onSlotChange }))))));
|
|
93
93
|
}
|
|
94
94
|
get el() { return index.getElement(this); }
|
|
95
95
|
};
|