stimeo-ui 0.18.2 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -0
- data/dist/controllers/alert_dialog_controller.js +246 -42
- data/dist/controllers/auto_submit_controller.js +26 -5
- data/dist/controllers/avatar_controller.js +29 -9
- data/dist/controllers/breadcrumb_controller.js +205 -17
- data/dist/controllers/bulk_select_controller.js +25 -4
- data/dist/controllers/calendar_controller.js +242 -7
- data/dist/controllers/carousel_controller.js +70 -15
- data/dist/controllers/character_counter_controller.js +26 -5
- data/dist/controllers/collapsible_controller.js +35 -8
- data/dist/controllers/combobox_controller.js +84 -20
- data/dist/controllers/command_palette_controller.js +296 -77
- data/dist/controllers/confirm_controller.js +225 -34
- data/dist/controllers/context_menu_controller.js +58 -29
- data/dist/controllers/currency_input_controller.js +1 -1
- data/dist/controllers/data_grid_controller.js +196 -9
- data/dist/controllers/date_range_picker_controller.js +25 -4
- data/dist/controllers/dialog_controller.js +252 -45
- data/dist/controllers/dismissible_controller.js +57 -11
- data/dist/controllers/drawer_controller.js +284 -58
- data/dist/controllers/dropdown_controller.js +63 -51
- data/dist/controllers/editable_controller.js +69 -6
- data/dist/controllers/empty_state_controller.js +187 -4
- data/dist/controllers/file_dropzone_controller.js +300 -12
- data/dist/controllers/filter_controller.js +194 -5
- data/dist/controllers/flash_controller.js +199 -12
- data/dist/controllers/focus_controller.js +195 -23
- data/dist/controllers/form_field_controller.js +65 -9
- data/dist/controllers/frame_loading_controller.js +25 -4
- data/dist/controllers/hover_card_controller.js +107 -38
- data/dist/controllers/input_mask_controller.js +1 -1
- data/dist/controllers/listbox_controller.js +94 -36
- data/dist/controllers/menu_controller.js +44 -23
- data/dist/controllers/menubar_controller.js +228 -46
- data/dist/controllers/meter_controller.js +25 -4
- data/dist/controllers/multi_select_controller.js +110 -42
- data/dist/controllers/nested_form_controller.js +258 -9
- data/dist/controllers/network_status_controller.js +25 -4
- data/dist/controllers/number_input_controller.js +26 -5
- data/dist/controllers/otp_controller.js +26 -5
- data/dist/controllers/overflow_menu_controller.js +183 -22
- data/dist/controllers/pagination_controller.js +179 -22
- data/dist/controllers/password_reveal_controller.js +25 -4
- data/dist/controllers/popover_controller.js +454 -34
- data/dist/controllers/progress_controller.js +25 -4
- data/dist/controllers/radio_group_controller.js +195 -40
- data/dist/controllers/rating_controller.js +58 -10
- data/dist/controllers/read_more_controller.js +191 -25
- data/dist/controllers/roving_controller.js +197 -6
- data/dist/controllers/scroll_area_controller.js +50 -12
- data/dist/controllers/scroll_visibility_controller.js +25 -4
- data/dist/controllers/scrollspy_controller.js +179 -3
- data/dist/controllers/separator_controller.js +25 -4
- data/dist/controllers/sidebar_controller.js +290 -93
- data/dist/controllers/skeleton_controller.js +25 -4
- data/dist/controllers/spinner_controller.js +25 -4
- data/dist/controllers/step_indicator_controller.js +181 -6
- data/dist/controllers/stepper_controller.js +188 -6
- data/dist/controllers/sticky_observer_controller.js +25 -4
- data/dist/controllers/submit_once_controller.js +25 -4
- data/dist/controllers/tabs_controller.js +189 -3
- data/dist/controllers/tags_input_controller.js +210 -9
- data/dist/controllers/theme_controller.js +192 -5
- data/dist/controllers/toast_controller.js +478 -16
- data/dist/controllers/toggle_group_controller.js +198 -35
- data/dist/controllers/toolbar_controller.js +198 -7
- data/dist/controllers/tooltip_controller.js +243 -45
- data/dist/controllers/tree_view_controller.js +200 -8
- data/dist/index.js +1764 -739
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +2 -2
|
@@ -44,6 +44,172 @@ function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
|
44
44
|
return true;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
function sharedRegistry(key, create) {
|
|
48
|
+
const symbol = Symbol.for(key);
|
|
49
|
+
const scope = globalThis;
|
|
50
|
+
const existing = scope[symbol];
|
|
51
|
+
if (existing !== void 0) return existing;
|
|
52
|
+
const registry2 = create();
|
|
53
|
+
Object.defineProperty(globalThis, symbol, { value: registry2 });
|
|
54
|
+
return registry2;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var registry = sharedRegistry(
|
|
58
|
+
"stimeo-ui.attribute-lease.registry.v1",
|
|
59
|
+
() => ({ stacks: /* @__PURE__ */ new WeakMap(), names: /* @__PURE__ */ new Map() })
|
|
60
|
+
);
|
|
61
|
+
function isAttributeValue(value) {
|
|
62
|
+
return value === null || typeof value === "string";
|
|
63
|
+
}
|
|
64
|
+
function readLeaseRecord(element, record) {
|
|
65
|
+
try {
|
|
66
|
+
const parsed = JSON.parse(element.getAttribute(record) ?? "null");
|
|
67
|
+
if (!Array.isArray(parsed)) return void 0;
|
|
68
|
+
const [original, written, ...rest] = parsed;
|
|
69
|
+
const linked = rest[0] !== false;
|
|
70
|
+
const beneath = linked ? rest : rest.slice(1);
|
|
71
|
+
if (!beneath.every((under) => typeof under === "string")) return void 0;
|
|
72
|
+
return isAttributeValue(original) && isAttributeValue(written) ? { original, written, linked, beneath } : void 0;
|
|
73
|
+
} catch {
|
|
74
|
+
return void 0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function attributeStack(element, attribute) {
|
|
78
|
+
const byAttribute = registry.stacks.get(element) ?? /* @__PURE__ */ new Map();
|
|
79
|
+
registry.stacks.set(element, byAttribute);
|
|
80
|
+
const known = byAttribute.get(attribute);
|
|
81
|
+
if (known) return known;
|
|
82
|
+
const found = [];
|
|
83
|
+
for (const record of registry.names.get(attribute) ?? []) {
|
|
84
|
+
const read = readLeaseRecord(element, record);
|
|
85
|
+
if (read) found.push({ ...read, record });
|
|
86
|
+
}
|
|
87
|
+
const depth = ({ beneath }) => beneath.filter((name) => found.some((other) => other.record === name)).length;
|
|
88
|
+
const stack = found.sort((one, other) => depth(one) - depth(other)).map(({ record, written, original, linked }, index) => ({
|
|
89
|
+
lease: null,
|
|
90
|
+
record,
|
|
91
|
+
written,
|
|
92
|
+
original,
|
|
93
|
+
linked: linked && index > 0
|
|
94
|
+
}));
|
|
95
|
+
byAttribute.set(attribute, stack);
|
|
96
|
+
return stack;
|
|
97
|
+
}
|
|
98
|
+
function findHold(stack, lease, record) {
|
|
99
|
+
return stack.find((held) => held.lease === lease) ?? stack.find((held) => held.lease === null && held.record === record);
|
|
100
|
+
}
|
|
101
|
+
var AttributeLease = class {
|
|
102
|
+
#attribute;
|
|
103
|
+
#record;
|
|
104
|
+
#base;
|
|
105
|
+
#preserveAuthor;
|
|
106
|
+
#held = /* @__PURE__ */ new Set();
|
|
107
|
+
constructor(attribute, owner, options = {}) {
|
|
108
|
+
this.#attribute = attribute;
|
|
109
|
+
this.#record = `data-${owner}-${attribute}-lease`;
|
|
110
|
+
this.#base = options.base === true;
|
|
111
|
+
this.#preserveAuthor = options.preserveAuthor === true;
|
|
112
|
+
const names = registry.names;
|
|
113
|
+
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
114
|
+
}
|
|
115
|
+
write(element, value, beforeWrite) {
|
|
116
|
+
const stack = attributeStack(element, this.#attribute);
|
|
117
|
+
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
118
|
+
this.#held.add(element);
|
|
119
|
+
const shows = !this.#covered(element, stack, hold);
|
|
120
|
+
hold.written = value;
|
|
121
|
+
this.#mark(element, stack);
|
|
122
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
123
|
+
}
|
|
124
|
+
adopt(element, options = {}) {
|
|
125
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
126
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
127
|
+
const stack = attributeStack(element, this.#attribute);
|
|
128
|
+
const hold = this.#take(stack);
|
|
129
|
+
if (!hold) return false;
|
|
130
|
+
const current = element.getAttribute(this.#attribute);
|
|
131
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
this.#held.add(element);
|
|
135
|
+
hold.original = current;
|
|
136
|
+
hold.linked = false;
|
|
137
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
138
|
+
if (!above.linked) break;
|
|
139
|
+
above.original = current;
|
|
140
|
+
}
|
|
141
|
+
this.#mark(element, stack);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
return(element) {
|
|
145
|
+
const held = this.#held.delete(element);
|
|
146
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
147
|
+
const stack = held || known || element.hasAttribute(this.#record) ? attributeStack(element, this.#attribute) : [];
|
|
148
|
+
const hold = this.#take(stack);
|
|
149
|
+
if (!hold) return false;
|
|
150
|
+
const carries = element.getAttribute(this.#attribute) === hold.written;
|
|
151
|
+
const owns = carries && !this.#covered(element, stack, hold);
|
|
152
|
+
const index = stack.indexOf(hold);
|
|
153
|
+
stack.splice(index, 1);
|
|
154
|
+
const above = stack[index];
|
|
155
|
+
if (above) above.linked &&= hold.linked;
|
|
156
|
+
this.#mark(element, stack);
|
|
157
|
+
if (!owns) return true;
|
|
158
|
+
const below = hold.linked ? stack[index - 1] : void 0;
|
|
159
|
+
this.#reflect(element, below ? below.written : hold.original);
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
returnAll() {
|
|
163
|
+
for (const element of Array.from(this.#held)) this.return(element);
|
|
164
|
+
}
|
|
165
|
+
#take(stack) {
|
|
166
|
+
const hold = findHold(stack, this, this.#record);
|
|
167
|
+
if (hold) hold.lease = this;
|
|
168
|
+
return hold;
|
|
169
|
+
}
|
|
170
|
+
#acquire(element, stack) {
|
|
171
|
+
const current = element.getAttribute(this.#attribute);
|
|
172
|
+
const top = stack.at(-1);
|
|
173
|
+
const bottom = stack[0];
|
|
174
|
+
const over = top?.written === current ? top : void 0;
|
|
175
|
+
const from = this.#base ? this.#preserveAuthor && !stack.some((held) => held.written === current) ? void 0 : bottom : over;
|
|
176
|
+
const hold = {
|
|
177
|
+
lease: this,
|
|
178
|
+
record: this.#record,
|
|
179
|
+
written: current,
|
|
180
|
+
original: from ? from.original : current,
|
|
181
|
+
linked: !this.#base && over !== void 0
|
|
182
|
+
};
|
|
183
|
+
if (this.#base && bottom) {
|
|
184
|
+
bottom.linked = true;
|
|
185
|
+
stack.unshift(hold);
|
|
186
|
+
} else stack.push(hold);
|
|
187
|
+
return hold;
|
|
188
|
+
}
|
|
189
|
+
#covered(element, stack, hold) {
|
|
190
|
+
const current = element.getAttribute(this.#attribute);
|
|
191
|
+
return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current);
|
|
192
|
+
}
|
|
193
|
+
#mark(element, stack) {
|
|
194
|
+
const records = /* @__PURE__ */ new Map([[this.#record, null]]);
|
|
195
|
+
stack.forEach((hold, index) => {
|
|
196
|
+
const names = stack.slice(0, index).map((under) => under.record);
|
|
197
|
+
const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);
|
|
198
|
+
const marker = hold.linked || beneath.length === 0 ? [] : [false];
|
|
199
|
+
records.set(
|
|
200
|
+
hold.record,
|
|
201
|
+
hold.written === hold.original && beneath.length === 0 && index === stack.length - 1 ? null : JSON.stringify([hold.original, hold.written, ...marker, ...beneath])
|
|
202
|
+
);
|
|
203
|
+
});
|
|
204
|
+
for (const [name, recorded] of records) {
|
|
205
|
+
setAttributeIfChanged(element, name, recorded);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
#reflect(element, value, beforeWrite) {
|
|
209
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
|
|
47
213
|
var AuthoredMutationWatcher = class {
|
|
48
214
|
#onAuthored;
|
|
49
215
|
#lifetime = null;
|
|
@@ -318,6 +484,13 @@ var DataGridController = class extends Controller {
|
|
|
318
484
|
};
|
|
319
485
|
static actions = ["onKeydown", "sort", "toggleSelect"];
|
|
320
486
|
static events = ["selectionchange", "sort", "reconcile"];
|
|
487
|
+
#selected = new AttributeLease("aria-selected", this.identifier);
|
|
488
|
+
#tabindex = new AttributeLease("tabindex", this.identifier);
|
|
489
|
+
#sort = new AttributeLease("aria-sort", this.identifier);
|
|
490
|
+
#multiselectable = new AttributeLease(
|
|
491
|
+
"aria-multiselectable",
|
|
492
|
+
this.identifier
|
|
493
|
+
);
|
|
321
494
|
#reconcile = new MorphRenderWatcher(() => this.#reconcileRows());
|
|
322
495
|
#observer = new AuthoredMutationWatcher((records) => {
|
|
323
496
|
if (this.#concernsRows(records)) this.#reconcile.schedule();
|
|
@@ -333,6 +506,7 @@ var DataGridController = class extends Controller {
|
|
|
333
506
|
this.#connectionGeneration += 1;
|
|
334
507
|
this.#reconcile.disconnect();
|
|
335
508
|
this.#observer.disconnect();
|
|
509
|
+
if (!this.scope.containsElement(this.element)) this.#multiselectable.return(this.element);
|
|
336
510
|
}
|
|
337
511
|
#restoreBaseline() {
|
|
338
512
|
const cells = this.#navigableCells();
|
|
@@ -374,21 +548,34 @@ var DataGridController = class extends Controller {
|
|
|
374
548
|
rowTargetConnected() {
|
|
375
549
|
this.#reconcile.schedule();
|
|
376
550
|
}
|
|
377
|
-
rowTargetDisconnected() {
|
|
551
|
+
rowTargetDisconnected(row) {
|
|
552
|
+
if (!this.scope.containsElement(row) || !this.rowTargets.includes(row)) {
|
|
553
|
+
this.#selected.return(row);
|
|
554
|
+
}
|
|
378
555
|
this.#reconcile.schedule();
|
|
379
556
|
}
|
|
380
557
|
cellTargetConnected() {
|
|
381
558
|
this.#reconcile.schedule();
|
|
382
559
|
}
|
|
383
|
-
cellTargetDisconnected() {
|
|
560
|
+
cellTargetDisconnected(cell) {
|
|
561
|
+
this.#returnTabindex(cell);
|
|
384
562
|
this.#reconcile.schedule();
|
|
385
563
|
}
|
|
386
564
|
columnHeaderTargetConnected() {
|
|
387
565
|
this.#reconcile.schedule();
|
|
388
566
|
}
|
|
389
|
-
columnHeaderTargetDisconnected() {
|
|
567
|
+
columnHeaderTargetDisconnected(header) {
|
|
568
|
+
if (!this.scope.containsElement(header) || !this.columnHeaderTargets.includes(header)) {
|
|
569
|
+
this.#sort.return(header);
|
|
570
|
+
}
|
|
571
|
+
this.#returnTabindex(header);
|
|
390
572
|
this.#reconcile.schedule();
|
|
391
573
|
}
|
|
574
|
+
#returnTabindex(cell) {
|
|
575
|
+
if (this.scope.containsElement(cell) && (this.cellTargets.includes(cell) || this.columnHeaderTargets.includes(cell)))
|
|
576
|
+
return;
|
|
577
|
+
this.#tabindex.return(cell);
|
|
578
|
+
}
|
|
392
579
|
#normalizeSelection() {
|
|
393
580
|
const rows = this.rowTargets;
|
|
394
581
|
if (this.selectionValue === "none") {
|
|
@@ -407,9 +594,9 @@ var DataGridController = class extends Controller {
|
|
|
407
594
|
}
|
|
408
595
|
#syncSelectable() {
|
|
409
596
|
if (this.selectionValue === "multiple") {
|
|
410
|
-
|
|
597
|
+
this.#multiselectable.write(this.element, "true");
|
|
411
598
|
} else {
|
|
412
|
-
this.element
|
|
599
|
+
this.#multiselectable.write(this.element, null);
|
|
413
600
|
}
|
|
414
601
|
}
|
|
415
602
|
sort(source) {
|
|
@@ -423,7 +610,7 @@ var DataGridController = class extends Controller {
|
|
|
423
610
|
if (control && !(control instanceof HTMLButtonElement)) return;
|
|
424
611
|
const direction = nextSortDirection(header.getAttribute("aria-sort") ?? "none");
|
|
425
612
|
for (const other of this.columnHeaderTargets) {
|
|
426
|
-
|
|
613
|
+
this.#sort.write(other, other === header ? direction : "none");
|
|
427
614
|
}
|
|
428
615
|
this.#setActiveCell(header, { focus: false });
|
|
429
616
|
this.dispatch("sort", { detail: { column: header, direction, reason } });
|
|
@@ -506,7 +693,7 @@ var DataGridController = class extends Controller {
|
|
|
506
693
|
#cycleSort(header) {
|
|
507
694
|
const direction = nextSortDirection(header.getAttribute("aria-sort") ?? "none");
|
|
508
695
|
for (const other of this.columnHeaderTargets) {
|
|
509
|
-
|
|
696
|
+
this.#sort.write(other, other === header ? direction : "none");
|
|
510
697
|
}
|
|
511
698
|
this.dispatch("sort", { detail: { column: header, direction, reason: "user" } });
|
|
512
699
|
}
|
|
@@ -568,7 +755,7 @@ var DataGridController = class extends Controller {
|
|
|
568
755
|
this.#stopHolder = cell;
|
|
569
756
|
for (const candidate of cells ?? this.#navigableCells()) {
|
|
570
757
|
const wanted = candidate === cell ? "0" : "-1";
|
|
571
|
-
|
|
758
|
+
this.#tabindex.write(candidate, wanted);
|
|
572
759
|
}
|
|
573
760
|
if (focus) cell.focus();
|
|
574
761
|
}
|
|
@@ -597,7 +784,7 @@ var DataGridController = class extends Controller {
|
|
|
597
784
|
return cells[Math.min(col, cells.length - 1)];
|
|
598
785
|
}
|
|
599
786
|
#writeSelection(target, value) {
|
|
600
|
-
|
|
787
|
+
this.#selected.write(target, value, () => {
|
|
601
788
|
this.#observer.claim(target, "aria-selected", value);
|
|
602
789
|
});
|
|
603
790
|
}
|
|
@@ -45,6 +45,7 @@ function hasModifierChord(event) {
|
|
|
45
45
|
|
|
46
46
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
47
47
|
if (element.getAttribute(name) === value) return false;
|
|
48
|
+
beforeWrite?.();
|
|
48
49
|
if (value === null) element.removeAttribute(name);
|
|
49
50
|
else element.setAttribute(name, value);
|
|
50
51
|
return true;
|
|
@@ -118,14 +119,34 @@ var AttributeLease = class {
|
|
|
118
119
|
const names = registry.names;
|
|
119
120
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
120
121
|
}
|
|
121
|
-
write(element, value) {
|
|
122
|
+
write(element, value, beforeWrite) {
|
|
122
123
|
const stack = attributeStack(element, this.#attribute);
|
|
123
124
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
124
125
|
this.#held.add(element);
|
|
125
126
|
const shows = !this.#covered(element, stack, hold);
|
|
126
127
|
hold.written = value;
|
|
127
128
|
this.#mark(element, stack);
|
|
128
|
-
if (shows) this.#reflect(element, value);
|
|
129
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
130
|
+
}
|
|
131
|
+
adopt(element, options = {}) {
|
|
132
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
133
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
134
|
+
const stack = attributeStack(element, this.#attribute);
|
|
135
|
+
const hold = this.#take(stack);
|
|
136
|
+
if (!hold) return false;
|
|
137
|
+
const current = element.getAttribute(this.#attribute);
|
|
138
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
this.#held.add(element);
|
|
142
|
+
hold.original = current;
|
|
143
|
+
hold.linked = false;
|
|
144
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
145
|
+
if (!above.linked) break;
|
|
146
|
+
above.original = current;
|
|
147
|
+
}
|
|
148
|
+
this.#mark(element, stack);
|
|
149
|
+
return true;
|
|
129
150
|
}
|
|
130
151
|
return(element) {
|
|
131
152
|
const held = this.#held.delete(element);
|
|
@@ -191,8 +212,8 @@ var AttributeLease = class {
|
|
|
191
212
|
setAttributeIfChanged(element, name, recorded);
|
|
192
213
|
}
|
|
193
214
|
}
|
|
194
|
-
#reflect(element, value) {
|
|
195
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
215
|
+
#reflect(element, value, beforeWrite) {
|
|
216
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
196
217
|
}
|
|
197
218
|
};
|
|
198
219
|
|