@zuzjs/ui 0.3.2 → 0.3.4

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.
Files changed (88) hide show
  1. package/README.md +0 -0
  2. package/dist/hooks.js +89 -0
  3. package/dist/styles.css +37 -62
  4. package/dist/ui.js +665 -0
  5. package/jest.config.js +0 -0
  6. package/package.json +16 -18
  7. package/rollup.config.js +30 -47
  8. package/src/comps/box.tsx +24 -28
  9. package/src/comps/button.tsx +23 -47
  10. package/src/comps/crumb.tsx +9 -0
  11. package/src/comps/form.tsx +57 -88
  12. package/src/comps/heading.tsx +25 -31
  13. package/src/comps/icon.tsx +24 -36
  14. package/src/comps/input.tsx +24 -224
  15. package/src/comps/select.tsx +23 -63
  16. package/src/comps/spinner.tsx +23 -35
  17. package/src/comps/stylesheet.tsx +5 -0
  18. package/src/context/AppContext.tsx +2 -2
  19. package/src/context/AppProvider.tsx +68 -105
  20. package/src/context/createSlice.tsx +15 -39
  21. package/src/context/index.tsx +4 -5
  22. package/src/core/css.ts +1 -0
  23. package/src/core/index.tsx +241 -0
  24. package/src/core/styles.ts +378 -371
  25. package/src/hooks/index.tsx +2 -10
  26. package/src/hooks/useDispatch.tsx +36 -36
  27. package/src/hooks/useStore.tsx +24 -26
  28. package/src/hooks.tsx +8 -0
  29. package/src/scss/mixins.scss +2 -2
  30. package/src/scss/props.scss +91 -69
  31. package/src/scss/{style.scss → styles.scss} +102 -132
  32. package/src/ui.tsx +13 -0
  33. package/tsconfig.json +0 -0
  34. package/tsconfig.lib.json +0 -0
  35. package/tsconfig.spec.json +0 -0
  36. package/dist/index.js +0 -1868
  37. package/src/actions/addForm.tsx +0 -0
  38. package/src/actions/index.tsx +0 -29
  39. package/src/actions/redo.tsx +0 -1
  40. package/src/actions/reset.tsx +0 -1
  41. package/src/actions/undo.tsx +0 -1
  42. package/src/comps/app.tsx +0 -34
  43. package/src/comps/checkbox.tsx +0 -74
  44. package/src/comps/component.tsx +0 -32
  45. package/src/comps/contextmenu.tsx +0 -60
  46. package/src/comps/cover.tsx +0 -34
  47. package/src/comps/image.tsx +0 -34
  48. package/src/comps/masonry.tsx +0 -192
  49. package/src/comps/mediaplayer.tsx +0 -12
  50. package/src/comps/placeholder.tsx +0 -58
  51. package/src/comps/root.tsx +0 -32
  52. package/src/comps/spacer.tsx +0 -20
  53. package/src/comps/text.tsx +0 -27
  54. package/src/comps/toaster.tsx +0 -117
  55. package/src/comps/tweet.tsx +0 -48
  56. package/src/context/_AppProvider.tsx +0 -116
  57. package/src/context/combineReducers.tsx +0 -47
  58. package/src/context/combineState.tsx +0 -14
  59. package/src/context/reduceReducers.tsx +0 -6
  60. package/src/context/store/appbase.tsx +0 -19
  61. package/src/context/store/lang.tsx +0 -26
  62. package/src/context/store/theme.tsx +0 -54
  63. package/src/core/defaultTheme.ts +0 -90
  64. package/src/core/extractCurrentDesignState.tsx +0 -0
  65. package/src/core/index.ts +0 -431
  66. package/src/core/router.ts +0 -86
  67. package/src/hooks/useAppReducer.tsx +0 -40
  68. package/src/hooks/useChooseEffect.tsx +0 -6
  69. package/src/hooks/useContextMenu.tsx +0 -123
  70. package/src/hooks/useDevice.tsx +0 -164
  71. package/src/hooks/useImage.tsx +0 -84
  72. package/src/hooks/useLang.tsx +0 -9
  73. package/src/hooks/useMediaPlayer.tsx +0 -27
  74. package/src/hooks/useNavigator.tsx +0 -6
  75. package/src/hooks/useRender.tsx +0 -29
  76. package/src/hooks/useResizeObserver.tsx +0 -84
  77. package/src/hooks/useRouter.tsx +0 -45
  78. package/src/hooks/useSelector.tsx +0 -9
  79. package/src/hooks/useTheme.tsx +0 -9
  80. package/src/hooks/useToast.tsx +0 -11
  81. package/src/index.tsx +0 -35
  82. package/src/kit/Builder.tsx +0 -18
  83. package/src/kit/Component.tsx +0 -32
  84. package/src/kit/Header.tsx +0 -21
  85. package/src/redux/slices/app.js +0 -26
  86. package/src/redux/slices/form.js +0 -46
  87. package/src/redux/store.js +0 -33
  88. package/src/scss/constants.scss +0 -4
