sibujs 1.2.0 → 1.4.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/README.md +29 -25
- package/dist/browser.cjs +804 -2
- package/dist/browser.d.cts +591 -1
- package/dist/browser.d.ts +591 -1
- package/dist/browser.js +50 -8
- package/dist/build.cjs +655 -237
- package/dist/build.js +15 -93
- package/dist/cdn.global.js +188 -7
- package/dist/chunk-2BYQDGN3.js +742 -0
- package/dist/chunk-32DY64NT.js +282 -0
- package/dist/chunk-3AIRKM3B.js +1263 -0
- package/dist/chunk-3X2YG6YM.js +505 -0
- package/dist/chunk-5X6PP2UK.js +28 -0
- package/dist/chunk-77L6NL3X.js +1097 -0
- package/dist/chunk-BGN5ZMP4.js +26 -0
- package/dist/chunk-BTU3TJDS.js +365 -0
- package/dist/chunk-CHF5OHIA.js +61 -0
- package/dist/chunk-CMBFNA7L.js +27 -0
- package/dist/chunk-CNZ35WI2.js +178 -0
- package/dist/chunk-DAHRH4ON.js +331 -0
- package/dist/chunk-EBGIRKQY.js +616 -0
- package/dist/chunk-EUZND3CB.js +27 -0
- package/dist/chunk-F3FA4F32.js +292 -0
- package/dist/chunk-JAKHTMQU.js +1000 -0
- package/dist/chunk-JCI5M6U6.js +956 -0
- package/dist/chunk-KQPDEVVS.js +398 -0
- package/dist/chunk-M4NLBH4I.js +725 -0
- package/dist/chunk-NEKUBFPT.js +60 -0
- package/dist/chunk-NYVAC6P5.js +37 -0
- package/dist/chunk-PTQJDMRT.js +146 -0
- package/dist/chunk-QWZG56ET.js +2744 -0
- package/dist/chunk-TSOKIX5Z.js +654 -0
- package/dist/chunk-UHNL42EF.js +2730 -0
- package/dist/chunk-VRW3FULF.js +725 -0
- package/dist/chunk-WZSPOOER.js +84 -0
- package/dist/chunk-YT6HQ6AM.js +14 -0
- package/dist/chunk-ZD6OAMTH.js +277 -0
- package/dist/chunk-ZWKZCBO6.js +317 -0
- package/dist/contracts-DDrwxvJ-.d.cts +245 -0
- package/dist/contracts-DDrwxvJ-.d.ts +245 -0
- package/dist/contracts-xo5ckdRP.d.cts +240 -0
- package/dist/contracts-xo5ckdRP.d.ts +240 -0
- package/dist/data.cjs +35 -2
- package/dist/data.d.cts +7 -0
- package/dist/data.d.ts +7 -0
- package/dist/data.js +9 -8
- package/dist/devtools.cjs +122 -0
- package/dist/devtools.d.cts +69 -461
- package/dist/devtools.d.ts +69 -461
- package/dist/devtools.js +127 -6
- package/dist/ecosystem.cjs +23 -6
- package/dist/ecosystem.d.cts +1 -1
- package/dist/ecosystem.d.ts +1 -1
- package/dist/ecosystem.js +10 -9
- package/dist/extras.cjs +1208 -88
- package/dist/extras.d.cts +6 -6
- package/dist/extras.d.ts +6 -6
- package/dist/extras.js +70 -33
- package/dist/index.cjs +663 -158
- package/dist/index.d.cts +398 -40
- package/dist/index.d.ts +398 -40
- package/dist/index.js +39 -21
- package/dist/introspect-BumjnBKr.d.cts +477 -0
- package/dist/introspect-CZrlcaYy.d.ts +477 -0
- package/dist/introspect-Cb0zgpi2.d.cts +477 -0
- package/dist/introspect-Y2xNXGSf.d.ts +477 -0
- package/dist/motion.js +4 -4
- package/dist/patterns.cjs +51 -24
- package/dist/patterns.d.cts +19 -57
- package/dist/patterns.d.ts +19 -57
- package/dist/patterns.js +8 -16
- package/dist/performance.js +4 -4
- package/dist/plugins.cjs +429 -82
- package/dist/plugins.d.cts +27 -4
- package/dist/plugins.d.ts +27 -4
- package/dist/plugins.js +156 -37
- package/dist/ssr-4PBXAOO3.js +40 -0
- package/dist/ssr-Do_SiVoL.d.cts +201 -0
- package/dist/ssr-Do_SiVoL.d.ts +201 -0
- package/dist/ssr.cjs +312 -60
- package/dist/ssr.d.cts +10 -1
- package/dist/ssr.d.ts +10 -1
- package/dist/ssr.js +13 -10
- package/dist/tagFactory-DaJ0YWX6.d.cts +47 -0
- package/dist/tagFactory-DaJ0YWX6.d.ts +47 -0
- package/dist/testing.cjs +233 -2
- package/dist/testing.d.cts +42 -1
- package/dist/testing.d.ts +42 -1
- package/dist/testing.js +129 -2
- package/dist/ui.cjs +374 -8
- package/dist/ui.d.cts +252 -2
- package/dist/ui.d.ts +252 -2
- package/dist/ui.js +329 -11
- package/dist/widgets.js +7 -7
- package/package.json +1 -1
package/dist/ui.cjs
CHANGED
|
@@ -30,9 +30,11 @@ __export(ui_exports, {
|
|
|
30
30
|
bindBoolAttr: () => bindBoolAttr,
|
|
31
31
|
bindData: () => bindData,
|
|
32
32
|
bindField: () => bindField,
|
|
33
|
-
composable: () => composable,
|
|
34
33
|
compose: () => compose,
|
|
34
|
+
createDialogAria: () => createDialogAria,
|
|
35
|
+
createFocusManager: () => createFocusManager,
|
|
35
36
|
createGuard: () => createGuard,
|
|
37
|
+
createListbox: () => createListbox,
|
|
36
38
|
createSlots: () => createSlots,
|
|
37
39
|
creditCardMask: () => creditCardMask,
|
|
38
40
|
custom: () => custom,
|
|
@@ -46,10 +48,13 @@ __export(ui_exports, {
|
|
|
46
48
|
eventBus: () => eventBus,
|
|
47
49
|
focus: () => focus,
|
|
48
50
|
form: () => form,
|
|
51
|
+
formAction: () => formAction,
|
|
49
52
|
hotkey: () => hotkey,
|
|
53
|
+
hover: () => hover,
|
|
50
54
|
infiniteScroll: () => infiniteScroll,
|
|
51
55
|
inputMask: () => inputMask,
|
|
52
56
|
intersection: () => intersection,
|
|
57
|
+
interval: () => interval,
|
|
53
58
|
lazyEffect: () => lazyEffect,
|
|
54
59
|
lazyLoad: () => lazyLoad,
|
|
55
60
|
matchesPattern: () => matchesPattern,
|
|
@@ -62,9 +67,11 @@ __export(ui_exports, {
|
|
|
62
67
|
removeScopedStyle: () => removeScopedStyle,
|
|
63
68
|
required: () => required,
|
|
64
69
|
scopedStyle: () => scopedStyle,
|
|
70
|
+
scrollLock: () => scrollLock,
|
|
65
71
|
ssnMask: () => ssnMask,
|
|
66
72
|
svgElement: () => svgElement,
|
|
67
73
|
timeMask: () => timeMask,
|
|
74
|
+
timeout: () => timeout,
|
|
68
75
|
toast: () => toast,
|
|
69
76
|
validateProps: () => validateProps,
|
|
70
77
|
validators: () => validators,
|
|
@@ -573,6 +580,41 @@ function form(config) {
|
|
|
573
580
|
};
|
|
574
581
|
}
|
|
575
582
|
|
|
583
|
+
// src/ui/formAction.ts
|
|
584
|
+
function formAction(fn) {
|
|
585
|
+
const [pending, setPending] = signal(false);
|
|
586
|
+
const [error, setError] = signal(null);
|
|
587
|
+
const [result, setResult] = signal(null);
|
|
588
|
+
let runId = 0;
|
|
589
|
+
async function run(...args) {
|
|
590
|
+
const currentId = ++runId;
|
|
591
|
+
setPending(true);
|
|
592
|
+
setError(null);
|
|
593
|
+
try {
|
|
594
|
+
const value = await fn(...args);
|
|
595
|
+
if (currentId !== runId) return;
|
|
596
|
+
setResult(value);
|
|
597
|
+
} catch (err) {
|
|
598
|
+
if (currentId !== runId) return;
|
|
599
|
+
setError(err);
|
|
600
|
+
} finally {
|
|
601
|
+
if (currentId === runId) setPending(false);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
function reset() {
|
|
605
|
+
setError(null);
|
|
606
|
+
setResult(null);
|
|
607
|
+
}
|
|
608
|
+
function onSubmit(e) {
|
|
609
|
+
e.preventDefault();
|
|
610
|
+
const formEl = e.currentTarget;
|
|
611
|
+
if (!formEl || typeof FormData === "undefined") return;
|
|
612
|
+
const data = new FormData(formEl);
|
|
613
|
+
run(data);
|
|
614
|
+
}
|
|
615
|
+
return { run, pending, error, result, reset, onSubmit };
|
|
616
|
+
}
|
|
617
|
+
|
|
576
618
|
// src/core/ssr-context.ts
|
|
577
619
|
var ssrMode = false;
|
|
578
620
|
function isSSR() {
|
|
@@ -902,10 +944,224 @@ function announce(message, priority = "polite") {
|
|
|
902
944
|
});
|
|
903
945
|
}
|
|
904
946
|
|
|
947
|
+
// src/core/rendering/createId.ts
|
|
948
|
+
var idCounter = 0;
|
|
949
|
+
function createId(prefix = "sibu") {
|
|
950
|
+
idCounter++;
|
|
951
|
+
return `${prefix}-${idCounter}`;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
// src/core/rendering/dispose.ts
|
|
955
|
+
var elementDisposers = /* @__PURE__ */ new WeakMap();
|
|
956
|
+
var _isDev4 = isDev();
|
|
957
|
+
var activeBindingCount = 0;
|
|
958
|
+
function registerDisposer(node, teardown) {
|
|
959
|
+
let disposers = elementDisposers.get(node);
|
|
960
|
+
if (!disposers) {
|
|
961
|
+
disposers = [];
|
|
962
|
+
elementDisposers.set(node, disposers);
|
|
963
|
+
}
|
|
964
|
+
disposers.push(teardown);
|
|
965
|
+
if (_isDev4) activeBindingCount++;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
// src/ui/a11yPrimitives.ts
|
|
969
|
+
var DEFAULT_FOCUS_SELECTOR = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
|
|
970
|
+
function createFocusManager(container, options = {}) {
|
|
971
|
+
const selector = options.selector ?? DEFAULT_FOCUS_SELECTOR;
|
|
972
|
+
const loop = options.loop ?? true;
|
|
973
|
+
function items() {
|
|
974
|
+
return Array.from(container.querySelectorAll(selector));
|
|
975
|
+
}
|
|
976
|
+
function focusFirst() {
|
|
977
|
+
const all = items();
|
|
978
|
+
if (all.length > 0) all[0].focus();
|
|
979
|
+
}
|
|
980
|
+
function focusLast() {
|
|
981
|
+
const all = items();
|
|
982
|
+
if (all.length > 0) all[all.length - 1].focus();
|
|
983
|
+
}
|
|
984
|
+
function focusNext() {
|
|
985
|
+
const all = items();
|
|
986
|
+
if (all.length === 0) return;
|
|
987
|
+
const idx = all.indexOf(document.activeElement);
|
|
988
|
+
if (idx === -1) {
|
|
989
|
+
all[0].focus();
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
const next = idx + 1;
|
|
993
|
+
if (next >= all.length) {
|
|
994
|
+
if (loop) all[0].focus();
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
all[next].focus();
|
|
998
|
+
}
|
|
999
|
+
function focusPrev() {
|
|
1000
|
+
const all = items();
|
|
1001
|
+
if (all.length === 0) return;
|
|
1002
|
+
const idx = all.indexOf(document.activeElement);
|
|
1003
|
+
if (idx === -1) {
|
|
1004
|
+
all[all.length - 1].focus();
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
const prev = idx - 1;
|
|
1008
|
+
if (prev < 0) {
|
|
1009
|
+
if (loop) all[all.length - 1].focus();
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
all[prev].focus();
|
|
1013
|
+
}
|
|
1014
|
+
return { focusFirst, focusLast, focusNext, focusPrev, items };
|
|
1015
|
+
}
|
|
1016
|
+
function createListbox(container, options = {}) {
|
|
1017
|
+
const multiple = options.multiple ?? false;
|
|
1018
|
+
const optionSelector = options.optionSelector ?? '[role="option"]';
|
|
1019
|
+
container.setAttribute("role", "listbox");
|
|
1020
|
+
if (multiple) container.setAttribute("aria-multiselectable", "true");
|
|
1021
|
+
if (!container.hasAttribute("tabindex")) container.setAttribute("tabindex", "0");
|
|
1022
|
+
const [activeValue, setActiveValue] = signal(null);
|
|
1023
|
+
const [selectedValue, setSelectedValue] = signal(null);
|
|
1024
|
+
const [activeDescendantId, setActiveDescendantId] = signal(null);
|
|
1025
|
+
function stampIds() {
|
|
1026
|
+
const opts = Array.from(container.querySelectorAll(optionSelector));
|
|
1027
|
+
for (const opt of opts) {
|
|
1028
|
+
if (!opt.id) opt.id = createId("listbox-option");
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
stampIds();
|
|
1032
|
+
function getOptions() {
|
|
1033
|
+
return Array.from(container.querySelectorAll(optionSelector));
|
|
1034
|
+
}
|
|
1035
|
+
function setActive(value) {
|
|
1036
|
+
setActiveValue(value);
|
|
1037
|
+
const opts = getOptions();
|
|
1038
|
+
for (const opt of opts) {
|
|
1039
|
+
if (opt.dataset.value === value) {
|
|
1040
|
+
opt.setAttribute("data-highlighted", "");
|
|
1041
|
+
setActiveDescendantId(opt.id || null);
|
|
1042
|
+
container.setAttribute("aria-activedescendant", opt.id || "");
|
|
1043
|
+
} else {
|
|
1044
|
+
opt.removeAttribute("data-highlighted");
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
if (value === null) {
|
|
1048
|
+
setActiveDescendantId(null);
|
|
1049
|
+
container.removeAttribute("aria-activedescendant");
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
function select(value) {
|
|
1053
|
+
if (multiple) {
|
|
1054
|
+
const current2 = selectedValue();
|
|
1055
|
+
const set = new Set((current2 ?? "").split(",").filter(Boolean));
|
|
1056
|
+
if (set.has(value)) set.delete(value);
|
|
1057
|
+
else set.add(value);
|
|
1058
|
+
setSelectedValue(Array.from(set).join(","));
|
|
1059
|
+
} else {
|
|
1060
|
+
setSelectedValue(value);
|
|
1061
|
+
}
|
|
1062
|
+
options.onSelect?.(value);
|
|
1063
|
+
const opts = getOptions();
|
|
1064
|
+
const current = selectedValue();
|
|
1065
|
+
const selected = new Set((current ?? "").split(",").filter(Boolean));
|
|
1066
|
+
for (const opt of opts) {
|
|
1067
|
+
const ov = opt.dataset.value ?? "";
|
|
1068
|
+
opt.setAttribute("aria-selected", selected.has(ov) ? "true" : "false");
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
function moveActive(delta) {
|
|
1072
|
+
const opts = getOptions();
|
|
1073
|
+
if (opts.length === 0) return;
|
|
1074
|
+
const currentIdx = opts.findIndex((o) => o.dataset.value === activeValue());
|
|
1075
|
+
let next = currentIdx + delta;
|
|
1076
|
+
if (next < 0) next = opts.length - 1;
|
|
1077
|
+
if (next >= opts.length) next = 0;
|
|
1078
|
+
const nextValue = opts[next].dataset.value ?? null;
|
|
1079
|
+
setActive(nextValue);
|
|
1080
|
+
if (typeof opts[next].scrollIntoView === "function") {
|
|
1081
|
+
opts[next].scrollIntoView({ block: "nearest" });
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
function onKeyDown(e) {
|
|
1085
|
+
switch (e.key) {
|
|
1086
|
+
case "ArrowDown":
|
|
1087
|
+
e.preventDefault();
|
|
1088
|
+
moveActive(1);
|
|
1089
|
+
break;
|
|
1090
|
+
case "ArrowUp":
|
|
1091
|
+
e.preventDefault();
|
|
1092
|
+
moveActive(-1);
|
|
1093
|
+
break;
|
|
1094
|
+
case "Home": {
|
|
1095
|
+
e.preventDefault();
|
|
1096
|
+
const opts = getOptions();
|
|
1097
|
+
if (opts.length > 0) setActive(opts[0].dataset.value ?? null);
|
|
1098
|
+
break;
|
|
1099
|
+
}
|
|
1100
|
+
case "End": {
|
|
1101
|
+
e.preventDefault();
|
|
1102
|
+
const opts = getOptions();
|
|
1103
|
+
if (opts.length > 0) setActive(opts[opts.length - 1].dataset.value ?? null);
|
|
1104
|
+
break;
|
|
1105
|
+
}
|
|
1106
|
+
case "Enter":
|
|
1107
|
+
case " ": {
|
|
1108
|
+
e.preventDefault();
|
|
1109
|
+
const active = activeValue();
|
|
1110
|
+
if (active !== null) select(active);
|
|
1111
|
+
break;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
function onClick(e) {
|
|
1116
|
+
const target = e.target.closest(optionSelector);
|
|
1117
|
+
if (!target || !container.contains(target)) return;
|
|
1118
|
+
const value = target.dataset.value ?? null;
|
|
1119
|
+
if (value !== null) {
|
|
1120
|
+
setActive(value);
|
|
1121
|
+
select(value);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
container.addEventListener("keydown", onKeyDown);
|
|
1125
|
+
container.addEventListener("click", onClick);
|
|
1126
|
+
function dispose() {
|
|
1127
|
+
container.removeEventListener("keydown", onKeyDown);
|
|
1128
|
+
container.removeEventListener("click", onClick);
|
|
1129
|
+
}
|
|
1130
|
+
registerDisposer(container, dispose);
|
|
1131
|
+
return { activeValue, selectedValue, activeDescendantId, dispose };
|
|
1132
|
+
}
|
|
1133
|
+
function createDialogAria(element, options = {}) {
|
|
1134
|
+
const titleId = options.labelledBy ?? createId("dialog-title");
|
|
1135
|
+
const descriptionId = options.describedBy ?? createId("dialog-desc");
|
|
1136
|
+
element.setAttribute("role", options.alert ? "alertdialog" : "dialog");
|
|
1137
|
+
if (options.modal ?? true) element.setAttribute("aria-modal", "true");
|
|
1138
|
+
element.setAttribute("aria-labelledby", titleId);
|
|
1139
|
+
element.setAttribute("aria-describedby", descriptionId);
|
|
1140
|
+
if (!element.hasAttribute("tabindex")) element.setAttribute("tabindex", "-1");
|
|
1141
|
+
return { titleId, descriptionId };
|
|
1142
|
+
}
|
|
1143
|
+
|
|
905
1144
|
// src/ui/scopedStyle.ts
|
|
906
1145
|
var scopeCounter = 0;
|
|
1146
|
+
function decodeCssEscapes(css) {
|
|
1147
|
+
return css.replace(/\\([0-9a-f]{1,6})[ \t\n\r\f]?|\\([^\n])/gi, (_match, hex, ch) => {
|
|
1148
|
+
if (hex) {
|
|
1149
|
+
const code = Number.parseInt(hex, 16);
|
|
1150
|
+
if (Number.isFinite(code) && code > 0 && code <= 1114111) {
|
|
1151
|
+
try {
|
|
1152
|
+
return String.fromCodePoint(code);
|
|
1153
|
+
} catch {
|
|
1154
|
+
return "";
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
return "";
|
|
1158
|
+
}
|
|
1159
|
+
return ch || "";
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
907
1162
|
function sanitizeCSS(css) {
|
|
908
|
-
let sanitized = css
|
|
1163
|
+
let sanitized = decodeCssEscapes(css);
|
|
1164
|
+
sanitized = sanitized.replace(/@import\s+[^;]+;/gi, "/* @import removed */");
|
|
909
1165
|
sanitized = sanitized.replace(/url\s*\(\s*(?:"[^"]*"|'[^']*'|[^)]*)\s*\)/gi, "/* url() removed */");
|
|
910
1166
|
sanitized = sanitized.replace(/expression\s*\(\s*(?:"[^"]*"|'[^']*'|[^)]*)\s*\)/gi, "/* expression() removed */");
|
|
911
1167
|
sanitized = sanitized.replace(/-moz-binding\s*:[^;]+;/gi, "/* -moz-binding removed */");
|
|
@@ -971,14 +1227,27 @@ function isUrlAttribute(attr) {
|
|
|
971
1227
|
}
|
|
972
1228
|
|
|
973
1229
|
// src/reactivity/bindAttribute.ts
|
|
974
|
-
var
|
|
1230
|
+
var _isDev5 = isDev();
|
|
1231
|
+
function isEventHandlerAttr(name) {
|
|
1232
|
+
if (name.length < 3) return false;
|
|
1233
|
+
const lower = name.toLowerCase();
|
|
1234
|
+
return lower[0] === "o" && lower[1] === "n" && lower.charCodeAt(2) >= 97 && lower.charCodeAt(2) <= 122;
|
|
1235
|
+
}
|
|
975
1236
|
function bindAttribute(el, attr, getter) {
|
|
1237
|
+
if (isEventHandlerAttr(attr)) {
|
|
1238
|
+
if (_isDev5)
|
|
1239
|
+
devWarn(
|
|
1240
|
+
`bindAttribute: refusing to bind event-handler attribute "${attr}". Use on:{ ${attr.slice(2)}: fn } instead.`
|
|
1241
|
+
);
|
|
1242
|
+
return () => {
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
976
1245
|
function commit() {
|
|
977
1246
|
let value;
|
|
978
1247
|
try {
|
|
979
1248
|
value = getter();
|
|
980
1249
|
} catch (err) {
|
|
981
|
-
if (
|
|
1250
|
+
if (_isDev5)
|
|
982
1251
|
devWarn(`bindAttribute: getter for "${attr}" threw: ${err instanceof Error ? err.message : String(err)}`);
|
|
983
1252
|
return;
|
|
984
1253
|
}
|
|
@@ -1314,6 +1583,99 @@ function lazyEffect(element, effectFn, options) {
|
|
|
1314
1583
|
};
|
|
1315
1584
|
}
|
|
1316
1585
|
|
|
1586
|
+
// src/ui/timers.ts
|
|
1587
|
+
function interval(fn, ms) {
|
|
1588
|
+
let id = null;
|
|
1589
|
+
let running = false;
|
|
1590
|
+
function start() {
|
|
1591
|
+
if (running) return;
|
|
1592
|
+
id = setInterval(fn, ms);
|
|
1593
|
+
running = true;
|
|
1594
|
+
}
|
|
1595
|
+
function stop() {
|
|
1596
|
+
if (id !== null) {
|
|
1597
|
+
clearInterval(id);
|
|
1598
|
+
id = null;
|
|
1599
|
+
}
|
|
1600
|
+
running = false;
|
|
1601
|
+
}
|
|
1602
|
+
start();
|
|
1603
|
+
return {
|
|
1604
|
+
stop,
|
|
1605
|
+
pause: stop,
|
|
1606
|
+
resume: start,
|
|
1607
|
+
isRunning: () => running
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
function timeout(fn, ms) {
|
|
1611
|
+
let pending = true;
|
|
1612
|
+
const id = setTimeout(() => {
|
|
1613
|
+
pending = false;
|
|
1614
|
+
fn();
|
|
1615
|
+
}, ms);
|
|
1616
|
+
return {
|
|
1617
|
+
cancel: () => {
|
|
1618
|
+
if (pending) {
|
|
1619
|
+
clearTimeout(id);
|
|
1620
|
+
pending = false;
|
|
1621
|
+
}
|
|
1622
|
+
},
|
|
1623
|
+
isPending: () => pending
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
// src/ui/hover.ts
|
|
1628
|
+
function hover(target) {
|
|
1629
|
+
const [hovered, setHovered] = signal(false);
|
|
1630
|
+
if (typeof window === "undefined") {
|
|
1631
|
+
return { hovered, dispose: () => {
|
|
1632
|
+
} };
|
|
1633
|
+
}
|
|
1634
|
+
const onEnter = () => setHovered(true);
|
|
1635
|
+
const onLeave = () => setHovered(false);
|
|
1636
|
+
target.addEventListener("pointerenter", onEnter);
|
|
1637
|
+
target.addEventListener("pointerleave", onLeave);
|
|
1638
|
+
function dispose() {
|
|
1639
|
+
target.removeEventListener("pointerenter", onEnter);
|
|
1640
|
+
target.removeEventListener("pointerleave", onLeave);
|
|
1641
|
+
}
|
|
1642
|
+
return { hovered, dispose };
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
// src/ui/scrollLock.ts
|
|
1646
|
+
var lockCount = 0;
|
|
1647
|
+
var savedOverflow = null;
|
|
1648
|
+
var savedPaddingRight = null;
|
|
1649
|
+
function scrollLock() {
|
|
1650
|
+
let owned = false;
|
|
1651
|
+
function lock() {
|
|
1652
|
+
if (owned) return;
|
|
1653
|
+
owned = true;
|
|
1654
|
+
lockCount++;
|
|
1655
|
+
if (lockCount !== 1 || typeof document === "undefined") return;
|
|
1656
|
+
const body = document.body;
|
|
1657
|
+
const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
1658
|
+
savedOverflow = body.style.overflow;
|
|
1659
|
+
savedPaddingRight = body.style.paddingRight;
|
|
1660
|
+
body.style.overflow = "hidden";
|
|
1661
|
+
if (scrollBarWidth > 0) {
|
|
1662
|
+
body.style.paddingRight = `${scrollBarWidth}px`;
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
function unlock() {
|
|
1666
|
+
if (!owned) return;
|
|
1667
|
+
owned = false;
|
|
1668
|
+
lockCount = Math.max(0, lockCount - 1);
|
|
1669
|
+
if (lockCount !== 0 || typeof document === "undefined") return;
|
|
1670
|
+
const body = document.body;
|
|
1671
|
+
body.style.overflow = savedOverflow ?? "";
|
|
1672
|
+
body.style.paddingRight = savedPaddingRight ?? "";
|
|
1673
|
+
savedOverflow = null;
|
|
1674
|
+
savedPaddingRight = null;
|
|
1675
|
+
}
|
|
1676
|
+
return { lock, unlock };
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1317
1679
|
// src/platform/customElement.ts
|
|
1318
1680
|
function defineElement(name, component, options = {}) {
|
|
1319
1681
|
if (customElements.get(name)) return;
|
|
@@ -1395,9 +1757,6 @@ function svgElement(tag, props = {}, ...nodes) {
|
|
|
1395
1757
|
}
|
|
1396
1758
|
|
|
1397
1759
|
// src/patterns/composable.ts
|
|
1398
|
-
function composable(setup) {
|
|
1399
|
-
return setup;
|
|
1400
|
-
}
|
|
1401
1760
|
function RenderProp(props) {
|
|
1402
1761
|
return props.render(props.data());
|
|
1403
1762
|
}
|
|
@@ -1570,9 +1929,11 @@ function createGuard(validator) {
|
|
|
1570
1929
|
bindBoolAttr,
|
|
1571
1930
|
bindData,
|
|
1572
1931
|
bindField,
|
|
1573
|
-
composable,
|
|
1574
1932
|
compose,
|
|
1933
|
+
createDialogAria,
|
|
1934
|
+
createFocusManager,
|
|
1575
1935
|
createGuard,
|
|
1936
|
+
createListbox,
|
|
1576
1937
|
createSlots,
|
|
1577
1938
|
creditCardMask,
|
|
1578
1939
|
custom,
|
|
@@ -1586,10 +1947,13 @@ function createGuard(validator) {
|
|
|
1586
1947
|
eventBus,
|
|
1587
1948
|
focus,
|
|
1588
1949
|
form,
|
|
1950
|
+
formAction,
|
|
1589
1951
|
hotkey,
|
|
1952
|
+
hover,
|
|
1590
1953
|
infiniteScroll,
|
|
1591
1954
|
inputMask,
|
|
1592
1955
|
intersection,
|
|
1956
|
+
interval,
|
|
1593
1957
|
lazyEffect,
|
|
1594
1958
|
lazyLoad,
|
|
1595
1959
|
matchesPattern,
|
|
@@ -1602,9 +1966,11 @@ function createGuard(validator) {
|
|
|
1602
1966
|
removeScopedStyle,
|
|
1603
1967
|
required,
|
|
1604
1968
|
scopedStyle,
|
|
1969
|
+
scrollLock,
|
|
1605
1970
|
ssnMask,
|
|
1606
1971
|
svgElement,
|
|
1607
1972
|
timeMask,
|
|
1973
|
+
timeout,
|
|
1608
1974
|
toast,
|
|
1609
1975
|
validateProps,
|
|
1610
1976
|
validators,
|