@zuzjs/ui 0.3.7 → 0.3.9

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 (45) hide show
  1. package/dist/bin.d.ts +2 -0
  2. package/dist/bin.js +107 -0
  3. package/dist/comps/base.d.ts +10 -0
  4. package/dist/comps/base.js +12 -0
  5. package/dist/comps/box.d.ts +4 -0
  6. package/dist/comps/box.js +15 -0
  7. package/dist/comps/button.d.ts +4 -0
  8. package/dist/comps/button.js +19 -0
  9. package/dist/comps/checkbox.d.ts +4 -0
  10. package/dist/comps/checkbox.js +28 -0
  11. package/dist/comps/cover.d.ts +11 -0
  12. package/dist/comps/cover.js +36 -0
  13. package/dist/comps/form.d.ts +18 -0
  14. package/dist/comps/form.js +287 -0
  15. package/dist/comps/heading.d.ts +7 -0
  16. package/dist/comps/heading.js +21 -0
  17. package/dist/comps/icon.d.ts +5 -0
  18. package/dist/comps/icon.js +18 -0
  19. package/dist/comps/input.d.ts +6 -0
  20. package/dist/comps/input.js +23 -0
  21. package/dist/comps/sheet.d.ts +13 -0
  22. package/dist/comps/sheet.js +102 -0
  23. package/dist/comps/spinner.d.ts +14 -0
  24. package/dist/comps/spinner.js +42 -0
  25. package/dist/funs/colors.d.ts +7 -0
  26. package/dist/funs/colors.js +9 -0
  27. package/dist/funs/css.d.ts +269 -0
  28. package/dist/funs/css.js +413 -0
  29. package/dist/funs/index.d.ts +20 -0
  30. package/dist/funs/index.js +125 -0
  31. package/dist/funs/stylesheet.d.ts +242 -0
  32. package/dist/funs/stylesheet.js +249 -0
  33. package/dist/index.d.ts +11 -0
  34. package/dist/index.js +11 -0
  35. package/dist/styles.css +1 -460
  36. package/dist/types/enums.d.ts +19 -0
  37. package/dist/types/enums.js +23 -0
  38. package/dist/types/index.d.ts +24 -0
  39. package/dist/types/index.js +1 -0
  40. package/dist/types/interfaces.d.ts +4 -0
  41. package/dist/types/interfaces.js +1 -0
  42. package/package.json +50 -44
  43. package/README.md +0 -1
  44. package/dist/hooks.js +0 -89
  45. package/dist/ui.js +0 -688
package/dist/hooks.js DELETED
@@ -1,89 +0,0 @@
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 };