@codbex/harmonia 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/harmonia.css +1 -1
- package/dist/harmonia.esm.js +567 -270
- package/dist/harmonia.esm.min.js +3 -3
- package/dist/harmonia.esm.min.js.map +4 -4
- package/dist/harmonia.js +565 -271
- package/dist/harmonia.min.js +2 -2
- package/dist/harmonia.min.js.map +4 -4
- package/package.json +1 -1
package/dist/harmonia.js
CHANGED
|
@@ -137,14 +137,14 @@
|
|
|
137
137
|
// src/components/accordion.js
|
|
138
138
|
function accordion_default(Alpine) {
|
|
139
139
|
Alpine.directive("h-accordion", (el, { expression, modifiers }, { Alpine: Alpine2 }) => {
|
|
140
|
-
el.
|
|
140
|
+
el._h_accordion = modifiers.includes("single") ? Alpine2.reactive({
|
|
141
141
|
single: true,
|
|
142
142
|
expandedId: expression ?? ""
|
|
143
143
|
}) : { single: false };
|
|
144
144
|
el.setAttribute("data-slot", "accordion");
|
|
145
145
|
});
|
|
146
146
|
Alpine.directive("h-accordion-item", (el, { expression, modifiers }, { effect, Alpine: Alpine2 }) => {
|
|
147
|
-
const accordion = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
147
|
+
const accordion = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_accordion"));
|
|
148
148
|
if (!accordion) {
|
|
149
149
|
throw new Error("h-accordion-item must be inside an h-accordion");
|
|
150
150
|
}
|
|
@@ -152,24 +152,24 @@
|
|
|
152
152
|
el.setAttribute("data-slot", "accordion-item");
|
|
153
153
|
const itemId = expression ?? `ha${v4_default()}`;
|
|
154
154
|
function getIsExpanded() {
|
|
155
|
-
if (accordion.
|
|
156
|
-
if (accordion.
|
|
157
|
-
return accordion.
|
|
155
|
+
if (accordion._h_accordion.single) {
|
|
156
|
+
if (accordion._h_accordion.expandedId !== "") {
|
|
157
|
+
return accordion._h_accordion.expandedId === itemId;
|
|
158
158
|
} else if (modifiers.includes("default")) {
|
|
159
|
-
accordion.
|
|
159
|
+
accordion._h_accordion.expandedId = itemId;
|
|
160
160
|
return true;
|
|
161
161
|
}
|
|
162
162
|
return false;
|
|
163
163
|
}
|
|
164
164
|
return modifiers.includes("default");
|
|
165
165
|
}
|
|
166
|
-
el.
|
|
166
|
+
el._h_accordionItem = Alpine2.reactive({
|
|
167
167
|
id: itemId,
|
|
168
168
|
controls: `ha${v4_default()}`,
|
|
169
169
|
expanded: getIsExpanded()
|
|
170
170
|
});
|
|
171
171
|
const setAttributes = () => {
|
|
172
|
-
el.setAttribute("data-state", el.
|
|
172
|
+
el.setAttribute("data-state", el._h_accordionItem.expanded ? "open" : "closed");
|
|
173
173
|
};
|
|
174
174
|
setAttributes();
|
|
175
175
|
effect(setAttributes);
|
|
@@ -178,8 +178,8 @@
|
|
|
178
178
|
if (el.tagName.length !== 2 && !el.tagName.startsWith("H")) {
|
|
179
179
|
throw new Error("h-accordion-trigger must be a header element");
|
|
180
180
|
}
|
|
181
|
-
const accordion = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
182
|
-
const accordionItem = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
181
|
+
const accordion = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_accordion"));
|
|
182
|
+
const accordionItem = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_accordionItem"));
|
|
183
183
|
if (!accordionItem || !accordion) {
|
|
184
184
|
throw new Error("h-accordion-trigger must be inside an h-accordion-item, which must be inside an h-accordion");
|
|
185
185
|
}
|
|
@@ -234,17 +234,17 @@
|
|
|
234
234
|
button.appendChild(chevronDown);
|
|
235
235
|
});
|
|
236
236
|
});
|
|
237
|
-
button.setAttribute("id", accordionItem.
|
|
238
|
-
button.setAttribute("aria-controls", accordionItem.
|
|
237
|
+
button.setAttribute("id", accordionItem._h_accordionItem.id);
|
|
238
|
+
button.setAttribute("aria-controls", accordionItem._h_accordionItem.controls);
|
|
239
239
|
const setAttributes = () => {
|
|
240
|
-
button.setAttribute("data-state", accordionItem.
|
|
241
|
-
button.setAttribute("aria-expanded", accordionItem.
|
|
240
|
+
button.setAttribute("data-state", accordionItem._h_accordionItem.expanded ? "open" : "closed");
|
|
241
|
+
button.setAttribute("aria-expanded", accordionItem._h_accordionItem.expanded);
|
|
242
242
|
};
|
|
243
243
|
const handler2 = () => {
|
|
244
|
-
accordionItem.
|
|
244
|
+
accordionItem._h_accordionItem.expanded = !accordionItem._h_accordionItem.expanded;
|
|
245
245
|
setAttributes();
|
|
246
|
-
if (accordion.
|
|
247
|
-
accordion.
|
|
246
|
+
if (accordion._h_accordion.single) {
|
|
247
|
+
accordion._h_accordion.expandedId = accordionItem._h_accordionItem.id;
|
|
248
248
|
}
|
|
249
249
|
};
|
|
250
250
|
setAttributes();
|
|
@@ -252,10 +252,10 @@
|
|
|
252
252
|
cleanup(() => {
|
|
253
253
|
el.removeEventListener("click", handler2);
|
|
254
254
|
});
|
|
255
|
-
if (accordion.
|
|
255
|
+
if (accordion._h_accordion.single) {
|
|
256
256
|
effect(() => {
|
|
257
|
-
if (accordion.
|
|
258
|
-
accordionItem.
|
|
257
|
+
if (accordion._h_accordion.expandedId !== accordionItem._h_accordionItem.id) {
|
|
258
|
+
accordionItem._h_accordionItem.expanded = false;
|
|
259
259
|
setAttributes();
|
|
260
260
|
}
|
|
261
261
|
});
|
|
@@ -264,13 +264,13 @@
|
|
|
264
264
|
Alpine.directive("h-accordion-content", (el, {}, { effect, Alpine: Alpine2 }) => {
|
|
265
265
|
el.classList.add("pt-0", "pb-4", "overflow-hidden", "text-sm", "data-[state=closed]:hidden");
|
|
266
266
|
el.setAttribute("data-slot", "accordion-content");
|
|
267
|
-
const parent = Alpine2.findClosest(el.parentElement, (parent2) => parent2.hasOwnProperty("
|
|
267
|
+
const parent = Alpine2.findClosest(el.parentElement, (parent2) => parent2.hasOwnProperty("_h_accordionItem"));
|
|
268
268
|
if (parent) {
|
|
269
|
-
el.setAttribute("id", parent.
|
|
270
|
-
el.setAttribute("aria-labelledby", parent.
|
|
271
|
-
el.setAttribute("data-state", parent.
|
|
269
|
+
el.setAttribute("id", parent._h_accordionItem.controls);
|
|
270
|
+
el.setAttribute("aria-labelledby", parent._h_accordionItem.id);
|
|
271
|
+
el.setAttribute("data-state", parent._h_accordionItem.expanded ? "open" : "closed");
|
|
272
272
|
effect(() => {
|
|
273
|
-
el.setAttribute("data-state", parent.
|
|
273
|
+
el.setAttribute("data-state", parent._h_accordionItem.expanded ? "open" : "closed");
|
|
274
274
|
});
|
|
275
275
|
}
|
|
276
276
|
});
|
|
@@ -360,7 +360,7 @@
|
|
|
360
360
|
"[&>svg]:size-5"
|
|
361
361
|
);
|
|
362
362
|
el.setAttribute("data-slot", "avatar");
|
|
363
|
-
el.
|
|
363
|
+
el._h_avatar = Alpine2.reactive({
|
|
364
364
|
fallback: false
|
|
365
365
|
});
|
|
366
366
|
if (el.tagName === "BUTTON") {
|
|
@@ -368,7 +368,7 @@
|
|
|
368
368
|
}
|
|
369
369
|
});
|
|
370
370
|
Alpine.directive("h-avatar-image", (el, {}, { cleanup }) => {
|
|
371
|
-
const avatar = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
371
|
+
const avatar = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_avatar"));
|
|
372
372
|
if (!avatar) {
|
|
373
373
|
throw new Error("h-avatar-image must be inside an h-avatar element");
|
|
374
374
|
}
|
|
@@ -379,7 +379,7 @@
|
|
|
379
379
|
function fallback(active = false) {
|
|
380
380
|
if (active) el.classList.add("hidden");
|
|
381
381
|
else el.classList.remove("hidden");
|
|
382
|
-
avatar.
|
|
382
|
+
avatar._h_avatar.fallback = active;
|
|
383
383
|
}
|
|
384
384
|
function completeCheck() {
|
|
385
385
|
if (el.complete) {
|
|
@@ -404,14 +404,14 @@
|
|
|
404
404
|
});
|
|
405
405
|
});
|
|
406
406
|
Alpine.directive("h-avatar-fallback", (el, {}, { effect }) => {
|
|
407
|
-
const avatar = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
407
|
+
const avatar = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_avatar"));
|
|
408
408
|
if (!avatar) {
|
|
409
409
|
throw new Error("h-avatar-fallback must be inside an h-avatar element");
|
|
410
410
|
}
|
|
411
411
|
el.classList.add("hidden", "bg-muted", "flex", "size-full", "items-center", "justify-center");
|
|
412
412
|
el.setAttribute("data-slot", "avatar-fallback");
|
|
413
413
|
effect(() => {
|
|
414
|
-
if (avatar.
|
|
414
|
+
if (avatar._h_avatar.fallback) el.classList.remove("hidden");
|
|
415
415
|
else el.classList.add("hidden");
|
|
416
416
|
});
|
|
417
417
|
});
|
|
@@ -425,7 +425,7 @@
|
|
|
425
425
|
"inline-flex",
|
|
426
426
|
"items-center",
|
|
427
427
|
"justify-center",
|
|
428
|
-
"rounded-
|
|
428
|
+
"rounded-full",
|
|
429
429
|
"border",
|
|
430
430
|
"px-2",
|
|
431
431
|
"py-0.5",
|
|
@@ -477,7 +477,7 @@
|
|
|
477
477
|
default: [
|
|
478
478
|
"bg-secondary",
|
|
479
479
|
"text-secondary-foreground",
|
|
480
|
-
"shadow-
|
|
480
|
+
"shadow-button",
|
|
481
481
|
"hover:bg-secondary-hover",
|
|
482
482
|
"active:bg-secondary-active",
|
|
483
483
|
"aria-pressed:bg-secondary-active",
|
|
@@ -488,7 +488,7 @@
|
|
|
488
488
|
primary: [
|
|
489
489
|
"bg-primary",
|
|
490
490
|
"text-primary-foreground",
|
|
491
|
-
"shadow-
|
|
491
|
+
"shadow-button",
|
|
492
492
|
"hover:bg-primary-hover",
|
|
493
493
|
"active:bg-primary-active",
|
|
494
494
|
"aria-pressed:bg-primary-active",
|
|
@@ -499,7 +499,7 @@
|
|
|
499
499
|
positive: [
|
|
500
500
|
"bg-positive",
|
|
501
501
|
"text-positive-foreground",
|
|
502
|
-
"shadow-
|
|
502
|
+
"shadow-button",
|
|
503
503
|
"hover:bg-positive-hover",
|
|
504
504
|
"active:bg-positive-active",
|
|
505
505
|
"aria-pressed:bg-positive-active",
|
|
@@ -510,7 +510,7 @@
|
|
|
510
510
|
negative: [
|
|
511
511
|
"bg-negative",
|
|
512
512
|
"text-negative-foreground",
|
|
513
|
-
"shadow-
|
|
513
|
+
"shadow-button",
|
|
514
514
|
"hover:bg-negative-hover",
|
|
515
515
|
"active:bg-negative-active",
|
|
516
516
|
"aria-pressed:bg-negative-active",
|
|
@@ -521,7 +521,7 @@
|
|
|
521
521
|
warning: [
|
|
522
522
|
"bg-warning",
|
|
523
523
|
"text-warning-foreground",
|
|
524
|
-
"shadow-
|
|
524
|
+
"shadow-button",
|
|
525
525
|
"hover:bg-warning-hover",
|
|
526
526
|
"active:bg-warning-active",
|
|
527
527
|
"aria-pressed:bg-warning-active",
|
|
@@ -612,21 +612,24 @@
|
|
|
612
612
|
el.setAttribute("data-slot", "button");
|
|
613
613
|
}
|
|
614
614
|
const inGroup = modifiers.includes("group");
|
|
615
|
+
let lastSize;
|
|
615
616
|
function setVariant(variant) {
|
|
616
617
|
for (const [_, value] of Object.entries(buttonVariants)) {
|
|
617
618
|
el.classList.remove(...value);
|
|
618
619
|
}
|
|
619
620
|
if (buttonVariants.hasOwnProperty(variant)) el.classList.add(...buttonVariants[variant]);
|
|
620
621
|
}
|
|
621
|
-
function setSize(size3) {
|
|
622
|
+
function setSize(size3 = "default") {
|
|
623
|
+
el.classList.remove(...getButtonSize(lastSize, inGroup));
|
|
622
624
|
el.classList.add(...getButtonSize(size3, inGroup));
|
|
623
|
-
if (size3
|
|
625
|
+
if (size3.startsWith("icon") && !el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
|
|
624
626
|
console.error('h-button: Icon-only buttons must have an "aria-label" or "aria-labelledby" attribute', el);
|
|
625
627
|
}
|
|
628
|
+
lastSize = size3;
|
|
626
629
|
}
|
|
627
630
|
setVariant(el.getAttribute("data-variant") ?? "default");
|
|
628
631
|
if (inGroup) {
|
|
629
|
-
el.classList.remove("shadow-
|
|
632
|
+
el.classList.remove("shadow-button", "inline-flex");
|
|
630
633
|
el.classList.add("shadow-none", "flex");
|
|
631
634
|
setSize(el.getAttribute("data-size") ?? "xs");
|
|
632
635
|
} else {
|
|
@@ -2165,7 +2168,7 @@
|
|
|
2165
2168
|
// src/components/calendar.js
|
|
2166
2169
|
function calendar_default(Alpine) {
|
|
2167
2170
|
Alpine.directive("h-calendar", (el, { expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
|
|
2168
|
-
const datepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
2171
|
+
const datepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_datepicker"));
|
|
2169
2172
|
el.classList.add("border", "rounded-control", "gap-2", "p-2");
|
|
2170
2173
|
el.setAttribute("tabindex", "-1");
|
|
2171
2174
|
if (datepicker) {
|
|
@@ -2173,9 +2176,9 @@
|
|
|
2173
2176
|
el.setAttribute("role", "dialog");
|
|
2174
2177
|
el.setAttribute("aria-modal", "true");
|
|
2175
2178
|
el.setAttribute("data-slot", "date-picker-calendar");
|
|
2176
|
-
el.setAttribute("data-state", datepicker.
|
|
2179
|
+
el.setAttribute("data-state", datepicker._h_datepicker.expanded ? "open" : "closed");
|
|
2177
2180
|
} else {
|
|
2178
|
-
el.classList.add("shadow-
|
|
2181
|
+
el.classList.add("shadow-input", "data-[invalid=true]:border-negative", "data-[invalid=true]:ring-negative/20", "dark:data-[invalid=true]:ring-negative/40");
|
|
2179
2182
|
}
|
|
2180
2183
|
let date = /* @__PURE__ */ new Date();
|
|
2181
2184
|
let selected = void 0;
|
|
@@ -2198,38 +2201,38 @@
|
|
|
2198
2201
|
}
|
|
2199
2202
|
}
|
|
2200
2203
|
if (datepicker) {
|
|
2201
|
-
datepicker.
|
|
2202
|
-
datepicker.
|
|
2203
|
-
if (triggerInput) datepicker.
|
|
2204
|
+
datepicker._h_datepicker.input.value = formatter.format(selected);
|
|
2205
|
+
datepicker._h_datepicker.input.setCustomValidity("");
|
|
2206
|
+
if (triggerInput) datepicker._h_datepicker.input.dispatchEvent(new Event("change", { bubbles: true }));
|
|
2204
2207
|
} else {
|
|
2205
2208
|
el.setAttribute("data-invalid", "false");
|
|
2206
2209
|
}
|
|
2207
2210
|
}
|
|
2208
2211
|
const onInputChange = () => {
|
|
2209
|
-
const newValue = new Date(datepicker.
|
|
2212
|
+
const newValue = new Date(datepicker._h_datepicker.input.value);
|
|
2210
2213
|
if (isNaN(newValue)) {
|
|
2211
|
-
console.error(`h-calendar: input value is not a valid date - ${datepicker.
|
|
2212
|
-
datepicker.
|
|
2214
|
+
console.error(`h-calendar: input value is not a valid date - ${datepicker._h_datepicker.input.value}`);
|
|
2215
|
+
datepicker._h_datepicker.input.setCustomValidity("Input value is not a valid date.");
|
|
2213
2216
|
return;
|
|
2214
2217
|
} else if (selected.getTime() !== newValue.getTime()) {
|
|
2215
2218
|
selected = newValue;
|
|
2216
2219
|
modelChange();
|
|
2217
2220
|
render();
|
|
2218
2221
|
}
|
|
2219
|
-
datepicker.
|
|
2222
|
+
datepicker._h_datepicker.input.setCustomValidity("");
|
|
2220
2223
|
};
|
|
2221
2224
|
if (datepicker) {
|
|
2222
|
-
datepicker.
|
|
2225
|
+
datepicker._h_datepicker.input.addEventListener("change", onInputChange);
|
|
2223
2226
|
}
|
|
2224
2227
|
function checkForModel() {
|
|
2225
2228
|
if (el.hasOwnProperty("_x_model") && el._x_model.get()) {
|
|
2226
2229
|
selected = new Date(el._x_model.get());
|
|
2227
2230
|
if (isNaN(selected)) {
|
|
2228
2231
|
console.error(`h-calendar: input value is not a valid date - ${el._x_model.get()}`);
|
|
2229
|
-
if (datepicker) datepicker.
|
|
2232
|
+
if (datepicker) datepicker._h_datepicker.input.setCustomValidity("Input value is not a valid date.");
|
|
2230
2233
|
else el.setAttribute("data-invalid", "true");
|
|
2231
2234
|
} else if (datepicker) {
|
|
2232
|
-
datepicker.
|
|
2235
|
+
datepicker._h_datepicker.input.value = formatter.format(selected);
|
|
2233
2236
|
}
|
|
2234
2237
|
}
|
|
2235
2238
|
}
|
|
@@ -2239,7 +2242,7 @@
|
|
|
2239
2242
|
selected = new Date(focusedDay);
|
|
2240
2243
|
modelChange(true);
|
|
2241
2244
|
render();
|
|
2242
|
-
if (datepicker) datepicker.
|
|
2245
|
+
if (datepicker) datepicker._h_datepicker.expanded = false;
|
|
2243
2246
|
}
|
|
2244
2247
|
function isDisabled(d) {
|
|
2245
2248
|
if (minDate && d < new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate())) return true;
|
|
@@ -2532,7 +2535,7 @@
|
|
|
2532
2535
|
newDay.setMonth(newDay.getMonth() + 1);
|
|
2533
2536
|
break;
|
|
2534
2537
|
case "Escape":
|
|
2535
|
-
if (datepicker) datepicker.
|
|
2538
|
+
if (datepicker) datepicker._h_datepicker.expanded = false;
|
|
2536
2539
|
return;
|
|
2537
2540
|
case "Enter":
|
|
2538
2541
|
case " ":
|
|
@@ -2596,8 +2599,8 @@
|
|
|
2596
2599
|
}
|
|
2597
2600
|
if (datepicker) {
|
|
2598
2601
|
effect(() => {
|
|
2599
|
-
el.setAttribute("data-state", datepicker.
|
|
2600
|
-
if (datepicker.
|
|
2602
|
+
el.setAttribute("data-state", datepicker._h_datepicker.expanded ? "open" : "closed");
|
|
2603
|
+
if (datepicker._h_datepicker.expanded) {
|
|
2601
2604
|
autoUpdateCleanup = autoUpdate(datepicker, el, updatePosition);
|
|
2602
2605
|
Alpine2.nextTick(() => {
|
|
2603
2606
|
focusDay();
|
|
@@ -2617,7 +2620,7 @@
|
|
|
2617
2620
|
dayCells[d].removeEventListener("click", dayClick);
|
|
2618
2621
|
}
|
|
2619
2622
|
if (datepicker) {
|
|
2620
|
-
datepicker.
|
|
2623
|
+
datepicker._h_datepicker.input.removeEventListener("change", onInputChange);
|
|
2621
2624
|
}
|
|
2622
2625
|
});
|
|
2623
2626
|
});
|
|
@@ -2702,7 +2705,7 @@
|
|
|
2702
2705
|
"has-[input:invalid]:ring-negative/20",
|
|
2703
2706
|
"relative",
|
|
2704
2707
|
"rounded-[0.25rem]",
|
|
2705
|
-
"shadow-
|
|
2708
|
+
"shadow-input",
|
|
2706
2709
|
"shrink-0",
|
|
2707
2710
|
"size-5",
|
|
2708
2711
|
"transition-color"
|
|
@@ -2715,7 +2718,7 @@
|
|
|
2715
2718
|
// src/components/collapsible.js
|
|
2716
2719
|
function collapsible_default(Alpine) {
|
|
2717
2720
|
Alpine.directive("h-collapsible", (el, { expression }, { effect, evaluate: evaluate2, evaluateLater, Alpine: Alpine2 }) => {
|
|
2718
|
-
el.
|
|
2721
|
+
el._h_collapsible = Alpine2.reactive({
|
|
2719
2722
|
expanded: expression ? evaluate2(expression) : false
|
|
2720
2723
|
});
|
|
2721
2724
|
if (!el.hasAttribute("data-slot")) el.setAttribute("data-slot", "collapsible");
|
|
@@ -2723,13 +2726,13 @@
|
|
|
2723
2726
|
const getExpanded = evaluateLater(expression);
|
|
2724
2727
|
effect(() => {
|
|
2725
2728
|
getExpanded((expanded) => {
|
|
2726
|
-
el.
|
|
2729
|
+
el._h_collapsible.expanded = expanded;
|
|
2727
2730
|
});
|
|
2728
2731
|
});
|
|
2729
2732
|
}
|
|
2730
2733
|
});
|
|
2731
2734
|
Alpine.directive("h-collapsible-trigger", (el, { modifiers }, { effect, Alpine: Alpine2, cleanup }) => {
|
|
2732
|
-
const collapsible = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
2735
|
+
const collapsible = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_collapsible"));
|
|
2733
2736
|
if (!collapsible) {
|
|
2734
2737
|
throw new Error("h-collapsible-trigger must be inside an h-collapsible element");
|
|
2735
2738
|
}
|
|
@@ -2740,10 +2743,10 @@
|
|
|
2740
2743
|
else el.classList.add("[&[data-state=open]>svg:not(:first-child):last-child]:rotate-180", "[&[data-state=open]>svg:only-child]:rotate-180");
|
|
2741
2744
|
}
|
|
2742
2745
|
const handler2 = () => {
|
|
2743
|
-
collapsible.
|
|
2746
|
+
collapsible._h_collapsible.expanded = !collapsible._h_collapsible.expanded;
|
|
2744
2747
|
};
|
|
2745
2748
|
effect(() => {
|
|
2746
|
-
el.setAttribute("data-state", collapsible.
|
|
2749
|
+
el.setAttribute("data-state", collapsible._h_collapsible.expanded ? "open" : "closed");
|
|
2747
2750
|
});
|
|
2748
2751
|
el.addEventListener("click", handler2);
|
|
2749
2752
|
cleanup(() => {
|
|
@@ -2751,14 +2754,14 @@
|
|
|
2751
2754
|
});
|
|
2752
2755
|
});
|
|
2753
2756
|
Alpine.directive("h-collapsible-content", (el, {}, { effect, Alpine: Alpine2 }) => {
|
|
2754
|
-
const collapsible = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
2757
|
+
const collapsible = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_collapsible"));
|
|
2755
2758
|
if (!collapsible) {
|
|
2756
2759
|
throw new Error("h-collapsible-content must be inside an h-collapsible element");
|
|
2757
2760
|
}
|
|
2758
2761
|
if (!el.hasAttribute("data-slot")) el.setAttribute("data-slot", "collapsible-content");
|
|
2759
|
-
el.classList.add("data-[state=closed]
|
|
2762
|
+
el.classList.add("data-[state=closed]:!hidden");
|
|
2760
2763
|
effect(() => {
|
|
2761
|
-
el.setAttribute("data-state", collapsible.
|
|
2764
|
+
el.setAttribute("data-state", collapsible._h_collapsible.expanded ? "open" : "closed");
|
|
2762
2765
|
});
|
|
2763
2766
|
});
|
|
2764
2767
|
}
|
|
@@ -2766,21 +2769,21 @@
|
|
|
2766
2769
|
// src/components/datepicker.js
|
|
2767
2770
|
function datepicker_default(Alpine) {
|
|
2768
2771
|
Alpine.directive("h-date-picker", (el, {}, { Alpine: Alpine2 }) => {
|
|
2769
|
-
el.
|
|
2772
|
+
el._h_datepicker = Alpine2.reactive({
|
|
2770
2773
|
id: void 0,
|
|
2771
2774
|
controls: `hdpc${v4_default()}`,
|
|
2772
2775
|
input: void 0,
|
|
2773
2776
|
expanded: false
|
|
2774
2777
|
});
|
|
2775
|
-
el.
|
|
2776
|
-
if (!el.
|
|
2778
|
+
el._h_datepicker.input = el.querySelector("input");
|
|
2779
|
+
if (!el._h_datepicker.input || el._h_datepicker.input.tagName !== "INPUT") {
|
|
2777
2780
|
throw new Error("h-date-picker must have an input inside it");
|
|
2778
|
-
} else if (el.
|
|
2779
|
-
el.
|
|
2781
|
+
} else if (el._h_datepicker.input.hasAttribute("id")) {
|
|
2782
|
+
el._h_datepicker.id = el._h_datepicker.input.getAttribute("id");
|
|
2780
2783
|
} else {
|
|
2781
2784
|
const id = `hdp${v4_default()}`;
|
|
2782
|
-
el.
|
|
2783
|
-
el.
|
|
2785
|
+
el._h_datepicker.input.setAttribute("id", id);
|
|
2786
|
+
el._h_datepicker.id = id;
|
|
2784
2787
|
}
|
|
2785
2788
|
el.classList.add(
|
|
2786
2789
|
"border-input",
|
|
@@ -2790,7 +2793,7 @@
|
|
|
2790
2793
|
"items-center",
|
|
2791
2794
|
"rounded-control",
|
|
2792
2795
|
"border",
|
|
2793
|
-
"shadow-
|
|
2796
|
+
"shadow-input",
|
|
2794
2797
|
"transition-[color,box-shadow]",
|
|
2795
2798
|
"duration-200",
|
|
2796
2799
|
"outline-none",
|
|
@@ -2810,9 +2813,9 @@
|
|
|
2810
2813
|
"dark:has-[input:invalid]:ring-negative/40"
|
|
2811
2814
|
);
|
|
2812
2815
|
el.setAttribute("data-slot", "date-picker");
|
|
2813
|
-
el.
|
|
2814
|
-
el.
|
|
2815
|
-
el.
|
|
2816
|
+
el._h_datepicker.input.classList.add("bg-transparent", "outline-none", "flex-1", "border-0", "focus-visible:ring-0", "disabled:pointer-events-none", "disabled:cursor-not-allowed", "disabled:opacity-50", "md:text-sm", "text-base");
|
|
2817
|
+
el._h_datepicker.input.setAttribute("aria-autocomplete", "none");
|
|
2818
|
+
el._h_datepicker.input.setAttribute("type", "text");
|
|
2816
2819
|
});
|
|
2817
2820
|
Alpine.directive("h-date-picker-trigger", (el, {}, { effect, cleanup, Alpine: Alpine2 }) => {
|
|
2818
2821
|
if (el.tagName !== "BUTTON") {
|
|
@@ -2821,11 +2824,11 @@
|
|
|
2821
2824
|
if (!el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
|
|
2822
2825
|
throw new Error('h-date-picker-trigger: must have an "aria-label" or "aria-labelledby" attribute');
|
|
2823
2826
|
}
|
|
2824
|
-
const datepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
2827
|
+
const datepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_datepicker"));
|
|
2825
2828
|
if (!datepicker) {
|
|
2826
2829
|
throw new Error("h-date-picker-trigger must be inside an h-date-picker element");
|
|
2827
2830
|
}
|
|
2828
|
-
el.setAttribute("aria-controls", datepicker.
|
|
2831
|
+
el.setAttribute("aria-controls", datepicker._h_datepicker.controls);
|
|
2829
2832
|
el.setAttribute("aria-expanded", "false");
|
|
2830
2833
|
el.setAttribute("aria-haspopup", "dialog");
|
|
2831
2834
|
el.setAttribute("type", "button");
|
|
@@ -2840,17 +2843,17 @@
|
|
|
2840
2843
|
})
|
|
2841
2844
|
);
|
|
2842
2845
|
effect(() => {
|
|
2843
|
-
el.setAttribute("data-state", datepicker.
|
|
2844
|
-
el.setAttribute("aria-expanded", datepicker.
|
|
2846
|
+
el.setAttribute("data-state", datepicker._h_datepicker.expanded ? "open" : "closed");
|
|
2847
|
+
el.setAttribute("aria-expanded", datepicker._h_datepicker.expanded);
|
|
2845
2848
|
});
|
|
2846
2849
|
const close = () => {
|
|
2847
|
-
datepicker.
|
|
2850
|
+
datepicker._h_datepicker.expanded = false;
|
|
2848
2851
|
};
|
|
2849
2852
|
const handler2 = () => {
|
|
2850
|
-
datepicker.
|
|
2851
|
-
el.setAttribute("aria-expanded", datepicker.
|
|
2853
|
+
datepicker._h_datepicker.expanded = !datepicker._h_datepicker.expanded;
|
|
2854
|
+
el.setAttribute("aria-expanded", datepicker._h_datepicker.expanded);
|
|
2852
2855
|
Alpine2.nextTick(() => {
|
|
2853
|
-
if (datepicker.
|
|
2856
|
+
if (datepicker._h_datepicker.expanded) {
|
|
2854
2857
|
top.addEventListener("click", close, { once: true });
|
|
2855
2858
|
} else {
|
|
2856
2859
|
top.removeEventListener("click", close);
|
|
@@ -2883,12 +2886,24 @@
|
|
|
2883
2886
|
}
|
|
2884
2887
|
}
|
|
2885
2888
|
inputs[0].focus();
|
|
2889
|
+
return;
|
|
2886
2890
|
} else {
|
|
2887
|
-
const
|
|
2888
|
-
if (
|
|
2889
|
-
|
|
2891
|
+
const textareas = el.getElementsByTagName("TEXTAREA");
|
|
2892
|
+
if (textareas.length) {
|
|
2893
|
+
for (let i = 0; i < textareas.length; i++) {
|
|
2894
|
+
if (textareas[i].autofocus) {
|
|
2895
|
+
textareas[i].focus();
|
|
2896
|
+
return;
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
textareas[0].focus();
|
|
2900
|
+
return;
|
|
2890
2901
|
}
|
|
2891
2902
|
}
|
|
2903
|
+
const buttons = el.getElementsByTagName("BUTTON");
|
|
2904
|
+
if (buttons.length) {
|
|
2905
|
+
buttons[0].focus();
|
|
2906
|
+
}
|
|
2892
2907
|
}
|
|
2893
2908
|
});
|
|
2894
2909
|
});
|
|
@@ -2905,7 +2920,8 @@
|
|
|
2905
2920
|
"top-[50%]",
|
|
2906
2921
|
"left-[50%]",
|
|
2907
2922
|
"z-50",
|
|
2908
|
-
"
|
|
2923
|
+
"flex",
|
|
2924
|
+
"flex-col",
|
|
2909
2925
|
"w-full",
|
|
2910
2926
|
"max-w-[calc(100%-2rem)]",
|
|
2911
2927
|
"translate-x-[-50%]",
|
|
@@ -2915,24 +2931,27 @@
|
|
|
2915
2931
|
"border",
|
|
2916
2932
|
"p-4",
|
|
2917
2933
|
"shadow-xl",
|
|
2918
|
-
"sm:max-w-lg"
|
|
2934
|
+
"sm:max-w-lg",
|
|
2935
|
+
"outline-none"
|
|
2919
2936
|
);
|
|
2920
2937
|
el.setAttribute("role", "dialog");
|
|
2921
2938
|
el.setAttribute("data-slot", "dialog");
|
|
2922
|
-
if (!el.hasAttribute("aria-labelledby")) {
|
|
2923
|
-
console.error('h-dialog: attribute "aria-labelledby" is missing');
|
|
2924
|
-
}
|
|
2925
|
-
if (!el.hasAttribute("aria-describedby")) {
|
|
2926
|
-
console.error('h-dialog: attribute "aria-describedby" is missing');
|
|
2927
|
-
}
|
|
2928
2939
|
});
|
|
2929
2940
|
Alpine.directive("h-dialog-header", (el) => {
|
|
2930
2941
|
el.classList.add("grid", "grid-cols-[1fr_auto]", "place-items-start", "gap-2", "text-center", "sm:text-left");
|
|
2931
2942
|
el.setAttribute("data-slot", "dialog-header");
|
|
2932
2943
|
});
|
|
2933
|
-
Alpine.directive("h-dialog-title", (el) => {
|
|
2944
|
+
Alpine.directive("h-dialog-title", (el, {}, { Alpine: Alpine2 }) => {
|
|
2934
2945
|
el.classList.add("text-lg", "leading-none", "font-semibold");
|
|
2935
2946
|
el.setAttribute("data-slot", "dialog-title");
|
|
2947
|
+
const dialog = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("role") === "dialog");
|
|
2948
|
+
if (dialog && (!dialog.hasAttribute("aria-labelledby") || !dialog.hasAttribute("aria-label"))) {
|
|
2949
|
+
if (!el.hasAttribute("id")) {
|
|
2950
|
+
const id = `dht${v4_default()}`;
|
|
2951
|
+
el.setAttribute("id", id);
|
|
2952
|
+
}
|
|
2953
|
+
dialog.setAttribute("aria-labelledby", el.getAttribute("id"));
|
|
2954
|
+
}
|
|
2936
2955
|
});
|
|
2937
2956
|
Alpine.directive("h-dialog-close", (el) => {
|
|
2938
2957
|
el.classList.add(
|
|
@@ -2952,9 +2971,17 @@
|
|
|
2952
2971
|
);
|
|
2953
2972
|
el.setAttribute("data-slot", "dialog-close");
|
|
2954
2973
|
});
|
|
2955
|
-
Alpine.directive("h-dialog-description", (el) => {
|
|
2974
|
+
Alpine.directive("h-dialog-description", (el, {}, { Alpine: Alpine2 }) => {
|
|
2956
2975
|
el.classList.add("col-span-full", "text-muted-foreground", "text-sm");
|
|
2957
2976
|
el.setAttribute("data-slot", "dialog-description");
|
|
2977
|
+
const dialog = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("role") === "dialog");
|
|
2978
|
+
if (dialog && (!dialog.hasAttribute("aria-describedby") || !dialog.hasAttribute("aria-description"))) {
|
|
2979
|
+
if (!el.hasAttribute("id")) {
|
|
2980
|
+
const id = `dhd${v4_default()}`;
|
|
2981
|
+
el.setAttribute("id", id);
|
|
2982
|
+
}
|
|
2983
|
+
dialog.setAttribute("aria-describedby", el.getAttribute("id"));
|
|
2984
|
+
}
|
|
2958
2985
|
});
|
|
2959
2986
|
Alpine.directive("h-dialog-footer", (el) => {
|
|
2960
2987
|
el.classList.add("flex", "flex-col-reverse", "gap-2", "sm:flex-row", "sm:justify-end");
|
|
@@ -3113,7 +3140,7 @@
|
|
|
3113
3140
|
"[&::-webkit-color-swatch-wrapper]:rounded-0",
|
|
3114
3141
|
"[&::-webkit-color-swatch-wrapper]:p-0",
|
|
3115
3142
|
"text-base",
|
|
3116
|
-
"shadow-
|
|
3143
|
+
"shadow-input",
|
|
3117
3144
|
"transition-[color,box-shadow]",
|
|
3118
3145
|
"outline-none",
|
|
3119
3146
|
"file:inline-flex",
|
|
@@ -3137,7 +3164,7 @@
|
|
|
3137
3164
|
"invalid:!border-negative"
|
|
3138
3165
|
);
|
|
3139
3166
|
if (modifiers.includes("group")) {
|
|
3140
|
-
el.classList.remove("rounded-control", "border", "bg-input-inner", "shadow-
|
|
3167
|
+
el.classList.remove("rounded-control", "border", "bg-input-inner", "shadow-input", "focus-visible:ring-[3px]");
|
|
3141
3168
|
el.classList.add("flex-1", "rounded-none", "border-0", "bg-transparent", "shadow-none", "focus-visible:ring-0");
|
|
3142
3169
|
el.setAttribute("data-slot", "input-group-control");
|
|
3143
3170
|
} else el.setAttribute("data-slot", "input");
|
|
@@ -3156,7 +3183,7 @@
|
|
|
3156
3183
|
"items-center",
|
|
3157
3184
|
"rounded-control",
|
|
3158
3185
|
"border",
|
|
3159
|
-
"shadow-
|
|
3186
|
+
"shadow-input",
|
|
3160
3187
|
"transition-[color,box-shadow]",
|
|
3161
3188
|
"outline-none",
|
|
3162
3189
|
"h-9",
|
|
@@ -3275,7 +3302,7 @@
|
|
|
3275
3302
|
"border-input",
|
|
3276
3303
|
"border",
|
|
3277
3304
|
"rounded-control",
|
|
3278
|
-
"shadow-
|
|
3305
|
+
"shadow-input",
|
|
3279
3306
|
"outline-none",
|
|
3280
3307
|
"disabled:pointer-events-none",
|
|
3281
3308
|
"disabled:cursor-not-allowed",
|
|
@@ -3374,13 +3401,11 @@
|
|
|
3374
3401
|
if (!list) {
|
|
3375
3402
|
throw new Error("h-list-header: must be placed inside an h-list element");
|
|
3376
3403
|
}
|
|
3377
|
-
if (el.hasAttribute("id")) {
|
|
3378
|
-
list.setAttribute("aria-labelledby", el.getAttribute("id"));
|
|
3379
|
-
} else {
|
|
3404
|
+
if (!el.hasAttribute("id")) {
|
|
3380
3405
|
const id = `lbh${v4_default()}`;
|
|
3381
3406
|
el.setAttribute("id", id);
|
|
3382
|
-
list.setAttribute("aria-labelledby", id);
|
|
3383
3407
|
}
|
|
3408
|
+
list.setAttribute("aria-labelledby", el.getAttribute("id"));
|
|
3384
3409
|
});
|
|
3385
3410
|
Alpine.directive("h-list-item", (el, { modifiers }) => {
|
|
3386
3411
|
el.classList.add("min-h-11", "flex", "items-center", "p-2", "gap-2", "align-middle", "outline-none");
|
|
@@ -3656,7 +3681,9 @@
|
|
|
3656
3681
|
Alpine.directive("h-menu-item", (el, {}, { cleanup, Alpine: Alpine2 }) => {
|
|
3657
3682
|
el.classList.add(
|
|
3658
3683
|
"focus:bg-secondary-hover",
|
|
3684
|
+
"focus:text-secondary-foreground",
|
|
3659
3685
|
"hover:bg-secondary-hover",
|
|
3686
|
+
"hover:text-secondary-foreground",
|
|
3660
3687
|
"data-[variant=negative]:text-negative",
|
|
3661
3688
|
"data-[variant=negative]:focus:bg-negative/10",
|
|
3662
3689
|
"data-[variant=negative]:hover:bg-negative/10",
|
|
@@ -3772,6 +3799,7 @@
|
|
|
3772
3799
|
Alpine2.nextTick(() => {
|
|
3773
3800
|
submenuitem.focus();
|
|
3774
3801
|
el._menu_sub.expanded = true;
|
|
3802
|
+
el.setAttribute("aria-expanded", true);
|
|
3775
3803
|
});
|
|
3776
3804
|
}
|
|
3777
3805
|
}
|
|
@@ -3781,28 +3809,33 @@
|
|
|
3781
3809
|
if (event.type === "mouseleave") {
|
|
3782
3810
|
el._menu_sub.close();
|
|
3783
3811
|
el._menu_sub.expanded = false;
|
|
3812
|
+
el.setAttribute("aria-expanded", false);
|
|
3784
3813
|
parentMenu.pauseKeyEvents = false;
|
|
3785
|
-
el.setAttribute("aria-expanded", "false");
|
|
3786
3814
|
parentMenu.focus();
|
|
3787
3815
|
} else if (el._menu_sub.expanded) {
|
|
3788
|
-
el.setAttribute("aria-expanded", "false");
|
|
3789
3816
|
el._menu_sub.close();
|
|
3790
3817
|
el._menu_sub.expanded = false;
|
|
3818
|
+
el.setAttribute("aria-expanded", false);
|
|
3791
3819
|
parentMenu.pauseKeyEvents = false;
|
|
3792
3820
|
el.removeEventListener("keydown", onKeydown);
|
|
3793
3821
|
}
|
|
3794
3822
|
}
|
|
3795
3823
|
function focusIn(event) {
|
|
3796
3824
|
el.setAttribute("tabindex", "0");
|
|
3797
|
-
if (event.type === "
|
|
3798
|
-
el.
|
|
3825
|
+
if (event.type === "click" && event.pointerType === "touch" && (event.target === el || event.target.parentElement === el)) {
|
|
3826
|
+
el._menu_sub.open(el);
|
|
3827
|
+
el._menu_sub.expanded = true;
|
|
3828
|
+
el.setAttribute("aria-expanded", true);
|
|
3829
|
+
event.stopPropagation();
|
|
3830
|
+
} else if (event.type === "mouseenter") {
|
|
3799
3831
|
el.addEventListener("mouseleave", focusOut);
|
|
3800
3832
|
el._menu_sub.open(el);
|
|
3801
3833
|
el._menu_sub.expanded = true;
|
|
3834
|
+
el.setAttribute("aria-expanded", true);
|
|
3802
3835
|
} else {
|
|
3803
3836
|
if (el._menu_sub.expanded) {
|
|
3804
|
-
el.setAttribute("aria-expanded", "false");
|
|
3805
3837
|
el._menu_sub.expanded = false;
|
|
3838
|
+
el.setAttribute("aria-expanded", false);
|
|
3806
3839
|
parentMenu.pauseKeyEvents = false;
|
|
3807
3840
|
}
|
|
3808
3841
|
el.addEventListener("keydown", onKeydown);
|
|
@@ -3810,9 +3843,11 @@
|
|
|
3810
3843
|
}
|
|
3811
3844
|
}
|
|
3812
3845
|
el.addEventListener("mouseenter", focusIn);
|
|
3846
|
+
el.addEventListener("click", focusIn);
|
|
3813
3847
|
el.addEventListener("focus", focusIn);
|
|
3814
3848
|
cleanup(() => {
|
|
3815
3849
|
el.removeEventListener("mouseenter", focusIn);
|
|
3850
|
+
el.removeEventListener("click", focusIn);
|
|
3816
3851
|
el.removeEventListener("focus", focusIn);
|
|
3817
3852
|
el.removeEventListener("blur", focusOut);
|
|
3818
3853
|
el.removeEventListener("mouseleave", focusOut);
|
|
@@ -4272,7 +4307,7 @@
|
|
|
4272
4307
|
"has-[input:invalid]:ring-negative/20",
|
|
4273
4308
|
"relative",
|
|
4274
4309
|
"rounded-full",
|
|
4275
|
-
"shadow-
|
|
4310
|
+
"shadow-input",
|
|
4276
4311
|
"shrink-0",
|
|
4277
4312
|
"size-5"
|
|
4278
4313
|
);
|
|
@@ -6168,7 +6203,7 @@
|
|
|
6168
6203
|
});
|
|
6169
6204
|
function select_default(Alpine) {
|
|
6170
6205
|
Alpine.directive("h-select", (el, {}, { Alpine: Alpine2 }) => {
|
|
6171
|
-
el.
|
|
6206
|
+
el._h_select = Alpine2.reactive({
|
|
6172
6207
|
id: void 0,
|
|
6173
6208
|
controls: `hsc${v4_default()}`,
|
|
6174
6209
|
expanded: false,
|
|
@@ -6176,17 +6211,18 @@
|
|
|
6176
6211
|
multiple: false,
|
|
6177
6212
|
label: [],
|
|
6178
6213
|
search: "",
|
|
6214
|
+
focusSearch: void 0,
|
|
6179
6215
|
filterType: FilterType["starts-with"]
|
|
6180
6216
|
});
|
|
6181
6217
|
el.setAttribute("data-slot", "select");
|
|
6182
6218
|
});
|
|
6183
6219
|
Alpine.directive("h-select-trigger", (el, {}, { effect, cleanup, Alpine: Alpine2 }) => {
|
|
6184
|
-
const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
6220
|
+
const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
|
|
6185
6221
|
if (!select) {
|
|
6186
6222
|
throw new Error("h-select-trigger must be inside an h-select element");
|
|
6187
6223
|
} else if (el.hasOwnProperty("_x_model")) {
|
|
6188
|
-
select.
|
|
6189
|
-
select.
|
|
6224
|
+
select._h_select.multiple = Array.isArray(el._x_model.get());
|
|
6225
|
+
select._h_select.model = el._x_model.get();
|
|
6190
6226
|
}
|
|
6191
6227
|
setButtonClasses(el);
|
|
6192
6228
|
const setVariant = (variant) => {
|
|
@@ -6195,7 +6231,7 @@
|
|
|
6195
6231
|
return;
|
|
6196
6232
|
} else if (variant === "transparent") {
|
|
6197
6233
|
el.classList.add(...buttonVariants["transparent"]);
|
|
6198
|
-
} else el.classList.add("shadow-
|
|
6234
|
+
} else el.classList.add("shadow-input", ...buttonVariants["outline"]);
|
|
6199
6235
|
};
|
|
6200
6236
|
const setSize = (size3) => {
|
|
6201
6237
|
const sizes = ["sm", "xs", "lg"];
|
|
@@ -6227,38 +6263,38 @@
|
|
|
6227
6263
|
if (mutation.attributeName === "value") {
|
|
6228
6264
|
el.dispatchEvent(new Event("change", { bubbles: true }));
|
|
6229
6265
|
if (el.value) selectValue.classList.remove("text-muted-foreground");
|
|
6230
|
-
} else if (mutation.attributeName === "placeholder" && !select.
|
|
6266
|
+
} else if (mutation.attributeName === "placeholder" && !select._h_select.label.length) {
|
|
6231
6267
|
getPlaceholder();
|
|
6232
6268
|
}
|
|
6233
6269
|
});
|
|
6234
6270
|
});
|
|
6235
6271
|
observer.observe(el, { attributes: true, attributeFilter: ["value", "placeholder"] });
|
|
6236
6272
|
effect(() => {
|
|
6237
|
-
if (select.
|
|
6238
|
-
selectValue.innerText = select.
|
|
6239
|
-
} else if (select.
|
|
6240
|
-
selectValue.innerText = select.
|
|
6273
|
+
if (select._h_select.label.length === 1) {
|
|
6274
|
+
selectValue.innerText = select._h_select.label[0];
|
|
6275
|
+
} else if (select._h_select.label.length > 1) {
|
|
6276
|
+
selectValue.innerText = select._h_select.label.join(", ");
|
|
6241
6277
|
} else {
|
|
6242
6278
|
getPlaceholder();
|
|
6243
6279
|
}
|
|
6244
6280
|
});
|
|
6245
6281
|
el.setAttribute("data-slot", "select-trigger");
|
|
6246
6282
|
if (el.hasAttribute("id")) {
|
|
6247
|
-
select.
|
|
6283
|
+
select._h_select.id = el.getAttribute("id");
|
|
6248
6284
|
} else {
|
|
6249
|
-
select.
|
|
6250
|
-
el.setAttribute("id", select.
|
|
6285
|
+
select._h_select.id = `hs${v4_default()}`;
|
|
6286
|
+
el.setAttribute("id", select._h_select.id);
|
|
6251
6287
|
}
|
|
6252
|
-
el.setAttribute("aria-controls", select.
|
|
6288
|
+
el.setAttribute("aria-controls", select._h_select.controls);
|
|
6253
6289
|
el.setAttribute("aria-haspopup", "listbox");
|
|
6254
6290
|
el.setAttribute("aria-autocomplete", "none");
|
|
6255
6291
|
el.setAttribute("role", "combobox");
|
|
6256
6292
|
effect(() => {
|
|
6257
|
-
el.setAttribute("data-state", select.
|
|
6258
|
-
el.setAttribute("aria-expanded", select.
|
|
6293
|
+
el.setAttribute("data-state", select._h_select.expanded ? "open" : "closed");
|
|
6294
|
+
el.setAttribute("aria-expanded", select._h_select.expanded);
|
|
6259
6295
|
});
|
|
6260
6296
|
const close = () => {
|
|
6261
|
-
select.
|
|
6297
|
+
select._h_select.expanded = false;
|
|
6262
6298
|
};
|
|
6263
6299
|
let content;
|
|
6264
6300
|
let options;
|
|
@@ -6266,26 +6302,72 @@
|
|
|
6266
6302
|
switch (event.key) {
|
|
6267
6303
|
case "Down":
|
|
6268
6304
|
case "ArrowDown":
|
|
6305
|
+
event.preventDefault();
|
|
6306
|
+
let nextIndex = 0;
|
|
6269
6307
|
for (let o = 0; o < options.length; o++) {
|
|
6270
|
-
if (options[o] ===
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
return;
|
|
6308
|
+
if (options[o].getAttribute("tabindex") === "0") {
|
|
6309
|
+
options[o].setAttribute("tabindex", "-1");
|
|
6310
|
+
if (o < options.length - 1) nextIndex = o + 1;
|
|
6311
|
+
break;
|
|
6275
6312
|
}
|
|
6276
6313
|
}
|
|
6277
|
-
options[
|
|
6314
|
+
if (options[nextIndex].getAttribute("data-disabled") === "true") {
|
|
6315
|
+
if (nextIndex === options.length - 1) nextIndex = 0;
|
|
6316
|
+
for (let o = nextIndex; o < options.length; o++) {
|
|
6317
|
+
if (options[o].getAttribute("data-disabled") !== "true") {
|
|
6318
|
+
nextIndex = o;
|
|
6319
|
+
break;
|
|
6320
|
+
}
|
|
6321
|
+
}
|
|
6322
|
+
}
|
|
6323
|
+
options[nextIndex].setAttribute("tabindex", "0");
|
|
6324
|
+
options[nextIndex].focus();
|
|
6278
6325
|
break;
|
|
6279
6326
|
case "Up":
|
|
6280
6327
|
case "ArrowUp":
|
|
6328
|
+
event.preventDefault();
|
|
6329
|
+
let prevIndex = options.length - 1;
|
|
6281
6330
|
for (let o = options.length - 1; o >= 0; o--) {
|
|
6282
|
-
if (options[o] ===
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6331
|
+
if (options[o].getAttribute("tabindex") === "0") {
|
|
6332
|
+
options[o].setAttribute("tabindex", "-1");
|
|
6333
|
+
if (o !== 0) prevIndex = o - 1;
|
|
6334
|
+
break;
|
|
6335
|
+
}
|
|
6336
|
+
}
|
|
6337
|
+
if (options[prevIndex].getAttribute("data-disabled") === "true") {
|
|
6338
|
+
if (prevIndex === 0) prevIndex = options.length - 1;
|
|
6339
|
+
for (let o = prevIndex; o >= 0; o--) {
|
|
6340
|
+
if (options[o].getAttribute("data-disabled") !== "true") {
|
|
6341
|
+
prevIndex = o;
|
|
6342
|
+
break;
|
|
6343
|
+
}
|
|
6344
|
+
}
|
|
6345
|
+
}
|
|
6346
|
+
options[prevIndex].setAttribute("tabindex", "0");
|
|
6347
|
+
options[prevIndex].focus();
|
|
6348
|
+
break;
|
|
6349
|
+
case "Home":
|
|
6350
|
+
case "PageUp":
|
|
6351
|
+
event.preventDefault();
|
|
6352
|
+
for (let o = 0; o < options.length; o++) {
|
|
6353
|
+
if (options[o].getAttribute("tabindex") === "0") {
|
|
6354
|
+
options[o].setAttribute("tabindex", "-1");
|
|
6355
|
+
break;
|
|
6356
|
+
}
|
|
6357
|
+
}
|
|
6358
|
+
options[0].setAttribute("tabindex", "0");
|
|
6359
|
+
options[0].focus();
|
|
6360
|
+
break;
|
|
6361
|
+
case "End":
|
|
6362
|
+
case "PageDown":
|
|
6363
|
+
event.preventDefault();
|
|
6364
|
+
for (let o = 0; o < options.length; o++) {
|
|
6365
|
+
if (options[o].getAttribute("tabindex") === "0") {
|
|
6366
|
+
options[o].setAttribute("tabindex", "-1");
|
|
6367
|
+
break;
|
|
6287
6368
|
}
|
|
6288
6369
|
}
|
|
6370
|
+
options[options.length - 1].setAttribute("tabindex", "0");
|
|
6289
6371
|
options[options.length - 1].focus();
|
|
6290
6372
|
break;
|
|
6291
6373
|
case "Enter":
|
|
@@ -6296,16 +6378,30 @@
|
|
|
6296
6378
|
case "Tab":
|
|
6297
6379
|
handler2();
|
|
6298
6380
|
break;
|
|
6381
|
+
case "Control":
|
|
6382
|
+
case "Shift":
|
|
6383
|
+
case "Alt":
|
|
6384
|
+
break;
|
|
6385
|
+
default:
|
|
6386
|
+
if (select._h_select.focusSearch) {
|
|
6387
|
+
for (let o = 0; o < options.length; o++) {
|
|
6388
|
+
if (options[o].getAttribute("tabindex") === "0") {
|
|
6389
|
+
options[o].setAttribute("tabindex", "-1");
|
|
6390
|
+
break;
|
|
6391
|
+
}
|
|
6392
|
+
}
|
|
6393
|
+
select._h_select.focusSearch();
|
|
6394
|
+
}
|
|
6299
6395
|
}
|
|
6300
6396
|
};
|
|
6301
6397
|
const handler2 = () => {
|
|
6302
|
-
select.
|
|
6303
|
-
if (select.
|
|
6304
|
-
if (!content) content = select.querySelector(`#${select.
|
|
6398
|
+
select._h_select.expanded = !select._h_select.expanded;
|
|
6399
|
+
if (select._h_select.expanded) {
|
|
6400
|
+
if (!content) content = select.querySelector(`#${select._h_select.controls}`);
|
|
6305
6401
|
options = content.querySelectorAll("[role=option]");
|
|
6306
6402
|
}
|
|
6307
6403
|
Alpine2.nextTick(() => {
|
|
6308
|
-
if (select.
|
|
6404
|
+
if (select._h_select.expanded) {
|
|
6309
6405
|
top.addEventListener("click", close, { once: true });
|
|
6310
6406
|
el.parentElement.addEventListener("keydown", shiftFocus);
|
|
6311
6407
|
} else {
|
|
@@ -6333,7 +6429,7 @@
|
|
|
6333
6429
|
});
|
|
6334
6430
|
});
|
|
6335
6431
|
Alpine.directive("h-select-content", (el, {}, { effect, Alpine: Alpine2 }) => {
|
|
6336
|
-
const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
6432
|
+
const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
|
|
6337
6433
|
if (!select) {
|
|
6338
6434
|
throw new Error("h-select-content must be inside an h-select element");
|
|
6339
6435
|
}
|
|
@@ -6341,11 +6437,11 @@
|
|
|
6341
6437
|
el.setAttribute("data-slot", "select-content");
|
|
6342
6438
|
el.setAttribute("role", "listbox");
|
|
6343
6439
|
el.setAttribute("role", "presentation");
|
|
6344
|
-
el.setAttribute("id", select.
|
|
6440
|
+
el.setAttribute("id", select._h_select.controls);
|
|
6345
6441
|
el.setAttribute("tabindex", "-1");
|
|
6346
|
-
el.setAttribute("aria-labelledby", select.
|
|
6347
|
-
el.setAttribute("data-state", select.
|
|
6348
|
-
const control = select.querySelector(`#${select.
|
|
6442
|
+
el.setAttribute("aria-labelledby", select._h_select.id);
|
|
6443
|
+
el.setAttribute("data-state", select._h_select.expanded ? "open" : "closed");
|
|
6444
|
+
const control = select.querySelector(`#${select._h_select.id}`);
|
|
6349
6445
|
if (!control) {
|
|
6350
6446
|
throw new Error("h-select-content: trigger not found");
|
|
6351
6447
|
}
|
|
@@ -6374,8 +6470,8 @@
|
|
|
6374
6470
|
});
|
|
6375
6471
|
}
|
|
6376
6472
|
effect(() => {
|
|
6377
|
-
el.setAttribute("data-state", select.
|
|
6378
|
-
if (select.
|
|
6473
|
+
el.setAttribute("data-state", select._h_select.expanded ? "open" : "closed");
|
|
6474
|
+
if (select._h_select.expanded) {
|
|
6379
6475
|
autoUpdateCleanup = autoUpdate(control, el, updatePosition);
|
|
6380
6476
|
} else {
|
|
6381
6477
|
if (autoUpdateCleanup) autoUpdateCleanup();
|
|
@@ -6387,14 +6483,16 @@
|
|
|
6387
6483
|
});
|
|
6388
6484
|
});
|
|
6389
6485
|
Alpine.directive("h-select-search", (el, { modifiers }, { effect, cleanup }) => {
|
|
6390
|
-
const select = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
6486
|
+
const select = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
|
|
6391
6487
|
if (!select) {
|
|
6392
6488
|
throw new Error("h-select-search must be inside an h-select element");
|
|
6393
|
-
} else
|
|
6489
|
+
} else {
|
|
6490
|
+
select._h_select.filterType = FilterType[modifiers[0]] ?? FilterType["starts-with"];
|
|
6491
|
+
}
|
|
6394
6492
|
el.classList.add("flex", "h-8", "items-center", "gap-2", "border-b", "px-2");
|
|
6395
6493
|
el.setAttribute("data-slot", "select-search");
|
|
6396
|
-
el.setAttribute("aria-autocomplete", select.
|
|
6397
|
-
el.setAttribute("aria-controls", select.
|
|
6494
|
+
el.setAttribute("aria-autocomplete", select._h_select.filterType === FilterType.none ? "both" : "list");
|
|
6495
|
+
el.setAttribute("aria-controls", select._h_select.controls);
|
|
6398
6496
|
el.setAttribute("aria-haspopup", "listbox");
|
|
6399
6497
|
el.setAttribute("role", "combobox");
|
|
6400
6498
|
el.setAttribute("autocomplete", "off");
|
|
@@ -6407,62 +6505,65 @@
|
|
|
6407
6505
|
searchInput.classList.add("placeholder:text-muted-foreground", "flex", "h-10", "w-full", "rounded-md", "bg-transparent", "py-3", "text-sm", "outline-hidden", "disabled:cursor-not-allowed", "disabled:opacity-50");
|
|
6408
6506
|
el.appendChild(searchIcon);
|
|
6409
6507
|
el.appendChild(searchInput);
|
|
6508
|
+
select._h_select.focusSearch = () => {
|
|
6509
|
+
searchInput.focus();
|
|
6510
|
+
};
|
|
6410
6511
|
function handler2(event) {
|
|
6411
|
-
if (event.type === "keydown" && event.key === "Escape") return;
|
|
6512
|
+
if (event.type === "keydown" && (event.key === "Escape" || event.key === "ArrowDown" || event.key === "Down")) return;
|
|
6412
6513
|
event.stopPropagation();
|
|
6413
6514
|
}
|
|
6414
6515
|
el.addEventListener("click", handler2);
|
|
6415
6516
|
el.addEventListener("keydown", handler2);
|
|
6416
|
-
if (select.
|
|
6517
|
+
if (select._h_select.filterType !== FilterType.none) {
|
|
6417
6518
|
let onInput2 = function() {
|
|
6418
|
-
select.
|
|
6519
|
+
select._h_select.search = searchInput.value.toLowerCase();
|
|
6419
6520
|
};
|
|
6420
6521
|
searchInput.addEventListener("keyup", onInput2);
|
|
6421
6522
|
}
|
|
6422
6523
|
effect(() => {
|
|
6423
|
-
if (select.
|
|
6424
|
-
el.setAttribute("aria-expanded", select.
|
|
6524
|
+
if (select._h_select.expanded) searchInput.focus({ preventScroll: true });
|
|
6525
|
+
el.setAttribute("aria-expanded", select._h_select.expanded);
|
|
6425
6526
|
});
|
|
6426
6527
|
cleanup(() => {
|
|
6427
6528
|
el.removeEventListener("click", handler2);
|
|
6428
6529
|
el.removeEventListener("keydown", handler2);
|
|
6429
|
-
if (select.
|
|
6530
|
+
if (select._h_select.filterType !== FilterType.none) searchInput.removeEventListener("keyup", onInput);
|
|
6430
6531
|
});
|
|
6431
6532
|
});
|
|
6432
6533
|
Alpine.directive("h-select-group", (el, {}, { effect }) => {
|
|
6433
6534
|
el.setAttribute("data-slot", "select-group");
|
|
6434
|
-
el.
|
|
6535
|
+
el._h_selectGroup = Alpine.reactive({
|
|
6435
6536
|
labelledby: void 0
|
|
6436
6537
|
});
|
|
6437
6538
|
effect(() => {
|
|
6438
|
-
if (el.
|
|
6439
|
-
el.setAttribute("aria-labelledby", el.
|
|
6539
|
+
if (el._h_selectGroup.labelledby) {
|
|
6540
|
+
el.setAttribute("aria-labelledby", el._h_selectGroup.labelledby);
|
|
6440
6541
|
}
|
|
6441
6542
|
});
|
|
6442
6543
|
});
|
|
6443
6544
|
Alpine.directive("h-select-label", (el) => {
|
|
6444
6545
|
el.classList.add("text-muted-foreground", "px-2", "py-1.5", "text-xs");
|
|
6445
6546
|
el.setAttribute("data-slot", "select-label");
|
|
6446
|
-
const selectGroup = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
6547
|
+
const selectGroup = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_selectGroup"));
|
|
6447
6548
|
if (selectGroup) {
|
|
6448
6549
|
const id = `hsl${v4_default()}`;
|
|
6449
6550
|
el.setAttribute("id", id);
|
|
6450
|
-
selectGroup.
|
|
6551
|
+
selectGroup._h_selectGroup.labelledby = id;
|
|
6451
6552
|
}
|
|
6452
6553
|
});
|
|
6453
6554
|
Alpine.directive("h-select-option", (el, { expression }, { effect, evaluateLater, cleanup }) => {
|
|
6454
|
-
const select = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
6555
|
+
const select = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
|
|
6455
6556
|
if (!select) {
|
|
6456
6557
|
throw new Error("h-select-option must be inside an h-select element");
|
|
6457
6558
|
}
|
|
6458
6559
|
el.classList.add(
|
|
6459
6560
|
"focus:bg-primary",
|
|
6460
6561
|
"focus:text-primary-foreground",
|
|
6461
|
-
"hover:bg-
|
|
6462
|
-
"hover:text-
|
|
6562
|
+
"hover:bg-secondary-hover",
|
|
6563
|
+
"hover:text-secondary-foreground",
|
|
6463
6564
|
"[&_svg:not([class*='text-'])]:text-muted-foreground",
|
|
6464
6565
|
"focus:[&_svg:not([class*='text-'])]:text-primary-foreground",
|
|
6465
|
-
"hover:[&_svg:not([class*='text-'])]:text-
|
|
6566
|
+
"hover:[&_svg:not([class*='text-'])]:text-secondary-foreground",
|
|
6466
6567
|
"relative",
|
|
6467
6568
|
"flex",
|
|
6468
6569
|
"w-full",
|
|
@@ -6506,26 +6607,26 @@
|
|
|
6506
6607
|
const getLabel = evaluateLater(expression);
|
|
6507
6608
|
effect(() => {
|
|
6508
6609
|
getLabel((label) => {
|
|
6509
|
-
if (select.
|
|
6510
|
-
select.
|
|
6511
|
-
} else if (select.
|
|
6512
|
-
select.
|
|
6610
|
+
if (select._h_select.multiple && select._h_select.model.includes(getValue())) {
|
|
6611
|
+
select._h_select.label[select._h_select.label.indexOf(labelEl.innerText)] = label;
|
|
6612
|
+
} else if (select._h_select.model === getValue()) {
|
|
6613
|
+
select._h_select.label[0] = label;
|
|
6513
6614
|
}
|
|
6514
6615
|
labelEl.innerText = label;
|
|
6515
6616
|
});
|
|
6516
6617
|
});
|
|
6517
6618
|
effect(() => {
|
|
6518
|
-
if (select.
|
|
6519
|
-
if (select.
|
|
6520
|
-
if (!labelEl.innerText.toLowerCase().startsWith(select.
|
|
6619
|
+
if (select._h_select.search) {
|
|
6620
|
+
if (select._h_select.filterType === FilterType["starts-with"]) {
|
|
6621
|
+
if (!labelEl.innerText.toLowerCase().startsWith(select._h_select.search)) {
|
|
6521
6622
|
el.classList.add("hidden");
|
|
6522
6623
|
} else el.classList.remove("hidden");
|
|
6523
|
-
} else if (select.
|
|
6524
|
-
if (!labelEl.innerText.toLowerCase().includes(select.
|
|
6624
|
+
} else if (select._h_select.filterType === FilterType.contains) {
|
|
6625
|
+
if (!labelEl.innerText.toLowerCase().includes(select._h_select.search)) {
|
|
6525
6626
|
el.classList.add("hidden");
|
|
6526
6627
|
} else el.classList.remove("hidden");
|
|
6527
|
-
} else if (select.
|
|
6528
|
-
const terms = select.
|
|
6628
|
+
} else if (select._h_select.filterType === FilterType["contains-each"]) {
|
|
6629
|
+
const terms = select._h_select.search.split(" ");
|
|
6529
6630
|
const label = labelEl.innerText.toLowerCase();
|
|
6530
6631
|
if (!terms.every((term) => label.includes(term))) el.classList.add("hidden");
|
|
6531
6632
|
else el.classList.remove("hidden");
|
|
@@ -6538,11 +6639,11 @@
|
|
|
6538
6639
|
if (selected) {
|
|
6539
6640
|
indicatorEl.classList.remove("invisible");
|
|
6540
6641
|
el.setAttribute("aria-selected", "true");
|
|
6541
|
-
if (!select.
|
|
6542
|
-
select.
|
|
6543
|
-
} else if (!select.
|
|
6544
|
-
if (select.
|
|
6545
|
-
else select.
|
|
6642
|
+
if (!select._h_select.label.length) {
|
|
6643
|
+
select._h_select.label.push(labelEl.innerText);
|
|
6644
|
+
} else if (!select._h_select.label.includes(labelEl.innerText)) {
|
|
6645
|
+
if (select._h_select.multiple) select._h_select.label.push(labelEl.innerText);
|
|
6646
|
+
else select._h_select.label[0] = labelEl.innerText;
|
|
6546
6647
|
}
|
|
6547
6648
|
} else {
|
|
6548
6649
|
indicatorEl.classList.add("invisible");
|
|
@@ -6550,30 +6651,30 @@
|
|
|
6550
6651
|
}
|
|
6551
6652
|
}
|
|
6552
6653
|
function removeLabel() {
|
|
6553
|
-
const lIndex = select.
|
|
6554
|
-
if (lIndex > -1) select.
|
|
6654
|
+
const lIndex = select._h_select.label.indexOf(labelEl.innerText);
|
|
6655
|
+
if (lIndex > -1) select._h_select.label.splice(lIndex, 1);
|
|
6555
6656
|
}
|
|
6556
6657
|
effect(() => {
|
|
6557
|
-
if (select.
|
|
6558
|
-
setSelectedState(select.
|
|
6658
|
+
if (select._h_select.multiple) {
|
|
6659
|
+
setSelectedState(select._h_select.model.includes(getValue()));
|
|
6559
6660
|
} else {
|
|
6560
|
-
setSelectedState(select.
|
|
6661
|
+
setSelectedState(select._h_select.model === getValue());
|
|
6561
6662
|
}
|
|
6562
6663
|
});
|
|
6563
6664
|
const handler2 = (event) => {
|
|
6564
6665
|
if (event.type === "keydown" && event.key === "Enter" || event.type === "click") {
|
|
6565
|
-
if (select.
|
|
6566
|
-
const vIndex = select.
|
|
6666
|
+
if (select._h_select.multiple) {
|
|
6667
|
+
const vIndex = select._h_select.model.indexOf(getValue());
|
|
6567
6668
|
if (vIndex > -1) {
|
|
6568
|
-
select.
|
|
6669
|
+
select._h_select.model.splice(vIndex, 1);
|
|
6569
6670
|
removeLabel();
|
|
6570
6671
|
} else {
|
|
6571
|
-
select.
|
|
6672
|
+
select._h_select.model.push(getValue());
|
|
6572
6673
|
}
|
|
6573
|
-
} else if (select.
|
|
6574
|
-
select.
|
|
6674
|
+
} else if (select._h_select.model !== getValue()) {
|
|
6675
|
+
select._h_select.model = getValue();
|
|
6575
6676
|
} else {
|
|
6576
|
-
select.
|
|
6677
|
+
select._h_select.model = "";
|
|
6577
6678
|
removeLabel();
|
|
6578
6679
|
}
|
|
6579
6680
|
}
|
|
@@ -6613,6 +6714,61 @@
|
|
|
6613
6714
|
});
|
|
6614
6715
|
}
|
|
6615
6716
|
|
|
6717
|
+
// src/components/sheet.js
|
|
6718
|
+
function sheet_default(Alpine) {
|
|
6719
|
+
Alpine.directive("h-sheet-overlay", (el, { expression }, { effect, evaluate: evaluate2, evaluateLater, cleanup }) => {
|
|
6720
|
+
el.classList.add("data-[open=false]:hidden", "fixed", "inset-0", "z-50", "bg-black/50");
|
|
6721
|
+
el.setAttribute("tabindex", "-1");
|
|
6722
|
+
el.setAttribute("data-slot", "sheet-overlay");
|
|
6723
|
+
el.setAttribute("data-open", evaluate2(expression));
|
|
6724
|
+
const getIsOpen = evaluateLater(expression);
|
|
6725
|
+
effect(() => {
|
|
6726
|
+
getIsOpen((isOpen) => {
|
|
6727
|
+
el.setAttribute("data-open", isOpen);
|
|
6728
|
+
});
|
|
6729
|
+
});
|
|
6730
|
+
const onClick = (event) => {
|
|
6731
|
+
if (event.target.getAttribute("data-slot") === "sheet-overlay") {
|
|
6732
|
+
evaluate2(`${expression} = false`);
|
|
6733
|
+
}
|
|
6734
|
+
};
|
|
6735
|
+
el.addEventListener("click", onClick);
|
|
6736
|
+
cleanup(() => {
|
|
6737
|
+
el.removeEventListener("click", onClick);
|
|
6738
|
+
});
|
|
6739
|
+
});
|
|
6740
|
+
Alpine.directive("h-sheet", (el, {}, { cleanup }) => {
|
|
6741
|
+
el.classList.add("bg-background", "fixed", "shadow-lg");
|
|
6742
|
+
el.setAttribute("data-slot", "sheet");
|
|
6743
|
+
let lastSide;
|
|
6744
|
+
const getSideClasses = (side) => {
|
|
6745
|
+
switch (side) {
|
|
6746
|
+
case "top":
|
|
6747
|
+
return ["inset-x-0", "top-0", "h-auto"];
|
|
6748
|
+
case "right":
|
|
6749
|
+
return ["inset-y-0", "right-0", "h-full", "w-auto", "sm:max-w-sm"];
|
|
6750
|
+
case "left":
|
|
6751
|
+
return ["inset-y-0", "left-0", "h-full", "w-auto", "sm:max-w-sm"];
|
|
6752
|
+
default:
|
|
6753
|
+
return ["inset-x-0", "bottom-0", "h-auto"];
|
|
6754
|
+
}
|
|
6755
|
+
};
|
|
6756
|
+
const setSide = (side) => {
|
|
6757
|
+
el.classList.remove(...getSideClasses(lastSide));
|
|
6758
|
+
el.classList.add(...getSideClasses(side));
|
|
6759
|
+
lastSide = side;
|
|
6760
|
+
};
|
|
6761
|
+
const observer = new MutationObserver(() => {
|
|
6762
|
+
setSide(el.getAttribute("data-align"));
|
|
6763
|
+
});
|
|
6764
|
+
setSide(el.getAttribute("data-align"));
|
|
6765
|
+
observer.observe(el, { attributes: true, attributeFilter: ["data-align"] });
|
|
6766
|
+
cleanup(() => {
|
|
6767
|
+
observer.disconnect();
|
|
6768
|
+
});
|
|
6769
|
+
});
|
|
6770
|
+
}
|
|
6771
|
+
|
|
6616
6772
|
// src/components/sidebar.js
|
|
6617
6773
|
function sidebar_default(Alpine) {
|
|
6618
6774
|
Alpine.directive("h-sidebar", (el, { modifiers }, { cleanup }) => {
|
|
@@ -6950,6 +7106,128 @@
|
|
|
6950
7106
|
});
|
|
6951
7107
|
}
|
|
6952
7108
|
|
|
7109
|
+
// src/components/split.js
|
|
7110
|
+
function split_default(Alpine) {
|
|
7111
|
+
Alpine.directive("h-split", (el) => {
|
|
7112
|
+
el.classList.add("group/split", "flex", "data-[orientation=horizontal]:flex-row", "data-[orientation=vertical]:flex-col");
|
|
7113
|
+
el.setAttribute("tabindex", "-1");
|
|
7114
|
+
el.setAttribute("data-slot", "split");
|
|
7115
|
+
});
|
|
7116
|
+
Alpine.directive("h-split-panel", (el) => {
|
|
7117
|
+
el.setAttribute("tabindex", "-1");
|
|
7118
|
+
el.setAttribute("data-slot", "split-panel");
|
|
7119
|
+
});
|
|
7120
|
+
Alpine.directive("h-split-gutter", (el, {}, { cleanup }) => {
|
|
7121
|
+
el.classList.add(
|
|
7122
|
+
"relative",
|
|
7123
|
+
"shrink-0",
|
|
7124
|
+
"touch-none",
|
|
7125
|
+
"bg-border",
|
|
7126
|
+
"outline-none",
|
|
7127
|
+
"hover:bg-primary-hover",
|
|
7128
|
+
"active:bg-primary-active",
|
|
7129
|
+
"before:absolute",
|
|
7130
|
+
"before:top-1/2",
|
|
7131
|
+
"before:left-1/2",
|
|
7132
|
+
"before:-translate-x-1/2",
|
|
7133
|
+
"before:-translate-y-1/2",
|
|
7134
|
+
"before:block",
|
|
7135
|
+
"before:bg-transparent",
|
|
7136
|
+
"hover:before:bg-primary-hover",
|
|
7137
|
+
"group-data-[locked=true]/split:pointer-events-none",
|
|
7138
|
+
"group-data-[orientation=horizontal]/split:cursor-col-resize",
|
|
7139
|
+
"group-data-[orientation=vertical]/split:cursor-row-resize"
|
|
7140
|
+
);
|
|
7141
|
+
const borderClasses = [
|
|
7142
|
+
"bg-border",
|
|
7143
|
+
"outline-none",
|
|
7144
|
+
"hover:bg-primary-hover",
|
|
7145
|
+
"active:bg-primary-active",
|
|
7146
|
+
"before:absolute",
|
|
7147
|
+
"before:top-1/2",
|
|
7148
|
+
"before:left-1/2",
|
|
7149
|
+
"before:-translate-x-1/2",
|
|
7150
|
+
"before:-translate-y-1/2",
|
|
7151
|
+
"before:block",
|
|
7152
|
+
"before:bg-transparent",
|
|
7153
|
+
"hover:before:bg-primary-hover",
|
|
7154
|
+
"group-data-[orientation=horizontal]/split:!w-px",
|
|
7155
|
+
"group-data-[orientation=horizontal]/split:before:h-full",
|
|
7156
|
+
"group-data-[orientation=horizontal]/split:before:w-[0.313rem]",
|
|
7157
|
+
"group-data-[orientation=vertical]/split:!h-px",
|
|
7158
|
+
"group-data-[orientation=vertical]/split:before:w-full",
|
|
7159
|
+
"group-data-[orientation=vertical]/split:before:h-[0.313rem]"
|
|
7160
|
+
];
|
|
7161
|
+
const handleClasses = [
|
|
7162
|
+
"bg-transparent",
|
|
7163
|
+
"outline-none",
|
|
7164
|
+
"after:absolute",
|
|
7165
|
+
"after:block",
|
|
7166
|
+
"after:rounded-sm",
|
|
7167
|
+
"after:bg-background",
|
|
7168
|
+
"after:border-split-handle",
|
|
7169
|
+
"after:border-2",
|
|
7170
|
+
"after:shadow-xs",
|
|
7171
|
+
"after:top-1/2",
|
|
7172
|
+
"after:left-1/2",
|
|
7173
|
+
"after:-translate-x-1/2",
|
|
7174
|
+
"after:-translate-y-1/2",
|
|
7175
|
+
"hover:after:border-primary-hover",
|
|
7176
|
+
"active:after:border-primary-active",
|
|
7177
|
+
"before:absolute",
|
|
7178
|
+
"before:block",
|
|
7179
|
+
"before:top-1/2",
|
|
7180
|
+
"before:left-1/2",
|
|
7181
|
+
"before:-translate-x-1/2",
|
|
7182
|
+
"before:-translate-y-1/2",
|
|
7183
|
+
"before:rounded-sm",
|
|
7184
|
+
"before:from-transparent",
|
|
7185
|
+
"before:from-15%",
|
|
7186
|
+
"before:via-split-handle",
|
|
7187
|
+
"before:to-85%",
|
|
7188
|
+
"before:to-transparent",
|
|
7189
|
+
"hover:before:bg-primary-hover",
|
|
7190
|
+
"hover:before:via-transparent",
|
|
7191
|
+
"active:before:bg-primary-active",
|
|
7192
|
+
"active:before:via-transparent",
|
|
7193
|
+
// Orientation classes
|
|
7194
|
+
"group-data-[orientation=horizontal]/split:before:h-full",
|
|
7195
|
+
"group-data-[orientation=horizontal]/split:before:w-0.5",
|
|
7196
|
+
"group-data-[orientation=horizontal]/split:before:bg-gradient-to-b",
|
|
7197
|
+
"group-data-[orientation=vertical]/split:before:h-0.5",
|
|
7198
|
+
"group-data-[orientation=vertical]/split:before:w-full",
|
|
7199
|
+
"group-data-[orientation=vertical]/split:before:bg-gradient-to-r",
|
|
7200
|
+
// Size classes
|
|
7201
|
+
"group-data-[orientation=horizontal]/split:!w-4",
|
|
7202
|
+
"group-data-[orientation=horizontal]/split:after:w-2.5",
|
|
7203
|
+
"group-data-[orientation=horizontal]/split:after:h-5",
|
|
7204
|
+
"group-data-[orientation=vertical]/split:!h-4",
|
|
7205
|
+
"group-data-[orientation=vertical]/split:after:w-5",
|
|
7206
|
+
"group-data-[orientation=vertical]/split:after:h-2.5"
|
|
7207
|
+
];
|
|
7208
|
+
el.setAttribute("data-slot", "split-gutter");
|
|
7209
|
+
el.setAttribute("tabindex", "-1");
|
|
7210
|
+
el.setAttribute("role", "separator");
|
|
7211
|
+
function setVariant(variant = "handle") {
|
|
7212
|
+
if (variant === "border") {
|
|
7213
|
+
el.classList.remove(...handleClasses);
|
|
7214
|
+
el.classList.add(...borderClasses);
|
|
7215
|
+
} else {
|
|
7216
|
+
el.classList.remove(...borderClasses);
|
|
7217
|
+
el.classList.add(...handleClasses);
|
|
7218
|
+
}
|
|
7219
|
+
}
|
|
7220
|
+
const observer = new MutationObserver(() => {
|
|
7221
|
+
setVariant(el.parentElement.getAttribute("data-variant"));
|
|
7222
|
+
});
|
|
7223
|
+
observer.observe(el.parentElement, { attributes: true, attributeFilter: ["data-variant"] });
|
|
7224
|
+
setVariant(el.parentElement.getAttribute("data-variant"));
|
|
7225
|
+
cleanup(() => {
|
|
7226
|
+
observer.disconnect();
|
|
7227
|
+
});
|
|
7228
|
+
});
|
|
7229
|
+
}
|
|
7230
|
+
|
|
6953
7231
|
// src/components/switch.js
|
|
6954
7232
|
function switch_default(Alpine) {
|
|
6955
7233
|
Alpine.directive("h-switch", (el) => {
|
|
@@ -6974,7 +7252,7 @@
|
|
|
6974
7252
|
"before:pointer-events-none",
|
|
6975
7253
|
"before:ring-0",
|
|
6976
7254
|
"before:rounded-full",
|
|
6977
|
-
"before:shadow-
|
|
7255
|
+
"before:shadow-input",
|
|
6978
7256
|
"before:size-5",
|
|
6979
7257
|
"before:transition-transform",
|
|
6980
7258
|
"bg-muted",
|
|
@@ -7006,7 +7284,7 @@
|
|
|
7006
7284
|
function table_default(Alpine) {
|
|
7007
7285
|
Alpine.directive("h-table-container", (el, { modifiers }) => {
|
|
7008
7286
|
if (modifiers.includes("scroll")) {
|
|
7009
|
-
el.classList.add("overflow-scroll", "[&_thead]:sticky", "[&_thead]:top-0", "[&_thead]:z-
|
|
7287
|
+
el.classList.add("overflow-scroll", "[&_thead]:sticky", "[&_thead]:top-0", "[&_thead]:z-2", "[&_tfoot]:sticky", "[&_tfoot]:bottom-0", "[&_tfoot]:z-2", "[&_tbody_tr_th]:sticky", "[&_tbody_tr_th]:left-0", "[&_tbody_tr_th]:z-1");
|
|
7010
7288
|
} else {
|
|
7011
7289
|
el.classList.add("relative", "w-full", "overflow-x-auto");
|
|
7012
7290
|
}
|
|
@@ -7127,6 +7405,7 @@
|
|
|
7127
7405
|
"[&:not([data-floating=true])]:data-[size=lg]:group-data-[orientation=horizontal]/tabs:min-h-12",
|
|
7128
7406
|
"data-[floating=true]:border",
|
|
7129
7407
|
"data-[floating=true]:shadow-xs",
|
|
7408
|
+
"data-[floating=true]:z-1",
|
|
7130
7409
|
"data-[floating=true]:rounded-lg",
|
|
7131
7410
|
"data-[floating=true]:p-[0.188rem]"
|
|
7132
7411
|
);
|
|
@@ -7348,7 +7627,7 @@
|
|
|
7348
7627
|
"px-3",
|
|
7349
7628
|
"py-2",
|
|
7350
7629
|
"text-base",
|
|
7351
|
-
"shadow-
|
|
7630
|
+
"shadow-input",
|
|
7352
7631
|
"transition-[color,box-shadow]",
|
|
7353
7632
|
"outline-none",
|
|
7354
7633
|
"focus-visible:ring-[3px]",
|
|
@@ -7357,7 +7636,7 @@
|
|
|
7357
7636
|
"md:text-sm"
|
|
7358
7637
|
);
|
|
7359
7638
|
if (modifiers.includes("group")) {
|
|
7360
|
-
el.classList.remove("rounded-control", "border", "bg-input-inner", "py-2", "shadow-
|
|
7639
|
+
el.classList.remove("rounded-control", "border", "bg-input-inner", "py-2", "shadow-input", "focus-visible:ring-[3px]");
|
|
7361
7640
|
el.classList.add("flex-1", "resize-none", "rounded-none", "border-0", "bg-transparent", "py-3", "shadow-none", "focus-visible:ring-0");
|
|
7362
7641
|
el.setAttribute("data-slot", "input-group-control");
|
|
7363
7642
|
} else el.setAttribute("data-slot", "textarea");
|
|
@@ -7497,7 +7776,7 @@
|
|
|
7497
7776
|
};
|
|
7498
7777
|
function timepicker_default(Alpine) {
|
|
7499
7778
|
Alpine.directive("h-time-picker", (el, { expression }, { evaluateLater, cleanup, effect, Alpine: Alpine2 }) => {
|
|
7500
|
-
el.
|
|
7779
|
+
el._h_timepicker = Alpine2.reactive({
|
|
7501
7780
|
id: void 0,
|
|
7502
7781
|
controls: `htpc${v4_default()}`,
|
|
7503
7782
|
model: void 0,
|
|
@@ -7506,8 +7785,8 @@
|
|
|
7506
7785
|
locale: void 0,
|
|
7507
7786
|
seconds: void 0,
|
|
7508
7787
|
close() {
|
|
7509
|
-
el.
|
|
7510
|
-
top.removeEventListener("click", el.
|
|
7788
|
+
el._h_timepicker.expanded = false;
|
|
7789
|
+
top.removeEventListener("click", el._h_timepicker.close);
|
|
7511
7790
|
}
|
|
7512
7791
|
});
|
|
7513
7792
|
el._time = {
|
|
@@ -7547,7 +7826,7 @@
|
|
|
7547
7826
|
"pr-2",
|
|
7548
7827
|
"text-sm",
|
|
7549
7828
|
"whitespace-nowrap",
|
|
7550
|
-
"shadow-
|
|
7829
|
+
"shadow-input",
|
|
7551
7830
|
"transition-[color,box-shadow]",
|
|
7552
7831
|
"duration-200",
|
|
7553
7832
|
"outline-none",
|
|
@@ -7574,28 +7853,28 @@
|
|
|
7574
7853
|
effect(() => {
|
|
7575
7854
|
getConfig((config) => {
|
|
7576
7855
|
if (config) {
|
|
7577
|
-
if (config["locale"]) el.
|
|
7578
|
-
el.
|
|
7856
|
+
if (config["locale"]) el._h_timepicker.locale = config.locale;
|
|
7857
|
+
el._h_timepicker.seconds = config["seconds"];
|
|
7579
7858
|
if (config["is12Hour"] !== void 0) {
|
|
7580
|
-
el.
|
|
7859
|
+
el._h_timepicker.is12Hour = config.is12Hour;
|
|
7581
7860
|
} else {
|
|
7582
|
-
el.
|
|
7861
|
+
el._h_timepicker.is12Hour = new Intl.DateTimeFormat(el._h_timepicker.locale, { hour: "numeric" }).resolvedOptions().hour12;
|
|
7583
7862
|
}
|
|
7584
7863
|
}
|
|
7585
7864
|
});
|
|
7586
7865
|
});
|
|
7587
7866
|
} else {
|
|
7588
|
-
el.
|
|
7867
|
+
el._h_timepicker.is12Hour = new Intl.DateTimeFormat(el._h_timepicker.locale, { hour: "numeric" }).resolvedOptions().hour12;
|
|
7589
7868
|
}
|
|
7590
7869
|
const handler2 = (event) => {
|
|
7591
7870
|
if (event.type === "keydown" && event.key !== "Enter") return;
|
|
7592
|
-
el.
|
|
7593
|
-
el.setAttribute("aria-expanded", el.
|
|
7871
|
+
el._h_timepicker.expanded = !el._h_timepicker.expanded;
|
|
7872
|
+
el.setAttribute("aria-expanded", el._h_timepicker.expanded);
|
|
7594
7873
|
Alpine2.nextTick(() => {
|
|
7595
|
-
if (el.
|
|
7596
|
-
top.addEventListener("click", el.
|
|
7874
|
+
if (el._h_timepicker.expanded) {
|
|
7875
|
+
top.addEventListener("click", el._h_timepicker.close);
|
|
7597
7876
|
} else {
|
|
7598
|
-
top.removeEventListener("click", el.
|
|
7877
|
+
top.removeEventListener("click", el._h_timepicker.close);
|
|
7599
7878
|
}
|
|
7600
7879
|
});
|
|
7601
7880
|
};
|
|
@@ -7604,14 +7883,14 @@
|
|
|
7604
7883
|
cleanup(() => {
|
|
7605
7884
|
el.removeEventListener("click", handler2);
|
|
7606
7885
|
el.removeEventListener("keydown", handler2);
|
|
7607
|
-
top.removeEventListener("click", el.
|
|
7886
|
+
top.removeEventListener("click", el._h_timepicker.close);
|
|
7608
7887
|
});
|
|
7609
7888
|
});
|
|
7610
7889
|
Alpine.directive("h-time-picker-input", (el, {}, { effect, Alpine: Alpine2 }) => {
|
|
7611
7890
|
if (el.tagName !== "INPUT") {
|
|
7612
7891
|
throw new Error("h-time-picker-input must be a readonly input of type text");
|
|
7613
7892
|
}
|
|
7614
|
-
const timepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
7893
|
+
const timepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_timepicker"));
|
|
7615
7894
|
if (!timepicker) {
|
|
7616
7895
|
throw new Error("h-time-picker-input must be inside an h-time-picker element");
|
|
7617
7896
|
}
|
|
@@ -7621,9 +7900,9 @@
|
|
|
7621
7900
|
});
|
|
7622
7901
|
};
|
|
7623
7902
|
if (el.hasOwnProperty("_x_model")) {
|
|
7624
|
-
timepicker.
|
|
7903
|
+
timepicker._h_timepicker.model = el._x_model;
|
|
7625
7904
|
} else {
|
|
7626
|
-
timepicker.
|
|
7905
|
+
timepicker._h_timepicker.model = {
|
|
7627
7906
|
get() {
|
|
7628
7907
|
return el.value;
|
|
7629
7908
|
},
|
|
@@ -7633,62 +7912,62 @@
|
|
|
7633
7912
|
};
|
|
7634
7913
|
}
|
|
7635
7914
|
if (el.hasAttribute("id")) {
|
|
7636
|
-
timepicker.
|
|
7915
|
+
timepicker._h_timepicker.id = el.getAttribute("id");
|
|
7637
7916
|
} else {
|
|
7638
|
-
timepicker.
|
|
7639
|
-
el.setAttribute("id", timepicker.
|
|
7917
|
+
timepicker._h_timepicker.id = `htp${v4_default()}`;
|
|
7918
|
+
el.setAttribute("id", timepicker._h_timepicker.id);
|
|
7640
7919
|
}
|
|
7641
7920
|
el.classList.add("cursor-pointer", "bg-transparent", "outline-none", "flex-1", "h-full", "border-0", "focus-visible:ring-0", "md:text-sm", "text-base", "after:block", "after:w-1");
|
|
7642
7921
|
el.readOnly = true;
|
|
7643
7922
|
el.setAttribute("aria-autocomplete", "none");
|
|
7644
|
-
el.setAttribute("aria-controls", timepicker.
|
|
7923
|
+
el.setAttribute("aria-controls", timepicker._h_timepicker.controls);
|
|
7645
7924
|
el.setAttribute("aria-expanded", "false");
|
|
7646
7925
|
el.setAttribute("aria-haspopup", "dialog");
|
|
7647
7926
|
el.setAttribute("type", "text");
|
|
7648
7927
|
el.setAttribute("data-slot", "time-picker-input");
|
|
7649
|
-
const rawTime = timepicker.
|
|
7928
|
+
const rawTime = timepicker._h_timepicker.model.get();
|
|
7650
7929
|
if (rawTime) {
|
|
7651
|
-
const { hour, minute, second, period } = getSelectedTime(rawTime, timepicker.
|
|
7652
|
-
if (timepicker.
|
|
7653
|
-
timepicker.
|
|
7654
|
-
} else if (timepicker.
|
|
7655
|
-
timepicker.
|
|
7656
|
-
}
|
|
7657
|
-
if (timepicker.
|
|
7658
|
-
if (timepicker.
|
|
7659
|
-
timepicker.
|
|
7930
|
+
const { hour, minute, second, period } = getSelectedTime(rawTime, timepicker._h_timepicker.is12Hour);
|
|
7931
|
+
if (timepicker._h_timepicker.seconds === void 0 && !second) {
|
|
7932
|
+
timepicker._h_timepicker.seconds = false;
|
|
7933
|
+
} else if (timepicker._h_timepicker.seconds === void 0 && second) {
|
|
7934
|
+
timepicker._h_timepicker.seconds = true;
|
|
7935
|
+
}
|
|
7936
|
+
if (timepicker._h_timepicker.is12Hour) {
|
|
7937
|
+
if (timepicker._h_timepicker.seconds) {
|
|
7938
|
+
timepicker._h_timepicker.model.set(`${hour}:${minute}:${second ?? "00"} ${period}`);
|
|
7660
7939
|
timepicker._time.parts.second = second ?? "00";
|
|
7661
7940
|
} else {
|
|
7662
|
-
timepicker.
|
|
7941
|
+
timepicker._h_timepicker.model.set(`${hour}:${minute} ${period}`);
|
|
7663
7942
|
}
|
|
7664
7943
|
timepicker._time.parts.hour = hour;
|
|
7665
7944
|
timepicker._time.parts.minute = minute;
|
|
7666
7945
|
timepicker._time.parts.period = period;
|
|
7667
7946
|
} else {
|
|
7668
|
-
if (timepicker.
|
|
7669
|
-
timepicker.
|
|
7947
|
+
if (timepicker._h_timepicker.seconds) {
|
|
7948
|
+
timepicker._h_timepicker.model.set(`${hour}:${minute}:${second ?? "00"}`);
|
|
7670
7949
|
timepicker._time.parts.second = second ?? "00";
|
|
7671
7950
|
} else {
|
|
7672
|
-
timepicker.
|
|
7951
|
+
timepicker._h_timepicker.model.set(`${hour}:${minute}`);
|
|
7673
7952
|
}
|
|
7674
7953
|
timepicker._time.parts.hour = hour;
|
|
7675
7954
|
timepicker._time.parts.minute = minute;
|
|
7676
7955
|
}
|
|
7677
7956
|
}
|
|
7678
7957
|
let placeholder;
|
|
7679
|
-
if (timepicker.
|
|
7680
|
-
placeholder = timepicker.
|
|
7958
|
+
if (timepicker._h_timepicker.seconds) {
|
|
7959
|
+
placeholder = timepicker._h_timepicker.is12Hour ? "--:--:-- --" : "--:--:--";
|
|
7681
7960
|
} else {
|
|
7682
|
-
placeholder = timepicker.
|
|
7961
|
+
placeholder = timepicker._h_timepicker.is12Hour ? "--:-- --" : "--:--";
|
|
7683
7962
|
}
|
|
7684
7963
|
el.setAttribute("placeholder", placeholder);
|
|
7685
7964
|
effect(() => {
|
|
7686
|
-
el.setAttribute("data-state", timepicker.
|
|
7687
|
-
el.setAttribute("aria-expanded", timepicker.
|
|
7965
|
+
el.setAttribute("data-state", timepicker._h_timepicker.expanded ? "open" : "closed");
|
|
7966
|
+
el.setAttribute("aria-expanded", timepicker._h_timepicker.expanded);
|
|
7688
7967
|
});
|
|
7689
7968
|
}).before("h-button");
|
|
7690
7969
|
Alpine.directive("h-time-picker-popup", (el, {}, { effect, cleanup, Alpine: Alpine2 }) => {
|
|
7691
|
-
const timepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("
|
|
7970
|
+
const timepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_timepicker"));
|
|
7692
7971
|
el.classList.add(
|
|
7693
7972
|
"overflow-hidden",
|
|
7694
7973
|
"outline-none",
|
|
@@ -7707,8 +7986,8 @@
|
|
|
7707
7986
|
el.setAttribute("role", "dialog");
|
|
7708
7987
|
el.setAttribute("aria-modal", "true");
|
|
7709
7988
|
el.setAttribute("data-slot", "time-picker-popup");
|
|
7710
|
-
el.setAttribute("aria-labelledby", timepicker.
|
|
7711
|
-
el.setAttribute("data-state", timepicker.
|
|
7989
|
+
el.setAttribute("aria-labelledby", timepicker._h_timepicker.id);
|
|
7990
|
+
el.setAttribute("data-state", timepicker._h_timepicker.expanded ? "open" : "closed");
|
|
7712
7991
|
const optionClasses = [
|
|
7713
7992
|
"px-3.5",
|
|
7714
7993
|
"py-2",
|
|
@@ -7730,7 +8009,7 @@
|
|
|
7730
8009
|
const updateModel = () => {
|
|
7731
8010
|
let newValue;
|
|
7732
8011
|
if (timepicker._time.parts.hour !== null && timepicker._time.parts.minute !== null) {
|
|
7733
|
-
if (timepicker.
|
|
8012
|
+
if (timepicker._h_timepicker.seconds) {
|
|
7734
8013
|
if (timepicker._time.parts.seconds !== null) {
|
|
7735
8014
|
newValue = `${timepicker._time.parts.hour}:${timepicker._time.parts.minute}:${timepicker._time.parts.second}`;
|
|
7736
8015
|
} else return;
|
|
@@ -7738,13 +8017,13 @@
|
|
|
7738
8017
|
newValue = `${timepicker._time.parts.hour}:${timepicker._time.parts.minute}`;
|
|
7739
8018
|
}
|
|
7740
8019
|
} else return;
|
|
7741
|
-
if (timepicker.
|
|
8020
|
+
if (timepicker._h_timepicker.is12Hour) {
|
|
7742
8021
|
if (timepicker._time.parts.period !== null) {
|
|
7743
8022
|
newValue += ` ${timepicker._time.parts.period}`;
|
|
7744
8023
|
} else return;
|
|
7745
8024
|
}
|
|
7746
8025
|
if (newValue) {
|
|
7747
|
-
timepicker.
|
|
8026
|
+
timepicker._h_timepicker.model.set(newValue);
|
|
7748
8027
|
timepicker._time.changed();
|
|
7749
8028
|
}
|
|
7750
8029
|
};
|
|
@@ -7752,22 +8031,22 @@
|
|
|
7752
8031
|
let date = /* @__PURE__ */ new Date();
|
|
7753
8032
|
let hour = date.getHours();
|
|
7754
8033
|
timepicker._time.parts.period = hour >= 12 ? dayPeriodLabels.pm : dayPeriodLabels.am;
|
|
7755
|
-
if (timepicker.
|
|
8034
|
+
if (timepicker._h_timepicker.is12Hour) {
|
|
7756
8035
|
hour = date.getHours() % 12 || 12;
|
|
7757
8036
|
}
|
|
7758
8037
|
let minute = date.getMinutes();
|
|
7759
8038
|
timepicker._time.parts.hour = hour < 10 ? `0${hour}` : hour.toString();
|
|
7760
8039
|
timepicker._time.parts.minute = minute < 10 ? `0${minute}` : minute.toString();
|
|
7761
|
-
if (timepicker.
|
|
8040
|
+
if (timepicker._h_timepicker.seconds) {
|
|
7762
8041
|
let second = date.getSeconds();
|
|
7763
8042
|
timepicker._time.parts.second = second < 10 ? `0${second}` : second.toString();
|
|
7764
8043
|
}
|
|
7765
8044
|
updateModel();
|
|
7766
|
-
timepicker.
|
|
8045
|
+
timepicker._h_timepicker.close();
|
|
7767
8046
|
};
|
|
7768
8047
|
function onKeyDown(event) {
|
|
7769
8048
|
if (event.key === "Escape") {
|
|
7770
|
-
timepicker.
|
|
8049
|
+
timepicker._h_timepicker.close();
|
|
7771
8050
|
} else if (event.target.tagName === "LI") {
|
|
7772
8051
|
let list;
|
|
7773
8052
|
let inHoursList = event.target.parentElement.dataset.type === "hours";
|
|
@@ -7785,7 +8064,7 @@
|
|
|
7785
8064
|
event.target.setAttribute("tabindex", "-1");
|
|
7786
8065
|
let prevElem = event.target.previousElementSibling;
|
|
7787
8066
|
if (prevElem === null || prevElem.classList.contains("hidden")) {
|
|
7788
|
-
if (inHoursList && timepicker.
|
|
8067
|
+
if (inHoursList && timepicker._h_timepicker.is12Hour) {
|
|
7789
8068
|
prevElem = list.children[12];
|
|
7790
8069
|
} else {
|
|
7791
8070
|
prevElem = list.lastChild;
|
|
@@ -7798,7 +8077,7 @@
|
|
|
7798
8077
|
event.target.setAttribute("tabindex", "-1");
|
|
7799
8078
|
let nextElem = event.target.nextElementSibling;
|
|
7800
8079
|
if (nextElem === null || nextElem.classList.contains("hidden")) {
|
|
7801
|
-
if (inHoursList && timepicker.
|
|
8080
|
+
if (inHoursList && timepicker._h_timepicker.is12Hour) {
|
|
7802
8081
|
nextElem = list.children[1];
|
|
7803
8082
|
} else {
|
|
7804
8083
|
nextElem = list.firstChild;
|
|
@@ -7821,7 +8100,7 @@
|
|
|
7821
8100
|
if (selectedHour) {
|
|
7822
8101
|
selectedHour.focus();
|
|
7823
8102
|
} else {
|
|
7824
|
-
hoursList.children[timepicker.
|
|
8103
|
+
hoursList.children[timepicker._h_timepicker.is12Hour ? 1 : 0].focus();
|
|
7825
8104
|
}
|
|
7826
8105
|
event.stopPropagation();
|
|
7827
8106
|
event.preventDefault();
|
|
@@ -7886,7 +8165,7 @@
|
|
|
7886
8165
|
}
|
|
7887
8166
|
const secondsList = document.createElement("ul");
|
|
7888
8167
|
secondsList.classList.add("flex-1", "overflow-y-scroll", "[scrollbar-width:thin]");
|
|
7889
|
-
if (!timepicker.
|
|
8168
|
+
if (!timepicker._h_timepicker.seconds) {
|
|
7890
8169
|
secondsList.classList.add("hidden");
|
|
7891
8170
|
}
|
|
7892
8171
|
secondsList.setAttribute("role", "listbox");
|
|
@@ -7906,7 +8185,7 @@
|
|
|
7906
8185
|
}
|
|
7907
8186
|
const periodList = document.createElement("ul");
|
|
7908
8187
|
periodList.classList.add("flex-1", "overflow-y-scroll", "[scrollbar-width:thin]");
|
|
7909
|
-
if (!timepicker.
|
|
8188
|
+
if (!timepicker._h_timepicker.is12Hour) {
|
|
7910
8189
|
periodList.classList.add("hidden");
|
|
7911
8190
|
}
|
|
7912
8191
|
periodList.setAttribute("role", "listbox");
|
|
@@ -7945,7 +8224,7 @@
|
|
|
7945
8224
|
okButton.setAttribute("data-action", "close");
|
|
7946
8225
|
okButton.innerText = el.dataset.labelOk ?? "OK";
|
|
7947
8226
|
okButton.disabled = true;
|
|
7948
|
-
okButton.addEventListener("click", timepicker.
|
|
8227
|
+
okButton.addEventListener("click", timepicker._h_timepicker.close);
|
|
7949
8228
|
footer.appendChild(okButton);
|
|
7950
8229
|
el.appendChild(footer);
|
|
7951
8230
|
Alpine2.initTree(footer);
|
|
@@ -7954,7 +8233,7 @@
|
|
|
7954
8233
|
let selectedSecond;
|
|
7955
8234
|
let selectedPeriod;
|
|
7956
8235
|
function render() {
|
|
7957
|
-
if (timepicker.
|
|
8236
|
+
if (timepicker._h_timepicker.is12Hour) {
|
|
7958
8237
|
hoursList.firstChild.classList.add("hidden");
|
|
7959
8238
|
for (let h = 1; h < 13; h++) {
|
|
7960
8239
|
if (hoursList.children[h].innerText === timepicker._time.parts.hour) {
|
|
@@ -7985,7 +8264,7 @@
|
|
|
7985
8264
|
}
|
|
7986
8265
|
}
|
|
7987
8266
|
if (!selectedHour) {
|
|
7988
|
-
hoursList.children[timepicker.
|
|
8267
|
+
hoursList.children[timepicker._h_timepicker.is12Hour ? 1 : 0].setAttribute("tabindex", "0");
|
|
7989
8268
|
}
|
|
7990
8269
|
for (let m = 0; m < minutesList.children.length; m++) {
|
|
7991
8270
|
if (minutesList.children[m].innerText === timepicker._time.parts.minute) {
|
|
@@ -8000,7 +8279,7 @@
|
|
|
8000
8279
|
if (!selectedMinute) {
|
|
8001
8280
|
minutesList.firstChild.setAttribute("tabindex", "0");
|
|
8002
8281
|
}
|
|
8003
|
-
if (timepicker.
|
|
8282
|
+
if (timepicker._h_timepicker.seconds) {
|
|
8004
8283
|
secondsList.classList.remove("hidden");
|
|
8005
8284
|
for (let s = 0; s < secondsList.children.length; s++) {
|
|
8006
8285
|
if (secondsList.children[s].innerText === timepicker._time.parts.second) {
|
|
@@ -8015,20 +8294,20 @@
|
|
|
8015
8294
|
if (!selectedSecond) {
|
|
8016
8295
|
secondsList.firstChild.setAttribute("tabindex", "0");
|
|
8017
8296
|
}
|
|
8018
|
-
if (timepicker.
|
|
8297
|
+
if (timepicker._h_timepicker.is12Hour) {
|
|
8019
8298
|
okButton.disabled = timepicker._time.parts.hour && timepicker._time.parts.minute && timepicker._time.parts.second && timepicker._time.parts.period ? false : true;
|
|
8020
8299
|
} else {
|
|
8021
8300
|
okButton.disabled = timepicker._time.parts.hour && timepicker._time.parts.minute && timepicker._time.parts.second ? false : true;
|
|
8022
8301
|
}
|
|
8023
8302
|
} else {
|
|
8024
8303
|
secondsList.classList.add("hidden");
|
|
8025
|
-
if (timepicker.
|
|
8304
|
+
if (timepicker._h_timepicker.is12Hour) {
|
|
8026
8305
|
okButton.disabled = timepicker._time.parts.hour && timepicker._time.parts.minute && timepicker._time.parts.period ? false : true;
|
|
8027
8306
|
} else {
|
|
8028
8307
|
okButton.disabled = timepicker._time.parts.hour && timepicker._time.parts.minute ? false : true;
|
|
8029
8308
|
}
|
|
8030
8309
|
}
|
|
8031
|
-
if (timepicker.
|
|
8310
|
+
if (timepicker._h_timepicker.is12Hour) {
|
|
8032
8311
|
periodList.classList.remove("hidden");
|
|
8033
8312
|
for (let p = 0; p < periodList.children.length; p++) {
|
|
8034
8313
|
if (periodList.children[p].innerText === timepicker._time.parts.period) {
|
|
@@ -8061,7 +8340,7 @@
|
|
|
8061
8340
|
if (selectedHour) {
|
|
8062
8341
|
selectedHour.focus();
|
|
8063
8342
|
} else {
|
|
8064
|
-
hoursList.children[timepicker.
|
|
8343
|
+
hoursList.children[timepicker._h_timepicker.is12Hour ? 1 : 0].focus();
|
|
8065
8344
|
}
|
|
8066
8345
|
Object.assign(el.style, {
|
|
8067
8346
|
left: `${x}px`,
|
|
@@ -8070,13 +8349,13 @@
|
|
|
8070
8349
|
});
|
|
8071
8350
|
}
|
|
8072
8351
|
effect(() => {
|
|
8073
|
-
el.setAttribute("data-state", timepicker.
|
|
8074
|
-
if (timepicker.
|
|
8352
|
+
el.setAttribute("data-state", timepicker._h_timepicker.expanded ? "open" : "closed");
|
|
8353
|
+
if (timepicker._h_timepicker.expanded) {
|
|
8075
8354
|
render();
|
|
8076
8355
|
autoUpdateCleanup = autoUpdate(timepicker, el, updatePosition);
|
|
8077
8356
|
if (selectedHour) selectedHour.scrollIntoView({ block: "center" });
|
|
8078
8357
|
if (selectedMinute) selectedMinute.scrollIntoView({ block: "center" });
|
|
8079
|
-
if (selectedSecond && timepicker.
|
|
8358
|
+
if (selectedSecond && timepicker._h_timepicker.seconds) selectedSecond.scrollIntoView({ block: "center" });
|
|
8080
8359
|
} else {
|
|
8081
8360
|
if (autoUpdateCleanup) autoUpdateCleanup();
|
|
8082
8361
|
Object.assign(el.style, {
|
|
@@ -8088,7 +8367,7 @@
|
|
|
8088
8367
|
cleanup(() => {
|
|
8089
8368
|
el.removeEventListener("keydown", onKeyDown);
|
|
8090
8369
|
el.removeEventListener("click", onClick);
|
|
8091
|
-
okButton.removeEventListener("click", timepicker.
|
|
8370
|
+
okButton.removeEventListener("click", timepicker._h_timepicker.close);
|
|
8092
8371
|
for (let h = 0; h < hoursList.children.length; h++) {
|
|
8093
8372
|
hoursList.children[h].removeEventListener("click", setHour);
|
|
8094
8373
|
}
|
|
@@ -8295,8 +8574,20 @@
|
|
|
8295
8574
|
};
|
|
8296
8575
|
}
|
|
8297
8576
|
|
|
8577
|
+
// src/utils/focus.js
|
|
8578
|
+
function focus_default(Alpine) {
|
|
8579
|
+
Alpine.directive("h-focus", (el, { expression }, { effect, evaluateLater }) => {
|
|
8580
|
+
const getValue = evaluateLater(expression);
|
|
8581
|
+
effect(() => {
|
|
8582
|
+
getValue((val) => {
|
|
8583
|
+
if (val) el.focus();
|
|
8584
|
+
});
|
|
8585
|
+
});
|
|
8586
|
+
});
|
|
8587
|
+
}
|
|
8588
|
+
|
|
8298
8589
|
// package.json
|
|
8299
|
-
var version = "0.
|
|
8590
|
+
var version = "0.7.0";
|
|
8300
8591
|
|
|
8301
8592
|
// src/index.js
|
|
8302
8593
|
window.Harmonia = { getBreakpointListener, getColorScheme, setColorScheme, version };
|
|
@@ -8326,9 +8617,11 @@
|
|
|
8326
8617
|
window.Alpine.plugin(range_default);
|
|
8327
8618
|
window.Alpine.plugin(select_default);
|
|
8328
8619
|
window.Alpine.plugin(separator_default);
|
|
8620
|
+
window.Alpine.plugin(sheet_default);
|
|
8329
8621
|
window.Alpine.plugin(sidebar_default);
|
|
8330
8622
|
window.Alpine.plugin(skeleton_default);
|
|
8331
8623
|
window.Alpine.plugin(spinner_default);
|
|
8624
|
+
window.Alpine.plugin(split_default);
|
|
8332
8625
|
window.Alpine.plugin(switch_default);
|
|
8333
8626
|
window.Alpine.plugin(table_default);
|
|
8334
8627
|
window.Alpine.plugin(tabs_default);
|
|
@@ -8339,6 +8632,7 @@
|
|
|
8339
8632
|
window.Alpine.plugin(timepicker_default);
|
|
8340
8633
|
window.Alpine.plugin(toolbar_default);
|
|
8341
8634
|
window.Alpine.plugin(tooltip_default);
|
|
8635
|
+
window.Alpine.plugin(focus_default);
|
|
8342
8636
|
});
|
|
8343
8637
|
})();
|
|
8344
8638
|
/*! Bundled license information:
|