@editora/ui-core 0.1.21 → 0.1.23
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/README.md +292 -221
- package/dist/{ElementBase-YlTLMsGk.mjs → ElementBase-BeZT54Hj.mjs} +3 -2
- package/dist/ElementBase-DxbvhLJs.js +1 -0
- package/dist/ElementBase.d.ts +2 -1
- package/dist/ElementBase.d.ts.map +1 -1
- package/dist/__tests__/setup.d.ts +0 -2
- package/dist/__tests__/setup.d.ts.map +1 -1
- package/dist/accordion.cjs.js +4 -4
- package/dist/accordion.esm.js +4 -4
- package/dist/alert-dialog.cjs.js +32 -32
- package/dist/alert-dialog.esm.js +95 -75
- package/dist/alert.cjs.js +7 -7
- package/dist/alert.esm.js +7 -7
- package/dist/anchor.cjs.js +3 -3
- package/dist/anchor.esm.js +6 -5
- package/dist/animated-beam.cjs.js +1 -1
- package/dist/animated-beam.esm.js +1 -1
- package/dist/animated-list.cjs.js +5 -5
- package/dist/animated-list.esm.js +5 -5
- package/dist/animated-text.cjs.js +5 -5
- package/dist/animated-text.esm.js +5 -5
- package/dist/app-header.cjs.js +4 -4
- package/dist/app-header.esm.js +4 -4
- package/dist/aspect-ratio.cjs.js +4 -4
- package/dist/aspect-ratio.esm.js +4 -4
- package/dist/avatar.cjs.js +14 -14
- package/dist/avatar.esm.js +31 -29
- package/dist/badge.cjs.js +5 -5
- package/dist/badge.esm.js +5 -5
- package/dist/block-controls.cjs.js +5 -5
- package/dist/block-controls.esm.js +5 -5
- package/dist/box.cjs.js +3 -3
- package/dist/box.esm.js +3 -3
- package/dist/breadcrumb.cjs.js +6 -6
- package/dist/breadcrumb.esm.js +6 -6
- package/dist/button.cjs.js +1 -1
- package/dist/button.esm.js +1 -1
- package/dist/{calendar-DLY4acgn.mjs → calendar-B3PUKHQm.mjs} +227 -183
- package/dist/{calendar-Dkof-FTK.js → calendar-D-mXMgqc.js} +74 -35
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +1 -1
- package/dist/card.cjs.js +8 -8
- package/dist/card.esm.js +63 -20
- package/dist/chart.cjs.js +5 -5
- package/dist/chart.esm.js +7 -7
- package/dist/checkbox.cjs.js +3 -3
- package/dist/checkbox.esm.js +3 -3
- package/dist/collapsible.cjs.js +8 -8
- package/dist/collapsible.esm.js +8 -8
- package/dist/collection.cjs.js +1 -1
- package/dist/collection.esm.js +9 -8
- package/dist/color-picker.cjs.js +30 -10
- package/dist/color-picker.esm.js +84 -62
- package/dist/combobox.cjs.js +29 -27
- package/dist/combobox.esm.js +51 -45
- package/dist/command-palette.cjs.js +1 -1
- package/dist/command-palette.esm.js +1 -1
- package/dist/command.cjs.js +2 -2
- package/dist/command.esm.js +3 -3
- package/dist/components/ui-alert-dialog.d.ts +1 -0
- package/dist/components/ui-alert-dialog.d.ts.map +1 -1
- package/dist/components/ui-anchor.d.ts +2 -1
- package/dist/components/ui-anchor.d.ts.map +1 -1
- package/dist/components/ui-avatar.d.ts +1 -0
- package/dist/components/ui-avatar.d.ts.map +1 -1
- package/dist/components/ui-button.d.ts +1 -0
- package/dist/components/ui-button.d.ts.map +1 -1
- package/dist/components/ui-calendar.d.ts.map +1 -1
- package/dist/components/ui-card.d.ts +3 -0
- package/dist/components/ui-card.d.ts.map +1 -1
- package/dist/components/ui-checkbox.d.ts.map +1 -1
- package/dist/components/ui-collection.d.ts +2 -1
- package/dist/components/ui-collection.d.ts.map +1 -1
- package/dist/components/ui-color-picker.d.ts.map +1 -1
- package/dist/components/ui-combobox.d.ts.map +1 -1
- package/dist/components/ui-data-table.d.ts.map +1 -1
- package/dist/components/ui-date-field.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.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-dock.d.ts +1 -0
- package/dist/components/ui-dock.d.ts.map +1 -1
- package/dist/components/ui-drawer.d.ts.map +1 -1
- package/dist/components/ui-dropdown.d.ts.map +1 -1
- package/dist/components/ui-field.d.ts.map +1 -1
- package/dist/components/ui-file-upload.d.ts.map +1 -1
- package/dist/components/ui-form.d.ts +1 -0
- package/dist/components/ui-form.d.ts.map +1 -1
- package/dist/components/ui-gantt.d.ts.map +1 -1
- package/dist/components/ui-input.d.ts.map +1 -1
- package/dist/components/ui-menu.d.ts.map +1 -1
- package/dist/components/ui-multi-select.d.ts.map +1 -1
- package/dist/components/ui-number-field.d.ts.map +1 -1
- package/dist/components/ui-password-field.d.ts.map +1 -1
- package/dist/components/ui-pin-input.d.ts +1 -0
- package/dist/components/ui-pin-input.d.ts.map +1 -1
- package/dist/components/ui-placement-grid.d.ts.map +1 -1
- package/dist/components/ui-progress.d.ts.map +1 -1
- package/dist/components/ui-radio.d.ts.map +1 -1
- package/dist/components/ui-rating.d.ts +1 -0
- package/dist/components/ui-rating.d.ts.map +1 -1
- package/dist/components/ui-roving-focus-group.d.ts +2 -1
- package/dist/components/ui-roving-focus-group.d.ts.map +1 -1
- package/dist/components/ui-select.d.ts.map +1 -1
- package/dist/components/ui-sortable.d.ts.map +1 -1
- package/dist/components/ui-switch.d.ts.map +1 -1
- package/dist/components/ui-table.d.ts.map +1 -1
- package/dist/components/ui-tabs.d.ts +1 -0
- package/dist/components/ui-tabs.d.ts.map +1 -1
- package/dist/components/ui-tags-input.d.ts +1 -0
- package/dist/components/ui-tags-input.d.ts.map +1 -1
- package/dist/components/ui-textarea.d.ts.map +1 -1
- package/dist/components/ui-time-field.d.ts.map +1 -1
- package/dist/components/ui-toggle-group.d.ts.map +1 -1
- package/dist/components/ui-toggle.d.ts.map +1 -1
- package/dist/components/ui-tree.d.ts.map +1 -1
- package/dist/components/ui-wizard.d.ts.map +1 -1
- package/dist/container.cjs.js +1 -1
- package/dist/container.esm.js +1 -1
- package/dist/context-menu.cjs.js +3 -3
- package/dist/context-menu.esm.js +5 -5
- package/dist/control-group.cjs.js +1 -1
- package/dist/control-group.esm.js +1 -1
- package/dist/control-name-BmoI1m3a.js +1 -0
- package/dist/control-name-Bpj7F34X.mjs +48 -0
- package/dist/data-table.cjs.js +6 -3
- package/dist/data-table.esm.js +146 -143
- package/dist/date-field.cjs.js +5 -5
- package/dist/date-field.esm.js +34 -31
- package/dist/date-picker.cjs.js +16 -16
- package/dist/date-picker.esm.js +49 -45
- package/dist/date-range-picker.cjs.js +5 -5
- package/dist/date-range-picker.esm.js +120 -118
- package/dist/date-range-time-picker.cjs.js +22 -22
- package/dist/date-range-time-picker.esm.js +89 -85
- package/dist/date-time-picker.cjs.js +23 -23
- package/dist/date-time-picker.esm.js +103 -99
- package/dist/{date-time-utils-y1N2gvG2.mjs → date-time-utils-BTlxnz5j.mjs} +1 -1
- package/dist/{date-time-utils-Dmost5Ee.js → date-time-utils-y3AvNvGe.js} +1 -1
- package/dist/description.cjs.js +4 -4
- package/dist/description.esm.js +4 -4
- package/dist/dialog.cjs.js +3 -3
- package/dist/dialog.esm.js +3 -3
- package/dist/direction-provider.cjs.js +1 -1
- package/dist/direction-provider.esm.js +1 -1
- package/dist/dismissable-layer.cjs.js +1 -1
- package/dist/dismissable-layer.esm.js +1 -1
- package/dist/dock.cjs.js +12 -12
- package/dist/dock.esm.js +73 -75
- package/dist/domElement-DazSZBjV.js +1 -0
- package/dist/domElement-ZlSGVP0l.mjs +5 -0
- package/dist/domElement.d.ts +2 -0
- package/dist/domElement.d.ts.map +1 -0
- package/dist/drawer.cjs.js +19 -19
- package/dist/drawer.esm.js +58 -58
- package/dist/dropdown.cjs.js +13 -13
- package/dist/dropdown.esm.js +50 -49
- package/dist/empty-state.cjs.js +4 -4
- package/dist/empty-state.esm.js +4 -4
- package/dist/field-error.cjs.js +2 -2
- package/dist/field-error.esm.js +2 -2
- package/dist/field.cjs.js +12 -12
- package/dist/field.esm.js +84 -75
- package/dist/fieldset.cjs.js +5 -5
- package/dist/fieldset.esm.js +5 -5
- package/dist/file-upload.cjs.js +4 -4
- package/dist/file-upload.esm.js +6 -4
- package/dist/flex.cjs.js +1 -1
- package/dist/flex.esm.js +1 -1
- package/dist/floating-toolbar.cjs.js +8 -8
- package/dist/floating-toolbar.esm.js +10 -10
- package/dist/focus-scope.cjs.js +1 -1
- package/dist/focus-scope.esm.js +1 -1
- package/dist/form.cjs.js +13 -13
- package/dist/form.esm.js +23 -13
- package/dist/gantt.cjs.js +43 -32
- package/dist/gantt.esm.js +100 -89
- package/dist/grid.cjs.js +1 -1
- package/dist/grid.esm.js +1 -1
- package/dist/hover-card.cjs.js +1 -1
- package/dist/hover-card.esm.js +1 -1
- package/dist/icon-cloud.cjs.js +4 -4
- package/dist/icon-cloud.esm.js +4 -4
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +121 -118
- package/dist/inline-edit.cjs.js +2 -2
- package/dist/inline-edit.esm.js +2 -2
- package/dist/input.cjs.js +14 -14
- package/dist/input.esm.js +40 -33
- package/dist/label.cjs.js +4 -4
- package/dist/label.esm.js +4 -4
- package/dist/layout.cjs.js +1 -1
- package/dist/layout.esm.js +1 -1
- package/dist/{listbox-B6QgECax.js → listbox-CTpRpuF7.js} +1 -1
- package/dist/{listbox-DJamVeFj.mjs → listbox-hMVOhKHC.mjs} +1 -1
- package/dist/listbox.cjs.js +1 -1
- package/dist/listbox.esm.js +1 -1
- package/dist/marquee.cjs.js +4 -4
- package/dist/marquee.esm.js +4 -4
- package/dist/masonry-grid.cjs.js +1 -1
- package/dist/masonry-grid.esm.js +1 -1
- package/dist/{menu-item-styles-CbNUEwP2.js → menu-item-styles-B4onAr4C.js} +3 -3
- package/dist/{menu-item-styles-CZiPwPwl.mjs → menu-item-styles-IGSFLAHu.mjs} +3 -3
- package/dist/menu.cjs.js +7 -7
- package/dist/menu.esm.js +30 -29
- package/dist/menubar.cjs.js +1 -1
- package/dist/menubar.esm.js +3 -3
- package/dist/meter.cjs.js +2 -2
- package/dist/meter.esm.js +2 -2
- package/dist/multi-select.cjs.js +17 -17
- package/dist/multi-select.esm.js +52 -44
- package/dist/navigation-menu.cjs.js +2 -2
- package/dist/navigation-menu.esm.js +2 -2
- package/dist/number-field.cjs.js +11 -13
- package/dist/number-field.esm.js +30 -28
- package/dist/number-ticker.cjs.js +5 -5
- package/dist/number-ticker.esm.js +5 -5
- package/dist/odometer.cjs.js +3 -3
- package/dist/odometer.esm.js +3 -3
- package/dist/orbiter.cjs.js +4 -4
- package/dist/orbiter.esm.js +4 -4
- package/dist/pagination.cjs.js +2 -2
- package/dist/pagination.esm.js +2 -2
- package/dist/{panel-group-CaD0_KQf.js → panel-group-BVHJEdfx.js} +1 -1
- package/dist/{panel-group-8sVNnGxg.mjs → panel-group-BxO_eNW6.mjs} +1 -1
- package/dist/panel-group.cjs.js +1 -1
- package/dist/panel-group.esm.js +1 -1
- package/dist/panel.cjs.js +1 -1
- package/dist/panel.esm.js +1 -1
- package/dist/password-field.cjs.js +23 -23
- package/dist/password-field.esm.js +48 -47
- package/dist/pin-input.cjs.js +8 -6
- package/dist/pin-input.esm.js +21 -15
- package/dist/placement-grid.cjs.js +4 -4
- package/dist/placement-grid.esm.js +58 -58
- package/dist/plugin-panel.cjs.js +2 -2
- package/dist/plugin-panel.esm.js +2 -2
- package/dist/popover.cjs.js +6 -6
- package/dist/popover.esm.js +5 -5
- package/dist/portal.cjs.js +1 -1
- package/dist/portal.esm.js +1 -1
- package/dist/positioner.cjs.js +1 -1
- package/dist/positioner.esm.js +1 -1
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +1 -1
- package/dist/primitives/control-name.d.ts +30 -0
- package/dist/primitives/control-name.d.ts.map +1 -0
- package/dist/primitives/trigger.d.ts +2 -0
- package/dist/primitives/trigger.d.ts.map +1 -0
- package/dist/progress.cjs.js +4 -4
- package/dist/progress.esm.js +20 -18
- package/dist/quick-actions.cjs.js +4 -4
- package/dist/quick-actions.esm.js +4 -4
- package/dist/radio-group.cjs.js +2 -2
- package/dist/radio-group.esm.js +2 -2
- package/dist/radio.cjs.js +3 -3
- package/dist/radio.esm.js +3 -3
- package/dist/rating.cjs.js +18 -17
- package/dist/rating.esm.js +91 -92
- package/dist/roving-focus-group.cjs.js +1 -1
- package/dist/roving-focus-group.esm.js +11 -10
- package/dist/{runtime-D1gFh1fS.mjs → runtime-CFnK53iC.mjs} +133 -94
- package/dist/runtime-DwE-tizc.js +1 -0
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.esm.js +29 -26
- package/dist/scroll-area.cjs.js +1 -1
- package/dist/scroll-area.esm.js +1 -1
- package/dist/section.cjs.js +1 -1
- package/dist/section.esm.js +1 -1
- package/dist/select.cjs.js +20 -19
- package/dist/select.esm.js +37 -33
- package/dist/selection-popup.cjs.js +3 -3
- package/dist/selection-popup.esm.js +3 -3
- package/dist/separator.cjs.js +8 -8
- package/dist/separator.esm.js +8 -8
- package/dist/sidebar.cjs.js +9 -9
- package/dist/sidebar.esm.js +16 -16
- package/dist/skeleton.cjs.js +8 -8
- package/dist/skeleton.esm.js +8 -8
- package/dist/slider.cjs.js +4 -4
- package/dist/slider.esm.js +4 -4
- package/dist/slot.cjs.js +4 -4
- package/dist/slot.esm.js +4 -4
- package/dist/sortable.cjs.js +43 -44
- package/dist/sortable.esm.js +100 -101
- package/dist/spinning-text.cjs.js +4 -4
- package/dist/spinning-text.esm.js +4 -4
- package/dist/split-button.cjs.js +1 -1
- package/dist/split-button.esm.js +2 -2
- package/dist/splitter.cjs.js +1 -1
- package/dist/splitter.esm.js +1 -1
- package/dist/stepper.cjs.js +2 -2
- package/dist/stepper.esm.js +2 -2
- package/dist/switch.cjs.js +11 -13
- package/dist/switch.esm.js +11 -13
- package/dist/table.cjs.js +10 -7
- package/dist/table.esm.js +47 -44
- package/dist/tabs.cjs.js +21 -22
- package/dist/tabs.esm.js +71 -67
- package/dist/tags-input.cjs.js +9 -9
- package/dist/tags-input.esm.js +32 -25
- package/dist/textarea.cjs.js +10 -10
- package/dist/textarea.esm.js +30 -21
- package/dist/theme.d.ts +18 -0
- package/dist/theme.d.ts.map +1 -1
- package/dist/time-field.cjs.js +5 -5
- package/dist/time-field.esm.js +21 -18
- package/dist/time-picker.cjs.js +4 -4
- package/dist/time-picker.esm.js +6 -6
- package/dist/timeline.cjs.js +3 -3
- package/dist/timeline.esm.js +5 -5
- package/dist/toast.cjs.js +7 -7
- package/dist/toast.esm.js +14 -14
- package/dist/toggle-group.cjs.js +6 -7
- package/dist/toggle-group.esm.js +64 -61
- package/dist/toggle.cjs.js +18 -18
- package/dist/toggle.esm.js +32 -31
- package/dist/toolbar.cjs.js +1 -1
- package/dist/toolbar.esm.js +1 -1
- package/dist/tooltip.cjs.js +5 -5
- package/dist/tooltip.esm.js +5 -5
- package/dist/transfer-list.cjs.js +4 -4
- package/dist/transfer-list.esm.js +4 -4
- package/dist/{tree-B3kE8ESs.mjs → tree-B_oQput6.mjs} +35 -34
- package/dist/tree-SivHxcAy.js +39 -0
- package/dist/tree-item.cjs.js +1 -1
- package/dist/tree-item.esm.js +1 -1
- package/dist/tree.cjs.js +1 -1
- package/dist/tree.esm.js +1 -1
- package/dist/trigger-BjnxLCeQ.mjs +9 -0
- package/dist/trigger-DkPsKxsP.js +1 -0
- package/dist/{ui-button-rXQOS9QJ.js → ui-button-BPrzJScZ.js} +29 -28
- package/dist/{ui-button-Q0GNNWKC.mjs → ui-button-Co8Sid6t.mjs} +70 -49
- package/dist/{ui-icon-BzVNC_lr.js → ui-icon-D3avtxX_.js} +5 -5
- package/dist/{ui-icon-YI6lyuqU.mjs → ui-icon-DLhB08Fo.mjs} +3 -3
- package/dist/visually-hidden.cjs.js +1 -1
- package/dist/visually-hidden.esm.js +1 -1
- package/dist/wizard.cjs.js +12 -13
- package/dist/wizard.esm.js +18 -16
- package/package.json +2 -2
- package/dist/ElementBase-EV6mVBUV.js +0 -1
- package/dist/runtime-CTaOSmBj.js +0 -1
- package/dist/tree-Dx_kv_ih.js +0 -39
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as u } from "./ElementBase-
|
|
1
|
+
import { E as u } from "./ElementBase-BeZT54Hj.mjs";
|
|
2
2
|
import { e as h } from "./positioner-D0VGxtYU.mjs";
|
|
3
3
|
const d = `
|
|
4
4
|
:host {
|
|
@@ -11,7 +11,7 @@ const d = `
|
|
|
11
11
|
|
|
12
12
|
--ui-floating-toolbar-bg: var(--ui-color-surface, #ffffff);
|
|
13
13
|
--ui-floating-toolbar-color: var(--ui-color-text, #0f172a);
|
|
14
|
-
--ui-floating-toolbar-muted: var(--ui-color-muted, #
|
|
14
|
+
--ui-floating-toolbar-muted: var(--ui-color-muted, #526175);
|
|
15
15
|
--ui-floating-toolbar-border-color: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 72%, transparent);
|
|
16
16
|
--ui-floating-toolbar-border: 1px solid var(--ui-floating-toolbar-border-color);
|
|
17
17
|
--ui-floating-toolbar-radius: 12px;
|
|
@@ -148,11 +148,11 @@ const d = `
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
:host([tone="success"]) {
|
|
151
|
-
--ui-floating-toolbar-accent: var(--ui-color-success, #
|
|
151
|
+
--ui-floating-toolbar-accent: var(--ui-color-success, #15803d);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
:host([tone="warning"]) {
|
|
155
|
-
--ui-floating-toolbar-accent: var(--ui-color-warning, #
|
|
155
|
+
--ui-floating-toolbar-accent: var(--ui-color-warning, #b45309);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
:host([tone="danger"]) {
|
|
@@ -203,7 +203,7 @@ const d = `
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
`;
|
|
206
|
-
function
|
|
206
|
+
function b(o, t) {
|
|
207
207
|
if (o == null || o === "") return t;
|
|
208
208
|
const e = Number(o);
|
|
209
209
|
return Number.isFinite(e) ? e : t;
|
|
@@ -213,7 +213,7 @@ function a(o, t) {
|
|
|
213
213
|
const e = o.trim().toLowerCase();
|
|
214
214
|
return e !== "false" && e !== "0" && e !== "off";
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function c(o) {
|
|
217
217
|
if (!document.body.contains(o)) return !1;
|
|
218
218
|
const t = window.getComputedStyle(o);
|
|
219
219
|
return !(t.display === "none" || t.visibility === "hidden" || Number.parseFloat(t.opacity || "1") <= 0);
|
|
@@ -414,12 +414,12 @@ class m extends u {
|
|
|
414
414
|
this._requestClose("anchor-missing");
|
|
415
415
|
return;
|
|
416
416
|
}
|
|
417
|
-
if (!
|
|
417
|
+
if (!c(this._anchor)) {
|
|
418
418
|
this._requestClose("anchor-hidden");
|
|
419
419
|
return;
|
|
420
420
|
}
|
|
421
421
|
if (!this._panel) return;
|
|
422
|
-
const t = Math.max(0,
|
|
422
|
+
const t = Math.max(0, b(this.getAttribute("offset"), 8)), e = f(this.getAttribute("placement")), i = p(this.getAttribute("align")), r = g(e, i);
|
|
423
423
|
if (!this._positioner || this._positionerPlacement !== r || this._positionerOffset !== t) {
|
|
424
424
|
this._positioner?.destroy(), this._positioner = h({
|
|
425
425
|
anchor: this._anchor,
|
|
@@ -488,14 +488,14 @@ class m extends u {
|
|
|
488
488
|
render() {
|
|
489
489
|
this.setContent(`
|
|
490
490
|
<style>${d}</style>
|
|
491
|
-
<
|
|
491
|
+
<div class="panel" part="panel" role="toolbar" aria-orientation="horizontal" tabindex="-1">
|
|
492
492
|
<div class="row row-toolbar" part="row-toolbar">
|
|
493
493
|
<slot name="toolbar"></slot>
|
|
494
494
|
</div>
|
|
495
495
|
<div class="row row-default" part="row-default">
|
|
496
496
|
<slot></slot>
|
|
497
497
|
</div>
|
|
498
|
-
</
|
|
498
|
+
</div>
|
|
499
499
|
`), 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();
|
|
500
500
|
}
|
|
501
501
|
}
|
package/dist/focus-scope.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("./ElementBase-DxbvhLJs.js"),n=require("./focus-scope-Bwug2gDv.js"),u=`
|
|
2
2
|
:host {
|
|
3
3
|
display: contents;
|
|
4
4
|
color-scheme: light dark;
|
package/dist/focus-scope.esm.js
CHANGED
package/dist/form.cjs.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("./ElementBase-DxbvhLJs.js");class _{constructor(){this.fields=new Map}registerField(t,e){if(!t)throw new Error("Field must have a name to register with the form");return this.fields.set(t,e),()=>{this.fields.delete(t)}}getValues(){const t={};for(const[e,i]of this.fields)t[e]=i.getValue();return t}setValue(t,e){const i=this.fields.get(t);i&&typeof i.setValue=="function"&&i.setValue(e)}async validateField(t){const e=this.fields.get(t);if(!e)return{valid:!0};if(typeof e.validate=="function"){const i=await e.validate();return e.setError&&e.setError(i.valid?void 0:i.message),i}return{valid:!0}}async validateAll(){const t={};let e=!0;const i=Array.from(this.fields.entries());for(const[r,s]of i){const n=await this.validateField(r);n.valid||(e=!1,t[r]=n.message||"invalid")}return{valid:e,errors:t}}}const v=new Set(["heading","title","description","state-text","loading-text"]),y=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-form-gap: 12px;
|
|
4
4
|
--ui-form-radius: 14px;
|
|
5
5
|
--ui-form-bg: var(--ui-color-surface, var(--ui-surface, #ffffff));
|
|
6
6
|
--ui-form-color: var(--ui-color-text, var(--ui-text, #0f172a));
|
|
7
|
-
--ui-form-muted: var(--ui-color-muted, var(--ui-muted, #
|
|
7
|
+
--ui-form-muted: var(--ui-color-muted, var(--ui-muted, #526175));
|
|
8
8
|
--ui-form-border-color: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 66%, transparent);
|
|
9
9
|
--ui-form-border: 1px solid var(--ui-form-border-color);
|
|
10
10
|
--ui-form-shadow:
|
|
@@ -131,9 +131,9 @@
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
.status[data-tone="warning"] {
|
|
134
|
-
--ui-form-status-bg: color-mix(in srgb, var(--ui-color-warning, #
|
|
135
|
-
--ui-form-status-border: color-mix(in srgb, var(--ui-color-warning, #
|
|
136
|
-
--ui-form-status-text: color-mix(in srgb, var(--ui-color-warning, #
|
|
134
|
+
--ui-form-status-bg: color-mix(in srgb, var(--ui-color-warning, #b45309) 12%, transparent);
|
|
135
|
+
--ui-form-status-border: color-mix(in srgb, var(--ui-color-warning, #b45309) 44%, var(--ui-form-border-color));
|
|
136
|
+
--ui-form-status-text: color-mix(in srgb, var(--ui-color-warning, #b45309) 90%, #111827 10%);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
.status[data-tone="error"] {
|
|
@@ -143,9 +143,9 @@
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
.status[data-tone="success"] {
|
|
146
|
-
--ui-form-status-bg: color-mix(in srgb, var(--ui-color-success, #
|
|
147
|
-
--ui-form-status-border: color-mix(in srgb, var(--ui-color-success, #
|
|
148
|
-
--ui-form-status-text: color-mix(in srgb, var(--ui-color-success, #
|
|
146
|
+
--ui-form-status-bg: color-mix(in srgb, var(--ui-color-success, #15803d) 12%, transparent);
|
|
147
|
+
--ui-form-status-border: color-mix(in srgb, var(--ui-color-success, #15803d) 44%, var(--ui-form-border-color));
|
|
148
|
+
--ui-form-status-text: color-mix(in srgb, var(--ui-color-success, #15803d) 90%, #111827 10%);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
.status[data-tone="loading"] {
|
|
@@ -214,11 +214,11 @@
|
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
:host([tone="success"]) {
|
|
217
|
-
--ui-form-accent: var(--ui-color-success, #
|
|
217
|
+
--ui-form-accent: var(--ui-color-success, #15803d);
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
:host([tone="warning"]) {
|
|
221
|
-
--ui-form-accent: var(--ui-color-warning, #
|
|
221
|
+
--ui-form-accent: var(--ui-color-warning, #b45309);
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
:host([tone="danger"]) {
|
|
@@ -281,11 +281,11 @@
|
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
:host([state="success"]) .form {
|
|
284
|
-
border-color: color-mix(in srgb, var(--ui-color-success, #
|
|
284
|
+
border-color: color-mix(in srgb, var(--ui-color-success, #15803d) 44%, var(--ui-form-border-color));
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
:host([state="warning"]) .form {
|
|
288
|
-
border-color: color-mix(in srgb, var(--ui-color-warning, #
|
|
288
|
+
border-color: color-mix(in srgb, var(--ui-color-warning, #b45309) 44%, var(--ui-form-border-color));
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
:host([state="error"]) .form {
|
|
@@ -342,7 +342,7 @@
|
|
|
342
342
|
border-color: CanvasText;
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
|
-
`;function m(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function u(o){if(!o)return!1;const t=o.assignedNodes({flatten:!0});return t.length?t.some(e=>e.nodeType===Node.TEXT_NODE?!!e.textContent?.trim():e.nodeType===Node.ELEMENT_NODE):!1}function x(o){const t=o.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"}function h(o){if(o==null)return o;if(o instanceof Date)return o.toISOString();if(typeof File<"u"&&o instanceof File)return{__file:!0,name:o.name,size:o.size,type:o.type,lastModified:o.lastModified};if(Array.isArray(o))return o.map(t=>h(t));if(typeof o=="object"){const t=Object.entries(o).sort(([i],[r])=>i.localeCompare(r)),e={};return t.forEach(([i,r])=>{e[i]=h(r)}),e}return o}function c(o){if(Array.isArray(o))return o.map(t=>c(t));if(o&&typeof o=="object"){if(typeof File<"u"&&o instanceof File)return o;if(o instanceof Date)return new Date(o.getTime());const t={};return Object.entries(o).forEach(([e,i])=>{t[e]=c(i)}),t}return o}function A(o){return o==="success"||o==="warning"||o==="error"?o:"default"}class b extends g.ElementBase{constructor(){super(),this._controller=new _,this._submitting=!1,this._autosaveTimer=null,this._readyFrame=null,this._dirtyFrame=null,this._initialSnapshot="",this._cleanValues={},this._baselineReady=!1,this._dirty=!1,this._dirtyAttrSyncing=!1,this._uid=Math.random().toString(36).slice(2,10),this._formEl=null,this._headerEl=null,this._headingEl=null,this._titleEl=null,this._descriptionEl=null,this._titleTextEl=null,this._descriptionTextEl=null,this._actionsEl=null,this._statusEl=null,this._statusTextEl=null,this._footerEl=null,this._titleSlot=null,this._headingSlot=null,this._descriptionSlot=null,this._actionsSlot=null,this._statusSlot=null,this._footerSlot=null,this._descriptionVisible=!1,this._statusVisible=!1,this._onNativeSubmit=this._onNativeSubmit.bind(this),this._onValueEvent=this._onValueEvent.bind(this),this._onBeforeUnload=this._onBeforeUnload.bind(this),this._onSlotChange=this._onSlotChange.bind(this)}static get observedAttributes(){return["novalidate","variant","tone","density","shape","elevation","gap","headless","loading","autosave","autosave-delay","guard-unsaved","dirty","disabled","heading","title","description","state","state-text","loading-text","aria-label","aria-labelledby"]}connectedCallback(){if(super.connectedCallback(),this.hasAttribute("title")&&!this.hasAttribute("heading")){const t=this.getAttribute("title");t!=null&&this.setAttribute("heading",t),this.removeAttribute("title")}this.root.addEventListener("submit",this._onNativeSubmit),this.root.addEventListener("slotchange",this._onSlotChange),this.addEventListener("input",this._onValueEvent),this.addEventListener("change",this._onValueEvent),this.hasAttribute("guard-unsaved")&&typeof window<"u"&&window.addEventListener("beforeunload",this._onBeforeUnload),queueMicrotask(()=>{!this.isConnected||this._baselineReady||this._setBaseline(this.getValues(),!1)}),this.hasAttribute("data-ui-ready")||(typeof requestAnimationFrame=="function"?this._readyFrame=requestAnimationFrame(()=>{this._readyFrame=null,this.setAttribute("data-ui-ready","")}):this._readyFrame=window.setTimeout(()=>{this._readyFrame=null,this.setAttribute("data-ui-ready","")},16))}disconnectedCallback(){this.root.removeEventListener("submit",this._onNativeSubmit),this.root.removeEventListener("slotchange",this._onSlotChange),this.removeEventListener("input",this._onValueEvent),this.removeEventListener("change",this._onValueEvent),this._readyFrame!=null&&(typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this._readyFrame),clearTimeout(this._readyFrame),this._readyFrame=null),this._autosaveTimer&&(clearTimeout(this._autosaveTimer),this._autosaveTimer=null),this._dirtyFrame!=null&&(typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this._dirtyFrame),clearTimeout(this._dirtyFrame),this._dirtyFrame=null),typeof window<"u"&&window.removeEventListener("beforeunload",this._onBeforeUnload),super.disconnectedCallback()}_onNativeSubmit(t){t.target?.classList.contains("form")&&(t.preventDefault(),t.stopPropagation(),!this.hasAttribute("disabled")&&this.submit())}registerField(t,e){return this._controller.registerField(t,e)}setValue(t,e){this._controller.setValue(t,e),this._setNativeValue(t,e,this._groupNativeControls({includeDisabled:!0})),this._scheduleDirtyRefresh()}setValues(t){if(!t||typeof t!="object")return;const e=this._groupNativeControls({includeDisabled:!0});Object.entries(t).forEach(([i,r])=>{this._controller.setValue(i,r),this._setNativeValue(i,r,e)}),this._scheduleDirtyRefresh()}getValues(){const t={...this._controller.getValues()},e=new Set(Object.keys(t)),i=this._collectNativeValues(e,this._groupNativeControls());return Object.assign(t,i),t}_queryNativeControls(t={}){const{includeDisabled:e=!1}=t;return Array.from(this.querySelectorAll("input[name],textarea[name],select[name]")).filter(r=>!(!x(r)||r.closest("ui-form")!==this||!e&&r.matches(":disabled")))}_groupNativeControls(t={}){const e=new Map;return this._queryNativeControls(t).forEach(i=>{const r=i.getAttribute("name")||"";if(!r)return;const s=e.get(r)||[];s.push(i),e.set(r,s)}),e}_collectNativeValues(t,e){const i={};return e.forEach((r,s)=>{if(t.has(s))return;const n=r[0];if(n){if(n instanceof HTMLInputElement&&n.type==="radio"){const a=r.find(l=>l instanceof HTMLInputElement&&l.checked);i[s]=a?a.value:"";return}if(n instanceof HTMLInputElement&&n.type==="checkbox"){if(r.length===1){i[s]=n.checked;return}i[s]=r.filter(a=>a instanceof HTMLInputElement&&a.checked).map(a=>a.value||"on");return}if(n instanceof HTMLSelectElement&&n.multiple){i[s]=Array.from(n.selectedOptions).map(a=>a.value);return}if(n instanceof HTMLInputElement&&n.type==="file"){i[s]=Array.from(n.files||[]);return}i[s]=n.value}}),i}_setNativeValue(t,e,i){const r=(i||this._groupNativeControls({includeDisabled:!0})).get(t)||[];if(!r.length)return;const s=r[0];if(s){if(s instanceof HTMLInputElement&&s.type==="radio"){const n=String(e??"");r.forEach(a=>{a instanceof HTMLInputElement&&(a.checked=a.value===n)});return}if(s instanceof HTMLInputElement&&s.type==="checkbox"){if(r.length===1){const a=typeof e=="boolean"?e:!!e;s.checked=a;return}const n=Array.isArray(e)?e.map(a=>String(a)):[];r.forEach(a=>{a instanceof HTMLInputElement&&(a.checked=n.includes(a.value||"on"))});return}if(s instanceof HTMLSelectElement&&s.multiple){const n=Array.isArray(e)?e.map(a=>String(a)):[];Array.from(s.options).forEach(a=>{a.selected=n.includes(a.value)});return}s instanceof HTMLInputElement&&s.type==="file"||(s.value=String(e??""))}}async validate(){const t=await this._controller.validateAll(),e=this._validateNativeControls(),i={valid:t.valid&&e.valid,errors:{...e.errors,...t.errors}};return this.dispatchEvent(new CustomEvent("validate",{bubbles:!0,composed:!0,detail:i})),i}_validateNativeControls(){const t={};let e=null,i=!0;return this._groupNativeControls().forEach((s,n)=>{for(const a of s)if(!(!a.willValidate||a.checkValidity())){i=!1,t[n]||(t[n]=a.validationMessage||"invalid"),e||(e=a);break}}),{valid:i,errors:t,firstInvalid:e}}async submit(){if(this._submitting||this.hasAttribute("loading")||this.hasAttribute("disabled"))return!1;this._submitting=!0;const t=this.hasAttribute("loading");t||this.setAttribute("loading","");try{const e=this.getValues();if(!this.hasAttribute("novalidate")){const r=await this._controller.validateAll(),s=this._validateNativeControls(),n={...s.errors,...r.errors},a=r.valid&&s.valid;if(this.dispatchEvent(new CustomEvent("validate",{bubbles:!0,composed:!0,detail:{valid:a,errors:n}})),!a)return this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,composed:!0,detail:{errors:n,values:e}})),this._focusFirstInvalid(s.firstInvalid,n),!1}return this.dispatchEvent(new CustomEvent("submit",{bubbles:!0,composed:!0,detail:{values:e}})),this.markClean(e),!0}finally{this._submitting=!1,t||this.removeAttribute("loading")}}_focusFirstInvalid(t,e){if(t){t.focus();return}const i=Object.entries(e).find(([,n])=>!!n)?.[0];if(!i)return;const r=i.replace(/"/g,'\\"'),s=this.querySelector(`[name="${r}"]`);!s||typeof s.focus!="function"||s.focus()}async requestSubmit(){return this.submit()}reset(t){if(t&&typeof t=="object"){this.setValues(t),this.markClean(t);return}this.setValues(this._cleanValues),this.markClean(this._cleanValues)}get dirty(){return this._dirty}isDirty(){return this._dirty}markClean(t){if(t&&typeof t=="object"){this._setBaseline(t);return}this._setBaseline(this.getValues())}_setBaseline(t,e=!0){this._cleanValues=c(t||{}),this._initialSnapshot=this._snapshot(this._cleanValues),this._baselineReady=!0,this._setDirty(!1,e)}_snapshot(t){const e=t&&typeof t=="object"?t:this.getValues();try{return JSON.stringify(h(e||{}))}catch{return""}}_setDirty(t,e=!0){this._dirty!==t&&(this._dirty=t,this._dirtyAttrSyncing=!0,t?this.setAttribute("dirty",""):this.hasAttribute("dirty")&&this.removeAttribute("dirty"),this._dirtyAttrSyncing=!1,this._syncStatus(),this._syncFormAttrs(),e&&this.dispatchEvent(new CustomEvent("dirty-change",{bubbles:!0,composed:!0,detail:{dirty:t,values:this.getValues()}})))}_scheduleDirtyRefresh(){if(this._dirtyFrame!=null)return;const t=typeof window<"u"?window.setTimeout.bind(window):setTimeout;this._dirtyFrame=t(()=>{this._dirtyFrame=null,this._refreshDirtyState()},0)}_refreshDirtyState(){if(!this._baselineReady)return;const t=this._snapshot()!==this._initialSnapshot;if(this._setDirty(t),!this.hasAttribute("autosave"))return;if(!t||this.hasAttribute("loading")){this._autosaveTimer&&(clearTimeout(this._autosaveTimer),this._autosaveTimer=null);return}const e=Number(this.getAttribute("autosave-delay")||800),i=Number.isFinite(e)&&e>=0?e:800;this._autosaveTimer&&clearTimeout(this._autosaveTimer),this._autosaveTimer=setTimeout(()=>{this._autosaveTimer=null,this._dirty&&this.dispatchEvent(new CustomEvent("autosave",{bubbles:!0,composed:!0,detail:{values:this.getValues(),dirty:this._dirty}}))},i)}_onValueEvent(t){const e=t.target;if(!e||e===this)return;const i=e.closest("ui-form");i&&i!==this||this._scheduleDirtyRefresh()}_onBeforeUnload(t){!this.hasAttribute("guard-unsaved")||!this._dirty||(t.preventDefault(),t.returnValue="")}_onSlotChange(){this._syncStructure(),this._syncStatus(),this._syncFormAttrs(),this._scheduleDirtyRefresh()}_syncGap(){const t=this.getAttribute("gap");t?this.style.setProperty("--ui-form-gap",t):this.style.removeProperty("--ui-form-gap")}_syncFormAttrs(){const t=this._formEl;if(!t)return;t.setAttribute("aria-busy",this.hasAttribute("loading")?"true":"false");const e=this.hasAttribute("disabled");t.setAttribute("aria-disabled",e?"true":"false"),e?t.setAttribute("inert",""):t.removeAttribute("inert"),this.hasAttribute("novalidate")?t.setAttribute("novalidate",""):t.removeAttribute("novalidate");const i=this.getAttribute("aria-label"),r=this.getAttribute("aria-labelledby");i?t.setAttribute("aria-label",i):t.removeAttribute("aria-label"),r?t.setAttribute("aria-labelledby",r):t.removeAttribute("aria-labelledby");const s=[];this._descriptionVisible&&s.push(`${this._uid}-description`),this._statusVisible&&s.push(`${this._uid}-status`),s.length?t.setAttribute("aria-describedby",s.join(" ")):t.removeAttribute("aria-describedby")}_syncStructure(){const t=(this.getAttribute("heading")||this.getAttribute("title")||"").trim(),e=(this.getAttribute("description")||"").trim(),i=u(this._headingSlot),r=u(this._titleSlot),s=u(this._descriptionSlot),n=u(this._actionsSlot),a=u(this._footerSlot),l=!!t||i||r,d=!!e||s,f=l||d,p=f||n;this._titleTextEl&&(this._titleTextEl.textContent=t,!t||i||r?this._titleTextEl.setAttribute("hidden",""):this._titleTextEl.removeAttribute("hidden")),this._descriptionTextEl&&(this._descriptionTextEl.textContent=e,!e||s?this._descriptionTextEl.setAttribute("hidden",""):this._descriptionTextEl.removeAttribute("hidden")),this._titleEl&&(l?this._titleEl.removeAttribute("hidden"):this._titleEl.setAttribute("hidden","")),this._descriptionEl&&(d?this._descriptionEl.removeAttribute("hidden"):this._descriptionEl.setAttribute("hidden","")),this._headingEl&&(f?this._headingEl.removeAttribute("hidden"):this._headingEl.setAttribute("hidden","")),this._actionsEl&&(n?this._actionsEl.removeAttribute("hidden"):this._actionsEl.setAttribute("hidden","")),this._headerEl&&(p?this._headerEl.removeAttribute("hidden"):this._headerEl.setAttribute("hidden","")),this._footerEl&&(a?this._footerEl.removeAttribute("hidden"):this._footerEl.setAttribute("hidden","")),this._descriptionVisible=d}_deriveStatusTextAndTone(){const t=this.hasAttribute("loading"),e=A(this.getAttribute("state")),i=(this.getAttribute("state-text")||"").trim(),r=(this.getAttribute("loading-text")||"").trim()||"Saving changes...";return t?{text:r,tone:"loading"}:i?{text:i,tone:e}:e==="success"?{text:"Saved",tone:"success"}:e==="warning"?{text:"Needs attention",tone:"warning"}:e==="error"?{text:"Validation errors present",tone:"error"}:this._dirty?{text:"Unsaved changes",tone:"warning"}:{text:"",tone:"default"}}_syncStatus(){if(!this._statusEl||!this._statusTextEl)return;const t=u(this._statusSlot),e=this._deriveStatusTextAndTone();t?this._statusTextEl.setAttribute("hidden",""):(this._statusTextEl.textContent=e.text,e.text?this._statusTextEl.removeAttribute("hidden"):this._statusTextEl.setAttribute("hidden",""));const i=t||!!e.text;i?this._statusEl.removeAttribute("hidden"):this._statusEl.setAttribute("hidden",""),this._statusEl.setAttribute("data-tone",e.tone),this._statusVisible=i}attributeChangedCallback(t,e,i){if(e!==i){if(t==="title"){i!=null&&!this.hasAttribute("heading")&&this.setAttribute("heading",i),this.hasAttribute("title")&&this.removeAttribute("title");return}if(v.has(t)){this._syncStructure(),this._syncStatus(),this._syncFormAttrs();return}if(t==="gap"){this._syncGap();return}if(t==="dirty"){if(!this._dirtyAttrSyncing){const r=this.hasAttribute("dirty");this._dirty=r,this._syncStatus(),this._syncFormAttrs()}return}if(t==="loading"||t==="novalidate"||t==="state"||t==="state-text"||t==="loading-text"||t==="disabled"){this._syncStatus(),this._syncFormAttrs();return}if(t==="guard-unsaved"){if(typeof window>"u")return;this.hasAttribute("guard-unsaved")?window.addEventListener("beforeunload",this._onBeforeUnload):window.removeEventListener("beforeunload",this._onBeforeUnload);return}(t==="aria-label"||t==="aria-labelledby")&&this._syncFormAttrs()}}render(){this._syncGap();const t=this.getAttribute("heading")||this.getAttribute("title")||"",e=this.getAttribute("description")||"";this.setContent(`
|
|
345
|
+
`;function m(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function u(o){if(!o)return!1;const t=o.assignedNodes({flatten:!0});return t.length?t.some(e=>e.nodeType===Node.TEXT_NODE?!!e.textContent?.trim():e.nodeType===Node.ELEMENT_NODE):!1}function x(o){const t=o.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"}function h(o){if(o==null)return o;if(o instanceof Date)return o.toISOString();if(typeof File<"u"&&o instanceof File)return{__file:!0,name:o.name,size:o.size,type:o.type,lastModified:o.lastModified};if(Array.isArray(o))return o.map(t=>h(t));if(typeof o=="object"){const t=Object.entries(o).sort(([i],[r])=>i.localeCompare(r)),e={};return t.forEach(([i,r])=>{e[i]=h(r)}),e}return o}function c(o){if(Array.isArray(o))return o.map(t=>c(t));if(o&&typeof o=="object"){if(typeof File<"u"&&o instanceof File)return o;if(o instanceof Date)return new Date(o.getTime());const t={};return Object.entries(o).forEach(([e,i])=>{t[e]=c(i)}),t}return o}function A(o){return o==="success"||o==="warning"||o==="error"?o:"default"}class b extends g.ElementBase{constructor(){super(),this._controller=new _,this._submitting=!1,this._autosaveTimer=null,this._readyFrame=null,this._dirtyFrame=null,this._initialSnapshot="",this._cleanValues={},this._baselineReady=!1,this._dirty=!1,this._dirtyAttrSyncing=!1,this._uid=Math.random().toString(36).slice(2,10),this._formEl=null,this._headerEl=null,this._headingEl=null,this._titleEl=null,this._descriptionEl=null,this._titleTextEl=null,this._descriptionTextEl=null,this._actionsEl=null,this._statusEl=null,this._statusTextEl=null,this._footerEl=null,this._titleSlot=null,this._headingSlot=null,this._descriptionSlot=null,this._actionsSlot=null,this._statusSlot=null,this._footerSlot=null,this._descriptionVisible=!1,this._statusVisible=!1,this._onNativeSubmit=this._onNativeSubmit.bind(this),this._onValueEvent=this._onValueEvent.bind(this),this._onBeforeUnload=this._onBeforeUnload.bind(this),this._onSlotChange=this._onSlotChange.bind(this)}static get observedAttributes(){return["novalidate","variant","tone","density","shape","elevation","gap","headless","loading","autosave","autosave-delay","guard-unsaved","dirty","disabled","heading","title","description","state","state-text","loading-text","aria-label","aria-labelledby"]}connectedCallback(){if(super.connectedCallback(),this.hasAttribute("title")&&!this.hasAttribute("heading")){const t=this.getAttribute("title");t!=null&&this.setAttribute("heading",t),this.removeAttribute("title")}this.root.addEventListener("submit",this._onNativeSubmit),this.root.addEventListener("slotchange",this._onSlotChange),this.addEventListener("input",this._onValueEvent),this.addEventListener("change",this._onValueEvent),this.hasAttribute("guard-unsaved")&&typeof window<"u"&&window.addEventListener("beforeunload",this._onBeforeUnload),this._adoptControls(),queueMicrotask(()=>{!this.isConnected||this._baselineReady||this._setBaseline(this.getValues(),!1)}),this.hasAttribute("data-ui-ready")||(typeof requestAnimationFrame=="function"?this._readyFrame=requestAnimationFrame(()=>{this._readyFrame=null,this.setAttribute("data-ui-ready","")}):this._readyFrame=window.setTimeout(()=>{this._readyFrame=null,this.setAttribute("data-ui-ready","")},16))}disconnectedCallback(){this.root.removeEventListener("submit",this._onNativeSubmit),this.root.removeEventListener("slotchange",this._onSlotChange),this.removeEventListener("input",this._onValueEvent),this.removeEventListener("change",this._onValueEvent),this._readyFrame!=null&&(typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this._readyFrame),clearTimeout(this._readyFrame),this._readyFrame=null),this._autosaveTimer&&(clearTimeout(this._autosaveTimer),this._autosaveTimer=null),this._dirtyFrame!=null&&(typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this._dirtyFrame),clearTimeout(this._dirtyFrame),this._dirtyFrame=null),typeof window<"u"&&window.removeEventListener("beforeunload",this._onBeforeUnload),super.disconnectedCallback()}_onNativeSubmit(t){t.target?.classList.contains("form")&&(t.preventDefault(),t.stopPropagation(),!this.hasAttribute("disabled")&&this.submit())}_adoptControls(){this.querySelectorAll("[name]").forEach(t=>{const e=t._registerWithForm;typeof e=="function"&&t.closest("ui-form")===this&&e.call(t)})}registerField(t,e){return this._controller.registerField(t,e)}setValue(t,e){this._controller.setValue(t,e),this._setNativeValue(t,e,this._groupNativeControls({includeDisabled:!0})),this._scheduleDirtyRefresh()}setValues(t){if(!t||typeof t!="object")return;const e=this._groupNativeControls({includeDisabled:!0});Object.entries(t).forEach(([i,r])=>{this._controller.setValue(i,r),this._setNativeValue(i,r,e)}),this._scheduleDirtyRefresh()}getValues(){const t={...this._controller.getValues()},e=new Set(Object.keys(t)),i=this._collectNativeValues(e,this._groupNativeControls());return Object.assign(t,i),t}_queryNativeControls(t={}){const{includeDisabled:e=!1}=t;return Array.from(this.querySelectorAll("input[name],textarea[name],select[name]")).filter(r=>!(!x(r)||r.closest("ui-form")!==this||!e&&r.matches(":disabled")))}_groupNativeControls(t={}){const e=new Map;return this._queryNativeControls(t).forEach(i=>{const r=i.getAttribute("name")||"";if(!r)return;const s=e.get(r)||[];s.push(i),e.set(r,s)}),e}_collectNativeValues(t,e){const i={};return e.forEach((r,s)=>{if(t.has(s))return;const n=r[0];if(n){if(n instanceof HTMLInputElement&&n.type==="radio"){const a=r.find(l=>l instanceof HTMLInputElement&&l.checked);i[s]=a?a.value:"";return}if(n instanceof HTMLInputElement&&n.type==="checkbox"){if(r.length===1){i[s]=n.checked;return}i[s]=r.filter(a=>a instanceof HTMLInputElement&&a.checked).map(a=>a.value||"on");return}if(n instanceof HTMLSelectElement&&n.multiple){i[s]=Array.from(n.selectedOptions).map(a=>a.value);return}if(n instanceof HTMLInputElement&&n.type==="file"){i[s]=Array.from(n.files||[]);return}i[s]=n.value}}),i}_setNativeValue(t,e,i){const r=(i||this._groupNativeControls({includeDisabled:!0})).get(t)||[];if(!r.length)return;const s=r[0];if(s){if(s instanceof HTMLInputElement&&s.type==="radio"){const n=String(e??"");r.forEach(a=>{a instanceof HTMLInputElement&&(a.checked=a.value===n)});return}if(s instanceof HTMLInputElement&&s.type==="checkbox"){if(r.length===1){const a=typeof e=="boolean"?e:!!e;s.checked=a;return}const n=Array.isArray(e)?e.map(a=>String(a)):[];r.forEach(a=>{a instanceof HTMLInputElement&&(a.checked=n.includes(a.value||"on"))});return}if(s instanceof HTMLSelectElement&&s.multiple){const n=Array.isArray(e)?e.map(a=>String(a)):[];Array.from(s.options).forEach(a=>{a.selected=n.includes(a.value)});return}s instanceof HTMLInputElement&&s.type==="file"||(s.value=String(e??""))}}async validate(){const t=await this._controller.validateAll(),e=this._validateNativeControls(),i={valid:t.valid&&e.valid,errors:{...e.errors,...t.errors}};return this.dispatchEvent(new CustomEvent("validate",{bubbles:!0,composed:!0,detail:i})),i}_validateNativeControls(){const t={};let e=null,i=!0;return this._groupNativeControls().forEach((s,n)=>{for(const a of s)if(!(!a.willValidate||a.checkValidity())){i=!1,t[n]||(t[n]=a.validationMessage||"invalid"),e||(e=a);break}}),{valid:i,errors:t,firstInvalid:e}}async submit(){if(this._submitting||this.hasAttribute("loading")||this.hasAttribute("disabled"))return!1;this._submitting=!0;const t=this.hasAttribute("loading");t||this.setAttribute("loading","");try{const e=this.getValues();if(!this.hasAttribute("novalidate")){const r=await this._controller.validateAll(),s=this._validateNativeControls(),n={...s.errors,...r.errors},a=r.valid&&s.valid;if(this.dispatchEvent(new CustomEvent("validate",{bubbles:!0,composed:!0,detail:{valid:a,errors:n}})),!a)return this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,composed:!0,detail:{errors:n,values:e}})),this._focusFirstInvalid(s.firstInvalid,n),!1}return this.dispatchEvent(new CustomEvent("submit",{bubbles:!0,composed:!0,detail:{values:e}})),this.markClean(e),!0}finally{this._submitting=!1,t||this.removeAttribute("loading")}}_focusFirstInvalid(t,e){if(t){t.focus();return}const i=Object.entries(e).find(([,n])=>!!n)?.[0];if(!i)return;const r=i.replace(/"/g,'\\"'),s=this.querySelector(`[name="${r}"]`);!s||typeof s.focus!="function"||s.focus()}async requestSubmit(){return this.submit()}reset(t){if(t&&typeof t=="object"){this.setValues(t),this.markClean(t);return}this.setValues(this._cleanValues),this.markClean(this._cleanValues)}get dirty(){return this._dirty}isDirty(){return this._dirty}markClean(t){if(t&&typeof t=="object"){this._setBaseline(t);return}this._setBaseline(this.getValues())}_setBaseline(t,e=!0){this._cleanValues=c(t||{}),this._initialSnapshot=this._snapshot(this._cleanValues),this._baselineReady=!0,this._setDirty(!1,e)}_snapshot(t){const e=t&&typeof t=="object"?t:this.getValues();try{return JSON.stringify(h(e||{}))}catch{return""}}_setDirty(t,e=!0){this._dirty!==t&&(this._dirty=t,this._dirtyAttrSyncing=!0,t?this.setAttribute("dirty",""):this.hasAttribute("dirty")&&this.removeAttribute("dirty"),this._dirtyAttrSyncing=!1,this._syncStatus(),this._syncFormAttrs(),e&&this.dispatchEvent(new CustomEvent("dirty-change",{bubbles:!0,composed:!0,detail:{dirty:t,values:this.getValues()}})))}_scheduleDirtyRefresh(){if(this._dirtyFrame!=null)return;const t=typeof window<"u"?window.setTimeout.bind(window):setTimeout;this._dirtyFrame=t(()=>{this._dirtyFrame=null,this._refreshDirtyState()},0)}_refreshDirtyState(){if(!this._baselineReady)return;const t=this._snapshot()!==this._initialSnapshot;if(this._setDirty(t),!this.hasAttribute("autosave"))return;if(!t||this.hasAttribute("loading")){this._autosaveTimer&&(clearTimeout(this._autosaveTimer),this._autosaveTimer=null);return}const e=Number(this.getAttribute("autosave-delay")||800),i=Number.isFinite(e)&&e>=0?e:800;this._autosaveTimer&&clearTimeout(this._autosaveTimer),this._autosaveTimer=setTimeout(()=>{this._autosaveTimer=null,this._dirty&&this.dispatchEvent(new CustomEvent("autosave",{bubbles:!0,composed:!0,detail:{values:this.getValues(),dirty:this._dirty}}))},i)}_onValueEvent(t){const e=t.target;if(!e||e===this)return;const i=e.closest("ui-form");i&&i!==this||this._scheduleDirtyRefresh()}_onBeforeUnload(t){!this.hasAttribute("guard-unsaved")||!this._dirty||(t.preventDefault(),t.returnValue="")}_onSlotChange(){this._syncStructure(),this._syncStatus(),this._syncFormAttrs(),this._scheduleDirtyRefresh()}_syncGap(){const t=this.getAttribute("gap");t?this.style.setProperty("--ui-form-gap",t):this.style.removeProperty("--ui-form-gap")}_syncFormAttrs(){const t=this._formEl;if(!t)return;t.setAttribute("aria-busy",this.hasAttribute("loading")?"true":"false");const e=this.hasAttribute("disabled");t.setAttribute("aria-disabled",e?"true":"false"),e?t.setAttribute("inert",""):t.removeAttribute("inert"),this.hasAttribute("novalidate")?t.setAttribute("novalidate",""):t.removeAttribute("novalidate");const i=this.getAttribute("aria-label"),r=this.getAttribute("aria-labelledby");i?t.setAttribute("aria-label",i):t.removeAttribute("aria-label"),r?t.setAttribute("aria-labelledby",r):t.removeAttribute("aria-labelledby");const s=[];this._descriptionVisible&&s.push(`${this._uid}-description`),this._statusVisible&&s.push(`${this._uid}-status`),s.length?t.setAttribute("aria-describedby",s.join(" ")):t.removeAttribute("aria-describedby")}_syncStructure(){const t=(this.getAttribute("heading")||this.getAttribute("title")||"").trim(),e=(this.getAttribute("description")||"").trim(),i=u(this._headingSlot),r=u(this._titleSlot),s=u(this._descriptionSlot),n=u(this._actionsSlot),a=u(this._footerSlot),l=!!t||i||r,d=!!e||s,f=l||d,p=f||n;this._titleTextEl&&(this._titleTextEl.textContent=t,!t||i||r?this._titleTextEl.setAttribute("hidden",""):this._titleTextEl.removeAttribute("hidden")),this._descriptionTextEl&&(this._descriptionTextEl.textContent=e,!e||s?this._descriptionTextEl.setAttribute("hidden",""):this._descriptionTextEl.removeAttribute("hidden")),this._titleEl&&(l?this._titleEl.removeAttribute("hidden"):this._titleEl.setAttribute("hidden","")),this._descriptionEl&&(d?this._descriptionEl.removeAttribute("hidden"):this._descriptionEl.setAttribute("hidden","")),this._headingEl&&(f?this._headingEl.removeAttribute("hidden"):this._headingEl.setAttribute("hidden","")),this._actionsEl&&(n?this._actionsEl.removeAttribute("hidden"):this._actionsEl.setAttribute("hidden","")),this._headerEl&&(p?this._headerEl.removeAttribute("hidden"):this._headerEl.setAttribute("hidden","")),this._footerEl&&(a?this._footerEl.removeAttribute("hidden"):this._footerEl.setAttribute("hidden","")),this._descriptionVisible=d}_deriveStatusTextAndTone(){const t=this.hasAttribute("loading"),e=A(this.getAttribute("state")),i=(this.getAttribute("state-text")||"").trim(),r=(this.getAttribute("loading-text")||"").trim()||"Saving changes...";return t?{text:r,tone:"loading"}:i?{text:i,tone:e}:e==="success"?{text:"Saved",tone:"success"}:e==="warning"?{text:"Needs attention",tone:"warning"}:e==="error"?{text:"Validation errors present",tone:"error"}:this._dirty?{text:"Unsaved changes",tone:"warning"}:{text:"",tone:"default"}}_syncStatus(){if(!this._statusEl||!this._statusTextEl)return;const t=u(this._statusSlot),e=this._deriveStatusTextAndTone();t?this._statusTextEl.setAttribute("hidden",""):(this._statusTextEl.textContent=e.text,e.text?this._statusTextEl.removeAttribute("hidden"):this._statusTextEl.setAttribute("hidden",""));const i=t||!!e.text;i?this._statusEl.removeAttribute("hidden"):this._statusEl.setAttribute("hidden",""),this._statusEl.setAttribute("data-tone",e.tone),this._statusVisible=i}attributeChangedCallback(t,e,i){if(e!==i){if(t==="title"){i!=null&&!this.hasAttribute("heading")&&this.setAttribute("heading",i),this.hasAttribute("title")&&this.removeAttribute("title");return}if(v.has(t)){this._syncStructure(),this._syncStatus(),this._syncFormAttrs();return}if(t==="gap"){this._syncGap();return}if(t==="dirty"){if(!this._dirtyAttrSyncing){const r=this.hasAttribute("dirty");this._dirty=r,this._syncStatus(),this._syncFormAttrs()}return}if(t==="loading"||t==="novalidate"||t==="state"||t==="state-text"||t==="loading-text"||t==="disabled"){this._syncStatus(),this._syncFormAttrs();return}if(t==="guard-unsaved"){if(typeof window>"u")return;this.hasAttribute("guard-unsaved")?window.addEventListener("beforeunload",this._onBeforeUnload):window.removeEventListener("beforeunload",this._onBeforeUnload);return}(t==="aria-label"||t==="aria-labelledby")&&this._syncFormAttrs()}}render(){this._syncGap();const t=this.getAttribute("heading")||this.getAttribute("title")||"",e=this.getAttribute("description")||"";this.setContent(`
|
|
346
346
|
<style>${y}</style>
|
|
347
347
|
<form
|
|
348
348
|
class="form"
|
package/dist/form.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as p } from "./ElementBase-
|
|
1
|
+
import { E as p } from "./ElementBase-BeZT54Hj.mjs";
|
|
2
2
|
class g {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.fields = /* @__PURE__ */ new Map();
|
|
@@ -45,7 +45,7 @@ const _ = /* @__PURE__ */ new Set(["heading", "title", "description", "state-tex
|
|
|
45
45
|
--ui-form-radius: 14px;
|
|
46
46
|
--ui-form-bg: var(--ui-color-surface, var(--ui-surface, #ffffff));
|
|
47
47
|
--ui-form-color: var(--ui-color-text, var(--ui-text, #0f172a));
|
|
48
|
-
--ui-form-muted: var(--ui-color-muted, var(--ui-muted, #
|
|
48
|
+
--ui-form-muted: var(--ui-color-muted, var(--ui-muted, #526175));
|
|
49
49
|
--ui-form-border-color: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 66%, transparent);
|
|
50
50
|
--ui-form-border: 1px solid var(--ui-form-border-color);
|
|
51
51
|
--ui-form-shadow:
|
|
@@ -172,9 +172,9 @@ const _ = /* @__PURE__ */ new Set(["heading", "title", "description", "state-tex
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
.status[data-tone="warning"] {
|
|
175
|
-
--ui-form-status-bg: color-mix(in srgb, var(--ui-color-warning, #
|
|
176
|
-
--ui-form-status-border: color-mix(in srgb, var(--ui-color-warning, #
|
|
177
|
-
--ui-form-status-text: color-mix(in srgb, var(--ui-color-warning, #
|
|
175
|
+
--ui-form-status-bg: color-mix(in srgb, var(--ui-color-warning, #b45309) 12%, transparent);
|
|
176
|
+
--ui-form-status-border: color-mix(in srgb, var(--ui-color-warning, #b45309) 44%, var(--ui-form-border-color));
|
|
177
|
+
--ui-form-status-text: color-mix(in srgb, var(--ui-color-warning, #b45309) 90%, #111827 10%);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
.status[data-tone="error"] {
|
|
@@ -184,9 +184,9 @@ const _ = /* @__PURE__ */ new Set(["heading", "title", "description", "state-tex
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
.status[data-tone="success"] {
|
|
187
|
-
--ui-form-status-bg: color-mix(in srgb, var(--ui-color-success, #
|
|
188
|
-
--ui-form-status-border: color-mix(in srgb, var(--ui-color-success, #
|
|
189
|
-
--ui-form-status-text: color-mix(in srgb, var(--ui-color-success, #
|
|
187
|
+
--ui-form-status-bg: color-mix(in srgb, var(--ui-color-success, #15803d) 12%, transparent);
|
|
188
|
+
--ui-form-status-border: color-mix(in srgb, var(--ui-color-success, #15803d) 44%, var(--ui-form-border-color));
|
|
189
|
+
--ui-form-status-text: color-mix(in srgb, var(--ui-color-success, #15803d) 90%, #111827 10%);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
.status[data-tone="loading"] {
|
|
@@ -255,11 +255,11 @@ const _ = /* @__PURE__ */ new Set(["heading", "title", "description", "state-tex
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
:host([tone="success"]) {
|
|
258
|
-
--ui-form-accent: var(--ui-color-success, #
|
|
258
|
+
--ui-form-accent: var(--ui-color-success, #15803d);
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
:host([tone="warning"]) {
|
|
262
|
-
--ui-form-accent: var(--ui-color-warning, #
|
|
262
|
+
--ui-form-accent: var(--ui-color-warning, #b45309);
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
:host([tone="danger"]) {
|
|
@@ -322,11 +322,11 @@ const _ = /* @__PURE__ */ new Set(["heading", "title", "description", "state-tex
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
:host([state="success"]) .form {
|
|
325
|
-
border-color: color-mix(in srgb, var(--ui-color-success, #
|
|
325
|
+
border-color: color-mix(in srgb, var(--ui-color-success, #15803d) 44%, var(--ui-form-border-color));
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
:host([state="warning"]) .form {
|
|
329
|
-
border-color: color-mix(in srgb, var(--ui-color-warning, #
|
|
329
|
+
border-color: color-mix(in srgb, var(--ui-color-warning, #b45309) 44%, var(--ui-form-border-color));
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
:host([state="error"]) .form {
|
|
@@ -466,7 +466,7 @@ class A extends p {
|
|
|
466
466
|
const t = this.getAttribute("title");
|
|
467
467
|
t != null && this.setAttribute("heading", t), this.removeAttribute("title");
|
|
468
468
|
}
|
|
469
|
-
this.root.addEventListener("submit", this._onNativeSubmit), this.root.addEventListener("slotchange", this._onSlotChange), this.addEventListener("input", this._onValueEvent), this.addEventListener("change", this._onValueEvent), this.hasAttribute("guard-unsaved") && typeof window < "u" && window.addEventListener("beforeunload", this._onBeforeUnload), queueMicrotask(() => {
|
|
469
|
+
this.root.addEventListener("submit", this._onNativeSubmit), this.root.addEventListener("slotchange", this._onSlotChange), this.addEventListener("input", this._onValueEvent), this.addEventListener("change", this._onValueEvent), this.hasAttribute("guard-unsaved") && typeof window < "u" && window.addEventListener("beforeunload", this._onBeforeUnload), this._adoptControls(), queueMicrotask(() => {
|
|
470
470
|
!this.isConnected || this._baselineReady || this._setBaseline(this.getValues(), !1);
|
|
471
471
|
}), this.hasAttribute("data-ui-ready") || (typeof requestAnimationFrame == "function" ? this._readyFrame = requestAnimationFrame(() => {
|
|
472
472
|
this._readyFrame = null, this.setAttribute("data-ui-ready", "");
|
|
@@ -480,6 +480,16 @@ class A extends p {
|
|
|
480
480
|
_onNativeSubmit(t) {
|
|
481
481
|
t.target?.classList.contains("form") && (t.preventDefault(), t.stopPropagation(), !this.hasAttribute("disabled") && this.submit());
|
|
482
482
|
}
|
|
483
|
+
// Markup that is on the page before the script that defines the elements is upgraded in the order the elements were
|
|
484
|
+
// defined, not in document order. A control defined before <ui-form> (ui-input, say) is upgraded first, finds no
|
|
485
|
+
// registerField() on the form yet, and skips registration for good: the form then has no values and validates
|
|
486
|
+
// nothing. Now that the form is upgraded, ask the controls inside it to register again.
|
|
487
|
+
_adoptControls() {
|
|
488
|
+
this.querySelectorAll("[name]").forEach((t) => {
|
|
489
|
+
const e = t._registerWithForm;
|
|
490
|
+
typeof e == "function" && t.closest("ui-form") === this && e.call(t);
|
|
491
|
+
});
|
|
492
|
+
}
|
|
483
493
|
registerField(t, e) {
|
|
484
494
|
return this._controller.registerField(t, e);
|
|
485
495
|
}
|
package/dist/gantt.cjs.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const At=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const At=require("./ElementBase-DxbvhLJs.js"),I=1440*60*1e3,y=42,V=62,J=376,N=28,Lt=15,vt=Lt*Math.SQRT2/2,gt={day:36,week:13,month:4.4,quarter:2.2,year:1.15},ht=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-gantt-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
4
4
|
--ui-gantt-panel: var(--ui-color-surface, #ffffff);
|
|
5
5
|
--ui-gantt-border: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 76%, transparent);
|
|
6
6
|
--ui-gantt-grid: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 56%, transparent);
|
|
7
7
|
--ui-gantt-text: var(--ui-color-text, #0f172a);
|
|
8
|
-
--ui-gantt-muted: var(--ui-color-muted, #
|
|
8
|
+
--ui-gantt-muted: var(--ui-color-muted, #526175);
|
|
9
9
|
--ui-gantt-accent: var(--ui-color-primary, #2563eb);
|
|
10
10
|
--ui-gantt-selected: color-mix(in srgb, var(--ui-gantt-accent) 10%, transparent);
|
|
11
11
|
display: block;
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
.zoom-button[aria-pressed="true"] {
|
|
89
89
|
border-color: color-mix(in srgb, var(--ui-gantt-accent) 46%, var(--ui-gantt-border));
|
|
90
90
|
background: color-mix(in srgb, var(--ui-gantt-accent) 10%, var(--ui-gantt-panel));
|
|
91
|
-
color: var(--ui-gantt-accent);
|
|
91
|
+
color: color-mix(in srgb, var(--ui-gantt-accent) 82%, var(--ui-gantt-text));
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
.viewport {
|
|
@@ -112,6 +112,17 @@
|
|
|
112
112
|
border-bottom: 1px solid var(--ui-gantt-border);
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
/* Explicit placement: the treegrid wrapper (display: contents) now holds the grid head and body
|
|
116
|
+
next to each other in the DOM, so the four panes no longer rely on source order. */
|
|
117
|
+
.grid-head { grid-column: 1; grid-row: 1; }
|
|
118
|
+
.timeline-head { grid-column: 2; grid-row: 1; }
|
|
119
|
+
.grid-body { grid-column: 1; grid-row: 2; }
|
|
120
|
+
.timeline-body { grid-column: 2; grid-row: 2; }
|
|
121
|
+
|
|
122
|
+
.grid-semantics {
|
|
123
|
+
display: contents;
|
|
124
|
+
}
|
|
125
|
+
|
|
115
126
|
.grid-head {
|
|
116
127
|
left: 0;
|
|
117
128
|
z-index: 5;
|
|
@@ -656,33 +667,31 @@
|
|
|
656
667
|
box-shadow: none;
|
|
657
668
|
}
|
|
658
669
|
}
|
|
659
|
-
`,mt={default:"var(--ui-color-primary, #2563eb)",info:"var(--ui-color-info, #
|
|
670
|
+
`,mt={default:"var(--ui-color-primary, #2563eb)",info:"var(--ui-color-info, #0e7490)",success:"var(--ui-color-success, #15803d)",warning:"var(--ui-color-warning, #b45309)",danger:"var(--ui-color-danger, #dc2626)"};function b(a){return String(a??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function f(a){if(a instanceof Date){const n=a.getTime();return Number.isFinite(n)?F(n):null}const t=String(a||"").trim(),i=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(i){const n=Number(i[1]),s=Number(i[2]),l=Number(i[3]),p=new Date(n,s-1,l).getTime();return Number.isFinite(p)?F(p):null}const e=Date.parse(t);return Number.isFinite(e)?F(e):null}function F(a){const t=new Date(a);return t.setHours(0,0,0,0),t.getTime()}function x(a,t){return F(a+t*I)}function E(a){const t=new Date(a),i=t.getFullYear(),e=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${i}-${e}-${n}`}function O(a){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(a))}function bt(a){return a==="day"||a==="month"||a==="quarter"||a==="year"?a:"week"}function W(a){return a==="start"||a==="end"||a==="label"||a==="progress"?a:"none"}function Dt(a){return a==="soft"||a==="striped"||a==="outline"||a==="glass"?a:"solid"}function Ft(a,t){if(!a)return[];try{const i=JSON.parse(a);return Array.isArray(i)?i.map((e,n)=>{if(!e||typeof e!="object")return null;const s=e,l=String(s.label||s.text||"").trim(),o=f(s.start),p=Number(s.duration);let u=f(s.end);if(u==null&&o!=null&&Number.isFinite(p)&&(u=x(o,Math.max(0,p))),!l||o==null)return null;const d=s.type==="summary"||s.type==="milestone"?s.type:"task",g=d==="milestone"?o:Math.max(u??x(o,1),x(o,1)),c=String(s.id||`task-${n+1}`),m=t.get(c)||{};return{id:c,label:l,start:m.start||E(o),end:m.end||E(g),progress:Number.isFinite(Number(s.progress))?Math.max(0,Math.min(100,Number(s.progress))):void 0,tone:typeof s.tone=="string"?s.tone:void 0,type:d,parent:s.parent!=null?String(s.parent):void 0,open:s.open!==!1,assignee:s.assignee!=null?String(s.assignee):s.owner!=null?String(s.owner):void 0,readonly:s.readonly===!0,baselineStart:s.baselineStart!=null?String(s.baselineStart):void 0,baselineEnd:s.baselineEnd!=null?String(s.baselineEnd):void 0,critical:s.critical===!0,segments:Array.isArray(s.segments)?s.segments:void 0}}).filter(Boolean):[]}catch{return[]}}function Rt(a){if(!a)return[];try{const t=JSON.parse(a);return Array.isArray(t)?t.map((i,e)=>{if(!i||typeof i!="object")return null;const n=i,s=String(n.source||"").trim(),l=String(n.target||"").trim();if(!s||!l)return null;const o=n.type==="s2s"||n.type==="e2e"||n.type==="s2e"?n.type:"e2s";return{id:String(n.id||`link-${e+1}`),source:s,target:l,type:o}}).filter(Boolean):[]}catch{return[]}}function qt(a,t){return t==="none"?a:[...a].sort((i,e)=>{if(t==="label")return i.label.localeCompare(e.label);if(t==="progress")return Number(e.progress??0)-Number(i.progress??0);const n=f(t==="start"?i.start:i.end)??0,s=f(t==="start"?e.start:e.end)??0;return n-s})}function Nt(a,t,i,e){const n=new Map,s=new Map(a.map(d=>[d.id,d]));a.forEach(d=>{const g=d.parent&&s.has(d.parent)?d.parent:"__root__",c=n.get(g)||[];c.push(d),n.set(g,c)});const l=i.trim().toLowerCase(),o=d=>!l||d.label.toLowerCase().includes(l)||(d.assignee||"").toLowerCase().includes(l)?!0:(n.get(d.id)||[]).some(o),p=[],u=(d,g)=>{qt(n.get(d)||[],e).forEach(c=>{if(!o(c))return;const m=f(c.start),h=f(c.end);if(m==null||h==null)return;const w=(n.get(c.id)||[]).length>0;p.push({...c,depth:g,hasChildren:w,startMs:m,endMs:h}),w&&!t.has(c.id)&&u(c.id,g+1)})};return u("__root__",0),p}function Ht(a,t,i,e,n=0,s=Number.POSITIVE_INFINITY){const l=Math.max(1,Math.ceil((t-a)/I)),o=e==="day"?1:e==="week"?7:e==="month"?30:e==="quarter"?91:365,p=Math.max(0,Math.floor(Math.max(0,n-480)/i/o)*o),u=Math.min(l,Math.ceil((n+s+960)/i/o)*o),d=[];for(let g=p;g<=u;g+=o){const c=g*i,m=x(a,g),h=e==="day"?O(m):new Intl.DateTimeFormat(void 0,{month:"short",year:e==="week"||e==="month"?void 0:"numeric"}).format(new Date(m));d.push(`<span class="tick" style="left:${c.toFixed(2)}px">${b(h)}</span>`)}return d.join("")}function H(a){return a.type==="summary"||a.hasChildren?"summary":a.type==="milestone"||a.startMs===a.endMs?"milestone":"task"}function ft(a){const t=H(a);return t==="summary"?17+9/2:t==="milestone"?7+N/2:12+18/2}function _t(a,t){return H(a)==="milestone"?t(a.startMs)-vt:t(a.startMs)}function jt(a,t){return H(a)==="milestone"?t(a.startMs)+vt:t(a.endMs)}function xt(a,t,i){return t==="start"?_t(a,i):jt(a,i)}function Vt(a="e2s"){return a==="s2s"?{source:"start",target:"start"}:a==="e2e"?{source:"end",target:"end"}:a==="s2e"?{source:"start",target:"end"}:{source:"end",target:"start"}}function Wt(a,t,i,e,n,s){const l=Vt(n),o=l.source==="start"?-1:1,p=l.target==="start"?1:-1,u=xt(a,l.source,s),d=xt(i,l.target,s),g=t*y+ft(a),c=e*y+ft(i),m=22,h=u+o*m,w=d-p*m,M=26;let k=(h+w)/2;if(o===p){const T=o===1?Math.max(h,w,u,d)+M:Math.min(h,w,u,d)-M;k=(o===1?w>h+M:w<h-M)?k:T}else(o===1?w<h:w>h)&&(k=o===1?Math.max(h,u,d)+M:Math.min(h,u,d)-M);const A=Math.abs(c-g)<1?l.target==="start"?c-16:c+16:c>g?c-y/2+3:c+y/2-3;return[[u,g],[h,g],[k,g],[k,A],[w,A],[w,c],[d,c]].map(([T,R],P)=>`${P===0?"M":"L"} ${T.toFixed(1)} ${R.toFixed(1)}`).join(" ")}class wt extends At.ElementBase{constructor(){super(...arguments),this.collapsed=new Set,this.overrides=new Map,this.drag=null,this.selectedId=null,this.internalFilter="",this.viewportTop=0,this.viewportLeft=0,this.viewportWidth=1800,this.viewportHeight=620,this.renderedFirstRow=0,this.renderedLastRow=0,this.scrollFrame=null,this.overridesVersion=0,this.taskCacheRaw=null,this.taskCacheVersion=-1,this.taskCache=[],this.linkCacheRaw=null,this.linkCache=[],this.visibleCacheKey="",this.visibleCache=[]}static get observedAttributes(){return["tasks","links","zoom","filter","sort","bar-variant","variant","readonly","show-toolbar","show-today","headless"]}render(){const t=this.getTasks(),i=this.getLinks(),e=bt(this.getAttribute("zoom")),n=W(this.getAttribute("sort")),s=Dt(this.getAttribute("bar-variant")),l=this.getAttribute("filter")??this.internalFilter,o=this.getVisibleTasks(t,l,n),p=this.hasAttribute("readonly"),u=this.getAttribute("show-toolbar")!=="false",d=this.getAttribute("show-today")!=="false";if(!t.length){this.setContent(`
|
|
660
671
|
<style>${ht}</style>
|
|
661
672
|
<section class="frame" part="frame">
|
|
662
673
|
<div class="empty" part="empty">No tasks in this range</div>
|
|
663
674
|
</section>
|
|
664
|
-
`);return}const g=t.map(r=>f(r.start)).filter(r=>r!=null),c=t.map(r=>f(r.end)).filter(r=>r!=null),m=x(Math.min(...g),-2),h=x(Math.max(...c),3),w=Math.max(7,Math.ceil((h-m)/I)),M=gt[e],k=Math.max(680,w*M),A=Math.max(o.length*y,y),
|
|
665
|
-
<
|
|
675
|
+
`);return}const g=t.map(r=>f(r.start)).filter(r=>r!=null),c=t.map(r=>f(r.end)).filter(r=>r!=null),m=x(Math.min(...g),-2),h=x(Math.max(...c),3),w=Math.max(7,Math.ceil((h-m)/I)),M=gt[e],k=Math.max(680,w*M),A=Math.max(o.length*y,y),S=this.getAttribute("virtualized")!=="false"&&o.length>240,T=Math.max(20,Math.ceil(Math.max(420,this.viewportHeight-V)/y)),R=160,P=Math.max(0,this.viewportTop-V),yt=Math.max(0,Math.floor(P/y)),X=Math.max(180,T*4),L=S?Math.max(0,Math.floor(yt/X)*X-R):0,B=S?Math.min(o.length,L+T+R*2+X):o.length,K=o.slice(L,B),_=L*y,j=Math.max(0,(o.length-B)*y);this.renderedFirstRow=L,this.renderedLastRow=B;const Q=new Map(o.map((r,$)=>[r.id,{task:r,index:$}])),tt=new Set(K.map(r=>r.id)),z=r=>(r-m)/I*M,kt=K.map((r,$)=>{const C=L+$,v=this.selectedId===r.id?" selected":"",D=H(r),G=r.progress==null?"-":`${Math.round(r.progress)}%`,U=D==="milestone"?O(r.startMs):`${O(r.startMs)} - ${O(r.endMs)}`;return`
|
|
676
|
+
<div class="grid-row${v}" part="grid-row" data-task-id="${b(r.id)}" role="row" aria-rowindex="${C+2}" aria-level="${r.depth+1}" ${r.hasChildren?`aria-expanded="${!this.collapsed.has(r.id)}"`:""}>
|
|
666
677
|
<div class="grid-cell task-name" role="gridcell" style="padding-left:${10+r.depth*18}px">
|
|
667
678
|
${r.hasChildren?`<button class="expander" data-action="toggle" data-task-id="${b(r.id)}" aria-label="${this.collapsed.has(r.id)?"Expand":"Collapse"} ${b(r.label)}">${this.collapsed.has(r.id)?"›":"⌄"}</button>`:'<span style="inline-size:22px"></span>'}
|
|
668
679
|
<span class="name-text" title="${b(r.label)}">${b(r.label)}</span>
|
|
669
680
|
</div>
|
|
670
|
-
<div class="grid-cell badge" role="gridcell">${b(r.assignee||
|
|
681
|
+
<div class="grid-cell badge" role="gridcell">${b(r.assignee||D)}</div>
|
|
671
682
|
<div class="grid-cell badge" role="gridcell">${b(U)}</div>
|
|
672
683
|
<div class="grid-cell badge" role="gridcell">${b(G)}</div>
|
|
673
|
-
</
|
|
674
|
-
`}).join(""),$t=K.map((r,$)=>{const
|
|
675
|
-
<
|
|
676
|
-
${r.baselineStart&&r.baselineEnd?`<span class="baseline" style="left:${
|
|
684
|
+
</div>
|
|
685
|
+
`}).join(""),$t=K.map((r,$)=>{const C=L+$,v=H(r),D=this.selectedId===r.id?" selected":"",G=this.selectedId===r.id||!this.selectedId&&C===0,U=mt[r.tone||(v==="summary"?"info":"default")]||mt.default,rt=v==="milestone"?z(r.startMs)-N/2:z(r.startMs),zt=z(v==="milestone"?r.startMs:r.endMs),Ct=v==="milestone"?N:Math.max(12,zt-rt),Tt=Math.max(0,Math.min(100,Number(r.progress??0))),at=!p&&!r.readonly&&v!=="summary",nt=at&&v==="task",it=v==="task"&&r.segments?.length?r.segments.map(st=>{const ot=f(st.start),lt=f(st.end);if(ot==null||lt==null)return"";const dt=Math.max(I,r.endMs-r.startMs),Z=Math.max(r.startMs,ot),ct=Math.min(r.endMs,lt);if(ct<=Z)return"";const pt=Math.max(0,Math.min(100,(Z-r.startMs)/dt*100)),It=(ct-Z)/dt*100,ut=Math.min(100-pt,Math.max(1,It));return ut<=0?"":`<span class="split-segment" style="left:${pt.toFixed(2)}%;width:${ut.toFixed(2)}%"></span>`}).join(""):"";return`
|
|
686
|
+
<div class="timeline-row${D}" part="timeline-row" data-task-id="${b(r.id)}">
|
|
687
|
+
${r.baselineStart&&r.baselineEnd?`<span class="baseline" style="left:${z(f(r.baselineStart)||r.startMs).toFixed(2)}px;width:${Math.max(4,z(f(r.baselineEnd)||r.endMs)-z(f(r.baselineStart)||r.startMs)).toFixed(2)}px"></span>`:""}
|
|
677
688
|
<button
|
|
678
689
|
class="bar ${v}${r.critical?" critical":""}${it?" split":""}"
|
|
679
690
|
part="bar ${v}"
|
|
680
691
|
data-task-id="${b(r.id)}"
|
|
681
692
|
data-kind="${v}"
|
|
682
|
-
role="gridcell"
|
|
683
693
|
tabindex="${G?"0":"-1"}"
|
|
684
|
-
|
|
685
|
-
aria-colindex="5"
|
|
694
|
+
${this.selectedId===r.id?'aria-current="true"':""}
|
|
686
695
|
style="left:${rt.toFixed(2)}px;width:${Ct.toFixed(2)}px;--tone:${U};--progress:${Tt.toFixed(2)}%"
|
|
687
696
|
aria-label="${b(r.label)}"
|
|
688
697
|
${at?'data-draggable="true"':""}
|
|
@@ -694,8 +703,8 @@
|
|
|
694
703
|
<span class="drag-tip"></span>
|
|
695
704
|
${nt?'<span class="handle end" data-mode="resize-end"></span>':""}
|
|
696
705
|
</button>
|
|
697
|
-
</
|
|
698
|
-
`}).join(""),et=i.map(r=>{const $=Q.get(r.source),
|
|
706
|
+
</div>
|
|
707
|
+
`}).join(""),et=i.map(r=>{const $=Q.get(r.source),C=Q.get(r.target);if(!$||!C||S&&!tt.has(r.source)&&!tt.has(r.target))return"";const v=Wt($.task,$.index,C.task,C.index,r.type,z),D=`${$.task.label} dependency to ${C.task.label}`;return`<path class="link-hit" d="${v}" data-link-id="${b(r.id)}" data-source-id="${b(r.source)}" data-target-id="${b(r.target)}" data-link-type="${b(r.type||"e2s")}" aria-label="${b(D)}" /><path d="${v}" />`}).join(""),Mt=et?'<defs><marker id="ui-gantt-arrow" markerWidth="9" markerHeight="9" refX="8.5" refY="4.5" orient="auto" markerUnits="userSpaceOnUse"><path d="M 0.5 0.75 L 8.5 4.5 L 0.5 8.25 z" /></marker></defs>':"",Y=F(Date.now()),Et=z(Y),St=d&&Y>=m&&Y<=h?`<div class="today" part="today" style="left:${Et.toFixed(2)}px"></div>`:"";this.setContent(`
|
|
699
708
|
<style>${ht}</style>
|
|
700
709
|
<section class="frame" part="frame" data-bar-variant="${s}">
|
|
701
710
|
${u?`
|
|
@@ -712,28 +721,30 @@
|
|
|
712
721
|
`:""}
|
|
713
722
|
<div class="viewport" part="viewport">
|
|
714
723
|
<div class="surface" part="surface" style="--day-width:${M}px;grid-template-columns:${J}px ${k.toFixed(2)}px;inline-size:max(100%, ${(J+k).toFixed(2)}px)">
|
|
715
|
-
<
|
|
716
|
-
<
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
724
|
+
<div class="grid-semantics" role="treegrid" aria-label="${b(this.getAttribute("aria-label")||"Project schedule")}" aria-rowcount="${o.length+1}" aria-colcount="4">
|
|
725
|
+
<div class="grid-head" part="grid-head" role="row">
|
|
726
|
+
<div role="columnheader" aria-sort="${n==="label"?"ascending":"none"}" style="display:contents"><button class="head-button" data-sort="label">Task</button></div>
|
|
727
|
+
<span role="columnheader">Owner</span>
|
|
728
|
+
<div role="columnheader" aria-sort="${n==="start"?"ascending":"none"}" style="display:contents"><button class="head-button" data-sort="start">Dates</button></div>
|
|
729
|
+
<div role="columnheader" aria-sort="${n==="progress"?"descending":"none"}" style="display:contents"><button class="head-button" data-sort="progress">%</button></div>
|
|
730
|
+
</div>
|
|
731
|
+
<div class="grid-body" part="grid-body" role="rowgroup">
|
|
732
|
+
${S&&_?`<div style="height:${_}px"></div>`:""}
|
|
733
|
+
${kt||'<div class="empty">No matching tasks</div>'}
|
|
734
|
+
${S&&j?`<div style="height:${j}px"></div>`:""}
|
|
735
|
+
</div>
|
|
736
|
+
</div>
|
|
737
|
+
<div class="timeline-head" part="timeline-head" aria-hidden="true">
|
|
722
738
|
<div class="scale" style="width:${k.toFixed(2)}px">${Ht(m,h,M,e,this.viewportLeft,this.viewportWidth)}</div>
|
|
723
|
-
</header>
|
|
724
|
-
<div class="grid-body" part="grid-body" role="treegrid" aria-rowcount="${o.length+1}" aria-colcount="4">
|
|
725
|
-
${z&&_?`<div style="height:${_}px"></div>`:""}
|
|
726
|
-
${kt||'<div class="empty">No matching tasks</div>'}
|
|
727
|
-
${z&&V?`<div style="height:${V}px"></div>`:""}
|
|
728
739
|
</div>
|
|
729
|
-
<div class="timeline-body" part="timeline-body" style="width:${k.toFixed(2)}px;min-height:${A}px">
|
|
740
|
+
<div class="timeline-body" part="timeline-body" role="group" aria-label="Timeline" style="width:${k.toFixed(2)}px;min-height:${A}px">
|
|
730
741
|
<svg class="links" width="${k.toFixed(0)}" height="${A}" viewBox="0 0 ${k.toFixed(0)} ${A}" aria-hidden="true">${Mt}${et}</svg>
|
|
731
742
|
${St}
|
|
732
|
-
${
|
|
743
|
+
${S&&_?`<div style="height:${_}px"></div>`:""}
|
|
733
744
|
${$t}
|
|
734
|
-
${
|
|
745
|
+
${S&&j?`<div style="height:${j}px"></div>`:""}
|
|
735
746
|
</div>
|
|
736
747
|
</div>
|
|
737
748
|
</div>
|
|
738
749
|
</section>
|
|
739
|
-
`);const q=this.root.querySelector(".viewport");q&&(q.scrollTop=this.viewportTop,q.scrollLeft=this.viewportLeft,this.viewportWidth=q.clientWidth||this.viewportWidth,this.viewportHeight=q.clientHeight||this.viewportHeight),this.bindEvents()}bindEvents(){this.root.querySelectorAll("[data-task-id]").forEach(t=>{t.addEventListener("click",i=>{const e=i.target,n=i.currentTarget;if(!n.classList.contains("bar")&&e.closest(".bar"))return;if(this.drag?.moved){i.stopPropagation();return}const l=i.currentTarget.dataset.taskId;l&&(e.closest('[data-action="toggle"]')||(n.classList.contains("bar")&&i.stopPropagation(),this.selectTask(l)))})}),this.root.querySelectorAll('[data-action="toggle"]').forEach(t=>{t.addEventListener("click",i=>{i.stopPropagation();const e=t.dataset.taskId;e&&(this.collapsed.has(e)?this.collapsed.delete(e):this.collapsed.add(e),this.requestRender())})}),this.root.querySelectorAll("[data-zoom]").forEach(t=>{t.addEventListener("click",()=>{const i=t.dataset.zoom||"week";this.setAttribute("zoom",i),this.dispatchEvent(new CustomEvent("zoomchange",{detail:{zoom:i},bubbles:!0,composed:!0}))})}),this.root.querySelectorAll(".head-button[data-sort]").forEach(t=>{t.addEventListener("click",()=>{const i=
|
|
750
|
+
`);const q=this.root.querySelector(".viewport");q&&(q.scrollTop=this.viewportTop,q.scrollLeft=this.viewportLeft,this.viewportWidth=q.clientWidth||this.viewportWidth,this.viewportHeight=q.clientHeight||this.viewportHeight),this.bindEvents()}bindEvents(){this.root.querySelectorAll("[data-task-id]").forEach(t=>{t.addEventListener("click",i=>{const e=i.target,n=i.currentTarget;if(!n.classList.contains("bar")&&e.closest(".bar"))return;if(this.drag?.moved){i.stopPropagation();return}const l=i.currentTarget.dataset.taskId;l&&(e.closest('[data-action="toggle"]')||(n.classList.contains("bar")&&i.stopPropagation(),this.selectTask(l)))})}),this.root.querySelectorAll('[data-action="toggle"]').forEach(t=>{t.addEventListener("click",i=>{i.stopPropagation();const e=t.dataset.taskId;e&&(this.collapsed.has(e)?this.collapsed.delete(e):this.collapsed.add(e),this.requestRender())})}),this.root.querySelectorAll("[data-zoom]").forEach(t=>{t.addEventListener("click",()=>{const i=t.dataset.zoom||"week";this.setAttribute("zoom",i),this.dispatchEvent(new CustomEvent("zoomchange",{detail:{zoom:i},bubbles:!0,composed:!0}))})}),this.root.querySelectorAll(".head-button[data-sort]").forEach(t=>{t.addEventListener("click",()=>{const i=W(t.dataset.sort||null);i==="none"?this.removeAttribute("sort"):this.setAttribute("sort",i),this.dispatchEvent(new CustomEvent("sortchange",{detail:{sort:i},bubbles:!0,composed:!0}))})}),this.root.querySelector(".viewport")?.addEventListener("scroll",t=>{const i=t.currentTarget,e=i.scrollTop,n=i.scrollLeft,s=Math.max(20,Math.ceil(Math.max(420,this.viewportHeight-V)/y)),l=Math.max(0,Math.floor(Math.max(0,e-V)/y)),o=l<this.renderedFirstRow+64||l+s>this.renderedLastRow-64,p=Math.abs(n-this.viewportLeft)>=Math.max(480,this.viewportWidth*.6);this.viewportTop=e,this.viewportLeft=n,!(!o&&!p)&&this.scrollFrame==null&&(this.scrollFrame=window.setTimeout(()=>{this.scrollFrame=null,this.requestRender()},24))},{passive:!0}),this.root.querySelector(".control")?.addEventListener("input",t=>{this.internalFilter=t.currentTarget.value,this.dispatchEvent(new CustomEvent("filterchange",{detail:{filter:this.internalFilter},bubbles:!0,composed:!0})),this.requestRender()}),this.root.querySelector(".select")?.addEventListener("change",t=>{const i=W(t.currentTarget.value);i==="none"?this.removeAttribute("sort"):this.setAttribute("sort",i),this.dispatchEvent(new CustomEvent("sortchange",{detail:{sort:i},bubbles:!0,composed:!0}))}),this.root.querySelectorAll(".link-hit").forEach(t=>{t.addEventListener("click",i=>{i.stopPropagation(),this.dispatchEvent(new CustomEvent("linkselect",{detail:{id:t.dataset.linkId||"",source:t.dataset.sourceId||"",target:t.dataset.targetId||"",type:t.dataset.linkType||"e2s"},bubbles:!0,composed:!0}))})}),!this.hasAttribute("readonly")&&this.root.querySelectorAll('.bar[data-draggable="true"]').forEach(t=>{t.addEventListener("pointerdown",e=>{if(e.button!==0)return;const n=t.dataset.taskId;if(!n)return;const l=this.getTasks().find(h=>h.id===n),o=f(l?.start),p=f(l?.end);if(!l||o==null||p==null)return;e.preventDefault();const u=t.dataset.kind||"task",d=e.target.dataset.mode||"move",g=u==="milestone"?"move":d,c=bt(this.getAttribute("zoom")),m=this.selectedId!==n;this.selectedId=n,this.dispatchEvent(new CustomEvent("taskselect",{detail:{id:n},bubbles:!0,composed:!0})),this.drag={taskId:n,mode:g,startX:e.clientX,originalStart:o,originalEnd:p,kind:u,rangeMin:this.rangeMin(),dayWidth:gt[c],latestStart:o,latestEnd:p,frame:null,bar:t,moved:!1,selectedChanged:m},t.classList.add("dragging"),t.setPointerCapture(e.pointerId)}),t.addEventListener("pointermove",e=>{if(!this.drag||this.drag.taskId!==t.dataset.taskId)return;e.preventDefault();const n=e.clientX-this.drag.startX;Math.abs(n)>2&&(this.drag.moved=!0);let s=this.drag.originalStart,l=this.drag.originalEnd;if(this.drag.mode==="move"){const o=Math.round(n/this.drag.dayWidth);s=x(this.drag.originalStart,o),l=this.drag.kind==="milestone"?s:x(this.drag.originalEnd,o)}else if(this.drag.mode==="resize-start"){const o=Math.round(n/this.drag.dayWidth);s=Math.min(x(this.drag.originalStart,o),x(l,-1))}else{const o=Math.round(n/this.drag.dayWidth);l=Math.max(x(this.drag.originalEnd,o),x(s,1))}this.drag.latestStart=s,this.drag.latestEnd=l,this.drag.frame==null&&(this.drag.frame=requestAnimationFrame(()=>{if(!this.drag)return;this.drag.frame=null;const o=(this.drag.latestStart-this.drag.rangeMin)/I*this.drag.dayWidth-(this.drag.kind==="milestone"?N/2:0),p=this.drag.kind==="milestone"?N:Math.max(12,(this.drag.latestEnd-this.drag.latestStart)/I*this.drag.dayWidth);this.drag.bar.style.left=`${o.toFixed(2)}px`,this.drag.bar.style.width=`${p.toFixed(2)}px`;const u=this.drag.bar.querySelector(".drag-tip");u&&(u.textContent=this.drag.kind==="milestone"?E(this.drag.latestStart):`${E(this.drag.latestStart)} - ${E(this.drag.latestEnd)}`)}))});const i=()=>{if(!this.drag)return;this.drag.frame!=null&&cancelAnimationFrame(this.drag.frame);const e=this.drag;if(e.bar.classList.remove("dragging"),this.drag=null,!e.moved){e.selectedChanged&&this.requestRender();return}const n={id:e.taskId,start:E(e.latestStart),end:E(e.latestEnd)};this.overrides.set(e.taskId,{start:n.start,end:n.end}),this.bumpOverrides(),this.dispatchEvent(new CustomEvent("taskchange",{detail:n,bubbles:!0,composed:!0})),this.requestRender()};t.addEventListener("pointerup",i),t.addEventListener("pointercancel",i),t.addEventListener("keydown",e=>{const n=t.dataset.taskId;if(!n)return;if(e.key==="Delete"||e.key==="Backspace"){e.preventDefault(),this.dispatchEvent(new CustomEvent("taskdelete",{detail:{id:n},bubbles:!0,composed:!0}));return}if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.selectTask(n);return}if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.preventDefault(),this.selectAdjacentTask(n,e.key==="ArrowDown"?1:-1);return}if(e.key!=="ArrowLeft"&&e.key!=="ArrowRight")return;const l=this.getTasks().find(h=>h.id===n),o=f(l?.start),p=f(l?.end);if(!l||o==null||p==null)return;e.preventDefault();const u=e.key==="ArrowLeft"?-1:1,d=t.dataset.kind==="milestone",g=e.shiftKey&&!d?o:x(o,u),c=d?g:e.shiftKey?Math.max(x(p,u),x(o,1)):x(p,u),m={id:n,start:E(g),end:E(c)};this.overrides.set(n,{start:m.start,end:m.end}),this.bumpOverrides(),this.dispatchEvent(new CustomEvent("taskchange",{detail:m,bubbles:!0,composed:!0})),this.requestRender()})})}rangeMin(){const i=this.getTasks().map(e=>f(e.start)).filter(e=>e!=null);return i.length?x(Math.min(...i),-2):F(Date.now())}selectTask(t){if(this.captureViewport(),this.selectedId===t){this.dispatchEvent(new CustomEvent("taskselect",{detail:{id:t},bubbles:!0,composed:!0}));return}this.selectedId=t,this.dispatchEvent(new CustomEvent("taskselect",{detail:{id:t},bubbles:!0,composed:!0})),this.requestRender()}selectAdjacentTask(t,i){const e=this.getVisibleTasks(this.getTasks(),this.getAttribute("filter")??this.internalFilter,W(this.getAttribute("sort"))),n=e.findIndex(l=>l.id===t),s=e[Math.max(0,Math.min(e.length-1,n+i))];!s||s.id===t||(this.selectedId=s.id,this.dispatchEvent(new CustomEvent("taskselect",{detail:{id:s.id},bubbles:!0,composed:!0})),this.requestRender(),window.requestAnimationFrame(()=>{this.root.querySelector(`.bar[data-task-id="${CSS.escape(s.id)}"]`)?.focus()}))}captureViewport(){const t=this.root.querySelector(".viewport");t&&(this.viewportTop=t.scrollTop,this.viewportLeft=t.scrollLeft,this.viewportWidth=t.clientWidth||this.viewportWidth,this.viewportHeight=t.clientHeight||this.viewportHeight)}getTasks(){const t=this.getAttribute("tasks");return t===this.taskCacheRaw&&this.taskCacheVersion===this.overridesVersion?this.taskCache:(this.taskCacheRaw=t,this.taskCacheVersion=this.overridesVersion,this.taskCache=Ft(t,this.overrides),this.visibleCacheKey="",this.taskCache)}getLinks(){const t=this.getAttribute("links");return t===this.linkCacheRaw?this.linkCache:(this.linkCacheRaw=t,this.linkCache=Rt(t),this.linkCache)}getVisibleTasks(t,i,e){const n=Array.from(this.collapsed).sort().join(","),s=`${this.taskCacheRaw||""}|${this.overridesVersion}|${i}|${e}|${n}`;return s===this.visibleCacheKey?this.visibleCache:(this.visibleCacheKey=s,this.visibleCache=Nt(t,this.collapsed,i,e),this.visibleCache)}bumpOverrides(){this.overridesVersion+=1,this.taskCacheVersion=-1,this.visibleCacheKey=""}shouldRenderOnAttributeChange(t,i,e){return t==="tasks"&&(this.overrides.clear(),this.bumpOverrides(),this.viewportTop=0,this.viewportLeft=0),t==="links"&&(this.linkCacheRaw=null),!0}}typeof customElements<"u"&&!customElements.get("ui-gantt")&&customElements.define("ui-gantt",wt);exports.UIGantt=wt;
|