gomtm 0.0.376 → 0.0.377

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,6 @@
1
+ /// <reference types="react" />
2
+ export declare function MtBlock(props: {
3
+ id: string;
4
+ type: string;
5
+ blockProps?: any;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import { Suspense } from "react";
3
+ import { BlockProvider } from "./block-store";
4
+ import { MtBlockRender } from "./blockRegister";
5
+ function MtBlock(props) {
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, {}) }) }) });
8
+ }
9
+ export {
10
+ MtBlock
11
+ };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function MtBlockEditor(): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ function MtBlockEditor() {
4
+ return /* @__PURE__ */ jsx("div", { className: "bg-red-200 p-2", children: "TODO:blockeditor" });
5
+ }
6
+ export {
7
+ MtBlockEditor
8
+ };
@@ -0,0 +1,14 @@
1
+ import { PropsWithChildren } from 'react';
2
+ interface BlockStateProps {
3
+ id: string;
4
+ type: string;
5
+ props?: any;
6
+ openEdit?: boolean;
7
+ }
8
+ export interface BlockState extends BlockStateProps {
9
+ setOpenEdit: (openEdit: boolean) => void;
10
+ }
11
+ export declare const blockContext: import("react").Context<import("zustand").StoreApi<BlockState> | null>;
12
+ export declare const BlockProvider: (props: PropsWithChildren<BlockStateProps>) => import("react").JSX.Element;
13
+ export declare function useBlock<T>(selector: (state: BlockState) => T): T;
14
+ export {};
@@ -0,0 +1,67 @@
1
+ "use client";
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __objRest = (source, exclude) => {
6
+ var target = {};
7
+ for (var prop in source)
8
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
9
+ target[prop] = source[prop];
10
+ if (source != null && __getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(source)) {
12
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
13
+ target[prop] = source[prop];
14
+ }
15
+ return target;
16
+ };
17
+ import { jsx } from "react/jsx-runtime";
18
+ import { createContext, useContext, useRef } from "react";
19
+ import { useStore } from "zustand";
20
+ import { createStore } from "zustand/vanilla";
21
+ const createBlockStore = (initProps) => {
22
+ return createStore()((set, get) => ({
23
+ id: "",
24
+ type: "",
25
+ // curdView: new CurdView(),
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,
35
+ 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
+ }));
47
+ };
48
+ const blockContext = createContext(null);
49
+ const BlockProvider = (props) => {
50
+ const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
51
+ const storeRef = useRef();
52
+ if (!storeRef.current) {
53
+ storeRef.current = createBlockStore(props);
54
+ }
55
+ return /* @__PURE__ */ jsx(blockContext.Provider, { value: storeRef.current, children });
56
+ };
57
+ function useBlock(selector) {
58
+ const store = useContext(blockContext);
59
+ if (!store)
60
+ throw new Error("useBlock Missing BlockProvider in the tree");
61
+ return useStore(store, selector);
62
+ }
63
+ export {
64
+ BlockProvider,
65
+ blockContext,
66
+ useBlock
67
+ };
@@ -0,0 +1,3 @@
1
+ import { ComponentType } from "react";
2
+ export declare const registerBlock: (type: string, comp: ComponentType<any>) => void;
3
+ export declare function MtBlockRender(props: {}): import("react").JSX.Element;
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __spreadValues = (a, b) => {
8
+ for (var prop in b || (b = {}))
9
+ if (__hasOwnProp.call(b, prop))
10
+ __defNormalProp(a, prop, b[prop]);
11
+ if (__getOwnPropSymbols)
12
+ for (var prop of __getOwnPropSymbols(b)) {
13
+ if (__propIsEnum.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ }
16
+ return a;
17
+ };
18
+ import { jsx, jsxs } from "react/jsx-runtime";
19
+ import { lazy } from "react";
20
+ import { useBlock } from "./block-store";
21
+ const blocks = {};
22
+ const registerBlock = (type, comp) => {
23
+ blocks[type] = comp;
24
+ };
25
+ const LzHelloBlock = lazy(() => import("./blocks/HelloText"));
26
+ const LzHello2Block = lazy(() => import("./blocks/Hello2Block"));
27
+ registerBlock("hello", LzHelloBlock);
28
+ registerBlock("hello2", LzHello2Block);
29
+ function MtBlockRender(props) {
30
+ const id = useBlock((x) => x.id);
31
+ const type = useBlock((x) => x.type);
32
+ const blockProps = useBlock((x) => x.props);
33
+ const BlockComp = blocks[type];
34
+ if (!BlockComp) {
35
+ return /* @__PURE__ */ jsxs("div", { className: "bg-600 mx-auto p-8", children: [
36
+ "unknow block:",
37
+ type
38
+ ] });
39
+ }
40
+ return /* @__PURE__ */ jsx(BlockComp, __spreadValues({}, blockProps));
41
+ }
42
+ export {
43
+ MtBlockRender,
44
+ registerBlock
45
+ };
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export default function Hello2Block(props: {
3
+ id: string;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { jsxs } from "react/jsx-runtime";
3
+ function Hello2Block(props) {
4
+ const { id } = props;
5
+ return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex gap-2 bg-blue-100 p-2", children: [
6
+ "hello2 block: ",
7
+ id
8
+ ] });
9
+ }
10
+ export {
11
+ Hello2Block as default
12
+ };
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export default function HelloBlock(props: {
3
+ id: string;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { jsxs } from "react/jsx-runtime";
3
+ function HelloBlock(props) {
4
+ const { id } = props;
5
+ return /* @__PURE__ */ jsxs("div", { children: [
6
+ "hello block: ",
7
+ id
8
+ ] });
9
+ }
10
+ export {
11
+ HelloBlock as default
12
+ };