@akanjs/ui 0.0.150 → 0.0.152
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 +37 -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 +31 -0
- package/Signal/Listener.d.ts +9 -0
- package/Signal/Message.d.ts +26 -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 +39 -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 +109 -0
- package/cjs/Button.js +71 -0
- package/cjs/ClientSide.js +27 -0
- package/cjs/Copy.js +38 -0
- package/cjs/CsrImage.js +51 -0
- package/cjs/Data/CardList.js +127 -0
- package/cjs/Data/Dashboard.js +64 -0
- package/cjs/Data/Insight.js +42 -0
- package/cjs/Data/Item.js +219 -0
- package/cjs/Data/ListContainer.js +285 -0
- package/cjs/Data/Pagination.js +65 -0
- package/cjs/Data/QueryMaker.js +326 -0
- package/cjs/Data/TableList.js +150 -0
- package/cjs/Data/index.js +33 -0
- package/cjs/Data/index_.js +49 -0
- package/cjs/DatePicker.js +178 -0
- package/cjs/Dialog/Action.js +32 -0
- package/cjs/Dialog/Close.js +39 -0
- package/cjs/Dialog/Content.js +28 -0
- package/cjs/Dialog/Modal.js +166 -0
- package/cjs/Dialog/Provider.js +47 -0
- package/cjs/Dialog/Title.js +32 -0
- package/cjs/Dialog/Trigger.js +39 -0
- package/cjs/Dialog/context.js +32 -0
- package/cjs/Dialog/index.js +37 -0
- package/cjs/DragAction.js +112 -0
- package/cjs/DraggableList.js +142 -0
- package/cjs/Dropdown.js +67 -0
- package/cjs/Empty.js +45 -0
- package/cjs/Field.js +1231 -0
- package/cjs/FontFace.js +77 -0
- package/cjs/Image.js +62 -0
- package/cjs/InfiniteScroll.js +70 -0
- package/cjs/Input.js +457 -0
- package/cjs/KeyboardAvoiding.js +66 -0
- package/cjs/Layout/BottomAction.js +27 -0
- package/cjs/Layout/BottomInset.js +54 -0
- package/cjs/Layout/BottomTab.js +62 -0
- package/cjs/Layout/Header.js +56 -0
- package/cjs/Layout/LeftSider.js +52 -0
- package/cjs/Layout/Navbar.js +45 -0
- package/cjs/Layout/RightSider.js +58 -0
- package/cjs/Layout/Sider.js +52 -0
- package/cjs/Layout/Template.js +27 -0
- package/cjs/Layout/TopLeftAction.js +40 -0
- package/cjs/Layout/Unit.js +28 -0
- package/cjs/Layout/View.js +27 -0
- package/cjs/Layout/Zone.js +27 -0
- package/cjs/Layout/index.js +48 -0
- package/cjs/Link/Back.js +28 -0
- package/cjs/Link/Close.js +37 -0
- package/cjs/Link/CsrLink.js +50 -0
- package/cjs/Link/NextLink.js +72 -0
- package/cjs/Link/index.js +48 -0
- package/cjs/{src/index.js → Link/types.js} +2 -10
- package/cjs/Load/Edit.js +43 -0
- package/cjs/Load/Edit_Client.js +94 -0
- package/cjs/Load/Page.js +35 -0
- package/cjs/Load/PageCSR.js +68 -0
- package/cjs/Load/Pagination.js +90 -0
- package/cjs/Load/Units.js +239 -0
- package/cjs/Load/View.js +89 -0
- package/cjs/Load/index.js +42 -0
- package/cjs/Load/index_.js +39 -0
- package/cjs/Loading/Area.js +29 -0
- package/cjs/Loading/Button.js +34 -0
- package/cjs/Loading/Input.js +34 -0
- package/cjs/Loading/ProgressBar.js +30 -0
- package/cjs/Loading/Skeleton.js +33 -0
- package/cjs/Loading/Spin.js +28 -0
- package/cjs/Loading/index.js +29 -0
- package/cjs/Menu.js +231 -0
- package/cjs/Modal.js +88 -0
- package/cjs/Model/Edit.js +67 -0
- package/cjs/Model/EditModal.js +253 -0
- package/cjs/Model/EditWrapper.js +49 -0
- package/cjs/Model/LoadInit.js +28 -0
- package/cjs/Model/New.js +67 -0
- package/cjs/Model/NewWrapper.js +29 -0
- package/cjs/Model/NewWrapper_Client.js +67 -0
- package/cjs/Model/Remove.js +92 -0
- package/cjs/Model/RemoveWrapper.js +49 -0
- package/cjs/Model/SureToRemove.js +125 -0
- package/cjs/Model/View.js +54 -0
- package/cjs/Model/ViewEditModal.js +129 -0
- package/cjs/Model/ViewModal.js +93 -0
- package/cjs/Model/ViewWrapper.js +49 -0
- package/cjs/Model/index.js +38 -0
- package/cjs/Model/index_.js +58 -0
- package/cjs/More.js +71 -0
- package/cjs/ObjectId.js +41 -0
- package/cjs/Pagination.js +115 -0
- package/cjs/Popconfirm.js +124 -0
- package/cjs/Portal.js +27 -0
- package/cjs/Radio.js +57 -0
- package/cjs/RecentTime.js +87 -0
- package/cjs/Refresh.js +46 -0
- package/cjs/ScreenNavigator.js +122 -0
- package/cjs/Select.js +283 -0
- package/cjs/Signal/Arg.js +277 -0
- package/cjs/Signal/Doc.js +258 -0
- package/cjs/Signal/GraphQL.js +261 -0
- package/cjs/Signal/Listener.js +66 -0
- package/cjs/Signal/Message.js +276 -0
- package/cjs/Signal/Object.js +131 -0
- package/cjs/Signal/PubSub.js +273 -0
- package/cjs/Signal/Request.js +45 -0
- package/cjs/Signal/Response.js +66 -0
- package/cjs/Signal/RestApi.js +357 -0
- package/cjs/Signal/WebSocket.js +69 -0
- package/cjs/Signal/index.js +42 -0
- package/cjs/System/CSR.js +395 -0
- package/cjs/System/Client.js +204 -0
- package/cjs/System/Common.js +68 -0
- package/cjs/System/DevModeToggle.js +42 -0
- package/cjs/System/Gtag.js +71 -0
- package/cjs/System/HealthCheck.js +61 -0
- package/cjs/System/Messages.js +173 -0
- package/cjs/System/Reconnect.js +86 -0
- package/cjs/System/Root.js +31 -0
- package/cjs/System/SSR.js +162 -0
- package/cjs/System/SelectLanguage.js +62 -0
- package/cjs/System/ThemeToggle.js +44 -0
- package/cjs/System/index.js +56 -0
- package/cjs/Tab/Menu.js +71 -0
- package/cjs/Tab/Menus.js +27 -0
- package/cjs/Tab/Panel.js +43 -0
- package/cjs/Tab/Provider.js +32 -0
- package/cjs/Tab/context.js +30 -0
- package/cjs/Tab/index.js +33 -0
- package/cjs/Table.js +84 -0
- package/cjs/ToggleSelect.js +123 -0
- package/cjs/Unauthorized.js +45 -0
- package/cjs/index.js +88 -2
- package/esm/BottomSheet.js +90 -0
- package/esm/Button.js +52 -0
- package/esm/ClientSide.js +8 -0
- package/esm/Copy.js +19 -0
- package/esm/CsrImage.js +32 -0
- package/esm/Data/CardList.js +98 -0
- package/esm/Data/Dashboard.js +45 -0
- package/esm/Data/Insight.js +23 -0
- package/esm/Data/Item.js +200 -0
- package/esm/Data/ListContainer.js +262 -0
- package/esm/Data/Pagination.js +46 -0
- package/esm/Data/QueryMaker.js +315 -0
- package/esm/Data/TableList.js +121 -0
- package/esm/Data/index.js +14 -0
- package/esm/Data/index_.js +20 -0
- package/esm/DatePicker.js +149 -0
- package/esm/Dialog/Action.js +13 -0
- package/esm/Dialog/Close.js +20 -0
- package/esm/Dialog/Content.js +9 -0
- package/esm/Dialog/Modal.js +137 -0
- package/esm/Dialog/Provider.js +18 -0
- package/esm/Dialog/Title.js +13 -0
- package/esm/Dialog/Trigger.js +20 -0
- package/esm/Dialog/context.js +13 -0
- package/esm/Dialog/index.js +18 -0
- package/esm/DragAction.js +93 -0
- package/esm/DraggableList.js +113 -0
- package/esm/Dropdown.js +48 -0
- package/esm/Empty.js +26 -0
- package/esm/Field.js +1212 -0
- package/esm/FontFace.js +58 -0
- package/esm/Image.js +33 -0
- package/esm/InfiniteScroll.js +51 -0
- package/esm/Input.js +442 -0
- package/esm/KeyboardAvoiding.js +47 -0
- package/esm/Layout/BottomAction.js +8 -0
- package/esm/Layout/BottomInset.js +35 -0
- package/esm/Layout/BottomTab.js +43 -0
- package/esm/Layout/Header.js +37 -0
- package/esm/Layout/LeftSider.js +33 -0
- package/esm/Layout/Navbar.js +26 -0
- package/esm/Layout/RightSider.js +39 -0
- package/esm/Layout/Sider.js +33 -0
- package/esm/Layout/Template.js +8 -0
- package/esm/Layout/TopLeftAction.js +21 -0
- package/esm/Layout/Unit.js +9 -0
- package/esm/Layout/View.js +8 -0
- package/esm/Layout/Zone.js +8 -0
- package/esm/Layout/index.js +29 -0
- package/esm/Link/Back.js +9 -0
- package/esm/Link/Close.js +18 -0
- package/esm/Link/CsrLink.js +31 -0
- package/esm/Link/NextLink.js +43 -0
- package/esm/Link/index.js +19 -0
- package/esm/Link/types.js +0 -0
- package/esm/Load/Edit.js +14 -0
- package/esm/Load/Edit_Client.js +75 -0
- package/esm/Load/Page.js +16 -0
- package/esm/Load/PageCSR.js +49 -0
- package/esm/Load/Pagination.js +71 -0
- package/esm/Load/Units.js +220 -0
- package/esm/Load/View.js +70 -0
- package/esm/Load/index.js +13 -0
- package/esm/Load/index_.js +10 -0
- package/esm/Loading/Area.js +10 -0
- package/esm/Loading/Button.js +15 -0
- package/esm/Loading/Input.js +15 -0
- package/esm/Loading/ProgressBar.js +11 -0
- package/esm/Loading/Skeleton.js +14 -0
- package/esm/Loading/Spin.js +9 -0
- package/esm/Loading/index.js +10 -0
- package/esm/Menu.js +212 -0
- package/esm/Modal.js +59 -0
- package/esm/Model/Edit.js +38 -0
- package/esm/Model/EditModal.js +234 -0
- package/esm/Model/EditWrapper.js +30 -0
- package/esm/Model/LoadInit.js +9 -0
- package/esm/Model/New.js +38 -0
- package/esm/Model/NewWrapper.js +10 -0
- package/esm/Model/NewWrapper_Client.js +48 -0
- package/esm/Model/Remove.js +73 -0
- package/esm/Model/RemoveWrapper.js +30 -0
- package/esm/Model/SureToRemove.js +106 -0
- package/esm/Model/View.js +35 -0
- package/esm/Model/ViewEditModal.js +100 -0
- package/esm/Model/ViewModal.js +64 -0
- package/esm/Model/ViewWrapper.js +30 -0
- package/esm/Model/index.js +33 -0
- package/esm/Model/index_.js +29 -0
- package/esm/More.js +42 -0
- package/esm/ObjectId.js +22 -0
- package/esm/Pagination.js +96 -0
- package/esm/Popconfirm.js +105 -0
- package/esm/Portal.js +8 -0
- package/esm/Radio.js +38 -0
- package/esm/RecentTime.js +58 -0
- package/esm/Refresh.js +17 -0
- package/esm/ScreenNavigator.js +103 -0
- package/esm/Select.js +264 -0
- package/esm/Signal/Arg.js +248 -0
- package/esm/Signal/Doc.js +229 -0
- package/esm/Signal/GraphQL.js +240 -0
- package/esm/Signal/Listener.js +47 -0
- package/esm/Signal/Message.js +247 -0
- package/esm/Signal/Object.js +112 -0
- package/esm/Signal/PubSub.js +244 -0
- package/esm/Signal/Request.js +26 -0
- package/esm/Signal/Response.js +47 -0
- package/esm/Signal/RestApi.js +336 -0
- package/esm/Signal/WebSocket.js +40 -0
- package/esm/Signal/index.js +13 -0
- package/esm/System/CSR.js +376 -0
- package/esm/System/Client.js +195 -0
- package/esm/System/Common.js +49 -0
- package/esm/System/DevModeToggle.js +23 -0
- package/esm/System/Gtag.js +52 -0
- package/esm/System/HealthCheck.js +42 -0
- package/esm/System/Messages.js +159 -0
- package/esm/System/Reconnect.js +67 -0
- package/esm/System/Root.js +12 -0
- package/esm/System/SSR.js +143 -0
- package/esm/System/SelectLanguage.js +43 -0
- package/esm/System/ThemeToggle.js +25 -0
- package/esm/System/index.js +27 -0
- package/esm/Tab/Menu.js +52 -0
- package/esm/Tab/Menus.js +8 -0
- package/esm/Tab/Panel.js +24 -0
- package/esm/Tab/Provider.js +13 -0
- package/esm/Tab/context.js +11 -0
- package/esm/Tab/index.js +14 -0
- package/esm/Table.js +65 -0
- package/esm/ToggleSelect.js +104 -0
- package/esm/Unauthorized.js +26 -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
package/esm/Refresh.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { BiLoaderAlt } from "react-icons/bi";
|
|
4
|
+
import PullToRefresh from "react-simple-pull-to-refresh";
|
|
5
|
+
const Refresh = ({ children, onRefresh }) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
PullToRefresh,
|
|
8
|
+
{
|
|
9
|
+
onRefresh,
|
|
10
|
+
refreshingContent: /* @__PURE__ */ jsx("div", { className: "bg-base-100 fixed left-1/2 flex size-10 -translate-x-1/2 items-center justify-center rounded-full shadow-sm", children: /* @__PURE__ */ jsx(BiLoaderAlt, { className: "animate-spin text-2xl" }) }),
|
|
11
|
+
children
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
Refresh
|
|
17
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { clsx } from "@akanjs/client";
|
|
4
|
+
import { useDrag } from "@use-gesture/react";
|
|
5
|
+
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
6
|
+
import { a, SpringValue, useSpringValue } from "react-spring";
|
|
7
|
+
const ScreenNavigatorContext = createContext({
|
|
8
|
+
bind: () => ({}),
|
|
9
|
+
xValue: new SpringValue(0),
|
|
10
|
+
setMenu: null,
|
|
11
|
+
onClickMenu: null,
|
|
12
|
+
currentMenu: "",
|
|
13
|
+
menus: []
|
|
14
|
+
});
|
|
15
|
+
const ScreenNavigator = ({
|
|
16
|
+
children,
|
|
17
|
+
setMenu = () => {
|
|
18
|
+
},
|
|
19
|
+
menus
|
|
20
|
+
}) => {
|
|
21
|
+
const [currentMenu, setCurrentMenu] = useState(menus[0]);
|
|
22
|
+
const xValue = useSpringValue(0, { config: { clamp: true } });
|
|
23
|
+
const ref = useRef(null);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!ref.current)
|
|
26
|
+
return;
|
|
27
|
+
const deviceWidth = ref.current.clientWidth / 2;
|
|
28
|
+
if (currentMenu === menus[1])
|
|
29
|
+
xValue.set(-deviceWidth);
|
|
30
|
+
else
|
|
31
|
+
xValue.set(0);
|
|
32
|
+
}, []);
|
|
33
|
+
const bind = useDrag(
|
|
34
|
+
({ first, last, offset: [x], velocity: [vx], direction: [dx], movement: [mx], cancel }) => {
|
|
35
|
+
if (!ref.current)
|
|
36
|
+
return;
|
|
37
|
+
//! 메뉴가 3개 이상일 경우 고려해야함
|
|
38
|
+
const deviceWidth = ref.current.clientWidth / 2;
|
|
39
|
+
if (x > 0 || x < -deviceWidth)
|
|
40
|
+
return;
|
|
41
|
+
if (dx < 1) {
|
|
42
|
+
if (x > -deviceWidth / 2) {
|
|
43
|
+
void xValue.start(x);
|
|
44
|
+
} else {
|
|
45
|
+
void xValue.start(-deviceWidth);
|
|
46
|
+
setCurrentMenu(menus[1]);
|
|
47
|
+
setMenu(menus[1]);
|
|
48
|
+
}
|
|
49
|
+
if (last && x > -deviceWidth / 2) {
|
|
50
|
+
void xValue.start(0);
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
if (x > -deviceWidth / 2) {
|
|
54
|
+
void xValue.start(0);
|
|
55
|
+
setCurrentMenu(menus[0]);
|
|
56
|
+
setMenu(menus[0]);
|
|
57
|
+
} else {
|
|
58
|
+
void xValue.start(x);
|
|
59
|
+
}
|
|
60
|
+
if (last && x < -deviceWidth / 2) {
|
|
61
|
+
void xValue.start(-deviceWidth);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{ axis: "x", filterTaps: true, threshold: 10 }
|
|
66
|
+
);
|
|
67
|
+
const onClickMenu = (menu) => {
|
|
68
|
+
if (!ref.current)
|
|
69
|
+
return;
|
|
70
|
+
const deviceWidth = ref.current.clientWidth / 2;
|
|
71
|
+
if (menu === menus[0]) {
|
|
72
|
+
void xValue.start(0);
|
|
73
|
+
setMenu(menus[0]);
|
|
74
|
+
setCurrentMenu(menus[0]);
|
|
75
|
+
} else {
|
|
76
|
+
void xValue.start(-deviceWidth);
|
|
77
|
+
setMenu(menus[1]);
|
|
78
|
+
setCurrentMenu(menus[1]);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return /* @__PURE__ */ jsx(ScreenNavigatorContext.Provider, { value: { bind, xValue, onClickMenu, menus, currentMenu, setMenu }, children: /* @__PURE__ */ jsx(a.div, { ...bind(), className: "flex h-full w-[200vw] overflow-x-scroll", style: { x: xValue }, ref, children }) });
|
|
82
|
+
};
|
|
83
|
+
const NavbarItem = ({ menu, children, className }) => {
|
|
84
|
+
const { onClickMenu, currentMenu } = useContext(ScreenNavigatorContext);
|
|
85
|
+
return /* @__PURE__ */ jsx(
|
|
86
|
+
"div",
|
|
87
|
+
{
|
|
88
|
+
className: clsx(className, currentMenu === menu ? "opacity-100" : "opacity-40"),
|
|
89
|
+
onClick: () => {
|
|
90
|
+
onClickMenu(menu);
|
|
91
|
+
},
|
|
92
|
+
children
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
ScreenNavigator.NavbarItem = NavbarItem;
|
|
97
|
+
const Screen = ({ children }) => {
|
|
98
|
+
return /* @__PURE__ */ jsx("div", { className: "h-full w-screen overflow-scroll", style: { touchAction: "pan-y" }, children });
|
|
99
|
+
};
|
|
100
|
+
ScreenNavigator.Screen = Screen;
|
|
101
|
+
export {
|
|
102
|
+
ScreenNavigator
|
|
103
|
+
};
|
package/esm/Select.js
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Enum } from "@akanjs/base";
|
|
4
|
+
import { clsx } from "@akanjs/client";
|
|
5
|
+
import { useDebounce, usePage } from "@akanjs/next";
|
|
6
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
+
import { BiCheck, BiChevronDown, BiX } from "react-icons/bi";
|
|
8
|
+
import { BsQuestionCircleFill } from "react-icons/bs";
|
|
9
|
+
import { TiDelete } from "react-icons/ti";
|
|
10
|
+
const Select = ({
|
|
11
|
+
label,
|
|
12
|
+
desc,
|
|
13
|
+
labelClassName,
|
|
14
|
+
className,
|
|
15
|
+
value,
|
|
16
|
+
options,
|
|
17
|
+
nullable,
|
|
18
|
+
disabled,
|
|
19
|
+
multiple,
|
|
20
|
+
searchable,
|
|
21
|
+
placeholder,
|
|
22
|
+
selectClassName,
|
|
23
|
+
selectorClassName,
|
|
24
|
+
selectedClassName,
|
|
25
|
+
onOpen,
|
|
26
|
+
onChange,
|
|
27
|
+
onSearch,
|
|
28
|
+
renderOption,
|
|
29
|
+
renderSelected
|
|
30
|
+
}) => {
|
|
31
|
+
const { l } = usePage();
|
|
32
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
33
|
+
const labeledOptions = useMemo(
|
|
34
|
+
() => options instanceof Enum ? options.values.map((v) => ({ label: v, value: v })) : options[0]?.label && options[0]?.value ? options : options.map((v) => ({ label: v, value: v })),
|
|
35
|
+
[options]
|
|
36
|
+
);
|
|
37
|
+
const [selectedValues, setSelectedValues] = useState(multiple ? value : [value]);
|
|
38
|
+
const [searchText, setSearchText] = useState("");
|
|
39
|
+
const [searchOptions, setSearchOptions] = useState(labeledOptions);
|
|
40
|
+
const dropdownRef = useRef(null);
|
|
41
|
+
const selected = (v) => {
|
|
42
|
+
if (multiple)
|
|
43
|
+
return selectedValues.includes(v);
|
|
44
|
+
return v === selectedValues[0];
|
|
45
|
+
};
|
|
46
|
+
const handleClickOutside = (event) => {
|
|
47
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
48
|
+
setIsOpen(false);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const onSelect = (v, index) => {
|
|
52
|
+
if (multiple) {
|
|
53
|
+
if (selectedValues.includes(v)) {
|
|
54
|
+
setSelectedValues(selectedValues.filter((rev) => rev !== v));
|
|
55
|
+
onChange(
|
|
56
|
+
selectedValues.filter((rev) => rev !== v),
|
|
57
|
+
selectedValues
|
|
58
|
+
);
|
|
59
|
+
} else {
|
|
60
|
+
setSelectedValues([...selectedValues, v]);
|
|
61
|
+
onChange([...selectedValues, v], selectedValues);
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
setSelectedValues([v]);
|
|
65
|
+
onChange(v, selectedValues[0]);
|
|
66
|
+
setIsOpen(false);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const debouncedOnSearch = useDebounce(
|
|
70
|
+
(text) => {
|
|
71
|
+
onSearch?.(text);
|
|
72
|
+
},
|
|
73
|
+
[searchText],
|
|
74
|
+
300
|
|
75
|
+
);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (isOpen)
|
|
78
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
79
|
+
else
|
|
80
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
81
|
+
return () => {
|
|
82
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
83
|
+
};
|
|
84
|
+
}, [isOpen]);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
setSearchOptions(labeledOptions);
|
|
87
|
+
}, [labeledOptions]);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (isOpen)
|
|
90
|
+
onOpen?.();
|
|
91
|
+
}, [isOpen]);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (multiple)
|
|
94
|
+
setSelectedValues(value);
|
|
95
|
+
else
|
|
96
|
+
setSelectedValues([value]);
|
|
97
|
+
}, [value]);
|
|
98
|
+
return /* @__PURE__ */ jsxs("div", { className: clsx("relative min-w-[150px]", className), ref: dropdownRef, children: [
|
|
99
|
+
/* @__PURE__ */ jsxs(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
"data-open": isOpen,
|
|
103
|
+
className: clsx(
|
|
104
|
+
"btn flex h-auto min-h-[40px] w-full cursor-pointer items-center px-0 py-1 pr-5 pl-1 focus:outline-hidden",
|
|
105
|
+
"bg-base-100 data-[open=true]:border-primary",
|
|
106
|
+
disabled && "cursor-not-allowed opacity-50",
|
|
107
|
+
selectClassName,
|
|
108
|
+
{ "border-base-300": isOpen }
|
|
109
|
+
),
|
|
110
|
+
onClick: () => {
|
|
111
|
+
setIsOpen(!isOpen);
|
|
112
|
+
},
|
|
113
|
+
children: [
|
|
114
|
+
/* @__PURE__ */ jsxs("span", { className: "flex w-full flex-wrap items-center gap-1", children: [
|
|
115
|
+
multiple ? /* @__PURE__ */ jsx(Fragment, { children: value.map((v, index) => {
|
|
116
|
+
const optionValue = labeledOptions.find((option) => option.value === v);
|
|
117
|
+
if (!optionValue)
|
|
118
|
+
return null;
|
|
119
|
+
return /* @__PURE__ */ jsxs(
|
|
120
|
+
"div",
|
|
121
|
+
{
|
|
122
|
+
className: "bg-success/70 text-success-content flex items-center gap-2 rounded-lg px-2 py-1 text-xs",
|
|
123
|
+
children: [
|
|
124
|
+
renderSelected ? renderSelected(optionValue.value) : optionValue.label,
|
|
125
|
+
/* @__PURE__ */ jsx(
|
|
126
|
+
"button",
|
|
127
|
+
{
|
|
128
|
+
onClick: (e) => {
|
|
129
|
+
e.stopPropagation();
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
onSelect(optionValue.value, index);
|
|
132
|
+
},
|
|
133
|
+
className: "opacity-50 duration-300 hover:opacity-100",
|
|
134
|
+
children: /* @__PURE__ */ jsx(BiX, { className: "text-base" })
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
index
|
|
140
|
+
);
|
|
141
|
+
}) }) : /* @__PURE__ */ jsx("div", { className: "px-2 py-1", children: value ? /* @__PURE__ */ jsx(Fragment, { children: (() => {
|
|
142
|
+
const optionValue = searchOptions.find((option) => selected(option.value));
|
|
143
|
+
if (!optionValue)
|
|
144
|
+
return null;
|
|
145
|
+
return renderSelected ? renderSelected(optionValue.value) : optionValue.label;
|
|
146
|
+
})() }) : "" }),
|
|
147
|
+
searchable && /* @__PURE__ */ jsx(
|
|
148
|
+
"input",
|
|
149
|
+
{
|
|
150
|
+
type: "text",
|
|
151
|
+
className: "input w-full flex-1 border-none bg-transparent shadow-none outline-none focus:border-none focus:shadow-none focus:outline-none",
|
|
152
|
+
placeholder: selectedValues.length > 0 ? "" : placeholder,
|
|
153
|
+
value: searchText,
|
|
154
|
+
onChange: (e) => {
|
|
155
|
+
if (!isOpen)
|
|
156
|
+
setIsOpen(true);
|
|
157
|
+
if (!onSearch)
|
|
158
|
+
setSearchOptions(
|
|
159
|
+
labeledOptions.filter(
|
|
160
|
+
(option) => option.label.toString().toLowerCase().includes(e.target.value.toLowerCase())
|
|
161
|
+
)
|
|
162
|
+
);
|
|
163
|
+
setSearchText(e.target.value);
|
|
164
|
+
debouncedOnSearch(e.target.value);
|
|
165
|
+
},
|
|
166
|
+
onClick: (e) => {
|
|
167
|
+
e.stopPropagation();
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
setIsOpen(!isOpen);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
] }),
|
|
174
|
+
multiple && selectedValues.length || !multiple && selectedValues[0] !== void 0 && selectedValues[0] !== null ? /* @__PURE__ */ jsx(
|
|
175
|
+
TiDelete,
|
|
176
|
+
{
|
|
177
|
+
className: "absolute right-8 z-[2] h-full text-lg duration-300 hover:cursor-pointer hover:opacity-50",
|
|
178
|
+
onClick: (e) => {
|
|
179
|
+
e.stopPropagation();
|
|
180
|
+
e.preventDefault();
|
|
181
|
+
setSearchText("");
|
|
182
|
+
setSelectedValues([]);
|
|
183
|
+
if (multiple)
|
|
184
|
+
onChange([], selectedValues);
|
|
185
|
+
else
|
|
186
|
+
onChange(null, selectedValues[0]);
|
|
187
|
+
setIsOpen(false);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
) : null,
|
|
191
|
+
/* @__PURE__ */ jsx(
|
|
192
|
+
BiChevronDown,
|
|
193
|
+
{
|
|
194
|
+
className: clsx("absolute top-1/2 right-2 -translate-y-1/2 text-lg duration-100", { "rotate-180": isOpen })
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
/* @__PURE__ */ jsxs(
|
|
201
|
+
"div",
|
|
202
|
+
{
|
|
203
|
+
"data-open": isOpen,
|
|
204
|
+
className: clsx(
|
|
205
|
+
"scrollbar-thin scrollbar-thumb-base-content/20 scrollbar-track scrollbar-track-base-content/40 bg-base-200 border-base-300 absolute z-20 mt-0.5 w-full overflow-y-scroll rounded-md shadow-lg transition-all",
|
|
206
|
+
"origin-center duration-200 data-[open=false]:h-0 data-[open=false]:border-none data-[open=true]:h-[270px] data-[open=true]:border",
|
|
207
|
+
selectorClassName
|
|
208
|
+
),
|
|
209
|
+
children: [
|
|
210
|
+
nullable && /* @__PURE__ */ jsx(
|
|
211
|
+
"div",
|
|
212
|
+
{
|
|
213
|
+
className: "cursor-pointer p-2",
|
|
214
|
+
onClick: () => {
|
|
215
|
+
setIsOpen(false);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
searchOptions.length > 0 ? /* @__PURE__ */ jsx(Fragment, { children: searchOptions.map((option, index) => {
|
|
220
|
+
const isSelected = selected(option.value);
|
|
221
|
+
return /* @__PURE__ */ jsxs("div", { className: "group", children: [
|
|
222
|
+
/* @__PURE__ */ jsxs(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
className: clsx(
|
|
226
|
+
"hover:bg-base-300 relative m-2 cursor-pointer rounded-sm p-2 duration-100 last:border-b-0",
|
|
227
|
+
{
|
|
228
|
+
selectedClassName: !multiple && isSelected,
|
|
229
|
+
"bg-success/70 text-success-content": isSelected
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
onClick: () => {
|
|
233
|
+
onSelect(option.value, index);
|
|
234
|
+
setSearchText("");
|
|
235
|
+
},
|
|
236
|
+
children: [
|
|
237
|
+
renderOption ? renderOption(option.value) : option.label,
|
|
238
|
+
/* @__PURE__ */ jsx("div", { className: clsx("absolute top-1/2 right-2 -translate-y-1/2 flex-wrap duration-200", {}), children: /* @__PURE__ */ jsx(
|
|
239
|
+
"div",
|
|
240
|
+
{
|
|
241
|
+
className: clsx("duration-200", {
|
|
242
|
+
"translate-y-0 opacity-100": isSelected,
|
|
243
|
+
"-translate-y-full opacity-0": !isSelected
|
|
244
|
+
}),
|
|
245
|
+
children: /* @__PURE__ */ jsx(BiCheck, {})
|
|
246
|
+
}
|
|
247
|
+
) })
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
),
|
|
251
|
+
/* @__PURE__ */ jsx("div", { className: "h-px w-full px-2 group-last:hidden", children: /* @__PURE__ */ jsx("div", { className: "bg-base-content/10 size-full" }) })
|
|
252
|
+
] }, index);
|
|
253
|
+
}) }) : /* @__PURE__ */ jsxs("div", { className: "text-base-content/50 flex size-full flex-col items-center justify-center gap-2 p-2 text-center text-5xl", children: [
|
|
254
|
+
/* @__PURE__ */ jsx(BsQuestionCircleFill, {}),
|
|
255
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm", children: l("shared.noOptions") })
|
|
256
|
+
] })
|
|
257
|
+
]
|
|
258
|
+
}
|
|
259
|
+
)
|
|
260
|
+
] });
|
|
261
|
+
};
|
|
262
|
+
export {
|
|
263
|
+
Select
|
|
264
|
+
};
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { getNonArrayModel, isGqlScalar } from "@akanjs/base";
|
|
4
|
+
import { getGqlTypeStr, getScalarExample } from "@akanjs/constant";
|
|
5
|
+
import { usePage } from "@akanjs/next";
|
|
6
|
+
import { st } from "@akanjs/store";
|
|
7
|
+
import { AiOutlineDelete } from "react-icons/ai";
|
|
8
|
+
import { DatePicker } from "../DatePicker";
|
|
9
|
+
import { Input } from "../Input";
|
|
10
|
+
import Object from "./Object";
|
|
11
|
+
function Arg({ argType, value, onChange }) {
|
|
12
|
+
return argType === "ID" ? /* @__PURE__ */ jsx(Arg.ID, { value, onChange }) : argType === "Int" ? /* @__PURE__ */ jsx(Arg.Int, { value, onChange }) : argType === "Float" ? /* @__PURE__ */ jsx(Arg.Float, { value, onChange }) : argType === "String" ? /* @__PURE__ */ jsx(Arg.String, { value, onChange }) : argType === "Boolean" ? /* @__PURE__ */ jsx(Arg.Boolean, { value, onChange }) : argType === "Date" ? /* @__PURE__ */ jsx(Arg.Date, { value, onChange }) : argType === "JSON" ? /* @__PURE__ */ jsx(Arg.Json, { value, onChange }) : argType === "Upload" ? /* @__PURE__ */ jsx(Arg.Upload, { value, onChange }) : /* @__PURE__ */ jsx(Fragment, {});
|
|
13
|
+
}
|
|
14
|
+
const ArgTable = ({ sigMeta, gqlMeta, argMetas }) => {
|
|
15
|
+
const { l } = usePage();
|
|
16
|
+
const onCopy = (text) => {
|
|
17
|
+
void navigator.clipboard.writeText(text);
|
|
18
|
+
st.do.showMessage({ content: "\uD074\uB9BD\uBCF4\uB4DC\uC5D0 \uBCF5\uC0AC\uB418\uC5C8\uC2B5\uB2C8\uB2E4.", type: "success", duration: 3 });
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ jsxs("table", { className: "table", children: [
|
|
21
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "text-bold", children: [
|
|
22
|
+
/* @__PURE__ */ jsx("th", { children: "Arg Key" }),
|
|
23
|
+
/* @__PURE__ */ jsx("th", { className: "text-center", children: "Type" }),
|
|
24
|
+
/* @__PURE__ */ jsx("th", { className: "text-center", children: "Enum" }),
|
|
25
|
+
/* @__PURE__ */ jsx("th", { className: "text-center", children: "Name" }),
|
|
26
|
+
/* @__PURE__ */ jsx("th", { className: "text-center", children: "Description" })
|
|
27
|
+
] }) }),
|
|
28
|
+
argMetas.map((argMeta, idx) => {
|
|
29
|
+
const [argRef, argArrDepth] = getNonArrayModel(argMeta.returns());
|
|
30
|
+
return /* @__PURE__ */ jsx("tbody", { className: "font-normal", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
31
|
+
/* @__PURE__ */ jsx("td", { children: argMeta.name }),
|
|
32
|
+
/* @__PURE__ */ jsx("td", { className: "text-center", children: /* @__PURE__ */ jsx(Object.Type, { objRef: argRef, arrDepth: argArrDepth }) }),
|
|
33
|
+
/* @__PURE__ */ jsx("td", { width: argMeta.argsOption.enum ? "20%" : "10%", className: "text-center", children: argMeta.argsOption.enum ? /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: argMeta.argsOption.enum.map((opt, idx2) => /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
34
|
+
"button",
|
|
35
|
+
{
|
|
36
|
+
"data-tip": l.enum(sigMeta.refName, argMeta.name, opt),
|
|
37
|
+
onClick: () => {
|
|
38
|
+
onCopy(opt);
|
|
39
|
+
},
|
|
40
|
+
className: "tooltip tooltip-primary btn btn-secondary btn-xs",
|
|
41
|
+
children: opt
|
|
42
|
+
},
|
|
43
|
+
idx2
|
|
44
|
+
) }, idx2)) }) : "-" }),
|
|
45
|
+
/* @__PURE__ */ jsx("td", { className: "text-center", children: l.arg(sigMeta.refName, gqlMeta.key, argMeta.name) }),
|
|
46
|
+
/* @__PURE__ */ jsx("td", { className: "text-center", children: l.argdesc(sigMeta.refName, gqlMeta.key, argMeta.name) })
|
|
47
|
+
] }) }, idx);
|
|
48
|
+
})
|
|
49
|
+
] });
|
|
50
|
+
};
|
|
51
|
+
Arg.Table = ArgTable;
|
|
52
|
+
const ArgParam = ({ argMeta, value, onChange }) => {
|
|
53
|
+
const [argRef, argArrDepth] = getNonArrayModel(argMeta.returns());
|
|
54
|
+
if (!isGqlScalar(argRef))
|
|
55
|
+
throw new Error(`Param arg - ${argMeta.key}/${argMeta.name} must be scalar`);
|
|
56
|
+
else if (argArrDepth > 0)
|
|
57
|
+
throw new Error(`Param arg - ${argMeta.key}/${argMeta.name} must not be array`);
|
|
58
|
+
const argType = getGqlTypeStr(argRef);
|
|
59
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-2", children: [
|
|
60
|
+
/* @__PURE__ */ jsxs("div", { className: "w-36 pl-2", children: [
|
|
61
|
+
"- ",
|
|
62
|
+
argMeta.name
|
|
63
|
+
] }),
|
|
64
|
+
/* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsx(Arg, { argType, value, onChange }) })
|
|
65
|
+
] });
|
|
66
|
+
};
|
|
67
|
+
Arg.Param = ArgParam;
|
|
68
|
+
const ArgQuery = ({ argMeta, value, onChange }) => {
|
|
69
|
+
const [argRef, argArrDepth] = getNonArrayModel(argMeta.returns());
|
|
70
|
+
if (!isGqlScalar(argRef))
|
|
71
|
+
throw new Error(`Query arg - ${argMeta.key}/${argMeta.name} must be scalar`);
|
|
72
|
+
else if (argArrDepth > 1)
|
|
73
|
+
throw new Error(`Query arg - ${argMeta.key}/${argMeta.name} must not be more than 2D array`);
|
|
74
|
+
const argType = getGqlTypeStr(argRef);
|
|
75
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
76
|
+
/* @__PURE__ */ jsxs("div", { className: "w-36 pl-2", children: [
|
|
77
|
+
"- ",
|
|
78
|
+
argMeta.name
|
|
79
|
+
] }),
|
|
80
|
+
/* @__PURE__ */ jsx("div", { className: "w-full", children: argArrDepth && Array.isArray(value) ? /* @__PURE__ */ jsxs("div", { children: [
|
|
81
|
+
value.map((val, idx) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
82
|
+
/* @__PURE__ */ jsx(
|
|
83
|
+
Arg,
|
|
84
|
+
{
|
|
85
|
+
argType,
|
|
86
|
+
value: val,
|
|
87
|
+
onChange: (val2) => {
|
|
88
|
+
onChange([...value.slice(0, idx), val2, ...value.slice(idx + 1)]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ jsx(
|
|
93
|
+
"button",
|
|
94
|
+
{
|
|
95
|
+
className: "btn btn-sm btn-square",
|
|
96
|
+
onClick: () => {
|
|
97
|
+
onChange([...value.slice(0, idx), ...value.slice(idx + 1)]);
|
|
98
|
+
},
|
|
99
|
+
children: /* @__PURE__ */ jsx(AiOutlineDelete, {})
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
] }, idx)),
|
|
103
|
+
/* @__PURE__ */ jsx(
|
|
104
|
+
"button",
|
|
105
|
+
{
|
|
106
|
+
className: "btn btn-sm",
|
|
107
|
+
onClick: () => {
|
|
108
|
+
onChange([...value, getScalarExample(argRef)]);
|
|
109
|
+
},
|
|
110
|
+
children: "+ Add"
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
] }) : /* @__PURE__ */ jsx(Arg, { argType, value, onChange }) })
|
|
114
|
+
] });
|
|
115
|
+
};
|
|
116
|
+
Arg.Query = ArgQuery;
|
|
117
|
+
const ArgFormData = ({ argMeta, value, onChange }) => {
|
|
118
|
+
const [argRef, argArrDepth] = getNonArrayModel(argMeta.returns());
|
|
119
|
+
if (getGqlTypeStr(argRef) !== "Upload")
|
|
120
|
+
throw new Error(`FormData arg - ${argMeta.key}/${argMeta.name} must be Upload`);
|
|
121
|
+
else if (argArrDepth < 1)
|
|
122
|
+
throw new Error(`FormData arg - ${argMeta.key}/${argMeta.name} must be array`);
|
|
123
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-2", children: [
|
|
124
|
+
/* @__PURE__ */ jsxs("div", { className: "w-36 pl-2", children: [
|
|
125
|
+
"- ",
|
|
126
|
+
argMeta.name
|
|
127
|
+
] }),
|
|
128
|
+
/* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsx(Arg, { argType: "Upload", value, onChange }) })
|
|
129
|
+
] });
|
|
130
|
+
};
|
|
131
|
+
Arg.FormData = ArgFormData;
|
|
132
|
+
const ArgID = ({ value, onChange }) => {
|
|
133
|
+
return /* @__PURE__ */ jsx(
|
|
134
|
+
Input,
|
|
135
|
+
{
|
|
136
|
+
inputClassName: "w-full",
|
|
137
|
+
value,
|
|
138
|
+
onChange: (value2) => {
|
|
139
|
+
onChange(value2);
|
|
140
|
+
},
|
|
141
|
+
validate: (e) => true
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
};
|
|
145
|
+
Arg.ID = ArgID;
|
|
146
|
+
const ArgInt = ({ value, onChange }) => {
|
|
147
|
+
return /* @__PURE__ */ jsx(
|
|
148
|
+
Input.Number,
|
|
149
|
+
{
|
|
150
|
+
inputClassName: "w-full",
|
|
151
|
+
value,
|
|
152
|
+
onChange: (value2) => {
|
|
153
|
+
onChange(value2 ?? 0);
|
|
154
|
+
},
|
|
155
|
+
validate: (e) => true
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
Arg.Int = ArgInt;
|
|
160
|
+
const ArgFloat = ({ value, onChange }) => {
|
|
161
|
+
return /* @__PURE__ */ jsx(
|
|
162
|
+
Input.Number,
|
|
163
|
+
{
|
|
164
|
+
inputClassName: "w-full",
|
|
165
|
+
value,
|
|
166
|
+
onChange: (value2) => {
|
|
167
|
+
onChange(value2 ?? 0);
|
|
168
|
+
},
|
|
169
|
+
validate: (e) => true
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
Arg.Float = ArgFloat;
|
|
174
|
+
const ArgString = ({ value, onChange }) => {
|
|
175
|
+
return /* @__PURE__ */ jsx(
|
|
176
|
+
Input,
|
|
177
|
+
{
|
|
178
|
+
inputClassName: "w-full",
|
|
179
|
+
value,
|
|
180
|
+
onChange: (value2) => {
|
|
181
|
+
onChange(value2);
|
|
182
|
+
},
|
|
183
|
+
validate: (e) => true
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
};
|
|
187
|
+
Arg.String = ArgString;
|
|
188
|
+
const ArgBoolean = ({ value, onChange }) => {
|
|
189
|
+
return /* @__PURE__ */ jsx(
|
|
190
|
+
Input.Checkbox,
|
|
191
|
+
{
|
|
192
|
+
className: "w-full",
|
|
193
|
+
checked: value,
|
|
194
|
+
onChange: (value2) => {
|
|
195
|
+
onChange(value2);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
};
|
|
200
|
+
Arg.Boolean = ArgBoolean;
|
|
201
|
+
const ArgDate = ({ value, onChange }) => {
|
|
202
|
+
return /* @__PURE__ */ jsx(
|
|
203
|
+
DatePicker,
|
|
204
|
+
{
|
|
205
|
+
className: "w-full",
|
|
206
|
+
value,
|
|
207
|
+
onChange: (value2) => {
|
|
208
|
+
onChange(value2);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
};
|
|
213
|
+
Arg.Date = ArgDate;
|
|
214
|
+
const ArgJson = ({ value, onChange }) => {
|
|
215
|
+
return /* @__PURE__ */ jsx(
|
|
216
|
+
Input.TextArea,
|
|
217
|
+
{
|
|
218
|
+
validate: (e) => true,
|
|
219
|
+
className: "w-full",
|
|
220
|
+
inputClassName: "w-full min-h-[300px]",
|
|
221
|
+
value,
|
|
222
|
+
onPressEnter: (value2) => {
|
|
223
|
+
onChange(value2);
|
|
224
|
+
},
|
|
225
|
+
onChange: (value2) => {
|
|
226
|
+
onChange(value2);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
};
|
|
231
|
+
Arg.Json = ArgJson;
|
|
232
|
+
const ArgUpload = ({ value, onChange }) => {
|
|
233
|
+
return /* @__PURE__ */ jsx(
|
|
234
|
+
"input",
|
|
235
|
+
{
|
|
236
|
+
type: "file",
|
|
237
|
+
multiple: true,
|
|
238
|
+
className: "file-input w-full max-w-xs",
|
|
239
|
+
onChange: (e) => {
|
|
240
|
+
onChange(new Array(e.target.files?.length).fill(0).map((_, idx) => e.target.files?.[idx]));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
};
|
|
245
|
+
Arg.Upload = ArgUpload;
|
|
246
|
+
export {
|
|
247
|
+
Arg as default
|
|
248
|
+
};
|