@codbex/harmonia 0.4.0 → 0.6.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.js CHANGED
@@ -137,39 +137,39 @@
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._accordion = modifiers.includes("single") ? Alpine2.reactive({
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("_accordion"));
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
  }
151
- el.classList.add("border-b", "last:border-b-0");
151
+ el.classList.add("border-b", "last:border-b-0", "[[data-variant=header]_&]:data-[state=closed]:border-b-0");
152
152
  el.setAttribute("data-slot", "accordion-item");
153
153
  const itemId = expression ?? `ha${v4_default()}`;
154
154
  function getIsExpanded() {
155
- if (accordion._accordion.single) {
156
- if (accordion._accordion.expandedId !== "") {
157
- return accordion._accordion.expandedId === itemId;
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._accordion.expandedId = itemId;
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._accordionItem = Alpine2.reactive({
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._accordionItem.expanded ? "open" : "closed");
172
+ el.setAttribute("data-state", el._h_accordionItem.expanded ? "open" : "closed");
173
173
  };
174
174
  setAttributes();
175
175
  effect(setAttributes);
@@ -178,12 +178,23 @@
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("_accordion"));
182
- const accordionItem = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_accordionItem"));
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
  }
186
- el.classList.add("flex");
186
+ el.classList.add(
187
+ "flex",
188
+ "h-12",
189
+ "[[data-size=md]_&]:h-10",
190
+ "[[data-size=sm]_&]:h-8",
191
+ "[[data-variant=header]_&]:bg-object-header",
192
+ "[[data-variant=header]_&]:text-object-header-foreground",
193
+ "[[data-variant=header]_&]:px-4",
194
+ "[[data-variant=header]_&]:border-b",
195
+ "[[data-size=md][data-variant=header]_&]:px-3",
196
+ "[[data-size=sm][data-variant=header]_&]:px-2.5"
197
+ );
187
198
  el.setAttribute("tabIndex", "-1");
188
199
  const getLabel = evaluateLater(expression);
189
200
  const chevronDown = createElement(ChevronDown, {
@@ -202,10 +213,9 @@
202
213
  "focus-visible:ring-ring/50",
203
214
  "flex",
204
215
  "flex-1",
205
- "items-start",
216
+ "items-center",
206
217
  "justify-between",
207
218
  "gap-4",
208
- "py-4",
209
219
  "text-left",
210
220
  "text-sm",
211
221
  "font-medium",
@@ -224,17 +234,17 @@
224
234
  button.appendChild(chevronDown);
225
235
  });
226
236
  });
227
- button.setAttribute("id", accordionItem._accordionItem.id);
228
- button.setAttribute("aria-controls", accordionItem._accordionItem.controls);
237
+ button.setAttribute("id", accordionItem._h_accordionItem.id);
238
+ button.setAttribute("aria-controls", accordionItem._h_accordionItem.controls);
229
239
  const setAttributes = () => {
230
- button.setAttribute("data-state", accordionItem._accordionItem.expanded ? "open" : "closed");
231
- button.setAttribute("aria-expanded", accordionItem._accordionItem.expanded);
240
+ button.setAttribute("data-state", accordionItem._h_accordionItem.expanded ? "open" : "closed");
241
+ button.setAttribute("aria-expanded", accordionItem._h_accordionItem.expanded);
232
242
  };
