@editora/ui-core 0.1.18 → 0.1.20
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/dist/{ElementBase-1b301e7f.js → ElementBase-EV6mVBUV.js} +1 -1
- package/dist/{ElementBase-909688f3.mjs → ElementBase-YlTLMsGk.mjs} +3 -3
- package/dist/accordion.cjs.js +3 -3
- package/dist/accordion.esm.js +39 -62
- package/dist/alert-dialog.cjs.js +19 -19
- package/dist/alert-dialog.esm.js +69 -87
- package/dist/alert.cjs.js +1 -1
- package/dist/alert.esm.js +4 -7
- package/dist/anchor.cjs.js +2 -2
- package/dist/anchor.esm.js +3 -3
- package/dist/animated-beam.cjs.js +83 -83
- package/dist/animated-beam.esm.js +250 -277
- package/dist/animated-list.cjs.js +4 -4
- package/dist/animated-list.esm.js +47 -61
- package/dist/animated-text.cjs.js +2 -2
- package/dist/animated-text.esm.js +13 -24
- package/dist/app-header.cjs.js +3 -3
- package/dist/app-header.esm.js +11 -13
- package/dist/aspect-ratio.cjs.js +1 -1
- package/dist/aspect-ratio.esm.js +4 -7
- package/dist/avatar.cjs.js +1 -1
- package/dist/avatar.esm.js +7 -13
- package/dist/badge.cjs.js +1 -1
- package/dist/badge.esm.js +4 -7
- package/dist/block-controls.cjs.js +2 -2
- package/dist/block-controls.esm.js +19 -35
- package/dist/box.cjs.js +1 -1
- package/dist/box.esm.js +8 -15
- package/dist/breadcrumb.cjs.js +2 -2
- package/dist/breadcrumb.esm.js +20 -37
- package/dist/button.cjs.js +1 -521
- package/dist/button.esm.js +2 -669
- package/dist/{calendar-2c11b824.mjs → calendar-DLY4acgn.mjs} +293 -342
- package/dist/{calendar-a8735e40.js → calendar-Dkof-FTK.js} +25 -25
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +8 -9
- package/dist/card.cjs.js +4 -4
- package/dist/card.esm.js +13 -19
- package/dist/chart.cjs.js +64 -64
- package/dist/chart.esm.js +223 -254
- package/dist/checkbox.cjs.js +1 -1
- package/dist/checkbox.esm.js +2 -3
- package/dist/collapsible.cjs.js +1 -1
- package/dist/collapsible.esm.js +5 -9
- package/dist/{collection-a1aac0c6.mjs → collection-C7URGjEI.mjs} +8 -14
- package/dist/collection.cjs.js +1 -1
- package/dist/collection.esm.js +4 -7
- package/dist/color-picker.cjs.js +9 -9
- package/dist/color-picker.esm.js +189 -252
- package/dist/combobox.cjs.js +13 -13
- package/dist/combobox.esm.js +93 -126
- package/dist/command-palette.cjs.js +3 -3
- package/dist/command-palette.esm.js +19 -30
- package/dist/command.cjs.js +4 -4
- package/dist/command.esm.js +41 -53
- package/dist/components/ui-button.d.ts +1 -0
- package/dist/components/ui-button.d.ts.map +1 -1
- package/dist/components/ui-date-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-time-picker.d.ts +1 -0
- package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts +1 -0
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-orbiter.d.ts.map +1 -1
- package/dist/components/ui-skeleton.d.ts.map +1 -1
- package/dist/components/ui-split-button.d.ts +1 -0
- package/dist/components/ui-split-button.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/container.cjs.js +2 -2
- package/dist/container.esm.js +2 -3
- package/dist/context-menu.cjs.js +8 -8
- package/dist/context-menu.esm.js +157 -219
- package/dist/control-group.cjs.js +1 -1
- package/dist/control-group.esm.js +2 -3
- package/dist/data-table.cjs.js +4 -4
- package/dist/data-table.esm.js +299 -381
- package/dist/date-field.cjs.js +3 -3
- package/dist/date-field.esm.js +68 -80
- package/dist/date-picker.cjs.js +30 -9
- package/dist/date-picker.esm.js +90 -97
- package/dist/date-range-picker.cjs.js +22 -3
- package/dist/date-range-picker.esm.js +103 -108
- package/dist/date-range-time-picker.cjs.js +28 -12
- package/dist/date-range-time-picker.esm.js +137 -150
- package/dist/date-time-picker.cjs.js +25 -9
- package/dist/date-time-picker.esm.js +139 -155
- package/dist/date-time-utils-Dmost5Ee.js +1 -0
- package/dist/date-time-utils-y1N2gvG2.mjs +268 -0
- package/dist/description.cjs.js +1 -1
- package/dist/description.esm.js +3 -5
- package/dist/dialog.cjs.js +12 -12
- package/dist/dialog.esm.js +44 -63
- package/dist/direction-provider.cjs.js +1 -1
- package/dist/direction-provider.esm.js +2 -3
- package/dist/{dismissable-layer-9c7e6b58.mjs → dismissable-layer-BmPIoK80.mjs} +29 -33
- package/dist/dismissable-layer-DNfrKA20.js +1 -0
- package/dist/dismissable-layer.cjs.js +2 -2
- package/dist/dismissable-layer.esm.js +4 -6
- package/dist/dock.cjs.js +5 -5
- package/dist/dock.esm.js +134 -155
- package/dist/drawer.cjs.js +2 -2
- package/dist/drawer.esm.js +18 -35
- package/dist/dropdown.cjs.js +2 -2
- package/dist/dropdown.esm.js +119 -149
- package/dist/dropzone.cjs.js +1 -1
- package/dist/dropzone.esm.js +0 -1
- package/dist/empty-state.cjs.js +1 -1
- package/dist/empty-state.esm.js +1 -1
- package/dist/field-error.cjs.js +1 -1
- package/dist/field-error.esm.js +3 -5
- package/dist/field.cjs.js +5 -5
- package/dist/field.esm.js +27 -34
- package/dist/fieldset.cjs.js +4 -4
- package/dist/fieldset.esm.js +19 -24
- package/dist/file-upload.cjs.js +4 -4
- package/dist/file-upload.esm.js +69 -93
- package/dist/flex.cjs.js +1 -1
- package/dist/flex.esm.js +5 -9
- package/dist/floating-toolbar.cjs.js +4 -4
- package/dist/floating-toolbar.esm.js +60 -85
- package/dist/focus-scope-Bwug2gDv.js +1 -0
- package/dist/{focus-scope-103833ee.mjs → focus-scope-CmEsG5UZ.mjs} +39 -48
- package/dist/focus-scope.cjs.js +2 -2
- package/dist/focus-scope.esm.js +15 -20
- package/dist/form.cjs.js +2 -2
- package/dist/form.esm.js +26 -53
- package/dist/gantt.cjs.js +43 -43
- package/dist/gantt.esm.js +295 -322
- package/dist/grid.cjs.js +1 -1
- package/dist/grid.esm.js +5 -9
- package/dist/hover-card.cjs.js +4 -4
- package/dist/hover-card.esm.js +22 -28
- package/dist/icon-cloud.cjs.js +7 -7
- package/dist/icon-cloud.esm.js +48 -62
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +2 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +378 -390
- package/dist/inline-edit.cjs.js +11 -11
- package/dist/inline-edit.esm.js +32 -36
- package/dist/input.cjs.js +17 -17
- package/dist/input.esm.js +50 -63
- package/dist/label.cjs.js +2 -2
- package/dist/label.esm.js +8 -17
- package/dist/layout.cjs.js +2 -2
- package/dist/layout.esm.js +20 -26
- package/dist/listbox-B6QgECax.js +46 -0
- package/dist/listbox-DJamVeFj.mjs +200 -0
- package/dist/listbox.cjs.js +1 -1
- package/dist/listbox.esm.js +2 -4
- package/dist/marquee.cjs.js +5 -5
- package/dist/marquee.esm.js +33 -50
- package/dist/masonry-grid.cjs.js +1 -1
- package/dist/masonry-grid.esm.js +5 -9
- package/dist/menu.cjs.js +3 -3
- package/dist/menu.esm.js +106 -126
- package/dist/menubar.cjs.js +5 -5
- package/dist/menubar.esm.js +118 -164
- package/dist/meter.cjs.js +2 -2
- package/dist/meter.esm.js +4 -4
- package/dist/multi-select.cjs.js +4 -4
- package/dist/multi-select.esm.js +120 -140
- package/dist/navigation-menu.cjs.js +4 -4
- package/dist/navigation-menu.esm.js +44 -55
- package/dist/number-field.cjs.js +2 -2
- package/dist/number-field.esm.js +73 -98
- package/dist/number-ticker.cjs.js +3 -3
- package/dist/number-ticker.esm.js +22 -43
- package/dist/odometer.cjs.js +1 -1
- package/dist/odometer.esm.js +5 -9
- package/dist/orbiter.cjs.js +13 -13
- package/dist/orbiter.esm.js +79 -90
- package/dist/{overlayManager-5bbd4dc3.mjs → overlayManager-BJjU1VA8.mjs} +4 -5
- package/dist/{overlayManager-0eda4e08.js → overlayManager-CSy3fJmJ.js} +1 -1
- package/dist/pagination.cjs.js +2 -2
- package/dist/pagination.esm.js +14 -18
- package/dist/{panel-group-a376cc5e.mjs → panel-group-8sVNnGxg.mjs} +24 -46
- package/dist/panel-group-CaD0_KQf.js +36 -0
- package/dist/panel-group.cjs.js +1 -1
- package/dist/panel-group.esm.js +2 -5
- package/dist/panel.cjs.js +4 -4
- package/dist/panel.esm.js +8 -10
- package/dist/password-field.cjs.js +9 -9
- package/dist/password-field.esm.js +62 -82
- package/dist/pin-input.cjs.js +3 -3
- package/dist/pin-input.esm.js +33 -39
- package/dist/placement-grid.cjs.js +4 -4
- package/dist/placement-grid.esm.js +108 -131
- package/dist/plugin-panel.cjs.js +7 -7
- package/dist/plugin-panel.esm.js +13 -15
- package/dist/popover.cjs.js +2 -2
- package/dist/popover.esm.js +21 -31
- package/dist/portal-DgpQ3Jo1.js +1 -0
- package/dist/{portal-fe73e5cc.mjs → portal-bR42gHvG.mjs} +43 -48
- package/dist/portal.cjs.js +2 -2
- package/dist/portal.esm.js +10 -19
- package/dist/{positioner-e9770c66.mjs → positioner-D0VGxtYU.mjs} +189 -209
- package/dist/positioner-D_fqyx_j.js +1 -0
- package/dist/positioner.cjs.js +2 -2
- package/dist/positioner.esm.js +11 -18
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +7 -13
- package/dist/progress.cjs.js +1 -1
- package/dist/progress.esm.js +5 -9
- package/dist/quick-actions.cjs.js +6 -6
- package/dist/quick-actions.esm.js +52 -62
- package/dist/radio-group.cjs.js +13 -13
- package/dist/radio-group.esm.js +39 -51
- package/dist/radio.cjs.js +1 -1
- package/dist/radio.esm.js +5 -9
- package/dist/rating.cjs.js +1 -1
- package/dist/rating.esm.js +12 -23
- package/dist/{roving-focus-group-4350c9a7.mjs → roving-focus-group-Dbm1Jko_.mjs} +3 -6
- package/dist/roving-focus-group.cjs.js +1 -1
- package/dist/roving-focus-group.esm.js +3 -5
- package/dist/runtime-CTaOSmBj.js +1 -0
- package/dist/{runtime-161f68a2.mjs → runtime-D1gFh1fS.mjs} +338 -366
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.esm.js +6 -6
- package/dist/scroll-area.cjs.js +3 -3
- package/dist/scroll-area.esm.js +38 -46
- package/dist/{scroll-lock-31da444f.mjs → scroll-lock-LfqXXqsu.mjs} +5 -9
- package/dist/section.cjs.js +1 -1
- package/dist/section.esm.js +1 -1
- package/dist/select.cjs.js +7 -7
- package/dist/select.esm.js +67 -97
- package/dist/selection-popup.cjs.js +1 -1
- package/dist/selection-popup.esm.js +8 -15
- package/dist/separator.cjs.js +1 -1
- package/dist/separator.esm.js +1 -1
- package/dist/sidebar.cjs.js +18 -18
- package/dist/sidebar.esm.js +117 -139
- package/dist/skeleton.cjs.js +11 -11
- package/dist/skeleton.esm.js +27 -24
- package/dist/slider.cjs.js +1 -1
- package/dist/slider.esm.js +6 -11
- package/dist/slot.cjs.js +4 -4
- package/dist/slot.esm.js +16 -19
- package/dist/sortable.cjs.js +45 -45
- package/dist/sortable.esm.js +421 -524
- package/dist/spinning-text.cjs.js +12 -12
- package/dist/spinning-text.esm.js +80 -92
- package/dist/split-button.cjs.js +4 -4
- package/dist/split-button.esm.js +77 -62
- package/dist/splitter.cjs.js +1 -1
- package/dist/splitter.esm.js +1 -1
- package/dist/stepper.cjs.js +8 -8
- package/dist/stepper.esm.js +32 -52
- package/dist/switch.cjs.js +7 -7
- package/dist/switch.esm.js +23 -31
- package/dist/table.cjs.js +2 -2
- package/dist/table.esm.js +46 -56
- package/dist/tabs.cjs.js +3 -3
- package/dist/tabs.esm.js +35 -55
- package/dist/tags-input.cjs.js +4 -4
- package/dist/tags-input.esm.js +45 -62
- package/dist/textarea.cjs.js +6 -6
- package/dist/textarea.esm.js +32 -41
- package/dist/time-field.cjs.js +4 -4
- package/dist/time-field.esm.js +70 -84
- package/dist/time-picker.cjs.js +29 -21
- package/dist/time-picker.esm.js +96 -110
- package/dist/timeline.cjs.js +1 -1
- package/dist/timeline.esm.js +3 -5
- package/dist/toast.cjs.js +2 -2
- package/dist/toast.esm.js +33 -47
- package/dist/toggle-group.cjs.js +6 -6
- package/dist/toggle-group.esm.js +85 -105
- package/dist/toggle.cjs.js +1 -1
- package/dist/toggle.esm.js +3 -5
- package/dist/toolbar.cjs.js +1 -1
- package/dist/toolbar.esm.js +13 -24
- package/dist/tooltip.cjs.js +2 -2
- package/dist/tooltip.esm.js +31 -42
- package/dist/transfer-list.cjs.js +19 -19
- package/dist/transfer-list.esm.js +98 -111
- package/dist/{tree-dcd74a4a.mjs → tree-B3kE8ESs.mjs} +55 -62
- package/dist/tree-Dx_kv_ih.js +39 -0
- package/dist/tree-item.cjs.js +2 -2
- package/dist/tree-item.esm.js +2 -3
- package/dist/tree.cjs.js +1 -1
- package/dist/tree.esm.js +2 -5
- package/dist/ui-button-Q0GNNWKC.mjs +665 -0
- package/dist/ui-button-rXQOS9QJ.js +521 -0
- package/dist/{icon-9e9da03b.js → ui-icon-BzVNC_lr.js} +4 -4
- package/dist/{icon-e2a85cc1.mjs → ui-icon-YI6lyuqU.mjs} +58 -65
- package/dist/visually-hidden.cjs.js +1 -1
- package/dist/visually-hidden.esm.js +1 -1
- package/dist/wizard.cjs.js +14 -14
- package/dist/wizard.esm.js +85 -105
- package/package.json +3 -3
- package/dist/date-time-utils-66480de4.js +0 -1
- package/dist/date-time-utils-a2c7af25.mjs +0 -307
- package/dist/dismissable-layer-193e3bed.js +0 -1
- package/dist/focus-scope-2b12b4e7.js +0 -1
- package/dist/listbox-308789a0.mjs +0 -210
- package/dist/listbox-ef2f708e.js +0 -46
- package/dist/panel-group-40254cdd.js +0 -36
- package/dist/portal-c69756c0.js +0 -1
- package/dist/positioner-33529bb8.js +0 -1
- package/dist/runtime-3f13807b.js +0 -1
- package/dist/tree-0a7a8d05.js +0 -39
- /package/dist/{collection-a2969ad2.js → collection-qv8A8rq4.js} +0 -0
- /package/dist/{menu-item-styles-27fdbac4.mjs → menu-item-styles-CZiPwPwl.mjs} +0 -0
- /package/dist/{menu-item-styles-83ad1e22.js → menu-item-styles-CbNUEwP2.js} +0 -0
- /package/dist/{roving-focus-group-5c059bf9.js → roving-focus-group-BdJ_4Njm.js} +0 -0
- /package/dist/{scroll-lock-d7b0df21.js → scroll-lock-BX6e3Ced.js} +0 -0
package/dist/file-upload.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
const
|
|
1
|
+
import { E as I } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
const M = `
|
|
3
3
|
:host {
|
|
4
4
|
--ui-file-upload-border-color: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 78%, transparent);
|
|
5
5
|
--ui-file-upload-border: 1px solid var(--ui-file-upload-border-color);
|
|
@@ -329,28 +329,25 @@ const j = `
|
|
|
329
329
|
opacity: 0.68;
|
|
330
330
|
}
|
|
331
331
|
`;
|
|
332
|
-
function
|
|
333
|
-
if (!Number.isFinite(
|
|
334
|
-
return "0 B";
|
|
332
|
+
function j(g) {
|
|
333
|
+
if (!Number.isFinite(g) || g <= 0) return "0 B";
|
|
335
334
|
const e = ["B", "KB", "MB", "GB"];
|
|
336
|
-
let t =
|
|
335
|
+
let t = g, i = 0;
|
|
337
336
|
for (; t >= 1024 && i < e.length - 1; )
|
|
338
337
|
t /= 1024, i += 1;
|
|
339
338
|
return `${t.toFixed(t >= 10 || i === 0 ? 0 : 1)} ${e[i]}`;
|
|
340
339
|
}
|
|
341
|
-
function
|
|
342
|
-
if (!e.trim())
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
const a = r.toLowerCase();
|
|
350
|
-
return a.startsWith(".") ? i.endsWith(a) : a.endsWith("/*") ? s.startsWith(a.slice(0, -1)) : s === a;
|
|
340
|
+
function O(g, e) {
|
|
341
|
+
if (!e.trim()) return !0;
|
|
342
|
+
const t = e.split(",").map((a) => a.trim()).filter(Boolean);
|
|
343
|
+
if (!t.length) return !0;
|
|
344
|
+
const i = g.name.toLowerCase(), s = (g.type || "").toLowerCase();
|
|
345
|
+
return t.some((a) => {
|
|
346
|
+
const r = a.toLowerCase();
|
|
347
|
+
return r.startsWith(".") ? i.endsWith(r) : r.endsWith("/*") ? s.startsWith(r.slice(0, -1)) : s === r;
|
|
351
348
|
});
|
|
352
349
|
}
|
|
353
|
-
class
|
|
350
|
+
class W extends I {
|
|
354
351
|
constructor() {
|
|
355
352
|
super(), this._files = [], this.uploadRequest = null, this._formUnregister = null, this._surfaceEl = null, this._inputEl = null, this._listEl = null, this._errorEl = null, this._actionsEl = null, this._dragging = !1, this._dragDepth = 0, this._previewUrls = /* @__PURE__ */ new Map(), this._uploadState = /* @__PURE__ */ new Map(), this._uploadControllers = /* @__PURE__ */ new Map(), this._uploadSequence = 0, this._onClick = this._onClick.bind(this), this._onKeyDown = this._onKeyDown.bind(this), this._onInputChange = this._onInputChange.bind(this), this._onDragEnter = this._onDragEnter.bind(this), this._onDragLeave = this._onDragLeave.bind(this), this._onDragOver = this._onDragOver.bind(this), this._onDrop = this._onDrop.bind(this);
|
|
356
353
|
}
|
|
@@ -385,27 +382,23 @@ class T extends M {
|
|
|
385
382
|
this._applyFiles(e, "api", !0);
|
|
386
383
|
}
|
|
387
384
|
openPicker() {
|
|
388
|
-
|
|
389
|
-
this._disabled() || (e = this._inputEl) == null || e.click();
|
|
385
|
+
this._disabled() || this._inputEl?.click();
|
|
390
386
|
}
|
|
391
387
|
clearFiles() {
|
|
392
388
|
this._files.length && (this.cancelUploads(), this._files = [], this._uploadState.clear(), this._inputEl && (this._inputEl.value = ""), this._syncUi(), this._emit("change", { files: [], source: "clear" }), this._emit("clear", {}));
|
|
393
389
|
}
|
|
394
390
|
removeFile(e) {
|
|
395
|
-
if (this._disabled() || e < 0 || e >= this._files.length)
|
|
396
|
-
return;
|
|
391
|
+
if (this._disabled() || e < 0 || e >= this._files.length) return;
|
|
397
392
|
const t = this._files[e];
|
|
398
393
|
this.cancelUpload(this._fileKey(t)), this._uploadState.delete(this._fileKey(t)), this._files = this._files.filter((i, s) => s !== e), this._syncUi(), this._emit("change", { files: this.files, source: "remove" });
|
|
399
394
|
}
|
|
400
395
|
async startUpload() {
|
|
401
|
-
if (!this.uploadRequest || this._disabled())
|
|
402
|
-
return;
|
|
396
|
+
if (!this.uploadRequest || this._disabled()) return;
|
|
403
397
|
const e = this._files.filter((i) => {
|
|
404
398
|
const s = this._uploadState.get(this._fileKey(i));
|
|
405
399
|
return !s || s.state === "pending" || s.state === "error" || s.state === "canceled";
|
|
406
400
|
});
|
|
407
|
-
if (!e.length)
|
|
408
|
-
return;
|
|
401
|
+
if (!e.length) return;
|
|
409
402
|
const t = ++this._uploadSequence;
|
|
410
403
|
this._emit("upload-start", { files: e, requestId: t }), await Promise.all(e.map((i) => this._runUpload(i, t))), this._emit("upload-complete", {
|
|
411
404
|
files: this.files,
|
|
@@ -433,9 +426,8 @@ class T extends M {
|
|
|
433
426
|
return !1;
|
|
434
427
|
}
|
|
435
428
|
render() {
|
|
436
|
-
var e, t, i, s, r, a, n;
|
|
437
429
|
this.setContent(`
|
|
438
|
-
<style>${
|
|
430
|
+
<style>${M}</style>
|
|
439
431
|
<div class="root">
|
|
440
432
|
<div class="meta" hidden>
|
|
441
433
|
<div class="label" hidden><span class="label-text"></span><span class="required" hidden>*</span></div>
|
|
@@ -457,22 +449,20 @@ class T extends M {
|
|
|
457
449
|
</div>
|
|
458
450
|
<div class="list" part="list" hidden></div>
|
|
459
451
|
</div>
|
|
460
|
-
`), this._surfaceEl = this.root.querySelector(".surface"), this._inputEl = this.root.querySelector(".input"), this._listEl = this.root.querySelector(".list"), this._errorEl = this.root.querySelector(".error"), this._actionsEl = this.root.querySelector(".actions"),
|
|
452
|
+
`), this._surfaceEl = this.root.querySelector(".surface"), this._inputEl = this.root.querySelector(".input"), this._listEl = this.root.querySelector(".list"), this._errorEl = this.root.querySelector(".error"), this._actionsEl = this.root.querySelector(".actions"), this._surfaceEl?.addEventListener("click", this._onClick), this._surfaceEl?.addEventListener("keydown", this._onKeyDown), this._surfaceEl?.addEventListener("dragenter", this._onDragEnter), this._surfaceEl?.addEventListener("dragleave", this._onDragLeave), this._surfaceEl?.addEventListener("dragover", this._onDragOver), this._surfaceEl?.addEventListener("drop", this._onDrop), this._inputEl?.addEventListener("change", this._onInputChange), this._syncUi();
|
|
461
453
|
}
|
|
462
454
|
_disabled() {
|
|
463
455
|
return this.hasAttribute("disabled") && this.getAttribute("disabled") !== "false";
|
|
464
456
|
}
|
|
465
457
|
_maxFiles() {
|
|
466
458
|
const e = this.getAttribute("max-files");
|
|
467
|
-
if (!e)
|
|
468
|
-
return null;
|
|
459
|
+
if (!e) return null;
|
|
469
460
|
const t = Number(e);
|
|
470
461
|
return Number.isFinite(t) && t > 0 ? Math.floor(t) : null;
|
|
471
462
|
}
|
|
472
463
|
_maxSize() {
|
|
473
464
|
const e = this.getAttribute("max-size");
|
|
474
|
-
if (!e)
|
|
475
|
-
return null;
|
|
465
|
+
if (!e) return null;
|
|
476
466
|
const t = Number(e);
|
|
477
467
|
return Number.isFinite(t) && t > 0 ? t : null;
|
|
478
468
|
}
|
|
@@ -480,11 +470,11 @@ class T extends M {
|
|
|
480
470
|
this._applyFiles(e, t, !1);
|
|
481
471
|
}
|
|
482
472
|
_applyFiles(e, t, i) {
|
|
483
|
-
const s = this.hasAttribute("multiple"),
|
|
473
|
+
const s = this.hasAttribute("multiple"), a = i ? [] : s ? [...this._files] : [], r = [], n = [], m = this.getAttribute("accept") || "", _ = this._maxFiles(), v = this._maxSize(), x = new Set(a.map((o) => this._fileKey(o)));
|
|
484
474
|
e.forEach((o) => {
|
|
485
475
|
const b = this._fileKey(o);
|
|
486
476
|
if (!x.has(b)) {
|
|
487
|
-
if (!
|
|
477
|
+
if (!O(o, m)) {
|
|
488
478
|
n.push({ file: o, reason: "accept" });
|
|
489
479
|
return;
|
|
490
480
|
}
|
|
@@ -492,20 +482,20 @@ class T extends M {
|
|
|
492
482
|
n.push({ file: o, reason: "max-size" });
|
|
493
483
|
return;
|
|
494
484
|
}
|
|
495
|
-
if (_ != null &&
|
|
485
|
+
if (_ != null && a.length + r.length >= _) {
|
|
496
486
|
n.push({ file: o, reason: "max-files" });
|
|
497
487
|
return;
|
|
498
488
|
}
|
|
499
|
-
x.add(b),
|
|
489
|
+
x.add(b), r.push(o);
|
|
500
490
|
}
|
|
501
|
-
}), i && (this.cancelUploads(), this._uploadState.clear()), this._files = [...
|
|
491
|
+
}), i && (this.cancelUploads(), this._uploadState.clear()), this._files = [...a, ...r], !s && this._files.length > 1 && (this._files = [this._files[this._files.length - 1]]);
|
|
502
492
|
const w = new Set(this._files.map((o) => this._fileKey(o)));
|
|
503
493
|
Array.from(this._uploadState.keys()).forEach((o) => {
|
|
504
494
|
w.has(o) || this._uploadState.delete(o);
|
|
505
495
|
}), this._files.forEach((o) => {
|
|
506
496
|
const b = this._fileKey(o);
|
|
507
497
|
this._uploadState.has(b) || this._uploadState.set(b, { state: "pending", progress: null });
|
|
508
|
-
}), this._syncUi(), this._emit("change", { files: this.files, source: t }), n.length ? (this._emit("reject", { rejected: n, source: t }), this.setAttribute("data-error", n[0].reason === "accept" ? "One or more files do not match the accepted types" : n[0].reason === "max-size" ? "One or more files exceed the size limit" : "Too many files selected")) : this.removeAttribute("data-error"),
|
|
498
|
+
}), this._syncUi(), this._emit("change", { files: this.files, source: t }), n.length ? (this._emit("reject", { rejected: n, source: t }), this.setAttribute("data-error", n[0].reason === "accept" ? "One or more files do not match the accepted types" : n[0].reason === "max-size" ? "One or more files exceed the size limit" : "Too many files selected")) : this.removeAttribute("data-error"), r.length && this.hasAttribute("upload-on-select") && this.uploadRequest && this.startUpload(), this._syncUi();
|
|
509
499
|
}
|
|
510
500
|
_emit(e, t) {
|
|
511
501
|
this.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 }));
|
|
@@ -517,30 +507,28 @@ class T extends M {
|
|
|
517
507
|
this._uploadState.set(e, t), this._syncUi();
|
|
518
508
|
}
|
|
519
509
|
async _runUpload(e, t) {
|
|
520
|
-
if (!this.uploadRequest)
|
|
521
|
-
return;
|
|
510
|
+
if (!this.uploadRequest) return;
|
|
522
511
|
const i = this._fileKey(e), s = new AbortController();
|
|
523
512
|
this._uploadControllers.set(i, s), this._setUploadEntry(i, { state: "uploading", progress: 0 });
|
|
524
|
-
const
|
|
513
|
+
const a = (r) => {
|
|
525
514
|
const n = this._uploadState.get(i);
|
|
526
|
-
if (!n || n.state !== "uploading")
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
this._uploadState.set(i, { ...n, progress: f }), this._emit("upload-progress", { file: e, fileKey: i, progress: f, requestId: t }), this._syncUi();
|
|
515
|
+
if (!n || n.state !== "uploading") return;
|
|
516
|
+
const m = Number.isFinite(r) ? Math.max(0, Math.min(100, r)) : 0;
|
|
517
|
+
this._uploadState.set(i, { ...n, progress: m }), this._emit("upload-progress", { file: e, fileKey: i, progress: m, requestId: t }), this._syncUi();
|
|
530
518
|
};
|
|
531
519
|
try {
|
|
532
|
-
const
|
|
520
|
+
const r = await this.uploadRequest({
|
|
533
521
|
file: e,
|
|
534
522
|
files: this.files,
|
|
535
523
|
signal: s.signal,
|
|
536
|
-
setProgress:
|
|
524
|
+
setProgress: a
|
|
537
525
|
});
|
|
538
|
-
s.signal.aborted ? (this._uploadState.set(i, { state: "canceled", progress: null }), this._emit("upload-cancel", { file: e, fileKey: i, requestId: t })) : (this._uploadState.set(i, { state: "success", progress: 100, result:
|
|
539
|
-
} catch (
|
|
526
|
+
s.signal.aborted ? (this._uploadState.set(i, { state: "canceled", progress: null }), this._emit("upload-cancel", { file: e, fileKey: i, requestId: t })) : (this._uploadState.set(i, { state: "success", progress: 100, result: r }), this._emit("upload-success", { file: e, fileKey: i, requestId: t, result: r }));
|
|
527
|
+
} catch (r) {
|
|
540
528
|
if (s.signal.aborted)
|
|
541
529
|
this._uploadState.set(i, { state: "canceled", progress: null }), this._emit("upload-cancel", { file: e, fileKey: i, requestId: t });
|
|
542
530
|
else {
|
|
543
|
-
const n =
|
|
531
|
+
const n = r instanceof Error ? r.message : "Upload failed";
|
|
544
532
|
this._uploadState.set(i, { state: "error", progress: null, error: n }), this._emit("upload-error", { file: e, fileKey: i, requestId: t, error: n });
|
|
545
533
|
}
|
|
546
534
|
} finally {
|
|
@@ -549,14 +537,13 @@ class T extends M {
|
|
|
549
537
|
}
|
|
550
538
|
_parseProgress() {
|
|
551
539
|
const e = this.getAttribute("progress");
|
|
552
|
-
if (!e)
|
|
553
|
-
return {};
|
|
540
|
+
if (!e) return {};
|
|
554
541
|
try {
|
|
555
542
|
const t = JSON.parse(e);
|
|
556
543
|
return !t || typeof t != "object" || Array.isArray(t) ? {} : Object.fromEntries(
|
|
557
544
|
Object.entries(t).map(([i, s]) => {
|
|
558
|
-
const
|
|
559
|
-
return [i, Number.isFinite(
|
|
545
|
+
const a = Number(s);
|
|
546
|
+
return [i, Number.isFinite(a) ? Math.max(0, Math.min(100, a)) : 0];
|
|
560
547
|
})
|
|
561
548
|
);
|
|
562
549
|
} catch {
|
|
@@ -578,7 +565,7 @@ class T extends M {
|
|
|
578
565
|
}
|
|
579
566
|
}
|
|
580
567
|
_actionSummary() {
|
|
581
|
-
const e = this._files.map((
|
|
568
|
+
const e = this._files.map((a) => this._uploadState.get(this._fileKey(a)) || { state: "pending", progress: null }), t = e.filter((a) => a.state === "uploading").length, i = e.filter((a) => a.state === "error").length, s = e.filter((a) => a.state === "success").length;
|
|
582
569
|
return t > 0 ? {
|
|
583
570
|
title: "Upload in progress",
|
|
584
571
|
subtitle: `${t} file${t === 1 ? "" : "s"} still uploading`
|
|
@@ -594,11 +581,9 @@ class T extends M {
|
|
|
594
581
|
};
|
|
595
582
|
}
|
|
596
583
|
_getPreviewUrl(e) {
|
|
597
|
-
if (!this.hasAttribute("show-previews") || typeof URL > "u" || typeof URL.createObjectURL != "function" || !e.type.startsWith("image/"))
|
|
598
|
-
return null;
|
|
584
|
+
if (!this.hasAttribute("show-previews") || typeof URL > "u" || typeof URL.createObjectURL != "function" || !e.type.startsWith("image/")) return null;
|
|
599
585
|
const t = this._fileKey(e), i = this._previewUrls.get(t);
|
|
600
|
-
if (i)
|
|
601
|
-
return i;
|
|
586
|
+
if (i) return i;
|
|
602
587
|
const s = URL.createObjectURL(e);
|
|
603
588
|
return this._previewUrls.set(t, s), s;
|
|
604
589
|
}
|
|
@@ -614,20 +599,18 @@ class T extends M {
|
|
|
614
599
|
});
|
|
615
600
|
}
|
|
616
601
|
_syncUi() {
|
|
617
|
-
if (!this._surfaceEl || !this._inputEl || !this._listEl || !this._errorEl || !this._actionsEl)
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
v.hidden = !e, v.querySelector(".label-text").textContent = e, $.hidden = !i, x.hidden = !t, x.textContent = t, w.hidden = !e && !t, o.textContent = this._files.length ? `${this._files.length} file${this._files.length === 1 ? "" : "s"} selected` : r, b.textContent = this._files.length ? this._files.map((p) => p.name).join(", ") : this.getAttribute("accept") ? `Accepted: ${this.getAttribute("accept")}` : "Supports click, keyboard, and drag-and-drop upload", D.textContent = a, D.disabled = s, this._surfaceEl.setAttribute("data-dragging", this._dragging ? "true" : "false"), this._surfaceEl.setAttribute("aria-disabled", s ? "true" : "false"), this._inputEl.disabled = s, this._inputEl.multiple = this.hasAttribute("multiple"), this._inputEl.name = this.getAttribute("name") || "", this._inputEl.accept = this.getAttribute("accept") || "", this._errorEl.hidden = !f, this._errorEl.textContent = f;
|
|
602
|
+
if (!this._surfaceEl || !this._inputEl || !this._listEl || !this._errorEl || !this._actionsEl) return;
|
|
603
|
+
const e = (this.getAttribute("label") || "").trim(), t = (this.getAttribute("description") || "").trim(), i = this.hasAttribute("required"), s = this._disabled(), a = this.getAttribute("drop-label") || "Drag files here or browse from your device", r = this.getAttribute("button-text") || "Choose files", n = this.getAttribute("upload-button-text") || "Start upload", m = (this.getAttribute("data-error") || "").trim(), _ = this._parseProgress(), v = this.root.querySelector(".label"), x = this.root.querySelector(".description"), w = this.root.querySelector(".meta"), o = this.root.querySelector(".headline"), b = this.root.querySelector(".subline"), D = this.root.querySelector(".cta"), R = this.root.querySelector(".required"), $ = this.root.querySelector(".actions-title"), B = this.root.querySelector(".actions-subtitle"), k = this.root.querySelector(".actions-row");
|
|
604
|
+
v.hidden = !e, v.querySelector(".label-text").textContent = e, R.hidden = !i, x.hidden = !t, x.textContent = t, w.hidden = !e && !t, o.textContent = this._files.length ? `${this._files.length} file${this._files.length === 1 ? "" : "s"} selected` : a, b.textContent = this._files.length ? this._files.map((p) => p.name).join(", ") : this.getAttribute("accept") ? `Accepted: ${this.getAttribute("accept")}` : "Supports click, keyboard, and drag-and-drop upload", D.textContent = r, D.disabled = s, this._surfaceEl.setAttribute("data-dragging", this._dragging ? "true" : "false"), this._surfaceEl.setAttribute("aria-disabled", s ? "true" : "false"), this._inputEl.disabled = s, this._inputEl.multiple = this.hasAttribute("multiple"), this._inputEl.name = this.getAttribute("name") || "", this._inputEl.accept = this.getAttribute("accept") || "", this._errorEl.hidden = !m, this._errorEl.textContent = m;
|
|
621
605
|
const L = !!this.uploadRequest && this._files.length > 0, N = this._actionSummary();
|
|
622
|
-
if (this._actionsEl.hidden = !L,
|
|
606
|
+
if (this._actionsEl.hidden = !L, $.textContent = N.title, B.textContent = N.subtitle, k.replaceChildren(), L) {
|
|
623
607
|
const p = this._files.some((l) => {
|
|
624
|
-
|
|
625
|
-
const h = ((c = this._uploadState.get(this._fileKey(l))) == null ? void 0 : c.state) || "pending";
|
|
608
|
+
const h = this._uploadState.get(this._fileKey(l))?.state || "pending";
|
|
626
609
|
return h === "pending" || h === "error" || h === "canceled";
|
|
627
|
-
}),
|
|
628
|
-
if (
|
|
610
|
+
}), f = document.createElement("button");
|
|
611
|
+
if (f.type = "button", f.className = "file-remove", f.dataset.variant = "primary", f.textContent = this.uploading ? "Uploading…" : p ? n : "Upload complete", f.disabled = s || this.uploading || !p, f.addEventListener("click", (l) => {
|
|
629
612
|
l.stopPropagation(), this.startUpload();
|
|
630
|
-
}), k.append(
|
|
613
|
+
}), k.append(f), this.uploading) {
|
|
631
614
|
const l = document.createElement("button");
|
|
632
615
|
l.type = "button", l.className = "file-remove", l.dataset.tone = "danger", l.textContent = "Cancel uploads", l.disabled = s, l.addEventListener("click", (h) => {
|
|
633
616
|
h.stopPropagation(), this.cancelUploads();
|
|
@@ -635,8 +618,7 @@ class T extends M {
|
|
|
635
618
|
}
|
|
636
619
|
}
|
|
637
620
|
const P = /* @__PURE__ */ new Set();
|
|
638
|
-
this._listEl.hidden = this._files.length === 0, this._listEl.replaceChildren(...this._files.map((p,
|
|
639
|
-
var R;
|
|
621
|
+
this._listEl.hidden = this._files.length === 0, this._listEl.replaceChildren(...this._files.map((p, f) => {
|
|
640
622
|
const l = document.createElement("div");
|
|
641
623
|
l.className = "file";
|
|
642
624
|
const h = this._fileKey(p);
|
|
@@ -648,13 +630,13 @@ class T extends M {
|
|
|
648
630
|
const d = document.createElement("img");
|
|
649
631
|
d.src = K, d.alt = "", y.append(d);
|
|
650
632
|
} else
|
|
651
|
-
y.textContent =
|
|
633
|
+
y.textContent = p.name.split(".").pop()?.slice(0, 4).toUpperCase() || "FILE";
|
|
652
634
|
const S = document.createElement("div");
|
|
653
635
|
S.className = "file-text";
|
|
654
636
|
const C = document.createElement("div");
|
|
655
637
|
C.className = "file-name", C.textContent = p.name;
|
|
656
638
|
const E = document.createElement("div");
|
|
657
|
-
E.className = "file-meta", E.textContent =
|
|
639
|
+
E.className = "file-meta", E.textContent = j(p.size);
|
|
658
640
|
const U = document.createElement("span");
|
|
659
641
|
U.className = "status", U.dataset.state = c.state, U.textContent = this._statusLabel(c.state), E.append(U), S.append(C, E);
|
|
660
642
|
const u = document.createElement("button");
|
|
@@ -663,7 +645,7 @@ class T extends M {
|
|
|
663
645
|
})) : c.state === "error" ? (u.textContent = "Retry", u.dataset.variant = "primary", u.addEventListener("click", (d) => {
|
|
664
646
|
d.stopPropagation(), this._uploadState.set(h, { state: "pending", progress: null }), this._syncUi(), this.startUpload();
|
|
665
647
|
})) : (u.textContent = "Remove", u.addEventListener("click", (d) => {
|
|
666
|
-
d.stopPropagation(), this.removeFile(
|
|
648
|
+
d.stopPropagation(), this.removeFile(f);
|
|
667
649
|
})), l.append(y, S, u);
|
|
668
650
|
const A = typeof c.progress == "number" ? c.progress : _[h] ?? _[p.name];
|
|
669
651
|
if (typeof A == "number") {
|
|
@@ -683,42 +665,38 @@ class T extends M {
|
|
|
683
665
|
})), this._revokePreviewUrls(P);
|
|
684
666
|
}
|
|
685
667
|
_registerWithForm() {
|
|
686
|
-
var e;
|
|
687
668
|
this._formUnregister && (this._formUnregister(), this._formUnregister = null);
|
|
688
669
|
try {
|
|
689
|
-
const
|
|
690
|
-
|
|
670
|
+
const s = this.getRootNode().host?.closest?.("ui-form") || null || this.closest("ui-form"), a = this.getAttribute("name");
|
|
671
|
+
s && typeof s.registerField == "function" && a && (this._formUnregister = s.registerField(a, {
|
|
691
672
|
name: a,
|
|
692
673
|
getValue: () => this.files,
|
|
693
|
-
setValue: (
|
|
694
|
-
Array.isArray(
|
|
674
|
+
setValue: (r) => {
|
|
675
|
+
Array.isArray(r) && r.every((n) => n instanceof File) && this.setFiles(r);
|
|
695
676
|
},
|
|
696
677
|
validate: async () => this.hasAttribute("required") && this._files.length === 0 ? { valid: !1, message: "At least one file is required" } : { valid: !0 },
|
|
697
|
-
setError: (
|
|
698
|
-
|
|
678
|
+
setError: (r) => {
|
|
679
|
+
r ? this.setAttribute("data-error", r) : this.removeAttribute("data-error"), this._syncUi();
|
|
699
680
|
}
|
|
700
681
|
}));
|
|
701
682
|
} catch {
|
|
702
683
|
}
|
|
703
684
|
}
|
|
704
685
|
_onClick(e) {
|
|
705
|
-
|
|
706
|
-
t != null && t.closest(".file-remove") || this.openPicker();
|
|
686
|
+
e.target?.closest(".file-remove") || this.openPicker();
|
|
707
687
|
}
|
|
708
688
|
_onKeyDown(e) {
|
|
709
689
|
e.key !== "Enter" && e.key !== " " || (e.preventDefault(), this.openPicker());
|
|
710
690
|
}
|
|
711
691
|
_onInputChange() {
|
|
712
|
-
|
|
713
|
-
const e = Array.from(((t = this._inputEl) == null ? void 0 : t.files) || []);
|
|
692
|
+
const e = Array.from(this._inputEl?.files || []);
|
|
714
693
|
e.length && (this._appendFiles(e, "picker"), this._inputEl && (this._inputEl.value = ""));
|
|
715
694
|
}
|
|
716
695
|
_onDragEnter(e) {
|
|
717
696
|
this._disabled() || (e.preventDefault(), this._dragDepth += 1, this._dragging = !0, this._syncUi());
|
|
718
697
|
}
|
|
719
698
|
_onDragLeave(e) {
|
|
720
|
-
if (!this._surfaceEl)
|
|
721
|
-
return;
|
|
699
|
+
if (!this._surfaceEl) return;
|
|
722
700
|
const t = e.relatedTarget;
|
|
723
701
|
t && this._surfaceEl.contains(t) || (this._dragDepth = Math.max(0, this._dragDepth - 1), !(this._dragDepth > 0) && (this._dragging = !1, this._syncUi()));
|
|
724
702
|
}
|
|
@@ -726,15 +704,13 @@ class T extends M {
|
|
|
726
704
|
this._disabled() || e.preventDefault();
|
|
727
705
|
}
|
|
728
706
|
_onDrop(e) {
|
|
729
|
-
|
|
730
|
-
if (this._disabled())
|
|
731
|
-
return;
|
|
707
|
+
if (this._disabled()) return;
|
|
732
708
|
e.preventDefault(), this._dragDepth = 0, this._dragging = !1;
|
|
733
|
-
const t = Array.from(
|
|
709
|
+
const t = Array.from(e.dataTransfer?.files || []);
|
|
734
710
|
t.length && this._appendFiles(t, "drop"), this._syncUi();
|
|
735
711
|
}
|
|
736
712
|
}
|
|
737
|
-
typeof customElements < "u" && !customElements.get("ui-file-upload") && customElements.define("ui-file-upload",
|
|
713
|
+
typeof customElements < "u" && !customElements.get("ui-file-upload") && customElements.define("ui-file-upload", W);
|
|
738
714
|
export {
|
|
739
|
-
|
|
715
|
+
W as UIFileUpload
|
|
740
716
|
};
|
package/dist/flex.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("./ElementBase-EV6mVBUV.js"),y={sm:"var(--ui-breakpoint-sm, 640px)",md:"var(--ui-breakpoint-md, 768px)",lg:"var(--ui-breakpoint-lg, 1024px)",xl:"var(--ui-breakpoint-xl, 1280px)"},p=["display","direction","align","justify","wrap","gap","rowgap","columngap"],v={xs:"var(--ui-space-xs, 4px)",sm:"var(--ui-space-sm, 8px)",md:"var(--ui-space-md, 12px)",lg:"var(--ui-space-lg, 20px)",xl:"var(--ui-space-xl, 28px)"},b=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-flex-display: flex;
|
|
4
4
|
--ui-flex-direction: row;
|
package/dist/flex.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as g } from "./ElementBase-
|
|
1
|
+
import { E as g } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
2
|
const h = {
|
|
3
3
|
sm: "var(--ui-breakpoint-sm, 640px)",
|
|
4
4
|
md: "var(--ui-breakpoint-md, 768px)",
|
|
@@ -63,11 +63,9 @@ const h = {
|
|
|
63
63
|
}
|
|
64
64
|
`;
|
|
65
65
|
function x(i) {
|
|
66
|
-
if (!i)
|
|
67
|
-
return null;
|
|
66
|
+
if (!i) return null;
|
|
68
67
|
const e = i.trim();
|
|
69
|
-
if (!e.startsWith("{"))
|
|
70
|
-
return null;
|
|
68
|
+
if (!e.startsWith("{")) return null;
|
|
71
69
|
try {
|
|
72
70
|
const s = JSON.parse(e);
|
|
73
71
|
return !s || typeof s != "object" ? null : s;
|
|
@@ -118,8 +116,7 @@ class b extends g {
|
|
|
118
116
|
_applyInlineStyles() {
|
|
119
117
|
this._appliedInlineProps.forEach((e) => this.style.removeProperty(e)), this._appliedInlineProps.clear(), p.forEach((e) => {
|
|
120
118
|
const s = this.getAttribute(e);
|
|
121
|
-
if (!s || x(s))
|
|
122
|
-
return;
|
|
119
|
+
if (!s || x(s)) return;
|
|
123
120
|
const o = d(e, s);
|
|
124
121
|
Object.entries(o).forEach(([n, u]) => {
|
|
125
122
|
this.style.setProperty(n, u), this._appliedInlineProps.add(n);
|
|
@@ -135,8 +132,7 @@ class b extends g {
|
|
|
135
132
|
};
|
|
136
133
|
p.forEach((r) => {
|
|
137
134
|
const l = this.getAttribute(r), t = x(l);
|
|
138
|
-
if (!t)
|
|
139
|
-
return;
|
|
135
|
+
if (!t) return;
|
|
140
136
|
const a = (c, m) => {
|
|
141
137
|
Object.assign(c, d(r, m));
|
|
142
138
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("./ElementBase-EV6mVBUV.js"),d=require("./positioner-D_fqyx_j.js"),c=`
|
|
2
2
|
:host {
|
|
3
3
|
position: fixed;
|
|
4
4
|
inset: 0;
|
|
@@ -200,8 +200,8 @@
|
|
|
200
200
|
transition: none !important;
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
`;function
|
|
204
|
-
<style>${
|
|
203
|
+
`;function b(o,t){if(o==null||o==="")return t;const e=Number(o);return Number.isFinite(e)?e:t}function a(o,t){if(o==null)return t;const e=o.trim().toLowerCase();return e!=="false"&&e!=="0"&&e!=="off"}function f(o){if(!document.body.contains(o))return!1;const t=window.getComputedStyle(o);return!(t.display==="none"||t.visibility==="hidden"||Number.parseFloat(t.opacity||"1")<=0)}function p(o){return o==="top"||o==="bottom"?o:"auto"}function g(o){return o==="start"||o==="end"?o:"center"}function _(o,t){const e=o==="top"?"top":"bottom";return t==="start"?`${e}-start`:t==="end"?`${e}-end`:e}function m(o){const t='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',e=[];return o.forEach(i=>{i instanceof HTMLElement&&(i.matches(t)&&e.push(i),e.push(...Array.from(i.querySelectorAll(t))))}),Array.from(new Set(e))}class l extends h.ElementBase{constructor(){super(...arguments),this._anchor=null,this._panel=null,this._toolbarSlot=null,this._defaultSlot=null,this._raf=null,this._resizeObserver=null,this._mutationObserver=null,this._positioner=null,this._positionerPlacement=null,this._positionerOffset=0,this._globalListenersBound=!1,this._isOpen=!1,this._closeReason="programmatic",this._onWindowChangeBound=this._onWindowChange.bind(this),this._onDocumentPointerDownBound=this._onDocumentPointerDown.bind(this),this._onDocumentKeyDownBound=this._onDocumentKeyDown.bind(this),this._onPanelKeyDownBound=this._onPanelKeyDown.bind(this),this._onSlotChangeBound=this._onSlotChange.bind(this)}static get observedAttributes(){return["open","anchor-id","headless","disabled","placement","align","offset","close-on-outside","close-on-escape","aria-label","aria-labelledby","variant","density","shape","elevation","tone"]}connectedCallback(){super.connectedCallback(),this._syncAnchorFromAttribute(),this._syncOpenState(),this._schedulePosition()}disconnectedCallback(){this._unbindGlobalListeners(),this._teardownObservers(),this._positioner?.destroy(),this._positioner=null,this._raf!=null&&(cancelAnimationFrame(this._raf),this._raf=null),super.disconnectedCallback()}attributeChangedCallback(t,e,i){if(e!==i){if(t==="anchor-id"){this._syncAnchorFromAttribute(),this.hasAttribute("open")&&!this._anchor&&this._requestClose("anchor-missing"),this._schedulePosition();return}if(t==="open"){this._syncOpenState(),this._schedulePosition();return}if(t==="disabled"){this.hasAttribute("disabled")&&this.hasAttribute("open")&&this._requestClose("disabled");return}if(t==="headless"){this._syncOpenState(),this._schedulePosition();return}if(t==="aria-label"||t==="aria-labelledby"){this._syncPanelA11y();return}(t==="placement"||t==="align"||t==="offset")&&this._schedulePosition()}}showForAnchorId(t){if(this.hasAttribute("disabled")||!t)return;const e=document.getElementById(t);if(!e){this._requestClose("anchor-missing");return}this._anchor=e,this.setAttribute("anchor-id",t),this.openToolbar()}hide(){this.closeToolbar("programmatic")}openToolbar(){this.hasAttribute("disabled")||(this.hasAttribute("open")||this.setAttribute("open",""),this._schedulePosition())}closeToolbar(t="programmatic"){this.hasAttribute("open")&&(this._closeReason=t,this.removeAttribute("open"))}_syncOpenState(){const t=this.hasAttribute("open")&&!this.hasAttribute("headless")&&!this.hasAttribute("disabled");if(t===this._isOpen){t&&this._schedulePosition();return}if(this._isOpen=t,t){this._bindGlobalListeners(),this._ensureObservers(),this._dispatchOpenEvents(),this._schedulePosition();return}this._unbindGlobalListeners(),this._teardownObservers(),this._positioner?.destroy(),this._positioner=null,this._positionerPlacement=null,this._positionerOffset=0,this._raf!=null&&(cancelAnimationFrame(this._raf),this._raf=null),this._dispatchCloseEvents(this._closeReason),this._closeReason="programmatic"}_dispatchOpenEvents(){this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!0}}))}_dispatchCloseEvents(t){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,detail:{reason:t}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!1,reason:t}}))}_requestClose(t){if(!this.hasAttribute("open"))return;const e=new CustomEvent("request-close",{detail:{reason:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(e);const i=new CustomEvent("ui-request-close",{detail:{reason:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(i),!(e.defaultPrevented||i.defaultPrevented)&&this.closeToolbar(t)}_syncAnchorFromAttribute(){const t=this.getAttribute("anchor-id");if(!t){this._anchor=null;return}this._anchor=document.getElementById(t)}_schedulePosition(){!this.hasAttribute("open")||this.hasAttribute("headless")||this.hasAttribute("disabled")||(this._raf!=null&&cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>{this._raf=null,this._position()}))}_ensureObservers(){if(!(this._resizeObserver&&this._mutationObserver)){if(typeof ResizeObserver<"u"){if(this._resizeObserver=new ResizeObserver(()=>this._schedulePosition()),this._panel)try{this._resizeObserver.observe(this._panel)}catch{}if(this._anchor)try{this._resizeObserver.observe(this._anchor)}catch{}}if(typeof MutationObserver<"u"&&this._anchor){this._mutationObserver=new MutationObserver(()=>this._schedulePosition());try{this._mutationObserver.observe(this._anchor,{attributes:!0,childList:!1,subtree:!1})}catch{}}}}_teardownObservers(){this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)}_refreshObservers(){this._isOpen&&(this._teardownObservers(),this._ensureObservers())}_bindGlobalListeners(){this._globalListenersBound||(window.addEventListener("scroll",this._onWindowChangeBound,{passive:!0,capture:!0}),window.addEventListener("resize",this._onWindowChangeBound),document.addEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.addEventListener("keydown",this._onDocumentKeyDownBound,!0),this._globalListenersBound=!0)}_unbindGlobalListeners(){this._globalListenersBound&&(window.removeEventListener("scroll",this._onWindowChangeBound,!0),window.removeEventListener("resize",this._onWindowChangeBound),document.removeEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.removeEventListener("keydown",this._onDocumentKeyDownBound,!0),this._globalListenersBound=!1)}_position(){if(!this.hasAttribute("open")||this.hasAttribute("headless")||this.hasAttribute("disabled"))return;if(!this._anchor){this._requestClose("anchor-missing");return}if(!f(this._anchor)){this._requestClose("anchor-hidden");return}if(!this._panel)return;const t=Math.max(0,b(this.getAttribute("offset"),8)),e=p(this.getAttribute("placement")),i=g(this.getAttribute("align")),r=_(e,i);if(!this._positioner||this._positionerPlacement!==r||this._positionerOffset!==t){this._positioner?.destroy(),this._positioner=d.createPositioner({anchor:this._anchor,floating:this._panel,placement:r,strategy:"fixed",offset:t,flip:!0,shift:!0,boundaryPadding:8,observeWindowResize:!1,observeScroll:!1,observeAncestorScroll:!1,observeAncestorResize:!1,observeLayoutShift:!1,observeAnchorResize:!1,observeFloatingResize:!1,onUpdate:s=>{const u=s.placement.startsWith("top")?"top":"bottom";this.style.setProperty("--ui-floating-toolbar-origin-x",i==="start"?"0%":i==="end"?"100%":"50%"),this._panel?.setAttribute("data-side",u)}}),this._positionerPlacement=r,this._positionerOffset=t;return}this._positioner?.update()}_onWindowChange(){this.hasAttribute("open")&&this._schedulePosition()}_onDocumentPointerDown(t){if(!this.hasAttribute("open")||!a(this.getAttribute("close-on-outside"),!0))return;const e=t.composedPath();e.includes(this)||this._anchor&&e.includes(this._anchor)||this._requestClose("outside")}_onDocumentKeyDown(t){this.hasAttribute("open")&&t.key==="Escape"&&a(this.getAttribute("close-on-escape"),!0)&&(t.preventDefault(),this._requestClose("escape"))}_onPanelKeyDown(t){if(!this._panel||!["ArrowRight","ArrowLeft","Home","End"].includes(t.key))return;const e=this._getFocusableItems();if(e.length===0)return;const i=document.activeElement,r=i?e.indexOf(i):-1;let n=r;t.key==="Home"?n=0:t.key==="End"?n=e.length-1:t.key==="ArrowRight"?n=r<0?0:(r+1)%e.length:t.key==="ArrowLeft"&&(n=r<0?e.length-1:(r-1+e.length)%e.length);const s=e[n];s&&(t.preventDefault(),s.focus())}_getFocusableItems(){const t=this._toolbarSlot?.assignedElements({flatten:!0})||[],e=this._defaultSlot?.assignedElements({flatten:!0})||[];return m([...t,...e])}_onSlotChange(){this._syncRowVisibility(),this._schedulePosition()}_syncRowVisibility(){const t=this.root.querySelector(".row-toolbar"),e=this.root.querySelector(".row-default");if(!t||!e)return;const i=(this._toolbarSlot?.assignedNodes({flatten:!0})||[]).some(n=>n.nodeType===Node.TEXT_NODE?!!n.textContent?.trim():n.nodeType===Node.ELEMENT_NODE),r=(this._defaultSlot?.assignedNodes({flatten:!0})||[]).some(n=>n.nodeType===Node.TEXT_NODE?!!n.textContent?.trim():n.nodeType===Node.ELEMENT_NODE);i?t.removeAttribute("hidden"):t.setAttribute("hidden",""),r?e.removeAttribute("hidden"):e.setAttribute("hidden","")}_syncPanelA11y(){if(!this._panel)return;const t=this.getAttribute("aria-labelledby"),e=this.getAttribute("aria-label")||(t?null:"Floating toolbar");t?this._panel.setAttribute("aria-labelledby",t):this._panel.removeAttribute("aria-labelledby"),e?this._panel.setAttribute("aria-label",e):this._panel.removeAttribute("aria-label")}render(){this.setContent(`
|
|
204
|
+
<style>${c}</style>
|
|
205
205
|
<section class="panel" part="panel" role="toolbar" aria-orientation="horizontal" tabindex="-1">
|
|
206
206
|
<div class="row row-toolbar" part="row-toolbar">
|
|
207
207
|
<slot name="toolbar"></slot>
|
|
@@ -210,4 +210,4 @@
|
|
|
210
210
|
<slot></slot>
|
|
211
211
|
</div>
|
|
212
212
|
</section>
|
|
213
|
-
`),this._panel=this.root.querySelector(".panel"),this._toolbarSlot=this.root.querySelector('slot[name="toolbar"]'),this._defaultSlot=this.root.querySelector("slot:not([name])"),
|
|
213
|
+
`),this._panel=this.root.querySelector(".panel"),this._toolbarSlot=this.root.querySelector('slot[name="toolbar"]'),this._defaultSlot=this.root.querySelector("slot:not([name])"),this._panel?.removeEventListener("keydown",this._onPanelKeyDownBound),this._panel?.addEventListener("keydown",this._onPanelKeyDownBound),this._toolbarSlot?.removeEventListener("slotchange",this._onSlotChangeBound),this._defaultSlot?.removeEventListener("slotchange",this._onSlotChangeBound),this._toolbarSlot?.addEventListener("slotchange",this._onSlotChangeBound),this._defaultSlot?.addEventListener("slotchange",this._onSlotChangeBound),this._syncPanelA11y(),this._syncRowVisibility(),this._refreshObservers(),this._schedulePosition()}}typeof customElements<"u"&&!customElements.get("ui-floating-toolbar")&&customElements.define("ui-floating-toolbar",l);exports.UIFloatingToolbar=l;
|