@akanjs/ui 0.0.150 → 0.0.151
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.
- package/BottomSheet.d.ts +13 -0
- package/Button.d.ts +9 -0
- package/ClientSide.d.ts +6 -0
- package/Copy.d.ts +6 -0
- package/CsrImage.d.ts +11 -0
- package/Data/CardList.d.ts +36 -0
- package/Data/Dashboard.d.ts +15 -0
- package/Data/Insight.d.ts +8 -0
- package/Data/Item.d.ts +74 -0
- package/Data/ListContainer.d.ts +38 -0
- package/Data/Pagination.d.ts +6 -0
- package/Data/QueryMaker.d.ts +9 -0
- package/Data/TableList.d.ts +26 -0
- package/Data/index.d.ts +10 -0
- package/Data/index_.d.ts +8 -0
- package/DatePicker.d.ts +38 -0
- package/Dialog/Action.d.ts +5 -0
- package/Dialog/Close.d.ts +5 -0
- package/Dialog/Content.d.ts +6 -0
- package/Dialog/Modal.d.ts +8 -0
- package/Dialog/Provider.d.ts +7 -0
- package/Dialog/Title.d.ts +5 -0
- package/Dialog/Trigger.d.ts +5 -0
- package/Dialog/context.d.ts +10 -0
- package/Dialog/index.d.ts +9 -0
- package/DragAction.d.ts +24 -0
- package/DraggableList.d.ts +25 -0
- package/Dropdown.d.ts +10 -0
- package/Empty.d.ts +9 -0
- package/Field.d.ts +404 -0
- package/FontFace.d.ts +6 -0
- package/Image.d.ts +17 -0
- package/InfiniteScroll.d.ts +10 -0
- package/Input.d.ts +85 -0
- package/KeyboardAvoiding.d.ts +7 -0
- package/Layout/BottomAction.d.ts +5 -0
- package/Layout/BottomInset.d.ts +6 -0
- package/Layout/BottomTab.d.ts +14 -0
- package/Layout/Header.d.ts +7 -0
- package/Layout/LeftSider.d.ts +8 -0
- package/Layout/Navbar.d.ts +11 -0
- package/Layout/RightSider.d.ts +9 -0
- package/Layout/Sider.d.ts +6 -0
- package/Layout/Template.d.ts +5 -0
- package/Layout/TopLeftAction.d.ts +5 -0
- package/Layout/Unit.d.ts +6 -0
- package/Layout/View.d.ts +5 -0
- package/Layout/Zone.d.ts +5 -0
- package/Layout/index.d.ts +14 -0
- package/Link/Back.d.ts +6 -0
- package/Link/Close.d.ts +6 -0
- package/Link/CsrLink.d.ts +2 -0
- package/Link/NextLink.d.ts +2 -0
- package/Link/index.d.ts +8 -0
- package/Link/types.d.ts +22 -0
- package/Load/Edit.d.ts +4 -0
- package/Load/Edit_Client.d.ts +25 -0
- package/Load/Page.d.ts +10 -0
- package/Load/PageCSR.d.ts +11 -0
- package/Load/Pagination.d.ts +8 -0
- package/Load/Units.d.ts +34 -0
- package/Load/View.d.ts +17 -0
- package/Load/index.d.ts +8 -0
- package/Load/index_.d.ts +3 -0
- package/Loading/Area.d.ts +1 -0
- package/Loading/Button.d.ts +7 -0
- package/Loading/Input.d.ts +7 -0
- package/Loading/ProgressBar.d.ts +6 -0
- package/Loading/Skeleton.d.ts +7 -0
- package/Loading/Spin.d.ts +7 -0
- package/Loading/index.d.ts +8 -0
- package/Menu.d.ts +26 -0
- package/Modal.d.ts +23 -0
- package/Model/Edit.d.ts +15 -0
- package/Model/EditModal.d.ts +33 -0
- package/Model/EditWrapper.d.ts +11 -0
- package/Model/LoadInit.d.ts +10 -0
- package/Model/New.d.ts +15 -0
- package/Model/NewWrapper.d.ts +12 -0
- package/Model/NewWrapper_Client.d.ts +12 -0
- package/Model/Remove.d.ts +10 -0
- package/Model/RemoveWrapper.d.ts +11 -0
- package/Model/SureToRemove.d.ts +10 -0
- package/Model/View.d.ts +19 -0
- package/Model/ViewEditModal.d.ts +11 -0
- package/Model/ViewModal.d.ts +13 -0
- package/Model/ViewWrapper.d.ts +11 -0
- package/Model/index.d.ts +15 -0
- package/Model/index_.d.ts +13 -0
- package/More.d.ts +12 -0
- package/ObjectId.d.ts +5 -0
- package/Pagination.d.ts +14 -0
- package/Popconfirm.d.ts +18 -0
- package/Portal.d.ts +6 -0
- package/Radio.d.ts +19 -0
- package/RecentTime.d.ts +7 -0
- package/Refresh.d.ts +7 -0
- package/ScreenNavigator.d.ts +18 -0
- package/Select.d.ts +29 -0
- package/Signal/Arg.d.ts +75 -0
- package/Signal/Doc.d.ts +19 -0
- package/Signal/GraphQL.d.ts +32 -0
- package/Signal/Listener.d.ts +9 -0
- package/Signal/Message.d.ts +27 -0
- package/Signal/Object.d.ts +19 -0
- package/Signal/PubSub.d.ts +26 -0
- package/Signal/Request.d.ts +8 -0
- package/Signal/Response.d.ts +16 -0
- package/Signal/RestApi.d.ts +40 -0
- package/Signal/WebSocket.d.ts +9 -0
- package/Signal/index.d.ts +20 -0
- package/System/CSR.d.ts +31 -0
- package/System/Client.d.ts +48 -0
- package/System/Common.d.ts +66 -0
- package/System/DevModeToggle.d.ts +1 -0
- package/System/Gtag.d.ts +3 -0
- package/System/HealthCheck.d.ts +5 -0
- package/System/Messages.d.ts +1 -0
- package/System/Reconnect.d.ts +6 -0
- package/System/Root.d.ts +5 -0
- package/System/SSR.d.ts +26 -0
- package/System/SelectLanguage.d.ts +5 -0
- package/System/ThemeToggle.d.ts +1 -0
- package/System/index.d.ts +11 -0
- package/Tab/Menu.d.ts +11 -0
- package/Tab/Menus.d.ts +5 -0
- package/Tab/Panel.d.ts +7 -0
- package/Tab/Provider.d.ts +6 -0
- package/Tab/context.d.ts +9 -0
- package/Tab/index.d.ts +7 -0
- package/Table.d.ts +26 -0
- package/ToggleSelect.d.ts +31 -0
- package/Unauthorized.d.ts +9 -0
- package/cjs/BottomSheet.js +113 -0
- package/cjs/Button.js +69 -0
- package/cjs/ClientSide.js +26 -0
- package/cjs/Copy.js +37 -0
- package/cjs/CsrImage.js +50 -0
- package/cjs/Data/CardList.js +119 -0
- package/cjs/Data/Dashboard.js +54 -0
- package/cjs/Data/Insight.js +38 -0
- package/cjs/Data/Item.js +204 -0
- package/cjs/Data/ListContainer.js +251 -0
- package/cjs/Data/Pagination.js +64 -0
- package/cjs/Data/QueryMaker.js +304 -0
- package/cjs/Data/TableList.js +139 -0
- package/cjs/Data/index.js +33 -0
- package/cjs/Data/index_.js +49 -0
- package/cjs/DatePicker.js +173 -0
- package/cjs/Dialog/Action.js +32 -0
- package/cjs/Dialog/Close.js +38 -0
- package/cjs/Dialog/Content.js +27 -0
- package/cjs/Dialog/Modal.js +155 -0
- package/cjs/Dialog/Provider.js +46 -0
- package/cjs/Dialog/Title.js +32 -0
- package/cjs/Dialog/Trigger.js +38 -0
- package/cjs/Dialog/context.js +32 -0
- package/cjs/Dialog/index.js +36 -0
- package/cjs/DragAction.js +111 -0
- package/cjs/DraggableList.js +141 -0
- package/cjs/Dropdown.js +64 -0
- package/cjs/Empty.js +50 -0
- package/cjs/Field.js +1109 -0
- package/cjs/FontFace.js +77 -0
- package/cjs/Image.js +61 -0
- package/cjs/InfiniteScroll.js +65 -0
- package/cjs/Input.js +440 -0
- package/cjs/KeyboardAvoiding.js +65 -0
- package/cjs/Layout/BottomAction.js +26 -0
- package/cjs/Layout/BottomInset.js +53 -0
- package/cjs/Layout/BottomTab.js +56 -0
- package/cjs/Layout/Header.js +52 -0
- package/cjs/Layout/LeftSider.js +49 -0
- package/cjs/Layout/Navbar.js +51 -0
- package/cjs/Layout/RightSider.js +52 -0
- package/cjs/Layout/Sider.js +39 -0
- package/cjs/Layout/Template.js +26 -0
- package/cjs/Layout/TopLeftAction.js +39 -0
- package/cjs/Layout/Unit.js +27 -0
- package/cjs/Layout/View.js +26 -0
- package/cjs/Layout/Zone.js +26 -0
- package/cjs/Layout/index.js +48 -0
- package/cjs/Link/Back.js +27 -0
- package/cjs/Link/Close.js +36 -0
- package/cjs/Link/CsrLink.js +49 -0
- package/cjs/Link/NextLink.js +71 -0
- package/cjs/Link/index.js +47 -0
- package/cjs/Link/types.js +15 -0
- package/cjs/Load/Edit.js +42 -0
- package/cjs/Load/Edit_Client.js +93 -0
- package/cjs/Load/Page.js +35 -0
- package/cjs/Load/PageCSR.js +67 -0
- package/cjs/Load/Pagination.js +89 -0
- package/cjs/Load/Units.js +232 -0
- package/cjs/Load/View.js +88 -0
- package/cjs/Load/index.js +42 -0
- package/cjs/Load/index_.js +39 -0
- package/cjs/Loading/Area.js +25 -0
- package/cjs/Loading/Button.js +33 -0
- package/cjs/Loading/Input.js +33 -0
- package/cjs/Loading/ProgressBar.js +29 -0
- package/cjs/Loading/Skeleton.js +27 -0
- package/cjs/Loading/Spin.js +27 -0
- package/cjs/Loading/index.js +29 -0
- package/cjs/Menu.js +215 -0
- package/cjs/Modal.js +75 -0
- package/cjs/Model/Edit.js +61 -0
- package/cjs/Model/EditModal.js +255 -0
- package/cjs/Model/EditWrapper.js +48 -0
- package/cjs/Model/LoadInit.js +27 -0
- package/cjs/Model/New.js +61 -0
- package/cjs/Model/NewWrapper.js +28 -0
- package/cjs/Model/NewWrapper_Client.js +66 -0
- package/cjs/Model/Remove.js +86 -0
- package/cjs/Model/RemoveWrapper.js +48 -0
- package/cjs/Model/SureToRemove.js +109 -0
- package/cjs/Model/View.js +44 -0
- package/cjs/Model/ViewEditModal.js +118 -0
- package/cjs/Model/ViewModal.js +92 -0
- package/cjs/Model/ViewWrapper.js +48 -0
- package/cjs/Model/index.js +38 -0
- package/cjs/Model/index_.js +58 -0
- package/cjs/More.js +67 -0
- package/cjs/ObjectId.js +37 -0
- package/cjs/Pagination.js +110 -0
- package/cjs/Popconfirm.js +116 -0
- package/cjs/Portal.js +27 -0
- package/cjs/Radio.js +53 -0
- package/cjs/RecentTime.js +86 -0
- package/cjs/Refresh.js +45 -0
- package/cjs/ScreenNavigator.js +121 -0
- package/cjs/Select.js +262 -0
- package/cjs/Signal/Arg.js +237 -0
- package/cjs/Signal/Doc.js +181 -0
- package/cjs/Signal/GraphQL.js +177 -0
- package/cjs/Signal/Listener.js +59 -0
- package/cjs/Signal/Message.js +190 -0
- package/cjs/Signal/Object.js +95 -0
- package/cjs/Signal/PubSub.js +191 -0
- package/cjs/Signal/Request.js +38 -0
- package/cjs/Signal/Response.js +53 -0
- package/cjs/Signal/RestApi.js +255 -0
- package/cjs/Signal/WebSocket.js +68 -0
- package/cjs/Signal/index.js +42 -0
- package/cjs/System/CSR.js +376 -0
- package/cjs/System/Client.js +200 -0
- package/cjs/System/Common.js +64 -0
- package/cjs/System/DevModeToggle.js +38 -0
- package/cjs/System/Gtag.js +67 -0
- package/cjs/System/HealthCheck.js +60 -0
- package/cjs/System/Messages.js +170 -0
- package/cjs/System/Reconnect.js +64 -0
- package/cjs/System/Root.js +30 -0
- package/cjs/System/SSR.js +144 -0
- package/cjs/System/SelectLanguage.js +58 -0
- package/cjs/System/ThemeToggle.js +40 -0
- package/cjs/System/index.js +55 -0
- package/cjs/Tab/Menu.js +70 -0
- package/cjs/{src/index.js → Tab/Menus.js} +8 -5
- package/cjs/Tab/Panel.js +42 -0
- package/cjs/Tab/Provider.js +31 -0
- package/cjs/Tab/context.js +30 -0
- package/cjs/Tab/index.js +32 -0
- package/cjs/Table.js +85 -0
- package/cjs/ToggleSelect.js +118 -0
- package/cjs/Unauthorized.js +50 -0
- package/cjs/index.js +88 -2
- package/esm/BottomSheet.js +84 -0
- package/esm/Button.js +40 -0
- package/esm/ClientSide.js +7 -0
- package/esm/Copy.js +18 -0
- package/esm/CsrImage.js +31 -0
- package/esm/Data/CardList.js +90 -0
- package/esm/Data/Dashboard.js +35 -0
- package/esm/Data/Insight.js +19 -0
- package/esm/Data/Item.js +175 -0
- package/esm/Data/ListContainer.js +228 -0
- package/esm/Data/Pagination.js +45 -0
- package/esm/Data/QueryMaker.js +293 -0
- package/esm/Data/TableList.js +110 -0
- package/esm/Data/index.js +14 -0
- package/esm/Data/index_.js +20 -0
- package/esm/DatePicker.js +144 -0
- package/esm/Dialog/Action.js +13 -0
- package/esm/Dialog/Close.js +19 -0
- package/esm/Dialog/Content.js +8 -0
- package/esm/Dialog/Modal.js +126 -0
- package/esm/Dialog/Provider.js +17 -0
- package/esm/Dialog/Title.js +13 -0
- package/esm/Dialog/Trigger.js +19 -0
- package/esm/Dialog/context.js +13 -0
- package/esm/Dialog/index.js +17 -0
- package/esm/DragAction.js +92 -0
- package/esm/DraggableList.js +112 -0
- package/esm/Dropdown.js +45 -0
- package/esm/Empty.js +21 -0
- package/esm/Field.js +1090 -0
- package/esm/FontFace.js +58 -0
- package/esm/Image.js +32 -0
- package/esm/InfiniteScroll.js +46 -0
- package/esm/Input.js +415 -0
- package/esm/KeyboardAvoiding.js +46 -0
- package/esm/Layout/BottomAction.js +7 -0
- package/esm/Layout/BottomInset.js +34 -0
- package/esm/Layout/BottomTab.js +37 -0
- package/esm/Layout/Header.js +33 -0
- package/esm/Layout/LeftSider.js +30 -0
- package/esm/Layout/Navbar.js +22 -0
- package/esm/Layout/RightSider.js +33 -0
- package/esm/Layout/Sider.js +20 -0
- package/esm/Layout/Template.js +7 -0
- package/esm/Layout/TopLeftAction.js +20 -0
- package/esm/Layout/Unit.js +8 -0
- package/esm/Layout/View.js +7 -0
- package/esm/Layout/Zone.js +7 -0
- package/esm/Layout/index.js +29 -0
- package/esm/Link/Back.js +8 -0
- package/esm/Link/Close.js +17 -0
- package/esm/Link/CsrLink.js +30 -0
- package/esm/Link/NextLink.js +42 -0
- package/esm/Link/index.js +18 -0
- package/esm/Link/types.js +0 -0
- package/esm/Load/Edit.js +13 -0
- package/esm/Load/Edit_Client.js +74 -0
- package/esm/Load/Page.js +16 -0
- package/esm/Load/PageCSR.js +48 -0
- package/esm/Load/Pagination.js +70 -0
- package/esm/Load/Units.js +213 -0
- package/esm/Load/View.js +69 -0
- package/esm/Load/index.js +13 -0
- package/esm/Load/index_.js +10 -0
- package/esm/Loading/Area.js +6 -0
- package/esm/Loading/Button.js +14 -0
- package/esm/Loading/Input.js +14 -0
- package/esm/Loading/ProgressBar.js +10 -0
- package/esm/Loading/Skeleton.js +8 -0
- package/esm/Loading/Spin.js +8 -0
- package/esm/Loading/index.js +10 -0
- package/esm/Menu.js +196 -0
- package/esm/Modal.js +46 -0
- package/esm/Model/Edit.js +32 -0
- package/esm/Model/EditModal.js +226 -0
- package/esm/Model/EditWrapper.js +29 -0
- package/esm/Model/LoadInit.js +8 -0
- package/esm/Model/New.js +32 -0
- package/esm/Model/NewWrapper.js +9 -0
- package/esm/Model/NewWrapper_Client.js +47 -0
- package/esm/Model/Remove.js +67 -0
- package/esm/Model/RemoveWrapper.js +29 -0
- package/esm/Model/SureToRemove.js +90 -0
- package/esm/Model/View.js +25 -0
- package/esm/Model/ViewEditModal.js +89 -0
- package/esm/Model/ViewModal.js +63 -0
- package/esm/Model/ViewWrapper.js +29 -0
- package/esm/Model/index.js +33 -0
- package/esm/Model/index_.js +29 -0
- package/esm/More.js +38 -0
- package/esm/ObjectId.js +18 -0
- package/esm/Pagination.js +91 -0
- package/esm/Popconfirm.js +87 -0
- package/esm/Portal.js +8 -0
- package/esm/Radio.js +34 -0
- package/esm/RecentTime.js +57 -0
- package/esm/Refresh.js +16 -0
- package/esm/ScreenNavigator.js +102 -0
- package/esm/Select.js +243 -0
- package/esm/Signal/Arg.js +208 -0
- package/esm/Signal/Doc.js +152 -0
- package/esm/Signal/GraphQL.js +156 -0
- package/esm/Signal/Listener.js +40 -0
- package/esm/Signal/Message.js +161 -0
- package/esm/Signal/Object.js +76 -0
- package/esm/Signal/PubSub.js +162 -0
- package/esm/Signal/Request.js +19 -0
- package/esm/Signal/Response.js +34 -0
- package/esm/Signal/RestApi.js +234 -0
- package/esm/Signal/WebSocket.js +39 -0
- package/esm/Signal/index.js +13 -0
- package/esm/System/CSR.js +357 -0
- package/esm/System/Client.js +191 -0
- package/esm/System/Common.js +45 -0
- package/esm/System/DevModeToggle.js +19 -0
- package/esm/System/Gtag.js +48 -0
- package/esm/System/HealthCheck.js +41 -0
- package/esm/System/Messages.js +156 -0
- package/esm/System/Reconnect.js +45 -0
- package/esm/System/Root.js +11 -0
- package/esm/System/SSR.js +125 -0
- package/esm/System/SelectLanguage.js +39 -0
- package/esm/System/ThemeToggle.js +21 -0
- package/esm/System/index.js +26 -0
- package/esm/Tab/Menu.js +51 -0
- package/esm/Tab/Menus.js +7 -0
- package/esm/Tab/Panel.js +23 -0
- package/esm/Tab/Provider.js +12 -0
- package/esm/Tab/context.js +11 -0
- package/esm/Tab/index.js +13 -0
- package/esm/Table.js +56 -0
- package/esm/ToggleSelect.js +99 -0
- package/esm/Unauthorized.js +21 -0
- package/esm/index.js +84 -1
- package/index.d.ts +41 -1
- package/package.json +23 -2
- package/esm/src/index.js +0 -4
- package/src/index.d.ts +0 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { makeResponseExample } from "@akanjs/signal";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { AiOutlineCopy } from "react-icons/ai";
|
|
4
|
+
import { Copy } from "../Copy";
|
|
5
|
+
function Response() {
|
|
6
|
+
return /* @__PURE__ */ React.createElement("div", null);
|
|
7
|
+
}
|
|
8
|
+
const ResponseExample = ({ sigRef, gqlMeta }) => {
|
|
9
|
+
const example = useMemo(() => JSON.stringify(makeResponseExample(sigRef, gqlMeta.key), null, 2), []);
|
|
10
|
+
return /* @__PURE__ */ React.createElement("div", { className: "relative" }, /* @__PURE__ */ React.createElement(
|
|
11
|
+
"textarea",
|
|
12
|
+
{
|
|
13
|
+
className: "bg-base-100 min-h-[500px] w-full rounded-md p-4 text-base",
|
|
14
|
+
value: example,
|
|
15
|
+
onChange: () => true
|
|
16
|
+
}
|
|
17
|
+
), /* @__PURE__ */ React.createElement("div", { className: "absolute top-4 right-4" }, /* @__PURE__ */ React.createElement(Copy, { text: example }, /* @__PURE__ */ React.createElement("button", { className: "btn btn-sm" }, /* @__PURE__ */ React.createElement(AiOutlineCopy, null), " Copy"))));
|
|
18
|
+
};
|
|
19
|
+
Response.Example = ResponseExample;
|
|
20
|
+
const ResponseResult = ({ status, data }) => {
|
|
21
|
+
const dataStr = data ? JSON.stringify(data, null, 2) : "";
|
|
22
|
+
return /* @__PURE__ */ React.createElement("div", { className: "relative" }, /* @__PURE__ */ React.createElement(
|
|
23
|
+
"textarea",
|
|
24
|
+
{
|
|
25
|
+
className: `textarea ${status === "loading" ? "textarea-disabled" : status === "success" ? "textarea-success border-success" : status === "error" ? "textarea-error text-error border-error" : ""} bg-base-100 min-h-[300px] w-full rounded-md p-4 text-sm font-normal`,
|
|
26
|
+
value: dataStr,
|
|
27
|
+
onChange: () => true
|
|
28
|
+
}
|
|
29
|
+
), status === "loading" ? /* @__PURE__ */ React.createElement("div", { className: "animate-fadeIn absolute inset-0 flex items-center justify-center backdrop-blur-sm" }, /* @__PURE__ */ React.createElement("span", { className: "loading loading-dots loading-lg" })) : status === "idle" ? /* @__PURE__ */ React.createElement(React.Fragment, null) : /* @__PURE__ */ React.createElement("div", { className: "absolute top-4 right-4" }, /* @__PURE__ */ React.createElement(Copy, { text: dataStr }, /* @__PURE__ */ React.createElement("button", { className: "btn btn-sm" }, /* @__PURE__ */ React.createElement(AiOutlineCopy, null), " Copy"))));
|
|
30
|
+
};
|
|
31
|
+
Response.Result = ResponseResult;
|
|
32
|
+
export {
|
|
33
|
+
Response as default
|
|
34
|
+
};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { baseClientEnv, getNonArrayModel, isGqlScalar } from "@akanjs/base";
|
|
3
|
+
import { getGqlTypeStr } from "@akanjs/constant";
|
|
4
|
+
import { usePage } from "@akanjs/next";
|
|
5
|
+
import {
|
|
6
|
+
getArgMetas,
|
|
7
|
+
getControllerPath,
|
|
8
|
+
getControllerPrefix,
|
|
9
|
+
getExampleData,
|
|
10
|
+
getGqlMetas,
|
|
11
|
+
getSigMeta,
|
|
12
|
+
getSignalRefsOnStorage
|
|
13
|
+
} from "@akanjs/signal";
|
|
14
|
+
import { st } from "@akanjs/store";
|
|
15
|
+
import React, { useMemo, useState } from "react";
|
|
16
|
+
import { AiOutlineApi, AiOutlineCopy, AiOutlineFileWord, AiOutlineSend } from "react-icons/ai";
|
|
17
|
+
import { Copy } from "../Copy";
|
|
18
|
+
import { Signal } from ".";
|
|
19
|
+
import Arg from "./Arg";
|
|
20
|
+
import Response from "./Response";
|
|
21
|
+
function RestApi() {
|
|
22
|
+
return /* @__PURE__ */ React.createElement("div", null);
|
|
23
|
+
}
|
|
24
|
+
const RestApiEndpoints = ({ refName, endpoints, openAll, httpUri }) => {
|
|
25
|
+
const sigRefs = getSignalRefsOnStorage(refName);
|
|
26
|
+
if (!sigRefs.length)
|
|
27
|
+
return null;
|
|
28
|
+
const tryRoles = st.use.tryRoles();
|
|
29
|
+
const gqlInfos = sigRefs.reduce(
|
|
30
|
+
(acc, sigRef) => [...acc, ...getGqlMetas(sigRef).map((gqlMeta) => ({ key: gqlMeta.key, gqlMeta, sigRef }))],
|
|
31
|
+
[]
|
|
32
|
+
).filter(({ key }) => !endpoints || endpoints.includes(key)).sort((a, b) => a.key > b.key ? 1 : -1).filter(({ gqlMeta }) => gqlMeta.signalOption.onlyFor !== "graphql").filter(({ gqlMeta }) => {
|
|
33
|
+
if (gqlMeta.type === "Pubsub" || gqlMeta.type === "Message")
|
|
34
|
+
return false;
|
|
35
|
+
if (gqlMeta.guards.includes("Public") && tryRoles.includes("Public"))
|
|
36
|
+
return true;
|
|
37
|
+
if ((gqlMeta.guards.includes("User") || gqlMeta.guards.includes("Every")) && tryRoles.includes("User"))
|
|
38
|
+
return true;
|
|
39
|
+
if ((gqlMeta.guards.includes("Admin") || gqlMeta.guards.includes("Every")) && tryRoles.includes("Admin"))
|
|
40
|
+
return true;
|
|
41
|
+
if (gqlMeta.guards.includes("SuperAdmin") && tryRoles.includes("SuperAdmin"))
|
|
42
|
+
return true;
|
|
43
|
+
return false;
|
|
44
|
+
});
|
|
45
|
+
return /* @__PURE__ */ React.createElement("div", null, gqlInfos.map(({ gqlMeta, sigRef }, idx) => /* @__PURE__ */ React.createElement(RestApiEndpoint, { key: idx, sigRef, gqlMeta, open: openAll, httpUri })));
|
|
46
|
+
};
|
|
47
|
+
RestApi.Endpoints = RestApiEndpoints;
|
|
48
|
+
const RestApiEndpoint = ({ sigRef, gqlMeta, open, httpUri }) => {
|
|
49
|
+
const { l } = usePage();
|
|
50
|
+
const sigMeta = getSigMeta(sigRef);
|
|
51
|
+
const [viewStatus, setViewStatus] = useState("doc");
|
|
52
|
+
const [argMetas] = getArgMetas(sigRef, gqlMeta.key);
|
|
53
|
+
const queryArgMetas = argMetas.filter((argMeta) => argMeta.type === "Query");
|
|
54
|
+
const paramArgMetas = argMetas.filter((argMeta) => argMeta.type === "Param");
|
|
55
|
+
const bodyArgMetas = argMetas.filter((argMeta) => argMeta.type === "Body");
|
|
56
|
+
const uploadArgMetas = argMetas.filter((argMeta) => argMeta.type === "Upload");
|
|
57
|
+
const prefix = getControllerPrefix(sigMeta);
|
|
58
|
+
const path = getControllerPath(gqlMeta, paramArgMetas);
|
|
59
|
+
return /* @__PURE__ */ React.createElement("div", { className: "collapse-arrow bg-base-300 collapse my-1" }, /* @__PURE__ */ React.createElement("input", { type: "checkbox", checked: open }), /* @__PURE__ */ React.createElement("div", { className: "collapse-title" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-3" }, /* @__PURE__ */ React.createElement("div", { className: `btn btn-xs w-16 ${gqlMeta.type === "Query" ? "btn-success" : "btn-accent"}` }, gqlMeta.type === "Query" ? "GET" : "POST"), prefix ? `/${prefix}` : "", "/", path, " ", /* @__PURE__ */ React.createElement("span", { className: "text-lg" }, "(", l.api(sigMeta.refName, gqlMeta.key), ")"))), /* @__PURE__ */ React.createElement("div", { className: "collapse-content bg-base-200 w-full" }, /* @__PURE__ */ React.createElement("div", { className: "mt-4 text-lg" }, /* @__PURE__ */ React.createElement("div", { className: "text-lg font-extrabold" }, "Description"), /* @__PURE__ */ React.createElement("hr", { className: "my-2 border-[0.1px] border-gray-400" }), gqlMeta.guards.some((guard) => guard !== "None") ? /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2 pb-3 pl-3 text-base font-normal" }, "- Guards:", gqlMeta.guards.map((guard) => /* @__PURE__ */ React.createElement(
|
|
60
|
+
"span",
|
|
61
|
+
{
|
|
62
|
+
className: `badge ${guard === "Public" ? "badge-success" : guard === "SuperAdmin" ? "badge-error" : guard === "Admin" ? "badge-error" : guard === "User" ? "badge-accent" : guard === "Owner" ? "badge-accent" : guard === "Every" ? "badge-warning" : ""}`,
|
|
63
|
+
key: guard
|
|
64
|
+
},
|
|
65
|
+
guard
|
|
66
|
+
))) : null, /* @__PURE__ */ React.createElement("div", { className: "pb-3 pl-3 text-base font-normal" }, "- ", l.apidesc(sigMeta.refName, gqlMeta.key))), /* @__PURE__ */ React.createElement("div", { className: "my-4 flex w-full gap-5 px-5" }, /* @__PURE__ */ React.createElement(
|
|
67
|
+
"button",
|
|
68
|
+
{
|
|
69
|
+
onClick: () => {
|
|
70
|
+
setViewStatus("doc");
|
|
71
|
+
},
|
|
72
|
+
className: `btn btn-success w-1/2 ${viewStatus === "doc" ? "" : "btn-outline"}`
|
|
73
|
+
},
|
|
74
|
+
/* @__PURE__ */ React.createElement(AiOutlineFileWord, { className: "text-xl" }),
|
|
75
|
+
" View Doc"
|
|
76
|
+
), /* @__PURE__ */ React.createElement(
|
|
77
|
+
"button",
|
|
78
|
+
{
|
|
79
|
+
onClick: () => {
|
|
80
|
+
setViewStatus("test");
|
|
81
|
+
},
|
|
82
|
+
className: `btn btn-primary w-1/2 ${viewStatus === "test" ? "" : "btn-outline"}`
|
|
83
|
+
},
|
|
84
|
+
/* @__PURE__ */ React.createElement(AiOutlineApi, { className: "text-xl" }),
|
|
85
|
+
" Restful API"
|
|
86
|
+
)), viewStatus === "doc" ? /* @__PURE__ */ React.createElement(
|
|
87
|
+
RestApiInterface,
|
|
88
|
+
{
|
|
89
|
+
sigRef,
|
|
90
|
+
gqlMeta,
|
|
91
|
+
queryArgMetas,
|
|
92
|
+
paramArgMetas,
|
|
93
|
+
bodyArgMetas,
|
|
94
|
+
uploadArgMetas
|
|
95
|
+
}
|
|
96
|
+
) : /* @__PURE__ */ React.createElement(
|
|
97
|
+
RestApiTry,
|
|
98
|
+
{
|
|
99
|
+
sigRef,
|
|
100
|
+
gqlMeta,
|
|
101
|
+
queryArgMetas,
|
|
102
|
+
paramArgMetas,
|
|
103
|
+
bodyArgMetas,
|
|
104
|
+
uploadArgMetas,
|
|
105
|
+
httpUri
|
|
106
|
+
}
|
|
107
|
+
)));
|
|
108
|
+
};
|
|
109
|
+
RestApi.Endpoint = RestApiEndpoint;
|
|
110
|
+
const RestApiInterface = ({
|
|
111
|
+
sigRef,
|
|
112
|
+
gqlMeta,
|
|
113
|
+
queryArgMetas,
|
|
114
|
+
paramArgMetas,
|
|
115
|
+
bodyArgMetas,
|
|
116
|
+
uploadArgMetas
|
|
117
|
+
}) => {
|
|
118
|
+
const sigMeta = getSigMeta(sigRef);
|
|
119
|
+
const [returnRef, arrDepth] = getNonArrayModel(gqlMeta.returns());
|
|
120
|
+
const isReturnModelType = !isGqlScalar(returnRef);
|
|
121
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-col gap-4" }, uploadArgMetas.length ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "text-lg font-extrabold" }, "Form data upload"), /* @__PURE__ */ React.createElement("div", { className: "bg-base-100 overflow-x-auto rounded-md p-3" }, /* @__PURE__ */ React.createElement(Arg.Table, { sigMeta, gqlMeta, argMetas: uploadArgMetas }))) : null, paramArgMetas.length ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "text-lg font-extrabold" }, "Parameters"), /* @__PURE__ */ React.createElement("div", { className: "bg-base-100 overflow-x-auto rounded-md p-3" }, /* @__PURE__ */ React.createElement(Arg.Table, { sigMeta, gqlMeta, argMetas: paramArgMetas }))) : null, queryArgMetas.length ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "text-lg font-extrabold" }, "Query"), /* @__PURE__ */ React.createElement("div", { className: "bg-base-100 overflow-x-auto rounded-md p-3" }, /* @__PURE__ */ React.createElement(Arg.Table, { sigMeta, gqlMeta, argMetas: queryArgMetas }))) : null, bodyArgMetas.length ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "text-lg font-extrabold" }, "Body"), /* @__PURE__ */ React.createElement("div", { className: "bg-base-100 overflow-x-auto rounded-md p-3" }, /* @__PURE__ */ React.createElement(Arg.Table, { sigMeta, gqlMeta, argMetas: bodyArgMetas }))) : null, /* @__PURE__ */ React.createElement("div", { className: "text-lg font-bold" }, /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-col gap-2 rounded-md font-normal md:flex-row" }, /* @__PURE__ */ React.createElement("div", { className: "w-full md:w-1/2" }, /* @__PURE__ */ React.createElement("div", { className: "text-lg font-extrabold" }, "Response Type"), /* @__PURE__ */ React.createElement("div", { className: "bg-base-100 max-h-[500px] overflow-auto rounded-md p-4 md:h-[500px]" }, "Returns: ", /* @__PURE__ */ React.createElement(Signal.Object.Type, { objRef: returnRef, arrDepth }), isReturnModelType ? /* @__PURE__ */ React.createElement(Signal.Object.Detail, { objRef: returnRef }) : null)), /* @__PURE__ */ React.createElement("div", { className: "w-full md:w-1/2" }, /* @__PURE__ */ React.createElement("div", { className: "text-lg font-extrabold" }, "Response Example"), /* @__PURE__ */ React.createElement(Response.Example, { sigRef, gqlMeta })))));
|
|
122
|
+
};
|
|
123
|
+
RestApi.Interface = RestApiInterface;
|
|
124
|
+
const RestApiTry = ({
|
|
125
|
+
sigRef,
|
|
126
|
+
gqlMeta,
|
|
127
|
+
queryArgMetas,
|
|
128
|
+
paramArgMetas,
|
|
129
|
+
bodyArgMetas,
|
|
130
|
+
uploadArgMetas,
|
|
131
|
+
httpUri = baseClientEnv.serverHttpUri
|
|
132
|
+
}) => {
|
|
133
|
+
const sigMeta = getSigMeta(sigRef);
|
|
134
|
+
const tryJwt = st.use.tryJwt();
|
|
135
|
+
const paramExample = useMemo(() => getExampleData(paramArgMetas, "restapi"), []);
|
|
136
|
+
const queryExample = useMemo(() => getExampleData(queryArgMetas, "restapi"), []);
|
|
137
|
+
const bodyExample = useMemo(() => JSON.stringify(getExampleData(bodyArgMetas, "restapi"), null, 2), []);
|
|
138
|
+
const [paramRequest, setParamRequest] = useState(paramExample);
|
|
139
|
+
const [queryRequest, setQueryRequest] = useState(queryExample);
|
|
140
|
+
const [bodyRequest, setBodyRequest] = useState(bodyExample);
|
|
141
|
+
const [uploadRequest, setUploadRequest] = useState({});
|
|
142
|
+
const [response, setResponse] = useState({
|
|
143
|
+
status: "idle",
|
|
144
|
+
data: null
|
|
145
|
+
});
|
|
146
|
+
const method = gqlMeta.type === "Query" ? "GET" : "POST";
|
|
147
|
+
const prefix = getControllerPrefix(sigMeta);
|
|
148
|
+
const path = getControllerPath(gqlMeta, paramArgMetas);
|
|
149
|
+
const queryString = new URLSearchParams(
|
|
150
|
+
Object.fromEntries(
|
|
151
|
+
queryArgMetas.map((argMeta) => {
|
|
152
|
+
const value = queryRequest[argMeta.name];
|
|
153
|
+
if (value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0)
|
|
154
|
+
return null;
|
|
155
|
+
const [argRef] = getNonArrayModel(argMeta.returns());
|
|
156
|
+
if (getGqlTypeStr(argRef) === "JSON")
|
|
157
|
+
return [argMeta.name, btoa(value)];
|
|
158
|
+
return [argMeta.name, value];
|
|
159
|
+
}).filter((entry) => !!entry)
|
|
160
|
+
)
|
|
161
|
+
).toString();
|
|
162
|
+
const requestPath = paramArgMetas.reduce(
|
|
163
|
+
(path2, argMeta) => path2.replace(`:${argMeta.name}`, paramRequest[argMeta.name]),
|
|
164
|
+
`${prefix ? `/${prefix}` : ""}/${path}`
|
|
165
|
+
) + (queryString.length ? `?${queryString}` : "");
|
|
166
|
+
const requestUrl = `${httpUri}${requestPath}`;
|
|
167
|
+
const getBody = () => {
|
|
168
|
+
if (!uploadArgMetas.length)
|
|
169
|
+
return bodyRequest;
|
|
170
|
+
const formData = new FormData();
|
|
171
|
+
const bodyObj = JSON.parse(bodyRequest);
|
|
172
|
+
bodyArgMetas.forEach((argMeta) => {
|
|
173
|
+
const value = bodyObj[argMeta.name];
|
|
174
|
+
if (value === void 0 || value === null || value === "")
|
|
175
|
+
return null;
|
|
176
|
+
formData.append(argMeta.name, value);
|
|
177
|
+
});
|
|
178
|
+
uploadArgMetas.forEach((argMeta) => {
|
|
179
|
+
const fileList = uploadRequest[argMeta.name];
|
|
180
|
+
Array.from(fileList).forEach((file) => {
|
|
181
|
+
formData.append(argMeta.name, file);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
return formData;
|
|
185
|
+
};
|
|
186
|
+
const onSend = async () => {
|
|
187
|
+
setResponse({ status: "loading", data: null });
|
|
188
|
+
const res = await fetch(requestUrl, {
|
|
189
|
+
method,
|
|
190
|
+
headers: {
|
|
191
|
+
"Content-Type": uploadArgMetas.length ? "application/form-data" : "application/json",
|
|
192
|
+
Authorization: `Bearer ${tryJwt}`
|
|
193
|
+
},
|
|
194
|
+
...method === "POST" ? { body: getBody() } : {}
|
|
195
|
+
});
|
|
196
|
+
const data = await res.json();
|
|
197
|
+
setResponse(res.ok ? { status: "success", data } : { status: "error", data });
|
|
198
|
+
};
|
|
199
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-col gap-4" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2 text-lg" }, /* @__PURE__ */ React.createElement("div", { className: "text-lg font-extrabold" }, "Request URL:"), /* @__PURE__ */ React.createElement(Copy, { text: `${httpUri}${requestPath}` }, /* @__PURE__ */ React.createElement("button", { className: "btn btn-sm btn-outline" }, requestPath, " ", /* @__PURE__ */ React.createElement(AiOutlineCopy, null)))), uploadArgMetas.length ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "text-lg" }, "Form data uplaod"), uploadArgMetas.map((argMeta) => /* @__PURE__ */ React.createElement(
|
|
200
|
+
Arg.FormData,
|
|
201
|
+
{
|
|
202
|
+
key: argMeta.name,
|
|
203
|
+
argMeta,
|
|
204
|
+
value: uploadRequest[argMeta.name],
|
|
205
|
+
onChange: (fileList) => {
|
|
206
|
+
setUploadRequest({ ...uploadRequest, [argMeta.name]: fileList });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
))) : null, paramArgMetas.length ? /* @__PURE__ */ React.createElement("div", { className: "border-t border-gray-400 pt-5" }, /* @__PURE__ */ React.createElement("div", { className: "text-lg font-extrabold" }, "Parameters"), paramArgMetas.map((argMeta, idx) => /* @__PURE__ */ React.createElement(
|
|
210
|
+
Arg.Param,
|
|
211
|
+
{
|
|
212
|
+
key: idx,
|
|
213
|
+
argMeta,
|
|
214
|
+
value: paramRequest[argMeta.name],
|
|
215
|
+
onChange: (value) => {
|
|
216
|
+
setParamRequest({ ...paramRequest, [argMeta.name]: value });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
))) : null, queryArgMetas.length ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "text-lg font-extrabold" }, "Queries"), queryArgMetas.map((argMeta, idx) => /* @__PURE__ */ React.createElement(
|
|
220
|
+
Arg.Query,
|
|
221
|
+
{
|
|
222
|
+
key: idx,
|
|
223
|
+
argMeta,
|
|
224
|
+
value: queryRequest[argMeta.name] ?? "",
|
|
225
|
+
onChange: (value) => {
|
|
226
|
+
setQueryRequest({ ...queryRequest, [argMeta.name]: value });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
))) : null, bodyArgMetas.length ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "text-lg" }, "Body"), /* @__PURE__ */ React.createElement(Arg.Json, { value: bodyRequest, onChange: setBodyRequest })) : null, /* @__PURE__ */ React.createElement("div", { className: "border-b border-gray-400 pb-5" }, /* @__PURE__ */ React.createElement("button", { className: "btn bg-success w-full", onClick: () => void onSend() }, /* @__PURE__ */ React.createElement(AiOutlineSend, { className: "-mt-0.5" }), " Send Request")), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "text-lg font-extrabold" }, "Response"), /* @__PURE__ */ React.createElement(Response.Result, { status: response.status, data: response.data })));
|
|
230
|
+
};
|
|
231
|
+
RestApi.Try = RestApiTry;
|
|
232
|
+
export {
|
|
233
|
+
RestApi as default
|
|
234
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getGqlMetas, getSignalRefsOnStorage } from "@akanjs/signal";
|
|
3
|
+
import { st } from "@akanjs/store";
|
|
4
|
+
import Message from "./Message";
|
|
5
|
+
import PubSub from "./PubSub";
|
|
6
|
+
function WebSocket() {
|
|
7
|
+
return /* @__PURE__ */ React.createElement("div", null);
|
|
8
|
+
}
|
|
9
|
+
const WebSocketEndpoints = ({ refName, openAll }) => {
|
|
10
|
+
const sigRefs = getSignalRefsOnStorage(refName);
|
|
11
|
+
const tryRoles = st.use.tryRoles();
|
|
12
|
+
const gqlInfos = sigRefs.reduce(
|
|
13
|
+
(acc, sigRef) => [...acc, ...getGqlMetas(sigRef).map((gqlMeta) => ({ key: gqlMeta.key, gqlMeta, sigRef }))],
|
|
14
|
+
[]
|
|
15
|
+
).sort((a, b) => a.key > b.key ? 1 : -1).filter(({ gqlMeta }) => gqlMeta.signalOption.onlyFor !== "restapi").filter(({ gqlMeta }) => {
|
|
16
|
+
if (gqlMeta.type === "Query" || gqlMeta.type === "Mutation")
|
|
17
|
+
return false;
|
|
18
|
+
if (gqlMeta.guards.includes("Public") && tryRoles.includes("Public"))
|
|
19
|
+
return true;
|
|
20
|
+
if ((gqlMeta.guards.includes("User") || gqlMeta.guards.includes("Every")) && tryRoles.includes("User"))
|
|
21
|
+
return true;
|
|
22
|
+
if ((gqlMeta.guards.includes("Admin") || gqlMeta.guards.includes("Every")) && tryRoles.includes("Admin"))
|
|
23
|
+
return true;
|
|
24
|
+
if (gqlMeta.guards.includes("SuperAdmin") && tryRoles.includes("SuperAdmin"))
|
|
25
|
+
return true;
|
|
26
|
+
return false;
|
|
27
|
+
});
|
|
28
|
+
return /* @__PURE__ */ React.createElement("div", null, gqlInfos.map(({ gqlMeta, sigRef }, idx) => {
|
|
29
|
+
if (gqlMeta.type === "Pubsub") {
|
|
30
|
+
return /* @__PURE__ */ React.createElement(PubSub.Endpoint, { key: idx, sigRef, gqlMeta, open: openAll });
|
|
31
|
+
} else {
|
|
32
|
+
return /* @__PURE__ */ React.createElement(Message.Endpoint, { key: idx, sigRef, gqlMeta, open: openAll });
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
WebSocket.Endpoints = WebSocketEndpoints;
|
|
37
|
+
export {
|
|
38
|
+
WebSocket as default
|
|
39
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Arg from "./Arg";
|
|
2
|
+
import Doc from "./Doc";
|
|
3
|
+
import GraphQL from "./GraphQL";
|
|
4
|
+
import Listener from "./Listener";
|
|
5
|
+
import Message from "./Message";
|
|
6
|
+
import Object from "./Object";
|
|
7
|
+
import PubSub from "./PubSub";
|
|
8
|
+
import RestApi from "./RestApi";
|
|
9
|
+
import WebSocket from "./WebSocket";
|
|
10
|
+
const Signal = { Doc, Object, GraphQL, RestApi, Arg, Listener, WebSocket, PubSub, Message };
|
|
11
|
+
export {
|
|
12
|
+
Signal
|
|
13
|
+
};
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx, device, getPathInfo, router, useCsr } from "@akanjs/client";
|
|
3
|
+
import { usePushNoti } from "@akanjs/next";
|
|
4
|
+
import { st } from "@akanjs/store";
|
|
5
|
+
import { a } from "@react-spring/web";
|
|
6
|
+
import { useEffect } from "react";
|
|
7
|
+
import { createPortal } from "react-dom";
|
|
8
|
+
import { FontFace } from "../FontFace";
|
|
9
|
+
import { Load } from "../Load";
|
|
10
|
+
import { Client, ClientPathWrapper } from "./Client";
|
|
11
|
+
import { Common } from "./Common";
|
|
12
|
+
const CSR = ({ children }) => {
|
|
13
|
+
return /* @__PURE__ */ React.createElement("div", null);
|
|
14
|
+
};
|
|
15
|
+
const CSRProvider = ({
|
|
16
|
+
className,
|
|
17
|
+
appName,
|
|
18
|
+
params,
|
|
19
|
+
head,
|
|
20
|
+
env,
|
|
21
|
+
theme,
|
|
22
|
+
prefix,
|
|
23
|
+
usePage,
|
|
24
|
+
fetch,
|
|
25
|
+
children,
|
|
26
|
+
gaTrackingId,
|
|
27
|
+
fonts,
|
|
28
|
+
layoutStyle = "web",
|
|
29
|
+
of,
|
|
30
|
+
fetchPing,
|
|
31
|
+
fetchMe,
|
|
32
|
+
fetchSelf
|
|
33
|
+
}) => {
|
|
34
|
+
return /* @__PURE__ */ React.createElement(
|
|
35
|
+
Load.Page,
|
|
36
|
+
{
|
|
37
|
+
of,
|
|
38
|
+
loader: async () => {
|
|
39
|
+
const { lang } = await params;
|
|
40
|
+
return { lang };
|
|
41
|
+
},
|
|
42
|
+
render: ({ lang }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Client.Wrapper, { theme }, /* @__PURE__ */ React.createElement(
|
|
43
|
+
CSRWrapper,
|
|
44
|
+
{
|
|
45
|
+
className,
|
|
46
|
+
appName,
|
|
47
|
+
lang,
|
|
48
|
+
head,
|
|
49
|
+
fonts,
|
|
50
|
+
prefix,
|
|
51
|
+
layoutStyle
|
|
52
|
+
},
|
|
53
|
+
children,
|
|
54
|
+
/* @__PURE__ */ React.createElement(Client.Inner, null),
|
|
55
|
+
/* @__PURE__ */ React.createElement(CSRInner, null)
|
|
56
|
+
)), /* @__PURE__ */ React.createElement(
|
|
57
|
+
Common.Wrapper,
|
|
58
|
+
{
|
|
59
|
+
fetch,
|
|
60
|
+
environment: env.environment,
|
|
61
|
+
fetchPing,
|
|
62
|
+
fetchMe,
|
|
63
|
+
fetchSelf,
|
|
64
|
+
render: ({ mePromise, selfPromise }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
65
|
+
Client.Bridge,
|
|
66
|
+
{
|
|
67
|
+
lang,
|
|
68
|
+
env,
|
|
69
|
+
mePromise,
|
|
70
|
+
selfPromise,
|
|
71
|
+
theme,
|
|
72
|
+
prefix,
|
|
73
|
+
gaTrackingId
|
|
74
|
+
}
|
|
75
|
+
), /* @__PURE__ */ React.createElement(CSRBridge, { lang, prefix }))
|
|
76
|
+
}
|
|
77
|
+
))
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
CSR.Provider = CSRProvider;
|
|
82
|
+
const CSRWrapper = ({
|
|
83
|
+
children,
|
|
84
|
+
lang,
|
|
85
|
+
head,
|
|
86
|
+
fonts = [],
|
|
87
|
+
appName,
|
|
88
|
+
className,
|
|
89
|
+
prefix,
|
|
90
|
+
layoutStyle = "web"
|
|
91
|
+
}) => {
|
|
92
|
+
const {
|
|
93
|
+
frameRootRef,
|
|
94
|
+
topSafeAreaRef,
|
|
95
|
+
bottomSafeAreaRef,
|
|
96
|
+
topInset,
|
|
97
|
+
topLeftAction,
|
|
98
|
+
bottomInset,
|
|
99
|
+
topSafeArea,
|
|
100
|
+
bottomSafeArea,
|
|
101
|
+
pathRoutes
|
|
102
|
+
} = useCsr();
|
|
103
|
+
const csrLoaded = st.use.csrLoaded();
|
|
104
|
+
const { router: reactRouter } = useCsr();
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (!router.isInitialized)
|
|
107
|
+
router.init({ type: "csr", lang, prefix, router: reactRouter });
|
|
108
|
+
st.do.setCsrLoaded(true);
|
|
109
|
+
}, []);
|
|
110
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, fonts.map((font, idx) => /* @__PURE__ */ React.createElement(FontFace, { key: idx, font })), /* @__PURE__ */ React.createElement(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
id: "frameRoot",
|
|
114
|
+
className: clsx(className, "h-screen w-full overflow-hidden", {
|
|
115
|
+
"bg-base-200": layoutStyle === "mobile"
|
|
116
|
+
}),
|
|
117
|
+
ref: frameRootRef
|
|
118
|
+
},
|
|
119
|
+
/* @__PURE__ */ React.createElement("div", { id: "pageContainers", className: "isolate" }),
|
|
120
|
+
csrLoaded ? pathRoutes.map((pathRoute) => /* @__PURE__ */ React.createElement(CSRPageContainer, { key: pathRoute.path, pathRoute, prefix, layoutStyle })) : null,
|
|
121
|
+
/* @__PURE__ */ React.createElement(
|
|
122
|
+
a.div,
|
|
123
|
+
{
|
|
124
|
+
id: "topSafeArea",
|
|
125
|
+
className: clsx("bg-base-100 fixed inset-x-0 top-0", {}),
|
|
126
|
+
ref: topSafeAreaRef,
|
|
127
|
+
style: topSafeArea?.containerStyle
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
/* @__PURE__ */ React.createElement(
|
|
131
|
+
a.div,
|
|
132
|
+
{
|
|
133
|
+
id: "topInsetContainer",
|
|
134
|
+
className: clsx("bg-base-100 fixed inset-x-0 isolate", {}),
|
|
135
|
+
style: topInset?.containerStyle
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
/* @__PURE__ */ React.createElement(
|
|
139
|
+
a.div,
|
|
140
|
+
{
|
|
141
|
+
id: "topLeftActionContainer",
|
|
142
|
+
className: clsx("aspect-1 absolute top-0 isolate flex items-center justify-center", {}),
|
|
143
|
+
style: topLeftAction?.containerStyle
|
|
144
|
+
}
|
|
145
|
+
),
|
|
146
|
+
/* @__PURE__ */ React.createElement(
|
|
147
|
+
a.div,
|
|
148
|
+
{
|
|
149
|
+
id: "bottomInsetContainer",
|
|
150
|
+
className: clsx("fixed inset-x-0 isolate", {}),
|
|
151
|
+
style: bottomInset?.containerStyle
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
/* @__PURE__ */ React.createElement(
|
|
155
|
+
a.div,
|
|
156
|
+
{
|
|
157
|
+
id: "bottomSafeArea",
|
|
158
|
+
className: "bg-base-100 fixed inset-x-0",
|
|
159
|
+
ref: bottomSafeAreaRef,
|
|
160
|
+
style: bottomSafeArea?.containerStyle
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
));
|
|
164
|
+
};
|
|
165
|
+
CSR.Wrapper = CSRWrapper;
|
|
166
|
+
const CSRInner = () => {
|
|
167
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null);
|
|
168
|
+
};
|
|
169
|
+
CSR.Inner = CSRInner;
|
|
170
|
+
const CSRBridge = ({ lang, prefix = "" }) => {
|
|
171
|
+
const pushNoti = usePushNoti();
|
|
172
|
+
const { location, pageContentRef } = useCsr();
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
const { path, pathname } = getPathInfo(location.pathname, lang, prefix);
|
|
175
|
+
st.do.set({
|
|
176
|
+
params: location.params,
|
|
177
|
+
searchParams: location.searchParams,
|
|
178
|
+
pageState: location.pathRoute.pageState,
|
|
179
|
+
pathname,
|
|
180
|
+
path
|
|
181
|
+
});
|
|
182
|
+
}, [location]);
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
device.listenKeyboardChanged(st.do.setKeyboardHeight);
|
|
185
|
+
device.setPageContentRef(pageContentRef);
|
|
186
|
+
if (device.info.platform === "web")
|
|
187
|
+
return;
|
|
188
|
+
void (async () => {
|
|
189
|
+
await pushNoti.init();
|
|
190
|
+
const token = await pushNoti.getToken();
|
|
191
|
+
if (!token)
|
|
192
|
+
return;
|
|
193
|
+
st.do.setDeviceToken(token);
|
|
194
|
+
})();
|
|
195
|
+
return () => {
|
|
196
|
+
device.unlistenKeyboardChanged();
|
|
197
|
+
};
|
|
198
|
+
}, []);
|
|
199
|
+
return null;
|
|
200
|
+
};
|
|
201
|
+
CSR.Bridge = CSRBridge;
|
|
202
|
+
const CSRPageContainer = ({ pathRoute, prefix, layoutStyle }) => {
|
|
203
|
+
const {
|
|
204
|
+
history,
|
|
205
|
+
location: currentLocation,
|
|
206
|
+
page: currentPage,
|
|
207
|
+
pageContentRef: currentPageContentRef,
|
|
208
|
+
pageClassName: currentPageClassName,
|
|
209
|
+
pageBind: currentPageBind,
|
|
210
|
+
prevLocation,
|
|
211
|
+
prevPage,
|
|
212
|
+
prevPageContentRef,
|
|
213
|
+
topInset,
|
|
214
|
+
bottomInset,
|
|
215
|
+
topLeftAction
|
|
216
|
+
} = useCsr();
|
|
217
|
+
const pageType = pathRoute === currentLocation.pathRoute ? "current" : pathRoute === prevLocation?.pathRoute ? "prev" : pathRoute.pageState.cache && history.current.cachedLocationMap.has(pathRoute.path) ? "cached" : null;
|
|
218
|
+
if (!pageType)
|
|
219
|
+
return null;
|
|
220
|
+
const pageContainers = document.getElementById("pageContainers");
|
|
221
|
+
const topInsetContainer = document.getElementById("topInsetContainer");
|
|
222
|
+
const bottomInsetContainer = document.getElementById("bottomInsetContainer");
|
|
223
|
+
const topLeftActionContainer = document.getElementById("topLeftActionContainer");
|
|
224
|
+
if (!pageContainers || !topInsetContainer || !bottomInsetContainer || !topLeftActionContainer)
|
|
225
|
+
return null;
|
|
226
|
+
const {
|
|
227
|
+
location,
|
|
228
|
+
page,
|
|
229
|
+
pageContentRef,
|
|
230
|
+
pageClassName,
|
|
231
|
+
pageBind,
|
|
232
|
+
topInsetContentStyle,
|
|
233
|
+
topLeftActionContentStyle,
|
|
234
|
+
bottomInsetContentStyle,
|
|
235
|
+
zIndex
|
|
236
|
+
} = pageType === "current" ? {
|
|
237
|
+
location: currentLocation,
|
|
238
|
+
page: currentPage,
|
|
239
|
+
pageContentRef: currentPageContentRef,
|
|
240
|
+
pageClassName: currentPageClassName,
|
|
241
|
+
pageBind: currentPageBind,
|
|
242
|
+
topInsetContentStyle: topInset?.contentStyle,
|
|
243
|
+
topLeftActionContentStyle: topLeftAction?.contentStyle,
|
|
244
|
+
bottomInsetContentStyle: bottomInset?.contentStyle,
|
|
245
|
+
zIndex: history.current.idx
|
|
246
|
+
} : pageType === "prev" ? {
|
|
247
|
+
location: prevLocation,
|
|
248
|
+
page: prevPage,
|
|
249
|
+
pageContentRef: prevPageContentRef,
|
|
250
|
+
pageClassName: "",
|
|
251
|
+
pageBind: () => ({}),
|
|
252
|
+
topInsetContentStyle: topInset?.prevContentStyle,
|
|
253
|
+
topLeftActionContentStyle: topLeftAction?.prevContentStyle,
|
|
254
|
+
bottomInsetContentStyle: bottomInset?.prevContentStyle,
|
|
255
|
+
zIndex: history.current.idxMap.get(prevLocation?.pathname ?? "") ?? 0
|
|
256
|
+
} : {
|
|
257
|
+
location: history.current.cachedLocationMap.get(pathRoute.path),
|
|
258
|
+
page: null,
|
|
259
|
+
pageContentRef: null,
|
|
260
|
+
pageClassName: "",
|
|
261
|
+
pageBind: () => ({}),
|
|
262
|
+
topInsetContentStyle: void 0,
|
|
263
|
+
topLeftActionContentStyle: void 0,
|
|
264
|
+
bottomInsetContentStyle: void 0,
|
|
265
|
+
zIndex: 0
|
|
266
|
+
};
|
|
267
|
+
if (!location)
|
|
268
|
+
return null;
|
|
269
|
+
const Page = pathRoute.Page;
|
|
270
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, createPortal(
|
|
271
|
+
/* @__PURE__ */ React.createElement(
|
|
272
|
+
a.div,
|
|
273
|
+
{
|
|
274
|
+
id: `pageContainer-${pathRoute.path}`,
|
|
275
|
+
style: { ...page?.containerStyle ?? {}, zIndex },
|
|
276
|
+
className: clsx("absolute top-0 left-0 isolate w-screen", {
|
|
277
|
+
absolute: pageType !== "current",
|
|
278
|
+
hidden: pageType === "cached"
|
|
279
|
+
})
|
|
280
|
+
},
|
|
281
|
+
/* @__PURE__ */ React.createElement(
|
|
282
|
+
ClientPathWrapper,
|
|
283
|
+
{
|
|
284
|
+
id: "pageContent",
|
|
285
|
+
wrapperRef: pageContentRef,
|
|
286
|
+
bind: pageBind,
|
|
287
|
+
className: clsx("bg-base-100 relative isolate w-full overflow-x-hidden shadow-inner", {
|
|
288
|
+
"bg-base-100 relative isolate overflow-x-hidden shadow-inner": pageType === "current",
|
|
289
|
+
"isolate h-screen w-screen overflow-hidden": pageType === "prev",
|
|
290
|
+
[pageClassName]: pathRoute.pageState.gesture
|
|
291
|
+
}),
|
|
292
|
+
style: page?.contentStyle,
|
|
293
|
+
pageType,
|
|
294
|
+
location,
|
|
295
|
+
prefix
|
|
296
|
+
},
|
|
297
|
+
pathRoute.Layouts.reduceRight(
|
|
298
|
+
(children, Layout) => {
|
|
299
|
+
return /* @__PURE__ */ React.createElement(Layout, { params: location.params, searchParams: location.searchParams }, children);
|
|
300
|
+
},
|
|
301
|
+
/* @__PURE__ */ React.createElement(Page, { params: location.params, searchParams: location.searchParams })
|
|
302
|
+
)
|
|
303
|
+
)
|
|
304
|
+
),
|
|
305
|
+
pageContainers
|
|
306
|
+
), createPortal(
|
|
307
|
+
/* @__PURE__ */ React.createElement(
|
|
308
|
+
ClientPathWrapper,
|
|
309
|
+
{
|
|
310
|
+
id: `topInsetContent-${pathRoute.path}`,
|
|
311
|
+
className: clsx("absolute top-0 left-0 isolate size-full", { hidden: pageType === "cached" }),
|
|
312
|
+
style: { ...topInsetContentStyle, zIndex },
|
|
313
|
+
pageType,
|
|
314
|
+
location,
|
|
315
|
+
prefix
|
|
316
|
+
}
|
|
317
|
+
),
|
|
318
|
+
topInsetContainer
|
|
319
|
+
), createPortal(
|
|
320
|
+
/* @__PURE__ */ React.createElement(
|
|
321
|
+
ClientPathWrapper,
|
|
322
|
+
{
|
|
323
|
+
id: `topLeftActionContent-${pathRoute.path}`,
|
|
324
|
+
className: clsx("absolute left-0 isolate flex h-full items-center justify-center", {
|
|
325
|
+
hidden: pageType === "cached"
|
|
326
|
+
}),
|
|
327
|
+
style: { ...topLeftActionContentStyle, zIndex },
|
|
328
|
+
pageType,
|
|
329
|
+
location,
|
|
330
|
+
prefix
|
|
331
|
+
}
|
|
332
|
+
),
|
|
333
|
+
topLeftActionContainer
|
|
334
|
+
), createPortal(
|
|
335
|
+
/* @__PURE__ */ React.createElement(
|
|
336
|
+
ClientPathWrapper,
|
|
337
|
+
{
|
|
338
|
+
id: `bottomInsetContent-${pathRoute.path}`,
|
|
339
|
+
className: clsx("bottom-0 isolate size-full", {
|
|
340
|
+
hidden: pageType === "cached",
|
|
341
|
+
absolute: pageType === "prev",
|
|
342
|
+
relative: pageType === "current"
|
|
343
|
+
}),
|
|
344
|
+
style: { ...bottomInsetContentStyle, zIndex },
|
|
345
|
+
pageType,
|
|
346
|
+
location,
|
|
347
|
+
prefix
|
|
348
|
+
}
|
|
349
|
+
),
|
|
350
|
+
bottomInsetContainer
|
|
351
|
+
));
|
|
352
|
+
};
|
|
353
|
+
var CSR_default = CSRProvider;
|
|
354
|
+
export {
|
|
355
|
+
CSR,
|
|
356
|
+
CSR_default as default
|
|
357
|
+
};
|