gomtm 0.0.377 → 0.0.378
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.
|
@@ -4,7 +4,7 @@ import { BlockProvider } from "./block-store";
|
|
|
4
4
|
import { MtBlockRender } from "./blockRegister";
|
|
5
5
|
function MtBlock(props) {
|
|
6
6
|
const { id, type, blockProps } = props;
|
|
7
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(BlockProvider, { id, type, children: /* @__PURE__ */ jsx(MtBlockRender, {}) }) }) });
|
|
7
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "loading block" }), children: /* @__PURE__ */ jsx(BlockProvider, { id, type, children: /* @__PURE__ */ jsx(MtBlockRender, {}) }) }) });
|
|
8
8
|
}
|
|
9
9
|
export {
|
|
10
10
|
MtBlock
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
interface BlockStateProps {
|
|
2
|
+
export interface BlockStateProps {
|
|
3
3
|
id: string;
|
|
4
4
|
type: string;
|
|
5
5
|
props?: any;
|
|
@@ -11,4 +11,4 @@ export interface BlockState extends BlockStateProps {
|
|
|
11
11
|
export declare const blockContext: import("react").Context<import("zustand").StoreApi<BlockState> | null>;
|
|
12
12
|
export declare const BlockProvider: (props: PropsWithChildren<BlockStateProps>) => import("react").JSX.Element;
|
|
13
13
|
export declare function useBlock<T>(selector: (state: BlockState) => T): T;
|
|
14
|
-
export
|
|
14
|
+
export declare const BlockDebug: () => import("react").JSX.Element;
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2
5
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
7
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
5
21
|
var __objRest = (source, exclude) => {
|
|
6
22
|
var target = {};
|
|
7
23
|
for (var prop in source)
|
|
@@ -14,35 +30,16 @@ var __objRest = (source, exclude) => {
|
|
|
14
30
|
}
|
|
15
31
|
return target;
|
|
16
32
|
};
|
|
17
|
-
import { jsx } from "react/jsx-runtime";
|
|
33
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
34
|
import { createContext, useContext, useRef } from "react";
|
|
19
35
|
import { useStore } from "zustand";
|
|
20
36
|
import { createStore } from "zustand/vanilla";
|
|
21
37
|
const createBlockStore = (initProps) => {
|
|
22
|
-
return createStore()((set, get) => ({
|
|
38
|
+
return createStore()((set, get) => __spreadProps(__spreadValues({
|
|
23
39
|
id: "",
|
|
24
|
-
type: ""
|
|
25
|
-
|
|
26
|
-
// backendUrl: "",
|
|
27
|
-
// viewUpdate: "",
|
|
28
|
-
// viewCreate: "",
|
|
29
|
-
// ...initProps,
|
|
30
|
-
// openRemove: false,
|
|
31
|
-
// setOpenRemove: (openRemove) => set({ openRemove }),
|
|
32
|
-
// openCreate: false,
|
|
33
|
-
// setOpenCreate: (openCreate) => set({ openCreate }),
|
|
34
|
-
// openEdit: false,
|
|
40
|
+
type: ""
|
|
41
|
+
}, initProps), {
|
|
35
42
|
setOpenEdit: (openEdit) => set({ openEdit })
|
|
36
|
-
// setActivateItem: (activateItem) => set({ activateItem }),
|
|
37
|
-
// setLayout: (layout) => {
|
|
38
|
-
// //todo
|
|
39
|
-
// setCookie(CONST_cookieListViewLayout, layout)
|
|
40
|
-
// return set((state) => ({ layout: layout }))
|
|
41
|
-
// },
|
|
42
|
-
// nextPage: () => {
|
|
43
|
-
// },
|
|
44
|
-
// setDetailData: (detailData) => set({ detailData }),
|
|
45
|
-
// setOpenCurdViewEditor: (openCurdViewEditor) => set({ openCurdViewEditor })
|
|
46
43
|
}));
|
|
47
44
|
};
|
|
48
45
|
const blockContext = createContext(null);
|
|
@@ -60,7 +57,22 @@ function useBlock(selector) {
|
|
|
60
57
|
throw new Error("useBlock Missing BlockProvider in the tree");
|
|
61
58
|
return useStore(store, selector);
|
|
62
59
|
}
|
|
60
|
+
const BlockDebug = () => {
|
|
61
|
+
const id = useBlock((x) => x.id);
|
|
62
|
+
const type = useBlock((x) => x.type);
|
|
63
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-red-300 p-4", children: [
|
|
64
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
65
|
+
"id: ",
|
|
66
|
+
JSON.stringify(id)
|
|
67
|
+
] }),
|
|
68
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
69
|
+
"type: ",
|
|
70
|
+
JSON.stringify(type)
|
|
71
|
+
] })
|
|
72
|
+
] });
|
|
73
|
+
};
|
|
63
74
|
export {
|
|
75
|
+
BlockDebug,
|
|
64
76
|
BlockProvider,
|
|
65
77
|
blockContext,
|
|
66
78
|
useBlock
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ComponentType } from "react";
|
|
2
2
|
export declare const registerBlock: (type: string, comp: ComponentType<any>) => void;
|
|
3
|
-
export declare function MtBlockRender(
|
|
3
|
+
export declare function MtBlockRender(): import("react").JSX.Element;
|
|
@@ -15,7 +15,7 @@ var __spreadValues = (a, b) => {
|
|
|
15
15
|
}
|
|
16
16
|
return a;
|
|
17
17
|
};
|
|
18
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
19
|
import { lazy } from "react";
|
|
20
20
|
import { useBlock } from "./block-store";
|
|
21
21
|
const blocks = {};
|
|
@@ -26,7 +26,7 @@ const LzHelloBlock = lazy(() => import("./blocks/HelloText"));
|
|
|
26
26
|
const LzHello2Block = lazy(() => import("./blocks/Hello2Block"));
|
|
27
27
|
registerBlock("hello", LzHelloBlock);
|
|
28
28
|
registerBlock("hello2", LzHello2Block);
|
|
29
|
-
function MtBlockRender(
|
|
29
|
+
function MtBlockRender() {
|
|
30
30
|
const id = useBlock((x) => x.id);
|
|
31
31
|
const type = useBlock((x) => x.type);
|
|
32
32
|
const blockProps = useBlock((x) => x.props);
|
|
@@ -37,7 +37,7 @@ function MtBlockRender(props) {
|
|
|
37
37
|
type
|
|
38
38
|
] });
|
|
39
39
|
}
|
|
40
|
-
return /* @__PURE__ */ jsx(BlockComp, __spreadValues({}, blockProps));
|
|
40
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(BlockComp, __spreadValues({}, blockProps)) });
|
|
41
41
|
}
|
|
42
42
|
export {
|
|
43
43
|
MtBlockRender,
|