sibujs 1.2.0 → 1.3.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.
Files changed (89) hide show
  1. package/README.md +29 -25
  2. package/dist/browser.cjs +804 -2
  3. package/dist/browser.d.cts +591 -1
  4. package/dist/browser.d.ts +591 -1
  5. package/dist/browser.js +50 -8
  6. package/dist/build.cjs +654 -144
  7. package/dist/build.js +14 -12
  8. package/dist/cdn.global.js +188 -7
  9. package/dist/chunk-2BYQDGN3.js +742 -0
  10. package/dist/chunk-32DY64NT.js +282 -0
  11. package/dist/chunk-3AIRKM3B.js +1263 -0
  12. package/dist/chunk-3X2YG6YM.js +505 -0
  13. package/dist/chunk-5X6PP2UK.js +28 -0
  14. package/dist/chunk-77L6NL3X.js +1097 -0
  15. package/dist/chunk-BGN5ZMP4.js +26 -0
  16. package/dist/chunk-BTU3TJDS.js +365 -0
  17. package/dist/chunk-CHF5OHIA.js +61 -0
  18. package/dist/chunk-CMBFNA7L.js +27 -0
  19. package/dist/chunk-DAHRH4ON.js +331 -0
  20. package/dist/chunk-EBGIRKQY.js +616 -0
  21. package/dist/chunk-EUZND3CB.js +27 -0
  22. package/dist/chunk-F3FA4F32.js +292 -0
  23. package/dist/chunk-JAKHTMQU.js +1000 -0
  24. package/dist/chunk-JCI5M6U6.js +956 -0
  25. package/dist/chunk-KQPDEVVS.js +398 -0
  26. package/dist/chunk-NEKUBFPT.js +60 -0
  27. package/dist/chunk-NYVAC6P5.js +37 -0
  28. package/dist/chunk-PTQJDMRT.js +146 -0
  29. package/dist/chunk-QWZG56ET.js +2744 -0
  30. package/dist/chunk-TSOKIX5Z.js +654 -0
  31. package/dist/chunk-VRW3FULF.js +725 -0
  32. package/dist/chunk-WZSPOOER.js +84 -0
  33. package/dist/chunk-YT6HQ6AM.js +14 -0
  34. package/dist/chunk-ZD6OAMTH.js +277 -0
  35. package/dist/contracts-DDrwxvJ-.d.cts +245 -0
  36. package/dist/contracts-DDrwxvJ-.d.ts +245 -0
  37. package/dist/data.cjs +35 -2
  38. package/dist/data.d.cts +7 -0
  39. package/dist/data.d.ts +7 -0
  40. package/dist/data.js +9 -8
  41. package/dist/devtools.cjs +122 -0
  42. package/dist/devtools.d.cts +69 -461
  43. package/dist/devtools.d.ts +69 -461
  44. package/dist/devtools.js +127 -6
  45. package/dist/ecosystem.cjs +23 -6
  46. package/dist/ecosystem.d.cts +1 -1
  47. package/dist/ecosystem.d.ts +1 -1
  48. package/dist/ecosystem.js +10 -9
  49. package/dist/extras.cjs +1207 -65
  50. package/dist/extras.d.cts +5 -5
  51. package/dist/extras.d.ts +5 -5
  52. package/dist/extras.js +69 -24
  53. package/dist/index.cjs +663 -144
  54. package/dist/index.d.cts +397 -17
  55. package/dist/index.d.ts +397 -17
  56. package/dist/index.js +39 -17
  57. package/dist/introspect-BumjnBKr.d.cts +477 -0
  58. package/dist/introspect-CZrlcaYy.d.ts +477 -0
  59. package/dist/introspect-Cb0zgpi2.d.cts +477 -0
  60. package/dist/introspect-Y2xNXGSf.d.ts +477 -0
  61. package/dist/motion.js +4 -4
  62. package/dist/patterns.cjs +51 -2
  63. package/dist/patterns.d.cts +18 -8
  64. package/dist/patterns.d.ts +18 -8
  65. package/dist/patterns.js +7 -7
  66. package/dist/performance.js +4 -4
  67. package/dist/plugins.cjs +428 -81
  68. package/dist/plugins.d.cts +27 -4
  69. package/dist/plugins.d.ts +27 -4
  70. package/dist/plugins.js +156 -37
  71. package/dist/ssr-4PBXAOO3.js +40 -0
  72. package/dist/ssr-Do_SiVoL.d.cts +201 -0
  73. package/dist/ssr-Do_SiVoL.d.ts +201 -0
  74. package/dist/ssr.cjs +312 -60
  75. package/dist/ssr.d.cts +10 -1
  76. package/dist/ssr.d.ts +10 -1
  77. package/dist/ssr.js +13 -10
  78. package/dist/tagFactory-DaJ0YWX6.d.cts +47 -0
  79. package/dist/tagFactory-DaJ0YWX6.d.ts +47 -0
  80. package/dist/testing.cjs +233 -2
  81. package/dist/testing.d.cts +42 -1
  82. package/dist/testing.d.ts +42 -1
  83. package/dist/testing.js +129 -2
  84. package/dist/ui.cjs +374 -3
  85. package/dist/ui.d.cts +252 -2
  86. package/dist/ui.d.ts +252 -2
  87. package/dist/ui.js +328 -8
  88. package/dist/widgets.js +7 -7
  89. package/package.json +1 -1
