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