@vev/silke 1.0.31 → 1.1.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/CHANGELOG.md +17 -0
- package/dist/index.js +22 -22
- package/dist/styles.css +49 -49
- package/dist/types/components/silke-conditions-input/utils.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/audio-field.d.ts +3 -0
- package/dist/types/components/silke-gradient-picker/silke-gradient-picker.d.ts +2 -5
- package/dist/types/icons.d.ts +7 -0
- package/jest.config.js +1 -0
- package/package.json +5 -29
- package/project.json +0 -9
- package/src/components/silke-autocomplete-field/autocomplete-item.tsx +1 -0
- package/src/components/silke-card/silke-card.tsx +12 -1
- package/src/components/silke-css-number-field/silke-css-number-field.tsx +2 -1
- package/src/components/silke-form-schema/fields/audio-field.tsx +77 -0
- package/src/components/silke-form-schema/fields/select-field.tsx +1 -1
- package/src/components/silke-form-schema/silke-schema-field.tsx +2 -3
- package/src/components/silke-gradient-picker/silke-gradient-picker.tsx +33 -16
- package/src/components/silke-icon-picker/icons-tab.tsx +1 -1
- package/src/icons.tsx +44 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/docs/app.d.ts +0 -3
- package/dist/types/docs/components/code-block/code-block.d.ts +0 -5
- package/dist/types/docs/components/code-block/index.d.ts +0 -1
- package/dist/types/docs/components/state-table/index.d.ts +0 -1
- package/dist/types/docs/components/state-table/state-table.d.ts +0 -13
- package/dist/types/docs/data/app/actions.d.ts +0 -1
- package/dist/types/docs/data/app/constants.d.ts +0 -5
- package/dist/types/docs/data/app/index.d.ts +0 -3
- package/dist/types/docs/data/app/store.d.ts +0 -8
- package/dist/types/docs/data/flux/action-decorator.d.ts +0 -5
- package/dist/types/docs/data/flux/action-utils.d.ts +0 -7
- package/dist/types/docs/data/flux/controller.d.ts +0 -24
- package/dist/types/docs/data/flux/dispatcher.d.ts +0 -7
- package/dist/types/docs/data/flux/index.d.ts +0 -6
- package/dist/types/docs/data/flux/store.d.ts +0 -15
- package/dist/types/docs/data/flux/use-store.d.ts +0 -2
- package/dist/types/docs/docs-provider.d.ts +0 -6
- package/dist/types/docs/index.d.ts +0 -2
- package/dist/types/docs/ipsum-generator.d.ts +0 -7
- package/dist/types/docs/parser.d.ts +0 -0
- package/dist/types/main.d.ts +0 -1
- package/public/index.html +0 -23
- package/src/docs/app.tsx +0 -166
- package/src/docs/components/code-block/code-block.scss +0 -15
- package/src/docs/components/code-block/code-block.tsx +0 -55
- package/src/docs/components/code-block/index.ts +0 -1
- package/src/docs/components/state-table/index.ts +0 -1
- package/src/docs/components/state-table/state-table.scss +0 -10
- package/src/docs/components/state-table/state-table.tsx +0 -57
- package/src/docs/data/app/actions.ts +0 -17
- package/src/docs/data/app/constants.ts +0 -5
- package/src/docs/data/app/index.ts +0 -3
- package/src/docs/data/app/store.ts +0 -14
- package/src/docs/data/flux/action-decorator.ts +0 -16
- package/src/docs/data/flux/action-utils.ts +0 -19
- package/src/docs/data/flux/controller.ts +0 -76
- package/src/docs/data/flux/dispatcher.ts +0 -79
- package/src/docs/data/flux/index.ts +0 -10
- package/src/docs/data/flux/store.ts +0 -44
- package/src/docs/data/flux/use-store.ts +0 -57
- package/src/docs/docs-provider.tsx +0 -24
- package/src/docs/index.ts +0 -3
- package/src/docs/ipsum-generator.tsx +0 -86
- package/src/docs/parser.ts +0 -1345
- package/src/index.mdx +0 -69
- package/src/main.tsx +0 -11
- package/src/playground.mdx +0 -65
- package/webpack.docs.ts +0 -248
package/dist/types/docs/app.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './code-block';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './state-table';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
type State = {
|
|
2
|
-
label: string;
|
|
3
|
-
inherit?: any;
|
|
4
|
-
states: any[];
|
|
5
|
-
};
|
|
6
|
-
interface StateTableProps {
|
|
7
|
-
component: any;
|
|
8
|
-
headers?: string[];
|
|
9
|
-
states: State[];
|
|
10
|
-
props: any[][];
|
|
11
|
-
}
|
|
12
|
-
export declare function StateTable({ headers, states, props, component: Comp }: StateTableProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function loadAppRoutes(): Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Store } from './store';
|
|
2
|
-
export declare const actionListeners: {
|
|
3
|
-
[event: string]: PropertyDescriptor[];
|
|
4
|
-
};
|
|
5
|
-
export declare function action(...events: string[]): <T extends Store>(target: T, funcName: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type ActionType<T = undefined> = string & {
|
|
2
|
-
type: T;
|
|
3
|
-
};
|
|
4
|
-
export type Dispatchers<T> = {
|
|
5
|
-
[Const in keyof T]: T[Const] extends ActionType<any> ? T[Const]['type'] extends undefined ? () => void : (payload: T[Const]['type']) => void : unknown;
|
|
6
|
-
};
|
|
7
|
-
export declare function generateDispatchers<T>(actionTypes: T): Dispatchers<T>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface IQueuedModel {
|
|
2
|
-
queued: boolean;
|
|
3
|
-
doUpdate: () => void;
|
|
4
|
-
}
|
|
5
|
-
export declare abstract class QueuedModel implements IQueuedModel {
|
|
6
|
-
queued: boolean;
|
|
7
|
-
constructor();
|
|
8
|
-
queue(): void;
|
|
9
|
-
abstract doUpdate(): void;
|
|
10
|
-
}
|
|
11
|
-
declare class FlowController {
|
|
12
|
-
beforeRenderQueue: IQueuedModel[];
|
|
13
|
-
renderQueue: IQueuedModel[];
|
|
14
|
-
constructor();
|
|
15
|
-
addBeforeRender(model: IQueuedModel): void;
|
|
16
|
-
removeBeforeRenderModel(model: IQueuedModel): void;
|
|
17
|
-
addRender(model: IQueuedModel): void;
|
|
18
|
-
removeRender(model: IQueuedModel): void;
|
|
19
|
-
update(): void;
|
|
20
|
-
doBeforeRender(): void;
|
|
21
|
-
doRender(): void;
|
|
22
|
-
}
|
|
23
|
-
declare const _default: FlowController;
|
|
24
|
-
export default _default;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Dispatcher } from 'flux';
|
|
2
|
-
declare class AppDispatcher extends Dispatcher<any> {
|
|
3
|
-
}
|
|
4
|
-
declare const dispatcher: AppDispatcher;
|
|
5
|
-
export declare function dispatch(event: string, payload?: any): void;
|
|
6
|
-
export declare function dispatchToAll(event: string, payload: any): void;
|
|
7
|
-
export default dispatcher;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { Store } from './store';
|
|
2
|
-
export { dispatch, dispatchToAll } from './dispatcher';
|
|
3
|
-
export { action } from './action-decorator';
|
|
4
|
-
export { useStore } from './use-store';
|
|
5
|
-
export { generateDispatchers, Dispatchers, ActionType } from './action-utils';
|
|
6
|
-
export { default as FlowController, IQueuedModel } from './controller';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { QueuedModel } from './controller';
|
|
2
|
-
type StoreListener = () => void;
|
|
3
|
-
export declare class Store extends QueuedModel {
|
|
4
|
-
#private;
|
|
5
|
-
constructor();
|
|
6
|
-
off(cb: StoreListener): void;
|
|
7
|
-
on(cb: StoreListener): void;
|
|
8
|
-
emit(): void;
|
|
9
|
-
doUpdate(): void;
|
|
10
|
-
protected handleDispatch({ type, payload }: {
|
|
11
|
-
type: string;
|
|
12
|
-
payload: any;
|
|
13
|
-
}): void;
|
|
14
|
-
}
|
|
15
|
-
export {};
|
|
File without changes
|
package/dist/types/main.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './styles/core.scss';
|
package/public/index.html
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>Vev Silke</title>
|
|
7
|
-
|
|
8
|
-
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,500,700" rel="stylesheet" />
|
|
9
|
-
<link
|
|
10
|
-
href="https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,slnt,wdth,wght,GRAD,XOPQ,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC@8..144,-10..0,25..151,100..1000,-200..150,27..175,323..603,25..135,649..854,-305..-98,560..788,416..570,528..760&display=swap"
|
|
11
|
-
rel="stylesheet"
|
|
12
|
-
/>
|
|
13
|
-
<link
|
|
14
|
-
href="https://fonts.googleapis.com/css?family=Source+Code+Pro:300,400,600,700,900&display=swap"
|
|
15
|
-
rel="stylesheet"
|
|
16
|
-
/>
|
|
17
|
-
<!-- <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" /> -->
|
|
18
|
-
<link rel="stylesheet" href="https://cdn.vev.design/fontawesome/7.0.0-v2/css/all.min.css" >
|
|
19
|
-
</head>
|
|
20
|
-
<body>
|
|
21
|
-
<div id="root" style="width: 100%;height:100%;"></div>
|
|
22
|
-
</body>
|
|
23
|
-
</html>
|
package/src/docs/app.tsx
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { Keyboard } from '@vev/utils';
|
|
2
|
-
import { last, startCase } from 'lodash';
|
|
3
|
-
import React, { useEffect, useState } from 'react';
|
|
4
|
-
import { BrowserRouter, Link, Route, Routes, useLocation, useNavigate } from 'react-router-dom';
|
|
5
|
-
import {
|
|
6
|
-
Flex,
|
|
7
|
-
SilkeAutocompleteField,
|
|
8
|
-
SilkeBox,
|
|
9
|
-
SilkeButton,
|
|
10
|
-
SilkeDivider,
|
|
11
|
-
SilkeDrawer,
|
|
12
|
-
SilkeIcon,
|
|
13
|
-
SilkeNavigationLink,
|
|
14
|
-
SilkeThemeEditor,
|
|
15
|
-
} from '../components';
|
|
16
|
-
import { SilkeThemeProvider } from '../silke-theme-provider';
|
|
17
|
-
import { AppRoute, AppStore, loadAppRoutes } from './data/app';
|
|
18
|
-
import { useStore } from './data/flux';
|
|
19
|
-
import { DocsProvider } from './docs-provider';
|
|
20
|
-
|
|
21
|
-
const sleep = (timeout = 2000) => new Promise((resolve) => setTimeout(resolve, timeout));
|
|
22
|
-
|
|
23
|
-
const getRouteLabel = (r: AppRoute): string => {
|
|
24
|
-
return startCase(last(r.path.split('/'))?.replace(/(silke-|\.mdx$)/g, ''));
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default function App() {
|
|
28
|
-
const [colorTheme, setColorTheme] = useState({});
|
|
29
|
-
const [showThemeSettings, setShowThemeSettings] = useState(false);
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
loadAppRoutes();
|
|
33
|
-
Keyboard.enable({});
|
|
34
|
-
}, []);
|
|
35
|
-
const handleFileUpload = async (file: File) => {
|
|
36
|
-
await sleep();
|
|
37
|
-
|
|
38
|
-
// Fails 10% of the uploads
|
|
39
|
-
if (Math.random() < 0.1) throw new Error('Failed');
|
|
40
|
-
|
|
41
|
-
return URL.createObjectURL(file);
|
|
42
|
-
};
|
|
43
|
-
return (
|
|
44
|
-
<SilkeThemeProvider colors={colorTheme} onFileUpload={handleFileUpload}>
|
|
45
|
-
<DocsProvider>
|
|
46
|
-
<BrowserRouter>
|
|
47
|
-
<SilkeBox flex fill>
|
|
48
|
-
<SilkeBox column bg="neutral-5" style={{ width: 256 }} scroll>
|
|
49
|
-
<SilkeBox pad="l">
|
|
50
|
-
<Link to="/">
|
|
51
|
-
<img src="https://editor.vev.design/static/logo.svg" width="38" />
|
|
52
|
-
</Link>
|
|
53
|
-
</SilkeBox>
|
|
54
|
-
<AppMenu />
|
|
55
|
-
</SilkeBox>
|
|
56
|
-
|
|
57
|
-
<SilkeBox scroll column flex gap="xl" vPad="xl">
|
|
58
|
-
<AppToolbar onReqestShowTheme={() => setShowThemeSettings(true)} />
|
|
59
|
-
<SilkeBox column hPad="xxl">
|
|
60
|
-
<AppRouter />
|
|
61
|
-
</SilkeBox>
|
|
62
|
-
</SilkeBox>
|
|
63
|
-
</SilkeBox>
|
|
64
|
-
<SilkeDrawer open={showThemeSettings} onRequestClose={() => setShowThemeSettings(false)}>
|
|
65
|
-
<SilkeThemeEditor theme={colorTheme} onChange={setColorTheme} />
|
|
66
|
-
</SilkeDrawer>
|
|
67
|
-
</BrowserRouter>
|
|
68
|
-
</DocsProvider>
|
|
69
|
-
</SilkeThemeProvider>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function AppToolbar({ onReqestShowTheme }: { onReqestShowTheme: () => void }) {
|
|
74
|
-
const [showSearch, setShowSearch] = useState(false);
|
|
75
|
-
const navigate = useNavigate();
|
|
76
|
-
const routes = useStore(AppStore, (s) => s.routes);
|
|
77
|
-
return (
|
|
78
|
-
<SilkeBox
|
|
79
|
-
hPad="xxl"
|
|
80
|
-
vPad="s"
|
|
81
|
-
gap="m"
|
|
82
|
-
style={{ position: 'sticky', top: -32, left: 0, zIndex: 1 }}
|
|
83
|
-
bg="neutral-0"
|
|
84
|
-
>
|
|
85
|
-
{showSearch ? (
|
|
86
|
-
<SilkeAutocompleteField
|
|
87
|
-
inline="label-inside"
|
|
88
|
-
autoFocus
|
|
89
|
-
placeholder="Search components"
|
|
90
|
-
label={<SilkeIcon icon="search" />}
|
|
91
|
-
items={routes.map((route) => ({
|
|
92
|
-
label: getRouteLabel(route),
|
|
93
|
-
value: route.path,
|
|
94
|
-
}))}
|
|
95
|
-
onChange={(value: string) => {
|
|
96
|
-
navigate(value);
|
|
97
|
-
setShowSearch(false);
|
|
98
|
-
}}
|
|
99
|
-
/>
|
|
100
|
-
) : (
|
|
101
|
-
<SilkeButton icon="search" onClick={() => setShowSearch(true)} />
|
|
102
|
-
)}
|
|
103
|
-
<Flex />
|
|
104
|
-
|
|
105
|
-
<SilkeButton icon="undo" label="Reset theme" kind="secondary" />
|
|
106
|
-
<SilkeButton icon="settings" label="Theme settings" onClick={onReqestShowTheme} />
|
|
107
|
-
</SilkeBox>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export function AppMenu() {
|
|
112
|
-
const location = useLocation();
|
|
113
|
-
const routes = useStore(AppStore, (s) => s.routes);
|
|
114
|
-
|
|
115
|
-
const allRoutes = routes
|
|
116
|
-
.filter((r) => r.path !== '/')
|
|
117
|
-
.sort((p1, p2) => (p1.path < p2.path ? -1 : 1));
|
|
118
|
-
const baseRoutes = [];
|
|
119
|
-
const formRoutes = [];
|
|
120
|
-
for (const route of allRoutes) {
|
|
121
|
-
if (/-field|checkbox|form/.test(route.path)) {
|
|
122
|
-
formRoutes.push(route);
|
|
123
|
-
} else {
|
|
124
|
-
baseRoutes.push(route);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return (
|
|
128
|
-
<SilkeBox column>
|
|
129
|
-
{baseRoutes.map((r) => (
|
|
130
|
-
<SilkeNavigationLink
|
|
131
|
-
key={r.path}
|
|
132
|
-
link={r.path}
|
|
133
|
-
icon="widget"
|
|
134
|
-
active={location.pathname === r.path}
|
|
135
|
-
label={getRouteLabel(r)}
|
|
136
|
-
/>
|
|
137
|
-
))}
|
|
138
|
-
<SilkeDivider />
|
|
139
|
-
{formRoutes.map((r) => (
|
|
140
|
-
<SilkeNavigationLink
|
|
141
|
-
key={r.path}
|
|
142
|
-
link={r.path}
|
|
143
|
-
icon="widget"
|
|
144
|
-
active={location.pathname === r.path}
|
|
145
|
-
label={getRouteLabel(r)}
|
|
146
|
-
/>
|
|
147
|
-
))}
|
|
148
|
-
</SilkeBox>
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export function AppRouter() {
|
|
153
|
-
const routes = useStore(AppStore, (s) => s.routes);
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<Routes>
|
|
157
|
-
<>
|
|
158
|
-
{routes
|
|
159
|
-
.sort((r1, r2) => (r1.path.length > r2.path.length ? -1 : 1))
|
|
160
|
-
.map(({ component: Component, path, ...routeProps }) => (
|
|
161
|
-
<Route key={path} path={path} element={<Component />} {...routeProps} />
|
|
162
|
-
))}
|
|
163
|
-
</>
|
|
164
|
-
</Routes>
|
|
165
|
-
);
|
|
166
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import { LiveEditor, LiveError, LivePreview, LiveProvider } from 'react-live';
|
|
4
|
-
import * as silke from '../../../index';
|
|
5
|
-
import styles from './code-block.scss';
|
|
6
|
-
import * as ipsum from '../../ipsum-generator';
|
|
7
|
-
import { useTheme } from '../../../components/silke-code-snippet/silke-code-snippet';
|
|
8
|
-
|
|
9
|
-
const { SilkeBox, SilkeTile, ButtonContext } = silke;
|
|
10
|
-
const CodeScope = {
|
|
11
|
-
...silke,
|
|
12
|
-
ReactDOM,
|
|
13
|
-
ipsum,
|
|
14
|
-
sleep: (timeout = 2000) => new Promise((resolve) => setTimeout(resolve, timeout)),
|
|
15
|
-
};
|
|
16
|
-
interface CodeBlockProps {
|
|
17
|
-
children: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const transformCode = (editorId: number) => (code: string) => {
|
|
21
|
-
code = ipsum.transform(editorId, code);
|
|
22
|
-
// If code starts with < we assume it only contains jsx
|
|
23
|
-
if (code.trim().startsWith('<')) return '<>' + code + '</>';
|
|
24
|
-
// Replace line that starts with jsx openeing tag ("<") with return statement
|
|
25
|
-
code = code.replace(/^</m, 'return <');
|
|
26
|
-
return `() =>{${code}}`;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
let lastEditorId = 0;
|
|
30
|
-
export function CodeBlock({ children }: CodeBlockProps) {
|
|
31
|
-
const editorId = useMemo(() => ++lastEditorId, []);
|
|
32
|
-
return (
|
|
33
|
-
<LiveProvider code={children} transformCode={transformCode(editorId)} scope={CodeScope}>
|
|
34
|
-
<SilkeBox column gap>
|
|
35
|
-
<SilkeBox gap>
|
|
36
|
-
<SilkeTile flex className={styles.preview}>
|
|
37
|
-
<ButtonContext kind="primary">
|
|
38
|
-
<LivePreview className="fill" />
|
|
39
|
-
</ButtonContext>
|
|
40
|
-
</SilkeTile>
|
|
41
|
-
<SilkeTile flex bg="neutral-5" column className={styles.code}>
|
|
42
|
-
<LiveEditor theme={useTheme} style={{ fontFamily: 'var(--font-family-mono)' }} />
|
|
43
|
-
<SilkeBox
|
|
44
|
-
bg="error-30"
|
|
45
|
-
className={styles.error}
|
|
46
|
-
style={{ borderRadius: 'var(--border-radius-small)' }}
|
|
47
|
-
>
|
|
48
|
-
<LiveError style={{ margin: 10 }} />
|
|
49
|
-
</SilkeBox>
|
|
50
|
-
</SilkeTile>
|
|
51
|
-
</SilkeBox>
|
|
52
|
-
</SilkeBox>
|
|
53
|
-
</LiveProvider>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './code-block';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './state-table';
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import styles from './state-table.scss';
|
|
3
|
-
|
|
4
|
-
type State = {
|
|
5
|
-
label: string;
|
|
6
|
-
inherit?: any;
|
|
7
|
-
states: any[];
|
|
8
|
-
};
|
|
9
|
-
interface StateTableProps {
|
|
10
|
-
component: any;
|
|
11
|
-
headers?: string[];
|
|
12
|
-
states: State[];
|
|
13
|
-
props: any[][];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function StateTable({ headers, states, props, component: Comp }: StateTableProps) {
|
|
17
|
-
const [stateProps, setStateProps] = useState({});
|
|
18
|
-
return (
|
|
19
|
-
<div>
|
|
20
|
-
<table className={styles.table}>
|
|
21
|
-
{headers && (
|
|
22
|
-
<tr>
|
|
23
|
-
<th></th>
|
|
24
|
-
{headers.map((h, i) => (
|
|
25
|
-
<td key={i}>{h}</td>
|
|
26
|
-
))}
|
|
27
|
-
</tr>
|
|
28
|
-
)}
|
|
29
|
-
{states.map(({ label, inherit, states }, i) => (
|
|
30
|
-
<tr key={i}>
|
|
31
|
-
<td>
|
|
32
|
-
<small>{label}</small>
|
|
33
|
-
</td>
|
|
34
|
-
{states.map((p, i) => (
|
|
35
|
-
<td key={i}>
|
|
36
|
-
<Comp {...inherit} {...p} {...stateProps} />
|
|
37
|
-
</td>
|
|
38
|
-
))}
|
|
39
|
-
</tr>
|
|
40
|
-
))}
|
|
41
|
-
</table>
|
|
42
|
-
{states.map(({ label, inherit, states }, i) => (
|
|
43
|
-
<pre key={i}>
|
|
44
|
-
{states.map((p, i) => `<${Comp.displayName} ${propsToHtml({ ...inherit, ...p })} />\n`)}
|
|
45
|
-
</pre>
|
|
46
|
-
))}
|
|
47
|
-
</div>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function propsToHtml(p: any) {
|
|
52
|
-
let s = '';
|
|
53
|
-
for (const attr in p) {
|
|
54
|
-
s += ' ' + attr + '=' + JSON.stringify(p[attr]);
|
|
55
|
-
}
|
|
56
|
-
return s;
|
|
57
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { dispatch } from '../flux';
|
|
2
|
-
import { AppRoute, SET_APP_ROUTES } from './constants';
|
|
3
|
-
|
|
4
|
-
export async function loadAppRoutes() {
|
|
5
|
-
const components = require.context('../../../', true, /\.mdx$/, 'lazy');
|
|
6
|
-
const routes = await Promise.all(
|
|
7
|
-
components.keys().map(async (path) => {
|
|
8
|
-
if (path.startsWith('./')) return null;
|
|
9
|
-
return {
|
|
10
|
-
path: '/' + path.replace(/(index)?\.mdx/, ''),
|
|
11
|
-
component: (await components(path)).default,
|
|
12
|
-
} as AppRoute;
|
|
13
|
-
}),
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
dispatch(SET_APP_ROUTES, routes.filter(Boolean));
|
|
17
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { action, Store } from '../flux';
|
|
2
|
-
import { AppRoute, SET_APP_ROUTES } from './constants';
|
|
3
|
-
|
|
4
|
-
class AppDataStore extends Store {
|
|
5
|
-
routes: AppRoute[] = [];
|
|
6
|
-
|
|
7
|
-
@action(SET_APP_ROUTES)
|
|
8
|
-
handleRoutes(e: string, routes: AppRoute[]) {
|
|
9
|
-
this.routes = routes;
|
|
10
|
-
this.emit();
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const AppStore = new AppDataStore();
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Store } from './store';
|
|
2
|
-
|
|
3
|
-
export const actionListeners: { [event: string]: PropertyDescriptor[] } = {};
|
|
4
|
-
export function action(...events: string[]) {
|
|
5
|
-
return function <T extends Store>(target: T, funcName: string, descriptor: PropertyDescriptor) {
|
|
6
|
-
const actions: Record<string, any> = Reflect.get(target, '__actions') || {};
|
|
7
|
-
|
|
8
|
-
events.forEach((event, i) => {
|
|
9
|
-
if (!actions[event]) actions[event] = [];
|
|
10
|
-
actions[event].push(funcName);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
Reflect.set(target, '__actions', actions);
|
|
14
|
-
return descriptor;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { dispatch } from './dispatcher';
|
|
2
|
-
|
|
3
|
-
export type ActionType<T = undefined> = string & { type: T };
|
|
4
|
-
export type Dispatchers<T> = {
|
|
5
|
-
[Const in keyof T]: T[Const] extends ActionType<any>
|
|
6
|
-
? T[Const]['type'] extends undefined
|
|
7
|
-
? () => void
|
|
8
|
-
: (payload: T[Const]['type']) => void
|
|
9
|
-
: unknown;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export function generateDispatchers<T>(actionTypes: T): Dispatchers<T> {
|
|
13
|
-
const res: any = {};
|
|
14
|
-
for (const key in actionTypes) {
|
|
15
|
-
res[key] = (payload: any) => dispatch(actionTypes[key] as any, payload);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return res as Dispatchers<T>;
|
|
19
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
export interface IQueuedModel {
|
|
2
|
-
queued: boolean;
|
|
3
|
-
doUpdate: () => void;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export abstract class QueuedModel implements IQueuedModel {
|
|
7
|
-
queued = false;
|
|
8
|
-
constructor() {
|
|
9
|
-
this.doUpdate = this.doUpdate.bind(this);
|
|
10
|
-
}
|
|
11
|
-
queue() {
|
|
12
|
-
this.queued = true;
|
|
13
|
-
}
|
|
14
|
-
abstract doUpdate(): void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
class FlowController {
|
|
18
|
-
beforeRenderQueue: IQueuedModel[] = [];
|
|
19
|
-
renderQueue: IQueuedModel[] = [];
|
|
20
|
-
|
|
21
|
-
constructor() {
|
|
22
|
-
this.doBeforeRender = this.doBeforeRender.bind(this);
|
|
23
|
-
this.doRender = this.doRender.bind(this);
|
|
24
|
-
this.update();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
addBeforeRender(model: IQueuedModel) {
|
|
28
|
-
this.beforeRenderQueue.push(model);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
removeBeforeRenderModel(model: IQueuedModel) {
|
|
32
|
-
const index = this.beforeRenderQueue.indexOf(model);
|
|
33
|
-
if (index !== -1) {
|
|
34
|
-
this.beforeRenderQueue.splice(index, 1);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
addRender(model: IQueuedModel) {
|
|
39
|
-
this.renderQueue.push(model);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
removeRender(model: IQueuedModel) {
|
|
43
|
-
const index = this.renderQueue.indexOf(model);
|
|
44
|
-
if (index !== -1) {
|
|
45
|
-
this.renderQueue.splice(index, 1);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
update() {
|
|
50
|
-
if (typeof window !== 'undefined' && window.requestAnimationFrame)
|
|
51
|
-
window.requestAnimationFrame(this.doBeforeRender);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
doBeforeRender() {
|
|
55
|
-
for (const model of this.beforeRenderQueue) {
|
|
56
|
-
if (model.queued) {
|
|
57
|
-
model.doUpdate();
|
|
58
|
-
model.queued = false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
this.doRender();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
doRender() {
|
|
65
|
-
for (const model of this.renderQueue) {
|
|
66
|
-
if (model.queued) {
|
|
67
|
-
model.doUpdate();
|
|
68
|
-
model.queued = false;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
this.update();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default new FlowController();
|