package/dist/ui.js CHANGED
@@ -37,7 +37,7 @@ import {
37
37
  toast,
38
38
  withScopedStyle,
39
39
  zipMask
40
- } from "./chunk-BW3WT46K.js";
40
+ } from "./chunk-JCI5M6U6.js";
41
41
  import {
42
42
  RenderProp,
43
43
  assertType,
@@ -55,15 +55,234 @@ import {
55
55
  withProps,
56
56
  withWrapper
57
57
  } from "./chunk-XYU6TZOW.js";
58
- import "./chunk-23VV7YD3.js";
59
- import "./chunk-L6JRBDNS.js";
58
+ import {
59
+ createId
60
+ } from "./chunk-YT6HQ6AM.js";
61
+ import {
62
+ registerDisposer
63
+ } from "./chunk-PTQJDMRT.js";
64
+ import "./chunk-NEKUBFPT.js";
65
+ import "./chunk-CMBFNA7L.js";
60
66
  import {
61
67
  effect
62
- } from "./chunk-6SA3QQES.js";
63
- import "./chunk-CHJ27IGK.js";
64
- import "./chunk-V2XTI523.js";
65
- import "./chunk-UNXCEF6S.js";
66
- import "./chunk-MLKGABMK.js";
68
+ } from "./chunk-CHF5OHIA.js";
69
+ import "./chunk-EUZND3CB.js";
70
+ import {
71
+ signal
72
+ } from "./chunk-WZSPOOER.js";
73
+ import "./chunk-ZD6OAMTH.js";
74
+ import "./chunk-5X6PP2UK.js";
75
+
76
+ // src/ui/formAction.ts
77
+ function formAction(fn) {
78
+ const [pending, setPending] = signal(false);
79
+ const [error, setError] = signal(null);
80
+ const [result, setResult] = signal(null);
81
+ let runId = 0;
82
+ async function run(...args) {
83
+ const currentId = ++runId;
84
+ setPending(true);
85
+ setError(null);
86
+ try {
87
+ const value = await fn(...args);
88
+ if (currentId !== runId) return;
89
+ setResult(value);
90
+ } catch (err) {
91
+ if (currentId !== runId) return;
92
+ setError(err);
93
+ } finally {
94
+ if (currentId === runId) setPending(false);
95
+ }
96
+ }
97
+ function reset() {
98
+ setError(null);
99
+ setResult(null);
100
+ }
101
+ function onSubmit(e) {
102
+ e.preventDefault();
103
+ const formEl = e.currentTarget;
104
+ if (!formEl || typeof FormData === "undefined") return;
105
+ const data = new FormData(formEl);
106
+ run(data);
107
+ }
108
+ return { run, pending, error, result, reset, onSubmit };
109
+ }
110
+
111
+ // src/ui/a11yPrimitives.ts
112
+ var DEFAULT_FOCUS_SELECTOR = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
113
+ function createFocusManager(container, options = {}) {
114
+ const selector = options.selector ?? DEFAULT_FOCUS_SELECTOR;
115
+ const loop = options.loop ?? true;
116
+ function items() {
117
+ return Array.from(container.querySelectorAll(selector));
118
+ }
119
+ function focusFirst() {
120
+ const all = items();
121
+ if (all.length > 0) all[0].focus();
122
+ }
123
+ function focusLast() {
124
+ const all = items();
125
+ if (all.length > 0) all[all.length - 1].focus();
126
+ }
127
+ function focusNext() {
128
+ const all = items();
129
+ if (all.length === 0) return;
130
+ const idx = all.indexOf(document.activeElement);
131
+ if (idx === -1) {
132
+ all[0].focus();
133
+ return;
134
+ }
135
+ const next = idx + 1;
136
+ if (next >= all.length) {
137
+ if (loop) all[0].focus();
138
+ return;
139
+ }
140
+ all[next].focus();
141
+ }
142
+ function focusPrev() {
143
+ const all = items();
144
+ if (all.length === 0) return;
145
+ const idx = all.indexOf(document.activeElement);
146
+ if (idx === -1) {
147
+ all[all.length - 1].focus();
148
+ return;
149
+ }
150
+ const prev = idx - 1;
151
+ if (prev < 0) {
152
+ if (loop) all[all.length - 1].focus();
153
+ return;
154
+ }
155
+ all[prev].focus();
156
+ }
157
+ return { focusFirst, focusLast, focusNext, focusPrev, items };
158
+ }
159
+ function createListbox(container, options = {}) {
160
+ const multiple = options.multiple ?? false;
161
+ const optionSelector = options.optionSelector ?? '[role="option"]';
162
+ container.setAttribute("role", "listbox");
163
+ if (multiple) container.setAttribute("aria-multiselectable", "true");
164
+ if (!container.hasAttribute("tabindex")) container.setAttribute("tabindex", "0");
165
+ const [activeValue, setActiveValue] = signal(null);
166
+ const [selectedValue, setSelectedValue] = signal(null);
167
+ const [activeDescendantId, setActiveDescendantId] = signal(null);
168
+ function stampIds() {
169
+ const opts = Array.from(container.querySelectorAll(optionSelector));
170
+ for (const opt of opts) {
171
+ if (!opt.id) opt.id = createId("listbox-option");
172
+ }
173
+ }
174
+ stampIds();
175
+ function getOptions() {
176
+ return Array.from(container.querySelectorAll(optionSelector));
177
+ }
178
+ function setActive(value) {
179
+ setActiveValue(value);
180
+ const opts = getOptions();
181
+ for (const opt of opts) {
182
+ if (opt.dataset.value === value) {
183
+ opt.setAttribute("data-highlighted", "");
184
+ setActiveDescendantId(opt.id || null);
185
+ container.setAttribute("aria-activedescendant", opt.id || "");
186
+ } else {
187
+ opt.removeAttribute("data-highlighted");
188
+ }
189
+ }
190
+ if (value === null) {
191
+ setActiveDescendantId(null);
192
+ container.removeAttribute("aria-activedescendant");
193
+ }
194
+ }
195
+ function select(value) {
196
+ if (multiple) {
197
+ const current2 = selectedValue();
198
+ const set = new Set((current2 ?? "").split(",").filter(Boolean));
199
+ if (set.has(value)) set.delete(value);
200
+ else set.add(value);
201
+ setSelectedValue(Array.from(set).join(","));
202
+ } else {
203
+ setSelectedValue(value);
204
+ }
205
+ options.onSelect?.(value);
206
+ const opts = getOptions();
207
+ const current = selectedValue();
208
+ const selected = new Set((current ?? "").split(",").filter(Boolean));
209
+ for (const opt of opts) {
210
+ const ov = opt.dataset.value ?? "";
211
+ opt.setAttribute("aria-selected", selected.has(ov) ? "true" : "false");
212
+ }
213
+ }
214
+ function moveActive(delta) {
215
+ const opts = getOptions();
216
+ if (opts.length === 0) return;
217
+ const currentIdx = opts.findIndex((o) => o.dataset.value === activeValue());
218
+ let next = currentIdx + delta;
219
+ if (next < 0) next = opts.length - 1;
220
+ if (next >= opts.length) next = 0;
221
+ const nextValue = opts[next].dataset.value ?? null;
222
+ setActive(nextValue);
223
+ if (typeof opts[next].scrollIntoView === "function") {
224
+ opts[next].scrollIntoView({ block: "nearest" });
225
+ }
226
+ }
227
+ function onKeyDown(e) {
228
+ switch (e.key) {
229
+ case "ArrowDown":
230
+ e.preventDefault();
231
+ moveActive(1);
232
+ break;
233
+ case "ArrowUp":
234
+ e.preventDefault();
235
+ moveActive(-1);
236
+ break;
237
+ case "Home": {
238
+ e.preventDefault();
239
+ const opts = getOptions();
240
+ if (opts.length > 0) setActive(opts[0].dataset.value ?? null);
241
+ break;
242
+ }
243
+ case "End": {
244
+ e.preventDefault();
245
+ const opts = getOptions();
246
+ if (opts.length > 0) setActive(opts[opts.length - 1].dataset.value ?? null);
247
+ break;
248
+ }
249
+ case "Enter":
250
+ case " ": {
251
+ e.preventDefault();
252
+ const active = activeValue();
253
+ if (active !== null) select(active);
254
+ break;
255
+ }
256
+ }
257
+ }
258
+ function onClick(e) {
259
+ const target = e.target.closest(optionSelector);
260
+ if (!target || !container.contains(target)) return;
261
+ const value = target.dataset.value ?? null;
262
+ if (value !== null) {
263
+ setActive(value);
264
+ select(value);
265
+ }
266
+ }
267
+ container.addEventListener("keydown", onKeyDown);
268
+ container.addEventListener("click", onClick);
269
+ function dispose() {
270
+ container.removeEventListener("keydown", onKeyDown);
271
+ container.removeEventListener("click", onClick);
272
+ }
273
+ registerDisposer(container, dispose);
274
+ return { activeValue, selectedValue, activeDescendantId, dispose };
275
+ }
276
+ function createDialogAria(element, options = {}) {
277
+ const titleId = options.labelledBy ?? createId("dialog-title");
278
+ const descriptionId = options.describedBy ?? createId("dialog-desc");
279
+ element.setAttribute("role", options.alert ? "alertdialog" : "dialog");
280
+ if (options.modal ?? true) element.setAttribute("aria-modal", "true");
281
+ element.setAttribute("aria-labelledby", titleId);
282
+ element.setAttribute("aria-describedby", descriptionId);
283
+ if (!element.hasAttribute("tabindex")) element.setAttribute("tabindex", "-1");
284
+ return { titleId, descriptionId };
285
+ }
67
286
 