233
243
  const handler2 = () => {
234
- accordionItem._accordionItem.expanded = !accordionItem._accordionItem.expanded;
244
+ accordionItem._h_accordionItem.expanded = !accordionItem._h_accordionItem.expanded;
235
245
  setAttributes();
236
- if (accordion._accordion.single) {
237
- accordion._accordion.expandedId = accordionItem._accordionItem.id;
246
+ if (accordion._h_accordion.single) {
247
+ accordion._h_accordion.expandedId = accordionItem._h_accordionItem.id;
238
248
  }
239
249
  };
240
250
  setAttributes();
@@ -242,10 +252,10 @@
242
252
  cleanup(() => {
243
253
  el.removeEventListener("click", handler2);
244
254
  });
245
- if (accordion._accordion.single) {
255
+ if (accordion._h_accordion.single) {
246
256
  effect(() => {
247
- if (accordion._accordion.expandedId !== accordionItem._accordionItem.id) {
248
- accordionItem._accordionItem.expanded = false;
257
+ if (accordion._h_accordion.expandedId !== accordionItem._h_accordionItem.id) {
258
+ accordionItem._h_accordionItem.expanded = false;
249
259
  setAttributes();
250
260
  }
251
261
  });
@@ -254,13 +264,13 @@
254
264
  Alpine.directive("h-accordion-content", (el, {}, { effect, Alpine: Alpine2 }) => {
255
265
  el.classList.add("pt-0", "pb-4", "overflow-hidden", "text-sm", "data-[state=closed]:hidden");
256
266
  el.setAttribute("data-slot", "accordion-content");
257
- const parent = Alpine2.findClosest(el.parentElement, (parent2) => parent2.hasOwnProperty("_accordionItem"));
267
+ const parent = Alpine2.findClosest(el.parentElement, (parent2) => parent2.hasOwnProperty("_h_accordionItem"));
258
268
  if (parent) {
259
- el.setAttribute("id", parent._accordionItem.controls);
260
- el.setAttribute("aria-labelledby", parent._accordionItem.id);
261
- el.setAttribute("data-state", parent._accordionItem.expanded ? "open" : "closed");
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");
262
272
  effect(() => {
263
- el.setAttribute("data-state", parent._accordionItem.expanded ? "open" : "closed");
273
+ el.setAttribute("data-state", parent._h_accordionItem.expanded ? "open" : "closed");
264
274
  });
265
275
  }
266
276
  });
@@ -305,13 +315,11 @@
305
315
  }
306
316
  setVariant(el.getAttribute("data-variant") ?? "default");
307
317
  const observer = new MutationObserver((mutations) => {
308
- mutations.forEach((mutation) => {
309
- if (mutation.type === "attributes" && mutation.attributeName === "data-variant") {
310
- setVariant(el.getAttribute("data-variant") ?? "default");
311
- }
318
+ mutations.forEach(() => {
319
+ setVariant(el.getAttribute("data-variant") ?? "default");
312
320
  });
313
321
  });
314
- observer.observe(el, { attributes: true });
322
+ observer.observe(el, { attributes: true, attributeFilter: ["data-variant"] });
315
323
  cleanup(() => {
316
324
  observer.disconnect();
317
325
  });
@@ -342,6 +350,7 @@
342
350
  "has-[img]:border-0",
343
351
  "flex",
344
352
  "size-8",
353
+ "aspect-square",
345
354
  "shrink-0",
346
355
  "overflow-hidden",
347
356
  "rounded-full",
@@ -351,7 +360,7 @@
351
360
  "[&>svg]:size-5"
352
361
  );
353
362
  el.setAttribute("data-slot", "avatar");
354
- el._avatar = Alpine2.reactive({
363
+ el._h_avatar = Alpine2.reactive({
355
364
  fallback: false
356
365
  });
357
366
  if (el.tagName === "BUTTON") {
@@ -359,7 +368,7 @@
359
368
  }
360
369
  });
361
370
  Alpine.directive("h-avatar-image", (el, {}, { cleanup }) => {
362
- const avatar = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_avatar"));
371
+ const avatar = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_avatar"));
363
372
  if (!avatar) {
364
373
  throw new Error("h-avatar-image must be inside an h-avatar element");
365
374
  }
@@ -370,7 +379,7 @@
370
379
  function fallback(active = false) {
371
380
  if (active) el.classList.add("hidden");
372
381
  else el.classList.remove("hidden");
373
- avatar._avatar.fallback = active;
382
+ avatar._h_avatar.fallback = active;
374
383
  }
375
384
  function completeCheck() {
376
385
  if (el.complete) {
@@ -384,27 +393,25 @@
384
393
  interval = setInterval(completeCheck, 10);
385
394
  }
386
395
  const observer = new MutationObserver((mutations) => {
387
- mutations.forEach((mutation) => {
388
- if (mutation.type === "attributes") {
389
- if (mutation.attributeName === "src") interval = setInterval(completeCheck, 10);
390
- }
396
+ mutations.forEach(() => {
397
+ interval = setInterval(completeCheck, 10);
391
398
  });
392
399
  });
393
- observer.observe(el, { attributes: true });
400
+ observer.observe(el, { attributes: true, attributeFilter: ["src"] });
394
401
  cleanup(() => {
395
402
  if (interval) clearInterval(interval);
396
403
  observer.disconnect();
397
404
  });
398
405
  });
399
406
  Alpine.directive("h-avatar-fallback", (el, {}, { effect }) => {
400
- const avatar = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_avatar"));
407
+ const avatar = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_avatar"));
401
408
  if (!avatar) {
402
409
  throw new Error("h-avatar-fallback must be inside an h-avatar element");
403
410
  }
404
411
  el.classList.add("hidden", "bg-muted", "flex", "size-full", "items-center", "justify-center");
405
412
  el.setAttribute("data-slot", "avatar-fallback");
406
413
  effect(() => {
407
- if (avatar._avatar.fallback) el.classList.remove("hidden");
414
+ if (avatar._h_avatar.fallback) el.classList.remove("hidden");
408
415
  else el.classList.add("hidden");
409
416
  });
410
417
  });
@@ -418,7 +425,7 @@
418
425
  "inline-flex",
419
426
  "items-center",
420
427
  "justify-center",
421
- "rounded-md",
428
+ "rounded-full",
422
429
  "border",
423
430
  "px-2",
424
431
  "py-0.5",
@@ -433,12 +440,6 @@
433
440
  "focus-visible:border-ring",
434
441
  "focus-visible:ring-ring/50",
435
442
  "focus-visible:ring-[3px]",
436
- "aria-invalid:ring-negative/20",
437
- "dark:aria-invalid:ring-negative/40",
438
- "aria-invalid:border-negative",
439
- "invalid:ring-negative/20",
440
- "dark:invalid:ring-negative/40",
441
- "invalid:border-negative",
442
443
  "transition-[color,box-shadow]",
443
444
  "overflow-hidden"
444
445
  );
@@ -460,13 +461,11 @@
460
461
  }
461
462
  setVariant(el.getAttribute("data-variant") ?? "default");
462
463
  const observer = new MutationObserver((mutations) => {
463
- mutations.forEach((mutation) => {
464
- if (mutation.type === "attributes" && mutation.attributeName === "data-variant") {
465
- setVariant(el.getAttribute("data-variant") ?? "default");
466
- }
464
+ mutations.forEach(() => {
465
+ setVariant(el.getAttribute("data-variant") ?? "default");
467
466
  });
468
467
  });
469
- observer.observe(el, { attributes: true });
468
+ observer.observe(el, { attributes: true, attributeFilter: ["data-variant"] });
470
469
  cleanup(() => {
471
470
  observer.disconnect();
472
471
  });
@@ -478,7 +477,7 @@
478
477
  default: [
479
478
  "bg-secondary",
480
479
  "text-secondary-foreground",
481
- "shadow-control",
480
+ "shadow-button",
482
481
  "hover:bg-secondary-hover",
483
482
  "active:bg-secondary-active",
484
483
  "aria-pressed:bg-secondary-active",
@@ -489,7 +488,7 @@
489
488
  primary: [
490
489
  "bg-primary",
491
490
  "text-primary-foreground",
492
- "shadow-control",
491
+ "shadow-button",
493
492
  "hover:bg-primary-hover",
494
493
  "active:bg-primary-active",
495
494
  "aria-pressed:bg-primary-active",
@@ -500,7 +499,7 @@
500
499
  positive: [
501
500
  "bg-positive",
502
501
  "text-positive-foreground",
503
- "shadow-control",
502
+ "shadow-button",
504
503
  "hover:bg-positive-hover",
505
504
  "active:bg-positive-active",
506
505
  "aria-pressed:bg-positive-active",
@@ -511,7 +510,7 @@
511
510
  negative: [
512
511
  "bg-negative",
513
512
  "text-negative-foreground",
514
- "shadow-control",
513
+ "shadow-button",
515
514
  "hover:bg-negative-hover",
516
515
  "active:bg-negative-active",
517
516
  "aria-pressed:bg-negative-active",
@@ -522,7 +521,7 @@
522
521
  warning: [
523
522
  "bg-warning",
524
523
  "text-warning-foreground",
525
- "shadow-control",
524
+ "shadow-button",
526
525
  "hover:bg-warning-hover",
527
526
  "active:bg-warning-active",
528
527
  "aria-pressed:bg-warning-active",
@@ -534,7 +533,6 @@
534
533
  "border",
535
534
  "bg-background",
536
535
  "text-foreground",
537
- "shadow-none",
538
536
  "hover:bg-secondary",
539
537
  "hover:text-secondary-foreground",
540
538
  "active:bg-secondary-active",
@@ -582,11 +580,31 @@
582
580
  "aria-invalid:ring-negative/20",
583
581
  "dark:aria-invalid:ring-negative/40",
584
582
  "aria-invalid:border-negative",
585
- "invalid:ring-negative/20",
586
- "dark:invalid:ring-negative/40",
587
- "invalid:border-negative"
583
+ "invalid:!ring-negative/20",
584
+ "dark:invalid:!ring-negative/40",
585
+ "invalid:!border-negative"
588
586
  );
589
587
  };
588
+ var getButtonSize = (size3, inGroup = false) => {
589
+ switch (size3) {
590
+ case "xs":
591
+ return inGroup ? ["h-6", "gap-1", "px-2", "[&>svg:not([class*='size-'])]:size-3.5", "has-[>svg]:px-2"] : ["h-6.5", "gap-1.5", "px-2.5", "has-[>svg]:px-2.5"];
592
+ case "sm":
593
+ return inGroup ? ["h-8", "px-2.5", "gap-1.5", "has-[>svg]:px-2.5"] : ["h-8", "gap-1.5", "px-3", "has-[>svg]:px-2.5"];
594
+ case "lg":
595
+ return ["h-10", "px-6", "has-[>svg]:px-4"];
596
+ case "icon-xs":
597
+ return inGroup ? ["size-6", "p-0", "has-[>svg]:p-0"] : ["size-6.5"];
598
+ case "icon-sm":
599
+ return inGroup ? ["size-8", "p-0", "has-[>svg]:p-0"] : ["size-8"];
600
+ case "icon":
601
+ return ["size-9"];
602
+ case "icon-lg":
603
+ return ["size-10"];
604
+ default:
605
+ return ["h-9", "px-4", "py-2", "has-[>svg]:px-3"];
606
+ }
607
+ };
590
608
  function button_default(Alpine) {
591
609
  Alpine.directive("h-button", (el, { modifiers }, { cleanup }) => {
592
610
  setButtonClasses(el);
@@ -594,34 +612,24 @@
594
612
  el.setAttribute("data-slot", "button");
595
613
  }
596
614
  const inGroup = modifiers.includes("group");
597
- const sizes = {
598
- default: ["h-9", "px-4", "py-2", "has-[>svg]:px-3"],
599
- xs: inGroup ? ["h-6", "gap-1", "px-2", "[&>svg:not([class*='size-'])]:size-3.5", "has-[>svg]:px-2"] : ["h-6.5", "gap-1.5", "px-2.5", "has-[>svg]:px-2.5"],
600
- sm: inGroup ? ["h-8", "px-2.5", "gap-1.5", "has-[>svg]:px-2.5"] : ["h-8", "gap-1.5", "px-3", "has-[>svg]:px-2.5"],
601
- lg: ["h-10", "px-6", "has-[>svg]:px-4"],
602
- "icon-xs": inGroup ? ["size-6", "p-0", "has-[>svg]:p-0"] : ["size-6.5"],
603
- "icon-sm": inGroup ? ["size-8", "p-0", "has-[>svg]:p-0"] : ["size-8"],
604
- icon: ["size-9"],
605
- "icon-lg": ["size-10"]
606
- };
615
+ let lastSize;
607
616
  function setVariant(variant) {
608
617
  for (const [_, value] of Object.entries(buttonVariants)) {
609
618
  el.classList.remove(...value);
610
619
  }
611
620
  if (buttonVariants.hasOwnProperty(variant)) el.classList.add(...buttonVariants[variant]);
612
621
  }
613
- function setSize(size3) {
614
- if (sizes.hasOwnProperty(size3)) {
615
- el.classList.add(...sizes[size3]);
616
- el.setAttribute("data-size", size3);
617
- if (size3.startsWith("icon") && !el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
618
- console.error('h-button: Icon-only buttons must have an "aria-label" or "aria-labelledby" attribute', el);
619
- }
622
+ function setSize(size3 = "default") {
623
+ el.classList.remove(...getButtonSize(lastSize, inGroup));
624
+ el.classList.add(...getButtonSize(size3, inGroup));
625
+ if (size3.startsWith("icon") && !el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
626
+ console.error('h-button: Icon-only buttons must have an "aria-label" or "aria-labelledby" attribute', el);
620
627
  }
628
+ lastSize = size3;
621
629
  }
622
630
  setVariant(el.getAttribute("data-variant") ?? "default");
623
631
  if (inGroup) {
624
- el.classList.remove("shadow-control", "inline-flex");
632
+ el.classList.remove("shadow-button", "inline-flex");
625
633
  el.classList.add("shadow-none", "flex");
626
634
  setSize(el.getAttribute("data-size") ?? "xs");
627
635
  } else {
@@ -631,19 +639,17 @@
631
639
  if (["date-picker-trigger", "time-picker-trigger"].includes(el.getAttribute("data-slot"))) {
632
640
  setSize("icon-xs");
633
641
  } else {
634
- setSize("default");
642
+ setSize();
635
643
  }
636
644
  }
637
645
  }
638
646
  const observer = new MutationObserver((mutations) => {
639
647
  mutations.forEach((mutation) => {
640
- if (mutation.type === "attributes") {
641
- if (mutation.attributeName === "data-variant") setVariant(el.getAttribute("data-variant") ?? "default");
642
- else if (mutation.attributeName === "data-size") setSize(el.getAttribute("data-size") ?? (inGroup ? "xs" : "default"));
643
- }
648
+ if (mutation.attributeName === "data-variant") setVariant(el.getAttribute("data-variant") ?? "default");
649
+ else setSize(el.getAttribute("data-size") ?? (inGroup ? "xs" : "default"));
644
650
  });
645
651
  });
646
- observer.observe(el, { attributes: true });
652
+ observer.observe(el, { attributes: true, attributeFilter: ["data-variant", "data-size"] });
647
653
  cleanup(() => {
648
654
  observer.disconnect();
649
655
  });
@@ -2162,7 +2168,7 @@
2162
2168
  // src/components/calendar.js
2163
2169
  function calendar_default(Alpine) {
2164
2170
  Alpine.directive("h-calendar", (el, { expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
2165
- const datepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_datepicker"));
2171
+ const datepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_datepicker"));
2166
2172
  el.classList.add("border", "rounded-control", "gap-2", "p-2");
2167
2173
  el.setAttribute("tabindex", "-1");
2168
2174
  if (datepicker) {
@@ -2170,9 +2176,9 @@
2170
2176
  el.setAttribute("role", "dialog");
2171
2177
  el.setAttribute("aria-modal", "true");
2172
2178
  el.setAttribute("data-slot", "date-picker-calendar");
2173
- el.setAttribute("data-state", datepicker._datepicker.expanded ? "open" : "closed");
2179
+ el.setAttribute("data-state", datepicker._h_datepicker.expanded ? "open" : "closed");
2174
2180
  } else {
2175
- el.classList.add("shadow-control", "data-[invalid=true]:border-negative", "data-[invalid=true]:ring-negative/20", "dark:data-[invalid=true]:ring-negative/40");
2181
+ el.classList.add("shadow-input", "data-[invalid=true]:border-negative", "data-[invalid=true]:ring-negative/20", "dark:data-[invalid=true]:ring-negative/40");
2176
2182
  }
2177
2183
  let date = /* @__PURE__ */ new Date();
2178
2184
  let selected = void 0;
@@ -2195,38 +2201,38 @@
2195
2201
  }
2196
2202
  }
2197
2203
  if (datepicker) {
2198
- datepicker._datepicker.input.value = formatter.format(selected);
2199
- datepicker._datepicker.input.setCustomValidity("");
2200
- if (triggerInput) datepicker._datepicker.input.dispatchEvent(new Event("change", { bubbles: true }));
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 }));
2201
2207
  } else {
2202
2208
  el.setAttribute("data-invalid", "false");
2203
2209
  }
2204
2210
  }
2205
2211
  const onInputChange = () => {
2206
- const newValue = new Date(datepicker._datepicker.input.value);
2212
+ const newValue = new Date(datepicker._h_datepicker.input.value);
2207
2213
  if (isNaN(newValue)) {
2208
- console.error(`h-calendar: input value is not a valid date - ${datepicker._datepicker.input.value}`);
2209
- datepicker._datepicker.input.setCustomValidity("Input value is not a valid date.");
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.");
2210
2216
  return;
2211
2217
  } else if (selected.getTime() !== newValue.getTime()) {
2212
2218
  selected = newValue;
2213
2219
  modelChange();
2214
2220
  render();
2215
2221
  }
2216
- datepicker._datepicker.input.setCustomValidity("");
2222
+ datepicker._h_datepicker.input.setCustomValidity("");
2217
2223
  };
2218
2224
  if (datepicker) {
2219
- datepicker._datepicker.input.addEventListener("change", onInputChange);
2225
+ datepicker._h_datepicker.input.addEventListener("change", onInputChange);
2220
2226
  }
2221
2227
  function checkForModel() {
2222
2228
  if (el.hasOwnProperty("_x_model") && el._x_model.get()) {
2223
2229
  selected = new Date(el._x_model.get());
2224
2230
  if (isNaN(selected)) {
2225
2231
  console.error(`h-calendar: input value is not a valid date - ${el._x_model.get()}`);
2226
- if (datepicker) datepicker._datepicker.input.setCustomValidity("Input value is not a valid date.");
2232
+ if (datepicker) datepicker._h_datepicker.input.setCustomValidity("Input value is not a valid date.");
2227
2233
  else el.setAttribute("data-invalid", "true");
2228
2234
  } else if (datepicker) {
2229
- datepicker._datepicker.input.value = formatter.format(selected);
2235
+ datepicker._h_datepicker.input.value = formatter.format(selected);
2230
2236
  }
2231
2237
  }
2232
2238
  }
@@ -2236,7 +2242,7 @@
2236
2242
  selected = new Date(focusedDay);
2237
2243
  modelChange(true);
2238
2244
  render();
2239
- if (datepicker) datepicker._datepicker.expanded = false;
2245
+ if (datepicker) datepicker._h_datepicker.expanded = false;
2240
2246
  }
2241
2247
  function isDisabled(d) {
2242
2248
  if (minDate && d < new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate())) return true;
@@ -2529,7 +2535,7 @@
2529
2535
  newDay.setMonth(newDay.getMonth() + 1);
2530
2536
  break;
2531
2537
  case "Escape":
2532
- if (datepicker) datepicker._datepicker.expanded = false;
2538
+ if (datepicker) datepicker._h_datepicker.expanded = false;
2533
2539
  return;
2534
2540
  case "Enter":
2535
2541
  case " ":
@@ -2593,8 +2599,8 @@
2593
2599
  }
2594
2600
  if (datepicker) {
2595
2601
  effect(() => {
2596
- el.setAttribute("data-state", datepicker._datepicker.expanded ? "open" : "closed");
2597
- if (datepicker._datepicker.expanded) {
2602
+ el.setAttribute("data-state", datepicker._h_datepicker.expanded ? "open" : "closed");
2603
+ if (datepicker._h_datepicker.expanded) {
2598
2604
  autoUpdateCleanup = autoUpdate(datepicker, el, updatePosition);
2599
2605
  Alpine2.nextTick(() => {
2600
2606
  focusDay();
@@ -2614,7 +2620,7 @@
2614
2620
  dayCells[d].removeEventListener("click", dayClick);
2615
2621
  }
2616
2622
  if (datepicker) {
2617
- datepicker._datepicker.input.removeEventListener("change", onInputChange);
2623
+ datepicker._h_datepicker.input.removeEventListener("change", onInputChange);
2618
2624
  }
2619
2625
  });
2620
2626
  });
@@ -2699,7 +2705,7 @@
2699
2705
  "has-[input:invalid]:ring-negative/20",
2700
2706
  "relative",
2701
2707
  "rounded-[0.25rem]",
2702
- "shadow-control",
2708
+ "shadow-input",
2703
2709
  "shrink-0",
2704
2710
  "size-5",
2705
2711
  "transition-color"
@@ -2712,7 +2718,7 @@
2712
2718
  // src/components/collapsible.js
2713
2719
  function collapsible_default(Alpine) {
2714
2720
  Alpine.directive("h-collapsible", (el, { expression }, { effect, evaluate: evaluate2, evaluateLater, Alpine: Alpine2 }) => {
2715
- el._collapsible = Alpine2.reactive({
2721
+ el._h_collapsible = Alpine2.reactive({
2716
2722
  expanded: expression ? evaluate2(expression) : false
2717
2723
  });
2718
2724
  if (!el.hasAttribute("data-slot")) el.setAttribute("data-slot", "collapsible");
@@ -2720,13 +2726,13 @@
2720
2726
  const getExpanded = evaluateLater(expression);
2721
2727
  effect(() => {
2722
2728
  getExpanded((expanded) => {
2723
- el._collapsible.expanded = expanded;
2729
+ el._h_collapsible.expanded = expanded;
2724
2730
  });
2725
2731
  });
2726
2732
  }
2727
2733
  });
2728
2734
  Alpine.directive("h-collapsible-trigger", (el, { modifiers }, { effect, Alpine: Alpine2, cleanup }) => {
2729
- const collapsible = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_collapsible"));
2735
+ const collapsible = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_collapsible"));
2730
2736
  if (!collapsible) {
2731
2737
  throw new Error("h-collapsible-trigger must be inside an h-collapsible element");
2732
2738
  }
@@ -2737,10 +2743,10 @@
2737
2743
  else el.classList.add("[&[data-state=open]>svg:not(:first-child):last-child]:rotate-180", "[&[data-state=open]>svg:only-child]:rotate-180");
2738
2744
  }
2739
2745
  const handler2 = () => {
2740
- collapsible._collapsible.expanded = !collapsible._collapsible.expanded;
2746
+ collapsible._h_collapsible.expanded = !collapsible._h_collapsible.expanded;
2741
2747
  };
2742
2748
  effect(() => {
2743
- el.setAttribute("data-state", collapsible._collapsible.expanded ? "open" : "closed");
2749
+ el.setAttribute("data-state", collapsible._h_collapsible.expanded ? "open" : "closed");
2744
2750
  });
2745
2751
  el.addEventListener("click", handler2);
2746
2752
  cleanup(() => {
@@ -2748,14 +2754,14 @@
2748
2754
  });
2749
2755
  });
2750
2756
  Alpine.directive("h-collapsible-content", (el, {}, { effect, Alpine: Alpine2 }) => {
2751
- const collapsible = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_collapsible"));
2757
+ const collapsible = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_collapsible"));
2752
2758
  if (!collapsible) {
2753
2759
  throw new Error("h-collapsible-content must be inside an h-collapsible element");
2754
2760
  }
2755
2761
  if (!el.hasAttribute("data-slot")) el.setAttribute("data-slot", "collapsible-content");
2756
- el.classList.add("data-[state=closed]:hidden");
2762
+ el.classList.add("data-[state=closed]:!hidden");
2757
2763
  effect(() => {
2758
- el.setAttribute("data-state", collapsible._collapsible.expanded ? "open" : "closed");
2764
+ el.setAttribute("data-state", collapsible._h_collapsible.expanded ? "open" : "closed");
2759
2765
  });
2760
2766
  });
2761
2767
  }
@@ -2763,21 +2769,21 @@
2763
2769
  // src/components/datepicker.js
2764
2770
  function datepicker_default(Alpine) {
2765
2771
  Alpine.directive("h-date-picker", (el, {}, { Alpine: Alpine2 }) => {
2766
- el._datepicker = Alpine2.reactive({
2772
+ el._h_datepicker = Alpine2.reactive({
2767
2773
  id: void 0,
2768
2774
  controls: `hdpc${v4_default()}`,
2769
2775
  input: void 0,
2770
2776
  expanded: false
2771
2777
  });
2772
- el._datepicker.input = el.querySelector("input");
2773
- if (!el._datepicker.input || el._datepicker.input.tagName !== "INPUT") {
2778
+ el._h_datepicker.input = el.querySelector("input");
2779
+ if (!el._h_datepicker.input || el._h_datepicker.input.tagName !== "INPUT") {
2774
2780
  throw new Error("h-date-picker must have an input inside it");
2775
- } else if (el._datepicker.input.hasAttribute("id")) {
2776
- el._datepicker.id = el._datepicker.input.getAttribute("id");
2781
+ } else if (el._h_datepicker.input.hasAttribute("id")) {
2782
+ el._h_datepicker.id = el._h_datepicker.input.getAttribute("id");
2777
2783
  } else {
2778
2784
  const id = `hdp${v4_default()}`;
2779
- el._datepicker.input.setAttribute("id", id);
2780
- el._datepicker.id = id;
2785
+ el._h_datepicker.input.setAttribute("id", id);
2786
+ el._h_datepicker.id = id;
2781
2787
  }
2782
2788
  el.classList.add(
2783
2789
  "border-input",
@@ -2787,7 +2793,7 @@
2787
2793
  "items-center",
2788
2794
  "rounded-control",
2789
2795
  "border",
2790
- "shadow-control",
2796
+ "shadow-input",
2791
2797
  "transition-[color,box-shadow]",
2792
2798
  "duration-200",
2793
2799
  "outline-none",
@@ -2807,9 +2813,9 @@
2807
2813
  "dark:has-[input:invalid]:ring-negative/40"
2808
2814
  );
2809
2815
  el.setAttribute("data-slot", "date-picker");
2810
- el._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");
2811
- el._datepicker.input.setAttribute("aria-autocomplete", "none");
2812
- el._datepicker.input.setAttribute("type", "text");
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");
2813
2819
  });
2814
2820
  Alpine.directive("h-date-picker-trigger", (el, {}, { effect, cleanup, Alpine: Alpine2 }) => {
2815
2821
  if (el.tagName !== "BUTTON") {
@@ -2818,11 +2824,11 @@
2818
2824
  if (!el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
2819
2825
  throw new Error('h-date-picker-trigger: must have an "aria-label" or "aria-labelledby" attribute');
2820
2826
  }
2821
- const datepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_datepicker"));
2827
+ const datepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_datepicker"));
2822
2828
  if (!datepicker) {
2823
2829
  throw new Error("h-date-picker-trigger must be inside an h-date-picker element");
2824
2830
  }
2825
- el.setAttribute("aria-controls", datepicker._datepicker.controls);
2831
+ el.setAttribute("aria-controls", datepicker._h_datepicker.controls);
2826
2832
  el.setAttribute("aria-expanded", "false");
2827
2833
  el.setAttribute("aria-haspopup", "dialog");
2828
2834
  el.setAttribute("type", "button");
@@ -2837,17 +2843,17 @@
2837
2843
  })
2838
2844
  );
2839
2845
  effect(() => {
2840
- el.setAttribute("data-state", datepicker._datepicker.expanded ? "open" : "closed");
2841
- el.setAttribute("aria-expanded", datepicker._datepicker.expanded);
2846
+ el.setAttribute("data-state", datepicker._h_datepicker.expanded ? "open" : "closed");
2847
+ el.setAttribute("aria-expanded", datepicker._h_datepicker.expanded);
2842
2848
  });
2843
2849
  const close = () => {
2844
- datepicker._datepicker.expanded = false;
2850
+ datepicker._h_datepicker.expanded = false;
2845
2851
  };
2846
2852
  const handler2 = () => {
2847
- datepicker._datepicker.expanded = !datepicker._datepicker.expanded;
2848
- el.setAttribute("aria-expanded", datepicker._datepicker.expanded);
2853
+ datepicker._h_datepicker.expanded = !datepicker._h_datepicker.expanded;
2854
+ el.setAttribute("aria-expanded", datepicker._h_datepicker.expanded);
2849
2855
  Alpine2.nextTick(() => {
2850
- if (datepicker._datepicker.expanded) {
2856
+ if (datepicker._h_datepicker.expanded) {
2851
2857
  top.addEventListener("click", close, { once: true });
2852
2858
  } else {
2853
2859
  top.removeEventListener("click", close);
@@ -2869,8 +2875,8 @@
2869
2875
  el.setAttribute("tabindex", "-1");
2870
2876
  el.setAttribute("data-slot", "dialog-overlay");
2871
2877
  const observer = new MutationObserver((mutations) => {
2872
- mutations.forEach((mutation) => {
2873
- if (mutation.type === "attributes" && mutation.attributeName === "data-open" && el.getAttribute("data-open") === "true") {
2878
+ mutations.forEach(() => {
2879
+ if (el.getAttribute("data-open") === "true") {
2874
2880
  const inputs = el.getElementsByTagName("INPUT");
2875
2881
  if (inputs.length) {
2876
2882
  for (let i = 0; i < inputs.length; i++) {
@@ -2880,16 +2886,28 @@
2880
2886
  }
2881
2887
  }
2882
2888
  inputs[0].focus();
2889
+ return;
2883
2890
  } else {
2884
- const buttons = el.getElementsByTagName("BUTTON");
2885
- if (buttons.length) {
2886
- buttons[0].focus();
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;
2887
2901
  }
2888
2902
  }
2903
+ const buttons = el.getElementsByTagName("BUTTON");
2904
+ if (buttons.length) {
2905
+ buttons[0].focus();
2906
+ }
2889
2907
  }
2890
2908
  });
2891
2909
  });
2892
- observer.observe(el, { attributes: true });
2910
+ observer.observe(el, { attributes: true, attributeFilter: ["data-open"] });
2893
2911
  cleanup(() => {
2894
2912
  observer.disconnect();
2895
2913
  });
@@ -2902,7 +2920,8 @@
2902
2920
  "top-[50%]",
2903
2921
  "left-[50%]",
2904
2922
  "z-50",
2905
- "grid",
2923
+ "flex",
2924
+ "flex-col",
2906
2925
  "w-full",
2907
2926
  "max-w-[calc(100%-2rem)]",
2908
2927
  "translate-x-[-50%]",
@@ -2912,24 +2931,27 @@
2912
2931
  "border",
2913
2932
  "p-4",
2914
2933
  "shadow-xl",
2915
- "sm:max-w-lg"
2934
+ "sm:max-w-lg",
2935
+ "outline-none"
2916
2936
  );
2917
2937
  el.setAttribute("role", "dialog");
2918
2938
  el.setAttribute("data-slot", "dialog");
2919
- if (!el.hasAttribute("aria-labelledby")) {
2920
- console.error('h-dialog: attribute "aria-labelledby" is missing');
2921
- }
2922
- if (!el.hasAttribute("aria-describedby")) {
2923
- console.error('h-dialog: attribute "aria-describedby" is missing');
2924
- }
2925
2939
  });
2926
2940
  Alpine.directive("h-dialog-header", (el) => {
2927
2941
  el.classList.add("grid", "grid-cols-[1fr_auto]", "place-items-start", "gap-2", "text-center", "sm:text-left");
2928
2942
  el.setAttribute("data-slot", "dialog-header");
2929
2943
  });
2930
- Alpine.directive("h-dialog-title", (el) => {
2944
+ Alpine.directive("h-dialog-title", (el, {}, { Alpine: Alpine2 }) => {
2931
2945
  el.classList.add("text-lg", "leading-none", "font-semibold");
2932
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
+ }
2933
2955
  });
2934
2956
  Alpine.directive("h-dialog-close", (el) => {
2935
2957
  el.classList.add(
@@ -2949,9 +2971,17 @@
2949
2971
  );
2950
2972
  el.setAttribute("data-slot", "dialog-close");
2951
2973
  });
2952
- Alpine.directive("h-dialog-description", (el) => {
2974
+ Alpine.directive("h-dialog-description", (el, {}, { Alpine: Alpine2 }) => {
2953
2975
  el.classList.add("col-span-full", "text-muted-foreground", "text-sm");
2954
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
+ }
2955
2985
  });
2956
2986
  Alpine.directive("h-dialog-footer", (el) => {
2957
2987
  el.classList.add("flex", "flex-col-reverse", "gap-2", "sm:flex-row", "sm:justify-end");
@@ -3110,7 +3140,7 @@
3110
3140
  "[&::-webkit-color-swatch-wrapper]:rounded-0",
3111
3141
  "[&::-webkit-color-swatch-wrapper]:p-0",
3112
3142
  "text-base",
3113
- "shadow-control",
3143
+ "shadow-input",
3114
3144
  "transition-[color,box-shadow]",
3115
3145
  "outline-none",
3116
3146
  "file:inline-flex",
@@ -3129,12 +3159,12 @@
3129
3159
  "aria-invalid:ring-negative/20",
3130
3160
  "dark:aria-invalid:ring-negative/40",
3131
3161
  "aria-invalid:border-negative",
3132
- "invalid:ring-negative/20",
3133
- "dark:invalid:ring-negative/40",
3134
- "invalid:border-negative"
3162
+ "invalid:!ring-negative/20",
3163
+ "dark:invalid:!ring-negative/40",
3164
+ "invalid:!border-negative"
3135
3165
  );
3136
3166
  if (modifiers.includes("group")) {
3137
- el.classList.remove("rounded-control", "border", "bg-input-inner", "shadow-control", "focus-visible:ring-[3px]");
3167
+ el.classList.remove("rounded-control", "border", "bg-input-inner", "shadow-input", "focus-visible:ring-[3px]");
3138
3168
  el.classList.add("flex-1", "rounded-none", "border-0", "bg-transparent", "shadow-none", "focus-visible:ring-0");
3139
3169
  el.setAttribute("data-slot", "input-group-control");
3140
3170
  } else el.setAttribute("data-slot", "input");
@@ -3153,7 +3183,7 @@
3153
3183
  "items-center",
3154
3184
  "rounded-control",
3155
3185
  "border",
3156
- "shadow-control",
3186
+ "shadow-input",
3157
3187
  "transition-[color,box-shadow]",
3158
3188
  "outline-none",
3159
3189
  "h-9",
@@ -3272,7 +3302,7 @@
3272
3302
  "border-input",
3273
3303
  "border",
3274
3304
  "rounded-control",
3275
- "shadow-control",
3305
+ "shadow-input",
3276
3306
  "outline-none",
3277
3307
  "disabled:pointer-events-none",
3278
3308
  "disabled:cursor-not-allowed",
@@ -3283,9 +3313,9 @@
3283
3313
  "aria-invalid:ring-negative/20",
3284
3314
  "dark:aria-invalid:ring-negative/40",
3285
3315
  "aria-invalid:border-negative",
3286
- "invalid:ring-negative/20",
3287
- "dark:invalid:ring-negative/40",
3288
- "invalid:border-negative",
3316
+ "invalid:!ring-negative/20",
3317
+ "dark:invalid:!ring-negative/40",
3318
+ "invalid:!border-negative",
3289
3319
  "[&>ul:first-child>*:first-child]:rounded-t-control",
3290
3320
  "[&>ul:last-child>*:last-child]:rounded-b-control"
3291
3321
  );
@@ -3371,13 +3401,11 @@
3371
3401
  if (!list) {
3372
3402
  throw new Error("h-list-header: must be placed inside an h-list element");
3373
3403
  }
3374
- if (el.hasAttribute("id")) {
3375
- list.setAttribute("aria-labelledby", el.getAttribute("id"));
3376
- } else {
3404
+ if (!el.hasAttribute("id")) {
3377
3405
  const id = `lbh${v4_default()}`;
3378
3406
  el.setAttribute("id", id);
3379
- list.setAttribute("aria-labelledby", id);
3380
3407
  }
3408
+ list.setAttribute("aria-labelledby", el.getAttribute("id"));
3381
3409
  });
3382
3410
  Alpine.directive("h-list-item", (el, { modifiers }) => {
3383
3411
  el.classList.add("min-h-11", "flex", "items-center", "p-2", "gap-2", "align-middle", "outline-none");
@@ -3653,7 +3681,9 @@
3653
3681
  Alpine.directive("h-menu-item", (el, {}, { cleanup, Alpine: Alpine2 }) => {
3654
3682
  el.classList.add(
3655
3683
  "focus:bg-secondary-hover",
3684
+ "focus:text-secondary-foreground",
3656
3685
  "hover:bg-secondary-hover",
3686
+ "hover:text-secondary-foreground",
3657
3687
  "data-[variant=negative]:text-negative",
3658
3688
  "data-[variant=negative]:focus:bg-negative/10",
3659
3689
  "data-[variant=negative]:hover:bg-negative/10",
@@ -3769,6 +3799,7 @@
3769
3799
  Alpine2.nextTick(() => {
3770
3800
  submenuitem.focus();
3771
3801
  el._menu_sub.expanded = true;
3802
+ el.setAttribute("aria-expanded", true);
3772
3803
  });
3773
3804
  }
3774
3805
  }
@@ -3778,28 +3809,33 @@
3778
3809
  if (event.type === "mouseleave") {
3779
3810
  el._menu_sub.close();
3780
3811
  el._menu_sub.expanded = false;
3812
+ el.setAttribute("aria-expanded", false);
3781
3813
  parentMenu.pauseKeyEvents = false;
3782
- el.setAttribute("aria-expanded", "false");
3783
3814
  parentMenu.focus();
3784
3815
  } else if (el._menu_sub.expanded) {
3785
- el.setAttribute("aria-expanded", "false");
3786
3816
  el._menu_sub.close();
3787
3817
  el._menu_sub.expanded = false;
3818
+ el.setAttribute("aria-expanded", false);
3788
3819
  parentMenu.pauseKeyEvents = false;
3789
3820
  el.removeEventListener("keydown", onKeydown);
3790
3821
  }
3791
3822
  }
3792
3823
  function focusIn(event) {
3793
3824
  el.setAttribute("tabindex", "0");
3794
- if (event.type === "mouseenter") {
3795
- el.setAttribute("aria-expanded", "true");
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") {
3796
3831
  el.addEventListener("mouseleave", focusOut);
3797
3832
  el._menu_sub.open(el);
3798
3833
  el._menu_sub.expanded = true;
3834
+ el.setAttribute("aria-expanded", true);
3799
3835
  } else {
3800
3836
  if (el._menu_sub.expanded) {
3801
- el.setAttribute("aria-expanded", "false");
3802
3837
  el._menu_sub.expanded = false;
3838
+ el.setAttribute("aria-expanded", false);
3803
3839
  parentMenu.pauseKeyEvents = false;
3804
3840
  }
3805
3841
  el.addEventListener("keydown", onKeydown);
@@ -3807,9 +3843,11 @@
3807
3843
  }
3808
3844
  }
3809
3845
  el.addEventListener("mouseenter", focusIn);
3846
+ el.addEventListener("click", focusIn);
3810
3847
  el.addEventListener("focus", focusIn);
3811
3848
  cleanup(() => {
3812
3849
  el.removeEventListener("mouseenter", focusIn);
3850
+ el.removeEventListener("click", focusIn);
3813
3851
  el.removeEventListener("focus", focusIn);
3814
3852
  el.removeEventListener("blur", focusOut);
3815
3853
  el.removeEventListener("mouseleave", focusOut);
@@ -4269,7 +4307,7 @@
4269
4307
  "has-[input:invalid]:ring-negative/20",
4270
4308
  "relative",
4271
4309
  "rounded-full",
4272
- "shadow-control",
4310
+ "shadow-input",
4273
4311
  "shrink-0",
4274
4312
  "size-5"
4275
4313
  );
@@ -6165,7 +6203,7 @@
6165
6203
  });
6166
6204
  function select_default(Alpine) {
6167
6205
  Alpine.directive("h-select", (el, {}, { Alpine: Alpine2 }) => {
6168
- el._select = Alpine2.reactive({
6206
+ el._h_select = Alpine2.reactive({
6169
6207
  id: void 0,
6170
6208
  controls: `hsc${v4_default()}`,
6171
6209
  expanded: false,
@@ -6173,22 +6211,41 @@
6173
6211
  multiple: false,
6174
6212
  label: [],
6175
6213
  search: "",
6214
+ focusSearch: void 0,
6176
6215
  filterType: FilterType["starts-with"]
6177
6216
  });
6178
6217
  el.setAttribute("data-slot", "select");
6179
6218
  });
6180
6219
  Alpine.directive("h-select-trigger", (el, {}, { effect, cleanup, Alpine: Alpine2 }) => {
6181
- const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_select"));
6220
+ const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
6182
6221
  if (!select) {
6183
6222
  throw new Error("h-select-trigger must be inside an h-select element");
6184
6223
  } else if (el.hasOwnProperty("_x_model")) {
6185
- select._select.multiple = Array.isArray(el._x_model.get());
6186
- select._select.model = el._x_model.get();
6224
+ select._h_select.multiple = Array.isArray(el._x_model.get());
6225
+ select._h_select.model = el._x_model.get();
6187
6226
  }
6227
+ setButtonClasses(el);
6228
+ const setVariant = (variant) => {
6229
+ if (variant === "secondary") {
6230
+ el.classList.add(...buttonVariants["default"]);
6231
+ return;
6232
+ } else if (variant === "transparent") {
6233
+ el.classList.add(...buttonVariants["transparent"]);
6234
+ } else el.classList.add("shadow-input", ...buttonVariants["outline"]);
6235
+ };
6236
+ const setSize = (size3) => {
6237
+ const sizes = ["sm", "xs", "lg"];
6238
+ if (sizes.includes(size3)) {
6239
+ el.classList.add(...getButtonSize(size3));
6240
+ } else el.classList.add(...getButtonSize());
6241
+ };
6242
+ setVariant(el.getAttribute("data-variant"));
6243
+ setSize(el.getAttribute("data-size"));
6244
+ el.classList.add("w-full", "[&_svg]:opacity-50", "[&[data-state=open]>svg]:rotate-180");
6188
6245
  el.setAttribute("type", "button");
6189
6246
  const selectValue = document.createElement("span");
6190
6247
  selectValue.setAttribute("data-slot", "select-value");
6191
- selectValue.classList.add("pointer-events-none");
6248
+ selectValue.classList.add("text-left", "truncate", "pointer-events-none", "w-full");
6192
6249
  function getPlaceholder() {
6193
6250
  if (!el.value) {
6194
6251
  const value = el.getAttribute("placeholder");
@@ -6203,100 +6260,41 @@
6203
6260
  getPlaceholder();
6204
6261
  const observer = new MutationObserver((mutations) => {
6205
6262
  mutations.forEach((mutation) => {
6206
- if (mutation.type === "attributes") {
6207
- if (mutation.attributeName === "value") {
6208
- el.dispatchEvent(new Event("change", { bubbles: true }));
6209
- if (el.value) selectValue.classList.remove("text-muted-foreground");
6210
- } else if (mutation.attributeName === "placeholder" && !select._select.label.length) {
6211
- getPlaceholder();
6212
- }
6263
+ if (mutation.attributeName === "value") {
6264
+ el.dispatchEvent(new Event("change", { bubbles: true }));
6265
+ if (el.value) selectValue.classList.remove("text-muted-foreground");
6266
+ } else if (mutation.attributeName === "placeholder" && !select._h_select.label.length) {
6267
+ getPlaceholder();
6213
6268
  }
6214
6269
  });
6215
6270
  });
6216
- observer.observe(el, { attributes: true });
6271
+ observer.observe(el, { attributes: true, attributeFilter: ["value", "placeholder"] });
6217
6272
  effect(() => {
6218
- if (select._select.label.length === 1) {
6219
- selectValue.innerText = select._select.label[0];
6220
- } else if (select._select.label.length > 1) {
6221
- selectValue.innerText = select._select.label.join(", ");
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(", ");
6222
6277
  } else {
6223
6278
  getPlaceholder();
6224
6279
  }
6225
6280
  });
6226
- el.classList.add(
6227
- "[&>*]:pointer-events-none",
6228
- "cursor-pointer",
6229
- "border-input",
6230
- "focus-visible:border-ring",
6231
- "focus-visible:ring-ring/50",
6232
- "aria-invalid:ring-negative/20",
6233
- "dark:aria-invalid:ring-negative/40",
6234
- "aria-invalid:border-negative",
6235
- "invalid:ring-negative/20",
6236
- "dark:invalid:ring-negative/40",
6237
- "invalid:border-negative",
6238
- "hover:bg-secondary-hover",
6239
- "active:bg-secondary-active",
6240
- "flex",
6241
- "w-full",
6242
- "items-center",
6243
- "justify-between",
6244
- "gap-2",
6245
- "rounded-control",
6246
- "border",
6247
- "bg-input-inner",
6248
- "px-3",
6249
- "text-sm",
6250
- "whitespace-nowrap",
6251
- "shadow-control",
6252
- "transition-[color,box-shadow]",
6253
- "outline-none",
6254
- "focus-visible:ring-[3px]",
6255
- "disabled:cursor-not-allowed",
6256
- "disabled:opacity-50",
6257
- "*:data-[slot=select-value]:line-clamp-1",
6258
- "*:data-[slot=select-value]:flex",
6259
- "*:data-[slot=select-value]:items-center",
6260
- "*:data-[slot=select-value]:gap-2",
6261
- "[&_svg]:pointer-events-none",
6262
- "[&_svg]:shrink-0",
6263
- "[&_svg:not([class*='size-'])]:size-4",
6264
- "[&_svg]:size-4",
6265
- "[&_svg]:opacity-50",
6266
- "[&[data-state=open]>svg]:rotate-180"
6267
- );
6268
6281
  el.setAttribute("data-slot", "select-trigger");
6269
6282
  if (el.hasAttribute("id")) {
6270
- select._select.id = el.getAttribute("id");
6283
+ select._h_select.id = el.getAttribute("id");
6271
6284
  } else {
6272
- select._select.id = `hs${v4_default()}`;
6273
- el.setAttribute("id", select._select.id);
6285
+ select._h_select.id = `hs${v4_default()}`;
6286
+ el.setAttribute("id", select._h_select.id);
6274
6287
  }
6275
- el.setAttribute("aria-controls", select._select.controls);
6288
+ el.setAttribute("aria-controls", select._h_select.controls);
6276
6289
  el.setAttribute("aria-haspopup", "listbox");
6277
6290
  el.setAttribute("aria-autocomplete", "none");
6278
6291
  el.setAttribute("role", "combobox");
6279
- const sizes = {
6280
- default: ["h-9", "py-2"],
6281
- xs: ["h-6.5", "py-[0.188rem]"],
6282
- sm: ["h-8", "py-1.5"]
6283
- };
6284
- function setSize(size3) {
6285
- for (const [_, value] of Object.entries(sizes)) {
6286
- el.classList.remove(...value);
6287
- }
6288
- if (sizes.hasOwnProperty(size3)) {
6289
- el.classList.add(...sizes[size3]);
6290
- }
6291
- }
6292
- if (!el.hasAttribute("data-size")) el.setAttribute("data-size", "default");
6293
- setSize(el.getAttribute("data-size"));
6294
6292
  effect(() => {
6295
- el.setAttribute("data-state", select._select.expanded ? "open" : "closed");
6296
- el.setAttribute("aria-expanded", select._select.expanded);
6293
+ el.setAttribute("data-state", select._h_select.expanded ? "open" : "closed");
6294
+ el.setAttribute("aria-expanded", select._h_select.expanded);
6297
6295
  });
6298
6296
  const close = () => {
6299
- select._select.expanded = false;
6297
+ select._h_select.expanded = false;
6300
6298
  };
6301
6299
  let content;
6302
6300
  let options;
@@ -6304,26 +6302,72 @@
6304
6302
  switch (event.key) {
6305
6303
  case "Down":
6306
6304
  case "ArrowDown":
6305
+ event.preventDefault();
6306
+ let nextIndex = 0;
6307
6307
  for (let o = 0; o < options.length; o++) {
6308
- if (options[o] === document.activeElement) {
6309
- if (o < options.length - 1) {
6310
- options[o + 1].focus();
6311
- } else options[0].focus();
6312
- 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;
6313
6312
  }
6314
6313
  }
6315
- options[0].focus();
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();
6316
6325
  break;
6317
6326
  case "Up":
6318
6327
  case "ArrowUp":
6328
+ event.preventDefault();
6329
+ let prevIndex = options.length - 1;
6319
6330
  for (let o = options.length - 1; o >= 0; o--) {
6320
- if (options[o] === document.activeElement) {
6321
- if (o !== 0) {
6322
- options[o - 1].focus();
6323
- } else options[options.length - 1].focus();
6324
- return;
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
+ }
6325
6344
  }
6326
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;
6368
+ }
6369
+ }
6370
+ options[options.length - 1].setAttribute("tabindex", "0");
6327
6371
  options[options.length - 1].focus();
6328
6372
  break;
6329
6373
  case "Enter":
@@ -6334,16 +6378,30 @@
6334
6378
  case "Tab":
6335
6379
  handler2();
6336
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
+ }
6337
6395
  }
6338
6396
  };
6339
6397
  const handler2 = () => {
6340
- select._select.expanded = !select._select.expanded;
6341
- if (select._select.expanded) {
6342
- if (!content) content = select.querySelector(`#${select._select.controls}`);
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}`);
6343
6401
  options = content.querySelectorAll("[role=option]");
6344
6402
  }
6345
6403
  Alpine2.nextTick(() => {
6346
- if (select._select.expanded) {
6404
+ if (select._h_select.expanded) {
6347
6405
  top.addEventListener("click", close, { once: true });
6348
6406
  el.parentElement.addEventListener("keydown", shiftFocus);
6349
6407
  } else {
@@ -6371,19 +6429,19 @@
6371
6429
  });
6372
6430
  });
6373
6431
  Alpine.directive("h-select-content", (el, {}, { effect, Alpine: Alpine2 }) => {
6374
- const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_select"));
6432
+ const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
6375
6433
  if (!select) {
6376
6434
  throw new Error("h-select-content must be inside an h-select element");
6377
6435
  }
6378
- el.classList.add("absolute", "bg-popover", "text-popover-foreground", "data-[state=closed]:hidden", "p-1", "top-0", "left-0", "z-50", "min-w-[1rem]", "overflow-x-hidden", "overflow-y-auto", "rounded-control", "border", "shadow-md");
6436
+ el.classList.add("absolute", "bg-popover", "text-popover-foreground", "data-[state=closed]:hidden", "p-1", "top-0", "left-0", "z-50", "min-w-[1rem]", "overflow-x-hidden", "overflow-y-auto", "rounded-md", "border", "shadow-md");
6379
6437
  el.setAttribute("data-slot", "select-content");
6380
6438
  el.setAttribute("role", "listbox");
6381
6439
  el.setAttribute("role", "presentation");
6382
- el.setAttribute("id", select._select.controls);
6440
+ el.setAttribute("id", select._h_select.controls);
6383
6441
  el.setAttribute("tabindex", "-1");
6384
- el.setAttribute("aria-labelledby", select._select.id);
6385
- el.setAttribute("data-state", select._select.expanded ? "open" : "closed");
6386
- const control = select.querySelector(`#${select._select.id}`);
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}`);
6387
6445
  if (!control) {
6388
6446
  throw new Error("h-select-content: trigger not found");
6389
6447
  }
@@ -6412,8 +6470,8 @@
6412
6470
  });
6413
6471
  }
6414
6472
  effect(() => {
6415
- el.setAttribute("data-state", select._select.expanded ? "open" : "closed");
6416
- if (select._select.expanded) {
6473
+ el.setAttribute("data-state", select._h_select.expanded ? "open" : "closed");
6474
+ if (select._h_select.expanded) {
6417
6475
  autoUpdateCleanup = autoUpdate(control, el, updatePosition);
6418
6476
  } else {
6419
6477
  if (autoUpdateCleanup) autoUpdateCleanup();
@@ -6425,14 +6483,16 @@
6425
6483
  });
6426
6484
  });
6427
6485
  Alpine.directive("h-select-search", (el, { modifiers }, { effect, cleanup }) => {
6428
- const select = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_select"));
6486
+ const select = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
6429
6487
  if (!select) {
6430
6488
  throw new Error("h-select-search must be inside an h-select element");
6431
- } else select._select.filterType = FilterType[modifiers[0]] ?? FilterType["starts-with"];
6489
+ } else {
6490
+ select._h_select.filterType = FilterType[modifiers[0]] ?? FilterType["starts-with"];
6491
+ }
6432
6492
  el.classList.add("flex", "h-8", "items-center", "gap-2", "border-b", "px-2");
6433
6493
  el.setAttribute("data-slot", "select-search");
6434
- el.setAttribute("aria-autocomplete", select._select.filterType === FilterType.none ? "both" : "list");
6435
- el.setAttribute("aria-controls", select._select.controls);
6494
+ el.setAttribute("aria-autocomplete", select._h_select.filterType === FilterType.none ? "both" : "list");
6495
+ el.setAttribute("aria-controls", select._h_select.controls);
6436
6496
  el.setAttribute("aria-haspopup", "listbox");
6437
6497
  el.setAttribute("role", "combobox");
6438
6498
  el.setAttribute("autocomplete", "off");
@@ -6445,69 +6505,72 @@
6445
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");
6446
6506
  el.appendChild(searchIcon);
6447
6507
  el.appendChild(searchInput);
6508
+ select._h_select.focusSearch = () => {
6509
+ searchInput.focus();
6510
+ };
6448
6511
  function handler2(event) {
6449
- if (event.type === "keydown" && event.key === "Escape") return;
6512
+ if (event.type === "keydown" && (event.key === "Escape" || event.key === "ArrowDown" || event.key === "Down")) return;
6450
6513
  event.stopPropagation();
6451
6514
  }
6452
6515
  el.addEventListener("click", handler2);
6453
6516
  el.addEventListener("keydown", handler2);
6454
- if (select._select.filterType !== FilterType.none) {
6517
+ if (select._h_select.filterType !== FilterType.none) {
6455
6518
  let onInput2 = function() {
6456
- select._select.search = searchInput.value.toLowerCase();
6519
+ select._h_select.search = searchInput.value.toLowerCase();
6457
6520
  };
6458
6521
  searchInput.addEventListener("keyup", onInput2);
6459
6522
  }
6460
6523
  effect(() => {
6461
- if (select._select.expanded) searchInput.focus({ preventScroll: true });
6462
- el.setAttribute("aria-expanded", select._select.expanded);
6524
+ if (select._h_select.expanded) searchInput.focus({ preventScroll: true });
6525
+ el.setAttribute("aria-expanded", select._h_select.expanded);
6463
6526
  });
6464
6527
  cleanup(() => {
6465
6528
  el.removeEventListener("click", handler2);
6466
6529
  el.removeEventListener("keydown", handler2);
6467
- if (select._select.filterType !== FilterType.none) searchInput.removeEventListener("keyup", onInput);
6530
+ if (select._h_select.filterType !== FilterType.none) searchInput.removeEventListener("keyup", onInput);
6468
6531
  });
6469
6532
  });
6470
6533
  Alpine.directive("h-select-group", (el, {}, { effect }) => {
6471
6534
  el.setAttribute("data-slot", "select-group");
6472
- el._selectGroup = Alpine.reactive({
6535
+ el._h_selectGroup = Alpine.reactive({
6473
6536
  labelledby: void 0
6474
6537
  });
6475
6538
  effect(() => {
6476
- if (el._selectGroup.labelledby) {
6477
- el.setAttribute("aria-labelledby", el._selectGroup.labelledby);
6539
+ if (el._h_selectGroup.labelledby) {
6540
+ el.setAttribute("aria-labelledby", el._h_selectGroup.labelledby);
6478
6541
  }
6479
6542
  });
6480
6543
  });
6481
6544
  Alpine.directive("h-select-label", (el) => {
6482
6545
  el.classList.add("text-muted-foreground", "px-2", "py-1.5", "text-xs");
6483
6546
  el.setAttribute("data-slot", "select-label");
6484
- const selectGroup = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_selectGroup"));
6547
+ const selectGroup = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_selectGroup"));
6485
6548
  if (selectGroup) {
6486
6549
  const id = `hsl${v4_default()}`;
6487
6550
  el.setAttribute("id", id);
6488
- selectGroup._selectGroup.labelledby = id;
6551
+ selectGroup._h_selectGroup.labelledby = id;
6489
6552
  }
6490
6553
  });
6491
6554
  Alpine.directive("h-select-option", (el, { expression }, { effect, evaluateLater, cleanup }) => {
6492
- const select = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_select"));
6555
+ const select = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
6493
6556
  if (!select) {
6494
6557
  throw new Error("h-select-option must be inside an h-select element");
6495
6558
  }
6496
6559
  el.classList.add(
6497
6560
  "focus:bg-primary",
6498
6561
  "focus:text-primary-foreground",
6499
- "hover:bg-primary",
6500
- "hover:text-primary-foreground",
6562
+ "hover:bg-secondary-hover",
6563
+ "hover:text-secondary-foreground",
6501
6564
  "[&_svg:not([class*='text-'])]:text-muted-foreground",
6502
6565
  "focus:[&_svg:not([class*='text-'])]:text-primary-foreground",
6503
- "hover:[&_svg:not([class*='text-'])]:text-primary-foreground",
6566
+ "hover:[&_svg:not([class*='text-'])]:text-secondary-foreground",
6504
6567
  "relative",
6505
6568
  "flex",
6506
6569
  "w-full",
6507
6570
  "cursor-default",
6508
6571
  "items-center",
6509
6572
  "gap-2",
6510
- "rounded-control",
6573
+ "rounded-sm",
6511
6574
  "py-1.5",
6512
6575
  "pr-8",
6513
6576
  "pl-2",
@@ -6544,26 +6607,26 @@
6544
6607
  const getLabel = evaluateLater(expression);
6545
6608
  effect(() => {
6546
6609
  getLabel((label) => {
6547
- if (select._select.multiple && select._select.model.includes(getValue())) {
6548
- select._select.label[select._select.label.indexOf(labelEl.innerText)] = label;
6549
- } else if (select._select.model === getValue()) {
6550
- select._select.label[0] = label;
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;
6551
6614
  }
6552
6615
  labelEl.innerText = label;
6553
6616
  });
6554
6617
  });
6555
6618
  effect(() => {
6556
- if (select._select.search) {
6557
- if (select._select.filterType === FilterType["starts-with"]) {
6558
- if (!labelEl.innerText.toLowerCase().startsWith(select._select.search)) {
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)) {
6559
6622
  el.classList.add("hidden");
6560
6623
  } else el.classList.remove("hidden");
6561
- } else if (select._select.filterType === FilterType.contains) {
6562
- if (!labelEl.innerText.toLowerCase().includes(select._select.search)) {
6624
+ } else if (select._h_select.filterType === FilterType.contains) {
6625
+ if (!labelEl.innerText.toLowerCase().includes(select._h_select.search)) {
6563
6626
  el.classList.add("hidden");
6564
6627
  } else el.classList.remove("hidden");
6565
- } else if (select._select.filterType === FilterType["contains-each"]) {
6566
- const terms = select._select.search.split(" ");
6628
+ } else if (select._h_select.filterType === FilterType["contains-each"]) {
6629
+ const terms = select._h_select.search.split(" ");
6567
6630
  const label = labelEl.innerText.toLowerCase();
6568
6631
  if (!terms.every((term) => label.includes(term))) el.classList.add("hidden");
6569
6632
  else el.classList.remove("hidden");
@@ -6576,11 +6639,11 @@
6576
6639
  if (selected) {
6577
6640
  indicatorEl.classList.remove("invisible");
6578
6641
  el.setAttribute("aria-selected", "true");
6579
- if (!select._select.label.length) {
6580
- select._select.label.push(labelEl.innerText);
6581
- } else if (!select._select.label.includes(labelEl.innerText)) {
6582
- if (select._select.multiple) select._select.label.push(labelEl.innerText);
6583
- else select._select.label[0] = labelEl.innerText;
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;
6584
6647
  }
6585
6648
  } else {
6586
6649
  indicatorEl.classList.add("invisible");
@@ -6588,30 +6651,30 @@
6588
6651
  }
6589
6652
  }
6590
6653
  function removeLabel() {
6591
- const lIndex = select._select.label.indexOf(labelEl.innerText);
6592
- if (lIndex > -1) select._select.label.splice(lIndex, 1);
6654
+ const lIndex = select._h_select.label.indexOf(labelEl.innerText);
6655
+ if (lIndex > -1) select._h_select.label.splice(lIndex, 1);
6593
6656
  }
6594
6657
  effect(() => {
6595
- if (select._select.multiple) {
6596
- setSelectedState(select._select.model.includes(getValue()));
6658
+ if (select._h_select.multiple) {
6659
+ setSelectedState(select._h_select.model.includes(getValue()));
6597
6660
  } else {
6598
- setSelectedState(select._select.model === getValue());
6661
+ setSelectedState(select._h_select.model === getValue());
6599
6662
  }
6600
6663
  });
6601
6664
  const handler2 = (event) => {
6602
6665
  if (event.type === "keydown" && event.key === "Enter" || event.type === "click") {
6603
- if (select._select.multiple) {
6604
- const vIndex = select._select.model.indexOf(getValue());
6666
+ if (select._h_select.multiple) {
6667
+ const vIndex = select._h_select.model.indexOf(getValue());
6605
6668
  if (vIndex > -1) {
6606
- select._select.model.splice(vIndex, 1);
6669
+ select._h_select.model.splice(vIndex, 1);
6607
6670
  removeLabel();
6608
6671
  } else {
6609
- select._select.model.push(getValue());
6672
+ select._h_select.model.push(getValue());
6610
6673
  }
6611
- } else if (select._select.model !== getValue()) {
6612
- select._select.model = getValue();
6674
+ } else if (select._h_select.model !== getValue()) {
6675
+ select._h_select.model = getValue();
6613
6676
  } else {
6614
- select._select.model = "";
6677
+ select._h_select.model = "";
6615
6678
  removeLabel();
6616
6679
  }
6617
6680
  }
@@ -6651,6 +6714,61 @@
6651
6714
  });
6652
6715
  }
6653
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
+
6654
6772
  // src/components/sidebar.js
6655
6773
  function sidebar_default(Alpine) {
6656
6774
  Alpine.directive("h-sidebar", (el, { modifiers }, { cleanup }) => {
@@ -6667,15 +6785,11 @@
6667
6785
  };
6668
6786
  setFloating();
6669
6787
  const observer = new MutationObserver((mutations) => {
6670
- mutations.forEach((mutation) => {
6671
- if (mutation.type === "attributes") {
6672
- if (mutation.attributeName === "data-floating") {
6673
- setFloating();
6674
- }
6675
- }
6788
+ mutations.forEach(() => {
6789
+ setFloating();
6676
6790
  });
6677
6791
  });
6678
- observer.observe(el, { attributes: true });
6792
+ observer.observe(el, { attributes: true, attributeFilter: ["data-floating"] });
6679
6793
  cleanup(() => {
6680
6794
  observer.disconnect();
6681
6795
  });
@@ -6962,10 +7076,21 @@
6962
7076
  el.classList.add("bg-secondary", "animate-pulse");
6963
7077
  if (modifiers.includes("control")) {
6964
7078
  el.classList.add("rounded-control");
7079
+ switch (el.getAttribute("data-size")) {
7080
+ case "xs":
7081
+ el.classList.add("h-6.5");
7082
+ break;
7083
+ case "sm":
7084
+ el.classList.add("h-8");
7085
+ break;
7086
+ default:
7087
+ el.classList.add("h-9");
7088
+ break;
7089
+ }
6965
7090
  } else if (modifiers.includes("card")) {
6966
7091
  el.classList.add("rounded-lg");
6967
7092
  } else if (modifiers.includes("avatar")) {
6968
- el.classList.add("rounded-full", "size-8");
7093
+ el.classList.add("rounded-full", "size-8", "aspect-square");
6969
7094
  } else el.classList.add("rounded-md");
6970
7095
  el.setAttribute("data-slot", "skeleton");
6971
7096
  });
@@ -7005,7 +7130,7 @@
7005
7130
  "before:pointer-events-none",
7006
7131
  "before:ring-0",
7007
7132
  "before:rounded-full",
7008
- "before:shadow-control",
7133
+ "before:shadow-input",
7009
7134
  "before:size-5",
7010
7135
  "before:transition-transform",
7011
7136
  "bg-muted",
@@ -7037,7 +7162,7 @@
7037
7162
  function table_default(Alpine) {
7038
7163
  Alpine.directive("h-table-container", (el, { modifiers }) => {
7039
7164
  if (modifiers.includes("scroll")) {
7040
- el.classList.add("overflow-scroll", "[&_thead]:sticky", "[&_thead]:top-0", "[&_thead]:z-10", "[&_tfoot]:sticky", "[&_tfoot]:bottom-0", "[&_tfoot]:z-10", "[&_tbody_tr_th]:sticky", "[&_tbody_tr_th]:left-0", "[&_tbody_tr_th]:z-5");
7165
+ 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");
7041
7166
  } else {
7042
7167
  el.classList.add("relative", "w-full", "overflow-x-auto");
7043
7168
  }
@@ -7158,6 +7283,7 @@
7158
7283
  "[&:not([data-floating=true])]:data-[size=lg]:group-data-[orientation=horizontal]/tabs:min-h-12",
7159
7284
  "data-[floating=true]:border",
7160
7285
  "data-[floating=true]:shadow-xs",
7286
+ "data-[floating=true]:z-1",
7161
7287
  "data-[floating=true]:rounded-lg",
7162
7288
  "data-[floating=true]:p-[0.188rem]"
7163
7289
  );
@@ -7328,8 +7454,11 @@
7328
7454
  case "blockquote":
7329
7455
  el.classList.add("mt-6", "border-l-2", "pl-6", "italic");
7330
7456
  break;
7457
+ case "code-inline":
7458
+ el.classList.add("bg-muted", "relative", "rounded", "px-[0.3rem]", "py-[0.2rem]", "font-mono", "text-sm", "font-semibold", "whitespace-pre");
7459
+ break;
7331
7460
  case "code":
7332
- el.classList.add("bg-muted", "relative", "rounded", "px-[0.3rem]", "py-[0.2rem]", "font-mono", "text-sm", "font-semibold");
7461
+ el.classList.add("bg-muted", "relative", "rounded", "p-3", "font-mono", "text-sm", "font-semibold", "whitespace-pre");
7333
7462
  break;
7334
7463
  case "lead":
7335
7464
  el.classList.add("text-muted-foreground", "text-xl");
@@ -7363,9 +7492,9 @@
7363
7492
  "aria-invalid:ring-negative/20",
7364
7493
  "dark:aria-invalid:ring-negative/40",
7365
7494
  "aria-invalid:border-negative",
7366
- "invalid:ring-negative/20",
7367
- "dark:invalid:ring-negative/40",
7368
- "invalid:border-negative",
7495
+ "invalid:!ring-negative/20",
7496
+ "dark:invalid:!ring-negative/40",
7497
+ "invalid:!border-negative",
7369
7498
  "bg-input-inner",
7370
7499
  "flex",
7371
7500
  "field-sizing-content",
@@ -7376,7 +7505,7 @@
7376
7505
  "px-3",
7377
7506
  "py-2",
7378
7507
  "text-base",
7379
- "shadow-control",
7508
+ "shadow-input",
7380
7509
  "transition-[color,box-shadow]",
7381
7510
  "outline-none",
7382
7511
  "focus-visible:ring-[3px]",
@@ -7385,7 +7514,7 @@
7385
7514
  "md:text-sm"
7386
7515
  );
7387
7516
  if (modifiers.includes("group")) {
7388
- el.classList.remove("rounded-control", "border", "bg-input-inner", "py-2", "shadow-control", "focus-visible:ring-[3px]");
7517
+ el.classList.remove("rounded-control", "border", "bg-input-inner", "py-2", "shadow-input", "focus-visible:ring-[3px]");
7389
7518
  el.classList.add("flex-1", "resize-none", "rounded-none", "border-0", "bg-transparent", "py-3", "shadow-none", "focus-visible:ring-0");
7390
7519
  el.setAttribute("data-slot", "input-group-control");
7391
7520
  } else el.setAttribute("data-slot", "textarea");
@@ -7525,7 +7654,7 @@
7525
7654
  };
7526
7655
  function timepicker_default(Alpine) {
7527
7656
  Alpine.directive("h-time-picker", (el, { expression }, { evaluateLater, cleanup, effect, Alpine: Alpine2 }) => {
7528
- el._timepicker = Alpine2.reactive({
7657
+ el._h_timepicker = Alpine2.reactive({
7529
7658
  id: void 0,
7530
7659
  controls: `htpc${v4_default()}`,
7531
7660
  model: void 0,
@@ -7534,8 +7663,8 @@
7534
7663
  locale: void 0,
7535
7664
  seconds: void 0,
7536
7665
  close() {
7537
- el._timepicker.expanded = false;
7538
- top.removeEventListener("click", el._timepicker.close);
7666
+ el._h_timepicker.expanded = false;
7667
+ top.removeEventListener("click", el._h_timepicker.close);
7539
7668
  }
7540
7669
  });
7541
7670
  el._time = {
@@ -7575,7 +7704,7 @@
7575
7704
  "pr-2",
7576
7705
  "text-sm",
7577
7706
  "whitespace-nowrap",
7578
- "shadow-control",
7707
+ "shadow-input",
7579
7708
  "transition-[color,box-shadow]",
7580
7709
  "duration-200",
7581
7710
  "outline-none",
@@ -7602,28 +7731,28 @@
7602
7731
  effect(() => {
7603
7732
  getConfig((config) => {
7604
7733
  if (config) {
7605
- if (config["locale"]) el._timepicker.locale = config.locale;
7606
- el._timepicker.seconds = config["seconds"];
7734
+ if (config["locale"]) el._h_timepicker.locale = config.locale;
7735
+ el._h_timepicker.seconds = config["seconds"];
7607
7736
  if (config["is12Hour"] !== void 0) {
7608
- el._timepicker.is12Hour = config.is12Hour;
7737
+ el._h_timepicker.is12Hour = config.is12Hour;
7609
7738
  } else {
7610
- el._timepicker.is12Hour = new Intl.DateTimeFormat(el._timepicker.locale, { hour: "numeric" }).resolvedOptions().hour12;
7739
+ el._h_timepicker.is12Hour = new Intl.DateTimeFormat(el._h_timepicker.locale, { hour: "numeric" }).resolvedOptions().hour12;
7611
7740
  }
7612
7741
  }
7613
7742
  });
7614
7743
  });
7615
7744
  } else {
7616
- el._timepicker.is12Hour = new Intl.DateTimeFormat(el._timepicker.locale, { hour: "numeric" }).resolvedOptions().hour12;
7745
+ el._h_timepicker.is12Hour = new Intl.DateTimeFormat(el._h_timepicker.locale, { hour: "numeric" }).resolvedOptions().hour12;
7617
7746
  }
7618
7747
  const handler2 = (event) => {
7619
7748
  if (event.type === "keydown" && event.key !== "Enter") return;
7620
- el._timepicker.expanded = !el._timepicker.expanded;
7621
- el.setAttribute("aria-expanded", el._timepicker.expanded);
7749
+ el._h_timepicker.expanded = !el._h_timepicker.expanded;
7750
+ el.setAttribute("aria-expanded", el._h_timepicker.expanded);
7622
7751
  Alpine2.nextTick(() => {
7623
- if (el._timepicker.expanded) {
7624
- top.addEventListener("click", el._timepicker.close);
7752
+ if (el._h_timepicker.expanded) {
7753
+ top.addEventListener("click", el._h_timepicker.close);
7625
7754
  } else {
7626
- top.removeEventListener("click", el._timepicker.close);
7755
+ top.removeEventListener("click", el._h_timepicker.close);
7627
7756
  }
7628
7757
  });
7629
7758
  };
@@ -7632,14 +7761,14 @@
7632
7761
  cleanup(() => {
7633
7762
  el.removeEventListener("click", handler2);
7634
7763
  el.removeEventListener("keydown", handler2);
7635
- top.removeEventListener("click", el._timepicker.close);
7764
+ top.removeEventListener("click", el._h_timepicker.close);
7636
7765
  });
7637
7766
  });
7638
7767
  Alpine.directive("h-time-picker-input", (el, {}, { effect, Alpine: Alpine2 }) => {
7639
7768
  if (el.tagName !== "INPUT") {
7640
7769
  throw new Error("h-time-picker-input must be a readonly input of type text");
7641
7770
  }
7642
- const timepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_timepicker"));
7771
+ const timepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_timepicker"));
7643
7772
  if (!timepicker) {
7644
7773
  throw new Error("h-time-picker-input must be inside an h-time-picker element");
7645
7774
  }
@@ -7649,9 +7778,9 @@
7649
7778
  });
7650
7779
  };
7651
7780
  if (el.hasOwnProperty("_x_model")) {
7652
- timepicker._timepicker.model = el._x_model;
7781
+ timepicker._h_timepicker.model = el._x_model;
7653
7782
  } else {
7654
- timepicker._timepicker.model = {
7783
+ timepicker._h_timepicker.model = {
7655
7784
  get() {
7656
7785
  return el.value;
7657
7786
  },
@@ -7661,62 +7790,62 @@
7661
7790
  };
7662
7791
  }
7663
7792
  if (el.hasAttribute("id")) {
7664
- timepicker._timepicker.id = el.getAttribute("id");
7793
+ timepicker._h_timepicker.id = el.getAttribute("id");
7665
7794
  } else {
7666
- timepicker._timepicker.id = `htp${v4_default()}`;
7667
- el.setAttribute("id", timepicker._timepicker.id);
7795
+ timepicker._h_timepicker.id = `htp${v4_default()}`;
7796
+ el.setAttribute("id", timepicker._h_timepicker.id);
7668
7797
  }
7669
7798
  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");
7670
7799
  el.readOnly = true;
7671
7800
  el.setAttribute("aria-autocomplete", "none");
7672
- el.setAttribute("aria-controls", timepicker._timepicker.controls);
7801
+ el.setAttribute("aria-controls", timepicker._h_timepicker.controls);
7673
7802
  el.setAttribute("aria-expanded", "false");
7674
7803
  el.setAttribute("aria-haspopup", "dialog");
7675
7804
  el.setAttribute("type", "text");
7676
7805
  el.setAttribute("data-slot", "time-picker-input");
7677
- const rawTime = timepicker._timepicker.model.get();
7806
+ const rawTime = timepicker._h_timepicker.model.get();
7678
7807
  if (rawTime) {
7679
- const { hour, minute, second, period } = getSelectedTime(rawTime, timepicker._timepicker.is12Hour);
7680
- if (timepicker._timepicker.seconds === void 0 && !second) {
7681
- timepicker._timepicker.seconds = false;
7682
- } else if (timepicker._timepicker.seconds === void 0 && second) {
7683
- timepicker._timepicker.seconds = true;
7684
- }
7685
- if (timepicker._timepicker.is12Hour) {
7686
- if (timepicker._timepicker.seconds) {
7687
- timepicker._timepicker.model.set(`${hour}:${minute}:${second ?? "00"} ${period}`);
7808
+ const { hour, minute, second, period } = getSelectedTime(rawTime, timepicker._h_timepicker.is12Hour);
7809
+ if (timepicker._h_timepicker.seconds === void 0 && !second) {
7810
+ timepicker._h_timepicker.seconds = false;
7811
+ } else if (timepicker._h_timepicker.seconds === void 0 && second) {
7812
+ timepicker._h_timepicker.seconds = true;
7813
+ }
7814
+ if (timepicker._h_timepicker.is12Hour) {
7815
+ if (timepicker._h_timepicker.seconds) {
7816
+ timepicker._h_timepicker.model.set(`${hour}:${minute}:${second ?? "00"} ${period}`);
7688
7817
  timepicker._time.parts.second = second ?? "00";
7689
7818
  } else {
7690
- timepicker._timepicker.model.set(`${hour}:${minute} ${period}`);
7819
+ timepicker._h_timepicker.model.set(`${hour}:${minute} ${period}`);
7691
7820
  }
7692
7821
  timepicker._time.parts.hour = hour;
7693
7822
  timepicker._time.parts.minute = minute;
7694
7823
  timepicker._time.parts.period = period;
7695
7824
  } else {
7696
- if (timepicker._timepicker.seconds) {
7697
- timepicker._timepicker.model.set(`${hour}:${minute}:${second ?? "00"}`);
7825
+ if (timepicker._h_timepicker.seconds) {
7826
+ timepicker._h_timepicker.model.set(`${hour}:${minute}:${second ?? "00"}`);
7698
7827
  timepicker._time.parts.second = second ?? "00";
7699
7828
  } else {
7700
- timepicker._timepicker.model.set(`${hour}:${minute}`);
7829
+ timepicker._h_timepicker.model.set(`${hour}:${minute}`);
7701
7830
  }
7702
7831
  timepicker._time.parts.hour = hour;
7703
7832
  timepicker._time.parts.minute = minute;
7704
7833
  }
7705
7834
  }
7706
7835
  let placeholder;
7707
- if (timepicker._timepicker.seconds) {
7708
- placeholder = timepicker._timepicker.is12Hour ? "--:--:-- --" : "--:--:--";
7836
+ if (timepicker._h_timepicker.seconds) {
7837
+ placeholder = timepicker._h_timepicker.is12Hour ? "--:--:-- --" : "--:--:--";
7709
7838
  } else {
7710
- placeholder = timepicker._timepicker.is12Hour ? "--:-- --" : "--:--";
7839
+ placeholder = timepicker._h_timepicker.is12Hour ? "--:-- --" : "--:--";
7711
7840
  }
7712
7841
  el.setAttribute("placeholder", placeholder);
7713
7842
  effect(() => {
7714
- el.setAttribute("data-state", timepicker._timepicker.expanded ? "open" : "closed");
7715
- el.setAttribute("aria-expanded", timepicker._timepicker.expanded);
7843
+ el.setAttribute("data-state", timepicker._h_timepicker.expanded ? "open" : "closed");
7844
+ el.setAttribute("aria-expanded", timepicker._h_timepicker.expanded);
7716
7845
  });
7717
7846
  }).before("h-button");
7718
7847
  Alpine.directive("h-time-picker-popup", (el, {}, { effect, cleanup, Alpine: Alpine2 }) => {
7719
- const timepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_timepicker"));
7848
+ const timepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_timepicker"));
7720
7849
  el.classList.add(
7721
7850
  "overflow-hidden",
7722
7851
  "outline-none",
@@ -7735,8 +7864,8 @@
7735
7864
  el.setAttribute("role", "dialog");
7736
7865
  el.setAttribute("aria-modal", "true");
7737
7866
  el.setAttribute("data-slot", "time-picker-popup");
7738
- el.setAttribute("aria-labelledby", timepicker._timepicker.id);
7739
- el.setAttribute("data-state", timepicker._timepicker.expanded ? "open" : "closed");
7867
+ el.setAttribute("aria-labelledby", timepicker._h_timepicker.id);
7868
+ el.setAttribute("data-state", timepicker._h_timepicker.expanded ? "open" : "closed");
7740
7869
  const optionClasses = [
7741
7870
  "px-3.5",
7742
7871
  "py-2",
@@ -7758,7 +7887,7 @@
7758
7887
  const updateModel = () => {
7759
7888
  let newValue;
7760
7889
  if (timepicker._time.parts.hour !== null && timepicker._time.parts.minute !== null) {
7761
- if (timepicker._timepicker.seconds) {
7890
+ if (timepicker._h_timepicker.seconds) {
7762
7891
  if (timepicker._time.parts.seconds !== null) {
7763
7892
  newValue = `${timepicker._time.parts.hour}:${timepicker._time.parts.minute}:${timepicker._time.parts.second}`;
7764
7893
  } else return;
@@ -7766,13 +7895,13 @@
7766
7895
  newValue = `${timepicker._time.parts.hour}:${timepicker._time.parts.minute}`;
7767
7896
  }
7768
7897
  } else return;
7769
- if (timepicker._timepicker.is12Hour) {
7898
+ if (timepicker._h_timepicker.is12Hour) {
7770
7899
  if (timepicker._time.parts.period !== null) {
7771
7900
  newValue += ` ${timepicker._time.parts.period}`;
7772
7901
  } else return;
7773
7902
  }
7774
7903
  if (newValue) {
7775
- timepicker._timepicker.model.set(newValue);
7904
+ timepicker._h_timepicker.model.set(newValue);
7776
7905
  timepicker._time.changed();
7777
7906
  }
7778
7907
  };
@@ -7780,22 +7909,22 @@
7780
7909
  let date = /* @__PURE__ */ new Date();
7781
7910
  let hour = date.getHours();
7782
7911
  timepicker._time.parts.period = hour >= 12 ? dayPeriodLabels.pm : dayPeriodLabels.am;
7783
- if (timepicker._timepicker.is12Hour) {
7912
+ if (timepicker._h_timepicker.is12Hour) {
7784
7913
  hour = date.getHours() % 12 || 12;
7785
7914
  }
7786
7915
  let minute = date.getMinutes();
7787
7916
  timepicker._time.parts.hour = hour < 10 ? `0${hour}` : hour.toString();
7788
7917
  timepicker._time.parts.minute = minute < 10 ? `0${minute}` : minute.toString();
7789
- if (timepicker._timepicker.seconds) {
7918
+ if (timepicker._h_timepicker.seconds) {
7790
7919
  let second = date.getSeconds();
7791
7920
  timepicker._time.parts.second = second < 10 ? `0${second}` : second.toString();
7792
7921
  }
7793
7922
  updateModel();
7794
- timepicker._timepicker.close();
7923
+ timepicker._h_timepicker.close();
7795
7924
  };
7796
7925
  function onKeyDown(event) {
7797
7926
  if (event.key === "Escape") {
7798
- timepicker._timepicker.close();
7927
+ timepicker._h_timepicker.close();
7799
7928
  } else if (event.target.tagName === "LI") {
7800
7929
  let list;
7801
7930
  let inHoursList = event.target.parentElement.dataset.type === "hours";
@@ -7813,7 +7942,7 @@
7813
7942
  event.target.setAttribute("tabindex", "-1");
7814
7943
  let prevElem = event.target.previousElementSibling;
7815
7944
  if (prevElem === null || prevElem.classList.contains("hidden")) {
7816
- if (inHoursList && timepicker._timepicker.is12Hour) {
7945
+ if (inHoursList && timepicker._h_timepicker.is12Hour) {
7817
7946
  prevElem = list.children[12];
7818
7947
  } else {
7819
7948
  prevElem = list.lastChild;
@@ -7826,7 +7955,7 @@
7826
7955
  event.target.setAttribute("tabindex", "-1");
7827
7956
  let nextElem = event.target.nextElementSibling;
7828
7957
  if (nextElem === null || nextElem.classList.contains("hidden")) {
7829
- if (inHoursList && timepicker._timepicker.is12Hour) {
7958
+ if (inHoursList && timepicker._h_timepicker.is12Hour) {
7830
7959
  nextElem = list.children[1];
7831
7960
  } else {
7832
7961
  nextElem = list.firstChild;
@@ -7849,7 +7978,7 @@
7849
7978
  if (selectedHour) {
7850
7979
  selectedHour.focus();
7851
7980
  } else {
7852
- hoursList.children[timepicker._timepicker.is12Hour ? 1 : 0].focus();
7981
+ hoursList.children[timepicker._h_timepicker.is12Hour ? 1 : 0].focus();
7853
7982
  }
7854
7983
  event.stopPropagation();
7855
7984
  event.preventDefault();
@@ -7914,7 +8043,7 @@
7914
8043
  }
7915
8044
  const secondsList = document.createElement("ul");
7916
8045
  secondsList.classList.add("flex-1", "overflow-y-scroll", "[scrollbar-width:thin]");
7917
- if (!timepicker._timepicker.seconds) {
8046
+ if (!timepicker._h_timepicker.seconds) {
7918
8047
  secondsList.classList.add("hidden");
7919
8048
  }
7920
8049
  secondsList.setAttribute("role", "listbox");
@@ -7934,7 +8063,7 @@
7934
8063
  }
7935
8064
  const periodList = document.createElement("ul");
7936
8065
  periodList.classList.add("flex-1", "overflow-y-scroll", "[scrollbar-width:thin]");
7937
- if (!timepicker._timepicker.is12Hour) {
8066
+ if (!timepicker._h_timepicker.is12Hour) {
7938
8067
  periodList.classList.add("hidden");
7939
8068
  }
7940
8069
  periodList.setAttribute("role", "listbox");
@@ -7973,7 +8102,7 @@
7973
8102
  okButton.setAttribute("data-action", "close");
7974
8103
  okButton.innerText = el.dataset.labelOk ?? "OK";
7975
8104
  okButton.disabled = true;
7976
- okButton.addEventListener("click", timepicker._timepicker.close);
8105
+ okButton.addEventListener("click", timepicker._h_timepicker.close);
7977
8106
  footer.appendChild(okButton);
7978
8107
  el.appendChild(footer);
7979
8108
  Alpine2.initTree(footer);
@@ -7982,7 +8111,7 @@
7982
8111
  let selectedSecond;
7983
8112
  let selectedPeriod;
7984
8113
  function render() {
7985
- if (timepicker._timepicker.is12Hour) {
8114
+ if (timepicker._h_timepicker.is12Hour) {
7986
8115
  hoursList.firstChild.classList.add("hidden");
7987
8116
  for (let h = 1; h < 13; h++) {
7988
8117
  if (hoursList.children[h].innerText === timepicker._time.parts.hour) {
@@ -8013,7 +8142,7 @@
8013
8142
  }
8014
8143
  }
8015
8144
  if (!selectedHour) {
8016
- hoursList.children[timepicker._timepicker.is12Hour ? 1 : 0].setAttribute("tabindex", "0");
8145
+ hoursList.children[timepicker._h_timepicker.is12Hour ? 1 : 0].setAttribute("tabindex", "0");
8017
8146
  }
8018
8147
  for (let m = 0; m < minutesList.children.length; m++) {
8019
8148
  if (minutesList.children[m].innerText === timepicker._time.parts.minute) {
@@ -8028,7 +8157,7 @@
8028
8157
  if (!selectedMinute) {
8029
8158
  minutesList.firstChild.setAttribute("tabindex", "0");
8030
8159
  }
8031
- if (timepicker._timepicker.seconds) {
8160
+ if (timepicker._h_timepicker.seconds) {
8032
8161
  secondsList.classList.remove("hidden");
8033
8162
  for (let s = 0; s < secondsList.children.length; s++) {
8034
8163
  if (secondsList.children[s].innerText === timepicker._time.parts.second) {
@@ -8043,20 +8172,20 @@
8043
8172
  if (!selectedSecond) {
8044
8173
  secondsList.firstChild.setAttribute("tabindex", "0");
8045
8174
  }
8046
- if (timepicker._timepicker.is12Hour) {
8175
+ if (timepicker._h_timepicker.is12Hour) {
8047
8176
  okButton.disabled = timepicker._time.parts.hour && timepicker._time.parts.minute && timepicker._time.parts.second && timepicker._time.parts.period ? false : true;
8048
8177
  } else {
8049
8178
  okButton.disabled = timepicker._time.parts.hour && timepicker._time.parts.minute && timepicker._time.parts.second ? false : true;
8050
8179
  }
8051
8180
  } else {
8052
8181
  secondsList.classList.add("hidden");
8053
- if (timepicker._timepicker.is12Hour) {
8182
+ if (timepicker._h_timepicker.is12Hour) {
8054
8183
  okButton.disabled = timepicker._time.parts.hour && timepicker._time.parts.minute && timepicker._time.parts.period ? false : true;
8055
8184
  } else {
8056
8185
  okButton.disabled = timepicker._time.parts.hour && timepicker._time.parts.minute ? false : true;
8057
8186
  }
8058
8187
  }
8059
- if (timepicker._timepicker.is12Hour) {
8188
+ if (timepicker._h_timepicker.is12Hour) {
8060
8189
  periodList.classList.remove("hidden");
8061
8190
  for (let p = 0; p < periodList.children.length; p++) {
8062
8191
  if (periodList.children[p].innerText === timepicker._time.parts.period) {
@@ -8089,7 +8218,7 @@
8089
8218
  if (selectedHour) {
8090
8219
  selectedHour.focus();
8091
8220
  } else {
8092
- hoursList.children[timepicker._timepicker.is12Hour ? 1 : 0].focus();
8221
+ hoursList.children[timepicker._h_timepicker.is12Hour ? 1 : 0].focus();
8093
8222
  }
8094
8223
  Object.assign(el.style, {
8095
8224
  left: `${x}px`,
@@ -8098,13 +8227,13 @@
8098
8227
  });
8099
8228
  }
8100
8229
  effect(() => {
8101
- el.setAttribute("data-state", timepicker._timepicker.expanded ? "open" : "closed");
8102
- if (timepicker._timepicker.expanded) {
8230
+ el.setAttribute("data-state", timepicker._h_timepicker.expanded ? "open" : "closed");
8231
+ if (timepicker._h_timepicker.expanded) {
8103
8232
  render();
8104
8233
  autoUpdateCleanup = autoUpdate(timepicker, el, updatePosition);
8105
8234
  if (selectedHour) selectedHour.scrollIntoView({ block: "center" });
8106
8235
  if (selectedMinute) selectedMinute.scrollIntoView({ block: "center" });
8107
- if (selectedSecond && timepicker._timepicker.seconds) selectedSecond.scrollIntoView({ block: "center" });
8236
+ if (selectedSecond && timepicker._h_timepicker.seconds) selectedSecond.scrollIntoView({ block: "center" });
8108
8237
  } else {
8109
8238
  if (autoUpdateCleanup) autoUpdateCleanup();
8110
8239
  Object.assign(el.style, {
@@ -8116,7 +8245,7 @@
8116
8245
  cleanup(() => {
8117
8246
  el.removeEventListener("keydown", onKeyDown);
8118
8247
  el.removeEventListener("click", onClick);
8119
- okButton.removeEventListener("click", timepicker._timepicker.close);
8248
+ okButton.removeEventListener("click", timepicker._h_timepicker.close);
8120
8249
  for (let h = 0; h < hoursList.children.length; h++) {
8121
8250
  hoursList.children[h].removeEventListener("click", setHour);
8122
8251
  }
@@ -8150,6 +8279,7 @@
8150
8279
  "w-full",
8151
8280
  "h-12",
8152
8281
  "data-[size=sm]:h-8",
8282
+ "data-[size=md]:h-10",
8153
8283
  "data-[variant=transparent]:bg-transparent",
8154
8284
  "data-[variant=transparent]:text-foreground",
8155
8285
  "data-[floating=true]:shadow-xs",
@@ -8159,11 +8289,11 @@
8159
8289
  el.setAttribute("data-slot", "toolbar");
8160
8290
  });
8161
8291
  Alpine.directive("h-toolbar-image", (el) => {
8162
- el.classList.add("size-8", "[[data-size=sm]_&]:size-6");
8292
+ el.classList.add("size-8", "[[data-size=md]_&]:size-7", "[[data-size=sm]_&]:size-6");
8163
8293
  el.setAttribute("data-slot", "toolbar-image");
8164
8294
  });
8165
8295
  Alpine.directive("h-toolbar-title", (el) => {
8166
- el.classList.add("text", "[[data-size=sm]_&]:text-sm", "first:pl-2", "font-medium", "whitespace-nowrap", "text-ellipsis", "overflow-hidden");
8296
+ el.classList.add("text", "[[data-size=sm]_&]:text-sm", "[[data-size=md]_&]:text-sm", "first:pl-2", "font-medium", "whitespace-nowrap", "text-ellipsis", "overflow-hidden");
8167
8297
  el.setAttribute("data-slot", "toolbar-title");
8168
8298
  });
8169
8299
  Alpine.directive("h-toolbar-spacer", (el) => {
@@ -8172,7 +8302,7 @@
8172
8302
  el.setAttribute("data-slot", "toolbar-spacer");
8173
8303
  });
8174
8304
  Alpine.directive("h-toolbar-separator", (el) => {
8175
- el.classList.add("w-px", "h-8", "[[data-size=sm]_&]:h-6", "border-l");
8305
+ el.classList.add("w-px", "h-8", "[[data-size=md]_&]:h-6", "[[data-size=sm]_&]:h-6", "border-l");
8176
8306
  el.setAttribute("data-slot", "toolbar-separator");
8177
8307
  });
8178
8308
  }
@@ -8305,11 +8435,40 @@
8305
8435
  };
8306
8436
  initColorScheme();
8307
8437
 
8438
+ // src/utils/breakpoint-listener.js
8439
+ function getBreakpointListener(handler2, breakpoint = 768) {
8440
+ const mql = top.matchMedia(`(width <= ${breakpoint}px)`);
8441
+ const onWidthChange = (event) => {
8442
+ handler2(event.matches);
8443
+ };
8444
+ mql.addEventListener("change", onWidthChange);
8445
+ handler2(mql.matches);
8446
+ return {
8447
+ _mql: mql,
8448
+ _onWidthChange: onWidthChange,
8449
+ remove() {
8450
+ this._mql.removeEventListener("change", this._onWidthChange);
8451
+ }
8452
+ };
8453
+ }
8454
+
8455
+ // src/utils/focus.js
8456
+ function focus_default(Alpine) {
8457
+ Alpine.directive("h-focus", (el, { expression }, { effect, evaluateLater }) => {
8458
+ const getValue = evaluateLater(expression);
8459
+ effect(() => {
8460
+ getValue((val) => {
8461
+ if (val) el.focus();
8462
+ });
8463
+ });
8464
+ });
8465
+ }
8466
+
8308
8467
  // package.json
8309
- var version = "0.4.0";
8468
+ var version = "0.6.0";
8310
8469
 
8311
8470
  // src/index.js
8312
- window.Harmonia = { getColorScheme, setColorScheme, version };
8471
+ window.Harmonia = { getBreakpointListener, getColorScheme, setColorScheme, version };
8313
8472
  document.addEventListener("alpine:init", () => {
8314
8473
  window.Alpine.plugin(accordion_default);
8315
8474
  window.Alpine.plugin(alert_default);
@@ -8336,6 +8495,7 @@
8336
8495
  window.Alpine.plugin(range_default);
8337
8496
  window.Alpine.plugin(select_default);
8338
8497
  window.Alpine.plugin(separator_default);
8498
+ window.Alpine.plugin(sheet_default);
8339
8499
  window.Alpine.plugin(sidebar_default);
8340
8500
  window.Alpine.plugin(skeleton_default);
8341
8501
  window.Alpine.plugin(spinner_default);
@@ -8349,6 +8509,7 @@
8349
8509
  window.Alpine.plugin(timepicker_default);
8350
8510
  window.Alpine.plugin(toolbar_default);
8351
8511
  window.Alpine.plugin(tooltip_default);
8512
+ window.Alpine.plugin(focus_default);
8352
8513
  });
8353
8514
  })();
8354
8515
  /*! Bundled license information: