@brushes/component-core 0.0.33 → 0.1.3

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 (43) hide show
  1. package/package.json +2 -2
  2. package/scripts/build.sh +4 -0
  3. package/src/basic-component/container/index.tsx +228 -0
  4. package/src/basic-component/default/index.tsx +55 -0
  5. package/src/basic-component/empty/index.tsx +24 -0
  6. package/{dist/basic-component/index.d.ts → src/basic-component/index.tsx} +1 -0
  7. package/src/basic-component/resizer/index.tsx +270 -0
  8. package/src/basic-component/resizer/numToMeasurement.ts +26 -0
  9. package/src/components/code.tsx +60 -0
  10. package/src/components/image.tsx +78 -0
  11. package/src/context/index.tsx +10 -0
  12. package/src/setting/basic.tsx +91 -0
  13. package/src/setting/title.tsx +14 -0
  14. package/src/store/commonModule.tsx +37 -0
  15. package/src/store/commonStore.tsx +103 -0
  16. package/src/store/rootModule.tsx +24 -0
  17. package/src/store/rootStore.tsx +56 -0
  18. package/src/store/storeDataConfig.tsx +50 -0
  19. package/src/tool/combine.ts +11 -0
  20. package/src/tool/fullpath.ts +13 -0
  21. package/dist/basic-component/container/index.d.ts +0 -23
  22. package/dist/basic-component/default/index.d.ts +0 -8
  23. package/dist/basic-component/empty/index.d.ts +0 -4
  24. package/dist/basic-component/resizer/index.d.ts +0 -0
  25. package/dist/basic-component/resizer/numToMeasurement.d.ts +0 -7
  26. package/dist/components/code.d.ts +0 -5
  27. package/dist/components/image.d.ts +0 -5
  28. package/dist/context/index.d.ts +0 -6
  29. package/dist/index.js +0 -26
  30. package/dist/setting/basic.d.ts +0 -7
  31. package/dist/setting/title.d.ts +0 -4
  32. package/dist/store/commonModule.d.ts +0 -5
  33. package/dist/store/commonStore.d.ts +0 -56
  34. package/dist/store/rootModule.d.ts +0 -5
  35. package/dist/store/rootStore.d.ts +0 -35
  36. package/dist/store/storeDataConfig.d.ts +0 -0
  37. package/dist/tool/combine.d.ts +0 -1
  38. package/dist/tool/fullpath.d.ts +0 -1
  39. /package/{dist/components/index.d.ts → src/components/index.ts} +0 -0
  40. /package/{dist/index.d.ts → src/index.ts} +0 -0
  41. /package/{dist/setting/index.d.ts → src/setting/index.ts} +0 -0
  42. /package/{dist/store/index.d.ts → src/store/index.tsx} +0 -0
  43. /package/{dist/tool/index.d.ts → src/tool/index.tsx} +0 -0