68
287
  // src/ui/lazyEffect.ts
69
288
  function lazyEffect(element, effectFn, options) {
@@ -97,6 +316,99 @@ function lazyEffect(element, effectFn, options) {
97
316
  }
98
317
  };
99
318
  }
319
+
320
+ // src/ui/timers.ts
321
+ function interval(fn, ms) {
322
+ let id = null;
323
+ let running = false;
324
+ function start() {
325
+ if (running) return;
326
+ id = setInterval(fn, ms);
327
+ running = true;
328
+ }
329
+ function stop() {
330
+ if (id !== null) {
331
+ clearInterval(id);
332
+ id = null;
333
+ }
334
+ running = false;
335
+ }
336
+ start();
337
+ return {
338
+ stop,
339
+ pause: stop,
340
+ resume: start,
341
+ isRunning: () => running
342
+ };
343
+ }
344
+ function timeout(fn, ms) {
345
+ let pending = true;
346
+ const id = setTimeout(() => {
347
+ pending = false;
348
+ fn();
349
+ }, ms);
350
+ return {
351
+ cancel: () => {
352
+ if (pending) {
353
+ clearTimeout(id);
354
+ pending = false;
355
+ }
356
+ },
357
+ isPending: () => pending
358
+ };
359
+ }
360
+
361
+ // src/ui/hover.ts
362
+ function hover(target) {
363
+ const [hovered, setHovered] = signal(false);
364
+ if (typeof window === "undefined") {
365
+ return { hovered, dispose: () => {
366
+ } };
367
+ }
368
+ const onEnter = () => setHovered(true);
369
+ const onLeave = () => setHovered(false);
370
+ target.addEventListener("pointerenter", onEnter);
371
+ target.addEventListener("pointerleave", onLeave);
372
+ function dispose() {
373
+ target.removeEventListener("pointerenter", onEnter);
374
+ target.removeEventListener("pointerleave", onLeave);
375
+ }
376
+ return { hovered, dispose };
377
+ }
378
+
379
+ // src/ui/scrollLock.ts
380
+ var lockCount = 0;
381
+ var savedOverflow = null;
382
+ var savedPaddingRight = null;
383
+ function scrollLock() {
384
+ let owned = false;
385
+ function lock() {
386
+ if (owned) return;
387
+ owned = true;
388
+ lockCount++;
389
+ if (lockCount !== 1 || typeof document === "undefined") return;
390
+ const body = document.body;
391
+ const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
392
+ savedOverflow = body.style.overflow;
393
+ savedPaddingRight = body.style.paddingRight;
394
+ body.style.overflow = "hidden";
395
+ if (scrollBarWidth > 0) {
396
+ body.style.paddingRight = `${scrollBarWidth}px`;
397
+ }
398
+ }
399
+ function unlock() {
400
+ if (!owned) return;
401
+ owned = false;
402
+ lockCount = Math.max(0, lockCount - 1);
403
+ if (lockCount !== 0 || typeof document === "undefined") return;
404
+ const body = document.body;
405
+ body.style.overflow = savedOverflow ?? "";
406
+ body.style.paddingRight = savedPaddingRight ?? "";
407
+ savedOverflow = null;
408
+ savedPaddingRight = null;
409
+ }
410
+ return { lock, unlock };
411
+ }
100
412
  export {
101
413
  FocusTrap,
102
414
  RenderProp,
@@ -110,7 +422,10 @@ export {
110
422
  bindField,
111
423
  composable,
112
424
  compose,
425
+ createDialogAria,
426
+ createFocusManager,
113
427
  createGuard,
428
+ createListbox,
114
429
  createSlots,
115
430
  creditCardMask,
116
431
  custom,
@@ -124,10 +439,13 @@ export {
124
439
  eventBus,
125
440
  focus,
126
441
  form,
442
+ formAction,
127
443
  hotkey,
444
+ hover,
128
445
  infiniteScroll,
129
446
  inputMask,
130
447
  intersection,
448
+ interval,
131
449
  lazyEffect,
132
450
  lazyLoad,
133
451
  matchesPattern,
@@ -140,9 +458,11 @@ export {
140
458
  removeScopedStyle,
141
459
  required,
142
460
  scopedStyle,
461
+ scrollLock,
143
462
  ssnMask,
144
463
  svgElement,
145
464
  timeMask,
465
+ timeout,
146
466
  toast,
147
467
  validateProps,
148
468
  validators,
package/dist/widgets.js CHANGED
@@ -8,13 +8,13 @@ import {
8
8
  select,
9
9
  tabs,
10
10
  tooltip
11
- } from "./chunk-C6KFWOFV.js";
12
- import "./chunk-TNQWPPE6.js";
13
- import "./chunk-L6JRBDNS.js";
14
- import "./chunk-CHJ27IGK.js";
15
- import "./chunk-V2XTI523.js";
16
- import "./chunk-UNXCEF6S.js";
17
- import "./chunk-MLKGABMK.js";
11
+ } from "./chunk-EBGIRKQY.js";
12
+ import "./chunk-NYVAC6P5.js";
13
+ import "./chunk-NEKUBFPT.js";
14
+ import "./chunk-EUZND3CB.js";
15
+ import "./chunk-WZSPOOER.js";
16
+ import "./chunk-ZD6OAMTH.js";
17
+ import "./chunk-5X6PP2UK.js";
18
18
  export {
19
19
  accordion,
20
20
  combobox,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sibujs",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "A lightweight, function-based frontend framework that combines the best of React, Svelte, and Vue — with zero VDOM and maximum simplicity. Designed for developers who want fine-grained reactivity and full control without compilation or magic.",
5
5
  "keywords": [
6
6
  "frontend",