@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/esm/Select.js ADDED
@@ -0,0 +1,243 @@
1
+ "use client";
2
+ import { Enum } from "@akanjs/base";
3
+ import { clsx } from "@akanjs/client";
4
+ import { useDebounce, usePage } from "@akanjs/next";
5
+ import { useEffect, useMemo, useRef, useState } from "react";
6
+ import { BiCheck, BiChevronDown, BiX } from "react-icons/bi";
7
+ import { BsQuestionCircleFill } from "react-icons/bs";
8
+ import { TiDelete } from "react-icons/ti";
9
+ const Select = ({
10
+ label,
11
+ desc,
12
+ labelClassName,
13
+ className,
14
+ value,
15
+ options,
16
+ nullable,
17
+ disabled,
18
+ multiple,
19
+ searchable,
20
+ placeholder,
21
+ selectClassName,
22
+ selectorClassName,
23
+ selectedClassName,
24
+ onOpen,
25
+ onChange,
26
+ onSearch,
27
+ renderOption,
28
+ renderSelected
29
+ }) => {
30
+ const { l } = usePage();
31
+ const [isOpen, setIsOpen] = useState(false);
32
+ const labeledOptions = useMemo(
33
+ () => options instanceof Enum ? options.values.map((v) => ({ label: v, value: v })) : options[0]?.label && options[0]?.value ? options : options.map((v) => ({ label: v, value: v })),
34
+ [options]
35
+ );
36
+ const [selectedValues, setSelectedValues] = useState(multiple ? value : [value]);
37
+ const [searchText, setSearchText] = useState("");
38
+ const [searchOptions, setSearchOptions] = useState(labeledOptions);
39
+ const dropdownRef = useRef(null);
40
+ const selected = (v) => {
41
+ if (multiple)
42
+ return selectedValues.includes(v);
43
+ return v === selectedValues[0];
44
+ };
45
+ const handleClickOutside = (event) => {
46
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
47
+ setIsOpen(false);
48
+ }
49
+ };
50
+ const onSelect = (v, index) => {
51
+ if (multiple) {
52
+ if (selectedValues.includes(v)) {
53
+ setSelectedValues(selectedValues.filter((rev) => rev !== v));
54
+ onChange(
55
+ selectedValues.filter((rev) => rev !== v),
56
+ selectedValues
57
+ );
58
+ } else {
59
+ setSelectedValues([...selectedValues, v]);
60
+ onChange([...selectedValues, v], selectedValues);
61
+ }
62
+ } else {
63
+ setSelectedValues([v]);
64
+ onChange(v, selectedValues[0]);
65
+ setIsOpen(false);
66
+ }
67
+ };
68
+ const debouncedOnSearch = useDebounce(
69
+ (text) => {
70
+ onSearch?.(text);
71
+ },
72
+ [searchText],
73
+ 300
74
+ );
75
+ useEffect(() => {
76
+ if (isOpen)
77
+ document.addEventListener("mousedown", handleClickOutside);
78
+ else
79
+ document.removeEventListener("mousedown", handleClickOutside);
80
+ return () => {
81
+ document.removeEventListener("mousedown", handleClickOutside);
82
+ };
83
+ }, [isOpen]);
84
+ useEffect(() => {
85
+ setSearchOptions(labeledOptions);
86
+ }, [labeledOptions]);
87
+ useEffect(() => {
88
+ if (isOpen)
89
+ onOpen?.();
90
+ }, [isOpen]);
91
+ useEffect(() => {
92
+ if (multiple)
93
+ setSelectedValues(value);
94
+ else
95
+ setSelectedValues([value]);
96
+ }, [value]);
97
+ return /* @__PURE__ */ React.createElement("div", { className: clsx("relative min-w-[150px]", className), ref: dropdownRef }, /* @__PURE__ */ React.createElement(
98
+ "div",
99
+ {
100
+ "data-open": isOpen,
101
+ className: clsx(
102
+ "btn flex h-auto min-h-[40px] w-full cursor-pointer items-center px-0 py-1 pr-5 pl-1 focus:outline-hidden",
103
+ "bg-base-100 data-[open=true]:border-primary",
104
+ disabled && "cursor-not-allowed opacity-50",
105
+ selectClassName,
106
+ { "border-base-300": isOpen }
107
+ ),
108
+ onClick: () => {
109
+ setIsOpen(!isOpen);
110
+ }
111
+ },
112
+ /* @__PURE__ */ React.createElement("span", { className: "flex w-full flex-wrap items-center gap-1" }, multiple ? /* @__PURE__ */ React.createElement(React.Fragment, null, value.map((v, index) => {
113
+ const optionValue = labeledOptions.find((option) => option.value === v);
114
+ if (!optionValue)
115
+ return null;
116
+ return /* @__PURE__ */ React.createElement(
117
+ "div",
118
+ {
119
+ key: index,
120
+ className: "bg-success/70 text-success-content flex items-center gap-2 rounded-lg px-2 py-1 text-xs"
121
+ },
122
+ renderSelected ? renderSelected(optionValue.value) : optionValue.label,
123
+ /* @__PURE__ */ React.createElement(
124
+ "button",
125
+ {
126
+ onClick: (e) => {
127
+ e.stopPropagation();
128
+ e.preventDefault();
129
+ onSelect(optionValue.value, index);
130
+ },
131
+ className: "opacity-50 duration-300 hover:opacity-100"
132
+ },
133
+ /* @__PURE__ */ React.createElement(BiX, { className: "text-base" })
134
+ )
135
+ );
136
+ })) : /* @__PURE__ */ React.createElement("div", { className: "px-2 py-1" }, value ? /* @__PURE__ */ React.createElement(React.Fragment, null, (() => {
137
+ const optionValue = searchOptions.find((option) => selected(option.value));
138
+ if (!optionValue)
139
+ return null;
140
+ return renderSelected ? renderSelected(optionValue.value) : optionValue.label;
141
+ })()) : ""), searchable && /* @__PURE__ */ React.createElement(
142
+ "input",
143
+ {
144
+ type: "text",
145
+ className: "input w-full flex-1 border-none bg-transparent shadow-none outline-none focus:border-none focus:shadow-none focus:outline-none",
146
+ placeholder: selectedValues.length > 0 ? "" : placeholder,
147
+ value: searchText,
148
+ onChange: (e) => {
149
+ if (!isOpen)
150
+ setIsOpen(true);
151
+ if (!onSearch)
152
+ setSearchOptions(
153
+ labeledOptions.filter(
154
+ (option) => option.label.toString().toLowerCase().includes(e.target.value.toLowerCase())
155
+ )
156
+ );
157
+ setSearchText(e.target.value);
158
+ debouncedOnSearch(e.target.value);
159
+ },
160
+ onClick: (e) => {
161
+ e.stopPropagation();
162
+ e.preventDefault();
163
+ setIsOpen(!isOpen);
164
+ }
165
+ }
166
+ )),
167
+ multiple && selectedValues.length || !multiple && selectedValues[0] !== void 0 && selectedValues[0] !== null ? /* @__PURE__ */ React.createElement(
168
+ TiDelete,
169
+ {
170
+ className: "absolute right-8 z-[2] h-full text-lg duration-300 hover:cursor-pointer hover:opacity-50",
171
+ onClick: (e) => {
172
+ e.stopPropagation();
173
+ e.preventDefault();
174
+ setSearchText("");
175
+ setSelectedValues([]);
176
+ if (multiple)
177
+ onChange([], selectedValues);
178
+ else
179
+ onChange(null, selectedValues[0]);
180
+ setIsOpen(false);
181
+ }
182
+ }
183
+ ) : null,
184
+ /* @__PURE__ */ React.createElement(
185
+ BiChevronDown,
186
+ {
187
+ className: clsx("absolute top-1/2 right-2 -translate-y-1/2 text-lg duration-100", { "rotate-180": isOpen })
188
+ }
189
+ )
190
+ ), /* @__PURE__ */ React.createElement(
191
+ "div",
192
+ {
193
+ "data-open": isOpen,
194
+ className: clsx(
195
+ "scrollbar-thin scrollbar-thumb-base-content/20 scrollbar-track scrollbar-track-base-content/40 bg-base-200 border-base-300 absolute z-20 mt-0.5 w-full overflow-y-scroll rounded-md shadow-lg transition-all",
196
+ "origin-center duration-200 data-[open=false]:h-0 data-[open=false]:border-none data-[open=true]:h-[270px] data-[open=true]:border",
197
+ selectorClassName
198
+ )
199
+ },
200
+ nullable && /* @__PURE__ */ React.createElement(
201
+ "div",
202
+ {
203
+ className: "cursor-pointer p-2",
204
+ onClick: () => {
205
+ setIsOpen(false);
206
+ }
207
+ }
208
+ ),
209
+ searchOptions.length > 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, searchOptions.map((option, index) => {
210
+ const isSelected = selected(option.value);
211
+ return /* @__PURE__ */ React.createElement("div", { key: index, className: "group" }, /* @__PURE__ */ React.createElement(
212
+ "div",
213
+ {
214
+ className: clsx(
215
+ "hover:bg-base-300 relative m-2 cursor-pointer rounded-sm p-2 duration-100 last:border-b-0",
216
+ {
217
+ selectedClassName: !multiple && isSelected,
218
+ "bg-success/70 text-success-content": isSelected
219
+ }
220
+ ),
221
+ onClick: () => {
222
+ onSelect(option.value, index);
223
+ setSearchText("");
224
+ }
225
+ },
226
+ renderOption ? renderOption(option.value) : option.label,
227
+ /* @__PURE__ */ React.createElement("div", { className: clsx("absolute top-1/2 right-2 -translate-y-1/2 flex-wrap duration-200", {}) }, /* @__PURE__ */ React.createElement(
228
+ "div",
229
+ {
230
+ className: clsx("duration-200", {
231
+ "translate-y-0 opacity-100": isSelected,
232
+ "-translate-y-full opacity-0": !isSelected
233
+ })
234
+ },
235
+ /* @__PURE__ */ React.createElement(BiCheck, null)
236
+ ))
237
+ ), /* @__PURE__ */ React.createElement("div", { className: "h-px w-full px-2 group-last:hidden" }, /* @__PURE__ */ React.createElement("div", { className: "bg-base-content/10 size-full" })));
238
+ })) : /* @__PURE__ */ React.createElement("div", { className: "text-base-content/50 flex size-full flex-col items-center justify-center gap-2 p-2 text-center text-5xl" }, /* @__PURE__ */ React.createElement(BsQuestionCircleFill, null), /* @__PURE__ */ React.createElement("div", { className: "text-sm" }, l("shared.noOptions")))
239
+ ));
240
+ };
241
+ export {
242
+ Select
243
+ };
@@ -0,0 +1,208 @@
1
+ "use client";
2
+ import { getNonArrayModel, isGqlScalar } from "@akanjs/base";
3
+ import { getGqlTypeStr, getScalarExample } from "@akanjs/constant";
4
+ import { usePage } from "@akanjs/next";
5
+ import { st } from "@akanjs/store";
6
+ import { AiOutlineDelete } from "react-icons/ai";
7
+ import { DatePicker } from "../DatePicker";
8
+ import { Input } from "../Input";
9
+ import Object from "./Object";
10
+ function Arg({ argType, value, onChange }) {
11
+ return argType === "ID" ? /* @__PURE__ */ React.createElement(Arg.ID, { value, onChange }) : argType === "Int" ? /* @__PURE__ */ React.createElement(Arg.Int, { value, onChange }) : argType === "Float" ? /* @__PURE__ */ React.createElement(Arg.Float, { value, onChange }) : argType === "String" ? /* @__PURE__ */ React.createElement(Arg.String, { value, onChange }) : argType === "Boolean" ? /* @__PURE__ */ React.createElement(Arg.Boolean, { value, onChange }) : argType === "Date" ? /* @__PURE__ */ React.createElement(Arg.Date, { value, onChange }) : argType === "JSON" ? /* @__PURE__ */ React.createElement(Arg.Json, { value, onChange }) : argType === "Upload" ? /* @__PURE__ */ React.createElement(Arg.Upload, { value, onChange }) : /* @__PURE__ */ React.createElement(React.Fragment, null);
12
+ }
13
+ const ArgTable = ({ sigMeta, gqlMeta, argMetas }) => {
14
+ const { l } = usePage();
15
+ const onCopy = (text) => {
16
+ void navigator.clipboard.writeText(text);
17
+ st.do.showMessage({ content: "\uD074\uB9BD\uBCF4\uB4DC\uC5D0 \uBCF5\uC0AC\uB418\uC5C8\uC2B5\uB2C8\uB2E4.", type: "success", duration: 3 });
18
+ };
19
+ return /* @__PURE__ */ React.createElement("table", { className: "table" }, /* @__PURE__ */ React.createElement("thead", null, /* @__PURE__ */ React.createElement("tr", { className: "text-bold" }, /* @__PURE__ */ React.createElement("th", null, "Arg Key"), /* @__PURE__ */ React.createElement("th", { className: "text-center" }, "Type"), /* @__PURE__ */ React.createElement("th", { className: "text-center" }, "Enum"), /* @__PURE__ */ React.createElement("th", { className: "text-center" }, "Name"), /* @__PURE__ */ React.createElement("th", { className: "text-center" }, "Description"))), argMetas.map((argMeta, idx) => {
20
+ const [argRef, argArrDepth] = getNonArrayModel(argMeta.returns());
21
+ return /* @__PURE__ */ React.createElement("tbody", { className: "font-normal", key: idx }, /* @__PURE__ */ React.createElement("tr", null, /* @__PURE__ */ React.createElement("td", null, argMeta.name), /* @__PURE__ */ React.createElement("td", { className: "text-center" }, /* @__PURE__ */ React.createElement(Object.Type, { objRef: argRef, arrDepth: argArrDepth })), /* @__PURE__ */ React.createElement("td", { width: argMeta.argsOption.enum ? "20%" : "10%", className: "text-center" }, argMeta.argsOption.enum ? /* @__PURE__ */ React.createElement("div", { className: "flex flex-col gap-2" }, argMeta.argsOption.enum.map((opt, idx2) => /* @__PURE__ */ React.createElement("div", { key: idx2 }, /* @__PURE__ */ React.createElement(
22
+ "button",
23
+ {
24
+ key: idx2,
25
+ "data-tip": l.enum(sigMeta.refName, argMeta.name, opt),
26
+ onClick: () => {
27
+ onCopy(opt);
28
+ },
29
+ className: "tooltip tooltip-primary btn btn-secondary btn-xs"
30
+ },
31
+ opt
32
+ )))) : "-"), /* @__PURE__ */ React.createElement("td", { className: "text-center" }, l.arg(sigMeta.refName, gqlMeta.key, argMeta.name)), /* @__PURE__ */ React.createElement("td", { className: "text-center" }, l.argdesc(sigMeta.refName, gqlMeta.key, argMeta.name))));
33
+ }));
34
+ };
35
+ Arg.Table = ArgTable;
36
+ const ArgParam = ({ argMeta, value, onChange }) => {
37
+ const [argRef, argArrDepth] = getNonArrayModel(argMeta.returns());
38
+ if (!isGqlScalar(argRef))
39
+ throw new Error(`Param arg - ${argMeta.key}/${argMeta.name} must be scalar`);
40
+ else if (argArrDepth > 0)
41
+ throw new Error(`Param arg - ${argMeta.key}/${argMeta.name} must not be array`);
42
+ const argType = getGqlTypeStr(argRef);
43
+ return /* @__PURE__ */ React.createElement("div", { className: "flex w-full items-center gap-2" }, /* @__PURE__ */ React.createElement("div", { className: "w-36 pl-2" }, "- ", argMeta.name), /* @__PURE__ */ React.createElement("div", { className: "w-full" }, /* @__PURE__ */ React.createElement(Arg, { argType, value, onChange })));
44
+ };
45
+ Arg.Param = ArgParam;
46
+ const ArgQuery = ({ argMeta, value, onChange }) => {
47
+ const [argRef, argArrDepth] = getNonArrayModel(argMeta.returns());
48
+ if (!isGqlScalar(argRef))
49
+ throw new Error(`Query arg - ${argMeta.key}/${argMeta.name} must be scalar`);
50
+ else if (argArrDepth > 1)
51
+ throw new Error(`Query arg - ${argMeta.key}/${argMeta.name} must not be more than 2D array`);
52
+ const argType = getGqlTypeStr(argRef);
53
+ return /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React.createElement("div", { className: "w-36 pl-2" }, "- ", argMeta.name), /* @__PURE__ */ React.createElement("div", { className: "w-full" }, argArrDepth && Array.isArray(value) ? /* @__PURE__ */ React.createElement("div", null, value.map((val, idx) => /* @__PURE__ */ React.createElement("div", { key: idx, className: "flex items-center gap-2" }, /* @__PURE__ */ React.createElement(
54
+ Arg,
55
+ {
56
+ argType,
57
+ value: val,
58
+ onChange: (val2) => {
59
+ onChange([...value.slice(0, idx), val2, ...value.slice(idx + 1)]);
60
+ }
61
+ }
62
+ ), /* @__PURE__ */ React.createElement(
63
+ "button",
64
+ {
65
+ className: "btn btn-sm btn-square",
66
+ onClick: () => {
67
+ onChange([...value.slice(0, idx), ...value.slice(idx + 1)]);
68
+ }
69
+ },
70
+ /* @__PURE__ */ React.createElement(AiOutlineDelete, null)
71
+ ))), /* @__PURE__ */ React.createElement(
72
+ "button",
73
+ {
74
+ className: "btn btn-sm",
75
+ onClick: () => {
76
+ onChange([...value, getScalarExample(argRef)]);
77
+ }
78
+ },
79
+ "+ Add"
80
+ )) : /* @__PURE__ */ React.createElement(Arg, { argType, value, onChange })));
81
+ };
82
+ Arg.Query = ArgQuery;
83
+ const ArgFormData = ({ argMeta, value, onChange }) => {
84
+ const [argRef, argArrDepth] = getNonArrayModel(argMeta.returns());
85
+ if (getGqlTypeStr(argRef) !== "Upload")
86
+ throw new Error(`FormData arg - ${argMeta.key}/${argMeta.name} must be Upload`);
87
+ else if (argArrDepth < 1)
88
+ throw new Error(`FormData arg - ${argMeta.key}/${argMeta.name} must be array`);
89
+ return /* @__PURE__ */ React.createElement("div", { className: "flex w-full items-center gap-2" }, /* @__PURE__ */ React.createElement("div", { className: "w-36 pl-2" }, "- ", argMeta.name), /* @__PURE__ */ React.createElement("div", { className: "w-full" }, /* @__PURE__ */ React.createElement(Arg, { argType: "Upload", value, onChange })));
90
+ };
91
+ Arg.FormData = ArgFormData;
92
+ const ArgID = ({ value, onChange }) => {
93
+ return /* @__PURE__ */ React.createElement(
94
+ Input,
95
+ {
96
+ inputClassName: "w-full",
97
+ value,
98
+ onChange: (value2) => {
99
+ onChange(value2);
100
+ },
101
+ validate: (e) => true
102
+ }
103
+ );
104
+ };
105
+ Arg.ID = ArgID;
106
+ const ArgInt = ({ value, onChange }) => {
107
+ return /* @__PURE__ */ React.createElement(
108
+ Input.Number,
109
+ {
110
+ inputClassName: "w-full",
111
+ value,
112
+ onChange: (value2) => {
113
+ onChange(value2 ?? 0);
114
+ },
115
+ validate: (e) => true
116
+ }
117
+ );
118
+ };
119
+ Arg.Int = ArgInt;
120
+ const ArgFloat = ({ value, onChange }) => {
121
+ return /* @__PURE__ */ React.createElement(
122
+ Input.Number,
123
+ {
124
+ inputClassName: "w-full",
125
+ value,
126
+ onChange: (value2) => {
127
+ onChange(value2 ?? 0);
128
+ },
129
+ validate: (e) => true
130
+ }
131
+ );
132
+ };
133
+ Arg.Float = ArgFloat;
134
+ const ArgString = ({ value, onChange }) => {
135
+ return /* @__PURE__ */ React.createElement(
136
+ Input,
137
+ {
138
+ inputClassName: "w-full",
139
+ value,
140
+ onChange: (value2) => {
141
+ onChange(value2);
142
+ },
143
+ validate: (e) => true
144
+ }
145
+ );
146
+ };
147
+ Arg.String = ArgString;
148
+ const ArgBoolean = ({ value, onChange }) => {
149
+ return /* @__PURE__ */ React.createElement(
150
+ Input.Checkbox,
151
+ {
152
+ className: "w-full",
153
+ checked: value,
154
+ onChange: (value2) => {
155
+ onChange(value2);
156
+ }
157
+ }
158
+ );
159
+ };
160
+ Arg.Boolean = ArgBoolean;
161
+ const ArgDate = ({ value, onChange }) => {
162
+ return /* @__PURE__ */ React.createElement(
163
+ DatePicker,
164
+ {
165
+ className: "w-full",
166
+ value,
167
+ onChange: (value2) => {
168
+ onChange(value2);
169
+ }
170
+ }
171
+ );
172
+ };
173
+ Arg.Date = ArgDate;
174
+ const ArgJson = ({ value, onChange }) => {
175
+ return /* @__PURE__ */ React.createElement(
176
+ Input.TextArea,
177
+ {
178
+ validate: (e) => true,
179
+ className: "w-full",
180
+ inputClassName: "w-full min-h-[300px]",
181
+ value,
182
+ onPressEnter: (value2) => {
183
+ onChange(value2);
184
+ },
185
+ onChange: (value2) => {
186
+ onChange(value2);
187
+ }
188
+ }
189
+ );
190
+ };
191
+ Arg.Json = ArgJson;
192
+ const ArgUpload = ({ value, onChange }) => {
193
+ return /* @__PURE__ */ React.createElement(
194
+ "input",
195
+ {
196
+ type: "file",
197
+ multiple: true,
198
+ className: "file-input w-full max-w-xs",
199
+ onChange: (e) => {
200
+ onChange(new Array(e.target.files?.length).fill(0).map((_, idx) => e.target.files?.[idx]));
201
+ }
202
+ }
203
+ );
204
+ };
205
+ Arg.Upload = ArgUpload;
206
+ export {
207
+ Arg as default
208
+ };
@@ -0,0 +1,152 @@
1
+ "use client";
2
+ import { lowerlize } from "@akanjs/common";
3
+ import { usePage } from "@akanjs/next";
4
+ import { client, defaultAccount, getAllSignalRefs, getSigMeta, roleTypes } from "@akanjs/signal";
5
+ import { st } from "@akanjs/store";
6
+ import decode from "jsonwebtoken/decode";
7
+ import { useState } from "react";
8
+ import { AiOutlineApi, AiOutlineCopy } from "react-icons/ai";
9
+ import { BiLock, BiLogoGraphql } from "react-icons/bi";
10
+ import { Copy } from "../Copy";
11
+ import { Input } from "../Input";
12
+ import { Modal } from "../Modal";
13
+ import GraphQL from "./GraphQL";
14
+ import RestApi from "./RestApi";
15
+ import WebSocket from "./WebSocket";
16
+ function Doc() {
17
+ return /* @__PURE__ */ React.createElement("div", null);
18
+ }
19
+ const DocSetting = () => {
20
+ const trySignalType = st.use.trySignalType();
21
+ const tryRoles = st.use.tryRoles();
22
+ const tryAccount = st.use.tryAccount();
23
+ const tryRoleForAll = roleTypes.every((roleType) => tryRoles.includes(roleType));
24
+ const baseUrl = trySignalType === "graphql" ? client.uri : client.uri.replace("/graphql", "");
25
+ return /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-wrap items-center justify-between gap-4" }, /* @__PURE__ */ React.createElement("div", { className: "flex flex-1 items-center gap-1" }, "BaseURL:", " ", /* @__PURE__ */ React.createElement(Copy, { text: baseUrl }, /* @__PURE__ */ React.createElement("button", { className: "btn btn-outline btn-sm" }, baseUrl, /* @__PURE__ */ React.createElement(AiOutlineCopy, null)))), /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-1" }, "Mode:", /* @__PURE__ */ React.createElement(
26
+ "button",
27
+ {
28
+ className: `btn btn-sm ${trySignalType === "graphql" ? "border-[#E535AB] bg-[#E535AB] text-white" : "btn-outline"}`,
29
+ onClick: () => {
30
+ st.do.setTrySignalType("graphql");
31
+ }
32
+ },
33
+ /* @__PURE__ */ React.createElement(BiLogoGraphql, null),
34
+ "GraphQL"
35
+ ), /* @__PURE__ */ React.createElement(
36
+ "button",
37
+ {
38
+ className: `btn btn-primary btn-sm ${trySignalType === "restapi" ? "" : "btn-outline"}`,
39
+ onClick: () => {
40
+ st.do.setTrySignalType("restapi");
41
+ }
42
+ },
43
+ /* @__PURE__ */ React.createElement(AiOutlineApi, null),
44
+ "Rest API"
45
+ )), /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-0.5" }, "For:", /* @__PURE__ */ React.createElement(
46
+ "button",
47
+ {
48
+ className: `btn btn-secondary btn-sm ${tryRoleForAll ? "" : "btn-outline"}`,
49
+ onClick: () => {
50
+ if (!tryRoleForAll)
51
+ st.do.setTryRoles([...roleTypes]);
52
+ }
53
+ },
54
+ "All"
55
+ ), roleTypes.map((roleType) => /* @__PURE__ */ React.createElement(
56
+ "button",
57
+ {
58
+ key: roleType,
59
+ className: `btn btn-secondary btn-sm ${!tryRoleForAll && tryRoles.includes(roleType) ? "" : "btn-outline"}`,
60
+ onClick: () => {
61
+ if (tryRoleForAll)
62
+ st.do.setTryRoles([roleType]);
63
+ else if (!tryRoles.includes(roleType))
64
+ st.do.setTryRoles([...tryRoles, roleType]);
65
+ else if (tryRoles.length !== 1)
66
+ st.do.setTryRoles(tryRoles.filter((t) => t !== roleType));
67
+ }
68
+ },
69
+ roleType
70
+ ))), /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-1" }, "Auth:", /* @__PURE__ */ React.createElement(DocAuthModal, null, /* @__PURE__ */ React.createElement("button", { className: `btn btn-sm ${!tryAccount.me && !tryAccount.self ? "btn-neutral" : "btn-warning"} ` }, /* @__PURE__ */ React.createElement(BiLock, null), " ", [
71
+ tryAccount.me ? "Admin" : null,
72
+ tryAccount.self ? "User" : null,
73
+ !tryAccount.me && !tryAccount.self ? "Public" : null
74
+ ].filter((roleType) => !!roleType).join(",")))));
75
+ };
76
+ Doc.Setting = DocSetting;
77
+ const DocAuthModal = ({ children }) => {
78
+ const tryJwt = st.use.tryJwt();
79
+ const [jwt, setJwt] = useState(tryJwt);
80
+ const [modalOpen, setModalOpen] = useState(false);
81
+ const decodedAccount = jwt ? decode(jwt) : null;
82
+ const accountStr = JSON.stringify(decodedAccount ?? defaultAccount, null, 2);
83
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
84
+ "div",
85
+ {
86
+ onClick: () => {
87
+ setModalOpen(true);
88
+ setJwt(tryJwt);
89
+ }
90
+ },
91
+ children
92
+ ), /* @__PURE__ */ React.createElement(
93
+ Modal,
94
+ {
95
+ bodyClassName: "flex flex-col gap-4",
96
+ open: modalOpen,
97
+ onCancel: () => {
98
+ setModalOpen(false);
99
+ },
100
+ title: "Set JWT for Authorization",
101
+ action: /* @__PURE__ */ React.createElement(
102
+ "button",
103
+ {
104
+ className: "btn btn-primary w-full",
105
+ onClick: () => {
106
+ st.set(
107
+ decodedAccount ? { tryJwt: jwt, tryAccount: decodedAccount } : { tryJwt: null, tryAccount: defaultAccount }
108
+ );
109
+ setModalOpen(false);
110
+ }
111
+ },
112
+ /* @__PURE__ */ React.createElement(BiLock, null),
113
+ " Set Authorization"
114
+ )
115
+ },
116
+ /* @__PURE__ */ React.createElement("div", { className: "w-full" }, /* @__PURE__ */ React.createElement("div", null, "Current JWT"), /* @__PURE__ */ React.createElement(Input, { inputClassName: "w-full", value: jwt ?? "", onChange: setJwt, validate: () => true })),
117
+ /* @__PURE__ */ React.createElement("div", { className: "w-full" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2" }, "Account Decoded", !decodedAccount?.me && !decodedAccount?.self ? /* @__PURE__ */ React.createElement("div", { className: "badge badge-primary" }, "Public") : null, decodedAccount?.me?.roles.map((role) => /* @__PURE__ */ React.createElement("div", { key: role, className: "badge badge-warning" }, "Admin-", role)), decodedAccount?.self?.roles.map((role) => /* @__PURE__ */ React.createElement("div", { key: role, className: "badge badge-neutral" }, "User-", role))), /* @__PURE__ */ React.createElement("div", { className: "relative" }, /* @__PURE__ */ React.createElement(
118
+ Input.TextArea,
119
+ {
120
+ inputClassName: "w-full",
121
+ value: accountStr,
122
+ onChange: () => true,
123
+ validate: () => true,
124
+ rows: 10
125
+ }
126
+ ), decodedAccount ? /* @__PURE__ */ React.createElement("div", { className: "absolute top-4 right-4" }, /* @__PURE__ */ React.createElement(Copy, { text: accountStr }, /* @__PURE__ */ React.createElement("button", { className: "btn btn-sm" }, /* @__PURE__ */ React.createElement(AiOutlineCopy, null), " Copy"))) : null))
127
+ ));
128
+ };
129
+ Doc.AuthModal = DocAuthModal;
130
+ const DocSignals = () => {
131
+ const sigRefs = getAllSignalRefs();
132
+ const refNames = [...new Set(sigRefs.map((sigRef) => getSigMeta(sigRef).refName))].sort(
133
+ (a, b) => lowerlize(a) > lowerlize(b) ? 1 : -1
134
+ );
135
+ return /* @__PURE__ */ React.createElement("div", null, refNames.map((refName, idx) => {
136
+ return /* @__PURE__ */ React.createElement("div", { className: "px-5 pb-5 text-3xl font-bold", key: idx }, /* @__PURE__ */ React.createElement(DocSignal, { refName }));
137
+ }));
138
+ };
139
+ Doc.DocSignals = DocSignals;
140
+ const DocSignal = ({ refName }) => {
141
+ return /* @__PURE__ */ React.createElement("div", { className: "collapse-arrow bg-base-200 collapse" }, /* @__PURE__ */ React.createElement("input", { type: "checkbox" }), /* @__PURE__ */ React.createElement("div", { className: "collapse-title text-xl font-medium" }, refName), /* @__PURE__ */ React.createElement("div", { className: "collapse-content" }, /* @__PURE__ */ React.createElement(GraphQL.Endpoints, { refName })));
142
+ };
143
+ Doc.DocSignal = DocSignal;
144
+ const Zone = ({ refName, openAll }) => {
145
+ const { l } = usePage();
146
+ const trySingnalType = st.use.trySignalType();
147
+ return /* @__PURE__ */ React.createElement("div", { className: "flex break-after-page flex-col gap-4" }, /* @__PURE__ */ React.createElement("div", { className: "text-3xl font-bold" }, refName), /* @__PURE__ */ React.createElement("div", { className: "mb-5" }, " - ", l.field(refName, "modelDesc")), /* @__PURE__ */ React.createElement("div", { className: "text-2xl font-bold" }, "APIs"), /* @__PURE__ */ React.createElement(DocSetting, null), trySingnalType === "graphql" ? /* @__PURE__ */ React.createElement(GraphQL.Endpoints, { refName, openAll }) : /* @__PURE__ */ React.createElement(RestApi.Endpoints, { refName, openAll }), /* @__PURE__ */ React.createElement("div", { className: "text-2xl font-bold" }, "Web Socket"), /* @__PURE__ */ React.createElement(WebSocket.Endpoints, { refName, openAll }));
148
+ };
149
+ Doc.Zone = Zone;
150
+ export {
151
+ Doc as default
152
+ };