@codbex/harmonia 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/harmonia.css +1 -1
- package/dist/harmonia.esm.js +40 -14
- package/dist/harmonia.esm.min.js +3 -3
- package/dist/harmonia.esm.min.js.map +3 -3
- package/dist/harmonia.js +40 -14
- package/dist/harmonia.min.js +2 -2
- package/dist/harmonia.min.js.map +3 -3
- package/package.json +1 -1
package/dist/harmonia.js
CHANGED
|
@@ -2181,7 +2181,7 @@
|
|
|
2181
2181
|
el.classList.add("border", "rounded-control", "gap-2", "p-2");
|
|
2182
2182
|
el.setAttribute("tabindex", "-1");
|
|
2183
2183
|
if (datepicker) {
|
|
2184
|
-
el.classList.add("
|
|
2184
|
+
el.classList.add("absolute", "bg-popover", "text-popover-foreground", "data-[state=open]:flex", "data-[state=open]:flex-col", "data-[state=closed]:hidden", "z-50", "shadow-md");
|
|
2185
2185
|
el.setAttribute("role", "dialog");
|
|
2186
2186
|
el.setAttribute("aria-modal", "true");
|
|
2187
2187
|
el.setAttribute("data-slot", "date-picker-calendar");
|
|
@@ -2611,7 +2611,6 @@
|
|
|
2611
2611
|
function updatePosition() {
|
|
2612
2612
|
computePosition2(datepicker, el, {
|
|
2613
2613
|
placement: el.getAttribute("data-align") || "bottom-start",
|
|
2614
|
-
strategy: "fixed",
|
|
2615
2614
|
middleware: [offset2(4), flip2(), shift2({ padding: 4 })]
|
|
2616
2615
|
}).then(({ x, y }) => {
|
|
2617
2616
|
Object.assign(el.style, {
|
|
@@ -2836,7 +2835,19 @@
|
|
|
2836
2835
|
"dark:has-[input:invalid]:ring-negative/40"
|
|
2837
2836
|
);
|
|
2838
2837
|
el.setAttribute("data-slot", "date-picker");
|
|
2839
|
-
el._h_datepicker.input.classList.add(
|
|
2838
|
+
el._h_datepicker.input.classList.add(
|
|
2839
|
+
"bg-transparent",
|
|
2840
|
+
"outline-none",
|
|
2841
|
+
"flex-1",
|
|
2842
|
+
"h-full",
|
|
2843
|
+
"border-0",
|
|
2844
|
+
"focus-visible:ring-0",
|
|
2845
|
+
"disabled:pointer-events-none",
|
|
2846
|
+
"disabled:cursor-not-allowed",
|
|
2847
|
+
"disabled:opacity-50",
|
|
2848
|
+
"md:text-sm",
|
|
2849
|
+
"text-base"
|
|
2850
|
+
);
|
|
2840
2851
|
el._h_datepicker.input.setAttribute("aria-autocomplete", "none");
|
|
2841
2852
|
el._h_datepicker.input.setAttribute("type", "text");
|
|
2842
2853
|
});
|
|
@@ -7893,6 +7904,15 @@
|
|
|
7893
7904
|
}
|
|
7894
7905
|
return { hour, minute, second, period };
|
|
7895
7906
|
};
|
|
7907
|
+
function scrollIntoCenter(container, element, behavior = "instant") {
|
|
7908
|
+
const containerRect = container.getBoundingClientRect();
|
|
7909
|
+
const elementRect = element.getBoundingClientRect();
|
|
7910
|
+
const offset4 = elementRect.top - containerRect.top - container.clientHeight / 2 + element.clientHeight / 2;
|
|
7911
|
+
container.scrollBy({
|
|
7912
|
+
top: offset4,
|
|
7913
|
+
behavior
|
|
7914
|
+
});
|
|
7915
|
+
}
|
|
7896
7916
|
function timepicker_default(Alpine) {
|
|
7897
7917
|
Alpine.directive("h-time-picker", (el, { expression }, { evaluateLater, cleanup, effect, Alpine: Alpine2 }) => {
|
|
7898
7918
|
el._h_timepicker = Alpine2.reactive({
|
|
@@ -8099,7 +8119,7 @@
|
|
|
8099
8119
|
"outline-none",
|
|
8100
8120
|
"border",
|
|
8101
8121
|
"rounded-control",
|
|
8102
|
-
"
|
|
8122
|
+
"absolute",
|
|
8103
8123
|
"bg-popover",
|
|
8104
8124
|
"text-popover-foreground",
|
|
8105
8125
|
"data-[state=open]:flex",
|
|
@@ -8511,21 +8531,26 @@
|
|
|
8511
8531
|
};
|
|
8512
8532
|
el.addEventListener("click", onClick2);
|
|
8513
8533
|
let autoUpdateCleanup;
|
|
8534
|
+
let focusFirstItem = true;
|
|
8514
8535
|
function updatePosition() {
|
|
8515
8536
|
computePosition2(timepicker, el, {
|
|
8516
8537
|
placement: el.getAttribute("data-align") || "bottom-start",
|
|
8517
|
-
strategy: "fixed",
|
|
8518
8538
|
middleware: [offset2(4), flip2(), shift2({ padding: 4 })]
|
|
8519
8539
|
}).then(({ x, y }) => {
|
|
8520
|
-
if (selectedHour) {
|
|
8521
|
-
selectedHour.focus();
|
|
8522
|
-
} else {
|
|
8523
|
-
hoursList.children[timepicker._h_timepicker.is12Hour ? 1 : 0].focus();
|
|
8524
|
-
}
|
|
8525
8540
|
Object.assign(el.style, {
|
|
8526
8541
|
left: `${x}px`,
|
|
8527
8542
|
top: `${y}px`
|
|
8528
8543
|
});
|
|
8544
|
+
if (focusFirstItem) {
|
|
8545
|
+
focusFirstItem = false;
|
|
8546
|
+
Alpine2.nextTick(() => {
|
|
8547
|
+
if (selectedHour) {
|
|
8548
|
+
selectedHour.focus();
|
|
8549
|
+
} else {
|
|
8550
|
+
hoursList.children[timepicker._h_timepicker.is12Hour ? 1 : 0].focus();
|
|
8551
|
+
}
|
|
8552
|
+
});
|
|
8553
|
+
}
|
|
8529
8554
|
});
|
|
8530
8555
|
}
|
|
8531
8556
|
effect(() => {
|
|
@@ -8533,11 +8558,12 @@
|
|
|
8533
8558
|
if (timepicker._h_timepicker.expanded) {
|
|
8534
8559
|
render();
|
|
8535
8560
|
autoUpdateCleanup = autoUpdate(timepicker, el, updatePosition);
|
|
8536
|
-
if (selectedHour) selectedHour.
|
|
8537
|
-
if (selectedMinute) selectedMinute.
|
|
8538
|
-
if (selectedSecond && timepicker._h_timepicker.seconds) selectedSecond.
|
|
8561
|
+
if (selectedHour) scrollIntoCenter(selectedHour.parentElement, selectedHour);
|
|
8562
|
+
if (selectedMinute) scrollIntoCenter(selectedMinute.parentElement, selectedMinute);
|
|
8563
|
+
if (selectedSecond && timepicker._h_timepicker.seconds) scrollIntoCenter(selectedSecond.parentElement, selectedSecond);
|
|
8539
8564
|
} else {
|
|
8540
8565
|
if (autoUpdateCleanup) autoUpdateCleanup();
|
|
8566
|
+
focusFirstItem = true;
|
|
8541
8567
|
Object.assign(el.style, {
|
|
8542
8568
|
left: "0px",
|
|
8543
8569
|
top: "0px"
|
|
@@ -9051,7 +9077,7 @@
|
|
|
9051
9077
|
}
|
|
9052
9078
|
|
|
9053
9079
|
// package.json
|
|
9054
|
-
var version = "0.9.
|
|
9080
|
+
var version = "0.9.1";
|
|
9055
9081
|
|
|
9056
9082
|
// src/index.js
|
|
9057
9083
|
window.Harmonia = { getBreakpointListener, addColorSchemeListener, getColorScheme, removeColorSchemeListener, setColorScheme, version };
|