@react-pakistan/util-functions 1.24.3 → 1.24.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.
@@ -22,16 +22,16 @@ interface Params {
22
22
  updateParams: object;
23
23
  }
24
24
  interface Return {
25
- byIdError: Error;
25
+ byIdError?: Error;
26
26
  byIdFetchNow: (url?: string, config?: FetchConfig) => void;
27
27
  byIdLoading: boolean;
28
28
  deleteError?: Error;
29
29
  deleteFetchNow?: (url?: string, config?: FetchConfig) => void;
30
30
  deleteLoading?: boolean;
31
- listError: Error;
31
+ listError?: Error;
32
32
  listFetchNow: () => void;
33
33
  listLoading: boolean;
34
- updateError: Error;
34
+ updateError?: Error;
35
35
  updateFetchNow: (url?: string, config?: FetchConfig) => void;
36
36
  updateLoading: boolean;
37
37
  }
package/index.d.ts CHANGED
@@ -25,4 +25,3 @@ export * from './general';
25
25
  export * from './hooks';
26
26
  export * from './local-storage';
27
27
  export * from './storybook';
28
- export * from './module/my-module';
package/index.js CHANGED
@@ -41,4 +41,4 @@ __exportStar(require("./general"), exports);
41
41
  __exportStar(require("./hooks"), exports);
42
42
  __exportStar(require("./local-storage"), exports);
43
43
  __exportStar(require("./storybook"), exports);
