@vev/silke 1.1.0 → 1.1.2
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 +14 -0
- package/dist/index.js +22 -22
- 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 +9 -0
- package/jest.config.js +1 -0
- package/package.json +3 -27
- 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/components/silke-iframe-portal/silke-iframe-portal.mdx +1 -1
- package/src/icons.tsx +46 -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
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Dispatcher } from 'flux';
|
|
2
|
-
|
|
3
|
-
const STORAGE_KEY = 'vevmessage';
|
|
4
|
-
const STORAGE_DATE_KEY = 'vevmessagetime';
|
|
5
|
-
const MAX_NUM_MESSAGES = 10;
|
|
6
|
-
|
|
7
|
-
interface IDispatchEvent {
|
|
8
|
-
type: string;
|
|
9
|
-
payload: any;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const DISPATCH_EVENT: IDispatchEvent = {
|
|
13
|
-
type: '',
|
|
14
|
-
payload: null,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
class AppDispatcher extends Dispatcher<any> {}
|
|
18
|
-
const dispatcher = new AppDispatcher();
|
|
19
|
-
|
|
20
|
-
export function dispatch(event: string, payload?: any): void {
|
|
21
|
-
DISPATCH_EVENT.type = event;
|
|
22
|
-
DISPATCH_EVENT.payload = payload;
|
|
23
|
-
dispatcher.dispatch(DISPATCH_EVENT);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let checkInterval,
|
|
27
|
-
lastRead = Date.now();
|
|
28
|
-
interface TabMessage {
|
|
29
|
-
time: number;
|
|
30
|
-
event: string;
|
|
31
|
-
payload: any;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const localStorage =
|
|
35
|
-
typeof self !== 'undefined' && typeof self.localStorage !== 'undefined' && self.localStorage;
|
|
36
|
-
let messages: TabMessage[] = getMessages();
|
|
37
|
-
if (localStorage) getMessages();
|
|
38
|
-
|
|
39
|
-
if (localStorage && !checkInterval) checkInterval = setInterval(readMessages, 300);
|
|
40
|
-
|
|
41
|
-
function readMessages() {
|
|
42
|
-
const now = Date.now();
|
|
43
|
-
// Hack to fix possible infinite loop, is last read less than 10ms ago then stop read
|
|
44
|
-
if (now - lastRead < 10) return console.log('Last read less than 10ms ago');
|
|
45
|
-
if (!localStorage) return console.log('No local storage present');
|
|
46
|
-
const writeTime = parseInt(localStorage.getItem(STORAGE_DATE_KEY) || '0') || 0;
|
|
47
|
-
if (writeTime > lastRead) {
|
|
48
|
-
// console.log('Reading messages');
|
|
49
|
-
messages = getMessages();
|
|
50
|
-
let i = messages.length;
|
|
51
|
-
while (i-- && messages[i].time > lastRead) {
|
|
52
|
-
// console.log('Got a new message', messages[i].event, messages[i].payload);
|
|
53
|
-
dispatch(messages[i].event, messages[i].payload);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
lastRead = now;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function dispatchToAll(event: string, payload: any): void {
|
|
61
|
-
// console.log('Dispatch to all', event, payload);
|
|
62
|
-
readMessages();
|
|
63
|
-
messages.push({ time: lastRead, event, payload });
|
|
64
|
-
if (messages.length > MAX_NUM_MESSAGES) {
|
|
65
|
-
messages = messages.slice(messages.length - MAX_NUM_MESSAGES);
|
|
66
|
-
}
|
|
67
|
-
if (!localStorage) return console.log('dispatch failed no locacl storage available'!);
|
|
68
|
-
localStorage.setItem(STORAGE_DATE_KEY, Date.now() + '');
|
|
69
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(messages));
|
|
70
|
-
dispatch(event, payload);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function getMessages(): TabMessage[] {
|
|
74
|
-
return typeof localStorage !== 'undefined' && localStorage
|
|
75
|
-
? JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]')
|
|
76
|
-
: [];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export default dispatcher;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Duplicate from:
|
|
2
|
-
// core/src/data
|
|
3
|
-
// For now :)
|
|
4
|
-
|
|
5
|
-
export { Store } from './store';
|
|
6
|
-
export { dispatch, dispatchToAll } from './dispatcher';
|
|
7
|
-
export { action } from './action-decorator';
|
|
8
|
-
export { useStore } from './use-store';
|
|
9
|
-
export { generateDispatchers, Dispatchers, ActionType } from './action-utils';
|
|
10
|
-
export { default as FlowController, IQueuedModel } from './controller';
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import AppDispatcher from './dispatcher';
|
|
2
|
-
import FlowController, { QueuedModel } from './controller';
|
|
3
|
-
|
|
4
|
-
type StoreListener = () => void;
|
|
5
|
-
|
|
6
|
-
export class Store extends QueuedModel {
|
|
7
|
-
#listeners: StoreListener[] = [];
|
|
8
|
-
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
AppDispatcher.register((p) => this.handleDispatch(p));
|
|
12
|
-
FlowController.addBeforeRender(this);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
off(cb: StoreListener): void {
|
|
16
|
-
const index = this.#listeners.indexOf(cb);
|
|
17
|
-
if (index !== -1) this.#listeners.splice(index, 1);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
on(cb: StoreListener) {
|
|
21
|
-
if (this.#listeners.indexOf(cb) === -1) this.#listeners.push(cb);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
emit(): void {
|
|
25
|
-
this.queued = true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
doUpdate(): void {
|
|
29
|
-
for (const cb of this.#listeners) cb();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
protected handleDispatch({ type, payload }: { type: string; payload: any }) {
|
|
33
|
-
const actions = Reflect.get(this, '__actions') as Record<string, any>;
|
|
34
|
-
if (!actions) return;
|
|
35
|
-
|
|
36
|
-
const listeners = actions[type];
|
|
37
|
-
if (listeners) {
|
|
38
|
-
for (const funcName of listeners) {
|
|
39
|
-
// @ts-ignore don know how to make typescript support this
|
|
40
|
-
this[funcName](type, payload);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { isArray } from 'lodash';
|
|
2
|
-
import { useEffect, useRef, useState } from 'react';
|
|
3
|
-
import flowController from './controller';
|
|
4
|
-
import { Store } from './store';
|
|
5
|
-
|
|
6
|
-
function hasChanged<U>(current: U, next: U, debugLabel?: string): boolean {
|
|
7
|
-
if (isArray(current) && isArray(next)) {
|
|
8
|
-
if (current.length !== next.length) return true;
|
|
9
|
-
let i = current.length;
|
|
10
|
-
while (i--) {
|
|
11
|
-
if (current[i] !== next[i]) {
|
|
12
|
-
if (debugLabel) console.log(`#${debugLabel}: change to array index ${i}`);
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
if (debugLabel && next !== current) {
|
|
20
|
-
if (debugLabel) console.log(`#${debugLabel}: change to value`);
|
|
21
|
-
}
|
|
22
|
-
return next !== current;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function useStore<T extends Store, U>(
|
|
26
|
-
store: T,
|
|
27
|
-
mapper: (store: T) => U,
|
|
28
|
-
deps?: any[],
|
|
29
|
-
debugLabel?: string,
|
|
30
|
-
): U {
|
|
31
|
-
const state = useRef<U>();
|
|
32
|
-
if (!state.current) state.current = mapper(store);
|
|
33
|
-
const [, forceUpdate] = useState<number>();
|
|
34
|
-
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
const flow = {
|
|
37
|
-
queued: true,
|
|
38
|
-
doUpdate: () => {
|
|
39
|
-
const next = mapper(store);
|
|
40
|
-
if (hasChanged(state.current, next, debugLabel)) {
|
|
41
|
-
state.current = next;
|
|
42
|
-
forceUpdate(Date.now());
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
const doQueue = () => (flow.queued = true);
|
|
47
|
-
flowController.addRender(flow);
|
|
48
|
-
store.on(doQueue);
|
|
49
|
-
flow.doUpdate();
|
|
50
|
-
|
|
51
|
-
return () => {
|
|
52
|
-
store.off(doQueue);
|
|
53
|
-
flowController.removeRender(flow);
|
|
54
|
-
};
|
|
55
|
-
}, deps || []);
|
|
56
|
-
return state.current;
|
|
57
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { MDXProvider } from '@mdx-js/react';
|
|
3
|
-
import { CodeBlock } from './components/code-block';
|
|
4
|
-
|
|
5
|
-
interface DocsProviderProps {
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function DocsProvider({ children }: DocsProviderProps) {
|
|
10
|
-
return (
|
|
11
|
-
<MDXProvider
|
|
12
|
-
components={{
|
|
13
|
-
code(props: any) {
|
|
14
|
-
return <CodeBlock {...props} />;
|
|
15
|
-
},
|
|
16
|
-
pre(props: any) {
|
|
17
|
-
return <div {...props} />;
|
|
18
|
-
},
|
|
19
|
-
}}
|
|
20
|
-
>
|
|
21
|
-
{children}
|
|
22
|
-
</MDXProvider>
|
|
23
|
-
);
|
|
24
|
-
}
|
package/src/docs/index.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { isNumber, sample, times, upperFirst } from 'lodash';
|
|
2
|
-
import generateName from 'project-name-generator';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
type IpsumFunc = (...args: any) => any;
|
|
6
|
-
type IpsumFunctions = { [key: string]: IpsumFunc };
|
|
7
|
-
|
|
8
|
-
const randomText = [
|
|
9
|
-
`You're telling the enemy exactly what you're going to do. No wonder you've been fighting Lorem Ipsum your entire adult life. Lorem Ipsum is unattractive, both inside and out. I fully understand why it’s former users left it for something else. They made a good decision.`,
|
|
10
|
-
`You know, it really doesn’t matter what you write as long as you’ve got a young, and beautiful, piece of text. You know, it really doesn’t matter what you write as long as you’ve got a young, and beautiful, piece of text. Look at these words. Are they small words? And he referred to my words - if they're small, something else must be small. I guarantee you there's no problem, I guarantee. The other thing with Lorem Ipsum is that you have to take out its family. I think the only difference between me and the other placeholder text is that I’m more honest and my words are more beautiful.`,
|
|
11
|
-
`We are going to make placeholder text great again. Greater than ever before. You know, it really doesn’t matter what you write as long as you’ve got a young, and beautiful, piece of text.`,
|
|
12
|
-
`That other text? Sadly, it’s no longer a 10. Lorem Ipsum's father was with Lee Harvey Oswald prior to Oswald's being, you know, shot. I was going to say something extremely rough to Lorem Ipsum, to its family, and I said to myself, "I can't do it. I just can't do it. It's inappropriate. It's not nice."`,
|
|
13
|
-
`You’re disgusting. Trump Ipsum is calling for a total and complete shutdown of Muslim text entering your website. If Trump Ipsum weren’t my own words, perhaps I’d be dating it.`,
|
|
14
|
-
`Lorem Ipsum is FAKE TEXT! Lorem Ipsum's father was with Lee Harvey Oswald prior to Oswald's being, you know, shot. I think the only card she has is the Lorem card. My placeholder text, I think, is going to end up being very good with women.`,
|
|
15
|
-
`I’m the best thing that ever happened to placeholder text. He’s not a word hero. He’s a word hero because he was captured. I like text that wasn’t captured. This placeholder text is gonna be HUGE.`,
|
|
16
|
-
`When other websites give you text, they’re not sending the best. They’re not sending you, they’re sending words that have lots of problems and they’re bringing those problems with us. They’re bringing mistakes. They’re bringing misspellings. They’re typists… And some, I assume, are good words. I was going to say something extremely rough to Lorem Ipsum, to its family, and I said to myself, "I can't do it. I just can't do it. It's inappropriate. It's not nice."`,
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
const ipsum: IpsumFunctions = {
|
|
20
|
-
image(size = 300): string {
|
|
21
|
-
return `https://picsum.photos/${size}/${size}?random='${img++}`;
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
name(words = 2): string {
|
|
25
|
-
return upperFirst(generateName({ words }).spaced);
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
list<T = any>(arg1: number | ((index: number) => T), arg2?: (index: number) => T): T[] {
|
|
29
|
-
const length = isNumber(arg1) ? arg1 : 10;
|
|
30
|
-
const cb = isNumber(arg1) ? arg2 : arg1;
|
|
31
|
-
return times(length, cb as (index: number) => T);
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
text(): string {
|
|
35
|
-
return sample(randomText) as string;
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
p(count = 3): JSX.Element[] {
|
|
39
|
-
const res: JSX.Element[] = [];
|
|
40
|
-
while (count--) res.push(<p key={count}>{sample(randomText)}</p>);
|
|
41
|
-
return res;
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
promise(cb: () => any, timeout = 2000): Promise<void> {
|
|
45
|
-
return new Promise((resolve) => {
|
|
46
|
-
setTimeout(() => resolve(cb()), timeout);
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// Used by eval of when replacing ipsum
|
|
52
|
-
// (window as any).ipsum = { name, list, image, text, p };
|
|
53
|
-
export function transform(editorId: number, code: string) {
|
|
54
|
-
const reg = /ipsum\s*\.\w+\(/g;
|
|
55
|
-
return code.replace(reg, (m) => m.replace(/^ipsum/, `ipsum.run(${editorId})`));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const timer: Record<string, number> = {};
|
|
59
|
-
const cachePointer: Record<string, number> = {};
|
|
60
|
-
const execCache: Record<string, any[]> = {};
|
|
61
|
-
|
|
62
|
-
export function run(id: number) {
|
|
63
|
-
const res: IpsumFunctions = {};
|
|
64
|
-
for (const key in ipsum) {
|
|
65
|
-
res[key] = (...args: any[]): any => {
|
|
66
|
-
const now = performance.now();
|
|
67
|
-
// Creating a cache id for the cmd
|
|
68
|
-
const cacheId = `${id}-${key}(${args.map((a) => a.toString()).join(',')})`;
|
|
69
|
-
const last = timer[cacheId] || now;
|
|
70
|
-
timer[cacheId] = now;
|
|
71
|
-
|
|
72
|
-
if (!execCache[cacheId]) execCache[cacheId] = [];
|
|
73
|
-
if (now - last > 30) cachePointer[cacheId] = 0;
|
|
74
|
-
|
|
75
|
-
const cache = execCache[cacheId];
|
|
76
|
-
const pointer = cachePointer[cacheId] || 0;
|
|
77
|
-
|
|
78
|
-
if (cache.length >= pointer) cache.push(ipsum[key](...args));
|
|
79
|
-
cachePointer[cacheId] = pointer + 1;
|
|
80
|
-
return cache[pointer];
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
return res;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
let img = 0;
|