@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,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { capitalize } from "@akanjs/common";
|
|
3
|
+
import { st } from "@akanjs/store";
|
|
4
|
+
import { Modal } from "../Modal";
|
|
5
|
+
import View from "./View";
|
|
6
|
+
function ViewModal({
|
|
7
|
+
id,
|
|
8
|
+
modal,
|
|
9
|
+
modalClassName,
|
|
10
|
+
viewClassName,
|
|
11
|
+
sliceName,
|
|
12
|
+
renderTitle,
|
|
13
|
+
renderAction,
|
|
14
|
+
renderView
|
|
15
|
+
}) {
|
|
16
|
+
const storeUse = st.use;
|
|
17
|
+
const storeDo = st.do;
|
|
18
|
+
const refName = st.slice[sliceName].refName;
|
|
19
|
+
const [modelName, ModelName] = [refName, capitalize(refName)];
|
|
20
|
+
const names = {
|
|
21
|
+
model: modelName,
|
|
22
|
+
Model: ModelName,
|
|
23
|
+
viewModel: `view${ModelName}`,
|
|
24
|
+
modelLoading: `${modelName}Loading`,
|
|
25
|
+
modelModal: `${modelName}Modal`,
|
|
26
|
+
resetModel: `reset${ModelName}`
|
|
27
|
+
};
|
|
28
|
+
const model = storeUse[names.model]();
|
|
29
|
+
const modelModal = storeUse[names.modelModal]();
|
|
30
|
+
const modelLoading = storeUse[names.modelLoading]();
|
|
31
|
+
const isModalOpen = modelModal === (modal ?? "view") && (modelLoading === id || model?.id === id);
|
|
32
|
+
const Title = () => {
|
|
33
|
+
if (!model || modelLoading || !renderTitle)
|
|
34
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null);
|
|
35
|
+
const render = renderTitle(model);
|
|
36
|
+
if (typeof render === "string")
|
|
37
|
+
return /* @__PURE__ */ React.createElement("h2", { className: "flex items-center text-2xl" }, render);
|
|
38
|
+
else
|
|
39
|
+
return render;
|
|
40
|
+
};
|
|
41
|
+
const Action = () => {
|
|
42
|
+
if (!model || modelLoading || !renderAction)
|
|
43
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null);
|
|
44
|
+
const render = renderAction(model);
|
|
45
|
+
return render;
|
|
46
|
+
};
|
|
47
|
+
return /* @__PURE__ */ React.createElement(
|
|
48
|
+
Modal,
|
|
49
|
+
{
|
|
50
|
+
open: isModalOpen,
|
|
51
|
+
onCancel: () => {
|
|
52
|
+
storeDo[names.resetModel]();
|
|
53
|
+
},
|
|
54
|
+
className: modalClassName,
|
|
55
|
+
title: /* @__PURE__ */ React.createElement(Title, null),
|
|
56
|
+
action: /* @__PURE__ */ React.createElement(Action, null)
|
|
57
|
+
},
|
|
58
|
+
/* @__PURE__ */ React.createElement(View, { className: viewClassName, model, modelLoading, render: renderView })
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
ViewModal as default
|
|
63
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx } from "@akanjs/client";
|
|
3
|
+
import { capitalize } from "@akanjs/common";
|
|
4
|
+
import { st } from "@akanjs/store";
|
|
5
|
+
function ViewWrapper({ children, sliceName, modelId, className, modal, resets }) {
|
|
6
|
+
const refName = st.slice[sliceName].refName;
|
|
7
|
+
const modelName = refName;
|
|
8
|
+
const names = {
|
|
9
|
+
viewModel: `view${capitalize(modelName)}`
|
|
10
|
+
};
|
|
11
|
+
const storeDo = st.do;
|
|
12
|
+
return /* @__PURE__ */ React.createElement(
|
|
13
|
+
"div",
|
|
14
|
+
{
|
|
15
|
+
className: clsx("cursor-pointer", className),
|
|
16
|
+
onClick: (e) => {
|
|
17
|
+
e.stopPropagation();
|
|
18
|
+
void storeDo[names.viewModel](modelId, { modal });
|
|
19
|
+
resets?.forEach((reset) => {
|
|
20
|
+
void storeDo[`reset${capitalize(reset)}`]();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
children
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
ViewWrapper as default
|
|
29
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Edit,
|
|
3
|
+
EditModal,
|
|
4
|
+
EditWrapper,
|
|
5
|
+
LoadInit,
|
|
6
|
+
New,
|
|
7
|
+
NewWrapper,
|
|
8
|
+
Remove,
|
|
9
|
+
RemoveWrapper,
|
|
10
|
+
SureToRemove,
|
|
11
|
+
View,
|
|
12
|
+
ViewEditModal,
|
|
13
|
+
ViewModal,
|
|
14
|
+
ViewWrapper
|
|
15
|
+
} from "./index_";
|
|
16
|
+
const Model = {
|
|
17
|
+
ViewModal,
|
|
18
|
+
View,
|
|
19
|
+
EditModal,
|
|
20
|
+
EditWrapper,
|
|
21
|
+
NewWrapper,
|
|
22
|
+
SureToRemove,
|
|
23
|
+
Remove,
|
|
24
|
+
RemoveWrapper,
|
|
25
|
+
LoadInit,
|
|
26
|
+
ViewWrapper,
|
|
27
|
+
ViewEditModal,
|
|
28
|
+
Edit,
|
|
29
|
+
New
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
Model
|
|
33
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { lazy } from "@akanjs/next";
|
|
2
|
+
const ViewModal = lazy(() => import("./ViewModal"));
|
|
3
|
+
const EditModal = lazy(() => import("./EditModal"));
|
|
4
|
+
const View = lazy(() => import("./View"));
|
|
5
|
+
const SureToRemove = lazy(() => import("./SureToRemove"));
|
|
6
|
+
const Remove = lazy(() => import("./Remove"));
|
|
7
|
+
const NewWrapper = lazy(() => import("./NewWrapper"));
|
|
8
|
+
const EditWrapper = lazy(() => import("./EditWrapper"));
|
|
9
|
+
const RemoveWrapper = lazy(() => import("./RemoveWrapper"));
|
|
10
|
+
const LoadInit = lazy(() => import("./LoadInit"));
|
|
11
|
+
const ViewWrapper = lazy(() => import("./ViewWrapper"));
|
|
12
|
+
const ViewEditModal = lazy(() => import("./ViewEditModal"));
|
|
13
|
+
const Edit = lazy(() => import("./Edit"));
|
|
14
|
+
const New = lazy(() => import("./New"));
|
|
15
|
+
export {
|
|
16
|
+
Edit,
|
|
17
|
+
EditModal,
|
|
18
|
+
EditWrapper,
|
|
19
|
+
LoadInit,
|
|
20
|
+
New,
|
|
21
|
+
NewWrapper,
|
|
22
|
+
Remove,
|
|
23
|
+
RemoveWrapper,
|
|
24
|
+
SureToRemove,
|
|
25
|
+
View,
|
|
26
|
+
ViewEditModal,
|
|
27
|
+
ViewModal,
|
|
28
|
+
ViewWrapper
|
|
29
|
+
};
|
package/esm/More.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx } from "@akanjs/client";
|
|
3
|
+
import dynamic from "next/dynamic";
|
|
4
|
+
import { isMobile } from "react-device-detect";
|
|
5
|
+
import { Pagination } from "./Pagination";
|
|
6
|
+
const InfiniteScroll = dynamic(() => import("./InfiniteScroll").then((mod) => mod.InfiniteScroll), { ssr: false });
|
|
7
|
+
const More = ({
|
|
8
|
+
total,
|
|
9
|
+
itemsPerPage,
|
|
10
|
+
currentPage,
|
|
11
|
+
onAddPage,
|
|
12
|
+
onPageSelect,
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
reverse
|
|
16
|
+
}) => {
|
|
17
|
+
if (total <= itemsPerPage) {
|
|
18
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
19
|
+
}
|
|
20
|
+
if (isMobile) {
|
|
21
|
+
return /* @__PURE__ */ React.createElement(
|
|
22
|
+
InfiniteScroll,
|
|
23
|
+
{
|
|
24
|
+
total,
|
|
25
|
+
currentPage,
|
|
26
|
+
itemsPerPage,
|
|
27
|
+
onAddPage,
|
|
28
|
+
onPageSelect,
|
|
29
|
+
reverse
|
|
30
|
+
},
|
|
31
|
+
children
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children, /* @__PURE__ */ React.createElement("div", { className: clsx("mt-4 flex w-full flex-wrap justify-center", className) }, /* @__PURE__ */ React.createElement(Pagination, { currentPage, total, itemsPerPage, onPageSelect })));
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
More
|
|
38
|
+
};
|
package/esm/ObjectId.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { AiOutlineCheck, AiOutlineCopy } from "react-icons/ai";
|
|
4
|
+
const ObjectId = ({ id }) => {
|
|
5
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
6
|
+
const shortenedId = `${id.substring(0, 4)}...${id.substring(id.length - 5)}`;
|
|
7
|
+
const handleCopyClick = () => {
|
|
8
|
+
void navigator.clipboard.writeText(id);
|
|
9
|
+
setIsCopied(true);
|
|
10
|
+
setTimeout(() => {
|
|
11
|
+
setIsCopied(false);
|
|
12
|
+
}, 2e3);
|
|
13
|
+
};
|
|
14
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React.createElement("div", { className: "tooltip tooltip-primary", "data-tip": id }, /* @__PURE__ */ React.createElement("div", { className: "text-xs font-semibold" }, shortenedId)), /* @__PURE__ */ React.createElement("button", { className: "btn btn-circle btn-xs", onClick: handleCopyClick }, isCopied ? /* @__PURE__ */ React.createElement(AiOutlineCheck, null) : /* @__PURE__ */ React.createElement(AiOutlineCopy, null)));
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
ObjectId
|
|
18
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx } from "@akanjs/client";
|
|
3
|
+
import { BiChevronLeft, BiChevronRight, BiDotsHorizontalRounded } from "react-icons/bi";
|
|
4
|
+
const Pagination = ({
|
|
5
|
+
currentPage,
|
|
6
|
+
total,
|
|
7
|
+
onPageSelect,
|
|
8
|
+
itemsPerPage,
|
|
9
|
+
renderEmpty,
|
|
10
|
+
classNames
|
|
11
|
+
}) => {
|
|
12
|
+
const totalPages = Math.ceil(total / (itemsPerPage || 1));
|
|
13
|
+
const handleLeftClick = () => {
|
|
14
|
+
if (currentPage <= 1)
|
|
15
|
+
return;
|
|
16
|
+
onPageSelect(currentPage - 1);
|
|
17
|
+
};
|
|
18
|
+
const handleRightClick = () => {
|
|
19
|
+
if (currentPage >= totalPages)
|
|
20
|
+
return;
|
|
21
|
+
onPageSelect(currentPage + 1);
|
|
22
|
+
};
|
|
23
|
+
const pageNumbers = new Array(totalPages).fill("").map((_, i) => {
|
|
24
|
+
return String(i + 1);
|
|
25
|
+
});
|
|
26
|
+
let displayNumbers = pageNumbers;
|
|
27
|
+
if (totalPages > 10) {
|
|
28
|
+
if (currentPage < 5) {
|
|
29
|
+
displayNumbers = pageNumbers.slice(0, 5).concat(["...", String(totalPages)]);
|
|
30
|
+
} else if (currentPage >= 5 && currentPage <= totalPages - 4) {
|
|
31
|
+
displayNumbers = [
|
|
32
|
+
"1",
|
|
33
|
+
"...",
|
|
34
|
+
...pageNumbers.slice(Number(currentPage) - 3, Number(currentPage) + 2),
|
|
35
|
+
"...",
|
|
36
|
+
String(totalPages)
|
|
37
|
+
];
|
|
38
|
+
} else {
|
|
39
|
+
displayNumbers = ["1", "...", ...pageNumbers.slice(-5)];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex items-center justify-center" }, total > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
43
|
+
"button",
|
|
44
|
+
{
|
|
45
|
+
className: clsx(
|
|
46
|
+
"btn btn-ghost btn-square duration-200",
|
|
47
|
+
currentPage > 1 ? "opacity-100" : "opacity-0 hover:cursor-default hover:opacity-0"
|
|
48
|
+
),
|
|
49
|
+
onClick: handleLeftClick
|
|
50
|
+
},
|
|
51
|
+
/* @__PURE__ */ React.createElement(BiChevronLeft, null)
|
|
52
|
+
), displayNumbers.map((pageNum, index) => {
|
|
53
|
+
if (pageNum === "...") {
|
|
54
|
+
return /* @__PURE__ */ React.createElement("button", { key: index, className: "btn btn-ghost btn-square text-primary/40" }, /* @__PURE__ */ React.createElement(BiDotsHorizontalRounded, null));
|
|
55
|
+
}
|
|
56
|
+
if (Number(pageNum) === currentPage) {
|
|
57
|
+
return /* @__PURE__ */ React.createElement(
|
|
58
|
+
"button",
|
|
59
|
+
{
|
|
60
|
+
key: index,
|
|
61
|
+
className: clsx("btn btn-ghost btn-square text-primary", classNames?.activePageNumClassName)
|
|
62
|
+
},
|
|
63
|
+
pageNum
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return /* @__PURE__ */ React.createElement(
|
|
67
|
+
"button",
|
|
68
|
+
{
|
|
69
|
+
key: index,
|
|
70
|
+
className: clsx("btn btn-ghost btn-square text-primary/40", classNames?.pageNumClassName),
|
|
71
|
+
onClick: () => {
|
|
72
|
+
onPageSelect(Number(pageNum));
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
pageNum
|
|
76
|
+
);
|
|
77
|
+
}), /* @__PURE__ */ React.createElement(
|
|
78
|
+
"button",
|
|
79
|
+
{
|
|
80
|
+
className: clsx(
|
|
81
|
+
"btn btn-ghost btn-square duration-200",
|
|
82
|
+
currentPage < totalPages ? "opacity-100" : "opacity-0 hover:cursor-default hover:opacity-0"
|
|
83
|
+
),
|
|
84
|
+
onClick: handleRightClick
|
|
85
|
+
},
|
|
86
|
+
/* @__PURE__ */ React.createElement(BiChevronRight, null)
|
|
87
|
+
)));
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
Pagination
|
|
91
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//! 디자인 수정, 테마 적용 안됨
|
|
3
|
+
import { clsx } from "@akanjs/client";
|
|
4
|
+
import { usePage } from "@akanjs/next";
|
|
5
|
+
import { animated, useSpring } from "@react-spring/web";
|
|
6
|
+
import React, { useEffect, useState } from "react";
|
|
7
|
+
import { BiMessageRoundedError } from "react-icons/bi";
|
|
8
|
+
const Popconfirm = ({
|
|
9
|
+
title,
|
|
10
|
+
description,
|
|
11
|
+
onConfirm,
|
|
12
|
+
okButtonProps,
|
|
13
|
+
cancelButtonProps,
|
|
14
|
+
okText,
|
|
15
|
+
cancelText,
|
|
16
|
+
children,
|
|
17
|
+
triggerClassName,
|
|
18
|
+
decoClassName
|
|
19
|
+
}) => {
|
|
20
|
+
const { l } = usePage();
|
|
21
|
+
const [isConfirming, setIsConfirming] = useState(false);
|
|
22
|
+
const popconfirmProps = useSpring({
|
|
23
|
+
opacity: isConfirming ? 1 : 0,
|
|
24
|
+
from: {
|
|
25
|
+
opacity: 0
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const popconfirm = document.querySelector(".popconfirm");
|
|
30
|
+
const popconfirmRect = popconfirm?.getBoundingClientRect();
|
|
31
|
+
const popconfirmDeco = document.querySelector(".popconfirm-deco");
|
|
32
|
+
if (popconfirmRect && popconfirmRect.x < 0) {
|
|
33
|
+
popconfirm?.classList.add("left-0", "right-auto");
|
|
34
|
+
popconfirmDeco?.classList.add("left-10", "left-auto");
|
|
35
|
+
}
|
|
36
|
+
if (popconfirmRect && popconfirmRect.x + popconfirmRect.width > window.innerWidth) {
|
|
37
|
+
popconfirm?.classList.add("left-auto", "right-0");
|
|
38
|
+
}
|
|
39
|
+
}, [isConfirming]);
|
|
40
|
+
const handleConfirm = () => {
|
|
41
|
+
setIsConfirming(false);
|
|
42
|
+
onConfirm?.();
|
|
43
|
+
};
|
|
44
|
+
const handleCancel = () => {
|
|
45
|
+
setIsConfirming(false);
|
|
46
|
+
};
|
|
47
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "relative inline-block" }, /* @__PURE__ */ React.createElement(
|
|
48
|
+
"div",
|
|
49
|
+
{
|
|
50
|
+
className: clsx("trigger", triggerClassName),
|
|
51
|
+
onClick: (e) => {
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
setIsConfirming(true);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
children
|
|
57
|
+
), isConfirming && /* @__PURE__ */ React.createElement(
|
|
58
|
+
animated.div,
|
|
59
|
+
{
|
|
60
|
+
className: "popconfirm border-base-300 bg-base-100 absolute -right-2 bottom-0 z-10 translate-y-[106%] rounded-lg border p-4 shadow-xl",
|
|
61
|
+
style: popconfirmProps
|
|
62
|
+
},
|
|
63
|
+
/* @__PURE__ */ React.createElement(
|
|
64
|
+
"div",
|
|
65
|
+
{
|
|
66
|
+
className: clsx(
|
|
67
|
+
"bg-base-100 border-base-300 popconfirm-deco absolute -top-2 size-4 rotate-45 rounded-sm border-t border-l",
|
|
68
|
+
{ "right-10": !decoClassName },
|
|
69
|
+
decoClassName
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
/* @__PURE__ */ React.createElement("div", { className: "flex gap-1" }, /* @__PURE__ */ React.createElement(BiMessageRoundedError, { className: "text-orange-500" }), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("p", { className: "mb-2 font-bold whitespace-nowrap" }, title), /* @__PURE__ */ React.createElement("div", { className: "mb-2 whitespace-nowrap" }, description))),
|
|
74
|
+
/* @__PURE__ */ React.createElement("div", { className: "flex justify-end gap-2" }, /* @__PURE__ */ React.createElement("button", { className: "btn btn-xs btn-outline", onClick: handleCancel, ...cancelButtonProps }, cancelText ?? l("util.cancel")), /* @__PURE__ */ React.createElement("button", { className: "btn btn-xs", onClick: handleConfirm, ...okButtonProps }, okText ?? l("util.ok")))
|
|
75
|
+
)), isConfirming && /* @__PURE__ */ React.createElement(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
className: "absolute top-0 left-0 h-screen w-full",
|
|
79
|
+
onClick: () => {
|
|
80
|
+
setIsConfirming(false);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
));
|
|
84
|
+
};
|
|
85
|
+
export {
|
|
86
|
+
Popconfirm
|
|
87
|
+
};
|
package/esm/Portal.js
ADDED
package/esm/Radio.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx } from "@akanjs/client";
|
|
3
|
+
const Radio = ({ value, children, disabled, className, onChange }) => {
|
|
4
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx(`flex gap-2`, className) }, children.map((child, idx) => {
|
|
5
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex items-center justify-center gap-1", key: idx }, /* @__PURE__ */ React.createElement(
|
|
6
|
+
"input",
|
|
7
|
+
{
|
|
8
|
+
type: "radio",
|
|
9
|
+
disabled,
|
|
10
|
+
className: "radio radio-primary radio-sm",
|
|
11
|
+
checked: value === child.props.value || value === idx,
|
|
12
|
+
onChange: () => {
|
|
13
|
+
onChange(child.props.value, idx);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
), /* @__PURE__ */ React.createElement(
|
|
17
|
+
"button",
|
|
18
|
+
{
|
|
19
|
+
className: "bg-transparent",
|
|
20
|
+
onClick: () => {
|
|
21
|
+
onChange(child.props.value, idx);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
child
|
|
25
|
+
));
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
const Item = ({ value, className, children }) => {
|
|
29
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx("", className) }, children);
|
|
30
|
+
};
|
|
31
|
+
Radio.Item = Item;
|
|
32
|
+
export {
|
|
33
|
+
Radio
|
|
34
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { dayjs } from "@akanjs/base";
|
|
2
|
+
import { clsx } from "@akanjs/client";
|
|
3
|
+
import { usePage } from "@akanjs/next";
|
|
4
|
+
import relativeTime from "dayjs/plugin/relativeTime";
|
|
5
|
+
dayjs.extend(relativeTime);
|
|
6
|
+
const RecentTime = ({
|
|
7
|
+
date,
|
|
8
|
+
breakUnit,
|
|
9
|
+
format = "auto",
|
|
10
|
+
className
|
|
11
|
+
}) => {
|
|
12
|
+
const { lang } = usePage();
|
|
13
|
+
const now = dayjs();
|
|
14
|
+
const datejs = dayjs(date).locale(lang);
|
|
15
|
+
const diff = dayjs().diff(datejs);
|
|
16
|
+
const dateFormat = format === "full" ? "YY-MM-DD HH:mm" : now.year() !== datejs.year() ? "YYYY-MM-DD" : now.month() !== datejs.month() || now.date() !== datejs.date() ? "MM-DD" : "HH:mm";
|
|
17
|
+
const diffSecs = Math.floor(diff / 1e3);
|
|
18
|
+
if (!date)
|
|
19
|
+
return null;
|
|
20
|
+
if (dayjs(0).isSame(date) || dayjs(-1).isSame(date))
|
|
21
|
+
return /* @__PURE__ */ React.createElement("span", null, "--:--");
|
|
22
|
+
if (breakUnit === "second")
|
|
23
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm:ss") }, datejs.format(dateFormat));
|
|
24
|
+
if (Math.abs(diffSecs) < 60)
|
|
25
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm") }, datejs.fromNow());
|
|
26
|
+
else if (breakUnit === "minute")
|
|
27
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm") }, datejs.format(dateFormat));
|
|
28
|
+
const diffMins = Math.floor(diff / (1e3 * 60));
|
|
29
|
+
if (Math.abs(diffMins) < 60)
|
|
30
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm") }, datejs.fromNow());
|
|
31
|
+
else if (breakUnit === "hour")
|
|
32
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm") }, datejs.format(dateFormat));
|
|
33
|
+
const diffHours = Math.floor(diff / (1e3 * 3600));
|
|
34
|
+
if (Math.abs(diffHours) < 24)
|
|
35
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm") }, datejs.fromNow());
|
|
36
|
+
else if (breakUnit === "day")
|
|
37
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm") }, datejs.format(dateFormat));
|
|
38
|
+
const diffDays = Math.floor(diff / (1e3 * 3600 * 24));
|
|
39
|
+
if (Math.abs(diffDays) < 7)
|
|
40
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm") }, datejs.fromNow());
|
|
41
|
+
else if (breakUnit === "week")
|
|
42
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm") }, datejs.format(dateFormat));
|
|
43
|
+
const diffWeeks = Math.floor(diff / (1e3 * 3600 * 24 * 7));
|
|
44
|
+
if (Math.abs(diffWeeks) < 4)
|
|
45
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm") }, datejs.fromNow());
|
|
46
|
+
else if (breakUnit === "month")
|
|
47
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm") }, datejs.format(dateFormat));
|
|
48
|
+
const diffMonths = Math.floor(diff / (1e3 * 3600 * 24 * 30));
|
|
49
|
+
if (Math.abs(diffMonths) < 12)
|
|
50
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm") }, datejs.fromNow());
|
|
51
|
+
else if (breakUnit === "year")
|
|
52
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm") }, datejs.format(dateFormat));
|
|
53
|
+
return /* @__PURE__ */ React.createElement("span", { className: clsx("tooltip", className), "data-tip": datejs.format("YYYY-MM-DD HH:mm") }, datejs.fromNow());
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
RecentTime
|
|
57
|
+
};
|
package/esm/Refresh.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { BiLoaderAlt } from "react-icons/bi";
|
|
3
|
+
import PullToRefresh from "react-simple-pull-to-refresh";
|
|
4
|
+
const Refresh = ({ children, onRefresh }) => {
|
|
5
|
+
return /* @__PURE__ */ React.createElement(
|
|
6
|
+
PullToRefresh,
|
|
7
|
+
{
|
|
8
|
+
onRefresh,
|
|
9
|
+
refreshingContent: /* @__PURE__ */ React.createElement("div", { className: "bg-base-100 fixed left-1/2 flex size-10 -translate-x-1/2 items-center justify-center rounded-full shadow-sm" }, /* @__PURE__ */ React.createElement(BiLoaderAlt, { className: "animate-spin text-2xl" }))
|
|
10
|
+
},
|
|
11
|
+
children
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
Refresh
|
|
16
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx } from "@akanjs/client";
|
|
3
|
+
import { useDrag } from "@use-gesture/react";
|
|
4
|
+
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
5
|
+
import { a, SpringValue, useSpringValue } from "react-spring";
|
|
6
|
+
const ScreenNavigatorContext = createContext({
|
|
7
|
+
bind: () => ({}),
|
|
8
|
+
xValue: new SpringValue(0),
|
|
9
|
+
setMenu: null,
|
|
10
|
+
onClickMenu: null,
|
|
11
|
+
currentMenu: "",
|
|
12
|
+
menus: []
|
|
13
|
+
});
|
|
14
|
+
const ScreenNavigator = ({
|
|
15
|
+
children,
|
|
16
|
+
setMenu = () => {
|
|
17
|
+
},
|
|
18
|
+
menus
|
|
19
|
+
}) => {
|
|
20
|
+
const [currentMenu, setCurrentMenu] = useState(menus[0]);
|
|
21
|
+
const xValue = useSpringValue(0, { config: { clamp: true } });
|
|
22
|
+
const ref = useRef(null);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!ref.current)
|
|
25
|
+
return;
|
|
26
|
+
const deviceWidth = ref.current.clientWidth / 2;
|
|
27
|
+
if (currentMenu === menus[1])
|
|
28
|
+
xValue.set(-deviceWidth);
|
|
29
|
+
else
|
|
30
|
+
xValue.set(0);
|
|
31
|
+
}, []);
|
|
32
|
+
const bind = useDrag(
|
|
33
|
+
({ first, last, offset: [x], velocity: [vx], direction: [dx], movement: [mx], cancel }) => {
|
|
34
|
+
if (!ref.current)
|
|
35
|
+
return;
|
|
36
|
+
//! 메뉴가 3개 이상일 경우 고려해야함
|
|
37
|
+
const deviceWidth = ref.current.clientWidth / 2;
|
|
38
|
+
if (x > 0 || x < -deviceWidth)
|
|
39
|
+
return;
|
|
40
|
+
if (dx < 1) {
|
|
41
|
+
if (x > -deviceWidth / 2) {
|
|
42
|
+
void xValue.start(x);
|
|
43
|
+
} else {
|
|
44
|
+
void xValue.start(-deviceWidth);
|
|
45
|
+
setCurrentMenu(menus[1]);
|
|
46
|
+
setMenu(menus[1]);
|
|
47
|
+
}
|
|
48
|
+
if (last && x > -deviceWidth / 2) {
|
|
49
|
+
void xValue.start(0);
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
if (x > -deviceWidth / 2) {
|
|
53
|
+
void xValue.start(0);
|
|
54
|
+
setCurrentMenu(menus[0]);
|
|
55
|
+
setMenu(menus[0]);
|
|
56
|
+
} else {
|
|
57
|
+
void xValue.start(x);
|
|
58
|
+
}
|
|
59
|
+
if (last && x < -deviceWidth / 2) {
|
|
60
|
+
void xValue.start(-deviceWidth);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{ axis: "x", filterTaps: true, threshold: 10 }
|
|
65
|
+
);
|
|
66
|
+
const onClickMenu = (menu) => {
|
|
67
|
+
if (!ref.current)
|
|
68
|
+
return;
|
|
69
|
+
const deviceWidth = ref.current.clientWidth / 2;
|
|
70
|
+
if (menu === menus[0]) {
|
|
71
|
+
void xValue.start(0);
|
|
72
|
+
setMenu(menus[0]);
|
|
73
|
+
setCurrentMenu(menus[0]);
|
|
74
|
+
} else {
|
|
75
|
+
void xValue.start(-deviceWidth);
|
|
76
|
+
setMenu(menus[1]);
|
|
77
|
+
setCurrentMenu(menus[1]);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return /* @__PURE__ */ React.createElement(ScreenNavigatorContext.Provider, { value: { bind, xValue, onClickMenu, menus, currentMenu, setMenu } }, /* @__PURE__ */ React.createElement(a.div, { ...bind(), className: "flex h-full w-[200vw] overflow-x-scroll", style: { x: xValue }, ref }, children));
|
|
81
|
+
};
|
|
82
|
+
const NavbarItem = ({ menu, children, className }) => {
|
|
83
|
+
const { onClickMenu, currentMenu } = useContext(ScreenNavigatorContext);
|
|
84
|
+
return /* @__PURE__ */ React.createElement(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
className: clsx(className, currentMenu === menu ? "opacity-100" : "opacity-40"),
|
|
88
|
+
onClick: () => {
|
|
89
|
+
onClickMenu(menu);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
children
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
ScreenNavigator.NavbarItem = NavbarItem;
|
|
96
|
+
const Screen = ({ children }) => {
|
|
97
|
+
return /* @__PURE__ */ React.createElement("div", { className: "h-full w-screen overflow-scroll", style: { touchAction: "pan-y" } }, children);
|
|
98
|
+
};
|
|
99
|
+
ScreenNavigator.Screen = Screen;
|
|
100
|
+
export {
|
|
101
|
+
ScreenNavigator
|
|
102
|
+
};
|