@brushes/context 0.0.1

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.
@@ -0,0 +1 @@
1
+ export * from "./store";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{jsx as o}from"react/jsx-runtime";import{createStore as r,useStore as e}from"zustand";import{createContext as t,useRef as n,useContext as s}from"react";import{persist as i,createJSONStorage as c}from"zustand/middleware";function u(o,r){var e={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&r.indexOf(t)<0&&(e[t]=o[t]);if(null!=o&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(t=Object.getOwnPropertySymbols(o);n<t.length;n++)r.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(o,t[n])&&(e[t[n]]=o[t[n]])}return e}"function"==typeof SuppressedError&&SuppressedError;const a={contractSettlOpno:0,upmMap:{},rebMoney:0,goodsCamount:0,shoppingCountPrice:0,totalDiscountPrice:0,accountsSumPrice:0,discount:0,freight:0,comDisMoney:0,copyComDisMoney:0,shoppingType:"",promotionCode:"",promotionCodes:""},d=t(null);function l(e){var{children:t}=e,s=u(e,["children"]);const i=n();return i.current||(i.current=(o=>{const e={moduleStore:{_ocDiscount:[],_ocPoints:[],_couponList:[],_selectCoupon:[],_shoppingList:[],_contractGoodsList:[],_orderDomainStr:[],_ocContractSettlList:[],_orderAddressInfo:{freight:0,goodsReceiptMem:"",goodsReceiptPhone:"",goodsReceiptArrdess:"",areaCode:""},defaultValue:void 0,_skuInfo:{},params:{},breadList:[],open:!1}};return r()(r=>Object.assign(Object.assign(Object.assign({},e),o),{setModuleStore:o=>r(r=>({moduleStore:Object.assign(r.moduleStore,o)}))}))})(s)),o(d.Provider,{value:i.current,children:t})}function p(o){const r=s(d);if(!r)throw new Error("Missing ModuleContext.Provider in the tree");return e(r,o)}const f=t(null);function m(e){var{children:t}=e,s=u(e,["children"]);const a=n();return a.current||(a.current=(o=>{const e={rootStore:{safe:0,_userInfo:{},_historyList:[],_themeColor:{colorPrimary:"#1677ff",colorBgTextHover:"#e6r4ff"},_orderCount:{},_cart:0,_webStore:{},_menuChildren:[]}};return r()(i(r=>Object.assign(Object.assign(Object.assign({},e),o),{setModuleRootStore:o=>r(r=>({rootStore:Object.assign(r.rootStore,o)}))}),{name:"root-storage",storage:c(()=>localStorage)}))})(s)),o(f.Provider,{value:a.current,children:t})}function g(o){const r=s(f);if(!r)throw new Error("Missing RootModuleContext.Provider in the tree");return e(r,o)}export{l as ModuleProvider,m as ModuleRootProvider,a as initialValueOrder,p as useModuleContext,g as useModuleRootContext};
@@ -0,0 +1,5 @@
1
+ import { ModuleState, moduleStore } from "./commonStore";
2
+ type ModuleProviderProps = React.PropsWithChildren<Partial<moduleStore>>;
3
+ export { initialValueOrder } from "./commonStore";
4
+ export declare function ModuleProvider({ children, ...props }: ModuleProviderProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function useModuleContext<T>(selector: (state: ModuleState) => T): T;
@@ -0,0 +1,56 @@
1
+ export declare const goodListIntialValue: {
2
+ dataPic: string;
3
+ goodsName: string;
4
+ goodsCamount: number;
5
+ skuName: string;
6
+ pricesetNprice: number;
7
+ };
8
+ export declare const initialValueOrder: {
9
+ contractSettlOpno: number;
10
+ upmMap: {};
11
+ rebMoney: number;
12
+ goodsCamount: number;
13
+ shoppingCountPrice: number;
14
+ totalDiscountPrice: number;
15
+ accountsSumPrice: number;
16
+ discount: number;
17
+ freight: number;
18
+ comDisMoney: number;
19
+ copyComDisMoney: number;
20
+ shoppingType: string;
21
+ promotionCode: string;
22
+ promotionCodes: string;
23
+ };
24
+ export type addressInfo = {
25
+ freight: number;
26
+ goodsReceiptMem: string;
27
+ goodsReceiptPhone: string;
28
+ goodsReceiptArrdess: string;
29
+ areaCode: string;
30
+ };
31
+ export type moduleType = {
32
+ [v: string]: any;
33
+ _ocPoints: Array<any>;
34
+ _ocDiscount: Array<any>;
35
+ _orderAddressInfo: addressInfo;
36
+ _couponList: [];
37
+ _selectCoupon: [];
38
+ _shoppingList: Array<any>;
39
+ _contractGoodsList: Array<typeof goodListIntialValue>;
40
+ _orderDomainStr: Array<typeof initialValueOrder>;
41
+ _ocContractSettlList: Array<any>;
42
+ open?: boolean;
43
+ defaultValue?: object;
44
+ goodNum?: number;
45
+ _skuInfo?: object;
46
+ params?: object;
47
+ breadList?: [];
48
+ };
49
+ export interface moduleStore {
50
+ moduleStore: moduleType;
51
+ }
52
+ export interface ModuleState extends moduleStore {
53
+ setModuleStore: (e: Partial<moduleType>) => void;
54
+ }
55
+ export type ModuleStore = ReturnType<typeof createModuleStore>;
56
+ export declare const createModuleStore: (initProps?: Partial<moduleStore>) => import("zustand").StoreApi<ModuleState>;
@@ -0,0 +1,2 @@
1
+ export * from "./commonModule";
2
+ export * from "./rootModule";
@@ -0,0 +1,5 @@
1
+ import { ModuleRootState, moduleRootStore } from "./rootStore";
2
+ type ModuleProviderProps = React.PropsWithChildren<Partial<moduleRootStore>>;
3
+ export declare function ModuleRootProvider({ children, ...props }: ModuleProviderProps): import("react/jsx-runtime").JSX.Element;
4
+ export declare function useModuleRootContext<T>(selector: (state: ModuleRootState) => T): T;
5
+ export {};
@@ -0,0 +1,36 @@
1
+ export type moduleType = {
2
+ [v: string]: any;
3
+ safe?: number;
4
+ _historyList: Array<any>;
5
+ _themeColor: {
6
+ colorPrimary: string;
7
+ colorBgTextHover: string;
8
+ };
9
+ _orderCount: {
10
+ [v: string]: string | number;
11
+ };
12
+ _userInfo: {
13
+ [v: string]: any;
14
+ };
15
+ _cart: number;
16
+ };
17
+ export interface moduleRootStore {
18
+ rootStore: moduleType;
19
+ }
20
+ export interface ModuleRootState extends moduleRootStore {
21
+ setModuleRootStore: (e: Partial<moduleType>) => void;
22
+ }
23
+ export type ModuleRootStore = ReturnType<typeof createRootModuleStore>;
24
+ export declare const createRootModuleStore: (initProps?: Partial<moduleRootStore>) => Omit<import("zustand").StoreApi<ModuleRootState>, "setState" | "persist"> & {
25
+ setState(partial: ModuleRootState | Partial<ModuleRootState> | ((state: ModuleRootState) => ModuleRootState | Partial<ModuleRootState>), replace?: false | undefined): unknown;
26
+ setState(state: ModuleRootState | ((state: ModuleRootState) => ModuleRootState), replace: true): unknown;
27
+ persist: {
28
+ setOptions: (options: Partial<import("zustand/middleware").PersistOptions<ModuleRootState, unknown, unknown>>) => void;
29
+ clearStorage: () => void;
30
+ rehydrate: () => Promise<void> | void;
31
+ hasHydrated: () => boolean;
32
+ onHydrate: (fn: (state: ModuleRootState) => void) => () => void;
33
+ onFinishHydration: (fn: (state: ModuleRootState) => void) => () => void;
34
+ getOptions: () => Partial<import("zustand/middleware").PersistOptions<ModuleRootState, unknown, unknown>>;
35
+ };
36
+ };
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@brushes/context",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "start": "rollup -c --watch",
8
+ "build": "./scripts/build.sh"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/qp-design/web-lowcode.git"
13
+ },
14
+ "dependencies": {
15
+ "zustand": "^5.0.3"
16
+ }
17
+ }
@@ -0,0 +1,15 @@
1
+ import ts from 'rollup-plugin-typescript2';
2
+ import terser from '@rollup/plugin-terser';
3
+
4
+ export default {
5
+ input: 'src/index.ts',
6
+ output: [
7
+ {
8
+ name: '@brushes/context',
9
+ file: 'dist/index.js'
10
+ }
11
+ ],
12
+ cache: false,
13
+ external: ['react/jsx-runtime', 'zustand', 'react', 'zustand/middleware'],
14
+ plugins: [ts({}), terser()]
15
+ };