@@ -1,224 +1,24 @@
1
- import {
2
- FC,
3
- Ref,
4
- LegacyRef,
5
- forwardRef,
6
- useRef,
7
- SyntheticEvent,
8
- useEffect,
9
- memo,
10
- } from 'react';
11
- import { ClassNames } from '@emotion/react'
12
- import { nanoid } from 'nanoid';
13
- import { cleanProps, buildCSS } from '../core'
14
- import { STORE_FORM_KEY } from '../context/AppProvider'
15
- import useDispatch from '../hooks/useDispatch'
16
- import useStore from '../hooks/useStore'
17
- import {
18
- UPDATE_FORM_FIELD
19
- } from '../actions'
20
-
21
- const SIZING_STYLE = [
22
- 'borderBottomWidth',
23
- 'borderLeftWidth',
24
- 'borderRightWidth',
25
- 'borderTopWidth',
26
- 'boxSizing',
27
- 'fontFamily',
28
- 'fontSize',
29
- 'fontStyle',
30
- 'fontWeight',
31
- 'letterSpacing',
32
- 'lineHeight',
33
- 'paddingBottom',
34
- 'paddingLeft',
35
- 'paddingRight',
36
- 'paddingTop',
37
- // non-standard
38
- 'tabSize',
39
- 'textIndent',
40
- // non-standard
41
- 'textRendering',
42
- 'textTransform',
43
- 'width',
44
- 'wordBreak',
45
- ] as const;
46
- type SizingProps = Extract<
47
- (typeof SIZING_STYLE)[number],
48
- keyof CSSStyleDeclaration
49
- >;
50
-
51
- export const noop = () => {};
52
-
53
- const pick = <Obj extends { [key: string]: any }, Key extends keyof Obj>(
54
- props: Key[],
55
- obj: Obj,
56
- ): Pick<Obj, Key> =>
57
- props.reduce((acc, prop) => {
58
- acc[prop] = obj[prop];
59
- return acc;
60
- }, {} as Pick<Obj, Key>);
61
-
62
- type SizingStyle = Pick<CSSStyleDeclaration, SizingProps>;
63
-
64
- export type SizingData = {
65
- sizingStyle: SizingStyle;
66
- paddingSize: number;
67
- borderSize: number;
68
- };
69
-
70
- const isIE = !!(document.documentElement as any).currentStyle
71
-
72
- const getSizingData = (node: HTMLElement): SizingData | null => {
73
-
74
- const style = window.getComputedStyle(node);
75
-
76
- if (style === null) {
77
- return null;
78
- }
79
-
80
- const sizingStyle = pick(SIZING_STYLE as unknown as SizingProps[], style);
81
- const { boxSizing } = sizingStyle;
82
-
83
- // probably node is detached from DOM, can't read computed dimensions
84
- if (boxSizing === '') {
85
- return null;
86
- }
87
-
88
- // IE (Edge has already correct behaviour) returns content width as computed width
89
- // so we need to add manually padding and border widths
90
- if (isIE && boxSizing === 'border-box') {
91
- sizingStyle.width =
92
- parseFloat(sizingStyle.width!) +
93
- parseFloat(sizingStyle.borderRightWidth!) +
94
- parseFloat(sizingStyle.borderLeftWidth!) +
95
- parseFloat(sizingStyle.paddingRight!) +
96
- parseFloat(sizingStyle.paddingLeft!) +
97
- 'px';
98
- }
99
-
100
- const paddingSize =
101
- parseFloat(sizingStyle.paddingBottom!) +
102
- parseFloat(sizingStyle.paddingTop!);
103
-
104
- const borderSize =
105
- parseFloat(sizingStyle.borderBottomWidth!) +
106
- parseFloat(sizingStyle.borderTopWidth!);
107
-
108
- return {
109
- sizingStyle,
110
- paddingSize,
111
- borderSize,
112
- };
113
-
114
- }
115
-
116
- const Input = forwardRef((props : { [ key: string ] : any }, ref : Ref<HTMLTextAreaElement|HTMLInputElement>) => {
117
-
118
- const {
119
- as,
120
- accept,
121
- multiple,
122
- onChange,
123
- onKeyUp,
124
- onClick,
125
- onBlur,
126
- onFocus,
127
- readOnly,
128
- type,
129
- tag,
130
- placeholder,
131
- name,
132
- form,
133
- touched,
134
- onSubmit,
135
- value,
136
- defaultValue,
137
- fref,
138
- autoComplete,
139
- elastic,
140
- minRows,
141
- maxRows
142
- } = props;
143
-
144
- const dispatch = useDispatch(STORE_FORM_KEY)
145
- const { forms } = useStore(state => state[STORE_FORM_KEY], false)
146
-
147
- let Tag : string = tag || 'input';
148
- const El = Tag as `textarea` | `input`
149
- const _ref = fref || useRef();
150
-
151
- const _defaultCSS = `width: 100%;border-radius: var(--radius-base);padding-left: 4px;padding-right: 4px;border-style: solid;border-width: 1px;border-color: var(--colors-gray-200);`;
152
-
153
- const isControlled = props.value !== undefined;
154
- const measurementsCacheRef = useRef<SizingData>();
155
-
156
- const handleElastic = () => {
157
- const node = _ref.current!
158
- const nodeSizingData = measurementsCacheRef.current
159
- ? measurementsCacheRef.current : getSizingData(node)
160
- if (!nodeSizingData) {
161
- return;
162
- }
163
- measurementsCacheRef.current = nodeSizingData;
164
-
165
- // const [height, rowHeight] = calculateNodeHeight(
166
- // nodeSizingData,
167
- // node.value || node.placeholder || 'x',
168
- // minRows || 6,
169
- // maxRows || 6,
170
- // );
171
-
172
- }
173
-
174
- useEffect(() => {}, [])
175
-
176
- return (
177
- <ClassNames>
178
- {({ css, cx }) => <El
179
- {...cleanProps(props)}
180
- type={type || `text`}
181
- placeholder={placeholder || undefined}
182
- autoComplete={autoComplete || undefined}
183
- name={name || nanoid()}
184
- multiple={type == 'file' ? multiple : undefined}
185
- accept={accept || `*`}
186
- className={`${as ? `${as} ` : ``}f ${cx(css`${_defaultCSS}${buildCSS(props)}&:hover {${buildCSS(props.hover || {})}} &:focus {${buildCSS(props.focus || {})}}`)}`}
187
- ref={_ref}
188
- value={value || undefined}
189
- defaultValue={defaultValue || ``}
190
- onKeyUp={(e : SyntheticEvent) => {
191
- let k = e['keyCode'] || ['which'];
192
- if(form && onSubmit && El != 'textarea' && k == 13){
193
- onSubmit(forms[form]);
194
- }else{
195
- if(onKeyUp) onKeyUp(e)
196
- }
197
-
198
- }}
199
- onChange={e => {
200
- let val = type == 'file' ?
201
- e.currentTarget.files
202
- : e.currentTarget.value;
203
- if(form) dispatch( dispatch( UPDATE_FORM_FIELD( form || 'orphan', name, val == "" ? null : val, forms ) ) );
204
- // if(El == `textarea` && elastic) handleElastic()
205
- onChange && onChange(val == "" ? null : val)
206
- }}
207
- onClick={onClick ? onClick : () => {}}
208
- readOnly={readOnly || false}
209
- onBlur={e => {
210
- if(onBlur) onBlur(e)
211
- if(touched){}
212
- }}
213
- onFocus={ e => {
214
- if(touched == false)dispatch( UPDATE_FORM_FIELD( form || 'orphan', `touched`, true, forms ) )
215
- if(onFocus) onFocus(e)
216
- }}
217
- />}
218
- </ClassNames>
219
- )
220
-
221
-
222
- })
223
-
224
- export default Input
1
+ import {
2
+ Ref,
3
+ forwardRef
4
+ } from "react";
5
+ import {
6
+ cleanProps,
7
+ withStyle
8
+ } from "../core";
9
+
10
+ const Input = forwardRef(( props: { [ key: string ] : any }, ref : Ref<HTMLTextAreaElement|HTMLInputElement>) => {
11
+
12
+ let Tag : string = props.tag || 'input';
13
+ const El = Tag as `textarea` | `input`
14
+ const _styles = withStyle(props)
15
+
16
+ return <El
17
+ className={_styles}
18
+ onChange={e => { props.onChange && props.onChange(e) }}
19
+ { ...cleanProps(props) }
20
+ />
21
+
22
+ })
23
+
24
+ export default Input
@@ -1,63 +1,23 @@
1
- import {
2
- FC,
3
- LegacyRef,
4
- forwardRef,
5
- useRef,
6
- useEffect
7
- } from 'react';
8
- import { ClassNames } from '@emotion/react'
9
- import { buildCSS } from '../core'
10
- import { nanoid } from 'nanoid';
11
- import useStore from "../hooks/useStore";
12
- import useDispatch from "../hooks/useDispatch";
13
- import {
14
- UPDATE_FORM_FIELD
15
- } from '../actions'
16
- import { STORE_FORM_KEY } from '../context/AppProvider'
17
-
18
- const Select = forwardRef((props : { [ key: string ] : any }, ref : LegacyRef<HTMLHeadingElement>) => {
19
-
20
- const {
21
- as,
22
- onChange,
23
- name,
24
- form,
25
- touched,
26
- options,
27
- defaultValue
28
- } = props;
29
-
30
- const _ref = useRef();
31
- const dispatch = useDispatch(STORE_FORM_KEY)
32
- const { forms } = useStore(state => state[STORE_FORM_KEY], false)
33
-
34
- const _defaultCSS = `width: 100%;border-radius: var(--radius-base);padding-left: 4px;padding-right: 4px;border-style: solid;border-width: 1px;border-color: var(--colors-gray-200);`;
35
-
36
- useEffect(() => {
37
- dispatch( dispatch( UPDATE_FORM_FIELD( form || 'orphan', name,
38
- defaultValue && defaultValue != null && defaultValue != "" && defaultValue != undefined ? defaultValue : options[0]?.value || '-1',
39
- forms ) ) );
40
- }, [])
41
-
42
- return (
43
- <ClassNames>
44
- {({ css, cx }) => <select
45
- onChange={e => {
46
- let val = e.currentTarget.value;
47
- dispatch( dispatch( UPDATE_FORM_FIELD( form || 'orphan', name, val, forms ) ) );
48
- onChange && onChange(val)
49
- }}
50
- onFocus={ e => touched == false && dispatch( UPDATE_FORM_FIELD( form || 'orphan', `touched`, true, forms ) ) }
51
- onBlur={e => {
52
- if(touched){}
53
- }}
54
- name={name || nanoid()}
55
- className={`${as ? as : ``} ${cx(css`${_defaultCSS}${buildCSS(props)}&:hover {${buildCSS(props.hover || {})}}`)}`}
56
- ref={_ref}>{options?.map(o => <option key={`select-${name}-option-${o.value}`} value={o.value}>{o.label}</option>)}</select>}
57
- </ClassNames>
58
- )
59
-
60
-
61
- })
62
-
63
- export default Select
1
+ import {
2
+ Ref,
3
+ forwardRef
4
+ } from "react";
5
+ import {
6
+ cleanProps,
7
+ withStyle
8
+ } from "../core";
9
+
10
+ const Select = forwardRef(( props: { [ key: string ] : any }, ref : Ref<HTMLTextAreaElement|HTMLInputElement>) => {
11
+
12
+ const _styles = withStyle(props)
13
+
14
+ return <select
15
+ className={_styles}
16
+ { ...cleanProps(props) }
17
+ onChange={e => { props.onChange && props.onChange(e) }}>
18
+ {props.options && props.options.map(o => <option key={`${props.id || props.as || props.name}-option-${o.value}`} value={o.value}>{o.label}</option>)}
19
+ </select>
20
+
21
+ })
22
+
23
+ export default Select
@@ -1,36 +1,24 @@
1
- import React from 'react';
2
- import Box from './box'
3
- import PropTypes from 'prop-types'
4
-
5
- const Spinner = (props : any) => {
6
-
7
- return (
8
- <Box
9
- rel
10
- w={props.size}
11
- h={props.size}
12
- zIndex={`1`}
13
- useSelect={`none`}>
14
- <Box abs as={`spinner rotating`} animationDirection={`reverse`} animationDuration={typeof props.s1 == `string` ? props.s1 : `${props.s1}s`} w={props.size} r={props.radius} h={props.size} bg={props.color} opacity={0.2} />
15
- <Box abs as={`spinner rotating`} animationDuration={typeof props.s2 == `string` ? props.s2 : `${props.s2}s`} w={props.size} r={props.radius} h={props.size} bg={props.color} opacity={0.5} />
16
- </Box>
17
- );
18
- }
19
-
20
- Spinner.defaultProps = {
21
- size: 30,
22
- radius: 4,
23
- color: `black`,
24
- s1: `5s`,
25
- s2: `1s`
26
- }
27
-
28
- Spinner.propTypes = {
29
- size: PropTypes.number.isRequired,
30
- color: PropTypes.string,
31
- radius: PropTypes.number,
32
- s1: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
33
- s2: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
34
- }
35
-
1
+ import React from 'react';
2
+ import Box from './box'
3
+ import PropTypes from 'prop-types'
4
+
5
+ const Spinner = (props : any) => {
6
+
7
+ const { size, w, h, color, radius, anim } = props
8
+
9
+ return <Box w={size || 50} rel zIndex={`1`} userSelect={`none`} h={size || 50} as={`zuz-spinner`} anim={(anim || 2).toString()} flex aic jcc>
10
+ <Box as={`zuz-loader`} r={radius || 4} w={w || 30} h={h || 6} bg={color || `#111`} />
11
+ </Box>
12
+
13
+ }
14
+
15
+ Spinner.propTypes = {
16
+ size: PropTypes.number,
17
+ w: PropTypes.number,
18
+ h: PropTypes.number,
19
+ radius: PropTypes.number,
20
+ color: PropTypes.string,
21
+ anim: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
22
+ }
23
+
36
24
  export default Spinner;
