fiboui 1.0.2 → 2.0.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/README.md +138 -92
- package/dist/FineGrain-kBxv0WeR.js +29 -0
- package/dist/Link-DDzSPY1Q.js +88 -0
- package/dist/PluginManager-D5-ApsSN.js +111 -0
- package/dist/Router-i6Nc6qVs.js +386 -0
- package/dist/builder-DjLYXkXu.js +1842 -0
- package/dist/bundle-mjs-wppB-TKB.js +2760 -0
- package/dist/cli/bin.js +20 -0
- package/dist/cli/commands/generate/component.js +67 -0
- package/dist/cli/commands/generate/index.js +10 -0
- package/dist/cli/commands/generate/module.js +58 -0
- package/dist/cli/commands/generate/plugin.js +67 -0
- package/dist/cli/commands/init.js +58 -0
- package/dist/content.js +17 -0
- package/dist/core.js +33 -0
- package/dist/{effects-D16XdB_d.mjs → effects-CnevV566.js} +1 -0
- package/dist/index-B1av7e36.js +1102 -0
- package/dist/index-BQGRpkzR.js +1024 -0
- package/dist/index-CTRZRn9S.js +90 -0
- package/dist/index-DKFr-sai.js +33 -0
- package/dist/index-Dm4j2mMM.js +1031 -0
- package/dist/index-RbfIZuAo.js +119 -0
- package/dist/index-yeYkDTAx.js +778 -0
- package/dist/index.d.ts +43753 -6
- package/dist/index.js +2054 -0
- package/dist/interactive.js +12 -0
- package/dist/layout.js +18 -0
- package/dist/mount-sAVX_FBU.js +95 -0
- package/dist/navigation.js +13 -0
- package/dist/provider-B0eB-Wy7.js +286 -0
- package/dist/structure.js +15 -0
- package/dist/style.css +1 -1
- package/dist/style.js +1 -0
- package/dist/theme.js +9 -0
- package/package.json +88 -13
- package/dist/content/Alert/index.d.ts +0 -878
- package/dist/content/Avatar/index.d.ts +0 -886
- package/dist/content/Badge/index.d.ts +0 -887
- package/dist/content/Image/index.d.ts +0 -893
- package/dist/content/Label/index.d.ts +0 -879
- package/dist/content/Progress/index.d.ts +0 -898
- package/dist/content/Skeleton/index.d.ts +0 -879
- package/dist/content/Spinner/index.d.ts +0 -880
- package/dist/content/Text/index.d.ts +0 -878
- package/dist/content/index.d.ts +0 -9
- package/dist/core/StateWrapper.d.ts +0 -31
- package/dist/core/builder.d.ts +0 -58
- package/dist/core/component.d.ts +0 -7
- package/dist/core/effects.d.ts +0 -4
- package/dist/core/hooks.d.ts +0 -5
- package/dist/core/icons.d.ts +0 -11
- package/dist/core/index.d.ts +0 -6
- package/dist/core/state.d.ts +0 -86
- package/dist/core/types.d.ts +0 -51
- package/dist/demo.d.ts +0 -7
- package/dist/index.esm.js +0 -4777
- package/dist/index.umd.js +0 -251
- package/dist/interactive/Button/index.d.ts +0 -897
- package/dist/interactive/Checkbox/index.d.ts +0 -884
- package/dist/interactive/Combobox/index.d.ts +0 -898
- package/dist/interactive/RadioGroup/index.d.ts +0 -888
- package/dist/interactive/Select/index.d.ts +0 -895
- package/dist/interactive/Switch/index.d.ts +0 -881
- package/dist/interactive/TextField/index.d.ts +0 -893
- package/dist/interactive/Textarea/index.d.ts +0 -890
- package/dist/interactive/index.d.ts +0 -8
- package/dist/layout/Center/index.d.ts +0 -869
- package/dist/layout/Column/index.d.ts +0 -881
- package/dist/layout/Container/index.d.ts +0 -870
- package/dist/layout/DashboardLayout/index.d.ts +0 -870
- package/dist/layout/Header/index.d.ts +0 -870
- package/dist/layout/Line/index.d.ts +0 -872
- package/dist/layout/Row/index.d.ts +0 -879
- package/dist/layout/Scaffold/index.d.ts +0 -878
- package/dist/layout/ScrollView/index.d.ts +0 -879
- package/dist/layout/Sidebar/index.d.ts +0 -870
- package/dist/layout/Spacer/index.d.ts +0 -875
- package/dist/layout/StakentComponents.d.ts +0 -4
- package/dist/layout/index.d.ts +0 -11
- package/dist/structure/Banner/index.d.ts +0 -879
- package/dist/structure/Box/index.d.ts +0 -869
- package/dist/structure/Card/index.d.ts +0 -881
- package/dist/structure/Collapse/index.d.ts +0 -884
- package/dist/structure/Grid/index.d.ts +0 -1757
- package/dist/structure/List/index.d.ts +0 -888
- package/dist/structure/Table/index.d.ts +0 -895
- package/dist/structure/Tags/index.d.ts +0 -876
- package/dist/structure/cards/AssetCard/index.d.ts +0 -884
- package/dist/structure/cards/CollectionCard/index.d.ts +0 -880
- package/dist/structure/cards/ContentCard/index.d.ts +0 -884
- package/dist/structure/cards/ProfileCard/index.d.ts +0 -892
- package/dist/structure/cards/index.d.ts +0 -5
- package/dist/structure/cards/variants/index.d.ts +0 -3490
- package/dist/structure/index.d.ts +0 -9
- package/dist/theme/cupertino.d.ts +0 -3
- package/dist/theme/index.d.ts +0 -5
- package/dist/theme/material.d.ts +0 -3
- package/dist/theme/provider.d.ts +0 -16
- package/dist/theme/types.d.ts +0 -57
- package/dist/theme/web.d.ts +0 -3
- package/src/content/Alert/index.ts +0 -110
- package/src/content/Avatar/index.ts +0 -116
- package/src/content/Badge/index.ts +0 -162
- package/src/content/Image/index.ts +0 -137
- package/src/content/Label/index.ts +0 -66
- package/src/content/Progress/index.ts +0 -378
- package/src/content/Skeleton/index.ts +0 -71
- package/src/content/Spinner/index.ts +0 -139
- package/src/content/Text/index.ts +0 -74
- package/src/content/index.ts +0 -9
- package/src/core/StateWrapper.tsx +0 -131
- package/src/core/builder.ts +0 -301
- package/src/core/component.ts +0 -49
- package/src/core/effects.ts +0 -27
- package/src/core/hooks.ts +0 -48
- package/src/core/icons.tsx +0 -57
- package/src/core/index.ts +0 -6
- package/src/core/state.ts +0 -297
- package/src/core/types.ts +0 -62
- package/src/demo.tsx +0 -1050
- package/src/index.ts +0 -8
- package/src/interactive/Button/index.ts +0 -219
- package/src/interactive/Checkbox/index.ts +0 -145
- package/src/interactive/Combobox/index.ts +0 -278
- package/src/interactive/RadioGroup/index.ts +0 -124
- package/src/interactive/Select/index.ts +0 -227
- package/src/interactive/Switch/index.ts +0 -123
- package/src/interactive/TextField/index.ts +0 -223
- package/src/interactive/Textarea/index.ts +0 -129
- package/src/interactive/index.ts +0 -8
- package/src/layout/Center/index.ts +0 -34
- package/src/layout/Column/index.ts +0 -101
- package/src/layout/Container/index.ts +0 -28
- package/src/layout/DashboardLayout/index.ts +0 -106
- package/src/layout/Header/index.ts +0 -50
- package/src/layout/Line/index.ts +0 -41
- package/src/layout/Row/index.ts +0 -93
- package/src/layout/Scaffold/index.ts +0 -133
- package/src/layout/ScrollView/index.ts +0 -67
- package/src/layout/Sidebar/index.ts +0 -56
- package/src/layout/Spacer/index.ts +0 -46
- package/src/layout/StakentComponents.tsx +0 -57
- package/src/layout/index.ts +0 -11
- package/src/structure/Banner/index.ts +0 -92
- package/src/structure/Box/index.ts +0 -46
- package/src/structure/Card/index.ts +0 -113
- package/src/structure/Collapse/index.ts +0 -122
- package/src/structure/Grid/index.ts +0 -197
- package/src/structure/List/index.ts +0 -185
- package/src/structure/Table/index.ts +0 -165
- package/src/structure/Tags/index.ts +0 -69
- package/src/structure/cards/AssetCard/index.ts +0 -158
- package/src/structure/cards/CollectionCard/index.ts +0 -95
- package/src/structure/cards/ContentCard/index.ts +0 -127
- package/src/structure/cards/ProfileCard/index.ts +0 -152
- package/src/structure/cards/index.ts +0 -5
- package/src/structure/cards/variants/index.ts +0 -301
- package/src/structure/index.ts +0 -10
- package/src/styles/base.css +0 -186
- package/src/styles/core.css +0 -52
- package/src/styles/themes/cupertino.css +0 -197
- package/src/styles/themes/material.css +0 -322
- package/src/styles/themes/web.css +0 -196
- package/src/theme/cupertino.ts +0 -85
- package/src/theme/index.ts +0 -5
- package/src/theme/material.ts +0 -86
- package/src/theme/provider.tsx +0 -76
- package/src/theme/types.ts +0 -62
- package/src/theme/web.ts +0 -82
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect, createContext, useContext, ReactNode, useRef } from 'react';
|
|
2
|
-
import { Observable, Signal, Tracker } from './state';
|
|
3
|
-
|
|
4
|
-
export function Observer({ children }: { children: () => ReactNode }) {
|
|
5
|
-
const [, forceUpdate] = useState({});
|
|
6
|
-
const tracker = useRef<Tracker | null>(null);
|
|
7
|
-
|
|
8
|
-
if (!tracker.current) {
|
|
9
|
-
tracker.current = new Tracker(() => {
|
|
10
|
-
forceUpdate({});
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
return () => {
|
|
16
|
-
tracker.current?.dispose();
|
|
17
|
-
}
|
|
18
|
-
}, []);
|
|
19
|
-
|
|
20
|
-
let result;
|
|
21
|
-
try {
|
|
22
|
-
result = tracker.current.execute(children);
|
|
23
|
-
} catch (e) {
|
|
24
|
-
console.error("Observer render error", e);
|
|
25
|
-
result = null;
|
|
26
|
-
}
|
|
27
|
-
return <>{result}</>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export const StateContext = createContext<Map<string, any>>(new Map());
|
|
35
|
-
|
|
36
|
-
export function useStateContext() {
|
|
37
|
-
return useContext(StateContext);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
interface StateWrapperProps {
|
|
45
|
-
stateMap: Map<string, any>;
|
|
46
|
-
children: ReactNode;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
export function StateWrapper({ stateMap, children }: StateWrapperProps) {
|
|
51
|
-
const [state] = useState(() => new Map(stateMap));
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<StateContext.Provider value={state}>
|
|
55
|
-
{children}
|
|
56
|
-
</StateContext.Provider>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
interface ObserverWrapperProps {
|
|
65
|
-
observables: Set<Observable<any>>;
|
|
66
|
-
children: ReactNode;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
export function ObserverWrapper({ observables, children }: ObserverWrapperProps) {
|
|
71
|
-
const [, forceUpdate] = useState({});
|
|
72
|
-
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
const unsubscribers = Array.from(observables).map(obs =>
|
|
75
|
-
obs.subscribe(() => forceUpdate({}))
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
return () => unsubscribers.forEach(unsub => unsub());
|
|
79
|
-
}, [observables]);
|
|
80
|
-
|
|
81
|
-
return <>{children}</>;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
interface SignalWrapperProps {
|
|
89
|
-
signals: Set<Signal<any>>;
|
|
90
|
-
children: ReactNode;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
export function SignalWrapper({ signals, children }: SignalWrapperProps) {
|
|
95
|
-
const [, forceUpdate] = useState({});
|
|
96
|
-
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
const unsubscribers = Array.from(signals).map(sig =>
|
|
99
|
-
sig.subscribe(() => forceUpdate({}))
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
return () => unsubscribers.forEach(unsub => unsub());
|
|
103
|
-
}, [signals]);
|
|
104
|
-
|
|
105
|
-
return <>{children}</>;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
interface ProviderWrapperProps {
|
|
113
|
-
providers: Map<string, any>;
|
|
114
|
-
children: ReactNode;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export const ProviderContext = createContext<Map<string, any>>(new Map());
|
|
118
|
-
|
|
119
|
-
export function useProvider<T>(key: string): T | undefined {
|
|
120
|
-
const providers = useContext(ProviderContext);
|
|
121
|
-
return providers.get(key);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
export function ProviderWrapper({ providers, children }: ProviderWrapperProps) {
|
|
126
|
-
return (
|
|
127
|
-
<ProviderContext.Provider value={providers}>
|
|
128
|
-
{children}
|
|
129
|
-
</ProviderContext.Provider>
|
|
130
|
-
);
|
|
131
|
-
}
|
package/src/core/builder.ts
DELETED
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import React, { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
2
|
-
import { ResponsiveStyles } from './types';
|
|
3
|
-
import { Observable, Signal } from './state';
|
|
4
|
-
import { Observer } from './StateWrapper';
|
|
5
|
-
import clsx from 'clsx';
|
|
6
|
-
|
|
7
|
-
import { cssToTailwind } from '@metagptx/css-to-tailwind';
|
|
8
|
-
|
|
9
|
-
export abstract class FiboBuilder {
|
|
10
|
-
protected _props: Record<string, any> = {};
|
|
11
|
-
protected _style: CSSProperties = {};
|
|
12
|
-
protected _cssStyles: CSSProperties = {};
|
|
13
|
-
protected _classNames: string[] = [];
|
|
14
|
-
protected _children: ReactNode[] = [];
|
|
15
|
-
protected _responsive?: ResponsiveStyles;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
protected _state: Map<string, any> = new Map();
|
|
19
|
-
protected _providers: Map<string, any> = new Map();
|
|
20
|
-
protected _observers: Set<Observable<any>> = new Set();
|
|
21
|
-
protected _signals: Set<Signal<any>> = new Set();
|
|
22
|
-
protected _isObserver: boolean = false;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
id(value: string): this {
|
|
27
|
-
this._props.id = value;
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
key(value: string | number): this {
|
|
32
|
-
this._props.key = value;
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
paddingHorizontal(value: string | number): this {
|
|
37
|
-
if (typeof value === 'number') {
|
|
38
|
-
this._classNames.push(`px-[${value}px]`);
|
|
39
|
-
} else {
|
|
40
|
-
this._classNames.push(`px-${value}`);
|
|
41
|
-
}
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
paddingVertical(value: string | number): this {
|
|
46
|
-
if (typeof value === 'number') {
|
|
47
|
-
this._classNames.push(`py-[${value}px]`);
|
|
48
|
-
} else {
|
|
49
|
-
this._classNames.push(`py-${value}`);
|
|
50
|
-
}
|
|
51
|
-
return this;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
marginHorizontal(value: string | number): this {
|
|
57
|
-
if (typeof value === 'number') {
|
|
58
|
-
this._classNames.push(`mx-[${value}px]`);
|
|
59
|
-
} else {
|
|
60
|
-
this._classNames.push(`mx-${value}`);
|
|
61
|
-
}
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
marginVertical(value: string | number): this {
|
|
66
|
-
if (typeof value === 'number') {
|
|
67
|
-
this._classNames.push(`my-[${value}px]`);
|
|
68
|
-
} else {
|
|
69
|
-
this._classNames.push(`my-${value}`);
|
|
70
|
-
}
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
flexDirection(direction: 'row' | 'column'): this {
|
|
89
|
-
this._classNames.push(`flex-${direction}`);
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
alignItems(alignment: 'start' | 'center' | 'end' | 'stretch'): this {
|
|
94
|
-
this._classNames.push(`items-${alignment}`);
|
|
95
|
-
return this;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
justifyContent(justify: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'): this {
|
|
99
|
-
this._classNames.push(`justify-${justify}`);
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
responsive(styles: ResponsiveStyles): this {
|
|
110
|
-
this._responsive = styles;
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
state<T>(key: string, initialValue: T): this {
|
|
120
|
-
this._state.set(key, initialValue);
|
|
121
|
-
return this;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
getState<T>(key: string): T | undefined {
|
|
126
|
-
return this._state.get(key);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
setState<T>(key: string, value: T): this {
|
|
131
|
-
this._state.set(key, value);
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
provide<T>(key: string, value: T): this {
|
|
137
|
-
this._providers.set(key, value);
|
|
138
|
-
return this;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
consume<T>(key: string): T | undefined {
|
|
143
|
-
return this._providers.get(key);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
observer(): this {
|
|
148
|
-
this._isObserver = true;
|
|
149
|
-
return this;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
observe<T>(observable: Observable<T>): this {
|
|
154
|
-
this._observers.add(observable);
|
|
155
|
-
return this;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
bindSignal<T>(signal: Signal<T>): this {
|
|
160
|
-
this._signals.add(signal);
|
|
161
|
-
return this;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
protected hasStateManagement(): boolean {
|
|
166
|
-
return (
|
|
167
|
-
this._state.size > 0 ||
|
|
168
|
-
this._providers.size > 0 ||
|
|
169
|
-
this._observers.size > 0 ||
|
|
170
|
-
this._signals.size > 0 ||
|
|
171
|
-
this._isObserver
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
className(className: string): this {
|
|
176
|
-
this._classNames.push(className);
|
|
177
|
-
return this;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
classNames(classNames: string[]): this {
|
|
181
|
-
this._classNames.push(...classNames);
|
|
182
|
-
return this;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
css(styles: CSSProperties): this {
|
|
186
|
-
this._cssStyles = { ...this._cssStyles, ...styles };
|
|
187
|
-
return this;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
style(style: CSSProperties): this {
|
|
191
|
-
this._style = { ...this._style, ...style };
|
|
192
|
-
return this;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
props(props: Record<string, any>): this {
|
|
196
|
-
this._props = { ...this._props, ...props };
|
|
197
|
-
return this;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
protected _childFunction?: () => ReactNode;
|
|
201
|
-
|
|
202
|
-
children(children: ReactNode | ReactNode[] | (() => ReactNode)): this {
|
|
203
|
-
if (typeof children === 'function') {
|
|
204
|
-
this._childFunction = children as () => ReactNode;
|
|
205
|
-
this._children = []; // Clear static children
|
|
206
|
-
} else {
|
|
207
|
-
const childArray = Array.isArray(children) ? children : [children];
|
|
208
|
-
this._children = childArray.map((child) => {
|
|
209
|
-
if (child && typeof child === 'object' && 'build' in child && typeof (child as any).build === 'function') {
|
|
210
|
-
return (child as any).build();
|
|
211
|
-
}
|
|
212
|
-
return child;
|
|
213
|
-
});
|
|
214
|
-
this._childFunction = undefined;
|
|
215
|
-
}
|
|
216
|
-
return this;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
protected getClassName(): string {
|
|
220
|
-
if (Object.keys(this._cssStyles).length > 0) {
|
|
221
|
-
|
|
222
|
-
const tailwindClasses = cssToTailwind(this._cssStyles as Record<string, string | number | undefined>);
|
|
223
|
-
if (tailwindClasses) {
|
|
224
|
-
this._classNames.push(tailwindClasses);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return clsx(this._classNames);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
protected getStyle(): CSSProperties {
|
|
231
|
-
let finalStyle = { ...this._style, ...this._cssStyles };
|
|
232
|
-
|
|
233
|
-
if (this._responsive) {
|
|
234
|
-
if (this._responsive.mobile) {
|
|
235
|
-
finalStyle = { ...finalStyle, ...this._responsive.mobile };
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return finalStyle;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
protected processChildren(): ReactNode[] {
|
|
243
|
-
if (this._childFunction) {
|
|
244
|
-
const result = this._childFunction();
|
|
245
|
-
// Ensure result is an array for consistent consumption by subclasses using ...children
|
|
246
|
-
return Array.isArray(result) ? result : [result];
|
|
247
|
-
}
|
|
248
|
-
return this._children;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
protected getChildFunction(): (() => ReactNode) | undefined {
|
|
252
|
-
return this._childFunction;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
abstract build(): ReactElement;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
type KnownKeys<T> = {
|
|
259
|
-
[K in keyof T]: string extends K ? never : number extends K ? never : K
|
|
260
|
-
} extends { [_ in keyof T]: infer U } ? U : never;
|
|
261
|
-
|
|
262
|
-
type StyleBuilder<T> = T & {
|
|
263
|
-
[K in KnownKeys<CSSProperties>]-?: (value: CSSProperties[K]) => StyleBuilder<T>;
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
export function createBuilder<T extends FiboBuilder, Args extends any[]>(
|
|
267
|
-
BuilderClass: new (...args: Args) => T
|
|
268
|
-
): (...args: Args) => StyleBuilder<T> {
|
|
269
|
-
return (...args: Args) => {
|
|
270
|
-
const instance = new BuilderClass(...args);
|
|
271
|
-
|
|
272
|
-
return new Proxy(instance, {
|
|
273
|
-
get(target, prop, receiver) {
|
|
274
|
-
if (prop === 'build') {
|
|
275
|
-
return () => {
|
|
276
|
-
// Check if this builder instance is marked as an observer
|
|
277
|
-
// Accessing protected/private members via casting
|
|
278
|
-
const isObserver = (target as any)._isObserver;
|
|
279
|
-
if (isObserver) {
|
|
280
|
-
return React.createElement(Observer, {
|
|
281
|
-
children: () => target.build()
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// Normal build
|
|
286
|
-
return target.build();
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (Reflect.has(target, prop)) {
|
|
291
|
-
return Reflect.get(target, prop, receiver);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
return (value: any) => {
|
|
295
|
-
target.css({ [prop]: value });
|
|
296
|
-
return receiver;
|
|
297
|
-
};
|
|
298
|
-
},
|
|
299
|
-
}) as StyleBuilder<T>;
|
|
300
|
-
};
|
|
301
|
-
}
|
package/src/core/component.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { ResponsiveStyles } from './types';
|
|
3
|
-
|
|
4
|
-
export function processChildren(children: ReactNode | ReactNode[]): ReactNode[] {
|
|
5
|
-
const childArray = Array.isArray(children) ? children : [children];
|
|
6
|
-
|
|
7
|
-
return childArray.map((child) => {
|
|
8
|
-
if (child && typeof child === 'object' && 'build' in child) {
|
|
9
|
-
return (child as any).build();
|
|
10
|
-
}
|
|
11
|
-
return child;
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function mergeStyles(...styles: (React.CSSProperties | undefined)[]): React.CSSProperties {
|
|
16
|
-
return styles.reduce<React.CSSProperties>((acc, style) => {
|
|
17
|
-
if (style) {
|
|
18
|
-
return { ...acc, ...style };
|
|
19
|
-
}
|
|
20
|
-
return acc;
|
|
21
|
-
}, {});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function applyResponsiveStyles(
|
|
25
|
-
baseStyle: React.CSSProperties,
|
|
26
|
-
responsive?: ResponsiveStyles
|
|
27
|
-
): React.CSSProperties {
|
|
28
|
-
if (!responsive) return baseStyle;
|
|
29
|
-
|
|
30
|
-
let finalStyle = { ...baseStyle };
|
|
31
|
-
|
|
32
|
-
if (typeof window !== 'undefined') {
|
|
33
|
-
const width = window.innerWidth;
|
|
34
|
-
|
|
35
|
-
if (width < 768 && responsive.mobile) {
|
|
36
|
-
finalStyle = { ...finalStyle, ...responsive.mobile };
|
|
37
|
-
} else if (width >= 768 && width < 1024 && responsive.tablet) {
|
|
38
|
-
finalStyle = { ...finalStyle, ...responsive.tablet };
|
|
39
|
-
} else if (width >= 1024 && responsive.desktop) {
|
|
40
|
-
finalStyle = { ...finalStyle, ...responsive.desktop };
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return finalStyle;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function normalizeValue(value: string | number, unit = 'px'): string {
|
|
48
|
-
return typeof value === 'number' ? `${value}${unit}` : value;
|
|
49
|
-
}
|
package/src/core/effects.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const createRipple = (event: { clientX: number, clientY: number }, button: HTMLElement, color: string = 'rgba(255, 255, 255, 0.3)') => {
|
|
4
|
-
if (!button) return;
|
|
5
|
-
const circle = document.createElement('span');
|
|
6
|
-
const diameter = Math.max(button.clientWidth, button.clientHeight);
|
|
7
|
-
const radius = diameter / 2;
|
|
8
|
-
|
|
9
|
-
const rect = button.getBoundingClientRect();
|
|
10
|
-
|
|
11
|
-
circle.style.width = circle.style.height = `${diameter}px`;
|
|
12
|
-
circle.style.left = `${event.clientX - rect.left - radius}px`;
|
|
13
|
-
circle.style.top = `${event.clientY - rect.top - radius}px`;
|
|
14
|
-
circle.style.position = 'absolute';
|
|
15
|
-
circle.style.borderRadius = '50%';
|
|
16
|
-
circle.style.transform = 'scale(0)';
|
|
17
|
-
circle.style.animation = 'fibo-ripple 600ms linear';
|
|
18
|
-
circle.style.backgroundColor = color;
|
|
19
|
-
circle.style.pointerEvents = 'none';
|
|
20
|
-
|
|
21
|
-
const rippleContainer = button.querySelector('.fibo-ripple-container') || button;
|
|
22
|
-
rippleContainer.appendChild(circle);
|
|
23
|
-
|
|
24
|
-
setTimeout(() => {
|
|
25
|
-
circle.remove();
|
|
26
|
-
}, 600);
|
|
27
|
-
};
|
package/src/core/hooks.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
import { Signal, ComputedSignal, Store, Observable } from './state';
|
|
3
|
-
|
|
4
|
-
export function useSignal<T>(signal: Signal<T> | ComputedSignal<T>): T {
|
|
5
|
-
const [value, setValue] = useState(signal.value);
|
|
6
|
-
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
// Initial sync
|
|
9
|
-
setValue(signal.value);
|
|
10
|
-
|
|
11
|
-
// Subscribe
|
|
12
|
-
const unsubscribe = signal.subscribe((newVal) => {
|
|
13
|
-
setValue(newVal);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
return unsubscribe;
|
|
17
|
-
}, [signal]);
|
|
18
|
-
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function useStore<T>(store: Store<T>): T {
|
|
23
|
-
const [state, setState] = useState(store.getState());
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
setState(store.getState());
|
|
27
|
-
const unsubscribe = store.subscribe((newState) => {
|
|
28
|
-
setState(newState);
|
|
29
|
-
});
|
|
30
|
-
return unsubscribe;
|
|
31
|
-
}, [store]);
|
|
32
|
-
|
|
33
|
-
return state;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function useObservable<T>(obs: Observable<T>): T {
|
|
37
|
-
const [val, setVal] = useState(obs.get());
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
setVal(obs.get());
|
|
41
|
-
const unsubscribe = obs.subscribe((newVal) => {
|
|
42
|
-
setVal(newVal);
|
|
43
|
-
});
|
|
44
|
-
return unsubscribe;
|
|
45
|
-
}, [obs]);
|
|
46
|
-
|
|
47
|
-
return val;
|
|
48
|
-
}
|
package/src/core/icons.tsx
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const Icons = {
|
|
4
|
-
Heart: (
|
|
5
|
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
6
|
-
<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"></path>
|
|
7
|
-
</svg>
|
|
8
|
-
),
|
|
9
|
-
Eth: (
|
|
10
|
-
<svg width="14" height="24" viewBox="0 0 32 32" fill="currentColor">
|
|
11
|
-
<path d="M15.925 23.96l-9.815-5.8 9.815 13.84 9.825-13.84-9.825 5.8zm0-23.96l-9.815 16.275 9.815 5.675 9.825-5.675-9.825-16.275zm0 20.3l-8.915-5.265 8.915-12.42 8.925 12.42-8.925 5.265z" />
|
|
12
|
-
</svg>
|
|
13
|
-
),
|
|
14
|
-
Verify: (
|
|
15
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="#3B82F6" stroke="none">
|
|
16
|
-
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"></path>
|
|
17
|
-
</svg>
|
|
18
|
-
),
|
|
19
|
-
More: (
|
|
20
|
-
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
21
|
-
<circle cx="12" cy="12" r="1" />
|
|
22
|
-
<circle cx="19" cy="12" r="1" />
|
|
23
|
-
<circle cx="5" cy="12" r="1" />
|
|
24
|
-
</svg>
|
|
25
|
-
),
|
|
26
|
-
Clock: (
|
|
27
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
28
|
-
<circle cx="12" cy="12" r="10"></circle>
|
|
29
|
-
<polyline points="12 6 12 12 16 14"></polyline>
|
|
30
|
-
</svg>
|
|
31
|
-
),
|
|
32
|
-
Info: (
|
|
33
|
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
34
|
-
<circle cx="12" cy="12" r="10"></circle>
|
|
35
|
-
<line x1="12" y1="16" x2="12" y2="12"></line>
|
|
36
|
-
<line x1="12" y1="8" x2="12.01" y2="8"></line>
|
|
37
|
-
</svg>
|
|
38
|
-
),
|
|
39
|
-
Check: (
|
|
40
|
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
41
|
-
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
|
|
42
|
-
<polyline points="22 4 12 14.01 9 11.01"></polyline>
|
|
43
|
-
</svg>
|
|
44
|
-
),
|
|
45
|
-
Search: (
|
|
46
|
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
47
|
-
<circle cx="11" cy="11" r="8"></circle>
|
|
48
|
-
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
49
|
-
</svg>
|
|
50
|
-
),
|
|
51
|
-
Close: (
|
|
52
|
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
53
|
-
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
54
|
-
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
55
|
-
</svg>
|
|
56
|
-
)
|
|
57
|
-
};
|