what-core 0.14.0 → 0.15.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 (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -38
  3. package/a11y.d.ts +128 -0
  4. package/data.d.ts +294 -0
  5. package/dist/a11y.js +510 -0
  6. package/dist/a11y.min.js +413 -0
  7. package/dist/actions.js +158 -0
  8. package/dist/actions.min.js +112 -0
  9. package/dist/animation.js +481 -0
  10. package/dist/animation.min.js +295 -0
  11. package/dist/async.js +180 -0
  12. package/dist/async.min.js +134 -0
  13. package/dist/components.js +577 -0
  14. package/dist/components.min.js +413 -0
  15. package/dist/data.js +1212 -0
  16. package/dist/data.min.js +918 -0
  17. package/dist/diagnostics.js +187 -0
  18. package/dist/diagnostics.min.js +134 -0
  19. package/dist/dom.js +796 -0
  20. package/dist/dom.min.js +603 -0
  21. package/dist/entries/a11y.js +43 -0
  22. package/dist/entries/a11y.min.js +43 -0
  23. package/dist/entries/data.js +29 -0
  24. package/dist/entries/data.min.js +29 -0
  25. package/dist/entries/dom.js +45 -0
  26. package/dist/entries/dom.min.js +45 -0
  27. package/dist/entries/form.js +31 -0
  28. package/dist/entries/form.min.js +31 -0
  29. package/dist/entries/internal.js +123 -0
  30. package/dist/entries/internal.min.js +123 -0
  31. package/dist/entries/motion.js +23 -0
  32. package/dist/entries/motion.min.js +23 -0
  33. package/dist/entries/ui.js +25 -0
  34. package/dist/entries/ui.min.js +25 -0
  35. package/dist/env.js +5 -0
  36. package/dist/env.min.js +5 -0
  37. package/dist/errors.js +1518 -0
  38. package/dist/errors.min.js +548 -0
  39. package/dist/form.js +936 -0
  40. package/dist/form.min.js +703 -0
  41. package/dist/guardrails.js +84 -0
  42. package/dist/guardrails.min.js +55 -0
  43. package/dist/h.js +232 -0
  44. package/dist/h.min.js +171 -0
  45. package/dist/head.js +241 -0
  46. package/dist/head.min.js +207 -0
  47. package/dist/helpers.js +126 -0
  48. package/dist/helpers.min.js +98 -0
  49. package/dist/hooks.js +255 -0
  50. package/dist/hooks.min.js +153 -0
  51. package/dist/hot.js +215 -0
  52. package/dist/hot.min.js +24 -0
  53. package/dist/hydration-data.js +495 -0
  54. package/dist/hydration-data.min.js +371 -0
  55. package/dist/import-changes.js +273 -0
  56. package/dist/import-changes.min.js +272 -0
  57. package/dist/index.js +95 -0
  58. package/dist/index.min.js +95 -227
  59. package/dist/jsx-dev-runtime.js +10 -0
  60. package/dist/jsx-dev-runtime.min.js +10 -1
  61. package/dist/jsx-runtime.js +27 -0
  62. package/dist/jsx-runtime.min.js +15 -1
  63. package/dist/live.js +54 -0
  64. package/dist/live.min.js +49 -0
  65. package/dist/markup-rules.js +250 -0
  66. package/dist/markup-rules.min.js +213 -0
  67. package/dist/reactive.js +3334 -0
  68. package/dist/reactive.min.js +2033 -0
  69. package/dist/render.js +4746 -0
  70. package/dist/render.min.js +2797 -1
  71. package/dist/scheduler.js +225 -0
  72. package/dist/scheduler.min.js +162 -0
  73. package/dist/selector.js +11 -0
  74. package/dist/selector.min.js +10 -0
  75. package/dist/server-context.js +148 -0
  76. package/dist/server-context.min.js +121 -0
  77. package/dist/skeleton.js +342 -0
  78. package/dist/skeleton.min.js +310 -0
  79. package/dist/store.js +72 -0
  80. package/dist/store.min.js +50 -0
  81. package/dist/testing.js +720 -0
  82. package/dist/testing.min.js +458 -1
  83. package/dist/vnode-adoption.js +19 -0
  84. package/dist/vnode-adoption.min.js +19 -0
  85. package/dist/vnode-renderer.js +61 -0
  86. package/dist/vnode-renderer.min.js +47 -0
  87. package/dom.d.ts +44 -0
  88. package/form.d.ts +218 -0
  89. package/hot.d.ts +35 -0
  90. package/index.d.ts +421 -736
  91. package/internal.d.ts +284 -0
  92. package/jsx-runtime.d.ts +160 -137
  93. package/markup-rules.d.ts +83 -0
  94. package/motion.d.ts +156 -0
  95. package/package.json +117 -3
  96. package/render.d.ts +278 -29
  97. package/src/a11y.js +64 -59
  98. package/src/actions.js +226 -0
  99. package/src/animation.js +105 -57
  100. package/src/async.js +259 -0
  101. package/src/components.js +495 -144
  102. package/src/data.js +1410 -1159
  103. package/src/diagnostics.js +263 -0
  104. package/src/dom.js +1159 -872
  105. package/src/entries/a11y.js +24 -0
  106. package/src/entries/data.js +17 -0
  107. package/src/entries/dom.js +29 -0
  108. package/src/entries/form.js +16 -0
  109. package/src/entries/internal.js +63 -0
  110. package/src/entries/motion.js +13 -0
  111. package/src/entries/ui.js +13 -0
  112. package/src/env-development.js +12 -0
  113. package/src/env.js +33 -0
  114. package/src/errors.js +1144 -168
  115. package/src/form.js +723 -225
  116. package/src/guardrails.js +38 -126
  117. package/src/h.js +227 -152
  118. package/src/head.js +189 -19
  119. package/src/helpers.js +47 -75
  120. package/src/hooks.js +233 -248
  121. package/src/hot.js +316 -0
  122. package/src/hydration-data.js +859 -16
  123. package/src/import-changes.js +156 -0
  124. package/src/index.js +38 -188
  125. package/src/jsx-dev-runtime.js +7 -14
  126. package/src/jsx-runtime.js +25 -9
  127. package/src/live.js +80 -0
  128. package/src/markup-rules.js +387 -0
  129. package/src/reactive.js +4400 -862
  130. package/src/render.js +6502 -2570
  131. package/src/scheduler.js +56 -21
  132. package/src/selector.js +31 -0
  133. package/src/server-context.js +252 -22
  134. package/src/skeleton.js +22 -12
  135. package/src/store.js +17 -31
  136. package/src/testing.js +389 -63
  137. package/src/vnode-adoption.js +48 -0
  138. package/src/vnode-renderer.js +114 -0
  139. package/testing.d.ts +81 -1
  140. package/ui.d.ts +20 -0
  141. package/dist/chunk-6YOUZ6T4.min.js +0 -1
  142. package/dist/chunk-FN6HXME3.min.js +0 -11
  143. package/dist/chunk-VKZY7JPN.min.js +0 -1
  144. package/src/agent-context.js +0 -127
  145. package/src/warnings.js +0 -193
@@ -0,0 +1,342 @@
1
+ // src/skeleton.js
2
+ import { h } from "./h.js";
3
+ import { signal, effect } from "./reactive.js";
4
+ var skeletonStyles = `
5
+ .what-skeleton {
6
+ background: linear-gradient(
7
+ 90deg,
8
+ var(--skeleton-base, #e0e0e0) 0%,
9
+ var(--skeleton-highlight, #f0f0f0) 50%,
10
+ var(--skeleton-base, #e0e0e0) 100%
11
+ );
12
+ background-size: 200% 100%;
13
+ animation: what-skeleton-shimmer 1.5s infinite ease-in-out;
14
+ border-radius: var(--skeleton-radius, 4px);
15
+ }
16
+
17
+ @keyframes what-skeleton-shimmer {
18
+ 0% { background-position: 200% 0; }
19
+ 100% { background-position: -200% 0; }
20
+ }
21
+
22
+ .what-skeleton-pulse {
23
+ animation: what-skeleton-pulse 1.5s infinite ease-in-out;
24
+ }
25
+
26
+ @keyframes what-skeleton-pulse {
27
+ 0%, 100% { opacity: 1; }
28
+ 50% { opacity: 0.5; }
29
+ }
30
+
31
+ .what-skeleton-wave {
32
+ position: relative;
33
+ overflow: hidden;
34
+ }
35
+
36
+ .what-skeleton-wave::after {
37
+ content: '';
38
+ position: absolute;
39
+ top: 0;
40
+ right: 0;
41
+ bottom: 0;
42
+ left: 0;
43
+ background: linear-gradient(
44
+ 90deg,
45
+ transparent 0%,
46
+ rgba(255, 255, 255, 0.4) 50%,
47
+ transparent 100%
48
+ );
49
+ animation: what-skeleton-wave 1.5s infinite;
50
+ }
51
+
52
+ @keyframes what-skeleton-wave {
53
+ 0% { transform: translateX(-100%); }
54
+ 100% { transform: translateX(100%); }
55
+ }
56
+ `;
57
+ var stylesInjected = false;
58
+ function injectStyles() {
59
+ if (stylesInjected || typeof document === "undefined") return;
60
+ stylesInjected = true;
61
+ const style = document.createElement("style");
62
+ style.textContent = skeletonStyles;
63
+ document.head.appendChild(style);
64
+ }
65
+ function Skeleton({
66
+ width,
67
+ height,
68
+ variant = "shimmer",
69
+ // 'shimmer' | 'pulse' | 'wave'
70
+ circle = false,
71
+ class: className,
72
+ style: customStyle,
73
+ count = 1
74
+ } = {}) {
75
+ injectStyles();
76
+ const baseClass = `what-skeleton ${variant === "pulse" ? "what-skeleton-pulse" : ""} ${variant === "wave" ? "what-skeleton-wave" : ""}`;
77
+ const withClass = (extra) => extra ? `${baseClass} ${extra}` : baseClass;
78
+ const finalClass = typeof className === "function" ? () => withClass(className()) : withClass(className);
79
+ const style = {
80
+ width: typeof width === "number" ? `${width}px` : width,
81
+ height: typeof height === "number" ? `${height}px` : height,
82
+ borderRadius: circle ? "50%" : void 0,
83
+ ...customStyle
84
+ };
85
+ if (count === 1) {
86
+ return h("div", { class: finalClass, style, "aria-hidden": "true" });
87
+ }
88
+ return Array.from(
89
+ { length: count },
90
+ (_, i) => h("div", {
91
+ key: i,
92
+ class: finalClass,
93
+ style: { ...style, marginBottom: i < count - 1 ? "8px" : void 0 },
94
+ "aria-hidden": "true"
95
+ })
96
+ );
97
+ }
98
+ function SkeletonText({
99
+ lines = 3,
100
+ lastLineWidth = "60%",
101
+ lineHeight = 16,
102
+ gap = 8,
103
+ variant = "shimmer"
104
+ } = {}) {
105
+ injectStyles();
106
+ return h(
107
+ "div",
108
+ { class: "what-skeleton-text", "aria-hidden": "true" },
109
+ Array.from(
110
+ { length: lines },
111
+ (_, i) => h("div", {
112
+ key: i,
113
+ class: `what-skeleton ${variant === "pulse" ? "what-skeleton-pulse" : ""}`,
114
+ style: {
115
+ height: `${lineHeight}px`,
116
+ width: i === lines - 1 ? lastLineWidth : "100%",
117
+ marginBottom: i < lines - 1 ? `${gap}px` : void 0
118
+ }
119
+ })
120
+ )
121
+ );
122
+ }
123
+ function SkeletonAvatar({
124
+ size = 40,
125
+ variant = "shimmer"
126
+ } = {}) {
127
+ return Skeleton({
128
+ width: size,
129
+ height: size,
130
+ circle: true,
131
+ variant
132
+ });
133
+ }
134
+ function SkeletonCard({
135
+ imageHeight = 200,
136
+ lines = 3,
137
+ variant = "shimmer"
138
+ } = {}) {
139
+ injectStyles();
140
+ return h(
141
+ "div",
142
+ { class: "what-skeleton-card", "aria-hidden": "true" },
143
+ // Image placeholder
144
+ h("div", {
145
+ class: `what-skeleton ${variant === "pulse" ? "what-skeleton-pulse" : ""}`,
146
+ style: { height: `${imageHeight}px`, width: "100%", marginBottom: "16px" }
147
+ }),
148
+ // Title
149
+ h("div", {
150
+ class: `what-skeleton ${variant === "pulse" ? "what-skeleton-pulse" : ""}`,
151
+ style: { height: "24px", width: "70%", marginBottom: "12px" }
152
+ }),
153
+ // Text lines
154
+ SkeletonText({ lines, variant })
155
+ );
156
+ }
157
+ function SkeletonTable({
158
+ rows = 5,
159
+ columns = 4,
160
+ variant = "shimmer"
161
+ } = {}) {
162
+ injectStyles();
163
+ return h(
164
+ "div",
165
+ { class: "what-skeleton-table", "aria-hidden": "true" },
166
+ // Header
167
+ h(
168
+ "div",
169
+ { style: { display: "flex", gap: "16px", marginBottom: "16px" } },
170
+ Array.from(
171
+ { length: columns },
172
+ (_, i) => h("div", {
173
+ key: i,
174
+ class: `what-skeleton ${variant === "pulse" ? "what-skeleton-pulse" : ""}`,
175
+ style: { height: "20px", flex: 1 }
176
+ })
177
+ )
178
+ ),
179
+ // Rows
180
+ Array.from(
181
+ { length: rows },
182
+ (_, rowIndex) => h(
183
+ "div",
184
+ {
185
+ key: rowIndex,
186
+ style: {
187
+ display: "flex",
188
+ gap: "16px",
189
+ marginBottom: rowIndex < rows - 1 ? "12px" : void 0
190
+ }
191
+ },
192
+ Array.from(
193
+ { length: columns },
194
+ (_2, colIndex) => h("div", {
195
+ key: colIndex,
196
+ class: `what-skeleton ${variant === "pulse" ? "what-skeleton-pulse" : ""}`,
197
+ style: { height: "16px", flex: 1 }
198
+ })
199
+ )
200
+ )
201
+ )
202
+ );
203
+ }
204
+ function IslandSkeleton({
205
+ type = "default",
206
+ // 'default' | 'card' | 'text' | 'custom'
207
+ height,
208
+ children
209
+ } = {}) {
210
+ injectStyles();
211
+ if (type === "card") {
212
+ return SkeletonCard({});
213
+ }
214
+ if (type === "text") {
215
+ return SkeletonText({});
216
+ }
217
+ if (children) {
218
+ return children;
219
+ }
220
+ return h("div", {
221
+ class: "what-skeleton what-island-skeleton",
222
+ style: {
223
+ height: typeof height === "number" ? `${height}px` : height || "100px",
224
+ width: "100%"
225
+ },
226
+ "aria-hidden": "true"
227
+ });
228
+ }
229
+ function useSkeleton(asyncFn, _deps = []) {
230
+ const isLoading = signal(true);
231
+ const data = signal(null);
232
+ const error = signal(null);
233
+ let latest = 0;
234
+ effect(() => {
235
+ const run = ++latest;
236
+ isLoading.set(true);
237
+ error.set(null);
238
+ Promise.resolve(asyncFn()).then((result) => {
239
+ if (run !== latest) return;
240
+ data.set(() => result);
241
+ isLoading.set(false);
242
+ }).catch((err) => {
243
+ if (run !== latest) return;
244
+ error.set(err);
245
+ isLoading.set(false);
246
+ });
247
+ });
248
+ return {
249
+ isLoading: () => isLoading(),
250
+ data: () => data(),
251
+ error: () => error(),
252
+ Skeleton: (props) => isLoading() ? Skeleton(props) : null
253
+ };
254
+ }
255
+ function Placeholder({
256
+ width = "100%",
257
+ height = 100,
258
+ label = "Loading...",
259
+ showLabel = false,
260
+ variant = "shimmer"
261
+ } = {}) {
262
+ injectStyles();
263
+ return h(
264
+ "div",
265
+ {
266
+ class: `what-skeleton ${variant === "pulse" ? "what-skeleton-pulse" : ""}`,
267
+ style: {
268
+ width: typeof width === "number" ? `${width}px` : width,
269
+ height: typeof height === "number" ? `${height}px` : height,
270
+ display: "flex",
271
+ alignItems: "center",
272
+ justifyContent: "center"
273
+ },
274
+ "aria-label": label,
275
+ role: "status"
276
+ },
277
+ showLabel && h("span", {
278
+ style: {
279
+ color: "var(--skeleton-text, #999)",
280
+ fontSize: "14px"
281
+ }
282
+ }, label)
283
+ );
284
+ }
285
+ function LoadingDots({ size = 8, color = "#666" } = {}) {
286
+ injectStyles();
287
+ const dotStyle = {
288
+ width: `${size}px`,
289
+ height: `${size}px`,
290
+ borderRadius: "50%",
291
+ backgroundColor: color,
292
+ animation: "what-skeleton-pulse 1s infinite ease-in-out"
293
+ };
294
+ return h(
295
+ "div",
296
+ {
297
+ class: "what-loading-dots",
298
+ style: { display: "flex", gap: `${size / 2}px` },
299
+ "aria-label": "Loading",
300
+ role: "status"
301
+ },
302
+ h("div", { style: { ...dotStyle, animationDelay: "0s" } }),
303
+ h("div", { style: { ...dotStyle, animationDelay: "0.2s" } }),
304
+ h("div", { style: { ...dotStyle, animationDelay: "0.4s" } })
305
+ );
306
+ }
307
+ function Spinner({ size = 24, color = "#666", strokeWidth = 2 } = {}) {
308
+ return h(
309
+ "svg",
310
+ {
311
+ width: size,
312
+ height: size,
313
+ viewBox: "0 0 24 24",
314
+ style: { animation: "spin 1s linear infinite" },
315
+ "aria-label": "Loading",
316
+ role: "status"
317
+ },
318
+ h("style", null, "@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }"),
319
+ h("circle", {
320
+ cx: 12,
321
+ cy: 12,
322
+ r: 10,
323
+ stroke: color,
324
+ strokeWidth,
325
+ fill: "none",
326
+ strokeDasharray: "31.4 31.4",
327
+ strokeLinecap: "round"
328
+ })
329
+ );
330
+ }
331
+ export {
332
+ IslandSkeleton,
333
+ LoadingDots,
334
+ Placeholder,
335
+ Skeleton,
336
+ SkeletonAvatar,
337
+ SkeletonCard,
338
+ SkeletonTable,
339
+ SkeletonText,
340
+ Spinner,
341
+ useSkeleton
342
+ };
@@ -0,0 +1,310 @@
1
+ // src/skeleton.js
2
+ import { h as s } from "./h.min.js";
3
+ import { signal as p, effect as x } from "./reactive.min.js";
4
+ var w = `
5
+ .what-skeleton {
6
+ background: linear-gradient(
7
+ 90deg,
8
+ var(--skeleton-base, #e0e0e0) 0%,
9
+ var(--skeleton-highlight, #f0f0f0) 50%,
10
+ var(--skeleton-base, #e0e0e0) 100%
11
+ );
12
+ background-size: 200% 100%;
13
+ animation: what-skeleton-shimmer 1.5s infinite ease-in-out;
14
+ border-radius: var(--skeleton-radius, 4px);
15
+ }
16
+
17
+ @keyframes what-skeleton-shimmer {
18
+ 0% { background-position: 200% 0; }
19
+ 100% { background-position: -200% 0; }
20
+ }
21
+
22
+ .what-skeleton-pulse {
23
+ animation: what-skeleton-pulse 1.5s infinite ease-in-out;
24
+ }
25
+
26
+ @keyframes what-skeleton-pulse {
27
+ 0%, 100% { opacity: 1; }
28
+ 50% { opacity: 0.5; }
29
+ }
30
+
31
+ .what-skeleton-wave {
32
+ position: relative;
33
+ overflow: hidden;
34
+ }
35
+
36
+ .what-skeleton-wave::after {
37
+ content: '';
38
+ position: absolute;
39
+ top: 0;
40
+ right: 0;
41
+ bottom: 0;
42
+ left: 0;
43
+ background: linear-gradient(
44
+ 90deg,
45
+ transparent 0%,
46
+ rgba(255, 255, 255, 0.4) 50%,
47
+ transparent 100%
48
+ );
49
+ animation: what-skeleton-wave 1.5s infinite;
50
+ }
51
+
52
+ @keyframes what-skeleton-wave {
53
+ 0% { transform: translateX(-100%); }
54
+ 100% { transform: translateX(100%); }
55
+ }
56
+ `, c = !1;
57
+ function i() {
58
+ if (c || typeof document > "u") return;
59
+ c = !0;
60
+ let e = document.createElement("style");
61
+ e.textContent = w, document.head.appendChild(e);
62
+ }
63
+ function y({
64
+ width: e,
65
+ height: n,
66
+ variant: t = "shimmer",
67
+ // 'shimmer' | 'pulse' | 'wave'
68
+ circle: r = !1,
69
+ class: a,
70
+ style: l,
71
+ count: o = 1
72
+ } = {}) {
73
+ i();
74
+ let d = `what-skeleton ${t === "pulse" ? "what-skeleton-pulse" : ""} ${t === "wave" ? "what-skeleton-wave" : ""}`, h = (u) => u ? `${d} ${u}` : d, f = typeof a == "function" ? () => h(a()) : h(a), k = {
75
+ width: typeof e == "number" ? `${e}px` : e,
76
+ height: typeof n == "number" ? `${n}px` : n,
77
+ borderRadius: r ? "50%" : void 0,
78
+ ...l
79
+ };
80
+ return o === 1 ? s("div", { class: f, style: k, "aria-hidden": "true" }) : Array.from(
81
+ { length: o },
82
+ (u, m) => s("div", {
83
+ key: m,
84
+ class: f,
85
+ style: { ...k, marginBottom: m < o - 1 ? "8px" : void 0 },
86
+ "aria-hidden": "true"
87
+ })
88
+ );
89
+ }
90
+ function g({
91
+ lines: e = 3,
92
+ lastLineWidth: n = "60%",
93
+ lineHeight: t = 16,
94
+ gap: r = 8,
95
+ variant: a = "shimmer"
96
+ } = {}) {
97
+ return i(), s(
98
+ "div",
99
+ { class: "what-skeleton-text", "aria-hidden": "true" },
100
+ Array.from(
101
+ { length: e },
102
+ (l, o) => s("div", {
103
+ key: o,
104
+ class: `what-skeleton ${a === "pulse" ? "what-skeleton-pulse" : ""}`,
105
+ style: {
106
+ height: `${t}px`,
107
+ width: o === e - 1 ? n : "100%",
108
+ marginBottom: o < e - 1 ? `${r}px` : void 0
109
+ }
110
+ })
111
+ )
112
+ );
113
+ }
114
+ function S({
115
+ size: e = 40,
116
+ variant: n = "shimmer"
117
+ } = {}) {
118
+ return y({
119
+ width: e,
120
+ height: e,
121
+ circle: !0,
122
+ variant: n
123
+ });
124
+ }
125
+ function v({
126
+ imageHeight: e = 200,
127
+ lines: n = 3,
128
+ variant: t = "shimmer"
129
+ } = {}) {
130
+ return i(), s(
131
+ "div",
132
+ { class: "what-skeleton-card", "aria-hidden": "true" },
133
+ // Image placeholder
134
+ s("div", {
135
+ class: `what-skeleton ${t === "pulse" ? "what-skeleton-pulse" : ""}`,
136
+ style: { height: `${e}px`, width: "100%", marginBottom: "16px" }
137
+ }),
138
+ // Title
139
+ s("div", {
140
+ class: `what-skeleton ${t === "pulse" ? "what-skeleton-pulse" : ""}`,
141
+ style: { height: "24px", width: "70%", marginBottom: "12px" }
142
+ }),
143
+ // Text lines
144
+ g({ lines: n, variant: t })
145
+ );
146
+ }
147
+ function C({
148
+ rows: e = 5,
149
+ columns: n = 4,
150
+ variant: t = "shimmer"
151
+ } = {}) {
152
+ return i(), s(
153
+ "div",
154
+ { class: "what-skeleton-table", "aria-hidden": "true" },
155
+ // Header
156
+ s(
157
+ "div",
158
+ { style: { display: "flex", gap: "16px", marginBottom: "16px" } },
159
+ Array.from(
160
+ { length: n },
161
+ (r, a) => s("div", {
162
+ key: a,
163
+ class: `what-skeleton ${t === "pulse" ? "what-skeleton-pulse" : ""}`,
164
+ style: { height: "20px", flex: 1 }
165
+ })
166
+ )
167
+ ),
168
+ // Rows
169
+ Array.from(
170
+ { length: e },
171
+ (r, a) => s(
172
+ "div",
173
+ {
174
+ key: a,
175
+ style: {
176
+ display: "flex",
177
+ gap: "16px",
178
+ marginBottom: a < e - 1 ? "12px" : void 0
179
+ }
180
+ },
181
+ Array.from(
182
+ { length: n },
183
+ (l, o) => s("div", {
184
+ key: o,
185
+ class: `what-skeleton ${t === "pulse" ? "what-skeleton-pulse" : ""}`,
186
+ style: { height: "16px", flex: 1 }
187
+ })
188
+ )
189
+ )
190
+ )
191
+ );
192
+ }
193
+ function B({
194
+ type: e = "default",
195
+ // 'default' | 'card' | 'text' | 'custom'
196
+ height: n,
197
+ children: t
198
+ } = {}) {
199
+ return i(), e === "card" ? v({}) : e === "text" ? g({}) : t || s("div", {
200
+ class: "what-skeleton what-island-skeleton",
201
+ style: {
202
+ height: typeof n == "number" ? `${n}px` : n || "100px",
203
+ width: "100%"
204
+ },
205
+ "aria-hidden": "true"
206
+ });
207
+ }
208
+ function L(e, n = []) {
209
+ let t = p(!0), r = p(null), a = p(null), l = 0;
210
+ return x(() => {
211
+ let o = ++l;
212
+ t.set(!0), a.set(null), Promise.resolve(e()).then((d) => {
213
+ o === l && (r.set(() => d), t.set(!1));
214
+ }).catch((d) => {
215
+ o === l && (a.set(d), t.set(!1));
216
+ });
217
+ }), {
218
+ isLoading: () => t(),
219
+ data: () => r(),
220
+ error: () => a(),
221
+ Skeleton: (o) => t() ? y(o) : null
222
+ };
223
+ }
224
+ function A({
225
+ width: e = "100%",
226
+ height: n = 100,
227
+ label: t = "Loading...",
228
+ showLabel: r = !1,
229
+ variant: a = "shimmer"
230
+ } = {}) {
231
+ return i(), s(
232
+ "div",
233
+ {
234
+ class: `what-skeleton ${a === "pulse" ? "what-skeleton-pulse" : ""}`,
235
+ style: {
236
+ width: typeof e == "number" ? `${e}px` : e,
237
+ height: typeof n == "number" ? `${n}px` : n,
238
+ display: "flex",
239
+ alignItems: "center",
240
+ justifyContent: "center"
241
+ },
242
+ "aria-label": t,
243
+ role: "status"
244
+ },
245
+ r && s("span", {
246
+ style: {
247
+ color: "var(--skeleton-text, #999)",
248
+ fontSize: "14px"
249
+ }
250
+ }, t)
251
+ );
252
+ }
253
+ function _({ size: e = 8, color: n = "#666" } = {}) {
254
+ i();
255
+ let t = {
256
+ width: `${e}px`,
257
+ height: `${e}px`,
258
+ borderRadius: "50%",
259
+ backgroundColor: n,
260
+ animation: "what-skeleton-pulse 1s infinite ease-in-out"
261
+ };
262
+ return s(
263
+ "div",
264
+ {
265
+ class: "what-loading-dots",
266
+ style: { display: "flex", gap: `${e / 2}px` },
267
+ "aria-label": "Loading",
268
+ role: "status"
269
+ },
270
+ s("div", { style: { ...t, animationDelay: "0s" } }),
271
+ s("div", { style: { ...t, animationDelay: "0.2s" } }),
272
+ s("div", { style: { ...t, animationDelay: "0.4s" } })
273
+ );
274
+ }
275
+ function D({ size: e = 24, color: n = "#666", strokeWidth: t = 2 } = {}) {
276
+ return s(
277
+ "svg",
278
+ {
279
+ width: e,
280
+ height: e,
281
+ viewBox: "0 0 24 24",
282
+ style: { animation: "spin 1s linear infinite" },
283
+ "aria-label": "Loading",
284
+ role: "status"
285
+ },
286
+ s("style", null, "@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }"),
287
+ s("circle", {
288
+ cx: 12,
289
+ cy: 12,
290
+ r: 10,
291
+ stroke: n,
292
+ strokeWidth: t,
293
+ fill: "none",
294
+ strokeDasharray: "31.4 31.4",
295
+ strokeLinecap: "round"
296
+ })
297
+ );
298
+ }
299
+ export {
300
+ B as IslandSkeleton,
301
+ _ as LoadingDots,
302
+ A as Placeholder,
303
+ y as Skeleton,
304
+ S as SkeletonAvatar,
305
+ v as SkeletonCard,
306
+ C as SkeletonTable,
307
+ g as SkeletonText,
308
+ D as Spinner,
309
+ L as useSkeleton
310
+ };
package/dist/store.js ADDED
@@ -0,0 +1,72 @@
1
+ // src/store.js
2
+ import { signal, computed, batch } from "./reactive.js";
3
+ import { report } from "./diagnostics.js";
4
+ function derived(fn) {
5
+ fn._storeComputed = true;
6
+ return fn;
7
+ }
8
+ function createStore(definition) {
9
+ const signals = {};
10
+ const computeds = {};
11
+ const actions = {};
12
+ for (const [key, value] of Object.entries(definition)) {
13
+ if (typeof value === "function" && value._storeComputed) {
14
+ if ((process.env.NODE_ENV !== "production") && value.length === 0) {
15
+ report("ERR_DERIVED_WITHOUT_STATE", { data: { key } });
16
+ }
17
+ computeds[key] = value;
18
+ } else if (typeof value === "function") {
19
+ actions[key] = value;
20
+ } else {
21
+ signals[key] = signal(value);
22
+ }
23
+ }
24
+ for (const [key, fn] of Object.entries(computeds)) {
25
+ const proxy = new Proxy({}, {
26
+ get(_, prop) {
27
+ if (signals[prop]) return signals[prop]();
28
+ if (computeds[prop]) return computeds[prop]();
29
+ return void 0;
30
+ }
31
+ });
32
+ computeds[key] = computed(() => fn(proxy));
33
+ }
34
+ for (const [key, fn] of Object.entries(actions)) {
35
+ actions[key] = (...args) => {
36
+ let result;
37
+ batch(() => {
38
+ const proxy = new Proxy({}, {
39
+ get(_, prop) {
40
+ if (signals[prop]) return signals[prop].peek();
41
+ if (computeds[prop]) return computeds[prop].peek();
42
+ if (actions[prop]) return actions[prop];
43
+ return void 0;
44
+ },
45
+ set(_, prop, val) {
46
+ if (signals[prop]) signals[prop].set(val);
47
+ return true;
48
+ }
49
+ });
50
+ result = fn.apply(proxy, args);
51
+ });
52
+ return result;
53
+ };
54
+ }
55
+ return function useStore() {
56
+ const result = {};
57
+ for (const [key, s] of Object.entries(signals)) {
58
+ Object.defineProperty(result, key, { get: () => s(), enumerable: true });
59
+ }
60
+ for (const [key, c] of Object.entries(computeds)) {
61
+ Object.defineProperty(result, key, { get: () => c(), enumerable: true });
62
+ }
63
+ for (const [key, fn] of Object.entries(actions)) {
64
+ result[key] = fn;
65
+ }
66
+ return result;
67
+ };
68
+ }
69
+ export {
70
+ createStore,
71
+ derived
72
+ };