@@ -0,0 +1,5 @@
1
+ import { getStylesheet } from "../core";
2
+
3
+ const Stylesheet = (props: any) => <style className={props.id || undefined}>{getStylesheet().join("")}</style>
4
+
5
+ export default Stylesheet
@@ -1,3 +1,3 @@
1
- import { createContext } from 'react'
2
- const AppContext = createContext({});
1
+ import { createContext } from 'react'
2
+ const AppContext = createContext({});
3
3
  export default AppContext;
@@ -1,106 +1,69 @@
1
- import React, {
2
- useCallback,
3
- useEffect,
4
- useMemo,
5
- useReducer
6
- } from 'react'
7
- import PropTypes from 'prop-types'
8
- import AppContext from './AppContext'
9
- import AppTheme from './store/theme'
10
- import AppLang from './store/lang'
11
-
12
- let isMounted = true;
13
- export const STORE_KEY = `__zuzjs`
14
- export const STORE_FORM_KEY = `${STORE_KEY}forms`
15
- export const STORE_DEFAUTLS = [`${STORE_KEY}base`, `${STORE_KEY}forms`]
16
-
17
- const defaultState = {
18
- [`${STORE_KEY}base`] : {
19
- debug: true,
20
- loading: false,
21
- _tmp: Math.random()
22
- },
23
- [STORE_FORM_KEY] : {
24
- forms: {}
25
- }
26
- }
27
-
28
- const rootReducer = (state, action ) => ({
29
- ...state,
30
- ...action.payload
31
- })
32
-
33
- const AppProvider = ({
34
- children,
35
- initialState = {},
36
- theme = {},
37
- lang = {}
38
- }) => {
39
-
40
-
41
- useEffect(() => {
42
- isMounted = true;
43
- return () => {
44
- isMounted = false;
45
- }
46
- }, [])
47
-
48
- const rootState = useMemo(() => ({
49
- ...defaultState,
50
- ...initialState,
51
- theme: new AppTheme({ theme }).get(),
52
- lang: new AppLang({ lang }).get(),
53
- }), [initialState])
54
-
55
- const [state, _dispatch] = useReducer(rootReducer, rootState);
56
-
57
- const dispatch = useCallback((args) => {
58
- if (isMounted) {
59
- _dispatch({ ...args });
60
- }
61
- },
62
- [_dispatch],
63
- );
64
-
65
- // const dispatch = useCallback((payload = {}, _key = 'base') => {
66
- // if(isMounted){
67
- // const key = STORE_DEFAUTLS.indexOf(`${STORE_KEY}${_key}`) > -1 ? `${STORE_KEY}${_key}` : _key;
68
- // const _state = { ...state[key] }
69
- // console.log('key', key)
70
- // console.log('state', _state)
71
- // _dispatch({
72
- // type: 'any',
73
- // payload: {
74
- // payload
75
- // }
76
- // })
77
- // }
78
- // }, [_dispatch]);
79
-
80
- const providedValue = useMemo(
81
- () => ({
82
- ...state,
83
- dispatch
84
- }),
85
- [state]
86
- )
87
-
88
-
89
- return <AppContext.Provider value={providedValue}>{children}</AppContext.Provider>
90
-
91
- }
92
-
93
- AppProvider.defaultProps = {
94
- theme: {},
95
- lang: {},
96
- initialState : {},
97
- }
98
-
99
- AppProvider.propTypes = {
100
- children: PropTypes.node.isRequired,
101
- initialState: PropTypes.instanceOf(Object),
102
- theme: PropTypes.instanceOf(Object),
103
- lang: PropTypes.instanceOf(Object)
104
- }
105
-
1
+ import {
2
+ useCallback,
3
+ useEffect,
4
+ useMemo,
5
+ useReducer
6
+ } from 'react'
7
+ import AppContext from './AppContext'
8
+
9
+ let isMounted = true;
10
+ export const STORE_KEY = `__zuzjs`
11
+ export const STORE_FORM_KEY = `${STORE_KEY}forms`
12
+ export const STORE_DEFAUTLS = [`${STORE_KEY}base`, `${STORE_KEY}forms`]
13
+
14
+ const defaultState = {
15
+ [`${STORE_KEY}base`] : {
16
+ debug: true,
17
+ loading: false,
18
+ _tmp: Math.random()
19
+ },
20
+ [STORE_FORM_KEY] : {
21
+ forms: {}
22
+ }
23
+ }
24
+
25
+ const rootReducer = (state, action ) => ({
26
+ ...state,
27
+ ...action.payload
28
+ })
29
+
30
+ const AppProvider = ({
31
+ children,
32
+ initialState = {}
33
+ }) => {
34
+
35
+ useEffect(() => {
36
+ isMounted = true;
37
+ return () => {
38
+ isMounted = false;
39
+ }
40
+ }, [])
41
+
42
+ const rootState = useMemo(() => ({
43
+ ...defaultState,
44
+ ...initialState
45
+ }), [initialState])
46
+
47
+ const [state, _dispatch] = useReducer(rootReducer, rootState);
48
+
49
+ const dispatch = useCallback((args) => {
50
+ if (isMounted) {
51
+ _dispatch({ ...args });
52
+ }
53
+ },
54
+ [_dispatch],
55
+ );
56
+
57
+ const providedValue = useMemo(
58
+ () => ({
59
+ ...state,
60
+ dispatch
61
+ }),
62
+ [state]
63
+ )
64
+
65
+ return <AppContext.Provider value={providedValue}>{children}</AppContext.Provider>
66
+
67
+ }
68
+
106
69
  export default AppProvider