@@ -0,0 +1,78 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { Form, Spin } from 'antd';
3
+ import { dynamicFormFields } from '@brushes/form';
4
+ import { createStyles } from 'antd-style';
5
+
6
+ const useStyle = createStyles(({ token, css }, { height }: { height: number }) => {
7
+ return {
8
+ wrap: css`
9
+ input[name='verCode'] {
10
+ height: ${height}px;
11
+ }
12
+ `
13
+ };
14
+ });
15
+ export const ImageCodeComponent = ({ api = '/web/ml/mlogin/getVerCode.img', codeKey, height = 40 }: { api?: string; codeKey?:string; height?: number }) => {
16
+ const { styles } = useStyle({ height });
17
+ const form = Form.useFormInstance();
18
+ const isDisabled = form.getFieldValue('isDisabled');
19
+ const [loading, setLoading] = useState(false);
20
+ const [verImg, setVerImg] = useState('');
21
+
22
+ useEffect(() => {
23
+ if (isDisabled === '') {
24
+ fetchCode();
25
+ }
26
+ }, [isDisabled]);
27
+
28
+ const fetchCode = () => {
29
+ setLoading(true);
30
+ const { getFieldsValue } = form;
31
+ const { loginName, userPhone, userinfoConPhone, ...rest } = getFieldsValue();
32
+
33
+ let params = loginName || userPhone || userinfoConPhone;
34
+ if(codeKey) {
35
+ params = rest[codeKey]
36
+ }
37
+
38
+ fetch(`${api}?userPhone=${params}`)
39
+ .then((code) => {
40
+ return code;
41
+ })
42
+ .then((res) => res.arrayBuffer())
43
+ .then((res) => {
44
+ const imgUrl = 'data:image/png;base64,' + window.btoa(String.fromCharCode(...new Uint8Array(res)));
45
+ setVerImg(imgUrl);
46
+ })
47
+ .catch((error: any) => {})
48
+ .finally(() => {
49
+ setLoading(false);
50
+ });
51
+ };
52
+ return (
53
+ <div className={styles.wrap}>
54
+ {dynamicFormFields(
55
+ [
56
+ {
57
+ name: 'verCode',
58
+ type: 'text',
59
+ label: '',
60
+ style: { width: '100%' },
61
+ rules: [{ required: true, message: '请输入' }],
62
+ extraProps: {
63
+ autoComplete: 'off',
64
+ placeholder: '请输入',
65
+ addonAfter: (
66
+ <Spin spinning={loading}>{verImg ? <img src={verImg} onClick={fetchCode} style={{ width: 90, height: height - 2 }} /> : <div style={{ width: 90, height: height - 2 }}></div>}</Spin>
67
+ ),
68
+ style: {
69
+ height
70
+ }
71
+ }
72
+ }
73
+ ],
74
+ form
75
+ )}
76
+ </div>
77
+ );
78
+ };
@@ -0,0 +1,10 @@
1
+ import { createContext, ReactNode, useContext } from 'react';
2
+ const Context = createContext({});
3
+
4
+ export function ApplicationContext({ value, children }: { value?: Object; children: ReactNode }) {
5
+ return <Context.Provider value={{ ...value }}>{children}</Context.Provider>;
6
+ }
7
+
8
+ export function useApplicationContext() {
9
+ return useContext(Context);
10
+ }
@@ -0,0 +1,91 @@
1
+ import { Collapse, Form } from 'antd';
2
+ import { Fragment } from 'react';
3
+ import { dynamicFormFields, useImmutableCallback } from '@brushes/form';
4
+ import { useNode } from '@craftjs/core';
5
+ import type { FieldType } from '@brushes/form';
6
+ import { isUndefined, debounce } from 'lodash';
7
+ import { defaultStyle } from '@brushes/core-transform';
8
+ import Title from './title';
9
+
10
+ export type formConfigType = {
11
+ title?: string;
12
+ formFields: FieldType[];
13
+ };
14
+
15
+ export type LayoutType = 'horizontal' | 'vertical' | 'inline';
16
+
17
+ export const basicSettings = (formFields: formConfigType[], layout?: LayoutType) => {
18
+ return () => {
19
+ const [form] = Form.useForm();
20
+ const {
21
+ configProps,
22
+ actions: { setProp }
23
+ } = useNode((node) => ({
24
+ configProps: node.data.props
25
+ }));
26
+ const isNeedOmit = (values: any) => {
27
+ if (Array.isArray(values)) {
28
+ return values.filter((v) => !isUndefined(v));
29
+ }
30
+ return values;
31
+ };
32
+
33
+ const isBreakChangeValue = (params: any) => {
34
+ let obj = {};
35
+ Reflect.ownKeys(params).forEach((key) => {
36
+ Reflect.set(obj, key, isNeedOmit(Reflect.get(params, key)));
37
+ });
38
+ return obj;
39
+ };
40
+
41
+ const callbackImpl = debounce(
42
+ useImmutableCallback((_: any, prevAllValues: any) => {
43
+ const allValues = isBreakChangeValue(prevAllValues);
44
+
45
+ setProp((props: object) => {
46
+ Object.entries(allValues).forEach(([key, value], index) => {
47
+ // if(key === '$_actions') {
48
+ // // const fun = new Function('', `return ${value}`);
49
+ // // @ts-ignore
50
+ // props['onClick'] = fun('daa')
51
+ // } else {
52
+ // @ts-ignore
53
+ props[key] = value;
54
+ // }
55
+ });
56
+ }, 500);
57
+
58
+ // setProp((props: object) => {}, 500);
59
+ }),
60
+ 500
61
+ );
62
+
63
+ return (
64
+ <Form layout={layout} form={form} onValuesChange={callbackImpl} initialValues={configProps}>
65
+ <Collapse
66
+ bordered
67
+ size={'small'}
68
+ ghost
69
+ expandIconPosition={'end'}
70
+ items={formFields
71
+ .concat(
72
+ {
73
+ title: '样式',
74
+ formFields: defaultStyle
75
+ }
76
+ // {
77
+ // title: 'store',
78
+ // formFields: storeConfig
79
+ // }
80
+ )
81
+ .map((item: any, indx: number) => ({
82
+ key: indx,
83
+ label: <Title title={item.title} />,
84
+ children: <Fragment key={indx}>{dynamicFormFields(item.formFields, form)}</Fragment>
85
+ }))}
86
+ defaultActiveKey={['0', '1', '2', '3']}
87
+ />
88
+ </Form>
89
+ );
90
+ };
91
+ };
@@ -0,0 +1,14 @@
1
+ import { Divider } from 'antd';
2
+
3
+ const Title = ({ title }: { title: string }) => {
4
+ return (
5
+ <>
6
+ <Divider style={{ fontSize: 13, margin: '2px 0' }} orientation="left">
7
+ {title}
8
+ </Divider>
9
+ {/*<Divider style={{fontSize:14}} orientation="left">{title}</Divider>*/}
10
+ </>
11
+ );
12
+ };
13
+
14
+ export default Title;
@@ -0,0 +1,37 @@
1
+ import { ModuleStore, createModuleStore, ModuleState, moduleStore } from './commonStore';
2
+ import { useRef, useContext, createContext } from 'react';
3
+ import { useStore } from 'zustand';
4
+ const ModuleContext = createContext<ModuleStore | null>(null);
5
+
6
+ type ModuleProviderProps = React.PropsWithChildren<Partial<moduleStore>>;
7
+
8
+ export { initialValueOrder } from './commonStore';
9
+
10
+ // Provider wrapper
11
+ export function ModuleProvider({ children, ...props }: ModuleProviderProps) {
12
+ const storeRef = useRef<ModuleStore>();
13
+
14
+ if (!storeRef.current) {
15
+ storeRef.current = createModuleStore(props);
16
+ }
17
+ return <ModuleContext.Provider value={storeRef.current}>{children}</ModuleContext.Provider>;
18
+ }
19
+
20
+ export function useModuleContext<T>(selector: (state: ModuleState) => T): T {
21
+ const store = useContext(ModuleContext);
22
+ if (!store) throw new Error('Missing ModuleContext.Provider in the tree');
23
+ return useStore(store, selector);
24
+ }
25
+
26
+ // example
27
+ // Consumer usage of the custom hook
28
+ // function CommonConsumer() {
29
+ // const module_id = useModuleContext((s) => s.module_id)
30
+ // const setModuleId = useModuleContext((s) => s.setModuleId)
31
+ // return (
32
+ // <>
33
+ // <div>{module_id} Bears.</div>
34
+ // <button onClick={setModuleId}>Add bear</button>
35
+ // </>
36
+ // )
37
+ // }
@@ -0,0 +1,103 @@
1
+ import { createStore } from 'zustand';
2
+
3
+ export const goodListIntialValue = {
4
+ dataPic: '',
5
+ goodsName: '',
6
+ goodsCamount: 0,
7
+ skuName: '',
8
+ pricesetNprice: 0
9
+ };
10
+
11
+ export const initialValueOrder = {
12
+ contractSettlOpno: 0,
13
+ upmMap: {},
14
+ rebMoney: 0,
15
+ goodsCamount: 0,
16
+ shoppingCountPrice: 0,
17
+ totalDiscountPrice: 0,
18
+ accountsSumPrice: 0,
19
+ discount: 0,
20
+ freight: 0,
21
+ comDisMoney: 0,
22
+ copyComDisMoney: 0,
23
+ shoppingType: '',
24
+ promotionCode: '',
25
+ promotionCodes: ''
26
+ };
27
+
28
+ export type addressInfo = {
29
+ freight: number;
30
+ goodsReceiptMem: string;
31
+ goodsReceiptPhone: string;
32
+ goodsReceiptArrdess: string;
33
+ areaCode: string;
34
+ };
35
+
36
+ export type moduleType = {
37
+ [v: string]: any;
38
+ _ocPoints: Array<any>;
39
+ _ocDiscount: Array<any>;
40
+ _orderAddressInfo: addressInfo;
41
+ _couponList: []; // 订单优惠券列表
42
+ _selectCoupon: []; // 选中的优惠券
43
+ _shoppingList: Array<any>; // 订单商品信息
44
+ _contractGoodsList: Array<typeof goodListIntialValue>; // 确认订单支付模块
45
+ _orderDomainStr: Array<typeof initialValueOrder>; // 确认订单支付模块
46
+ _ocContractSettlList: Array<any>; // 确认订单支付模块
47
+ open?: boolean; //抽屉展示或掩藏
48
+ defaultValue?: object; // 页面模块默认值
49
+ goodNum?: number; // 选择商品数量
50
+ _skuInfo?: { [v:string]:any }; // sku商品数据
51
+ params?: object; //每个模块的请求参数
52
+ breadList?: []; //面包屑
53
+ };
54
+
55
+ export interface moduleStore {
56
+ // module_id?: number;
57
+ // current?: number;
58
+ // hotelParams?: object;
59
+ // extraParams?: object; //每个模块的扩展参数
60
+ // title?: string;
61
+ moduleStore: Partial<moduleType>;
62
+ }
63
+
64
+ export interface ModuleState extends moduleStore {
65
+ setModuleStore: (e: Partial<moduleType>) => void;
66
+ }
67
+
68
+ export type ModuleStore = ReturnType<typeof createModuleStore>;
69
+
70
+ export const createModuleStore = (initProps?: Partial<moduleStore>) => {
71
+ const DEFAULT_PROPS: moduleStore = {
72
+ moduleStore: {
73
+ _ocDiscount: [],
74
+ _ocPoints: [],
75
+ _couponList: [],
76
+ _selectCoupon: [], // 选中的优惠券
77
+ _shoppingList: [], // 订单商品信息
78
+ _contractGoodsList: [],
79
+ _orderDomainStr: [],
80
+ _ocContractSettlList: [],
81
+ _orderAddressInfo: {
82
+ freight: 0,
83
+ goodsReceiptMem: '',
84
+ goodsReceiptPhone: '',
85
+ goodsReceiptArrdess: '',
86
+ areaCode: ''
87
+ },
88
+ defaultValue: void 0,
89
+ _skuInfo: {},
90
+ params: {},
91
+ breadList: [],
92
+ open: false
93
+ }
94
+ };
95
+ return createStore<ModuleState>()((set) => ({
96
+ ...DEFAULT_PROPS,
97
+ ...initProps,
98
+ setModuleStore: (store) =>
99
+ set((state) => {
100
+ return { moduleStore: Object.assign(state.moduleStore, store) };
101
+ })
102
+ }));
103
+ };
@@ -0,0 +1,24 @@
1
+ import { ModuleRootStore, createRootModuleStore, ModuleRootState, moduleRootStore } from './rootStore';
2
+ import { useRef, useContext, createContext } from 'react';
3
+ import { useStore } from 'zustand';
4
+
5
+ const ModuleContext = createContext<ModuleRootStore | null>(null);
6
+
7
+ type ModuleProviderProps = React.PropsWithChildren<Partial<moduleRootStore>>;
8
+
9
+ // Provider wrapper
10
+ export function ModuleRootProvider({ children, ...props }: ModuleProviderProps) {
11
+ const storeRef = useRef<ModuleRootStore>();
12
+
13
+ if (!storeRef.current) {
14
+ storeRef.current = createRootModuleStore(props);
15
+ }
16
+
17
+ return <ModuleContext.Provider value={storeRef.current}>{children}</ModuleContext.Provider>;
18
+ }
19
+
20
+ export function useModuleRootContext<T>(selector: (state: ModuleRootState) => T): T {
21
+ const store = useContext(ModuleContext);
22
+ if (!store) throw new Error('Missing ModuleContext.Provider in the tree');
23
+ return useStore(store, selector);
24
+ }
@@ -0,0 +1,56 @@
1
+ import { createStore } from 'zustand';
2
+ import { persist, createJSONStorage } from 'zustand/middleware';
3
+
4
+ export type moduleType = {
5
+ [v: string]: any;
6
+ _historyList: Array<any>;
7
+ _themeColor: { colorPrimary: string; colorBgTextHover: string };
8
+ _orderCount: { [v: string]: string | number }; // 订单角标
9
+ _userInfo: { [v: string]: any }; // 用户信息
10
+ _cart: number; // 购物车数据
11
+ };
12
+
13
+ export interface moduleRootStore {
14
+ // module_id?: number;
15
+ // current?: number;
16
+ // hotelParams?: object;
17
+ // extraParams?: object; //每个模块的扩展参数
18
+ // title?: string;
19
+ rootStore: moduleType;
20
+ }
21
+
22
+ export interface ModuleRootState extends moduleRootStore {
23
+ setModuleRootStore: (e: Partial<moduleType>) => void;
24
+ }
25
+
26
+ export type ModuleRootStore = ReturnType<typeof createRootModuleStore>;
27
+
28
+ export const createRootModuleStore = (initProps?: Partial<moduleRootStore>) => {
29
+ const DEFAULT_PROPS: moduleRootStore = {
30
+ rootStore: {
31
+ _userInfo: {},
32
+ _historyList: [],
33
+ _themeColor: { colorPrimary: '#1677ff', colorBgTextHover: '#e6r4ff' },
34
+ _orderCount: {},
35
+ _cart: 0,
36
+ _webStore: {},
37
+ _menuChildren: []
38
+ }
39
+ };
40
+ return createStore<ModuleRootState>()(
41
+ persist(
42
+ (set) => ({
43
+ ...DEFAULT_PROPS,
44
+ ...initProps,
45
+ setModuleRootStore: (store) =>
46
+ set((state) => {
47
+ return { rootStore: Object.assign(state.rootStore, store) };
48
+ })
49
+ }),
50
+ {
51
+ name: 'root-storage', // 存储的 key 名
52
+ storage: createJSONStorage(() => localStorage) // (optional) by default, 'localStorage' is used
53
+ }
54
+ )
55
+ );
56
+ };
@@ -0,0 +1,50 @@
1
+ // import type { FieldType } from '@brushes/form';
2
+ // import { useModuleContext } from './commonModule';
3
+ // import markdownit from 'markdown-it';
4
+ //
5
+ // const md = markdownit({
6
+ // tables: true,
7
+ // html: true, // 在源码中启用 HTML 标签
8
+ // xhtmlOut: false, // 使用 '/' 来闭合单标签 (比如 <br />)。
9
+ // // 这个选项只对完全的 CommonMark 模式兼容。
10
+ // breaks: true, // 转换段落里的 '\n' 到 <br>。
11
+ // langPrefix: 'language-', // 给围栏代码块的 CSS 语言前缀。对于额外的高亮代码非常有用。
12
+ // linkify: true, // 将类似 URL 的文本自动转换为链接。
13
+ //
14
+ // // 启用一些语言中立的替换 + 引号美化
15
+ // typographer: false,
16
+ //
17
+ // // 双 + 单引号替换对,当 typographer 启用时。
18
+ // // 或者智能引号等,可以是 String 或 Array。
19
+ // //
20
+ // // 比方说,你可以支持 '«»„“' 给俄罗斯人使用, '„“‚‘' 给德国人使用。
21
+ // // 还有 ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] 给法国人使用(包括 nbsp)。
22
+ // quotes: '“”‘’',
23
+ //
24
+ // // 高亮函数,会返回转义的HTML。
25
+ // // 或 '' 如果源字符串未更改,则应在外部进行转义。
26
+ // // 如果结果以 <pre ... 开头,内部包装器则会跳过。
27
+ // highlight: function (/*str, lang*/) {
28
+ // return '';
29
+ // }
30
+ // });
31
+ //
32
+ // const StoreJsx = () => {
33
+ // const moduleStore = useModuleContext((s) => s.moduleStore);
34
+ // return (
35
+ // <>
36
+ // <p>当前模块数据</p>
37
+ // <div className={'markdown-body 123'} dangerouslySetInnerHTML={{ __html: md.render(JSON.stringify(moduleStore)) }}></div>
38
+ // </>
39
+ // );
40
+ // };
41
+ // export const storeConfig: FieldType[] = [
42
+ // {
43
+ // label: '',
44
+ // name: '___store',
45
+ // type: 'slot',
46
+ // extraProps: {
47
+ // render: StoreJsx
48
+ // }
49
+ // }
50
+ // ];
@@ -0,0 +1,11 @@
1
+ export function combine(array: Array<any>) {
2
+ array.forEach((item) => {
3
+ try {
4
+ const { Component, setting } = item;
5
+ Component.craft = setting;
6
+ Component.craft.displayName = item.name;
7
+ } catch (e) {
8
+ console.error(e, item);
9
+ }
10
+ });
11
+ }
@@ -0,0 +1,13 @@
1
+ const baseUrl = process.env.REACT_APP_BASE_URL;
2
+ const path = process.env.REACT_IMG_PATH || '';
3
+ export const fullpath = (str: string = '') => {
4
+ let computedPath = str;
5
+ if (!str) return '';
6
+ if (str.startsWith('http')) {
7
+ return str;
8
+ }
9
+ if (!(str.startsWith(path) || str.startsWith(path.slice(1)))) {
10
+ computedPath = path + str;
11
+ }
12
+ return baseUrl + computedPath;
13
+ };
@@ -1,23 +0,0 @@
1
- import { ReactNode } from 'react';
2
- export declare const Inner: ({ children, enabled, root, text }: {
3
- text?: string;
4
- root?: boolean;
5
- enabled: boolean;
6
- children: ReactNode;
7
- }) => import("react/jsx-runtime").JSX.Element;
8
- export declare const IsShowContainer: ({ moduleShowValue, rootKey, isRevert, children, routerIsShowValue, routerIsShow, moduleIsShow, padding, storeKey, margin }: {
9
- isRevert?: boolean;
10
- routerIsShowValue?: string;
11
- rootKey?: string;
12
- moduleShowValue?: string;
13
- moduleIsShow?: string;
14
- routerIsShow?: string;
15
- storeKey: string;
16
- padding: object;
17
- margin: object;
18
- children?: ReactNode;
19
- }) => import("react/jsx-runtime").JSX.Element | undefined;
20
- export declare const Container: ({ width, text, children, background, margin, positionValue, padding, backgroundImage, position, $$_actions, $_actions, borderColor, ...props }: any) => import("react/jsx-runtime").JSX.Element;
21
- export declare const OutContainerComponent: ({ width, api, params, children, background, padding, backgroundImage, ...props }: any) => import("react/jsx-runtime").JSX.Element;
22
- export declare const OutContainer: (props: any) => import("react/jsx-runtime").JSX.Element;
23
- export declare const ContainerWrap: ({ width, background, children, backgroundImage, height, $$_style, $_style, ...props }: any) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +0,0 @@
1
- export declare const DefaultJsx: ({ text, root }: {
2
- text?: string;
3
- root?: boolean;
4
- }) => import("react/jsx-runtime").JSX.Element;
5
- export declare const DefaultEditorBg: ({ content, color }: {
6
- content?: string;
7
- color?: string;
8
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +0,0 @@
1
- export declare const SlotEmpty: React.FC<{
2
- children?: React.ReactNode;
3
- borderColor?: string;
4
- }>;
File without changes
@@ -1,7 +0,0 @@
1
- export declare const isPercentage: (val: string) => boolean;
2
- export declare const percentToPx: (value: any, comparativeValue: number) => any;
3
- export declare const pxToPercent: (value: any, comparativeValue: number) => number;
4
- export declare const getElementDimensions: (element: HTMLElement) => {
5
- width: number;
6
- height: number;
7
- };
@@ -1,5 +0,0 @@
1
- export declare const CodeComponent: ({ api, codeKey, height }: {
2
- codeKey?: string;
3
- api?: string;
4
- height?: number;
5
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +0,0 @@
1
- export declare const ImageCodeComponent: ({ api, codeKey, height }: {
2
- api?: string;
3
- codeKey?: string;
4
- height?: number;
5
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +0,0 @@
1
- import { ReactNode } from 'react';
2
- export declare function ApplicationContext({ value, children }: {
3
- value?: Object;
4
- children: ReactNode;
5
- }): import("react/jsx-runtime").JSX.Element;
6
- export declare function useApplicationContext(): {};
package/dist/index.js DELETED
@@ -1,26 +0,0 @@
1
- import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{useState as o,useMemo as n,useEffect as i,createContext as s,useRef as c,useContext as a}from"react";import{Form as d,Button as l,Spin as u,Watermark as h,Typography as g}from"antd";import{useMountedRef as p,dynamicFormFields as b}from"@brushes/form";import{get as m}from"@brushes/request";import{createStyles as f}from"antd-style";export*from"antd-style";import{QjIcon as y}from"@brushes/share-resource";import{useEditor as x,useNode as v}from"@craftjs/core";export*from"@craftjs/core";import{createStore as w,useStore as O}from"zustand";import{persist as j,createJSONStorage as C}from"zustand/middleware";import{useSearchParams as S}from"react-router-dom";import{get as _,isUndefined as P,isEmpty as $}from"lodash";function k(e){e.forEach(e=>{try{const{Component:t,setting:r}=e;t.craft=r,t.craft.displayName=e.name}catch(t){console.error(t,e)}})}const I=process.env.REACT_APP_BASE_URL,M=process.env.REACT_IMG_PATH||"",A=(e="")=>{let t=e;return e?e.startsWith("http")?e:(e.startsWith(M)||e.startsWith(M.slice(1))||(t=M+e),I+t):""};function T(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r}"function"==typeof SuppressedError&&SuppressedError;const V=({api:t="/web/ml/muser/sendPhone.json",codeKey:r,height:s=36})=>{const c=d.useFormInstance(),a=c.getFieldValue("verCode"),[u,h]=o(0),[g,b]=o(!1),f=p(),y=n(()=>u>0||!a,[u,a]);i(()=>{const e=setTimeout(function(){0!==u?f.current&&h(e=>e-1):clearTimeout(e)},1e3);return()=>clearTimeout(e)},[u,f]);return e(l,{loading:g,size:"small",type:"link",disabled:y,style:{cursor:"pointer",height:s,width:90},onClick:()=>{b(!0);const{getFieldsValue:e}=c,o=e(),{loginName:n,userPhone:i,userinfoConPhone:s,verCode:a}=o,d=T(o,["loginName","userPhone","userinfoConPhone","verCode"]);let l={userPhone:n||i||s,code:a};r&&(l={userPhone:d[r],code:a}),m(t,l).then(()=>{h(60)}).catch(e=>{}).finally(()=>{b(!1)})},children:0===u?"获取验证码":`倒计时${u}秒`})},E=f(({token:e,css:t},{height:r})=>({wrap:t`
2
- input[name='verCode'] {
3
- height: ${r}px;
4
- }
5
- `})),N=({api:t="/web/ml/mlogin/getVerCode.img",codeKey:r,height:n=40})=>{const{styles:s}=E({height:n}),c=d.useFormInstance(),a=c.getFieldValue("isDisabled"),[l,h]=o(!1),[g,p]=o("");i(()=>{""===a&&m()},[a]);const m=()=>{h(!0);const{getFieldsValue:e}=c,o=e(),{loginName:n,userPhone:i,userinfoConPhone:s}=o,a=T(o,["loginName","userPhone","userinfoConPhone"]);let d=n||i||s;r&&(d=a[r]),fetch(`${t}?userPhone=${d}`).then(e=>e).then(e=>e.arrayBuffer()).then(e=>{const t="data:image/png;base64,"+window.btoa(String.fromCharCode(...new Uint8Array(e)));p(t)}).catch(e=>{}).finally(()=>{h(!1)})};return e("div",{className:s.wrap,children:b([{name:"verCode",type:"text",label:"",style:{width:"100%"},rules:[{required:!0,message:"请输入"}],extraProps:{autoComplete:"off",placeholder:"请输入",addonAfter:e(u,{spinning:l,children:g?e("img",{src:g,onClick:m,style:{width:90,height:n-2}}):e("div",{style:{width:90,height:n-2}})}),style:{height:n}}}],c)})},R=f(({token:e,css:t})=>({defaultWrap:t`
6
- border: dashed 1px rgba(0, 0, 0, 0.15);
7
- width: 100%;
8
- text-align: center;
9
- border-radius: ${e.borderRadius}px;
10
- height: 100%;
11
- justify-content: center;
12
- align-items: center;
13
- display: flex;
14
- flex-direction: column;
15
- color: ${e.colorTextLabel};
16
- p {
17
- margin-top: 10px;
18
- font-size: 12px;
19
- }
20
- }`})),z=({text:r="内容放置区域",root:o})=>{const{styles:n}=R();return t("div",{className:n.defaultWrap,style:{minHeight:o?"calc(100vh - 110px)":"auto"},children:[e(y,{style:{fontSize:50,fontWeight:500,display:"block",color:"#bbb"},name:"icon-computer"}),e("p",{children:r})]})},L=({content:t="/",color:r="blue"})=>e(h,{gap:[1,1],font:{color:r},rotate:0,height:10,width:10,content:t,children:e("div",{style:{height:10}})}),W={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=s(null);function F(t){var{children:r}=t,o=T(t,["children"]);const n=c();return n.current||(n.current=(e=>{const t={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 w()(r=>Object.assign(Object.assign(Object.assign({},t),e),{setModuleStore:e=>r(t=>({moduleStore:Object.assign(t.moduleStore,e)}))}))})(o)),e(D.Provider,{value:n.current,children:r})}function B(e){const t=a(D);if(!t)throw new Error("Missing ModuleContext.Provider in the tree");return O(t,e)}const H=s(null);function K(t){var{children:r}=t,o=T(t,["children"]);const n=c();return n.current||(n.current=(e=>{const t={rootStore:{_userInfo:{},_historyList:[],_themeColor:{colorPrimary:"#1677ff",colorBgTextHover:"#e6r4ff"},_orderCount:{},_cart:0,_webStore:{},_menuChildren:[]}};return w()(j(r=>Object.assign(Object.assign(Object.assign({},t),e),{setModuleRootStore:e=>r(t=>({rootStore:Object.assign(t.rootStore,e)}))}),{name:"root-storage",storage:C(()=>localStorage)}))})(o)),e(H.Provider,{value:n.current,children:r})}function q(e){const t=a(H);if(!t)throw new Error("Missing ModuleContext.Provider in the tree");return O(t,e)}const G=f(({token:e,css:t})=>({category:t`
21
- &:hover {
22
- box-shadow: 0 1px 5px 1px rgba(0, 0, 0, 0.1);
23
- }
24
- `,width_100:t`
25
- width: 100%;
26
- `})),U=({children:t,enabled:o,root:n,text:i})=>e(r,{children:t||(o?e(z,{text:i,root:n}):"")}),J=({moduleShowValue:t,rootKey:r="",isRevert:o=!1,children:i,routerIsShowValue:s,routerIsShow:c,moduleIsShow:a="",padding:d,storeKey:l="",margin:u})=>{const h=B(e=>e.moduleStore[l]),g=q(e=>e.rootStore[r]),{enabled:p}=x(e=>({enabled:e.options.enabled})),{connectors:{connect:b,drag:m}}=v();let[f]=S();const y=n(()=>{if(l&&h)return"number"==typeof h[a]?_(h,a)+"":_(h,a)},[h,l,a]),w=n(()=>{if(r&&g)return"number"==typeof g[a]?_(g,a)+"":_(g,a)},[g,r,a]);if(n(()=>{const e=c&&f.has(c)&&!s||c&&f.has(c)&&s&&s.split(",").includes(f.get(c)||"")||l&&!t&&!a&&!P(h)&&!$(h)||a&&l&&!t&&!P(y)&&!$(y)||t&&l&&a&&t.split(",").includes(y+"")||r&&!t&&!a&&!P(g)&&!$(g)||a&&r&&!t&&!P(w)&&!$(w)||t&&r&&a&&t.split(",").includes(w+"");return o?!e:e},[c,s,o,h,l,t,a,y,r,g,w])||p)return e("div",{style:Object.assign(Object.assign({},u),d),ref:e=>b(m(e)),children:e(U,{enabled:p,children:i})})},Q=t=>{var{width:r,text:o,children:i,background:s,margin:c={},positionValue:a={},padding:d={},backgroundImage:l,position:u,$$_actions:h,$_actions:g,borderColor:p}=t,b=T(t,["width","text","children","background","margin","positionValue","padding","backgroundImage","position","$$_actions","$_actions","borderColor"]);const{styles:m}=G(),{enabled:f}=x(e=>({enabled:e.options.enabled})),y=n(()=>"fixed"===u&&0===a.right&&f?Object.assign(Object.assign({},a),{right:412}):"fixed"===u&&0===a.left&&f?Object.assign(Object.assign({},a),{left:172}):a,[a,u]),{connectors:{connect:w,drag:O}}=v();return e("div",{className:f?m.category:"",ref:e=>w(O(e)),style:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},c),{display:"flex",boxSizing:"border-box",position:u,border:`solid 1px ${p}`}),d),b),y),{background:l?`url(${A(l)}) repeat-x center 0`:s,width:(r+"").includes("%")?r:`${r}px`}),children:e(U,{text:o,enabled:f,children:i})})},X=t=>{var{width:r,api:o,params:n,children:i,background:s,padding:c={},backgroundImage:a}=t,d=T(t,["width","api","params","children","background","padding","backgroundImage"]);const{enabled:l}=x(e=>({enabled:e.options.enabled})),{connectors:{connect:u,drag:h}}=v(),{styles:g}=G();return e("div",{ref:e=>u(h(e)),className:l?g.category:"",style:Object.assign(Object.assign(Object.assign({margin:"0 auto",display:"flex",boxSizing:"border-box"},c),d),{background:a?`url(${A(a)}) repeat-x center 0`:s,width:(r+"").includes("%")?r:`${r}px`}),children:e(U,{enabled:l,children:i})})},Y=t=>e(F,{children:e(X,Object.assign({},t))}),Z=t=>{var{width:r,background:o,children:n,backgroundImage:i,height:s,$$_style:c="",$_style:a=""}=t,d=T(t,["width","background","children","backgroundImage","height","$$_style","$_style"]);const{connectors:{connect:l,drag:u}}=v(),{enabled:h}=x(e=>({enabled:e.options.enabled}));return e("div",Object.assign({},d,{ref:e=>l(u(e)),style:{width:r,paddingBottom:5,background:i?`url(${A(i)}) repeat-x center 0`:o,minHeight:`calc(${s}vh - 110px)`},children:e(U,{root:!0,enabled:h,children:n})}))},ee=({children:t="当前为插槽容器,可以自定义组件代码。",borderColor:r="rgba(0, 0, 0, 0.1)"})=>e("div",{style:{height:"100%",width:"100%",borderColor:r,borderWidth:1,borderStyle:"dashed",fontSize:12,textAlign:"center",fontWeight:"normal",background:"rgba(255,255,255, 0.2)"},children:e(g.Text,{type:"secondary",children:t})}),te=s({});function re({value:t,children:r}){return e(te.Provider,{value:Object.assign({},t),children:r})}function oe(){return a(te)}export{re as ApplicationContext,V as CodeComponent,Q as Container,Z as ContainerWrap,L as DefaultEditorBg,z as DefaultJsx,N as ImageCodeComponent,U as Inner,J as IsShowContainer,F as ModuleProvider,K as ModuleRootProvider,Y as OutContainer,X as OutContainerComponent,ee as SlotEmpty,k as combine,A as fullpath,W as initialValueOrder,oe as useApplicationContext,B as useModuleContext,q as useModuleRootContext};
@@ -1,7 +0,0 @@
1
- import type { FieldType } from '@brushes/form';
2
- export type formConfigType = {
3
- title?: string;
4
- formFields: FieldType[];
5
- };
6
- export type LayoutType = 'horizontal' | 'vertical' | 'inline';
7
- export declare const basicSettings: (formFields: formConfigType[], layout?: LayoutType) => () => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +0,0 @@
1
- declare const Title: ({ title }: {
2
- title: string;
3
- }) => import("react/jsx-runtime").JSX.Element;
4
- export default Title;
@@ -1,5 +0,0 @@
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;