sibujs 1.1.0 → 1.2.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/build.cjs +52 -17
- package/dist/build.js +10 -3
- package/dist/cdn.global.js +4 -4
- package/dist/chunk-B7SWRFUT.js +332 -0
- package/dist/chunk-GCOK2LC3.js +282 -0
- package/dist/chunk-OUZZEE4S.js +365 -0
- package/dist/chunk-P6W3STU4.js +2249 -0
- package/dist/chunk-VMVDTCXB.js +712 -0
- package/dist/ecosystem.cjs +45 -17
- package/dist/ecosystem.js +2 -2
- package/dist/extras.cjs +45 -17
- package/dist/extras.js +4 -4
- package/dist/index.cjs +45 -17
- package/dist/index.js +3 -3
- package/dist/plugins.cjs +45 -17
- package/dist/plugins.js +2 -2
- package/dist/ssr.cjs +45 -17
- package/dist/ssr.js +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createPlugin
|
|
3
|
+
} from "./chunk-K5ZUMYVS.js";
|
|
4
|
+
import {
|
|
5
|
+
tagFactory
|
|
6
|
+
} from "./chunk-B7SWRFUT.js";
|
|
7
|
+
import {
|
|
8
|
+
derived
|
|
9
|
+
} from "./chunk-L6JRBDNS.js";
|
|
10
|
+
import {
|
|
11
|
+
effect
|
|
12
|
+
} from "./chunk-6SA3QQES.js";
|
|
13
|
+
import {
|
|
14
|
+
batch,
|
|
15
|
+
signal
|
|
16
|
+
} from "./chunk-V2XTI523.js";
|
|
17
|
+
|
|
18
|
+
// src/ecosystem/adapters/mobx.ts
|
|
19
|
+
function mobXAdapter(options) {
|
|
20
|
+
return createPlugin("sibu-mobx", (ctx) => {
|
|
21
|
+
const { autorun } = options;
|
|
22
|
+
const disposers = [];
|
|
23
|
+
function fromMobX(expression) {
|
|
24
|
+
const [getValue, setValue] = signal(expression());
|
|
25
|
+
const disposer = autorun(() => {
|
|
26
|
+
const newValue = expression();
|
|
27
|
+
batch(() => {
|
|
28
|
+
setValue(newValue);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
disposers.push(disposer);
|
|
32
|
+
return getValue;
|
|
33
|
+
}
|
|
34
|
+
function toMobX(sibuGetter, callback) {
|
|
35
|
+
return effect(() => {
|
|
36
|
+
callback(sibuGetter());
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function destroy() {
|
|
40
|
+
for (const disposer of disposers) {
|
|
41
|
+
disposer();
|
|
42
|
+
}
|
|
43
|
+
disposers.length = 0;
|
|
44
|
+
}
|
|
45
|
+
const api = { fromMobX, toMobX, destroy };
|
|
46
|
+
ctx.provide("mobx", api);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/ecosystem/adapters/redux.ts
|
|
51
|
+
function reduxAdapter(options) {
|
|
52
|
+
return createPlugin("sibu-redux", (ctx) => {
|
|
53
|
+
const { store } = options;
|
|
54
|
+
const [getState, setState] = signal(store.getState());
|
|
55
|
+
const unsubscribe = store.subscribe(() => {
|
|
56
|
+
batch(() => {
|
|
57
|
+
setState(store.getState());
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
function useSelector(selector) {
|
|
61
|
+
return derived(() => selector(getState()));
|
|
62
|
+
}
|
|
63
|
+
const api = {
|
|
64
|
+
getState,
|
|
65
|
+
useSelector,
|
|
66
|
+
dispatch: store.dispatch.bind(store),
|
|
67
|
+
destroy: unsubscribe
|
|
68
|
+
};
|
|
69
|
+
ctx.provide("redux", api);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/ecosystem/adapters/zustand.ts
|
|
74
|
+
function zustandAdapter(options) {
|
|
75
|
+
return createPlugin("sibu-zustand", (ctx) => {
|
|
76
|
+
const { store } = options;
|
|
77
|
+
const [getState, setSibuState] = signal(store.getState());
|
|
78
|
+
const unsubscribe = store.subscribe((state) => {
|
|
79
|
+
batch(() => {
|
|
80
|
+
setSibuState(state);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
function useSelector(selector) {
|
|
84
|
+
return derived(() => selector(getState()));
|
|
85
|
+
}
|
|
86
|
+
const api = {
|
|
87
|
+
getState,
|
|
88
|
+
useSelector,
|
|
89
|
+
setState: store.setState.bind(store),
|
|
90
|
+
destroy() {
|
|
91
|
+
unsubscribe();
|
|
92
|
+
store.destroy();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
ctx.provide("zustand", api);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/ecosystem/ui/componentAdapter.ts
|
|
100
|
+
function createTheme(initial) {
|
|
101
|
+
const [getConfig, setConfig] = signal(initial);
|
|
102
|
+
function resolveClass(component, variant) {
|
|
103
|
+
const config = getConfig();
|
|
104
|
+
const overrideKey = variant ? `${component}-${variant}` : component;
|
|
105
|
+
if (config.classOverrides?.[overrideKey]) {
|
|
106
|
+
return config.classOverrides[overrideKey];
|
|
107
|
+
}
|
|
108
|
+
const base = `${config.prefix}-${component}`;
|
|
109
|
+
return variant ? `${base} ${config.prefix}-${component}--${variant}` : base;
|
|
110
|
+
}
|
|
111
|
+
function setTheme(partial) {
|
|
112
|
+
setConfig((prev) => ({ ...prev, ...partial }));
|
|
113
|
+
}
|
|
114
|
+
return { config: getConfig, setTheme, resolveClass };
|
|
115
|
+
}
|
|
116
|
+
function componentAdapter(config) {
|
|
117
|
+
const theme = createTheme({ prefix: config.prefix });
|
|
118
|
+
const components = {};
|
|
119
|
+
for (const [name, mapping] of Object.entries(config.components)) {
|
|
120
|
+
const factory = tagFactory(mapping.tag || "div");
|
|
121
|
+
components[name] = (props = {}) => {
|
|
122
|
+
const { variant, size, class: userClass, ...rest } = props;
|
|
123
|
+
const classes = [mapping.baseClass];
|
|
124
|
+
if (variant && mapping.variants?.[variant]) {
|
|
125
|
+
classes.push(mapping.variants[variant]);
|
|
126
|
+
}
|
|
127
|
+
if (size && mapping.sizes?.[size]) {
|
|
128
|
+
classes.push(mapping.sizes[size]);
|
|
129
|
+
}
|
|
130
|
+
let finalClass;
|
|
131
|
+
if (typeof userClass === "function") {
|
|
132
|
+
finalClass = () => {
|
|
133
|
+
const extra = userClass();
|
|
134
|
+
return extra ? `${classes.join(" ")} ${extra}` : classes.join(" ");
|
|
135
|
+
};
|
|
136
|
+
} else if (typeof userClass === "string" && userClass) {
|
|
137
|
+
finalClass = `${classes.join(" ")} ${userClass}`;
|
|
138
|
+
} else {
|
|
139
|
+
finalClass = classes.join(" ");
|
|
140
|
+
}
|
|
141
|
+
const mergedProps = {
|
|
142
|
+
...mapping.defaultProps,
|
|
143
|
+
...rest,
|
|
144
|
+
class: finalClass
|
|
145
|
+
};
|
|
146
|
+
return factory(mergedProps);
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return { name: config.name, components, theme };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// src/ecosystem/ui/antd.ts
|
|
153
|
+
var antdConfig = {
|
|
154
|
+
name: "antd",
|
|
155
|
+
prefix: "ant",
|
|
156
|
+
components: {
|
|
157
|
+
Button: {
|
|
158
|
+
tag: "button",
|
|
159
|
+
baseClass: "ant-btn",
|
|
160
|
+
variants: {
|
|
161
|
+
primary: "ant-btn-primary",
|
|
162
|
+
dashed: "ant-btn-dashed",
|
|
163
|
+
text: "ant-btn-text",
|
|
164
|
+
link: "ant-btn-link",
|
|
165
|
+
default: "ant-btn-default",
|
|
166
|
+
danger: "ant-btn-dangerous"
|
|
167
|
+
},
|
|
168
|
+
sizes: {
|
|
169
|
+
sm: "ant-btn-sm",
|
|
170
|
+
lg: "ant-btn-lg"
|
|
171
|
+
},
|
|
172
|
+
defaultProps: { type: "button" }
|
|
173
|
+
},
|
|
174
|
+
Input: {
|
|
175
|
+
tag: "input",
|
|
176
|
+
baseClass: "ant-input",
|
|
177
|
+
sizes: {
|
|
178
|
+
sm: "ant-input-sm",
|
|
179
|
+
lg: "ant-input-lg"
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
Card: {
|
|
183
|
+
tag: "div",
|
|
184
|
+
baseClass: "ant-card",
|
|
185
|
+
variants: {
|
|
186
|
+
bordered: "ant-card-bordered"
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
Modal: {
|
|
190
|
+
tag: "div",
|
|
191
|
+
baseClass: "ant-modal"
|
|
192
|
+
},
|
|
193
|
+
Tag: {
|
|
194
|
+
tag: "span",
|
|
195
|
+
baseClass: "ant-tag",
|
|
196
|
+
variants: {
|
|
197
|
+
success: "ant-tag-success",
|
|
198
|
+
error: "ant-tag-error",
|
|
199
|
+
warning: "ant-tag-warning",
|
|
200
|
+
processing: "ant-tag-processing"
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
Badge: {
|
|
204
|
+
tag: "span",
|
|
205
|
+
baseClass: "ant-badge"
|
|
206
|
+
},
|
|
207
|
+
Avatar: {
|
|
208
|
+
tag: "span",
|
|
209
|
+
baseClass: "ant-avatar",
|
|
210
|
+
sizes: {
|
|
211
|
+
sm: "ant-avatar-sm",
|
|
212
|
+
lg: "ant-avatar-lg"
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
var antdAdapter = componentAdapter(antdConfig);
|
|
218
|
+
|
|
219
|
+
// src/ecosystem/ui/chakra.ts
|
|
220
|
+
var chakraConfig = {
|
|
221
|
+
name: "chakra",
|
|
222
|
+
prefix: "chakra",
|
|
223
|
+
components: {
|
|
224
|
+
Button: {
|
|
225
|
+
tag: "button",
|
|
226
|
+
baseClass: "chakra-button",
|
|
227
|
+
variants: {
|
|
228
|
+
solid: "chakra-button--solid",
|
|
229
|
+
outline: "chakra-button--outline",
|
|
230
|
+
ghost: "chakra-button--ghost",
|
|
231
|
+
link: "chakra-button--link"
|
|
232
|
+
},
|
|
233
|
+
sizes: {
|
|
234
|
+
xs: "chakra-button--xs",
|
|
235
|
+
sm: "chakra-button--sm",
|
|
236
|
+
md: "chakra-button--md",
|
|
237
|
+
lg: "chakra-button--lg"
|
|
238
|
+
},
|
|
239
|
+
defaultProps: { type: "button" }
|
|
240
|
+
},
|
|
241
|
+
Input: {
|
|
242
|
+
tag: "input",
|
|
243
|
+
baseClass: "chakra-input",
|
|
244
|
+
variants: {
|
|
245
|
+
outline: "chakra-input--outline",
|
|
246
|
+
filled: "chakra-input--filled",
|
|
247
|
+
flushed: "chakra-input--flushed",
|
|
248
|
+
unstyled: "chakra-input--unstyled"
|
|
249
|
+
},
|
|
250
|
+
sizes: {
|
|
251
|
+
xs: "chakra-input--xs",
|
|
252
|
+
sm: "chakra-input--sm",
|
|
253
|
+
md: "chakra-input--md",
|
|
254
|
+
lg: "chakra-input--lg"
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
Card: {
|
|
258
|
+
tag: "div",
|
|
259
|
+
baseClass: "chakra-card",
|
|
260
|
+
variants: {
|
|
261
|
+
elevated: "chakra-card--elevated",
|
|
262
|
+
outline: "chakra-card--outline",
|
|
263
|
+
filled: "chakra-card--filled",
|
|
264
|
+
unstyled: "chakra-card--unstyled"
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
Modal: {
|
|
268
|
+
tag: "div",
|
|
269
|
+
baseClass: "chakra-modal__content"
|
|
270
|
+
},
|
|
271
|
+
Badge: {
|
|
272
|
+
tag: "span",
|
|
273
|
+
baseClass: "chakra-badge",
|
|
274
|
+
variants: {
|
|
275
|
+
solid: "chakra-badge--solid",
|
|
276
|
+
subtle: "chakra-badge--subtle",
|
|
277
|
+
outline: "chakra-badge--outline"
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
Stack: {
|
|
281
|
+
tag: "div",
|
|
282
|
+
baseClass: "chakra-stack",
|
|
283
|
+
variants: {
|
|
284
|
+
horizontal: "chakra-stack--horizontal",
|
|
285
|
+
vertical: "chakra-stack--vertical"
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
var chakraAdapter = componentAdapter(chakraConfig);
|
|
291
|
+
|
|
292
|
+
// src/ecosystem/ui/material.ts
|
|
293
|
+
var materialConfig = {
|
|
294
|
+
name: "material",
|
|
295
|
+
prefix: "mdc",
|
|
296
|
+
components: {
|
|
297
|
+
Button: {
|
|
298
|
+
tag: "button",
|
|
299
|
+
baseClass: "mdc-button",
|
|
300
|
+
variants: {
|
|
301
|
+
raised: "mdc-button--raised",
|
|
302
|
+
outlined: "mdc-button--outlined",
|
|
303
|
+
text: "mdc-button--text",
|
|
304
|
+
unelevated: "mdc-button--unelevated"
|
|
305
|
+
},
|
|
306
|
+
sizes: {
|
|
307
|
+
sm: "mdc-button--dense"
|
|
308
|
+
},
|
|
309
|
+
defaultProps: { type: "button" }
|
|
310
|
+
},
|
|
311
|
+
Input: {
|
|
312
|
+
tag: "div",
|
|
313
|
+
baseClass: "mdc-text-field",
|
|
314
|
+
variants: {
|
|
315
|
+
outlined: "mdc-text-field--outlined",
|
|
316
|
+
filled: "mdc-text-field--filled"
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
Card: {
|
|
320
|
+
tag: "div",
|
|
321
|
+
baseClass: "mdc-card",
|
|
322
|
+
variants: {
|
|
323
|
+
outlined: "mdc-card--outlined",
|
|
324
|
+
elevated: "mdc-card--elevated"
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
Modal: {
|
|
328
|
+
tag: "div",
|
|
329
|
+
baseClass: "mdc-dialog",
|
|
330
|
+
variants: {
|
|
331
|
+
fullscreen: "mdc-dialog--fullscreen"
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
Chip: {
|
|
335
|
+
tag: "span",
|
|
336
|
+
baseClass: "mdc-chip",
|
|
337
|
+
variants: {
|
|
338
|
+
outlined: "mdc-chip--outlined"
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
List: {
|
|
342
|
+
tag: "ul",
|
|
343
|
+
baseClass: "mdc-list",
|
|
344
|
+
variants: {
|
|
345
|
+
dense: "mdc-list--dense"
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
ListItem: {
|
|
349
|
+
tag: "li",
|
|
350
|
+
baseClass: "mdc-list-item"
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
var materialAdapter = componentAdapter(materialConfig);
|
|
355
|
+
|
|
356
|
+
export {
|
|
357
|
+
mobXAdapter,
|
|
358
|
+
reduxAdapter,
|
|
359
|
+
zustandAdapter,
|
|
360
|
+
createTheme,
|
|
361
|
+
componentAdapter,
|
|
362
|
+
antdAdapter,
|
|
363
|
+
chakraAdapter,
|
|
364
|
+
materialAdapter
|
|
365
|
+
};
|