fiboui 1.0.0 → 1.0.1
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 +144 -73
- package/dist/core/StateWrapper.d.ts +3 -0
- package/dist/core/builder.d.ts +4 -1
- package/dist/core/effects.d.ts +4 -3
- package/dist/core/hooks.d.ts +5 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/state.d.ts +76 -27
- package/dist/effects-D16XdB_d.mjs +10 -0
- package/dist/index.esm.js +1181 -1026
- package/dist/index.umd.js +4 -4
- package/dist/interactive/TextField/index.d.ts +3 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/core/StateWrapper.tsx +28 -2
- package/src/core/builder.ts +48 -10
- package/src/core/effects.ts +3 -3
- package/src/core/hooks.ts +48 -0
- package/src/core/index.ts +1 -0
- package/src/core/state.ts +203 -139
- package/src/demo.tsx +5 -0
- package/src/interactive/Button/index.ts +2 -1
- package/src/interactive/TextField/index.ts +29 -6
- package/src/structure/Box/index.ts +3 -2
- package/dist/effects-Co9C_Dyx.mjs +0 -9
- package/dist/examples/ScaffoldExamples.d.ts +0 -3
- package/dist/examples/StateExamples.d.ts +0 -5
- package/src/examples/ScaffoldExamples.tsx +0 -299
- package/src/examples/StateExamples.tsx +0 -149
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { Scaffold } from '../layout/Scaffold';
|
|
4
|
-
import { Box } from '../structure/Box';
|
|
5
|
-
import { Text } from '../content/Text';
|
|
6
|
-
import { Button } from '../interactive/Button';
|
|
7
|
-
import { Header } from '../layout/Header';
|
|
8
|
-
import { Row } from '../layout/Row';
|
|
9
|
-
import { Column } from '../layout/Column';
|
|
10
|
-
import { signal, createStore } from '../core/state';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const lightTheme = {
|
|
18
|
-
primary: '#3B82F6',
|
|
19
|
-
secondary: '#10B981',
|
|
20
|
-
background: '#FFFFFF',
|
|
21
|
-
text: '#1F2937',
|
|
22
|
-
mode: 'light' as const,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const darkTheme = {
|
|
26
|
-
primary: '#60A5FA',
|
|
27
|
-
secondary: '#34D399',
|
|
28
|
-
background: '#1F2937',
|
|
29
|
-
text: '#F9FAFB',
|
|
30
|
-
mode: 'dark' as const,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const currentTheme = signal<typeof lightTheme | typeof darkTheme>(lightTheme);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const appStore = createStore({
|
|
38
|
-
user: {
|
|
39
|
-
name: 'Guest',
|
|
40
|
-
email: '',
|
|
41
|
-
isLoggedIn: false,
|
|
42
|
-
},
|
|
43
|
-
notifications: [],
|
|
44
|
-
settings: {
|
|
45
|
-
language: 'pt-BR',
|
|
46
|
-
timezone: 'America/Sao_Paulo',
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
function AppHeader() {
|
|
55
|
-
const theme = currentTheme.value;
|
|
56
|
-
const user = appStore.getState().user;
|
|
57
|
-
|
|
58
|
-
return Header()
|
|
59
|
-
.height(64)
|
|
60
|
-
.children(
|
|
61
|
-
Row()
|
|
62
|
-
.mainAxisAlignment('spaceBetween')
|
|
63
|
-
.crossAxisAlignment('center')
|
|
64
|
-
.padding('0 24px')
|
|
65
|
-
.children([
|
|
66
|
-
Text('🏗️ My App').variant('h2').color(theme.primary).build(),
|
|
67
|
-
|
|
68
|
-
Row()
|
|
69
|
-
.spacing(16)
|
|
70
|
-
.children([
|
|
71
|
-
Text(user.name).variant('body').build(),
|
|
72
|
-
Button()
|
|
73
|
-
.text(theme.mode === 'light' ? '🌙' : '☀️')
|
|
74
|
-
.variant('outline')
|
|
75
|
-
.onPress(() => {
|
|
76
|
-
currentTheme.value =
|
|
77
|
-
theme.mode === 'light' ? darkTheme : lightTheme;
|
|
78
|
-
})
|
|
79
|
-
.build(),
|
|
80
|
-
])
|
|
81
|
-
.build(),
|
|
82
|
-
])
|
|
83
|
-
.build()
|
|
84
|
-
)
|
|
85
|
-
.build();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function AppContent() {
|
|
89
|
-
const theme = currentTheme.value;
|
|
90
|
-
|
|
91
|
-
return Box()
|
|
92
|
-
.flex('1')
|
|
93
|
-
.padding('24px')
|
|
94
|
-
.backgroundColor(theme.background)
|
|
95
|
-
.children(
|
|
96
|
-
Column()
|
|
97
|
-
.spacing(24)
|
|
98
|
-
.children([
|
|
99
|
-
Text('Welcome to FiboUI!').variant('h1').color(theme.text).build(),
|
|
100
|
-
Text('This app uses Scaffold for global configuration.')
|
|
101
|
-
.variant('body')
|
|
102
|
-
.color(theme.text)
|
|
103
|
-
.build(),
|
|
104
|
-
|
|
105
|
-
Box()
|
|
106
|
-
.padding('24px')
|
|
107
|
-
.backgroundColor(theme.primary)
|
|
108
|
-
.borderRadius('12px')
|
|
109
|
-
.children(
|
|
110
|
-
Text('Themed Box')
|
|
111
|
-
.variant('h3')
|
|
112
|
-
.color('#FFFFFF')
|
|
113
|
-
.build()
|
|
114
|
-
)
|
|
115
|
-
.build(),
|
|
116
|
-
])
|
|
117
|
-
.build()
|
|
118
|
-
)
|
|
119
|
-
.build();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function AppFooter() {
|
|
123
|
-
const theme = currentTheme.value;
|
|
124
|
-
|
|
125
|
-
return Box()
|
|
126
|
-
.padding('16px 24px')
|
|
127
|
-
.borderTop(`1px solid ${theme.primary}`)
|
|
128
|
-
.backgroundColor(theme.background)
|
|
129
|
-
.children(
|
|
130
|
-
Text('© 2024 My App - Built with FiboUI')
|
|
131
|
-
.variant('caption')
|
|
132
|
-
.color(theme.text)
|
|
133
|
-
.textAlign('center')
|
|
134
|
-
.build()
|
|
135
|
-
)
|
|
136
|
-
.build();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
export function App() {
|
|
144
|
-
return (
|
|
145
|
-
Scaffold()
|
|
146
|
-
|
|
147
|
-
.theme(currentTheme.value)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
.locale('pt-BR')
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
.providers({
|
|
154
|
-
store: appStore,
|
|
155
|
-
theme: currentTheme,
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
.bindSignal(currentTheme)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
.children([
|
|
163
|
-
AppHeader(),
|
|
164
|
-
AppContent(),
|
|
165
|
-
AppFooter(),
|
|
166
|
-
])
|
|
167
|
-
.build()
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const ecommerceTheme = {
|
|
176
|
-
primary: '#FF6B6B',
|
|
177
|
-
secondary: '#4ECDC4',
|
|
178
|
-
background: '#F7F7F7',
|
|
179
|
-
text: '#2C3E50',
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const ecommerceStore = createStore({
|
|
183
|
-
cart: [],
|
|
184
|
-
products: [],
|
|
185
|
-
user: null,
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
export function EcommerceApp() {
|
|
189
|
-
return (
|
|
190
|
-
Scaffold()
|
|
191
|
-
.theme(ecommerceTheme)
|
|
192
|
-
.locale('pt-BR')
|
|
193
|
-
.provider('cart', ecommerceStore)
|
|
194
|
-
.provider('analytics', { track: () => {} })
|
|
195
|
-
.backgroundColor(ecommerceTheme.background)
|
|
196
|
-
.children([
|
|
197
|
-
|
|
198
|
-
Header()
|
|
199
|
-
.height(80)
|
|
200
|
-
.children(
|
|
201
|
-
Row()
|
|
202
|
-
.mainAxisAlignment('spaceBetween')
|
|
203
|
-
.padding('0 48px')
|
|
204
|
-
.children([
|
|
205
|
-
Text('🛒 Shop').variant('h2').build(),
|
|
206
|
-
Text('Cart (0)').variant('body').build(),
|
|
207
|
-
])
|
|
208
|
-
.build()
|
|
209
|
-
)
|
|
210
|
-
.build(),
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
Box()
|
|
214
|
-
.flex('1')
|
|
215
|
-
.padding('48px')
|
|
216
|
-
.children(
|
|
217
|
-
Text('Products will go here')
|
|
218
|
-
.variant('h3')
|
|
219
|
-
.build()
|
|
220
|
-
)
|
|
221
|
-
.build(),
|
|
222
|
-
])
|
|
223
|
-
.build()
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
export function DashboardApp() {
|
|
232
|
-
return (
|
|
233
|
-
Scaffold()
|
|
234
|
-
.theme(darkTheme)
|
|
235
|
-
.locale('en-US')
|
|
236
|
-
.providers({
|
|
237
|
-
auth: createStore({ user: null, token: null }),
|
|
238
|
-
notifications: createStore({ items: [] }),
|
|
239
|
-
settings: createStore({ theme: 'dark', sidebar: 'expanded' }),
|
|
240
|
-
})
|
|
241
|
-
.children([
|
|
242
|
-
|
|
243
|
-
Box()
|
|
244
|
-
.display('flex')
|
|
245
|
-
.height('100vh')
|
|
246
|
-
.children([
|
|
247
|
-
|
|
248
|
-
Box()
|
|
249
|
-
.width('260px')
|
|
250
|
-
.backgroundColor('#1E293B')
|
|
251
|
-
.children(
|
|
252
|
-
Text('Sidebar').color('#FFF').padding('24px').build()
|
|
253
|
-
)
|
|
254
|
-
.build(),
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
Box()
|
|
258
|
-
.flex('1')
|
|
259
|
-
.display('flex')
|
|
260
|
-
.flexDirection('column')
|
|
261
|
-
.children([
|
|
262
|
-
|
|
263
|
-
Box()
|
|
264
|
-
.height('64px')
|
|
265
|
-
.backgroundColor('#0F172A')
|
|
266
|
-
.children(
|
|
267
|
-
Text('Dashboard')
|
|
268
|
-
.color('#FFF')
|
|
269
|
-
.padding('0 24px')
|
|
270
|
-
.lineHeight('64px')
|
|
271
|
-
.build()
|
|
272
|
-
)
|
|
273
|
-
.build(),
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
Box()
|
|
277
|
-
.flex('1')
|
|
278
|
-
.padding('24px')
|
|
279
|
-
.backgroundColor('#0F172A')
|
|
280
|
-
.children(
|
|
281
|
-
Text('Dashboard content')
|
|
282
|
-
.color('#FFF')
|
|
283
|
-
.build()
|
|
284
|
-
)
|
|
285
|
-
.build(),
|
|
286
|
-
])
|
|
287
|
-
.build(),
|
|
288
|
-
])
|
|
289
|
-
.build(),
|
|
290
|
-
])
|
|
291
|
-
.build()
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { Box } from '../structure/Box';
|
|
2
|
-
import { Text } from '../content/Text';
|
|
3
|
-
import { Button } from '../interactive/Button';
|
|
4
|
-
import { signal, computed, observable, createStore } from '../core/state';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export function SignalCounterExample() {
|
|
11
|
-
const count = signal(0);
|
|
12
|
-
const doubled = computed(() => count.value * 2);
|
|
13
|
-
|
|
14
|
-
return Box()
|
|
15
|
-
.display('flex')
|
|
16
|
-
.flexDirection('column')
|
|
17
|
-
.gap('16px')
|
|
18
|
-
.padding('24px')
|
|
19
|
-
.border('1px solid #E5E7EB')
|
|
20
|
-
.borderRadius('8px')
|
|
21
|
-
.children([
|
|
22
|
-
Text(`Count: ${count.value}`).variant('h3').build(),
|
|
23
|
-
Text(`Doubled: ${doubled.value}`).variant('body').build(),
|
|
24
|
-
Box()
|
|
25
|
-
.display('flex')
|
|
26
|
-
.gap('8px')
|
|
27
|
-
.children([
|
|
28
|
-
Button()
|
|
29
|
-
.text('Increment')
|
|
30
|
-
.onPress(() => count.value++)
|
|
31
|
-
.build(),
|
|
32
|
-
Button()
|
|
33
|
-
.text('Decrement')
|
|
34
|
-
.onPress(() => count.value--)
|
|
35
|
-
.build(),
|
|
36
|
-
])
|
|
37
|
-
.build(),
|
|
38
|
-
])
|
|
39
|
-
.bindSignal(count)
|
|
40
|
-
.bindSignal(doubled)
|
|
41
|
-
.build();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
export function ObservableExample() {
|
|
49
|
-
const state = observable({ name: 'John', age: 25 });
|
|
50
|
-
|
|
51
|
-
return Box()
|
|
52
|
-
.display('flex')
|
|
53
|
-
.flexDirection('column')
|
|
54
|
-
.gap('16px')
|
|
55
|
-
.padding('24px')
|
|
56
|
-
.border('1px solid #E5E7EB')
|
|
57
|
-
.borderRadius('8px')
|
|
58
|
-
.children([
|
|
59
|
-
Text(`Name: ${state.get().name}`).variant('body').build(),
|
|
60
|
-
Text(`Age: ${state.get().age}`).variant('body').build(),
|
|
61
|
-
Button()
|
|
62
|
-
.text('Update')
|
|
63
|
-
.onPress(() => state.set({ name: 'Jane', age: 30 }))
|
|
64
|
-
.build(),
|
|
65
|
-
])
|
|
66
|
-
.observe(state)
|
|
67
|
-
.build();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const appStore = createStore({
|
|
75
|
-
user: { name: 'Guest', loggedIn: false },
|
|
76
|
-
theme: 'light',
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
export function StoreExample() {
|
|
80
|
-
const state = appStore.getState();
|
|
81
|
-
|
|
82
|
-
return Box()
|
|
83
|
-
.display('flex')
|
|
84
|
-
.flexDirection('column')
|
|
85
|
-
.gap('16px')
|
|
86
|
-
.padding('24px')
|
|
87
|
-
.border('1px solid #E5E7EB')
|
|
88
|
-
.borderRadius('8px')
|
|
89
|
-
.children([
|
|
90
|
-
Text(`User: ${state.user.name}`).variant('body').build(),
|
|
91
|
-
Text(`Theme: ${state.theme}`).variant('body').build(),
|
|
92
|
-
Button()
|
|
93
|
-
.text('Login')
|
|
94
|
-
.onPress(() =>
|
|
95
|
-
appStore.setState({ user: { name: 'John Doe', loggedIn: true } })
|
|
96
|
-
)
|
|
97
|
-
.build(),
|
|
98
|
-
])
|
|
99
|
-
.observer()
|
|
100
|
-
.build();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
export function ProviderExample() {
|
|
108
|
-
const theme = { primary: '#3B82F6', secondary: '#10B981' };
|
|
109
|
-
|
|
110
|
-
return Box()
|
|
111
|
-
.provide('theme', theme)
|
|
112
|
-
.padding('24px')
|
|
113
|
-
.children([
|
|
114
|
-
Box()
|
|
115
|
-
.padding('16px')
|
|
116
|
-
.backgroundColor('#3B82F6')
|
|
117
|
-
.borderRadius('8px')
|
|
118
|
-
.children(
|
|
119
|
-
Text('Themed Box').color('#FFF').variant('h3').build()
|
|
120
|
-
)
|
|
121
|
-
.build(),
|
|
122
|
-
])
|
|
123
|
-
.build();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
export function LocalStateExample() {
|
|
131
|
-
return Box()
|
|
132
|
-
.state('count', 0)
|
|
133
|
-
.state('name', 'Guest')
|
|
134
|
-
.display('flex')
|
|
135
|
-
.flexDirection('column')
|
|
136
|
-
.gap('16px')
|
|
137
|
-
.padding('24px')
|
|
138
|
-
.border('1px solid #E5E7EB')
|
|
139
|
-
.borderRadius('8px')
|
|
140
|
-
.children([
|
|
141
|
-
Text('Local State Example').variant('h3').build(),
|
|
142
|
-
Text('Count: 0').variant('body').build(),
|
|
143
|
-
Text('Name: Guest').variant('body').build(),
|
|
144
|
-
Button()
|
|
145
|
-
.text('Increment')
|
|
146
|
-
.build(),
|
|
147
|
-
])
|
|
148
|
-
.build();
|
|
149
|
-
}
|