@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.
Files changed (405) hide show
  1. package/BottomSheet.d.ts +13 -0
  2. package/Button.d.ts +9 -0
  3. package/ClientSide.d.ts +6 -0
  4. package/Copy.d.ts +6 -0
  5. package/CsrImage.d.ts +11 -0
  6. package/Data/CardList.d.ts +36 -0
  7. package/Data/Dashboard.d.ts +15 -0
  8. package/Data/Insight.d.ts +8 -0
  9. package/Data/Item.d.ts +74 -0
  10. package/Data/ListContainer.d.ts +38 -0
  11. package/Data/Pagination.d.ts +6 -0
  12. package/Data/QueryMaker.d.ts +9 -0
  13. package/Data/TableList.d.ts +26 -0
  14. package/Data/index.d.ts +10 -0
  15. package/Data/index_.d.ts +8 -0
  16. package/DatePicker.d.ts +38 -0
  17. package/Dialog/Action.d.ts +5 -0
  18. package/Dialog/Close.d.ts +5 -0
  19. package/Dialog/Content.d.ts +6 -0
  20. package/Dialog/Modal.d.ts +8 -0
  21. package/Dialog/Provider.d.ts +7 -0
  22. package/Dialog/Title.d.ts +5 -0
  23. package/Dialog/Trigger.d.ts +5 -0
  24. package/Dialog/context.d.ts +10 -0
  25. package/Dialog/index.d.ts +9 -0
  26. package/DragAction.d.ts +24 -0
  27. package/DraggableList.d.ts +25 -0
  28. package/Dropdown.d.ts +10 -0
  29. package/Empty.d.ts +9 -0
  30. package/Field.d.ts +404 -0
  31. package/FontFace.d.ts +6 -0
  32. package/Image.d.ts +17 -0
  33. package/InfiniteScroll.d.ts +10 -0
  34. package/Input.d.ts +85 -0
  35. package/KeyboardAvoiding.d.ts +7 -0
  36. package/Layout/BottomAction.d.ts +5 -0
  37. package/Layout/BottomInset.d.ts +6 -0
  38. package/Layout/BottomTab.d.ts +14 -0
  39. package/Layout/Header.d.ts +7 -0
  40. package/Layout/LeftSider.d.ts +8 -0
  41. package/Layout/Navbar.d.ts +11 -0
  42. package/Layout/RightSider.d.ts +9 -0
  43. package/Layout/Sider.d.ts +6 -0
  44. package/Layout/Template.d.ts +5 -0
  45. package/Layout/TopLeftAction.d.ts +5 -0
  46. package/Layout/Unit.d.ts +6 -0
  47. package/Layout/View.d.ts +5 -0
  48. package/Layout/Zone.d.ts +5 -0
  49. package/Layout/index.d.ts +14 -0
  50. package/Link/Back.d.ts +6 -0
  51. package/Link/Close.d.ts +6 -0
  52. package/Link/CsrLink.d.ts +2 -0
  53. package/Link/NextLink.d.ts +2 -0
  54. package/Link/index.d.ts +8 -0
  55. package/Link/types.d.ts +22 -0
  56. package/Load/Edit.d.ts +4 -0
  57. package/Load/Edit_Client.d.ts +25 -0
  58. package/Load/Page.d.ts +10 -0
  59. package/Load/PageCSR.d.ts +11 -0
  60. package/Load/Pagination.d.ts +8 -0
  61. package/Load/Units.d.ts +34 -0
  62. package/Load/View.d.ts +17 -0
  63. package/Load/index.d.ts +8 -0
  64. package/Load/index_.d.ts +3 -0
  65. package/Loading/Area.d.ts +1 -0
  66. package/Loading/Button.d.ts +7 -0
  67. package/Loading/Input.d.ts +7 -0
  68. package/Loading/ProgressBar.d.ts +6 -0
  69. package/Loading/Skeleton.d.ts +7 -0
  70. package/Loading/Spin.d.ts +7 -0
  71. package/Loading/index.d.ts +8 -0
  72. package/Menu.d.ts +26 -0
  73. package/Modal.d.ts +23 -0
  74. package/Model/Edit.d.ts +15 -0
  75. package/Model/EditModal.d.ts +33 -0
  76. package/Model/EditWrapper.d.ts +11 -0
  77. package/Model/LoadInit.d.ts +10 -0
  78. package/Model/New.d.ts +15 -0
  79. package/Model/NewWrapper.d.ts +12 -0
  80. package/Model/NewWrapper_Client.d.ts +12 -0
  81. package/Model/Remove.d.ts +10 -0
  82. package/Model/RemoveWrapper.d.ts +11 -0
  83. package/Model/SureToRemove.d.ts +10 -0
  84. package/Model/View.d.ts +19 -0
  85. package/Model/ViewEditModal.d.ts +11 -0
  86. package/Model/ViewModal.d.ts +13 -0
  87. package/Model/ViewWrapper.d.ts +11 -0
  88. package/Model/index.d.ts +15 -0
  89. package/Model/index_.d.ts +13 -0
  90. package/More.d.ts +12 -0
  91. package/ObjectId.d.ts +5 -0
  92. package/Pagination.d.ts +14 -0
  93. package/Popconfirm.d.ts +18 -0
  94. package/Portal.d.ts +6 -0
  95. package/Radio.d.ts +19 -0
  96. package/RecentTime.d.ts +7 -0
  97. package/Refresh.d.ts +7 -0
  98. package/ScreenNavigator.d.ts +18 -0
  99. package/Select.d.ts +29 -0
  100. package/Signal/Arg.d.ts +75 -0
  101. package/Signal/Doc.d.ts +19 -0
  102. package/Signal/GraphQL.d.ts +32 -0
  103. package/Signal/Listener.d.ts +9 -0
  104. package/Signal/Message.d.ts +27 -0
  105. package/Signal/Object.d.ts +19 -0
  106. package/Signal/PubSub.d.ts +26 -0
  107. package/Signal/Request.d.ts +8 -0
  108. package/Signal/Response.d.ts +16 -0
  109. package/Signal/RestApi.d.ts +40 -0
  110. package/Signal/WebSocket.d.ts +9 -0
  111. package/Signal/index.d.ts +20 -0
  112. package/System/CSR.d.ts +31 -0
  113. package/System/Client.d.ts +48 -0
  114. package/System/Common.d.ts +66 -0
  115. package/System/DevModeToggle.d.ts +1 -0
  116. package/System/Gtag.d.ts +3 -0
  117. package/System/HealthCheck.d.ts +5 -0
  118. package/System/Messages.d.ts +1 -0
  119. package/System/Reconnect.d.ts +6 -0
  120. package/System/Root.d.ts +5 -0
  121. package/System/SSR.d.ts +26 -0
  122. package/System/SelectLanguage.d.ts +5 -0
  123. package/System/ThemeToggle.d.ts +1 -0
  124. package/System/index.d.ts +11 -0
  125. package/Tab/Menu.d.ts +11 -0
  126. package/Tab/Menus.d.ts +5 -0
  127. package/Tab/Panel.d.ts +7 -0
  128. package/Tab/Provider.d.ts +6 -0
  129. package/Tab/context.d.ts +9 -0
  130. package/Tab/index.d.ts +7 -0
  131. package/Table.d.ts +26 -0
  132. package/ToggleSelect.d.ts +31 -0
  133. package/Unauthorized.d.ts +9 -0
  134. package/cjs/BottomSheet.js +113 -0
  135. package/cjs/Button.js +69 -0
  136. package/cjs/ClientSide.js +26 -0
  137. package/cjs/Copy.js +37 -0
  138. package/cjs/CsrImage.js +50 -0
  139. package/cjs/Data/CardList.js +119 -0
  140. package/cjs/Data/Dashboard.js +54 -0
  141. package/cjs/Data/Insight.js +38 -0
  142. package/cjs/Data/Item.js +204 -0
  143. package/cjs/Data/ListContainer.js +251 -0
  144. package/cjs/Data/Pagination.js +64 -0
  145. package/cjs/Data/QueryMaker.js +304 -0
  146. package/cjs/Data/TableList.js +139 -0
  147. package/cjs/Data/index.js +33 -0
  148. package/cjs/Data/index_.js +49 -0
  149. package/cjs/DatePicker.js +173 -0
  150. package/cjs/Dialog/Action.js +32 -0
  151. package/cjs/Dialog/Close.js +38 -0
  152. package/cjs/Dialog/Content.js +27 -0
  153. package/cjs/Dialog/Modal.js +155 -0
  154. package/cjs/Dialog/Provider.js +46 -0
  155. package/cjs/Dialog/Title.js +32 -0
  156. package/cjs/Dialog/Trigger.js +38 -0
  157. package/cjs/Dialog/context.js +32 -0
  158. package/cjs/Dialog/index.js +36 -0
  159. package/cjs/DragAction.js +111 -0
  160. package/cjs/DraggableList.js +141 -0
  161. package/cjs/Dropdown.js +64 -0
  162. package/cjs/Empty.js +50 -0
  163. package/cjs/Field.js +1109 -0
  164. package/cjs/FontFace.js +77 -0
  165. package/cjs/Image.js +61 -0
  166. package/cjs/InfiniteScroll.js +65 -0
  167. package/cjs/Input.js +440 -0
  168. package/cjs/KeyboardAvoiding.js +65 -0
  169. package/cjs/Layout/BottomAction.js +26 -0
  170. package/cjs/Layout/BottomInset.js +53 -0
  171. package/cjs/Layout/BottomTab.js +56 -0
  172. package/cjs/Layout/Header.js +52 -0
  173. package/cjs/Layout/LeftSider.js +49 -0
  174. package/cjs/Layout/Navbar.js +51 -0
  175. package/cjs/Layout/RightSider.js +52 -0
  176. package/cjs/Layout/Sider.js +39 -0
  177. package/cjs/Layout/Template.js +26 -0
  178. package/cjs/Layout/TopLeftAction.js +39 -0
  179. package/cjs/Layout/Unit.js +27 -0
  180. package/cjs/Layout/View.js +26 -0
  181. package/cjs/Layout/Zone.js +26 -0
  182. package/cjs/Layout/index.js +48 -0
  183. package/cjs/Link/Back.js +27 -0
  184. package/cjs/Link/Close.js +36 -0
  185. package/cjs/Link/CsrLink.js +49 -0
  186. package/cjs/Link/NextLink.js +71 -0
  187. package/cjs/Link/index.js +47 -0
  188. package/cjs/Link/types.js +15 -0
  189. package/cjs/Load/Edit.js +42 -0
  190. package/cjs/Load/Edit_Client.js +93 -0
  191. package/cjs/Load/Page.js +35 -0
  192. package/cjs/Load/PageCSR.js +67 -0
  193. package/cjs/Load/Pagination.js +89 -0
  194. package/cjs/Load/Units.js +232 -0
  195. package/cjs/Load/View.js +88 -0
  196. package/cjs/Load/index.js +42 -0
  197. package/cjs/Load/index_.js +39 -0
  198. package/cjs/Loading/Area.js +25 -0
  199. package/cjs/Loading/Button.js +33 -0
  200. package/cjs/Loading/Input.js +33 -0
  201. package/cjs/Loading/ProgressBar.js +29 -0
  202. package/cjs/Loading/Skeleton.js +27 -0
  203. package/cjs/Loading/Spin.js +27 -0
  204. package/cjs/Loading/index.js +29 -0
  205. package/cjs/Menu.js +215 -0
  206. package/cjs/Modal.js +75 -0
  207. package/cjs/Model/Edit.js +61 -0
  208. package/cjs/Model/EditModal.js +255 -0
  209. package/cjs/Model/EditWrapper.js +48 -0
  210. package/cjs/Model/LoadInit.js +27 -0
  211. package/cjs/Model/New.js +61 -0
  212. package/cjs/Model/NewWrapper.js +28 -0
  213. package/cjs/Model/NewWrapper_Client.js +66 -0
  214. package/cjs/Model/Remove.js +86 -0
  215. package/cjs/Model/RemoveWrapper.js +48 -0
  216. package/cjs/Model/SureToRemove.js +109 -0
  217. package/cjs/Model/View.js +44 -0
  218. package/cjs/Model/ViewEditModal.js +118 -0
  219. package/cjs/Model/ViewModal.js +92 -0
  220. package/cjs/Model/ViewWrapper.js +48 -0
  221. package/cjs/Model/index.js +38 -0
  222. package/cjs/Model/index_.js +58 -0
  223. package/cjs/More.js +67 -0
  224. package/cjs/ObjectId.js +37 -0
  225. package/cjs/Pagination.js +110 -0
  226. package/cjs/Popconfirm.js +116 -0
  227. package/cjs/Portal.js +27 -0
  228. package/cjs/Radio.js +53 -0
  229. package/cjs/RecentTime.js +86 -0
  230. package/cjs/Refresh.js +45 -0
  231. package/cjs/ScreenNavigator.js +121 -0
  232. package/cjs/Select.js +262 -0
  233. package/cjs/Signal/Arg.js +237 -0
  234. package/cjs/Signal/Doc.js +181 -0
  235. package/cjs/Signal/GraphQL.js +177 -0
  236. package/cjs/Signal/Listener.js +59 -0
  237. package/cjs/Signal/Message.js +190 -0
  238. package/cjs/Signal/Object.js +95 -0
  239. package/cjs/Signal/PubSub.js +191 -0
  240. package/cjs/Signal/Request.js +38 -0
  241. package/cjs/Signal/Response.js +53 -0
  242. package/cjs/Signal/RestApi.js +255 -0
  243. package/cjs/Signal/WebSocket.js +68 -0
  244. package/cjs/Signal/index.js +42 -0
  245. package/cjs/System/CSR.js +376 -0
  246. package/cjs/System/Client.js +200 -0
  247. package/cjs/System/Common.js +64 -0
  248. package/cjs/System/DevModeToggle.js +38 -0
  249. package/cjs/System/Gtag.js +67 -0
  250. package/cjs/System/HealthCheck.js +60 -0
  251. package/cjs/System/Messages.js +170 -0
  252. package/cjs/System/Reconnect.js +64 -0
  253. package/cjs/System/Root.js +30 -0
  254. package/cjs/System/SSR.js +144 -0
  255. package/cjs/System/SelectLanguage.js +58 -0
  256. package/cjs/System/ThemeToggle.js +40 -0
  257. package/cjs/System/index.js +55 -0
  258. package/cjs/Tab/Menu.js +70 -0
  259. package/cjs/{src/index.js → Tab/Menus.js} +8 -5
  260. package/cjs/Tab/Panel.js +42 -0
  261. package/cjs/Tab/Provider.js +31 -0
  262. package/cjs/Tab/context.js +30 -0
  263. package/cjs/Tab/index.js +32 -0
  264. package/cjs/Table.js +85 -0
  265. package/cjs/ToggleSelect.js +118 -0
  266. package/cjs/Unauthorized.js +50 -0
  267. package/cjs/index.js +88 -2
  268. package/esm/BottomSheet.js +84 -0
  269. package/esm/Button.js +40 -0
  270. package/esm/ClientSide.js +7 -0
  271. package/esm/Copy.js +18 -0
  272. package/esm/CsrImage.js +31 -0
  273. package/esm/Data/CardList.js +90 -0
  274. package/esm/Data/Dashboard.js +35 -0
  275. package/esm/Data/Insight.js +19 -0
  276. package/esm/Data/Item.js +175 -0
  277. package/esm/Data/ListContainer.js +228 -0
  278. package/esm/Data/Pagination.js +45 -0
  279. package/esm/Data/QueryMaker.js +293 -0
  280. package/esm/Data/TableList.js +110 -0
  281. package/esm/Data/index.js +14 -0
  282. package/esm/Data/index_.js +20 -0
  283. package/esm/DatePicker.js +144 -0
  284. package/esm/Dialog/Action.js +13 -0
  285. package/esm/Dialog/Close.js +19 -0
  286. package/esm/Dialog/Content.js +8 -0
  287. package/esm/Dialog/Modal.js +126 -0
  288. package/esm/Dialog/Provider.js +17 -0
  289. package/esm/Dialog/Title.js +13 -0
  290. package/esm/Dialog/Trigger.js +19 -0
  291. package/esm/Dialog/context.js +13 -0
  292. package/esm/Dialog/index.js +17 -0
  293. package/esm/DragAction.js +92 -0
  294. package/esm/DraggableList.js +112 -0
  295. package/esm/Dropdown.js +45 -0
  296. package/esm/Empty.js +21 -0
  297. package/esm/Field.js +1090 -0
  298. package/esm/FontFace.js +58 -0
  299. package/esm/Image.js +32 -0
  300. package/esm/InfiniteScroll.js +46 -0
  301. package/esm/Input.js +415 -0
  302. package/esm/KeyboardAvoiding.js +46 -0
  303. package/esm/Layout/BottomAction.js +7 -0
  304. package/esm/Layout/BottomInset.js +34 -0
  305. package/esm/Layout/BottomTab.js +37 -0
  306. package/esm/Layout/Header.js +33 -0
  307. package/esm/Layout/LeftSider.js +30 -0
  308. package/esm/Layout/Navbar.js +22 -0
  309. package/esm/Layout/RightSider.js +33 -0
  310. package/esm/Layout/Sider.js +20 -0
  311. package/esm/Layout/Template.js +7 -0
  312. package/esm/Layout/TopLeftAction.js +20 -0
  313. package/esm/Layout/Unit.js +8 -0
  314. package/esm/Layout/View.js +7 -0
  315. package/esm/Layout/Zone.js +7 -0
  316. package/esm/Layout/index.js +29 -0
  317. package/esm/Link/Back.js +8 -0
  318. package/esm/Link/Close.js +17 -0
  319. package/esm/Link/CsrLink.js +30 -0
  320. package/esm/Link/NextLink.js +42 -0
  321. package/esm/Link/index.js +18 -0
  322. package/esm/Link/types.js +0 -0
  323. package/esm/Load/Edit.js +13 -0
  324. package/esm/Load/Edit_Client.js +74 -0
  325. package/esm/Load/Page.js +16 -0
  326. package/esm/Load/PageCSR.js +48 -0
  327. package/esm/Load/Pagination.js +70 -0
  328. package/esm/Load/Units.js +213 -0
  329. package/esm/Load/View.js +69 -0
  330. package/esm/Load/index.js +13 -0
  331. package/esm/Load/index_.js +10 -0
  332. package/esm/Loading/Area.js +6 -0
  333. package/esm/Loading/Button.js +14 -0
  334. package/esm/Loading/Input.js +14 -0
  335. package/esm/Loading/ProgressBar.js +10 -0
  336. package/esm/Loading/Skeleton.js +8 -0
  337. package/esm/Loading/Spin.js +8 -0
  338. package/esm/Loading/index.js +10 -0
  339. package/esm/Menu.js +196 -0
  340. package/esm/Modal.js +46 -0
  341. package/esm/Model/Edit.js +32 -0
  342. package/esm/Model/EditModal.js +226 -0
  343. package/esm/Model/EditWrapper.js +29 -0
  344. package/esm/Model/LoadInit.js +8 -0
  345. package/esm/Model/New.js +32 -0
  346. package/esm/Model/NewWrapper.js +9 -0
  347. package/esm/Model/NewWrapper_Client.js +47 -0
  348. package/esm/Model/Remove.js +67 -0
  349. package/esm/Model/RemoveWrapper.js +29 -0
  350. package/esm/Model/SureToRemove.js +90 -0
  351. package/esm/Model/View.js +25 -0
  352. package/esm/Model/ViewEditModal.js +89 -0
  353. package/esm/Model/ViewModal.js +63 -0
  354. package/esm/Model/ViewWrapper.js +29 -0
  355. package/esm/Model/index.js +33 -0
  356. package/esm/Model/index_.js +29 -0
  357. package/esm/More.js +38 -0
  358. package/esm/ObjectId.js +18 -0
  359. package/esm/Pagination.js +91 -0
  360. package/esm/Popconfirm.js +87 -0
  361. package/esm/Portal.js +8 -0
  362. package/esm/Radio.js +34 -0
  363. package/esm/RecentTime.js +57 -0
  364. package/esm/Refresh.js +16 -0
  365. package/esm/ScreenNavigator.js +102 -0
  366. package/esm/Select.js +243 -0
  367. package/esm/Signal/Arg.js +208 -0
  368. package/esm/Signal/Doc.js +152 -0
  369. package/esm/Signal/GraphQL.js +156 -0
  370. package/esm/Signal/Listener.js +40 -0
  371. package/esm/Signal/Message.js +161 -0
  372. package/esm/Signal/Object.js +76 -0
  373. package/esm/Signal/PubSub.js +162 -0
  374. package/esm/Signal/Request.js +19 -0
  375. package/esm/Signal/Response.js +34 -0
  376. package/esm/Signal/RestApi.js +234 -0
  377. package/esm/Signal/WebSocket.js +39 -0
  378. package/esm/Signal/index.js +13 -0
  379. package/esm/System/CSR.js +357 -0
  380. package/esm/System/Client.js +191 -0
  381. package/esm/System/Common.js +45 -0
  382. package/esm/System/DevModeToggle.js +19 -0
  383. package/esm/System/Gtag.js +48 -0
  384. package/esm/System/HealthCheck.js +41 -0
  385. package/esm/System/Messages.js +156 -0
  386. package/esm/System/Reconnect.js +45 -0
  387. package/esm/System/Root.js +11 -0
  388. package/esm/System/SSR.js +125 -0
  389. package/esm/System/SelectLanguage.js +39 -0
  390. package/esm/System/ThemeToggle.js +21 -0
  391. package/esm/System/index.js +26 -0
  392. package/esm/Tab/Menu.js +51 -0
  393. package/esm/Tab/Menus.js +7 -0
  394. package/esm/Tab/Panel.js +23 -0
  395. package/esm/Tab/Provider.js +12 -0
  396. package/esm/Tab/context.js +11 -0
  397. package/esm/Tab/index.js +13 -0
  398. package/esm/Table.js +56 -0
  399. package/esm/ToggleSelect.js +99 -0
  400. package/esm/Unauthorized.js +21 -0
  401. package/esm/index.js +84 -1
  402. package/index.d.ts +41 -1
  403. package/package.json +23 -2
  404. package/esm/src/index.js +0 -4
  405. package/src/index.d.ts +0 -1