44
- __exportStar(require("./module/my-module"), exports);
44
+ // export * from './module/my-module';
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- type State = {
3
- count: number;
4
- isLoading: boolean;
5
- };
6
- type Action = {
7
- type: 'INCREMENT';
8
- } | {
9
- type: 'DECREMENT';
10
- } | {
11
- type: 'SET_LOADING';
12
- payload: boolean;
13
- };
14
- type MyModuleProviderProps = {
15
- children: React.ReactNode;
16
- initialState?: Partial<State>;
17
- };
18
- export declare const MyModuleProvider: React.FC<MyModuleProviderProps>;
19
- export declare const useMyModule: () => {
20
- state: State;
21
- dispatch: React.Dispatch<Action>;
22
- };
23
- export declare const Counter: React.FC;
24
- export {};
@@ -1,88 +1,69 @@
1
- "use strict";
2
- /* eslint-disable */
3
- var __assign = (this && this.__assign) || function () {
4
- __assign = Object.assign || function(t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
- t[p] = s[p];
9
- }
10
- return t;
11
- };
12
- return __assign.apply(this, arguments);
13
- };
14
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- var desc = Object.getOwnPropertyDescriptor(m, k);
17
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
- desc = { enumerable: true, get: function() { return m[k]; } };
19
- }
20
- Object.defineProperty(o, k2, desc);
21
- }) : (function(o, m, k, k2) {
22
- if (k2 === undefined) k2 = k;
23
- o[k2] = m[k];
24
- }));
25
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26
- Object.defineProperty(o, "default", { enumerable: true, value: v });
27
- }) : function(o, v) {
28
- o["default"] = v;
29
- });
30
- var __importStar = (this && this.__importStar) || (function () {
31
- var ownKeys = function(o) {
32
- ownKeys = Object.getOwnPropertyNames || function (o) {
33
- var ar = [];
34
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
35
- return ar;
36
- };
37
- return ownKeys(o);
38
- };
39
- return function (mod) {
40
- if (mod && mod.__esModule) return mod;
41
- var result = {};
42
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
43
- __setModuleDefault(result, mod);
44
- return result;
45
- };
46
- })();
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.Counter = exports.useMyModule = exports.MyModuleProvider = void 0;
49
- var react_1 = __importStar(require("react"));
50
- // 2. Create a context for your module
51
- var MyModuleContext = (0, react_1.createContext)(undefined);
52
- // 3. Reducer function
53
- var reducer = function (state, action) {
54
- switch (action.type) {
55
- case 'INCREMENT':
56
- return __assign(__assign({}, state), { count: state.count + 1 });
57
- case 'DECREMENT':
58
- return __assign(__assign({}, state), { count: state.count - 1 });
59
- case 'SET_LOADING':
60
- return __assign(__assign({}, state), { isLoading: action.payload });
61
- default:
62
- return state;
63
- }
64
- };
65
- var MyModuleProvider = function (_a) {
66
- var children = _a.children, initialState = _a.initialState;
67
- var _b = (0, react_1.useReducer)(reducer, __assign({ count: 0, isLoading: false }, initialState)), state = _b[0], dispatch = _b[1];
68
- return (react_1.default.createElement(MyModuleContext.Provider, { value: { state: state, dispatch: dispatch } }, children));
69
- };
70
- exports.MyModuleProvider = MyModuleProvider;
71
- // 5. Custom hook to access the context
72
- var useMyModule = function () {
73
- var context = (0, react_1.useContext)(MyModuleContext);
74
- if (context === undefined) {
75
- throw new Error('useMyModule must be used within a MyModuleProvider');
76
- }
77
- return context;
78
- };
79
- exports.useMyModule = useMyModule;
80
- // 6. Your actual module components
81
- var Counter = function () {
82
- var _a = (0, exports.useMyModule)(), state = _a.state, dispatch = _a.dispatch;
83
- return (react_1.default.createElement("div", null,
84
- react_1.default.createElement("button", { onClick: function () { return dispatch({ type: 'DECREMENT' }); } }, "-"),
85
- react_1.default.createElement("span", null, state.count),
86
- react_1.default.createElement("button", { onClick: function () { return dispatch({ type: 'INCREMENT' }); } }, "+")));
87
- };
88
- exports.Counter = Counter;
1
+ // /* eslint-disable */
2
+ // import React, { useReducer, createContext, useContext } from 'react';
3
+ // // 1. Define your state shape and actions
4
+ // type State = {
5
+ // // Your state properties here
6
+ // count: number;
7
+ // isLoading: boolean;
8
+ // };
9
+ // type Action =
10
+ // | { type: 'INCREMENT' }
11
+ // | { type: 'DECREMENT' }
12
+ // | { type: 'SET_LOADING'; payload: boolean };
13
+ // // 2. Create a context for your module
14
+ // const MyModuleContext = createContext<{
15
+ // state: State;
16
+ // dispatch: React.Dispatch<Action>;
17
+ // } | undefined>(undefined);
18
+ // // 3. Reducer function
19
+ // const reducer = (state: State, action: Action): State => {
20
+ // switch (action.type) {
21
+ // case 'INCREMENT':
22
+ // return { ...state, count: state.count + 1 };
23
+ // case 'DECREMENT':
24
+ // return { ...state, count: state.count - 1 };
25
+ // case 'SET_LOADING':
26
+ // return { ...state, isLoading: action.payload };
27
+ // default:
28
+ // return state;
29
+ // }
30
+ // };
31
+ // // 4. Provider component
32
+ // type MyModuleProviderProps = {
33
+ // children: React.ReactNode;
34
+ // initialState?: Partial<State>;
35
+ // };
36
+ // export const MyModuleProvider: React.FC<MyModuleProviderProps> = ({
37
+ // children,
38
+ // initialState,
39
+ // }) => {
40
+ // const [state, dispatch] = useReducer(reducer, {
41
+ // count: 0,
42
+ // isLoading: false,
43
+ // ...initialState,
44
+ // });
45
+ // return (
46
+ // <MyModuleContext.Provider value={{ state, dispatch }}>
47
+ // {children}
48
+ // </MyModuleContext.Provider>
49
+ // );
50
+ // };
51
+ // // 5. Custom hook to access the context
52
+ // export const useMyModule = () => {
53
+ // const context = useContext(MyModuleContext);
54
+ // if (context === undefined) {
55
+ // throw new Error('useMyModule must be used within a MyModuleProvider');
56
+ // }
57
+ // return context;
58
+ // };
59
+ // // 6. Your actual module components
60
+ // export const Counter: React.FC = () => {
61
+ // const { state, dispatch } = useMyModule();
62
+ // return (
63
+ // <div>
64
+ // <button onClick={() => dispatch({ type: 'DECREMENT' })}>-</button>
65
+ // <span>{state.count}</span>
66
+ // <button onClick={() => dispatch({ type: 'INCREMENT' })}>+</button>
67
+ // </div>
68
+ // );
69
+ // };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.24.3",
3
+ "version": "1.24.5",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {