@akanjs/ui 0.0.149 → 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
package/esm/FontFace.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
const fontStyleMap = {
|
|
4
|
+
thin: 100,
|
|
5
|
+
extralight: 200,
|
|
6
|
+
light: 300,
|
|
7
|
+
regular: 400,
|
|
8
|
+
medium: 500,
|
|
9
|
+
extrabold: 600,
|
|
10
|
+
semibold: 700,
|
|
11
|
+
bold: 800,
|
|
12
|
+
black: 900
|
|
13
|
+
};
|
|
14
|
+
const fontWeightMap = {
|
|
15
|
+
100: "thin",
|
|
16
|
+
200: "extralight",
|
|
17
|
+
300: "light",
|
|
18
|
+
400: "regular",
|
|
19
|
+
500: "medium",
|
|
20
|
+
600: "extrabold",
|
|
21
|
+
700: "semibold",
|
|
22
|
+
800: "bold",
|
|
23
|
+
900: "black"
|
|
24
|
+
};
|
|
25
|
+
const FontFace = ({ font }) => {
|
|
26
|
+
const getWeight = (style) => {
|
|
27
|
+
const findWeight = font.paths.find((path) => fontWeightMap[path.weight] === style);
|
|
28
|
+
if (!findWeight) {
|
|
29
|
+
const findWeight2 = font.paths.reduce((prev, curr) => {
|
|
30
|
+
return Math.abs(fontStyleMap[style] - curr.weight) < Math.abs(fontStyleMap[style] - prev.weight) ? curr : prev;
|
|
31
|
+
}, font.paths[0]);
|
|
32
|
+
return findWeight2.weight;
|
|
33
|
+
}
|
|
34
|
+
return findWeight.weight;
|
|
35
|
+
};
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const styles = ["thin", "extralight", "light", "regular", "medium", "extrabold", "semibold", "bold", "black"];
|
|
38
|
+
const fontFace = `:root { --font-${font.name}: ${font.name}} ${styles.map(
|
|
39
|
+
(style2) => `@font-face {
|
|
40
|
+
font-family: '${font.name}';
|
|
41
|
+
src: url('${font.paths.find((path) => getWeight(style2) === path.weight)?.src}');
|
|
42
|
+
font-weight: ${getWeight(style2)};
|
|
43
|
+
font-style: ${style2};
|
|
44
|
+
}`
|
|
45
|
+
)}`;
|
|
46
|
+
const fontText = fontFace.replace(/,/g, " ");
|
|
47
|
+
const style = document.createElement("style");
|
|
48
|
+
style.appendChild(document.createTextNode(fontText));
|
|
49
|
+
document.head.appendChild(style);
|
|
50
|
+
return () => {
|
|
51
|
+
document.head.removeChild(style);
|
|
52
|
+
};
|
|
53
|
+
}, [font.name, font.paths]);
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
FontFace
|
|
58
|
+
};
|
package/esm/Image.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { baseClientEnv } from "@akanjs/base";
|
|
2
|
+
import { clsx } from "@akanjs/client";
|
|
3
|
+
import NextImage from "next/image";
|
|
4
|
+
import { CsrImage } from "./CsrImage";
|
|
5
|
+
const Image = ({
|
|
6
|
+
src,
|
|
7
|
+
file,
|
|
8
|
+
className,
|
|
9
|
+
abstractData,
|
|
10
|
+
alt,
|
|
11
|
+
...props
|
|
12
|
+
}) => {
|
|
13
|
+
const url = src ?? file?.url ?? "/empty.png";
|
|
14
|
+
const [width, height] = [props.width ?? file?.imageSize[0], props.height ?? file?.imageSize[1]];
|
|
15
|
+
const blurDataURL = abstractData ?? file?.abstractData;
|
|
16
|
+
return baseClientEnv.renderMode === "csr" ? /* @__PURE__ */ React.createElement(CsrImage, { src, file, abstractData, className, ...props }) : /* @__PURE__ */ React.createElement(
|
|
17
|
+
NextImage,
|
|
18
|
+
{
|
|
19
|
+
src: url,
|
|
20
|
+
fill: props.fill ?? (!width && !height),
|
|
21
|
+
width,
|
|
22
|
+
height,
|
|
23
|
+
className: clsx("object-cover", className),
|
|
24
|
+
alt: alt ?? "image",
|
|
25
|
+
...blurDataURL ? { placeholder: "blur", blurDataURL } : {},
|
|
26
|
+
...props
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
Image
|
|
32
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { BiLoaderAlt } from "react-icons/bi";
|
|
4
|
+
const InfiniteScroll = ({
|
|
5
|
+
itemsPerPage,
|
|
6
|
+
currentPage,
|
|
7
|
+
total,
|
|
8
|
+
onPageSelect,
|
|
9
|
+
onAddPage,
|
|
10
|
+
children,
|
|
11
|
+
reverse
|
|
12
|
+
}) => {
|
|
13
|
+
const [isFetching, setIsFetching] = useState(false);
|
|
14
|
+
const target = useRef(null);
|
|
15
|
+
const page = useRef(currentPage);
|
|
16
|
+
const totalPages = Math.ceil(total / (itemsPerPage || 1));
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const observer = new IntersectionObserver((entries) => {
|
|
19
|
+
const [entry] = entries;
|
|
20
|
+
if (entry.isIntersecting)
|
|
21
|
+
void fetchMoreItems();
|
|
22
|
+
});
|
|
23
|
+
if (target.current)
|
|
24
|
+
observer.observe(target.current);
|
|
25
|
+
return () => {
|
|
26
|
+
observer.disconnect();
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
const fetchMoreItems = async () => {
|
|
30
|
+
if (isFetching)
|
|
31
|
+
return;
|
|
32
|
+
const nextPage = page.current + 1;
|
|
33
|
+
if (nextPage > totalPages)
|
|
34
|
+
return;
|
|
35
|
+
setIsFetching(true);
|
|
36
|
+
await onAddPage(nextPage);
|
|
37
|
+
void onAddPage(nextPage);
|
|
38
|
+
onPageSelect(nextPage);
|
|
39
|
+
setIsFetching(false);
|
|
40
|
+
page.current = nextPage;
|
|
41
|
+
};
|
|
42
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, reverse ? /* @__PURE__ */ React.createElement("div", { ref: target, className: "flex w-full items-end justify-center" }, isFetching && /* @__PURE__ */ React.createElement(BiLoaderAlt, { className: "h-10 animate-spin pb-4 text-2xl" })) : null, children, !reverse ? /* @__PURE__ */ React.createElement("div", { ref: target, className: "flex h-32 w-full justify-center pt-4" }, isFetching && /* @__PURE__ */ React.createElement(BiLoaderAlt, { className: "animate-spin text-2xl" })) : null);
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
InfiniteScroll
|
|
46
|
+
};
|
package/esm/Input.js
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx } from "@akanjs/client";
|
|
3
|
+
import { isEmail } from "@akanjs/common";
|
|
4
|
+
import { usePage } from "@akanjs/next";
|
|
5
|
+
import React, {
|
|
6
|
+
useEffect,
|
|
7
|
+
useRef,
|
|
8
|
+
useState
|
|
9
|
+
} from "react";
|
|
10
|
+
import { AiOutlineEye, AiOutlineEyeInvisible } from "react-icons/ai";
|
|
11
|
+
const Input = ({
|
|
12
|
+
className,
|
|
13
|
+
nullable,
|
|
14
|
+
inputRef,
|
|
15
|
+
value,
|
|
16
|
+
cacheKey,
|
|
17
|
+
inputStyleType = "bordered",
|
|
18
|
+
icon,
|
|
19
|
+
iconClassName,
|
|
20
|
+
inputClassName,
|
|
21
|
+
inputWrapperClassName,
|
|
22
|
+
onPressEnter,
|
|
23
|
+
onPressEscape,
|
|
24
|
+
onChange,
|
|
25
|
+
validate,
|
|
26
|
+
...rest
|
|
27
|
+
}) => {
|
|
28
|
+
const { l } = usePage();
|
|
29
|
+
const [firstFocus, setFirstFocus] = useState(true);
|
|
30
|
+
const validateResult = validate(value);
|
|
31
|
+
const status = !nullable && !value ? null : !value.length ? "warning" : validateResult === true ? "success" : "error";
|
|
32
|
+
const invalidMessage = value && !value.length || validateResult === true || firstFocus ? null : validateResult === false ? l("util.invalidValueError") : validateResult;
|
|
33
|
+
const statusClass = inputStyleType === "bordered" ? status === "error" ? "input-error" : !firstFocus && status === "warning" ? "input-warning" : status === "success" ? "input-success" : "" : "";
|
|
34
|
+
const inputType = inputStyleType === "bordered" ? "input" : inputStyleType === "borderless" ? "input-ghost" : "border-0 border-b rounded-none";
|
|
35
|
+
const handleKeyDown = (e) => {
|
|
36
|
+
if (onPressEnter && e.key === "Enter")
|
|
37
|
+
onPressEnter(e.currentTarget.value, e);
|
|
38
|
+
if (e.key === "Escape") {
|
|
39
|
+
e.currentTarget.blur();
|
|
40
|
+
onPressEscape?.(e);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!cacheKey)
|
|
45
|
+
return;
|
|
46
|
+
sessionStorage.setItem(cacheKey, value);
|
|
47
|
+
}, [value]);
|
|
48
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx("relative isolate flex items-center", className) }, icon ? /* @__PURE__ */ React.createElement("div", { className: clsx("flex items-center justify-center", iconClassName) }, icon) : null, /* @__PURE__ */ React.createElement(
|
|
49
|
+
"input",
|
|
50
|
+
{
|
|
51
|
+
...rest,
|
|
52
|
+
ref: inputRef,
|
|
53
|
+
value,
|
|
54
|
+
onChange: (e) => {
|
|
55
|
+
if (cacheKey) {
|
|
56
|
+
sessionStorage.setItem(cacheKey, e.target.value);
|
|
57
|
+
}
|
|
58
|
+
onChange?.(e.target.value, e);
|
|
59
|
+
},
|
|
60
|
+
onBlur: (e) => {
|
|
61
|
+
if (firstFocus && value)
|
|
62
|
+
setFirstFocus(false);
|
|
63
|
+
},
|
|
64
|
+
onKeyDown: handleKeyDown,
|
|
65
|
+
className: clsx(
|
|
66
|
+
`b-5 focus:border-primary text-base-content outline-hidden duration-300 focus:outline-hidden ${icon && ""}`,
|
|
67
|
+
inputType,
|
|
68
|
+
// statusClass,
|
|
69
|
+
inputClassName
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
), /* @__PURE__ */ React.createElement(
|
|
73
|
+
"div",
|
|
74
|
+
{
|
|
75
|
+
"data-validate": !!validateResult,
|
|
76
|
+
className: "text-error absolute -bottom-4 text-xs whitespace-nowrap duration-300"
|
|
77
|
+
},
|
|
78
|
+
invalidMessage
|
|
79
|
+
));
|
|
80
|
+
};
|
|
81
|
+
const TextArea = ({
|
|
82
|
+
className,
|
|
83
|
+
nullable,
|
|
84
|
+
value,
|
|
85
|
+
inputClassName,
|
|
86
|
+
inputWrapperClassName,
|
|
87
|
+
cacheKey,
|
|
88
|
+
onPressEnter,
|
|
89
|
+
onPressEscape,
|
|
90
|
+
onChange,
|
|
91
|
+
validate,
|
|
92
|
+
...rest
|
|
93
|
+
}) => {
|
|
94
|
+
const { l } = usePage();
|
|
95
|
+
const inputRef = useRef(null);
|
|
96
|
+
const validateResult = validate(value);
|
|
97
|
+
const [firstFocus, setFirstFocus] = useState(true);
|
|
98
|
+
const status = !nullable && !value.length ? "warning" : validateResult === true ? "success" : "error";
|
|
99
|
+
const invalidMessage = !value.length || validateResult === true || firstFocus ? null : validateResult === false ? l("util.invalidValueError") : validateResult;
|
|
100
|
+
const statusClass = status === "error" ? "textarea-error" : !firstFocus && status === "warning" ? "textarea-warning" : status === "success" ? "textarea-success" : "";
|
|
101
|
+
const handleKeyDown = (e) => {
|
|
102
|
+
if (onPressEnter && e.key === "Enter")
|
|
103
|
+
onPressEnter(e.currentTarget.value, e);
|
|
104
|
+
};
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (!cacheKey)
|
|
107
|
+
return;
|
|
108
|
+
const value2 = sessionStorage.getItem(cacheKey);
|
|
109
|
+
if (value2) {
|
|
110
|
+
onChange?.(value2);
|
|
111
|
+
}
|
|
112
|
+
}, []);
|
|
113
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx("relative mb-5", className) }, /* @__PURE__ */ React.createElement(
|
|
114
|
+
"textarea",
|
|
115
|
+
{
|
|
116
|
+
...rest,
|
|
117
|
+
ref: inputRef,
|
|
118
|
+
value,
|
|
119
|
+
onChange: (e) => {
|
|
120
|
+
if (cacheKey) {
|
|
121
|
+
sessionStorage.setItem(cacheKey, e.target.value);
|
|
122
|
+
}
|
|
123
|
+
onChange?.(e.target.value, e);
|
|
124
|
+
},
|
|
125
|
+
onKeyDown: handleKeyDown,
|
|
126
|
+
onBlur: (e) => {
|
|
127
|
+
if (firstFocus && value)
|
|
128
|
+
setFirstFocus(false);
|
|
129
|
+
},
|
|
130
|
+
className: clsx(
|
|
131
|
+
`textarea textarea-bordered focus:border-primary text-base-content resize-none outline-hidden duration-300 focus:outline-hidden`,
|
|
132
|
+
statusClass,
|
|
133
|
+
inputClassName
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
), invalidMessage ? /* @__PURE__ */ React.createElement("div", { className: "text-error animate-fadeIn absolute -bottom-4 text-xs" }, invalidMessage) : null);
|
|
137
|
+
};
|
|
138
|
+
Input.TextArea = TextArea;
|
|
139
|
+
const Password = ({
|
|
140
|
+
className,
|
|
141
|
+
nullable,
|
|
142
|
+
value,
|
|
143
|
+
icon,
|
|
144
|
+
iconClassName,
|
|
145
|
+
inputClassName,
|
|
146
|
+
inputWrapperClassName,
|
|
147
|
+
cacheKey,
|
|
148
|
+
onPressEnter,
|
|
149
|
+
onPressEscape,
|
|
150
|
+
onChange,
|
|
151
|
+
validate,
|
|
152
|
+
...rest
|
|
153
|
+
}) => {
|
|
154
|
+
const { l } = usePage();
|
|
155
|
+
const inputRef = useRef(null);
|
|
156
|
+
const validateResult = validate(value);
|
|
157
|
+
const [firstFocus, setFirstFocus] = useState(true);
|
|
158
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
159
|
+
const status = !nullable && !value.length ? "warning" : validateResult === true ? "success" : "error";
|
|
160
|
+
const invalidMessage = !value.length || validateResult === true || firstFocus ? "" : validateResult === false ? l("util.invalidValueError") : validateResult;
|
|
161
|
+
const statusClass = status === "error" ? "input-error" : !firstFocus && status === "warning" ? "input-warning" : status === "success" ? "input-success" : "";
|
|
162
|
+
const handleKeyDown = (e) => {
|
|
163
|
+
if (onPressEnter && e.key === "Enter")
|
|
164
|
+
onPressEnter(e.currentTarget.value, e);
|
|
165
|
+
if (onPressEscape && e.key === "Escape")
|
|
166
|
+
onPressEscape(e);
|
|
167
|
+
};
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
if (!cacheKey)
|
|
170
|
+
return;
|
|
171
|
+
const value2 = sessionStorage.getItem(cacheKey);
|
|
172
|
+
if (value2) {
|
|
173
|
+
onChange?.(value2);
|
|
174
|
+
}
|
|
175
|
+
}, []);
|
|
176
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx("relative isolate pb-2", className) }, /* @__PURE__ */ React.createElement("div", { className: clsx("relative flex items-center justify-between", inputWrapperClassName) }, icon ? /* @__PURE__ */ React.createElement("div", { className: clsx("absolute inset-y-0 left-4 z-10 flex items-center justify-center", iconClassName) }, icon) : null, /* @__PURE__ */ React.createElement(
|
|
177
|
+
"input",
|
|
178
|
+
{
|
|
179
|
+
...rest,
|
|
180
|
+
type: showPassword ? "text" : "password",
|
|
181
|
+
ref: inputRef,
|
|
182
|
+
value,
|
|
183
|
+
onBlur: (e) => {
|
|
184
|
+
if (firstFocus && value)
|
|
185
|
+
setFirstFocus(false);
|
|
186
|
+
},
|
|
187
|
+
onKeyDown: handleKeyDown,
|
|
188
|
+
onChange: (e) => {
|
|
189
|
+
if (cacheKey) {
|
|
190
|
+
sessionStorage.setItem(cacheKey, e.target.value);
|
|
191
|
+
}
|
|
192
|
+
onChange?.(e.target.value, e);
|
|
193
|
+
},
|
|
194
|
+
className: clsx(
|
|
195
|
+
`input focus:border-primary text-base-content duration-300 focus:outline-hidden ${icon && "pl-12"}`,
|
|
196
|
+
statusClass,
|
|
197
|
+
inputClassName
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
), /* @__PURE__ */ React.createElement("div", { className: "absolute top-1/2 right-2 flex -translate-y-1/2 items-center justify-center" }, /* @__PURE__ */ React.createElement(
|
|
201
|
+
"button",
|
|
202
|
+
{
|
|
203
|
+
onClick: () => {
|
|
204
|
+
setShowPassword(!showPassword);
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
showPassword ? /* @__PURE__ */ React.createElement(AiOutlineEye, null) : /* @__PURE__ */ React.createElement(AiOutlineEyeInvisible, null)
|
|
208
|
+
))), /* @__PURE__ */ React.createElement(
|
|
209
|
+
"div",
|
|
210
|
+
{
|
|
211
|
+
"data-validate": !!invalidMessage.length,
|
|
212
|
+
className: "text-error h-2 text-xs duration-300 data-[validate=false]:opacity-0 data-[validate=true]:opacity-100"
|
|
213
|
+
},
|
|
214
|
+
invalidMessage
|
|
215
|
+
));
|
|
216
|
+
};
|
|
217
|
+
Input.Password = Password;
|
|
218
|
+
const Email = ({
|
|
219
|
+
inputStyleType = "bordered",
|
|
220
|
+
className,
|
|
221
|
+
nullable,
|
|
222
|
+
value,
|
|
223
|
+
cacheKey,
|
|
224
|
+
onPressEnter,
|
|
225
|
+
onPressEscape,
|
|
226
|
+
onChange,
|
|
227
|
+
validate,
|
|
228
|
+
icon,
|
|
229
|
+
iconClassName,
|
|
230
|
+
inputClassName,
|
|
231
|
+
inputWrapperClassName,
|
|
232
|
+
...rest
|
|
233
|
+
}) => {
|
|
234
|
+
const { l } = usePage();
|
|
235
|
+
const inputRef = useRef(null);
|
|
236
|
+
const isValidEmail = isEmail(value);
|
|
237
|
+
const [firstFocus, setFirstFocus] = useState(true);
|
|
238
|
+
const validateResult = !isValidEmail ? l("util.emailInvalidError") : validate(value);
|
|
239
|
+
const status = !nullable && !value.length ? "warning" : !isValidEmail ? "error" : validateResult === true ? "success" : "error";
|
|
240
|
+
const invalidMessage = !value.length || validateResult === true || firstFocus ? null : validateResult === false ? l("util.invalidValueError") : validateResult;
|
|
241
|
+
const statusClass = status === "error" ? "input-error" : !firstFocus && status === "warning" ? "input-warning" : status === "success" ? "input-success" : "";
|
|
242
|
+
const inputType = inputStyleType === "bordered" ? "input-bordered" : inputStyleType === "borderless" ? "input" : "input-bordered rounded-none";
|
|
243
|
+
const handleKeyDown = (e) => {
|
|
244
|
+
if (onPressEnter && e.key === "Enter")
|
|
245
|
+
onPressEnter(e.currentTarget.value, e);
|
|
246
|
+
if (e.key === "Escape") {
|
|
247
|
+
e.currentTarget.blur();
|
|
248
|
+
onPressEscape?.(e);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
useEffect(() => {
|
|
252
|
+
if (!cacheKey)
|
|
253
|
+
return;
|
|
254
|
+
const value2 = sessionStorage.getItem(cacheKey);
|
|
255
|
+
if (value2) {
|
|
256
|
+
onChange?.(value2);
|
|
257
|
+
}
|
|
258
|
+
}, []);
|
|
259
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx("relative isolate mb-5", className) }, /* @__PURE__ */ React.createElement("div", { className: clsx("flex items-center", inputWrapperClassName) }, icon ? /* @__PURE__ */ React.createElement("div", { className: clsx("absolute inset-y-0 left-4 z-10 flex items-center justify-center", iconClassName) }, icon) : null, /* @__PURE__ */ React.createElement(
|
|
260
|
+
"input",
|
|
261
|
+
{
|
|
262
|
+
...rest,
|
|
263
|
+
type: "email",
|
|
264
|
+
value,
|
|
265
|
+
ref: inputRef,
|
|
266
|
+
onKeyDown: handleKeyDown,
|
|
267
|
+
onBlur: (e) => {
|
|
268
|
+
if (firstFocus && value)
|
|
269
|
+
setFirstFocus(false);
|
|
270
|
+
},
|
|
271
|
+
onChange: (e) => {
|
|
272
|
+
if (cacheKey) {
|
|
273
|
+
sessionStorage.setItem(cacheKey, e.target.value);
|
|
274
|
+
}
|
|
275
|
+
onChange?.(e.target.value, e);
|
|
276
|
+
},
|
|
277
|
+
className: clsx(
|
|
278
|
+
`input focus:border-primary text-base-content outline-hidden duration-300 focus:outline-hidden ${icon && "pl-12"}`,
|
|
279
|
+
inputType,
|
|
280
|
+
statusClass,
|
|
281
|
+
inputClassName
|
|
282
|
+
)
|
|
283
|
+
}
|
|
284
|
+
)), invalidMessage ? /* @__PURE__ */ React.createElement("div", { className: "text-error animate-fadeIn absolute -bottom-4 text-xs" }, invalidMessage) : null);
|
|
285
|
+
};
|
|
286
|
+
Input.Email = Email;
|
|
287
|
+
const Number = ({
|
|
288
|
+
className,
|
|
289
|
+
nullable,
|
|
290
|
+
value,
|
|
291
|
+
icon,
|
|
292
|
+
cacheKey,
|
|
293
|
+
iconClassName,
|
|
294
|
+
inputClassName,
|
|
295
|
+
inputWrapperClassName,
|
|
296
|
+
numberFormat,
|
|
297
|
+
onPressEnter,
|
|
298
|
+
onPressEscape,
|
|
299
|
+
validate,
|
|
300
|
+
onChange,
|
|
301
|
+
formatter,
|
|
302
|
+
parser,
|
|
303
|
+
...rest
|
|
304
|
+
}) => {
|
|
305
|
+
const { l } = usePage();
|
|
306
|
+
const inputRef = useRef(null);
|
|
307
|
+
const validateResult = validate ? validate(value) : void 0;
|
|
308
|
+
const generateFormat = () => {
|
|
309
|
+
return isNaN(value ?? 0) ? "" : formatter ? formatter(value?.toString() ?? "") : value?.toString() ?? "";
|
|
310
|
+
};
|
|
311
|
+
const [firstFocus, setFirstFocus] = useState(true);
|
|
312
|
+
const [formatValue, setFormatValue] = useState(generateFormat());
|
|
313
|
+
const status = validate !== void 0 ? validateResult === true ? "success" : "error" : !nullable && value === null ? "warning" : "";
|
|
314
|
+
const invalidMessage = value === null || validateResult === true ? null : validateResult === false ? l("util.invalidValueError") : validateResult;
|
|
315
|
+
const statusClass = validate !== void 0 ? status === "error" ? "input-error" : !firstFocus && status === "warning" ? "input-warning" : status === "success" ? "input-success" : "input" : "input";
|
|
316
|
+
const handleKeyDown = (e) => {
|
|
317
|
+
const numberValue = parseFloat(e.currentTarget.value.replace(/[^\d-]/g, ""));
|
|
318
|
+
if (e.key === "Enter") {
|
|
319
|
+
if (isNaN(numberValue)) {
|
|
320
|
+
e.currentTarget.value = "";
|
|
321
|
+
setFormatValue("");
|
|
322
|
+
onChange(null);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (rest.max !== void 0 && numberValue > parseFloat(rest.max)) {
|
|
326
|
+
const maxValue = formatter ? formatter(String(rest.max)) : String(rest.max);
|
|
327
|
+
e.currentTarget.value = maxValue;
|
|
328
|
+
setFormatValue(maxValue);
|
|
329
|
+
onPressEnter?.(parseFloat(maxValue), e);
|
|
330
|
+
return;
|
|
331
|
+
} else if (rest.min !== void 0 && numberValue < parseFloat(rest.min)) {
|
|
332
|
+
const minValue = formatter ? formatter(String(rest.min)) : String(rest.min);
|
|
333
|
+
e.currentTarget.value = minValue;
|
|
334
|
+
setFormatValue(minValue);
|
|
335
|
+
onPressEnter?.(parseFloat(minValue), e);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
setFormatValue(formatter ? formatter(String(numberValue)) : String(numberValue));
|
|
339
|
+
onPressEnter?.(numberValue, e);
|
|
340
|
+
}
|
|
341
|
+
if (e.key === "Escape") {
|
|
342
|
+
if (isNaN(numberValue)) {
|
|
343
|
+
e.currentTarget.value = "";
|
|
344
|
+
setFormatValue("");
|
|
345
|
+
onChange(null);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (rest.max !== void 0 && numberValue > parseFloat(rest.max)) {
|
|
349
|
+
e.currentTarget.value = formatter ? formatter(String(rest.max)) : String(rest.max);
|
|
350
|
+
} else if (rest.min !== void 0 && numberValue < parseFloat(rest.min)) {
|
|
351
|
+
e.currentTarget.value = formatter ? formatter(String(rest.min)) : String(rest.min);
|
|
352
|
+
}
|
|
353
|
+
e.currentTarget.blur();
|
|
354
|
+
onPressEscape?.(e);
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
useEffect(() => {
|
|
358
|
+
if (cacheKey) {
|
|
359
|
+
const value2 = sessionStorage.getItem(cacheKey);
|
|
360
|
+
if (value2) {
|
|
361
|
+
setFormatValue(value2);
|
|
362
|
+
onChange(parser ? parseFloat(value2) : parseFloat(value2));
|
|
363
|
+
}
|
|
364
|
+
} else {
|
|
365
|
+
setFormatValue(generateFormat());
|
|
366
|
+
}
|
|
367
|
+
}, []);
|
|
368
|
+
useEffect(() => {
|
|
369
|
+
setFormatValue(generateFormat());
|
|
370
|
+
}, [value]);
|
|
371
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx("relative isolate mb-2", className) }, /* @__PURE__ */ React.createElement("div", { className: clsx("flex items-center", inputWrapperClassName) }, icon ? /* @__PURE__ */ React.createElement("div", { className: clsx("absolute inset-y-0 left-4 z-10 flex items-center justify-center", iconClassName) }, icon) : null, /* @__PURE__ */ React.createElement(
|
|
372
|
+
"input",
|
|
373
|
+
{
|
|
374
|
+
...rest,
|
|
375
|
+
ref: inputRef,
|
|
376
|
+
value: formatValue,
|
|
377
|
+
onKeyDown: handleKeyDown,
|
|
378
|
+
onBlur: (e) => {
|
|
379
|
+
if (firstFocus && value)
|
|
380
|
+
setFirstFocus(false);
|
|
381
|
+
},
|
|
382
|
+
onChange: (e) => {
|
|
383
|
+
const parsedValue = parser ? parser(e.target.value) : e.target.value;
|
|
384
|
+
setFormatValue(formatter ? formatter(parsedValue) : e.target.value);
|
|
385
|
+
onChange(parser ? parseFloat(parsedValue) : parseFloat(e.target.value), e);
|
|
386
|
+
if (cacheKey)
|
|
387
|
+
sessionStorage.setItem(cacheKey, parsedValue);
|
|
388
|
+
},
|
|
389
|
+
className: clsx(
|
|
390
|
+
`input focus:border-primary text-base-content duration-300 focus:outline-hidden ${icon && "pl-12"}`,
|
|
391
|
+
statusClass,
|
|
392
|
+
inputClassName
|
|
393
|
+
)
|
|
394
|
+
}
|
|
395
|
+
)), invalidMessage ? /* @__PURE__ */ React.createElement("div", { className: "text-error animate-fadeIn absolute -bottom-4 text-xs" }, invalidMessage) : null);
|
|
396
|
+
};
|
|
397
|
+
Input.Number = Number;
|
|
398
|
+
const Checkbox = ({ checked, onChange, className, ...rest }) => {
|
|
399
|
+
return /* @__PURE__ */ React.createElement(
|
|
400
|
+
"input",
|
|
401
|
+
{
|
|
402
|
+
...rest,
|
|
403
|
+
type: "checkbox",
|
|
404
|
+
checked,
|
|
405
|
+
className: clsx("checkbox", className),
|
|
406
|
+
onChange: (e) => {
|
|
407
|
+
onChange(e.target.checked, e);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
};
|
|
412
|
+
Input.Checkbox = Checkbox;
|
|
413
|
+
export {
|
|
414
|
+
Input
|
|
415
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCsr } from "@akanjs/client";
|
|
3
|
+
import { st } from "@akanjs/store";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { a, useSpring } from "react-spring";
|
|
6
|
+
const KeyboardAvoiding = ({ children, className }) => {
|
|
7
|
+
const keyboardHeight = st.use.keyboardHeight();
|
|
8
|
+
const defaultHeight = useRef(null);
|
|
9
|
+
const pageState = st.use.pageState();
|
|
10
|
+
const { pageContentRef } = useCsr();
|
|
11
|
+
const [{ height }, setSpring] = useSpring(() => ({
|
|
12
|
+
height: 0,
|
|
13
|
+
config: { duration: 100 }
|
|
14
|
+
}));
|
|
15
|
+
const onChange = async (height2) => {
|
|
16
|
+
await Promise.all([setSpring.start({ height: height2 })]);
|
|
17
|
+
};
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const test = async () => {
|
|
20
|
+
if (!pageContentRef.current)
|
|
21
|
+
return;
|
|
22
|
+
const newHeight = keyboardHeight ? keyboardHeight - pageState.bottomSafeArea : 0;
|
|
23
|
+
await onChange(newHeight);
|
|
24
|
+
if (Math.floor(pageContentRef.current.scrollTop + pageContentRef.current.clientHeight) === pageContentRef.current.scrollHeight)
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
if (!pageContentRef.current)
|
|
27
|
+
return;
|
|
28
|
+
pageContentRef.current.scrollTo({
|
|
29
|
+
top: pageContentRef.current.scrollHeight,
|
|
30
|
+
behavior: "smooth"
|
|
31
|
+
});
|
|
32
|
+
}, 200);
|
|
33
|
+
};
|
|
34
|
+
void test();
|
|
35
|
+
}, [keyboardHeight]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (pageContentRef.current) {
|
|
38
|
+
const heightNum = parseInt(pageContentRef.current.style.height.replace("px", ""));
|
|
39
|
+
defaultHeight.current = heightNum;
|
|
40
|
+
}
|
|
41
|
+
}, []);
|
|
42
|
+
return /* @__PURE__ */ React.createElement(a.div, { className: "h-auto", style: { marginBottom: height } }, children);
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
KeyboardAvoiding
|
|
46
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Portal } from "../Portal";
|
|
2
|
+
const BottomAction = ({ className, children }) => {
|
|
3
|
+
return /* @__PURE__ */ React.createElement(Portal, { id: "bottomActionContent" }, /* @__PURE__ */ React.createElement("div", { className }, children));
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
BottomAction
|
|
7
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { baseClientEnv } from "@akanjs/base";
|
|
3
|
+
import { clsx, usePathCtx } from "@akanjs/client";
|
|
4
|
+
import { st } from "@akanjs/store";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import { Portal } from "../Portal";
|
|
7
|
+
const BottomInset = ({ className, children, keyboardSticky }) => {
|
|
8
|
+
const [render, setRender] = useState(false);
|
|
9
|
+
const { location } = usePathCtx();
|
|
10
|
+
const suffix = baseClientEnv.renderMode === "csr" ? `-${location.pathRoute.path}` : "";
|
|
11
|
+
const keyboardHeight = st.use.keyboardHeight();
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
setRender(true);
|
|
14
|
+
}, []);
|
|
15
|
+
if (!render)
|
|
16
|
+
return null;
|
|
17
|
+
return /* @__PURE__ */ React.createElement(Portal, { id: `bottomInsetContent${suffix}` }, /* @__PURE__ */ React.createElement(
|
|
18
|
+
"div",
|
|
19
|
+
{
|
|
20
|
+
className: clsx(className, `size-full transition-all ease-out`, {
|
|
21
|
+
"duration-[285ms]": keyboardHeight,
|
|
22
|
+
"duration-0": !keyboardHeight,
|
|
23
|
+
absolute: keyboardSticky && keyboardHeight
|
|
24
|
+
}),
|
|
25
|
+
style: {
|
|
26
|
+
bottom: keyboardSticky && keyboardHeight ? keyboardHeight - location.pathRoute.pageState.bottomSafeArea : 0
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
children
|
|
30
|
+
));
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
BottomInset
|
|
34
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx } from "@akanjs/client";
|
|
3
|
+
import { usePage } from "@akanjs/next";
|
|
4
|
+
import { Link } from "../Link";
|
|
5
|
+
import { BottomInset } from "./BottomInset";
|
|
6
|
+
const BottomTab = ({ className, tabs, height = 64 }) => {
|
|
7
|
+
const { lang } = usePage();
|
|
8
|
+
const isActiveTab = (tabHref) => {
|
|
9
|
+
const locationPath = window.location.pathname.startsWith(`/${lang}`) ? window.location.pathname.slice(lang.length + 1) === "" ? "/" : window.location.pathname.slice(lang.length + 1) : window.location.pathname;
|
|
10
|
+
return tabHref === "/" ? locationPath === tabHref : locationPath.startsWith(tabHref);
|
|
11
|
+
};
|
|
12
|
+
return /* @__PURE__ */ React.createElement(BottomInset, { className: "h-full" }, /* @__PURE__ */ React.createElement(
|
|
13
|
+
"div",
|
|
14
|
+
{
|
|
15
|
+
className: clsx(
|
|
16
|
+
`bg-base-100 border-base-200 flex size-full items-center justify-around rounded-t-xl border border-b-0`,
|
|
17
|
+
className
|
|
18
|
+
)
|
|
19
|
+
},
|
|
20
|
+
tabs.map((tab) => /* @__PURE__ */ React.createElement(
|
|
21
|
+
Link,
|
|
22
|
+
{
|
|
23
|
+
key: tab.name,
|
|
24
|
+
href: tab.href,
|
|
25
|
+
className: `relative flex w-full flex-col items-center justify-end gap-1 ${isActiveTab(tab.href) ? "" : "opacity-60"}`
|
|
26
|
+
},
|
|
27
|
+
/* @__PURE__ */ React.createElement("div", { className: "indicator" }, isActiveTab(tab.href) ? tab.activeIcon ?? tab.icon : tab.icon, tab.notiCount && tab.notiCount > 0 ? (
|
|
28
|
+
// <div className="absolute top-1 right-2 bg-error w-5 h-5 rounded-full flex items-center justify-center text-base-100">
|
|
29
|
+
/* @__PURE__ */ React.createElement("div", { className: "indicator-item text-base-100 bg-secondary flex size-2 items-center justify-center rounded-full text-[10px]" })
|
|
30
|
+
) : null),
|
|
31
|
+
/* @__PURE__ */ React.createElement("span", null, tab.name)
|
|
32
|
+
))
|
|
33
|
+
));
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
BottomTab
|
|
37
|
+
};
|