package/cjs/Menu.js ADDED
@@ -0,0 +1,215 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Menu_exports = {};
20
+ __export(Menu_exports, {
21
+ Menu: () => Menu
22
+ });
23
+ module.exports = __toCommonJS(Menu_exports);
24
+ var import_client = require("@akanjs/client");
25
+ var import_store = require("@akanjs/store");
26
+ var import_react = require("react");
27
+ var import_ai = require("react-icons/ai");
28
+ const Menu = ({
29
+ items,
30
+ onClick,
31
+ selectedKeys,
32
+ labelClassName,
33
+ defaultSelectedKeys,
34
+ className = "",
35
+ ulClassName = "",
36
+ liClassName,
37
+ style,
38
+ mode = "inline",
39
+ activeStyle = "bordered",
40
+ inlineCollapsed,
41
+ onMouseOver,
42
+ onMouseLeave
43
+ }) => {
44
+ const [expandedKey, setExpandedKey] = (0, import_react.useState)();
45
+ const [currentKey, setCurrentKey] = (0, import_react.useState)(defaultSelectedKeys?.[0] ?? null);
46
+ const modeClassName = mode === "horizontal" ? "menu-horizontal flex-row " : "bg-base-200";
47
+ const menuRef = (0, import_react.useRef)(null);
48
+ const LiRefs = (0, import_react.useRef)([]);
49
+ const overflowLiRef = (0, import_react.useRef)(null);
50
+ const itemWidthsRef = (0, import_react.useRef)([]);
51
+ const innerWidth = import_store.st.use.innerWidth();
52
+ const subMenuClassName = mode === "horizontal" ? `fixed menu-title bottom-0 translate-y-[98%] border-0 rounded-xs shadow-lg bg-base-100 hover:bg-base-100 flex flex-col` : "flex flex-col gap-0 p-0 bg-primary/10 hover:bg-primary/10 overflow-hidden";
53
+ const subMenuItemClassName = mode === "inline" ? "w-full h-full bg-red-500 btn btn-ghost px-2 m-0 hover:bg-primary/20 btn btn-ghost text-primary-focus font-normal" : "w-full text-center duration-300 whitespace-nowrap btn btn-ghost text-primary-focus font-normal";
54
+ const activeClassName = activeStyle === "active" ? "bg-primary text-primary-focus" : activeStyle === "bordered" ? " border-b-2 border-white" : activeStyle;
55
+ const [overflowMenuItems, setOverflowMenuItems] = (0, import_react.useState)([]);
56
+ (0, import_react.useLayoutEffect)(() => {
57
+ if (mode !== "horizontal")
58
+ return;
59
+ const menu = menuRef.current;
60
+ if (!menu)
61
+ return;
62
+ const liList = LiRefs.current;
63
+ const widths = [];
64
+ liList.forEach((li) => {
65
+ widths.push(li.getBoundingClientRect().width);
66
+ });
67
+ itemWidthsRef.current = widths;
68
+ checkOverflow();
69
+ }, []);
70
+ (0, import_react.useEffect)(() => {
71
+ checkOverflow();
72
+ }, [innerWidth]);
73
+ const checkOverflow = (0, import_react.useCallback)(() => {
74
+ if (mode !== "horizontal" || !itemWidthsRef.current.length)
75
+ return;
76
+ const menu = menuRef.current;
77
+ if (!menu)
78
+ return;
79
+ const totalWidth = menu.getBoundingClientRect().width;
80
+ const widths = itemWidthsRef.current;
81
+ const overflowItems = [];
82
+ let accumulatedWidth = 0;
83
+ for (let i = 0; i < widths.length; i++) {
84
+ accumulatedWidth += widths[i];
85
+ if (accumulatedWidth > totalWidth) {
86
+ if (overflowItems.length === 0 && i - 1 >= 0)
87
+ overflowItems.push(items[i - 1]);
88
+ overflowItems.push(items[i]);
89
+ }
90
+ }
91
+ setOverflowMenuItems(overflowItems);
92
+ }, [items, mode]);
93
+ const handleOnClick = (item) => {
94
+ setCurrentKey(item.key);
95
+ if (mode === "inline" && item.children)
96
+ setExpandedKey(item.key === expandedKey ? void 0 : item.key);
97
+ else
98
+ onClick?.(item);
99
+ };
100
+ const checkIsActive = (key) => {
101
+ if (selectedKeys)
102
+ return selectedKeys.includes(key);
103
+ return key === currentKey;
104
+ };
105
+ return /* @__PURE__ */ React.createElement(
106
+ "div",
107
+ {
108
+ ref: menuRef,
109
+ id: "menu",
110
+ className: (0, import_client.clsx)(mode === "horizontal" ? "w-full shrink overflow-hidden" : "w-fit", className)
111
+ },
112
+ /* @__PURE__ */ React.createElement(
113
+ "ul",
114
+ {
115
+ className: (0, import_client.clsx)("menu size-full flex-nowrap overflow-y-auto p-0", modeClassName, ulClassName),
116
+ style: { ...style },
117
+ onMouseOver,
118
+ onMouseLeave
119
+ },
120
+ items.filter((item) => !overflowMenuItems.some((overflowItem) => overflowItem.key === item.key)).map((item, idx) => {
121
+ const isOverflowItem = overflowMenuItems.some((overflowItem) => overflowItem.key === item.key);
122
+ const overflowClassName = isOverflowItem ? "opacity-50" : "";
123
+ return /* @__PURE__ */ React.createElement(
124
+ "li",
125
+ {
126
+ ref: (el) => {
127
+ if (el)
128
+ LiRefs.current[idx] = el;
129
+ },
130
+ id: item.key,
131
+ key: item.key,
132
+ className: (0, import_client.clsx)("relative m-0 duration-200 hover:opacity-70", overflowClassName, liClassName, {
133
+ "bg-base-300": activeStyle === "active" && checkIsActive(item.key),
134
+ "border-base-100 border-b-2": activeStyle === "bordered" && checkIsActive(item.key)
135
+ }),
136
+ onClick: () => {
137
+ if (!isOverflowItem)
138
+ handleOnClick(item);
139
+ },
140
+ onMouseEnter: () => {
141
+ if (mode === "horizontal" && !isOverflowItem && item.children && expandedKey !== item.key)
142
+ setExpandedKey(item.key);
143
+ },
144
+ onMouseLeave: () => {
145
+ if (mode === "horizontal" && !isOverflowItem)
146
+ setExpandedKey(void 0);
147
+ }
148
+ },
149
+ /* @__PURE__ */ React.createElement("div", { className: "flex h-full justify-between rounded-none" }, /* @__PURE__ */ React.createElement("div", { className: (0, import_client.clsx)("flex items-center gap-1", labelClassName?.(checkIsActive(item.key))) }, item.icon, !inlineCollapsed && /* @__PURE__ */ React.createElement("div", { className: "text-base-content whitespace-nowrap" }, item.label)), item.children && mode === "inline" && /* @__PURE__ */ React.createElement(
150
+ import_ai.AiFillCaretDown,
151
+ {
152
+ className: (0, import_client.clsx)(
153
+ "text-xs transition-transform duration-400",
154
+ expandedKey === item.key ? "rotate-180" : ""
155
+ )
156
+ }
157
+ )),
158
+ item.children && expandedKey === item.key && /* @__PURE__ */ React.createElement("div", { className: subMenuClassName }, item.children.map((child) => /* @__PURE__ */ React.createElement(
159
+ "div",
160
+ {
161
+ onClick: (e) => {
162
+ e.stopPropagation();
163
+ onClick?.(child);
164
+ setExpandedKey(void 0);
165
+ },
166
+ key: child.key,
167
+ className: subMenuItemClassName
168
+ },
169
+ child.label
170
+ )))
171
+ );
172
+ }),
173
+ overflowMenuItems.length > 0 && mode === "horizontal" && /* @__PURE__ */ React.createElement(OverflowMenu, { overflowItems: overflowMenuItems, onClick })
174
+ )
175
+ );
176
+ };
177
+ const OverflowMenu = ({ overflowItems, onClick }) => {
178
+ const [isOpen, setIsOpen] = (0, import_react.useState)(false);
179
+ const [expandedKey, setExpandedKey] = (0, import_react.useState)();
180
+ const handleMouseEnter = () => {
181
+ setIsOpen(true);
182
+ };
183
+ const handleMouseLeave = () => {
184
+ setIsOpen(false);
185
+ };
186
+ return /* @__PURE__ */ React.createElement("li", { className: "relative h-full", onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }, /* @__PURE__ */ React.createElement("div", { className: "flex h-full items-center justify-center rounded-none" }, /* @__PURE__ */ React.createElement(import_ai.AiOutlineEllipsis, null)), isOpen && /* @__PURE__ */ React.createElement("div", { className: "bg-base-100 hover:bg-base-100 fixed -bottom-0 flex translate-y-[98%] flex-col rounded-xs border-0 p-2 shadow-lg" }, overflowItems.map((item) => /* @__PURE__ */ React.createElement(
187
+ "div",
188
+ {
189
+ key: item.key,
190
+ onClick: () => onClick?.(item),
191
+ className: "btn btn-ghost text-primary-focus relative font-normal whitespace-nowrap",
192
+ onMouseEnter: () => {
193
+ if (item.children && expandedKey !== item.key)
194
+ setExpandedKey(item.key);
195
+ },
196
+ onMouseLeave: () => {
197
+ setExpandedKey(void 0);
198
+ }
199
+ },
200
+ item.label,
201
+ item.children && expandedKey === item.key && /* @__PURE__ */ React.createElement("div", { className: "bg-base-100 absolute top-0 left-0 -translate-x-full p-4 drop-shadow-sm" }, item.children.map((child) => /* @__PURE__ */ React.createElement(
202
+ "div",
203
+ {
204
+ onClick: (e) => {
205
+ e.stopPropagation();
206
+ onClick?.(child);
207
+ setExpandedKey(void 0);
208
+ },
209
+ key: child.key,
210
+ className: "btn btn-ghost text-primary-focus flex items-center justify-center text-center font-normal"
211
+ },
212
+ child.label
213
+ )))
214
+ ))));
215
+ };
package/cjs/Modal.js ADDED
@@ -0,0 +1,75 @@
1
+ "use client";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var Modal_exports = {};
30
+ __export(Modal_exports, {
31
+ Modal: () => Modal,
32
+ Window: () => Window
33
+ });
34
+ module.exports = __toCommonJS(Modal_exports);
35
+ var RadixDialog = __toESM(require("@radix-ui/react-dialog"));
36
+ var import_bi = require("react-icons/bi");
37
+ var import_Dialog = require("./Dialog");
38
+ const Modal = ({
39
+ className,
40
+ title,
41
+ action,
42
+ open,
43
+ onCancel,
44
+ bodyClassName,
45
+ children,
46
+ confirmClose = false
47
+ }) => {
48
+ return /* @__PURE__ */ React.createElement(import_Dialog.Dialog, { open }, /* @__PURE__ */ React.createElement(import_Dialog.Dialog.Modal, { className, onCancel, bodyClassName, confirmClose }, title ? /* @__PURE__ */ React.createElement(import_Dialog.Dialog.Title, null, title) : null, /* @__PURE__ */ React.createElement(import_Dialog.Dialog.Content, null, children), action ? /* @__PURE__ */ React.createElement(import_Dialog.Dialog.Action, null, action) : null));
49
+ };
50
+ const Window = ({ open, onCancel, title, children }) => {
51
+ if (!open)
52
+ return null;
53
+ return /* @__PURE__ */ React.createElement(RadixDialog.Root, { open }, /* @__PURE__ */ React.createElement(RadixDialog.Portal, null, /* @__PURE__ */ React.createElement(RadixDialog.Overlay, { className: "fixed inset-0 bg-black/40" }), /* @__PURE__ */ React.createElement(
54
+ RadixDialog.Content,
55
+ {
56
+ className: "animate-fadeIn fixed top-1/2 left-1/2 z-[2] w-[90%] min-w-auto -translate-x-1/2 -translate-y-1/2 rounded-[10px] border-[3px] border-black text-black backdrop-blur-lg md:w-fit",
57
+ style: {
58
+ background: `rgba(255, 255, 255, 0.3)`,
59
+ width: "406px"
60
+ }
61
+ },
62
+ /* @__PURE__ */ React.createElement(RadixDialog.Title, { className: "height-[36px] relative overflow-hidden rounded-t-[6px] border-b-2 border-black bg-white/60 text-center" }, /* @__PURE__ */ React.createElement("div", { className: "m-0 text-[22px]" }, title), /* @__PURE__ */ React.createElement(
63
+ RadixDialog.Close,
64
+ {
65
+ onClick: () => {
66
+ onCancel();
67
+ },
68
+ className: "absolute top-0 right-0 flex h-[34px] w-[40px] cursor-pointer items-center justify-center border-l-2 border-black"
69
+ },
70
+ /* @__PURE__ */ React.createElement(import_bi.BiX, { className: "text-[32px]" })
71
+ )),
72
+ /* @__PURE__ */ React.createElement(RadixDialog.Description, { className: "overflow-y-hidden rounded-b-[10px] p-2" }, children)
73
+ )));
74
+ };
75
+ Modal.Window = Window;
@@ -0,0 +1,61 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var Edit_exports = {};
29
+ __export(Edit_exports, {
30
+ default: () => Edit
31
+ });
32
+ module.exports = __toCommonJS(Edit_exports);
33
+ var import_client = require("@akanjs/client");
34
+ var import_next = require("@akanjs/next");
35
+ var import_ai = require("react-icons/ai");
36
+ var import_EditModal = __toESM(require("./EditModal"));
37
+ var import_EditWrapper = __toESM(require("./EditWrapper"));
38
+ function Edit({
39
+ className,
40
+ wrapperClassName,
41
+ type = "button",
42
+ children,
43
+ sliceName,
44
+ modelId,
45
+ modal,
46
+ renderTitle
47
+ }) {
48
+ const { l } = (0, import_next.usePage)();
49
+ return /* @__PURE__ */ React.createElement("div", { className: (0, import_client.clsx)("inline", wrapperClassName) }, /* @__PURE__ */ React.createElement(
50
+ import_EditWrapper.default,
51
+ {
52
+ className: (0, import_client.clsx)("flex w-full items-center justify-center gap-2", className),
53
+ sliceName,
54
+ modelId,
55
+ modal
56
+ },
57
+ /* @__PURE__ */ React.createElement(import_ai.AiOutlineEdit, null),
58
+ " ",
59
+ type === "button" ? l("shared.edit") : null
60
+ ), /* @__PURE__ */ React.createElement(import_EditModal.default, { renderTitle, sliceName, id: modelId }, children));
61
+ }
@@ -0,0 +1,255 @@
1
+ "use client";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var EditModal_exports = {};
30
+ __export(EditModal_exports, {
31
+ default: () => EditModal
32
+ });
33
+ module.exports = __toCommonJS(EditModal_exports);
34
+ var import_client = require("@akanjs/client");
35
+ var import_common = require("@akanjs/common");
36
+ var import_constant = require("@akanjs/constant");
37
+ var import_next = require("@akanjs/next");
38
+ var import_signal = require("@akanjs/signal");
39
+ var import_store2 = require("@akanjs/store");
40
+ var import_react = __toESM(require("react"));
41
+ var import_ai = require("react-icons/ai");
42
+ var import_Button = require("../Button");
43
+ var import_Modal = require("../Modal");
44
+ const EditModel = ({
45
+ type = "modal",
46
+ sliceName,
47
+ className,
48
+ checkSubmit = true,
49
+ edit,
50
+ modal,
51
+ children,
52
+ loadingWrapper
53
+ }) => {
54
+ const storeUse = import_store2.st.use;
55
+ const storeDo = import_store2.st.do;
56
+ const refName = import_store2.st.slice[sliceName].refName;
57
+ const [modelName, ModelName] = (0, import_react.useMemo)(() => [(0, import_common.lowerlize)(refName), (0, import_common.capitalize)(refName)], []);
58
+ const names = (0, import_react.useMemo)(
59
+ () => ({
60
+ model: modelName,
61
+ Model: ModelName,
62
+ modelForm: `${modelName}Form`,
63
+ modelFormLoading: `${modelName}FormLoading`,
64
+ modelModal: `${modelName}Modal`,
65
+ checkModelSubmitable: `check${ModelName}Submitable`
66
+ }),
67
+ []
68
+ );
69
+ const modelModal = storeUse[names.modelModal]();
70
+ const modelForm = storeUse[names.modelForm]();
71
+ const checkSubmitable = (0, import_next.useDebounce)(() => {
72
+ storeDo[names.checkModelSubmitable]();
73
+ });
74
+ (0, import_react.useEffect)(() => {
75
+ if (checkSubmit)
76
+ checkSubmitable();
77
+ }, [modelModal, modelForm]);
78
+ const LoadingWrapper = (0, import_react.useMemo)(() => {
79
+ return loadingWrapper === false ? ({ children: children2, className: className2 }) => children2 : typeof loadingWrapper === "function" ? loadingWrapper : ({ children: children2, className: className2 }) => {
80
+ const modelFormLoading = storeUse[names.modelFormLoading]();
81
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_client.clsx)("", className2) }, children2, modelFormLoading ? /* @__PURE__ */ import_react.default.createElement("div", { className: "bg-base-100/50 absolute inset-0 animate-pulse" }) : null);
82
+ };
83
+ }, []);
84
+ return /* @__PURE__ */ import_react.default.createElement(LoadingWrapper, { className: (0, import_client.clsx)("w-full", className) }, children);
85
+ };
86
+ function EditModal({
87
+ type = "modal",
88
+ sliceName,
89
+ id,
90
+ className,
91
+ disabled,
92
+ checkSubmit = true,
93
+ modalClassName,
94
+ edit,
95
+ modal,
96
+ renderTitle,
97
+ children,
98
+ submitOption,
99
+ renderSubmit,
100
+ loadingWrapper,
101
+ onSubmit,
102
+ onCancel
103
+ }) {
104
+ const { l } = (0, import_next.usePage)();
105
+ const refName = import_store2.st.slice[sliceName].refName;
106
+ const storeUse = import_store2.st.use;
107
+ const storeDo = import_store2.st.do;
108
+ const storeSel = import_store2.st.sel;
109
+ const modelEdit = edit?.then ? (0, import_react.use)(edit) : edit;
110
+ const [modelName, ModelName] = (0, import_react.useMemo)(() => [(0, import_common.lowerlize)(refName), (0, import_common.capitalize)(refName)], []);
111
+ const names = (0, import_react.useMemo)(
112
+ () => ({
113
+ model: modelName,
114
+ modelForm: `${modelName}Form`,
115
+ modelFormLoading: `${modelName}FormLoading`,
116
+ modelModal: `${modelName}Modal`,
117
+ modelSubmit: `${modelName}Submit`,
118
+ submitModel: `submit${ModelName}`,
119
+ resetModel: `reset${ModelName}`,
120
+ setModelModal: `set${ModelName}Modal`,
121
+ modelLoading: `${modelName}Loading`,
122
+ modelViewAt: `${modelName}ViewAt`,
123
+ newModel: `new${ModelName}`,
124
+ crystalizeModel: `crystalize${ModelName}`,
125
+ modelObj: `${modelName}Obj`
126
+ }),
127
+ []
128
+ );
129
+ const modelModal = storeUse[names.modelModal]();
130
+ const modelFormId = storeSel(
131
+ (state) => state[names.modelForm].id
132
+ );
133
+ const modelFormLoading = storeUse[names.modelFormLoading]();
134
+ const isModalOpen = modelModal === (modal ?? "edit") && (modelFormLoading === false || modelFormLoading === id) && (!modelFormId && !id || id === modelFormId);
135
+ (0, import_react.useEffect)(() => {
136
+ if (!modelEdit)
137
+ return;
138
+ const refName2 = modelEdit.refName;
139
+ const editType = refName2 && modelEdit[names.modelObj] ? "edit" : "new";
140
+ const crystalizeModel = import_signal.fetch[names.crystalizeModel];
141
+ const modelRef = (0, import_constant.getFullModelRef)(modelName);
142
+ if (editType === "edit") {
143
+ const crystal = crystalizeModel(modelEdit[names.modelObj]);
144
+ import_store2.st.set({
145
+ [names.model]: crystal,
146
+ [names.modelLoading]: false,
147
+ [names.modelForm]: (0, import_signal.immerify)(modelRef, crystal),
148
+ [names.modelFormLoading]: false,
149
+ [names.modelModal]: modal ?? "edit",
150
+ [names.modelViewAt]: modelEdit[names.modelViewAt]
151
+ });
152
+ } else {
153
+ const crystal = crystalizeModel(modelEdit);
154
+ void storeDo[names.newModel](crystal, { modal, setDefault: true, sliceName });
155
+ }
156
+ return () => {
157
+ };
158
+ }, [modelEdit]);
159
+ const handleCancel = (0, import_react.useCallback)(() => {
160
+ const modelForm = import_store2.st.get()[names.modelForm];
161
+ const form = (0, import_common.deepObjectify)({ ...modelForm });
162
+ void storeDo[names.setModelModal](null);
163
+ if (typeof onCancel === "function")
164
+ onCancel(form);
165
+ else if (onCancel === "back")
166
+ import_client.router.back();
167
+ else if (onCancel === "reset")
168
+ void storeDo[names.resetModel]();
169
+ else if (typeof onCancel === "string")
170
+ import_client.router.replace(onCancel);
171
+ }, []);
172
+ const Title = () => {
173
+ const modelFormLoading2 = storeUse[names.modelFormLoading]();
174
+ const modelForm = storeUse[names.modelForm]();
175
+ return modelFormLoading2 ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null) : renderTitle ? typeof renderTitle === "string" ? `${l(`${modelName}.modelName`)}${renderTitle === "default" ? "" : ` - ${modelForm[renderTitle]}`}` : /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, renderTitle(modelForm)) : /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null);
176
+ };
177
+ const Submit = (0, import_react.useMemo)(
178
+ () => renderSubmit === false ? () => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null) : typeof renderSubmit === "function" ? () => renderSubmit(storeUse[names.modelForm]()) : () => {
179
+ const modelSubmit = storeUse[names.modelSubmit]();
180
+ const handleSubmit = (0, import_react.useCallback)(async ({ onError } = {}) => {
181
+ await storeDo[names.submitModel]({
182
+ ...submitOption,
183
+ sliceName,
184
+ onError,
185
+ onSuccess: typeof onSubmit === "function" ? onSubmit : void 0
186
+ });
187
+ if (onSubmit === "back")
188
+ import_client.router.back();
189
+ else if (onSubmit === "reset")
190
+ void storeDo[names.resetModel]();
191
+ else if (typeof onSubmit === "string")
192
+ import_client.router.replace(onSubmit);
193
+ }, []);
194
+ return /* @__PURE__ */ import_react.default.createElement(
195
+ import_Button.Button,
196
+ {
197
+ className: "btn btn-primary w-full gap-2 rounded-2xl",
198
+ disabled: modelSubmit.disabled || !!disabled,
199
+ onClick: async (e, { onError }) => {
200
+ await handleSubmit({ onError });
201
+ },
202
+ onSuccess: () => {
203
+ }
204
+ },
205
+ modelFormId ? /* @__PURE__ */ import_react.default.createElement(import_ai.AiOutlineSave, null) : /* @__PURE__ */ import_react.default.createElement(import_ai.AiOutlinePlus, null),
206
+ l(modelFormId ? "shared.updateModel" : "shared.createModel", {
207
+ model: l.field(names.model, "modelName")
208
+ })
209
+ );
210
+ },
211
+ [disabled, modelFormId]
212
+ );
213
+ if (type === "modal")
214
+ return /* @__PURE__ */ import_react.default.createElement(
215
+ import_Modal.Modal,
216
+ {
217
+ open: isModalOpen,
218
+ onCancel: () => {
219
+ handleCancel();
220
+ },
221
+ className: modalClassName,
222
+ title: /* @__PURE__ */ import_react.default.createElement(Title, null),
223
+ action: /* @__PURE__ */ import_react.default.createElement(Submit, null)
224
+ },
225
+ isModalOpen ? /* @__PURE__ */ import_react.default.createElement(
226
+ EditModel,
227
+ {
228
+ type,
229
+ sliceName,
230
+ className,
231
+ checkSubmit,
232
+ edit,
233
+ modal,
234
+ loadingWrapper
235
+ },
236
+ children
237
+ ) : null
238
+ );
239
+ else if (isModalOpen)
240
+ return /* @__PURE__ */ import_react.default.createElement(
241
+ EditModel,
242
+ {
243
+ type,
244
+ sliceName,
245
+ className,
246
+ checkSubmit,
247
+ edit,
248
+ modal,
249
+ loadingWrapper
250
+ },
251
+ /* @__PURE__ */ import_react.default.createElement(Title, null),
252
+ children,
253
+ type === "form" ? /* @__PURE__ */ import_react.default.createElement("div", { className: "mt-4" }, /* @__PURE__ */ import_react.default.createElement(Submit, null)) : null
254
+ );
255
+ }
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var EditWrapper_exports = {};
20
+ __export(EditWrapper_exports, {
21
+ default: () => EditWrapper
22
+ });
23
+ module.exports = __toCommonJS(EditWrapper_exports);
24
+ var import_client = require("@akanjs/client");
25
+ var import_common = require("@akanjs/common");
26
+ var import_store = require("@akanjs/store");
27
+ function EditWrapper({ children, sliceName, modelId, className, modal, resets }) {
28
+ const refName = import_store.st.slice[sliceName].refName;
29
+ const modelName = refName;
30
+ const names = {
31
+ editModel: `edit${(0, import_common.capitalize)(modelName)}`
32
+ };
33
+ const storeDo = import_store.st.do;
34
+ return /* @__PURE__ */ React.createElement(
35
+ "div",
36
+ {
37
+ className: (0, import_client.clsx)("cursor-pointer", className),
38
+ onClick: (e) => {
39
+ e.stopPropagation();
40
+ void storeDo[names.editModel](modelId, { modal });
41
+ resets?.forEach((reset) => {
42
+ void storeDo[`reset${(0, import_common.capitalize)(reset)}`]();
43
+ });
44
+ }
45
+ },
46
+ children
47
+ );
48
+ }
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var LoadInit_exports = {};
20
+ __export(LoadInit_exports, {
21
+ default: () => LoadInit
22
+ });
23
+ module.exports = __toCommonJS(LoadInit_exports);
24
+ var import_Load = require("../Load");
25
+ function LoadInit({ init }) {
26
+ return /* @__PURE__ */ React.createElement(import_Load.Load.Units, { init, renderList: () => null, loading: null, renderEmpty: null });
27
+ }