@codbex/harmonia 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/harmonia.css +1 -1
- package/dist/harmonia.esm.js +177 -6
- package/dist/harmonia.esm.min.js +3 -3
- package/dist/harmonia.esm.min.js.map +4 -4
- package/dist/harmonia.js +174 -7
- package/dist/harmonia.min.js +2 -2
- package/dist/harmonia.min.js.map +4 -4
- package/package.json +1 -1
package/dist/harmonia.js
CHANGED
|
@@ -606,7 +606,7 @@
|
|
|
606
606
|
}
|
|
607
607
|
};
|
|
608
608
|
function button_default(Alpine) {
|
|
609
|
-
Alpine.directive("h-button", (el, { modifiers }, { cleanup }) => {
|
|
609
|
+
Alpine.directive("h-button", (el, { original, modifiers }, { cleanup }) => {
|
|
610
610
|
setButtonClasses(el);
|
|
611
611
|
if (!el.hasAttribute("data-slot")) {
|
|
612
612
|
el.setAttribute("data-slot", "button");
|
|
@@ -623,7 +623,7 @@
|
|
|
623
623
|
el.classList.remove(...getButtonSize(lastSize, inGroup));
|
|
624
624
|
el.classList.add(...getButtonSize(size3, inGroup));
|
|
625
625
|
if (size3.startsWith("icon") && !el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
|
|
626
|
-
console.error(
|
|
626
|
+
console.error(`${original}: Icon-only buttons must have an "aria-label" or "aria-labelledby" attribute`, el);
|
|
627
627
|
}
|
|
628
628
|
lastSize = size3;
|
|
629
629
|
}
|
|
@@ -2167,7 +2167,7 @@
|
|
|
2167
2167
|
|
|
2168
2168
|
// src/components/calendar.js
|
|
2169
2169
|
function calendar_default(Alpine) {
|
|
2170
|
-
Alpine.directive("h-calendar", (el, { expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
|
|
2170
|
+
Alpine.directive("h-calendar", (el, { original, expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
|
|
2171
2171
|
const datepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_datepicker"));
|
|
2172
2172
|
el.classList.add("border", "rounded-control", "gap-2", "p-2");
|
|
2173
2173
|
el.setAttribute("tabindex", "-1");
|
|
@@ -2211,7 +2211,7 @@
|
|
|
2211
2211
|
const onInputChange = () => {
|
|
2212
2212
|
const newValue = new Date(datepicker._h_datepicker.input.value);
|
|
2213
2213
|
if (isNaN(newValue)) {
|
|
2214
|
-
console.error(
|
|
2214
|
+
console.error(`${original}: input value is not a valid date - ${datepicker._h_datepicker.input.value}`);
|
|
2215
2215
|
datepicker._h_datepicker.input.setCustomValidity("Input value is not a valid date.");
|
|
2216
2216
|
return;
|
|
2217
2217
|
} else if (selected.getTime() !== newValue.getTime()) {
|
|
@@ -2228,7 +2228,7 @@
|
|
|
2228
2228
|
if (el.hasOwnProperty("_x_model") && el._x_model.get()) {
|
|
2229
2229
|
selected = new Date(el._x_model.get());
|
|
2230
2230
|
if (isNaN(selected)) {
|
|
2231
|
-
console.error(
|
|
2231
|
+
console.error(`${original}: input value is not a valid date - ${el._x_model.get()}`);
|
|
2232
2232
|
if (datepicker) datepicker._h_datepicker.input.setCustomValidity("Input value is not a valid date.");
|
|
2233
2233
|
else el.setAttribute("data-invalid", "true");
|
|
2234
2234
|
} else if (datepicker) {
|
|
@@ -7106,6 +7106,128 @@
|
|
|
7106
7106
|
});
|
|
7107
7107
|
}
|
|
7108
7108
|
|
|
7109
|
+
// src/components/split.js
|
|
7110
|
+
function split_default(Alpine) {
|
|
7111
|
+
Alpine.directive("h-split", (el) => {
|
|
7112
|
+
el.classList.add("group/split", "flex", "data-[orientation=horizontal]:flex-row", "data-[orientation=vertical]:flex-col");
|
|
7113
|
+
el.setAttribute("tabindex", "-1");
|
|
7114
|
+
el.setAttribute("data-slot", "split");
|
|
7115
|
+
});
|
|
7116
|
+
Alpine.directive("h-split-panel", (el) => {
|
|
7117
|
+
el.setAttribute("tabindex", "-1");
|
|
7118
|
+
el.setAttribute("data-slot", "split-panel");
|
|
7119
|
+
});
|
|
7120
|
+
Alpine.directive("h-split-gutter", (el, {}, { cleanup }) => {
|
|
7121
|
+
el.classList.add(
|
|
7122
|
+
"relative",
|
|
7123
|
+
"shrink-0",
|
|
7124
|
+
"touch-none",
|
|
7125
|
+
"bg-border",
|
|
7126
|
+
"outline-none",
|
|
7127
|
+
"hover:bg-primary-hover",
|
|
7128
|
+
"active:bg-primary-active",
|
|
7129
|
+
"before:absolute",
|
|
7130
|
+
"before:top-1/2",
|
|
7131
|
+
"before:left-1/2",
|
|
7132
|
+
"before:-translate-x-1/2",
|
|
7133
|
+
"before:-translate-y-1/2",
|
|
7134
|
+
"before:block",
|
|
7135
|
+
"before:bg-transparent",
|
|
7136
|
+
"hover:before:bg-primary-hover",
|
|
7137
|
+
"group-data-[locked=true]/split:pointer-events-none",
|
|
7138
|
+
"group-data-[orientation=horizontal]/split:cursor-col-resize",
|
|
7139
|
+
"group-data-[orientation=vertical]/split:cursor-row-resize"
|
|
7140
|
+
);
|
|
7141
|
+
const borderClasses = [
|
|
7142
|
+
"bg-border",
|
|
7143
|
+
"outline-none",
|
|
7144
|
+
"hover:bg-primary-hover",
|
|
7145
|
+
"active:bg-primary-active",
|
|
7146
|
+
"before:absolute",
|
|
7147
|
+
"before:top-1/2",
|
|
7148
|
+
"before:left-1/2",
|
|
7149
|
+
"before:-translate-x-1/2",
|
|
7150
|
+
"before:-translate-y-1/2",
|
|
7151
|
+
"before:block",
|
|
7152
|
+
"before:bg-transparent",
|
|
7153
|
+
"hover:before:bg-primary-hover",
|
|
7154
|
+
"group-data-[orientation=horizontal]/split:!w-px",
|
|
7155
|
+
"group-data-[orientation=horizontal]/split:before:h-full",
|
|
7156
|
+
"group-data-[orientation=horizontal]/split:before:w-[0.313rem]",
|
|
7157
|
+
"group-data-[orientation=vertical]/split:!h-px",
|
|
7158
|
+
"group-data-[orientation=vertical]/split:before:w-full",
|
|
7159
|
+
"group-data-[orientation=vertical]/split:before:h-[0.313rem]"
|
|
7160
|
+
];
|
|
7161
|
+
const handleClasses = [
|
|
7162
|
+
"bg-transparent",
|
|
7163
|
+
"outline-none",
|
|
7164
|
+
"after:absolute",
|
|
7165
|
+
"after:block",
|
|
7166
|
+
"after:rounded-sm",
|
|
7167
|
+
"after:bg-background",
|
|
7168
|
+
"after:border-split-handle",
|
|
7169
|
+
"after:border-2",
|
|
7170
|
+
"after:shadow-xs",
|
|
7171
|
+
"after:top-1/2",
|
|
7172
|
+
"after:left-1/2",
|
|
7173
|
+
"after:-translate-x-1/2",
|
|
7174
|
+
"after:-translate-y-1/2",
|
|
7175
|
+
"hover:after:border-primary-hover",
|
|
7176
|
+
"active:after:border-primary-active",
|
|
7177
|
+
"before:absolute",
|
|
7178
|
+
"before:block",
|
|
7179
|
+
"before:top-1/2",
|
|
7180
|
+
"before:left-1/2",
|
|
7181
|
+
"before:-translate-x-1/2",
|
|
7182
|
+
"before:-translate-y-1/2",
|
|
7183
|
+
"before:rounded-sm",
|
|
7184
|
+
"before:from-transparent",
|
|
7185
|
+
"before:from-15%",
|
|
7186
|
+
"before:via-split-handle",
|
|
7187
|
+
"before:to-85%",
|
|
7188
|
+
"before:to-transparent",
|
|
7189
|
+
"hover:before:bg-primary-hover",
|
|
7190
|
+
"hover:before:via-transparent",
|
|
7191
|
+
"active:before:bg-primary-active",
|
|
7192
|
+
"active:before:via-transparent",
|
|
7193
|
+
// Orientation classes
|
|
7194
|
+
"group-data-[orientation=horizontal]/split:before:h-full",
|
|
7195
|
+
"group-data-[orientation=horizontal]/split:before:w-0.5",
|
|
7196
|
+
"group-data-[orientation=horizontal]/split:before:bg-gradient-to-b",
|
|
7197
|
+
"group-data-[orientation=vertical]/split:before:h-0.5",
|
|
7198
|
+
"group-data-[orientation=vertical]/split:before:w-full",
|
|
7199
|
+
"group-data-[orientation=vertical]/split:before:bg-gradient-to-r",
|
|
7200
|
+
// Size classes
|
|
7201
|
+
"group-data-[orientation=horizontal]/split:!w-4",
|
|
7202
|
+
"group-data-[orientation=horizontal]/split:after:w-2.5",
|
|
7203
|
+
"group-data-[orientation=horizontal]/split:after:h-5",
|
|
7204
|
+
"group-data-[orientation=vertical]/split:!h-4",
|
|
7205
|
+
"group-data-[orientation=vertical]/split:after:w-5",
|
|
7206
|
+
"group-data-[orientation=vertical]/split:after:h-2.5"
|
|
7207
|
+
];
|
|
7208
|
+
el.setAttribute("data-slot", "split-gutter");
|
|
7209
|
+
el.setAttribute("tabindex", "-1");
|
|
7210
|
+
el.setAttribute("role", "separator");
|
|
7211
|
+
function setVariant(variant = "handle") {
|
|
7212
|
+
if (variant === "border") {
|
|
7213
|
+
el.classList.remove(...handleClasses);
|
|
7214
|
+
el.classList.add(...borderClasses);
|
|
7215
|
+
} else {
|
|
7216
|
+
el.classList.remove(...borderClasses);
|
|
7217
|
+
el.classList.add(...handleClasses);
|
|
7218
|
+
}
|
|
7219
|
+
}
|
|
7220
|
+
const observer = new MutationObserver(() => {
|
|
7221
|
+
setVariant(el.parentElement.getAttribute("data-variant"));
|
|
7222
|
+
});
|
|
7223
|
+
observer.observe(el.parentElement, { attributes: true, attributeFilter: ["data-variant"] });
|
|
7224
|
+
setVariant(el.parentElement.getAttribute("data-variant"));
|
|
7225
|
+
cleanup(() => {
|
|
7226
|
+
observer.disconnect();
|
|
7227
|
+
});
|
|
7228
|
+
});
|
|
7229
|
+
}
|
|
7230
|
+
|
|
7109
7231
|
// src/components/switch.js
|
|
7110
7232
|
function switch_default(Alpine) {
|
|
7111
7233
|
Alpine.directive("h-switch", (el) => {
|
|
@@ -8387,11 +8509,19 @@
|
|
|
8387
8509
|
// src/utils/theme.js
|
|
8388
8510
|
var colorSchemeKey = "codbex.harmonia.colorMode";
|
|
8389
8511
|
var savedScheme = localStorage.getItem(colorSchemeKey);
|
|
8512
|
+
var callbacks = [];
|
|
8513
|
+
var onColorSchemeChange = (scheme) => {
|
|
8514
|
+
for (let i = 0; i < callbacks.length; i++) {
|
|
8515
|
+
callbacks[i](scheme);
|
|
8516
|
+
}
|
|
8517
|
+
};
|
|
8390
8518
|
var colorSchemeChange = (event) => {
|
|
8391
8519
|
if (event.matches) {
|
|
8392
8520
|
document.documentElement.classList.add("dark");
|
|
8521
|
+
onColorSchemeChange("dark");
|
|
8393
8522
|
} else {
|
|
8394
8523
|
document.documentElement.classList.remove("dark");
|
|
8524
|
+
onColorSchemeChange("light");
|
|
8395
8525
|
}
|
|
8396
8526
|
};
|
|
8397
8527
|
var initColorScheme = () => {
|
|
@@ -8411,15 +8541,19 @@
|
|
|
8411
8541
|
document.documentElement.classList.add("dark");
|
|
8412
8542
|
localStorage.setItem(colorSchemeKey, "dark");
|
|
8413
8543
|
window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change", colorSchemeChange);
|
|
8544
|
+
onColorSchemeChange("dark");
|
|
8414
8545
|
} else if (mode === "light") {
|
|
8415
8546
|
document.documentElement.classList.remove("dark");
|
|
8416
8547
|
localStorage.setItem(colorSchemeKey, "light");
|
|
8417
8548
|
window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change", colorSchemeChange);
|
|
8549
|
+
onColorSchemeChange("light");
|
|
8418
8550
|
} else {
|
|
8419
8551
|
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
8420
8552
|
document.documentElement.classList.add("dark");
|
|
8553
|
+
onColorSchemeChange("dark");
|
|
8421
8554
|
} else {
|
|
8422
8555
|
document.documentElement.classList.remove("dark");
|
|
8556
|
+
onColorSchemeChange("light");
|
|
8423
8557
|
}
|
|
8424
8558
|
localStorage.setItem(colorSchemeKey, "auto");
|
|
8425
8559
|
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", colorSchemeChange);
|
|
@@ -8433,6 +8567,17 @@
|
|
|
8433
8567
|
}
|
|
8434
8568
|
return "light";
|
|
8435
8569
|
};
|
|
8570
|
+
var addColorSchemeListener = (callback) => {
|
|
8571
|
+
callbacks.push(callback);
|
|
8572
|
+
};
|
|
8573
|
+
var removeColorSchemeListener = (callback) => {
|
|
8574
|
+
for (let i = 0; i < callbacks.length; i++) {
|
|
8575
|
+
if (callbacks[i] === callback) {
|
|
8576
|
+
callbacks.splice(i, 1);
|
|
8577
|
+
return;
|
|
8578
|
+
}
|
|
8579
|
+
}
|
|
8580
|
+
};
|
|
8436
8581
|
initColorScheme();
|
|
8437
8582
|
|
|
8438
8583
|
// src/utils/breakpoint-listener.js
|
|
@@ -8452,6 +8597,26 @@
|
|
|
8452
8597
|
};
|
|
8453
8598
|
}
|
|
8454
8599
|
|
|
8600
|
+
// src/utils/template.js
|
|
8601
|
+
function template_default(Alpine) {
|
|
8602
|
+
Alpine.directive("h-template", (el, { original, expression }, { evaluate: evaluate2, Alpine: Alpine2, cleanup }) => {
|
|
8603
|
+
if (el.hasAttribute(Alpine2.prefixed("data"))) {
|
|
8604
|
+
const template = evaluate2(expression);
|
|
8605
|
+
const clone = template.content.cloneNode(true).firstElementChild;
|
|
8606
|
+
Alpine2.addScopeToNode(clone, Alpine2.closestDataStack(el)[0], el.parentElement);
|
|
8607
|
+
Alpine2.mutateDom(() => {
|
|
8608
|
+
el.before(clone);
|
|
8609
|
+
Alpine2.initTree(clone);
|
|
8610
|
+
});
|
|
8611
|
+
cleanup(() => {
|
|
8612
|
+
clone.remove();
|
|
8613
|
+
});
|
|
8614
|
+
} else {
|
|
8615
|
+
console.error(`${original}: ${Alpine2.prefixed("data")} directive is missing`);
|
|
8616
|
+
}
|
|
8617
|
+
});
|
|
8618
|
+
}
|
|
8619
|
+
|
|
8455
8620
|
// src/utils/focus.js
|
|
8456
8621
|
function focus_default(Alpine) {
|
|
8457
8622
|
Alpine.directive("h-focus", (el, { expression }, { effect, evaluateLater }) => {
|
|
@@ -8465,10 +8630,10 @@
|
|
|
8465
8630
|
}
|
|
8466
8631
|
|
|
8467
8632
|
// package.json
|
|
8468
|
-
var version = "0.
|
|
8633
|
+
var version = "0.8.0";
|
|
8469
8634
|
|
|
8470
8635
|
// src/index.js
|
|
8471
|
-
window.Harmonia = { getBreakpointListener, getColorScheme, setColorScheme, version };
|
|
8636
|
+
window.Harmonia = { getBreakpointListener, addColorSchemeListener, getColorScheme, removeColorSchemeListener, setColorScheme, version };
|
|
8472
8637
|
document.addEventListener("alpine:init", () => {
|
|
8473
8638
|
window.Alpine.plugin(accordion_default);
|
|
8474
8639
|
window.Alpine.plugin(alert_default);
|
|
@@ -8499,6 +8664,7 @@
|
|
|
8499
8664
|
window.Alpine.plugin(sidebar_default);
|
|
8500
8665
|
window.Alpine.plugin(skeleton_default);
|
|
8501
8666
|
window.Alpine.plugin(spinner_default);
|
|
8667
|
+
window.Alpine.plugin(split_default);
|
|
8502
8668
|
window.Alpine.plugin(switch_default);
|
|
8503
8669
|
window.Alpine.plugin(table_default);
|
|
8504
8670
|
window.Alpine.plugin(tabs_default);
|
|
@@ -8510,6 +8676,7 @@
|
|
|
8510
8676
|
window.Alpine.plugin(toolbar_default);
|
|
8511
8677
|
window.Alpine.plugin(tooltip_default);
|
|
8512
8678
|
window.Alpine.plugin(focus_default);
|
|
8679
|
+
window.Alpine.plugin(template_default);
|
|
8513
8680
|
});
|
|
8514
8681
|
})();
|
|
8515
8682
|
/*! Bundled license information:
|