@zuzjs/ui 0.3.3 → 0.3.5
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 +0 -0
- package/dist/hooks.js +89 -0
- package/dist/styles.css +37 -62
- package/dist/ui.js +679 -0
- package/jest.config.js +0 -0
- package/package.json +17 -18
- package/rollup.config.js +30 -47
- package/tsconfig.json +0 -0
- package/tsconfig.lib.json +0 -0
- package/tsconfig.spec.json +0 -0
- package/dist/index.js +0 -1879
- package/src/actions/addForm.tsx +0 -0
- package/src/actions/index.tsx +0 -29
- package/src/actions/redo.tsx +0 -1
- package/src/actions/reset.tsx +0 -1
- package/src/actions/undo.tsx +0 -1
- package/src/comps/app.tsx +0 -34
- package/src/comps/box.tsx +0 -28
- package/src/comps/button.tsx +0 -47
- package/src/comps/checkbox.tsx +0 -74
- package/src/comps/component.tsx +0 -32
- package/src/comps/contextmenu.tsx +0 -60
- package/src/comps/cover.tsx +0 -34
- package/src/comps/form.tsx +0 -89
- package/src/comps/heading.tsx +0 -31
- package/src/comps/icon.tsx +0 -36
- package/src/comps/image.tsx +0 -34
- package/src/comps/input.tsx +0 -224
- package/src/comps/masonry.tsx +0 -192
- package/src/comps/mediaplayer.tsx +0 -12
- package/src/comps/placeholder.tsx +0 -58
- package/src/comps/root.tsx +0 -32
- package/src/comps/select.tsx +0 -63
- package/src/comps/spacer.tsx +0 -20
- package/src/comps/spinner.tsx +0 -36
- package/src/comps/text.tsx +0 -27
- package/src/comps/toaster.tsx +0 -123
- package/src/comps/tweet.tsx +0 -48
- package/src/context/AppContext.tsx +0 -3
- package/src/context/AppProvider.tsx +0 -106
- package/src/context/_AppProvider.tsx +0 -116
- package/src/context/combineReducers.tsx +0 -47
- package/src/context/combineState.tsx +0 -14
- package/src/context/createSlice.tsx +0 -40
- package/src/context/index.tsx +0 -6
- package/src/context/reduceReducers.tsx +0 -6
- package/src/context/store/appbase.tsx +0 -19
- package/src/context/store/lang.tsx +0 -26
- package/src/context/store/theme.tsx +0 -54
- package/src/core/extractCurrentDesignState.tsx +0 -0
- package/src/core/index.ts +0 -431
- package/src/core/router.ts +0 -86
- package/src/core/styles.ts +0 -372
- package/src/hooks/index.tsx +0 -10
- package/src/hooks/useAppReducer.tsx +0 -40
- package/src/hooks/useChooseEffect.tsx +0 -6
- package/src/hooks/useContextMenu.tsx +0 -123
- package/src/hooks/useDevice.tsx +0 -168
- package/src/hooks/useDispatch.tsx +0 -37
- package/src/hooks/useImage.tsx +0 -84
- package/src/hooks/useLang.tsx +0 -9
- package/src/hooks/useMediaPlayer.tsx +0 -27
- package/src/hooks/useNavigator.tsx +0 -6
- package/src/hooks/useRender.tsx +0 -29
- package/src/hooks/useResizeObserver.tsx +0 -84
- package/src/hooks/useRouter.tsx +0 -45
- package/src/hooks/useSelector.tsx +0 -9
- package/src/hooks/useStore.tsx +0 -27
- package/src/hooks/useTheme.tsx +0 -9
- package/src/hooks/useToast.tsx +0 -11
- package/src/index.tsx +0 -33
- package/src/kit/Builder.tsx +0 -18
- package/src/kit/Component.tsx +0 -32
- package/src/kit/Header.tsx +0 -21
- package/src/scss/constants.scss +0 -4
- package/src/scss/mixins.scss +0 -3
- package/src/scss/props.scss +0 -70
- package/src/scss/style.scss +0 -133
package/README.md
CHANGED
|
File without changes
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createContext, useEffect, useMemo, useReducer, useCallback, useContext } from 'react';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
const AppContext = createContext({});
|
|
5
|
+
|
|
6
|
+
let isMounted = true;
|
|
7
|
+
const STORE_KEY = `__zuzjs`;
|
|
8
|
+
const STORE_FORM_KEY = `${STORE_KEY}forms`;
|
|
9
|
+
const defaultState = {
|
|
10
|
+
[`${STORE_KEY}base`]: {
|
|
11
|
+
debug: true,
|
|
12
|
+
loading: false,
|
|
13
|
+
_tmp: Math.random()
|
|
14
|
+
},
|
|
15
|
+
[STORE_FORM_KEY]: {
|
|
16
|
+
forms: {}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const rootReducer = (state, action) => (Object.assign(Object.assign({}, state), action.payload));
|
|
20
|
+
const AppProvider = ({ children, initialState = {} }) => {
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
isMounted = true;
|
|
23
|
+
return () => {
|
|
24
|
+
isMounted = false;
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
const rootState = useMemo(() => (Object.assign(Object.assign({}, defaultState), initialState)), [initialState]);
|
|
28
|
+
const [state, _dispatch] = useReducer(rootReducer, rootState);
|
|
29
|
+
const dispatch = useCallback((args) => {
|
|
30
|
+
if (isMounted) {
|
|
31
|
+
_dispatch(Object.assign({}, args));
|
|
32
|
+
}
|
|
33
|
+
}, [_dispatch]);
|
|
34
|
+
const providedValue = useMemo(() => (Object.assign(Object.assign({}, state), { dispatch })), [state]);
|
|
35
|
+
return jsx(AppContext.Provider, { value: providedValue, children: children });
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const createSlice = ({ name, initialState, reducers }) => {
|
|
39
|
+
return {
|
|
40
|
+
name,
|
|
41
|
+
reducer: reducers,
|
|
42
|
+
actions: reducers,
|
|
43
|
+
state: initialState
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const useStore = (callback, withFilter = true) => {
|
|
48
|
+
let _state = useContext(AppContext);
|
|
49
|
+
let state = withFilter ? {} : _state;
|
|
50
|
+
if (withFilter) {
|
|
51
|
+
const filters = ['defaultState', 'theme', 'dispatch', `${STORE_KEY}base`, `${STORE_KEY}forms`];
|
|
52
|
+
Object.keys(_state).map(k => {
|
|
53
|
+
if (filters.indexOf(k) == -1) {
|
|
54
|
+
state[k] = _state[k];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if ("function" == typeof callback) {
|
|
59
|
+
return callback(state);
|
|
60
|
+
}
|
|
61
|
+
return state;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const useDispatch = (key) => {
|
|
65
|
+
const state = useContext(AppContext);
|
|
66
|
+
const dispatch = state['dispatch'];
|
|
67
|
+
const prepareState = (prevState, nextState) => {
|
|
68
|
+
const nextKeys = Object.keys(nextState);
|
|
69
|
+
nextKeys.map(k => {
|
|
70
|
+
if (prevState[k] !== nextState[k]) {
|
|
71
|
+
prevState[k] = nextState[k];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return Object.assign(Object.assign({}, prevState), nextState);
|
|
75
|
+
};
|
|
76
|
+
if (key) {
|
|
77
|
+
return (payload = {}) => {
|
|
78
|
+
dispatch({
|
|
79
|
+
action: key,
|
|
80
|
+
payload: {
|
|
81
|
+
[key]: prepareState(state[key], payload)
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return dispatch;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { AppProvider as Provider, createSlice, useDispatch, useStore };
|
package/dist/styles.css
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--primary-color: #b72b2e;
|
|
3
|
-
--primary-font: "Open Sans", sans-serif, segoe ui;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
1
|
*, *:before, *:after {
|
|
7
2
|
-moz-box-sizing: border-box;
|
|
8
3
|
-webkit-box-sizing: border-box;
|
|
@@ -57,51 +52,60 @@ a img {
|
|
|
57
52
|
border: none;
|
|
58
53
|
}
|
|
59
54
|
|
|
60
|
-
*, .f {
|
|
61
|
-
font-family: var(--primary-font);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.fb {
|
|
65
|
-
font-family: var(--primary-font-bold);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
55
|
button {
|
|
69
56
|
cursor: pointer;
|
|
70
57
|
}
|
|
71
58
|
|
|
59
|
+
.grid {
|
|
60
|
+
display: grid;
|
|
61
|
+
}
|
|
62
|
+
|
|
72
63
|
.fixed {
|
|
73
64
|
position: fixed;
|
|
74
65
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
66
|
+
.fixed.fill {
|
|
67
|
+
top: 0px;
|
|
68
|
+
left: 0px;
|
|
69
|
+
right: 0px;
|
|
70
|
+
bottom: 0px;
|
|
78
71
|
}
|
|
79
72
|
|
|
80
|
-
.
|
|
81
|
-
|
|
73
|
+
.rel {
|
|
74
|
+
position: relative;
|
|
82
75
|
}
|
|
83
76
|
|
|
84
|
-
.
|
|
85
|
-
|
|
77
|
+
.abs {
|
|
78
|
+
position: absolute;
|
|
79
|
+
}
|
|
80
|
+
.abs.abc {
|
|
81
|
+
top: 50%;
|
|
82
|
+
left: 50%;
|
|
83
|
+
transform: translate(-50%, -50%);
|
|
84
|
+
}
|
|
85
|
+
.abs.fill {
|
|
86
|
+
top: 0px;
|
|
87
|
+
left: 0px;
|
|
88
|
+
right: 0px;
|
|
89
|
+
bottom: 0px;
|
|
86
90
|
}
|
|
87
91
|
|
|
88
|
-
.
|
|
89
|
-
|
|
92
|
+
.sticky {
|
|
93
|
+
position: sticky;
|
|
90
94
|
}
|
|
91
95
|
|
|
92
|
-
.
|
|
93
|
-
|
|
96
|
+
.block {
|
|
97
|
+
display: block;
|
|
94
98
|
}
|
|
95
99
|
|
|
96
|
-
.
|
|
97
|
-
|
|
100
|
+
.iblock {
|
|
101
|
+
display: inline-block;
|
|
98
102
|
}
|
|
99
103
|
|
|
100
104
|
.tdnh, .tdn {
|
|
101
105
|
text-decoration: none;
|
|
102
106
|
}
|
|
103
107
|
|
|
104
|
-
.tdnh:hover {
|
|
108
|
+
.tdnh:hover, .tdh:hover {
|
|
105
109
|
text-decoration: underline;
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -135,6 +139,9 @@ button {
|
|
|
135
139
|
.flex.jce {
|
|
136
140
|
justify-content: flex-end;
|
|
137
141
|
}
|
|
142
|
+
.flex.col {
|
|
143
|
+
flex-direction: column;
|
|
144
|
+
}
|
|
138
145
|
|
|
139
146
|
/*
|
|
140
147
|
COLORS
|
|
@@ -356,19 +363,7 @@ button {
|
|
|
356
363
|
font-weight: 900;
|
|
357
364
|
}
|
|
358
365
|
|
|
359
|
-
|
|
360
|
-
from {
|
|
361
|
-
-webkit-transform: rotate(0deg);
|
|
362
|
-
-o-transform: rotate(0deg);
|
|
363
|
-
transform: rotate(0deg);
|
|
364
|
-
}
|
|
365
|
-
to {
|
|
366
|
-
-webkit-transform: rotate(360deg);
|
|
367
|
-
-o-transform: rotate(360deg);
|
|
368
|
-
transform: rotate(360deg);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
@keyframes rotating {
|
|
366
|
+
@keyframes rotate-loop {
|
|
372
367
|
from {
|
|
373
368
|
-ms-transform: rotate(0deg);
|
|
374
369
|
-moz-transform: rotate(0deg);
|
|
@@ -384,34 +379,14 @@ button {
|
|
|
384
379
|
transform: rotate(360deg);
|
|
385
380
|
}
|
|
386
381
|
}
|
|
387
|
-
.
|
|
388
|
-
|
|
389
|
-
-moz-animation: rotating 2s linear infinite;
|
|
390
|
-
-ms-animation: rotating 2s linear infinite;
|
|
391
|
-
-o-animation: rotating 2s linear infinite;
|
|
392
|
-
animation: rotating 2s linear infinite;
|
|
382
|
+
.zuz-spinner .zuz-loader {
|
|
383
|
+
animation: rotate-loop 0.5s linear infinite;
|
|
393
384
|
}
|
|
394
385
|
|
|
395
386
|
.button {
|
|
396
|
-
background: var(--primary-color);
|
|
397
|
-
color: #fff;
|
|
398
387
|
border: 0px;
|
|
399
388
|
}
|
|
400
389
|
|
|
401
|
-
.zuz-toast {
|
|
402
|
-
border-radius: 5px;
|
|
403
|
-
transition: all 0.15s linear 0s;
|
|
404
|
-
}
|
|
405
|
-
.zuz-toast.hidden {
|
|
406
|
-
transform: translate(-50%, -300px) scale(0.5) !important;
|
|
407
|
-
}
|
|
408
|
-
.zuz-toast.showing {
|
|
409
|
-
transform: translate(-50%, -50px) scale(0.9) !important;
|
|
410
|
-
}
|
|
411
|
-
.zuz-toast.visible {
|
|
412
|
-
transform: translate(-50%, 0px) scale(1) !important;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
390
|
.zuz-checkbox {
|
|
416
391
|
opacity: 0;
|
|
417
392
|
position: absolute;
|