@@ -1,40 +1,16 @@
1
- import React, { useReducer, useMemo } from 'react'
2
- import PropTypes from 'prop-types'
3
- import combineReducers from './combineReducers'
4
-
5
- const createSlice = ({
6
- name,
7
- initialState,
8
- reducers
9
- }) => {
10
-
11
- // const _dynamiceReducers = {}
12
- // Object.keys(reducers).map(k => {
13
- // _dynamiceReducers[reducers[k].name] = [reducers[k].reducer, initialState]
14
- // })
15
-
16
- // const _keys = Object.keys(reducers);
17
- // const [reducer, state] = combineReducers(_dynamiceReducers);
18
-
19
- return {
20
- name,
21
- reducer: reducers,
22
- actions: reducers,
23
- state: initialState
24
- }
25
-
26
- }
27
-
28
- createSlice.defaultProps = {
29
- name: `app`,
30
- initialState: {},
31
- reducers: {}
32
- }
33
-
34
- createSlice.propTypes = {
35
- name: PropTypes.string.isRequired,
36
- initialState: PropTypes.instanceOf(Object).isRequired,
37
- reducers: PropTypes.instanceOf(Object).isRequired
38
- }
39
-
1
+ const createSlice = ({
2
+ name,
3
+ initialState,
4
+ reducers
5
+ }) => {
6
+
7
+ return {
8
+ name,
9
+ reducer: reducers,
10
+ actions: reducers,
11
+ state: initialState
12
+ }
13
+
14
+ }
15
+
40
16
  export default createSlice;
@@ -1,6 +1,5 @@
1
- import AppContext from './AppContext'
2
-
3
- export default AppContext;
4
-
5
- export { default as Provider } from './AppProvider';
1
+ import AppContext from './AppContext'
2
+
3
+ export default AppContext;
4
+ export { default as Provider } from './AppProvider';
6
5
  export { default as createSlice } from './createSlice';
@@ -0,0 +1 @@
1
+ export default {}