@_tc/template-core 0.0.1-bate.35 → 0.0.1-bate.37

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 (418) hide show
  1. package/cjs/app/controller/base.js +3 -3
  2. package/cjs/app/controller/project.js +1 -1
  3. package/cjs/app/controller/view.js +16 -7
  4. package/cjs/app/middleware/api-params-verify.js +10 -1
  5. package/cjs/app/middleware/error-handle.js +9 -3
  6. package/cjs/app/middleware/project-handler.js +1 -1
  7. package/cjs/app/router/view.js +3 -1
  8. package/cjs/app/router-schema/project.js +1 -1
  9. package/cjs/app/service/project.js +5 -0
  10. package/cjs/bundler/defaultAlias.js +5 -0
  11. package/cjs/bundler/dev.js +4 -3
  12. package/cjs/bundler/index.js +2 -1
  13. package/cjs/bundler/prod.js +4 -3
  14. package/cjs/bundler/utils.js +53 -24
  15. package/cjs/packages/common/LRUCache.js +4 -0
  16. package/cjs/packages/common/array/index.js +43 -0
  17. package/cjs/packages/common/cache/LRUCache.js +45 -0
  18. package/cjs/packages/common/cache/index.js +4 -0
  19. package/cjs/packages/common/guards/index.js +34 -0
  20. package/cjs/packages/common/i18n/default.js +95 -0
  21. package/cjs/packages/common/i18n/en-US.js +95 -0
  22. package/cjs/packages/common/i18n/index.js +178 -0
  23. package/cjs/packages/common/i18n/locales.js +17 -0
  24. package/cjs/packages/common/i18n/types.js +1 -0
  25. package/cjs/packages/common/index.js +65 -0
  26. package/cjs/packages/common/log/index.js +160 -0
  27. package/cjs/packages/common/number/index.js +14 -0
  28. package/cjs/packages/common/object/filterEmpty.js +32 -0
  29. package/cjs/packages/common/object/filtereEmpty.js +5 -0
  30. package/cjs/packages/common/object/index.js +26 -0
  31. package/cjs/packages/common/string/index.js +17 -0
  32. package/cjs/packages/common/types/index.js +1 -0
  33. package/cjs/packages/core/index.js +17 -12
  34. package/cjs/packages/core/loader/model.js +3 -3
  35. package/cjs/packages/core/loader/router.js +14 -5
  36. package/esm/app/controller/base.js +3 -3
  37. package/esm/app/controller/project.js +3 -3
  38. package/esm/app/controller/view.js +16 -7
  39. package/esm/app/middleware/api-params-verify.js +10 -1
  40. package/esm/app/middleware/error-handle.js +9 -3
  41. package/esm/app/middleware/project-handler.js +1 -1
  42. package/esm/app/router/view.js +3 -1
  43. package/esm/app/router-schema/project.js +1 -1
  44. package/esm/app/service/project.js +5 -0
  45. package/esm/bundler/defaultAlias.js +4 -0
  46. package/esm/bundler/dev.js +4 -3
  47. package/esm/bundler/index.js +2 -1
  48. package/esm/bundler/prod.js +4 -3
  49. package/esm/bundler/utils.js +53 -24
  50. package/esm/index.js +2 -2
  51. package/esm/packages/common/LRUCache.js +2 -0
  52. package/esm/packages/common/array/index.js +37 -0
  53. package/esm/packages/common/cache/LRUCache.js +43 -0
  54. package/esm/packages/common/cache/index.js +2 -0
  55. package/esm/packages/common/guards/index.js +26 -0
  56. package/esm/packages/common/i18n/default.js +93 -0
  57. package/esm/packages/common/i18n/en-US.js +93 -0
  58. package/esm/packages/common/i18n/index.js +162 -0
  59. package/esm/packages/common/i18n/locales.js +11 -0
  60. package/esm/packages/common/i18n/types.js +0 -0
  61. package/esm/packages/common/index.js +13 -0
  62. package/esm/packages/common/log/index.js +146 -0
  63. package/esm/packages/common/number/index.js +11 -0
  64. package/esm/packages/common/object/filterEmpty.js +29 -0
  65. package/esm/packages/common/object/filtereEmpty.js +2 -0
  66. package/esm/packages/common/object/index.js +20 -0
  67. package/esm/packages/common/string/index.js +13 -0
  68. package/esm/packages/common/types/index.js +0 -0
  69. package/esm/packages/core/index.js +17 -12
  70. package/esm/packages/core/loader/model.js +3 -3
  71. package/esm/packages/core/loader/router.js +14 -5
  72. package/fe/frontend/dash/Dashboard.d.ts +7 -0
  73. package/fe/frontend/dash/Dashboard.js +63 -0
  74. package/fe/frontend/dash/dash.entry.d.ts +2 -0
  75. package/fe/frontend/dash/dash.entry.js +62 -0
  76. package/fe/frontend/index.d.ts +3 -0
  77. package/fe/frontend/index.js +1 -0
  78. package/fe/frontend/main.css +5 -1
  79. package/fe/frontend/main.d.ts +10 -3
  80. package/fe/frontend/main.js +13 -4
  81. package/fe/frontend/testPage/testPage.entry.js +1 -2
  82. package/fe/frontend/typing/window.d.ts +7 -0
  83. package/fe/frontend/typing/window.js +1 -0
  84. package/fe/frontend/widgets/api/baseInfo.d.ts +31 -0
  85. package/fe/frontend/widgets/api/baseInfo.js +15 -0
  86. package/fe/frontend/widgets/common/CRUD/CRUD.d.ts +70 -0
  87. package/fe/frontend/widgets/common/CRUD/CRUD.js +207 -0
  88. package/fe/frontend/widgets/common/CRUD/index.d.ts +2 -0
  89. package/fe/frontend/widgets/common/CRUD/index.js +1 -0
  90. package/fe/frontend/widgets/common/auth/index.d.ts +7 -0
  91. package/fe/frontend/widgets/common/auth/index.js +20 -0
  92. package/fe/frontend/widgets/common/generateMenuData.d.ts +4 -0
  93. package/fe/frontend/widgets/common/generateMenuData.js +14 -0
  94. package/fe/frontend/widgets/common/importComponent.d.ts +5 -0
  95. package/fe/frontend/widgets/common/importComponent.js +7 -0
  96. package/fe/frontend/widgets/common/language.d.ts +2 -0
  97. package/fe/frontend/widgets/common/language.js +8 -0
  98. package/fe/frontend/widgets/common/logFn/index.d.ts +4 -0
  99. package/fe/frontend/widgets/common/logFn/index.js +8 -0
  100. package/fe/frontend/widgets/common/menu.d.ts +22 -0
  101. package/fe/frontend/widgets/common/menu.js +80 -0
  102. package/fe/frontend/widgets/common/request.d.ts +33 -0
  103. package/fe/frontend/widgets/common/request.js +127 -0
  104. package/fe/frontend/widgets/components/BasePage/HeaderView.d.ts +9 -0
  105. package/fe/frontend/widgets/components/BasePage/HeaderView.js +14 -0
  106. package/fe/frontend/widgets/components/Router/index.d.ts +9 -0
  107. package/fe/frontend/widgets/components/Router/index.js +11 -0
  108. package/fe/frontend/widgets/components/Router/type.d.ts +2 -0
  109. package/fe/frontend/widgets/components/Router/type.js +1 -0
  110. package/fe/frontend/widgets/defaultPages/Iframe/index.d.ts +3 -0
  111. package/fe/frontend/widgets/defaultPages/Iframe/index.js +14 -0
  112. package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/DetailPanel.d.ts +7 -0
  113. package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/DetailPanel.js +94 -0
  114. package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/PopFrom.d.ts +13 -0
  115. package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/PopFrom.js +109 -0
  116. package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/data.d.ts +3 -0
  117. package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/data.js +6 -0
  118. package/fe/frontend/widgets/defaultPages/Schema/components/SchemaSearch/index.d.ts +3 -0
  119. package/fe/frontend/widgets/defaultPages/Schema/components/SchemaSearch/index.js +58 -0
  120. package/fe/frontend/widgets/defaultPages/Schema/components/SchemaTable/index.d.ts +11 -0
  121. package/fe/frontend/widgets/defaultPages/Schema/components/SchemaTable/index.js +176 -0
  122. package/fe/frontend/widgets/defaultPages/Schema/data/eventInfo.d.ts +8 -0
  123. package/fe/frontend/widgets/defaultPages/Schema/data/eventInfo.js +6 -0
  124. package/fe/frontend/widgets/defaultPages/Schema/data/index.d.ts +3 -0
  125. package/fe/frontend/widgets/defaultPages/Schema/data/index.js +1 -0
  126. package/fe/frontend/widgets/defaultPages/Schema/hooks/useComConfig.d.ts +10 -0
  127. package/fe/frontend/widgets/defaultPages/Schema/hooks/useComConfig.js +14 -0
  128. package/fe/frontend/widgets/defaultPages/Schema/index.d.ts +3 -0
  129. package/fe/frontend/widgets/defaultPages/Schema/index.js +67 -0
  130. package/fe/frontend/widgets/defaultPages/Schema/schemaType.d.ts +41 -0
  131. package/fe/frontend/widgets/defaultPages/Schema/schemaType.js +4 -0
  132. package/fe/frontend/widgets/defaultPages/Schema/stores/schemaEventBus.d.ts +23 -0
  133. package/fe/frontend/widgets/defaultPages/Schema/stores/schemaEventBus.js +66 -0
  134. package/fe/frontend/widgets/defaultPages/Schema/stores/schemaStore.d.ts +33 -0
  135. package/fe/frontend/widgets/defaultPages/Schema/stores/schemaStore.js +24 -0
  136. package/fe/frontend/widgets/defaultPages/Schema/utils/fetchErrorShow.d.ts +3 -0
  137. package/fe/frontend/widgets/defaultPages/Schema/utils/fetchErrorShow.js +8 -0
  138. package/fe/frontend/widgets/defaultPages/Schema/utils/permissions.d.ts +3 -0
  139. package/fe/frontend/widgets/defaultPages/Schema/utils/permissions.js +3 -0
  140. package/fe/frontend/widgets/defaultPages/Schema/utils/schemaConversion.d.ts +3 -0
  141. package/fe/frontend/widgets/defaultPages/Schema/utils/schemaConversion.js +72 -0
  142. package/fe/frontend/widgets/defaultPages/Schema/utils/validator.d.ts +4 -0
  143. package/fe/frontend/widgets/defaultPages/Schema/utils/validator.js +31 -0
  144. package/fe/frontend/widgets/defaultPages/SidebarSlotPage/SidebarSlotContainer.d.ts +10 -0
  145. package/fe/frontend/widgets/defaultPages/SidebarSlotPage/SidebarSlotContainer.js +31 -0
  146. package/fe/frontend/widgets/defaultPages/SidebarSlotPage/index.d.ts +3 -0
  147. package/fe/frontend/widgets/defaultPages/SidebarSlotPage/index.js +15 -0
  148. package/fe/frontend/widgets/defaultPages/SidebarSlotPageTmp.d.ts +3 -0
  149. package/fe/frontend/widgets/defaultPages/SidebarSlotPageTmp.js +17 -0
  150. package/fe/frontend/widgets/defaultPages/SlotPage/index.d.ts +3 -0
  151. package/fe/frontend/widgets/defaultPages/SlotPage/index.js +24 -0
  152. package/fe/frontend/widgets/defaultPages/Todo.d.ts +3 -0
  153. package/fe/frontend/widgets/defaultPages/Todo.js +5 -0
  154. package/fe/frontend/widgets/hooks/useCurrentMenuData.d.ts +11 -0
  155. package/fe/frontend/widgets/hooks/useCurrentMenuData.js +20 -0
  156. package/fe/frontend/widgets/hooks/useRouterParams.d.ts +5 -0
  157. package/fe/frontend/widgets/hooks/useRouterParams.js +11 -0
  158. package/fe/frontend/widgets/store/mode.d.ts +16 -0
  159. package/fe/frontend/widgets/store/mode.js +36 -0
  160. package/fe/model/types/data/button.d.ts +23 -0
  161. package/fe/model/types/data/button.js +1 -0
  162. package/fe/model/types/data/component.d.ts +37 -0
  163. package/fe/model/types/data/component.js +1 -0
  164. package/fe/model/types/data/fetchInfo.d.ts +8 -0
  165. package/fe/model/types/data/fetchInfo.js +1 -0
  166. package/fe/model/types/data/schema.d.ts +47 -0
  167. package/fe/model/types/data/schema.js +1 -0
  168. package/fe/model/types/data/search.d.ts +7 -0
  169. package/fe/model/types/data/search.js +1 -0
  170. package/fe/model/types/menuType.d.ts +44 -0
  171. package/fe/model/types/menuType.js +1 -0
  172. package/fe/model/types/model.d.ts +20 -0
  173. package/fe/model/types/model.js +1 -0
  174. package/fe/packages/common/array/index.d.ts +7 -0
  175. package/fe/packages/common/array/index.js +40 -0
  176. package/fe/packages/common/cache/LRUCache.d.ts +13 -0
  177. package/fe/packages/common/cache/LRUCache.js +47 -0
  178. package/fe/packages/common/cache/index.d.ts +2 -0
  179. package/fe/packages/common/cache/index.js +1 -0
  180. package/fe/packages/common/guards/index.d.ts +9 -0
  181. package/fe/packages/common/guards/index.js +24 -0
  182. package/fe/packages/common/i18n/default.d.ts +87 -0
  183. package/fe/packages/common/i18n/default.js +85 -0
  184. package/fe/packages/common/i18n/en-US.d.ts +87 -0
  185. package/fe/packages/common/i18n/en-US.js +85 -0
  186. package/fe/packages/common/i18n/index.d.ts +19 -0
  187. package/fe/packages/common/i18n/index.js +142 -0
  188. package/fe/packages/common/i18n/locales.d.ts +8 -0
  189. package/fe/packages/common/i18n/locales.js +10 -0
  190. package/fe/packages/common/i18n/types.d.ts +47 -0
  191. package/fe/packages/common/i18n/types.js +1 -0
  192. package/fe/packages/common/index.d.ts +10 -0
  193. package/fe/packages/common/index.js +9 -0
  194. package/fe/packages/common/log/index.d.ts +33 -0
  195. package/fe/packages/common/log/index.js +176 -0
  196. package/fe/packages/common/number/index.d.ts +3 -0
  197. package/fe/packages/common/number/index.js +10 -0
  198. package/fe/packages/common/object/filterEmpty.d.ts +3 -0
  199. package/fe/packages/common/object/filterEmpty.js +33 -0
  200. package/fe/packages/common/object/index.d.ts +5 -0
  201. package/fe/packages/common/object/index.js +25 -0
  202. package/fe/packages/common/string/index.d.ts +4 -0
  203. package/fe/packages/common/string/index.js +17 -0
  204. package/fe/packages/common/types/index.d.ts +4 -0
  205. package/fe/packages/common/types/index.js +1 -0
  206. package/fe/packages/ui/react/components/Button/Button.d.ts +16 -30
  207. package/fe/packages/ui/react/components/Button/Button.js +53 -26
  208. package/fe/packages/ui/react/components/Button/SumbitButton.d.ts +2 -6
  209. package/fe/packages/ui/react/components/Button/SumbitButton.js +3 -14
  210. package/fe/packages/ui/react/components/Button/index.d.ts +1 -1
  211. package/fe/packages/ui/react/components/Checkbox/Checkbox.d.ts +1 -1
  212. package/fe/packages/ui/react/components/Checkbox/Checkbox.js +5 -3
  213. package/fe/packages/ui/react/components/{ConfirmDialog.d.ts → ConfirmDialog/ConfirmDialog.d.ts} +0 -8
  214. package/fe/packages/ui/react/components/ConfirmDialog/ConfirmDialog.js +11 -0
  215. package/fe/packages/ui/react/components/ConfirmDialog/index.d.ts +2 -0
  216. package/fe/packages/ui/react/components/ConfirmDialog/index.js +1 -0
  217. package/fe/packages/ui/react/components/DataTable/ActionBtn.d.ts +3 -1
  218. package/fe/packages/ui/react/components/DataTable/ActionBtn.js +85 -4
  219. package/fe/packages/ui/react/components/DataTable/{data-table.d.ts → index.d.ts} +10 -23
  220. package/fe/packages/ui/react/components/DataTable/{data-table.js → index.js} +57 -47
  221. package/fe/packages/ui/react/components/Date/Calendar.d.ts +0 -13
  222. package/fe/packages/ui/react/components/Date/Calendar.js +5 -13
  223. package/fe/packages/ui/react/components/Date/Date.d.ts +4 -13
  224. package/fe/packages/ui/react/components/Date/Date.js +70 -66
  225. package/fe/packages/ui/react/components/Date/LocaleContext.d.ts +0 -4
  226. package/fe/packages/ui/react/components/Date/LocaleContext.js +0 -4
  227. package/fe/packages/ui/react/components/Date/LocaleProvider.d.ts +0 -11
  228. package/fe/packages/ui/react/components/Date/LocaleProvider.js +0 -11
  229. package/fe/packages/ui/react/components/Date/TimePicker.js +3 -2
  230. package/fe/packages/ui/react/components/Date/dateLocaleStore.d.ts +0 -6
  231. package/fe/packages/ui/react/components/Date/dropdownPositioning.d.ts +3 -0
  232. package/fe/packages/ui/react/components/Date/dropdownPositioning.js +12 -0
  233. package/fe/packages/ui/react/components/Date/locales.d.ts +1 -19
  234. package/fe/packages/ui/react/components/Date/locales.js +7 -47
  235. package/fe/packages/ui/react/components/Drawer/Drawer.d.ts +23 -0
  236. package/fe/packages/ui/react/components/Drawer/Drawer.js +100 -0
  237. package/fe/packages/ui/react/components/Drawer/index.d.ts +3 -0
  238. package/fe/packages/ui/react/components/Drawer/index.js +1 -0
  239. package/fe/packages/ui/react/components/Dropdown/Dropdown.d.ts +24 -0
  240. package/fe/packages/ui/react/components/Dropdown/Dropdown.js +28 -0
  241. package/fe/packages/ui/react/components/Dropdown/index.d.ts +2 -0
  242. package/fe/packages/ui/react/components/Dropdown/index.js +1 -0
  243. package/fe/packages/ui/react/components/Form/Form.d.ts +0 -6
  244. package/fe/packages/ui/react/components/Form/Form.js +1 -1
  245. package/fe/packages/ui/react/components/Form/FormItem.d.ts +0 -21
  246. package/fe/packages/ui/react/components/Form/FormItem.js +2 -9
  247. package/fe/packages/ui/react/components/Form/SchemaForm/data.d.ts +45 -0
  248. package/fe/packages/ui/react/components/Form/{SchemeForm → SchemaForm}/data.js +8 -1
  249. package/fe/packages/ui/react/components/Form/SchemaForm/index.d.ts +60 -0
  250. package/fe/packages/ui/react/components/Form/SchemaForm/index.js +75 -0
  251. package/fe/packages/ui/react/components/Form/index.d.ts +1 -1
  252. package/fe/packages/ui/react/components/Form/index.js +1 -1
  253. package/fe/packages/ui/react/components/ImagePreview/ImagePreview.js +15 -20
  254. package/fe/packages/ui/react/components/ImagePreview/PreviewImage.d.ts +0 -3
  255. package/fe/packages/ui/react/components/ImagePreview/PreviewImage.js +5 -2
  256. package/fe/packages/ui/react/components/Input/Input.d.ts +3 -21
  257. package/fe/packages/ui/react/components/Input/Input.js +5 -7
  258. package/fe/packages/ui/react/components/InputNumber/InputNumber.d.ts +26 -0
  259. package/fe/packages/ui/react/components/InputNumber/InputNumber.js +144 -0
  260. package/fe/packages/ui/react/components/InputNumber/index.d.ts +2 -0
  261. package/fe/packages/ui/react/components/InputNumber/index.js +1 -0
  262. package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.d.ts +30 -0
  263. package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.js +63 -0
  264. package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.test.d.ts +2 -0
  265. package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.test.js +27 -0
  266. package/fe/packages/ui/react/components/Label/Label.d.ts +0 -29
  267. package/fe/packages/ui/react/components/Label/Label.js +2 -4
  268. package/fe/packages/ui/react/components/Menu/Menu.d.ts +18 -0
  269. package/fe/packages/ui/react/components/Menu/Menu.js +98 -0
  270. package/fe/packages/ui/react/components/Menu/MenuContext.d.ts +39 -0
  271. package/fe/packages/ui/react/components/Menu/MenuContext.js +97 -0
  272. package/fe/packages/ui/react/components/Menu/MenuItem.d.ts +3 -0
  273. package/fe/packages/ui/react/components/Menu/MenuItem.js +33 -0
  274. package/fe/packages/ui/react/components/Menu/SubMenu.d.ts +3 -0
  275. package/fe/packages/ui/react/components/Menu/SubMenu.js +124 -0
  276. package/fe/packages/ui/react/components/Menu/index.d.ts +9 -0
  277. package/fe/packages/ui/react/components/Menu/index.js +5 -0
  278. package/fe/packages/ui/react/components/Menu/menuTypes.d.ts +58 -0
  279. package/fe/packages/ui/react/components/Menu/menuTypes.js +1 -0
  280. package/fe/packages/ui/react/components/Menu/utils.d.ts +2 -0
  281. package/fe/packages/ui/react/components/Menu/utils.js +7 -0
  282. package/fe/packages/ui/react/components/Message/Message.d.ts +0 -7
  283. package/fe/packages/ui/react/components/Message/Message.js +4 -4
  284. package/fe/packages/ui/react/components/Message/MessageManager.js +0 -8
  285. package/fe/packages/ui/react/components/Modal/Modal.d.ts +3 -7
  286. package/fe/packages/ui/react/components/Modal/Modal.js +6 -44
  287. package/fe/packages/ui/react/components/Modal/ModalManager.d.ts +0 -12
  288. package/fe/packages/ui/react/components/Modal/ModalManager.js +5 -7
  289. package/fe/packages/ui/react/components/Overlay/Overlay.d.ts +20 -0
  290. package/fe/packages/ui/react/components/Overlay/Overlay.js +53 -0
  291. package/fe/packages/ui/react/components/Overlay/index.d.ts +3 -0
  292. package/fe/packages/ui/react/components/Overlay/index.js +1 -0
  293. package/fe/packages/ui/react/components/{Pagination.d.ts → Pagination/Pagination.d.ts} +0 -7
  294. package/fe/packages/ui/react/components/{Pagination.js → Pagination/Pagination.js} +5 -12
  295. package/fe/packages/ui/react/components/Pagination/index.d.ts +2 -0
  296. package/fe/packages/ui/react/components/Pagination/index.js +1 -0
  297. package/fe/packages/ui/react/components/Popup/Popup.d.ts +26 -0
  298. package/fe/packages/ui/react/components/Popup/Popup.js +69 -0
  299. package/fe/packages/ui/react/components/Popup/index.d.ts +2 -0
  300. package/fe/packages/ui/react/components/Popup/index.js +1 -0
  301. package/fe/packages/ui/react/components/Search/Search.d.ts +2 -5
  302. package/fe/packages/ui/react/components/Search/Search.js +3 -3
  303. package/fe/packages/ui/react/components/Select/Select.d.ts +2 -2
  304. package/fe/packages/ui/react/components/Select/Select.js +52 -113
  305. package/fe/packages/ui/react/components/Select/dropdownPositioning.d.ts +3 -0
  306. package/fe/packages/ui/react/components/Select/dropdownPositioning.js +13 -0
  307. package/fe/packages/ui/react/components/Skeleton/Skeleton.d.ts +0 -15
  308. package/fe/packages/ui/react/components/Skeleton/Skeleton.js +3 -3
  309. package/fe/packages/ui/react/components/Switch/Switch.js +3 -1
  310. package/fe/packages/ui/react/components/TableSearch/TableSearch.d.ts +5 -41
  311. package/fe/packages/ui/react/components/TableSearch/TableSearch.js +21 -22
  312. package/fe/packages/ui/react/components/TableSearch/lang.js +5 -14
  313. package/fe/packages/ui/react/components/Textarea/Textarea.d.ts +21 -0
  314. package/fe/packages/ui/react/components/Textarea/Textarea.js +36 -0
  315. package/fe/packages/ui/react/components/Textarea/index.d.ts +2 -0
  316. package/fe/packages/ui/react/components/Textarea/index.js +1 -0
  317. package/fe/packages/ui/react/components/Tooltip/Tooltip.d.ts +9 -0
  318. package/fe/packages/ui/react/components/Tooltip/Tooltip.js +71 -0
  319. package/fe/packages/ui/react/components/Tooltip/index.d.ts +2 -0
  320. package/fe/packages/ui/react/components/Tooltip/index.js +1 -0
  321. package/fe/packages/ui/react/components/{TreeSelect.d.ts → TreeSelect/TreeSelect.d.ts} +0 -6
  322. package/fe/packages/ui/react/components/{TreeSelect.js → TreeSelect/TreeSelect.js} +9 -17
  323. package/fe/packages/ui/react/components/TreeSelect/index.d.ts +2 -0
  324. package/fe/packages/ui/react/components/TreeSelect/index.js +1 -0
  325. package/fe/packages/ui/react/components/Upload/ImageUpload.js +18 -6
  326. package/fe/packages/ui/react/components/Upload/Upload.d.ts +0 -27
  327. package/fe/packages/ui/react/components/Upload/Upload.js +2 -1
  328. package/fe/packages/ui/react/components/{breadcrumb.js → breadcrumb/breadcrumb.js} +15 -21
  329. package/fe/packages/ui/react/components/breadcrumb/index.d.ts +2 -0
  330. package/fe/packages/ui/react/components/breadcrumb/index.js +1 -0
  331. package/fe/packages/ui/react/components/hooks/useDropdownPositioning.d.ts +43 -0
  332. package/fe/packages/ui/react/components/hooks/useDropdownPositioning.js +123 -0
  333. package/fe/packages/ui/react/components/hooks/useInputController.d.ts +0 -3
  334. package/fe/packages/ui/react/components/hooks/useInputController.js +0 -7
  335. package/fe/packages/ui/react/components/index.d.ts +7 -1
  336. package/fe/packages/ui/react/components/index.js +7 -1
  337. package/fe/packages/ui/react/components/table/index.d.ts +2 -0
  338. package/fe/packages/ui/react/components/table/index.js +1 -0
  339. package/fe/packages/ui/react/components/table/table.js +20 -0
  340. package/fe/packages/ui/react/components/testPage/MenuTestPage.d.ts +2 -0
  341. package/fe/packages/ui/react/components/testPage/MenuTestPage.js +101 -0
  342. package/fe/packages/ui/react/components/testPage/index.js +251 -81
  343. package/fe/packages/ui/react/hooks/useExecuteOnce.d.ts +12 -0
  344. package/fe/packages/ui/react/hooks/useExecuteOnce.js +36 -0
  345. package/fe/packages/ui/react/hooks/useInit.d.ts +1 -1
  346. package/fe/packages/ui/react/hooks/useInit.js +1 -1
  347. package/fe/packages/ui/react/hooks/useLanguage.d.ts +1 -6
  348. package/fe/packages/ui/react/hooks/useRefState.d.ts +18 -0
  349. package/fe/packages/ui/react/hooks/useRefState.js +28 -0
  350. package/fe/packages/ui/react/hooks/useWatch.d.ts +15 -0
  351. package/fe/packages/ui/react/hooks/useWatch.js +87 -0
  352. package/fe/packages/ui/react/hooks/useWatch.test.d.ts +2 -0
  353. package/fe/packages/ui/react/hooks/useWatch.test.js +22 -0
  354. package/fe/packages/ui/react/i18n/I18nProvider.d.ts +13 -0
  355. package/fe/packages/ui/react/i18n/I18nProvider.js +25 -0
  356. package/fe/packages/ui/react/i18n/index.d.ts +4 -0
  357. package/fe/packages/ui/react/i18n/index.js +3 -0
  358. package/fe/packages/ui/react/i18n/useI18n.d.ts +9 -0
  359. package/fe/packages/ui/react/i18n/useI18n.js +14 -0
  360. package/fe/packages/ui/react/index.css +238 -0
  361. package/fe/packages/ui/react/index.d.ts +2 -0
  362. package/fe/packages/ui/react/index.js +2 -2
  363. package/fe/packages/ui/react/lib/createStoreHook.d.ts +9 -0
  364. package/fe/packages/ui/react/lib/createStoreHook.js +6 -0
  365. package/fe/packages/ui/react/lib/export.d.ts +2 -46
  366. package/fe/packages/ui/react/lib/export.js +0 -40
  367. package/fe/packages/ui/react/lib/utils.d.ts +0 -24
  368. package/fe/packages/ui/react/lib/utils.js +0 -25
  369. package/fe/packages/ui/react/stores/breadcrumb.js +0 -2
  370. package/fe/packages/ui/react/stores/language.d.ts +3 -12
  371. package/fe/packages/ui/react/stores/language.js +2 -51
  372. package/fe/typings/type.d.ts +5 -0
  373. package/fe/typings/type.js +1 -0
  374. package/package.json +14 -2
  375. package/types/app/controller/base.d.ts +3 -3
  376. package/types/app/router/view.d.ts +2 -3
  377. package/types/app/service/project.d.ts +29 -4
  378. package/types/app/type.d.ts +1 -0
  379. package/types/app/typings.d.ts +12 -21
  380. package/types/bundler/defaultAlias.d.ts +3 -0
  381. package/types/bundler/utils.d.ts +1 -1
  382. package/types/config/config.default.d.ts +14 -0
  383. package/types/packages/common/LRUCache.d.ts +1 -0
  384. package/types/packages/common/array/index.d.ts +6 -0
  385. package/types/packages/common/cache/LRUCache.d.ts +12 -0
  386. package/types/packages/common/cache/index.d.ts +1 -0
  387. package/types/packages/common/guards/index.d.ts +8 -0
  388. package/types/packages/common/i18n/default.d.ts +86 -0
  389. package/types/packages/common/i18n/en-US.d.ts +86 -0
  390. package/types/packages/common/i18n/index.d.ts +18 -0
  391. package/types/packages/common/i18n/locales.d.ts +7 -0
  392. package/types/packages/common/i18n/types.d.ts +46 -0
  393. package/types/packages/common/index.d.ts +9 -0
  394. package/types/packages/common/log/index.d.ts +32 -0
  395. package/types/packages/common/number/index.d.ts +2 -0
  396. package/types/packages/common/object/filterEmpty.d.ts +2 -0
  397. package/types/packages/common/object/filtereEmpty.d.ts +1 -0
  398. package/types/packages/common/object/index.d.ts +4 -0
  399. package/types/packages/common/string/index.d.ts +3 -0
  400. package/types/packages/common/types/index.d.ts +3 -0
  401. package/types/packages/core/index.d.ts +1 -1
  402. package/types/packages/core/loader/router.d.ts +1 -1
  403. package/types/packages/core/types.d.ts +12 -3
  404. package/fe/packages/ui/react/components/ConfirmDialog.js +0 -9
  405. package/fe/packages/ui/react/components/Dropdown.d.ts +0 -16
  406. package/fe/packages/ui/react/components/Dropdown.js +0 -54
  407. package/fe/packages/ui/react/components/Form/SchemeForm/data.d.ts +0 -51
  408. package/fe/packages/ui/react/components/Form/SchemeForm/index.d.ts +0 -152
  409. package/fe/packages/ui/react/components/Form/SchemeForm/index.js +0 -69
  410. package/fe/packages/ui/react/components/Textarea.d.ts +0 -59
  411. package/fe/packages/ui/react/components/Textarea.js +0 -35
  412. package/fe/packages/ui/react/components/Tooltip.d.ts +0 -25
  413. package/fe/packages/ui/react/components/Tooltip.js +0 -118
  414. package/fe/packages/ui/react/components/table.js +0 -20
  415. package/fe/packages/ui/react/locales/index.d.ts +0 -8
  416. package/fe/packages/ui/react/locales/index.js +0 -6
  417. /package/fe/packages/ui/react/components/{breadcrumb.d.ts → breadcrumb/breadcrumb.d.ts} +0 -0
  418. /package/fe/packages/ui/react/components/{table.d.ts → table/table.d.ts} +0 -0
@@ -0,0 +1,144 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from '../../lib/utils';
3
+ import { ChevronDown, ChevronUp, X } from 'lucide-react';
4
+ import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
+ import { formatNumber, isValidNumberInput, normalizeNumber, parseInputNumber, shouldSyncDisplayValue, stepValue, } from './inputNumberUtils';
6
+ const formatDisplayValue = (value, constraints) => typeof value === 'number' ? formatNumber(value, constraints) : '';
7
+ const getBlurValue = (rawValue) => {
8
+ if (rawValue === '' || rawValue === '-' || rawValue === '.' || rawValue === '-.') {
9
+ return undefined;
10
+ }
11
+ const normalizedRawValue = rawValue.endsWith('.') ? rawValue.slice(0, -1) : rawValue;
12
+ const parsedValue = Number(normalizedRawValue);
13
+ return Number.isFinite(parsedValue) ? parsedValue : undefined;
14
+ };
15
+ const InputNumber = forwardRef(({ className, inputClassName, value: controlledValue, onChange, defaultValue, allowClear, addonAfter, allowStep = false, disabled, min, max, precision, step, inputMode = 'decimal', ...props }, ref) => {
16
+ const constraints = useMemo(() => ({
17
+ min,
18
+ max,
19
+ precision,
20
+ step,
21
+ }), [max, min, precision, step]);
22
+ const isControlled = controlledValue !== undefined;
23
+ const [internalValue, setInternalValue] = useState(defaultValue);
24
+ const currentValue = isControlled ? controlledValue : internalValue;
25
+ const [isFocused, setIsFocused] = useState(false);
26
+ const [displayValue, setDisplayValue] = useState(() => formatDisplayValue(currentValue, constraints));
27
+ const inputRef = useRef(null);
28
+ const setRefs = useCallback((node) => {
29
+ inputRef.current = node;
30
+ if (typeof ref === 'function') {
31
+ ref(node);
32
+ }
33
+ else if (ref) {
34
+ ref.current = node;
35
+ }
36
+ }, [ref]);
37
+ useEffect(() => {
38
+ if (!shouldSyncDisplayValue({ isFocused, displayValue, currentValue })) {
39
+ return;
40
+ }
41
+ const nextDisplayValue = formatDisplayValue(currentValue, constraints);
42
+ if (nextDisplayValue !== displayValue) {
43
+ setDisplayValue(nextDisplayValue);
44
+ }
45
+ }, [constraints, currentValue, displayValue, isFocused]);
46
+ const emitChange = useCallback((nextValue, e, forceNotify = false) => {
47
+ if (!isControlled) {
48
+ setInternalValue(nextValue);
49
+ }
50
+ if (forceNotify || !Object.is(currentValue, nextValue)) {
51
+ onChange?.(nextValue, e);
52
+ }
53
+ }, [currentValue, isControlled, onChange]);
54
+ const createSyntheticChangeEvent = useCallback((value) => {
55
+ const target = inputRef.current;
56
+ if (target) {
57
+ target.value = value;
58
+ }
59
+ return {
60
+ target: { value },
61
+ currentTarget: { value },
62
+ };
63
+ }, []);
64
+ const handleChange = useCallback((e) => {
65
+ const nextDisplayValue = e.target.value;
66
+ if (!isValidNumberInput(nextDisplayValue)) {
67
+ return;
68
+ }
69
+ setDisplayValue(nextDisplayValue);
70
+ const parsedValue = parseInputNumber(nextDisplayValue);
71
+ if (parsedValue.kind === 'empty') {
72
+ emitChange(undefined, e);
73
+ return;
74
+ }
75
+ if (parsedValue.kind === 'number') {
76
+ emitChange(parsedValue.value, e);
77
+ }
78
+ }, [emitChange]);
79
+ const handleBlur = useCallback((e) => {
80
+ setIsFocused(false);
81
+ const nextValue = getBlurValue(displayValue);
82
+ if (nextValue === undefined) {
83
+ const syntheticEvent = createSyntheticChangeEvent('');
84
+ setDisplayValue('');
85
+ emitChange(undefined, syntheticEvent);
86
+ props.onBlur?.(e);
87
+ return;
88
+ }
89
+ const normalizedValue = normalizeNumber(nextValue, constraints);
90
+ const nextDisplayValue = formatDisplayValue(normalizedValue, constraints);
91
+ const syntheticEvent = createSyntheticChangeEvent(nextDisplayValue);
92
+ setDisplayValue(nextDisplayValue);
93
+ emitChange(normalizedValue, syntheticEvent);
94
+ props.onBlur?.(e);
95
+ }, [constraints, createSyntheticChangeEvent, displayValue, emitChange, props]);
96
+ const handleFocus = useCallback((e) => {
97
+ if (disabled) {
98
+ return;
99
+ }
100
+ setIsFocused(true);
101
+ props.onFocus?.(e);
102
+ }, [disabled, props]);
103
+ const clearIcon = useMemo(() => {
104
+ if (!allowClear) {
105
+ return undefined;
106
+ }
107
+ if (typeof allowClear === 'boolean') {
108
+ return (_jsx("span", { className: cn('h-5 w-5 rounded-full', 'bg-muted text-foreground', 'flex items-center justify-center', 'transition-colors hover:bg-muted/80'), children: _jsx(X, { size: 12 }) }));
109
+ }
110
+ return allowClear.clearIcon;
111
+ }, [allowClear]);
112
+ const hasValue = displayValue.length > 0;
113
+ const showClearIcon = hasValue && clearIcon && !disabled;
114
+ const hasRightAccessories = showClearIcon || addonAfter || allowStep;
115
+ const currentParsedValue = parseInputNumber(displayValue);
116
+ const stepBaseValue = currentParsedValue.kind === 'number' ? currentParsedValue.value : currentValue;
117
+ const normalizedCurrentStepValue = typeof stepBaseValue === 'number' ? normalizeNumber(stepBaseValue, constraints) : undefined;
118
+ const canStep = useCallback((direction) => {
119
+ if (disabled) {
120
+ return false;
121
+ }
122
+ const nextValue = stepValue(stepBaseValue, direction, constraints);
123
+ return !Object.is(nextValue, normalizedCurrentStepValue);
124
+ }, [constraints, disabled, normalizedCurrentStepValue, stepBaseValue]);
125
+ const handleStep = useCallback((direction) => {
126
+ const nextValue = stepValue(stepBaseValue, direction, constraints);
127
+ const nextDisplayValue = formatDisplayValue(nextValue, constraints);
128
+ const syntheticEvent = createSyntheticChangeEvent(nextDisplayValue);
129
+ setDisplayValue(nextDisplayValue);
130
+ emitChange(nextValue, syntheticEvent, true);
131
+ inputRef.current?.focus();
132
+ }, [constraints, createSyntheticChangeEvent, emitChange, stepBaseValue]);
133
+ const handleClear = useCallback((e) => {
134
+ e.preventDefault();
135
+ e.stopPropagation();
136
+ const syntheticEvent = createSyntheticChangeEvent('');
137
+ setDisplayValue('');
138
+ emitChange(undefined, syntheticEvent, true);
139
+ inputRef.current?.focus();
140
+ }, [createSyntheticChangeEvent, emitChange]);
141
+ return (_jsxs("div", { className: cn('tc-ui-input-number relative w-full', className), children: [_jsx("input", { ref: setRefs, type: "text", value: displayValue, onChange: handleChange, inputMode: inputMode, className: cn('flex w-full rounded-lg px-4 py-3 text-sm', 'border transition-colors duration-200', 'placeholder:text-muted-foreground', 'focus:outline-none', showClearIcon && !allowStep && !addonAfter && 'pr-10', hasRightAccessories && 'pr-24', allowStep && addonAfter && 'pr-28', disabled ? 'cursor-not-allowed bg-muted border-border text-muted-foreground' : 'bg-background', !disabled && !hasValue && !isFocused && 'border-border', !disabled && (hasValue || isFocused) && 'border-theme', inputClassName), onFocus: handleFocus, onBlur: handleBlur, disabled: disabled, ...props }), hasRightAccessories && (_jsxs("div", { className: "absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1", children: [showClearIcon && (_jsx("button", { type: "button", onMouseDown: (e) => e.preventDefault(), onClick: handleClear, children: clearIcon })), addonAfter && _jsx("div", { children: addonAfter }), allowStep && (_jsxs("div", { className: "flex flex-col overflow-hidden rounded-md border border-border", children: [_jsx("button", { type: "button", onMouseDown: (e) => e.preventDefault(), onClick: () => handleStep('up'), disabled: !canStep('up'), className: cn('flex h-4 w-4 items-center justify-center bg-background text-foreground transition-colors', 'border-b border-border', 'disabled:cursor-not-allowed disabled:text-muted-foreground', !disabled && canStep('up') && 'hover:bg-muted'), children: _jsx(ChevronUp, { size: 12 }) }), _jsx("button", { type: "button", onMouseDown: (e) => e.preventDefault(), onClick: () => handleStep('down'), disabled: !canStep('down'), className: cn('flex h-4 w-4 items-center justify-center bg-background text-foreground transition-colors', 'disabled:cursor-not-allowed disabled:text-muted-foreground', !disabled && canStep('down') && 'hover:bg-muted'), children: _jsx(ChevronDown, { size: 12 }) })] }))] }))] }));
142
+ });
143
+ InputNumber.displayName = 'InputNumber';
144
+ export { InputNumber };
@@ -0,0 +1,2 @@
1
+ export * from './InputNumber';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ export * from './InputNumber';
@@ -0,0 +1,30 @@
1
+ export interface InputNumberConstraints {
2
+ min?: number;
3
+ max?: number;
4
+ precision?: number;
5
+ step?: number;
6
+ }
7
+ export type ParsedInputNumber = {
8
+ kind: 'empty';
9
+ } | {
10
+ kind: 'incomplete';
11
+ } | {
12
+ kind: 'invalid';
13
+ } | {
14
+ kind: 'number';
15
+ value: number;
16
+ };
17
+ export type StepDirection = 'up' | 'down';
18
+ export declare const isValidNumberInput: (value: string) => boolean;
19
+ export declare const clampValue: (value: number, constraints: InputNumberConstraints) => number;
20
+ export declare const applyPrecision: (value: number, precision?: number) => number;
21
+ export declare const normalizeNumber: (value: number, constraints: InputNumberConstraints) => number;
22
+ export declare const formatNumber: (value: number, constraints: InputNumberConstraints) => string;
23
+ export declare const parseInputNumber: (value: string) => ParsedInputNumber;
24
+ export declare const shouldSyncDisplayValue: ({ isFocused, displayValue, currentValue, }: {
25
+ isFocused: boolean;
26
+ displayValue: string;
27
+ currentValue: number | undefined;
28
+ }) => boolean;
29
+ export declare const stepValue: (currentValue: number | undefined, direction: StepDirection, constraints: InputNumberConstraints) => number;
30
+ //# sourceMappingURL=inputNumberUtils.d.ts.map
@@ -0,0 +1,63 @@
1
+ const isFiniteNumber = (value) => typeof value === 'number' && Number.isFinite(value);
2
+ export const isValidNumberInput = (value) => /^-?\d*(\.\d*)?$/.test(value);
3
+ export const clampValue = (value, constraints) => {
4
+ let nextValue = value;
5
+ if (isFiniteNumber(constraints.min)) {
6
+ nextValue = Math.max(nextValue, constraints.min);
7
+ }
8
+ if (isFiniteNumber(constraints.max)) {
9
+ nextValue = Math.min(nextValue, constraints.max);
10
+ }
11
+ return nextValue;
12
+ };
13
+ export const applyPrecision = (value, precision) => {
14
+ if (typeof precision !== 'number' || precision < 0) {
15
+ return value;
16
+ }
17
+ return Number(value.toFixed(precision));
18
+ };
19
+ export const normalizeNumber = (value, constraints) => {
20
+ return clampValue(applyPrecision(value, constraints.precision), constraints);
21
+ };
22
+ export const formatNumber = (value, constraints) => {
23
+ const normalized = normalizeNumber(value, constraints);
24
+ if (typeof constraints.precision === 'number' && constraints.precision >= 0) {
25
+ return normalized.toFixed(constraints.precision);
26
+ }
27
+ return String(normalized);
28
+ };
29
+ export const parseInputNumber = (value) => {
30
+ if (value === '') {
31
+ return { kind: 'empty' };
32
+ }
33
+ if (value === '-' || value === '.' || value === '-.' || /^-?\d+\.$/.test(value)) {
34
+ return { kind: 'incomplete' };
35
+ }
36
+ if (!isValidNumberInput(value)) {
37
+ return { kind: 'invalid' };
38
+ }
39
+ const parsedValue = Number(value);
40
+ if (!Number.isFinite(parsedValue)) {
41
+ return { kind: 'invalid' };
42
+ }
43
+ return { kind: 'number', value: parsedValue };
44
+ };
45
+ export const shouldSyncDisplayValue = ({ isFocused, displayValue, currentValue, }) => {
46
+ if (!isFocused) {
47
+ return true;
48
+ }
49
+ const parsedDisplayValue = parseInputNumber(displayValue);
50
+ if (parsedDisplayValue.kind === 'incomplete' || parsedDisplayValue.kind === 'invalid') {
51
+ return false;
52
+ }
53
+ if (parsedDisplayValue.kind === 'empty') {
54
+ return currentValue !== undefined;
55
+ }
56
+ return !Object.is(parsedDisplayValue.value, currentValue);
57
+ };
58
+ export const stepValue = (currentValue, direction, constraints) => {
59
+ const step = constraints.step && constraints.step > 0 ? constraints.step : 1;
60
+ const baseValue = isFiniteNumber(currentValue) ? currentValue : 0;
61
+ const delta = direction === 'up' ? step : -step;
62
+ return normalizeNumber(baseValue + delta, constraints);
63
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inputNumberUtils.test.d.ts.map
@@ -0,0 +1,27 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import { clampValue, formatNumber, parseInputNumber, shouldSyncDisplayValue, stepValue } from './inputNumberUtils';
4
+ test('parseInputNumber keeps empty and transitional values unresolved', () => {
5
+ assert.deepEqual(parseInputNumber(''), { kind: 'empty' });
6
+ assert.deepEqual(parseInputNumber('-'), { kind: 'incomplete' });
7
+ assert.deepEqual(parseInputNumber('.'), { kind: 'incomplete' });
8
+ assert.deepEqual(parseInputNumber('1.'), { kind: 'incomplete' });
9
+ assert.deepEqual(parseInputNumber('-1.'), { kind: 'incomplete' });
10
+ assert.deepEqual(parseInputNumber('1.25'), { kind: 'number', value: 1.25 });
11
+ });
12
+ test('formatNumber applies precision and clamps boundaries', () => {
13
+ assert.equal(formatNumber(1.236, { precision: 2 }), '1.24');
14
+ assert.equal(formatNumber(12, { max: 10 }), '10');
15
+ assert.equal(clampValue(-3, { min: 0 }), 0);
16
+ });
17
+ test('stepValue respects min max precision and step', () => {
18
+ assert.equal(stepValue(undefined, 'up', { step: 0.25, precision: 2 }), 0.25);
19
+ assert.equal(stepValue(9.9, 'up', { step: 1, max: 10, precision: 1 }), 10);
20
+ assert.equal(stepValue(0.3, 'down', { step: 0.2, min: 0, precision: 1 }), 0.1);
21
+ });
22
+ test('shouldSyncDisplayValue preserves editable decimals while focused', () => {
23
+ assert.equal(shouldSyncDisplayValue({ isFocused: true, displayValue: '12.5', currentValue: 12.5 }), false);
24
+ assert.equal(shouldSyncDisplayValue({ isFocused: true, displayValue: '12.56', currentValue: 12.56 }), false);
25
+ assert.equal(shouldSyncDisplayValue({ isFocused: true, displayValue: '12.56', currentValue: 3.14 }), true);
26
+ assert.equal(shouldSyncDisplayValue({ isFocused: false, displayValue: '12.56', currentValue: 12.56 }), true);
27
+ });
@@ -4,46 +4,17 @@ type VerticalLayout = {
4
4
  };
5
5
  type HorizontalLayout = {
6
6
  layout?: 'horizontal';
7
- /**
8
- * 标签宽度
9
- * @default 'auto'
10
- */
11
7
  labelWidth?: string | number;
12
- /**
13
- * 标签对齐方式
14
- * @default 'left'
15
- */
16
8
  labelAlign?: 'left' | 'right' | 'center';
17
9
  };
18
10
  export type LabelLayout = HorizontalLayout | VerticalLayout;
19
11
  export type LabelProps = {
20
- /**
21
- * 标签文本
22
- */
23
12
  label: ReactNode;
24
- /**
25
- * 标签内容
26
- */
27
13
  children: ReactNode;
28
- /**
29
- * 是否必填(显示红色星号)
30
- */
31
14
  required?: boolean;
32
- /**
33
- * 标签的 htmlFor 属性
34
- */
35
15
  htmlFor?: string;
36
- /**
37
- * 容器类名
38
- */
39
16
  className?: string;
40
- /**
41
- * 标签类名
42
- */
43
17
  labelClassName?: string;
44
- /**
45
- * 内容区域类名
46
- */
47
18
  contentClassName?: string;
48
19
  } & LabelLayout;
49
20
  declare const Label: import("react").ForwardRefExoticComponent<LabelProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn } from '../../lib/utils';
3
3
  import { forwardRef, useMemo } from 'react';
4
- // 标签对齐样式
5
4
  const labelAlignStyles = {
6
5
  left: 'text-left',
7
6
  right: 'text-right',
@@ -10,7 +9,6 @@ const labelAlignStyles = {
10
9
  const Label = forwardRef((props, ref) => {
11
10
  const { label, children, layout = 'vertical', required = false, htmlFor, className, labelClassName, contentClassName, } = props;
12
11
  const isVertical = layout === 'vertical';
13
- // 标签样式
14
12
  const labelStyles = cn('text-sm font-medium text-foreground', required && "before:content-['*'] before:pt-1 before:mr-0.5 before:text-destructive", labelClassName);
15
13
  const { usedClassName, labelWidth } = useMemo(() => {
16
14
  let usedLabelWidth;
@@ -27,9 +25,9 @@ const Label = forwardRef((props, ref) => {
27
25
  };
28
26
  }, [props]);
29
27
  if (isVertical) {
30
- return (_jsxs("div", { ref: ref, className: cn('flex flex-col gap-2', className), children: [_jsx("label", { htmlFor: htmlFor, className: labelStyles, children: label }), _jsx("div", { className: cn('w-full', contentClassName), children: children })] }));
28
+ return (_jsxs("div", { ref: ref, className: cn('tc-ui-label flex flex-col gap-2', className), children: [_jsx("label", { htmlFor: htmlFor, className: labelStyles, children: label }), _jsx("div", { className: cn('w-full', contentClassName), children: children })] }));
31
29
  }
32
- return (_jsxs("div", { ref: ref, className: cn('flex items-center gap-4', className), children: [_jsx("label", { htmlFor: htmlFor, className: cn(labelStyles, usedClassName), style: { width: labelWidth, flexShrink: 0 }, children: label }), _jsx("div", { className: cn('flex-1', contentClassName), children: children })] }));
30
+ return (_jsxs("div", { ref: ref, className: cn('tc-ui-label flex items-center gap-4', className), children: [_jsx("label", { htmlFor: htmlFor, className: cn(labelStyles, usedClassName), style: { width: labelWidth, flexShrink: 0 }, children: label }), _jsx("div", { className: cn('flex-1', contentClassName), children: children })] }));
33
31
  });
34
32
  Label.displayName = 'Label';
35
33
  export { Label };
@@ -0,0 +1,18 @@
1
+ import { type FC } from "react";
2
+ import { MenuItem } from "./MenuItem";
3
+ import { SubMenu } from "./SubMenu";
4
+ import type { MenuProps } from "./menuTypes";
5
+ export interface CollapseToggleHandle {
6
+ collapse: () => void;
7
+ expand: () => void;
8
+ }
9
+ export interface CollapseToggleProps {
10
+ className?: string;
11
+ }
12
+ export declare const CollapseToggle: import("react").ForwardRefExoticComponent<CollapseToggleProps & import("react").RefAttributes<CollapseToggleHandle>>;
13
+ export declare const Menu: FC<MenuProps> & {
14
+ Item: typeof MenuItem;
15
+ SubMenu: typeof SubMenu;
16
+ CollapseToggle: typeof CollapseToggle;
17
+ };
18
+ //# sourceMappingURL=Menu.d.ts.map
@@ -0,0 +1,98 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../../lib/utils";
3
+ import { forwardRef, useEffect, useImperativeHandle, useRef, } from "react";
4
+ import { ChevronLeft, ChevronRight } from "lucide-react";
5
+ import { CollapsedContext, useMenuStore, MenuStoreContext, createMenuContextValue, } from "./MenuContext";
6
+ import { MenuItem } from "./MenuItem";
7
+ import { SubMenu } from "./SubMenu";
8
+ function renderItems(items, parentKey) {
9
+ return items.map((item) => {
10
+ if (item.children && item.children.length > 0) {
11
+ return (_jsx(SubMenu, { eventKey: item.key, label: item.label, icon: item.icon, disabled: item.disabled, popup: item.popup, parentKey: parentKey, children: renderItems(item.children, item.key) }, item.key));
12
+ }
13
+ return (_jsx(MenuItem, { eventKey: item.key, icon: item.icon, disabled: item.disabled, danger: item.danger, onClick: item.onClick, className: item.className, style: item.style, width: item.width, minWidth: item.minWidth, maxWidth: item.maxWidth, children: item.label }, item.key));
14
+ });
15
+ }
16
+ export const CollapseToggle = forwardRef(({ className }, ref) => {
17
+ const collapsed = useMenuStore((s) => s.collapsed);
18
+ const setCollapsed = useMenuStore((s) => s.setCollapsed);
19
+ const onCollapse = useMenuStore((s) => s.onCollapse);
20
+ const propsCollapsed = useMenuStore((s) => s.propsCollapsed);
21
+ const shouldShowCollapseToggle = () => {
22
+ if (typeof propsCollapsed !== "undefined" &&
23
+ typeof onCollapse === "undefined") {
24
+ return false;
25
+ }
26
+ return true;
27
+ };
28
+ useImperativeHandle(ref, () => ({
29
+ collapse: () => setCollapsed(true),
30
+ expand: () => setCollapsed(false),
31
+ }), [setCollapsed]);
32
+ if (!shouldShowCollapseToggle()) {
33
+ return null;
34
+ }
35
+ return (_jsx("div", { role: "button", onClick: () => setCollapsed(!collapsed), className: cn("mx-1 mb-1 flex h-9 cursor-pointer items-center justify-center rounded-lg", "text-muted-foreground transition-all", "hover:bg-muted/60 hover:text-foreground", className), children: collapsed ? (_jsx(ChevronRight, { className: "h-4 w-4" })) : (_jsx(ChevronLeft, { className: "h-4 w-4" })) }));
36
+ });
37
+ CollapseToggle.displayName = "CollapseToggle";
38
+ function MenuInner({ children, items, className, mode, }) {
39
+ const collapsed = useMenuStore((s) => s.collapsed);
40
+ const collapsedWidth = useMenuStore((s) => s.collapsedWidth);
41
+ const content = items ? renderItems(items) : children;
42
+ return (_jsxs("nav", { role: "menu", className: cn("tc-ui-menu relative overflow-hidden rounded-xl bg-background shadow-sm", mode === "left" && "flex flex-col p-1", mode === "top" && "flex flex-row items-center p-[3px]", className), style: mode === "left" && collapsed ? { width: collapsedWidth } : undefined, children: [mode === "left" && _jsx(CollapseToggle, {}), _jsx(CollapsedContext.Provider, { value: mode === "left" && collapsed, children: _jsx("div", { className: cn(mode === "left" && "flex flex-col gap-1", mode === "top" && "flex flex-row items-center gap-1"), children: content }) })] }));
43
+ }
44
+ export const Menu = ({ mode = "left", expandTrigger = "click", expandMode = "accordion", selectedKey: controlledSelectedKey, defaultSelectedKey, onSelect, items, children, className, collapsed: controlledCollapsed, defaultCollapsed, onCollapse, collapsedWidth = 64, collapsedLabelTooltip = true, }) => {
45
+ const storeRef = useRef(null);
46
+ if (!storeRef.current) {
47
+ storeRef.current = createMenuContextValue({
48
+ mode,
49
+ expandTrigger,
50
+ expandMode,
51
+ selectedKey: controlledSelectedKey,
52
+ defaultSelectedKey,
53
+ collapsed: controlledCollapsed,
54
+ propsCollapsed: controlledCollapsed,
55
+ defaultCollapsed,
56
+ collapsedWidth,
57
+ collapsedLabelTooltip,
58
+ onSelect,
59
+ onCollapse,
60
+ });
61
+ }
62
+ const store = storeRef.current;
63
+ useEffect(() => {
64
+ store.setState({
65
+ mode,
66
+ expandTrigger,
67
+ expandMode,
68
+ propsCollapsed: controlledCollapsed,
69
+ collapsedWidth,
70
+ collapsedLabelTooltip,
71
+ onSelect,
72
+ onCollapse,
73
+ });
74
+ }, [
75
+ mode,
76
+ expandTrigger,
77
+ expandMode,
78
+ controlledCollapsed,
79
+ collapsedWidth,
80
+ collapsedLabelTooltip,
81
+ onSelect,
82
+ onCollapse,
83
+ ]);
84
+ useEffect(() => {
85
+ if (controlledSelectedKey !== undefined) {
86
+ store.setState({ selectedKey: controlledSelectedKey });
87
+ }
88
+ }, [controlledSelectedKey]);
89
+ useEffect(() => {
90
+ if (controlledCollapsed !== undefined) {
91
+ store.setState({ collapsed: controlledCollapsed });
92
+ }
93
+ }, [controlledCollapsed]);
94
+ return (_jsx(MenuStoreContext.Provider, { value: store, children: _jsx(MenuInner, { mode: mode, items: items, className: className, children: children }) }));
95
+ };
96
+ Menu.Item = MenuItem;
97
+ Menu.SubMenu = SubMenu;
98
+ Menu.CollapseToggle = CollapseToggle;
@@ -0,0 +1,39 @@
1
+ export declare const CollapsedContext: import("react").Context<boolean>;
2
+ interface MenuStore {
3
+ mode: 'top' | 'left';
4
+ expandTrigger: 'hover' | 'click';
5
+ expandMode: 'accordion' | 'multiple';
6
+ selectedKey: string | undefined;
7
+ openKeys: string[];
8
+ openKeyParents: Record<string, string>;
9
+ collapsed: boolean;
10
+ propsCollapsed: boolean | undefined;
11
+ collapsedWidth: number;
12
+ collapsedLabelTooltip: boolean;
13
+ onSelect: ((key: string) => void) | undefined;
14
+ onCollapse: ((collapsed: boolean) => void) | undefined;
15
+ isControlledSelected: boolean;
16
+ isControlledCollapsed: boolean;
17
+ setSelectedKey: (key: string) => void;
18
+ toggleOpenKey: (key: string, parentKey?: string) => void;
19
+ setCollapsed: (collapsed: boolean) => void;
20
+ }
21
+ declare const MenuStoreContext: import("react").Context<import("zustand").StoreApi<MenuStore> | null>;
22
+ export declare function useMenuStore<T>(selector: (state: MenuStore) => T): T;
23
+ export declare function createMenuContextValue(overrides: {
24
+ mode?: 'top' | 'left';
25
+ expandTrigger?: 'hover' | 'click';
26
+ expandMode?: 'accordion' | 'multiple';
27
+ selectedKey?: string;
28
+ defaultSelectedKey?: string;
29
+ collapsed?: boolean;
30
+ propsCollapsed?: boolean;
31
+ defaultCollapsed?: boolean;
32
+ collapsedWidth?: number;
33
+ collapsedLabelTooltip?: boolean;
34
+ onSelect?: (key: string) => void;
35
+ onCollapse?: (collapsed: boolean) => void;
36
+ }): import("zustand").StoreApi<MenuStore>;
37
+ export { MenuStoreContext };
38
+ export type { MenuStore };
39
+ //# sourceMappingURL=MenuContext.d.ts.map
@@ -0,0 +1,97 @@
1
+ import { createContext, useContext } from 'react';
2
+ export const CollapsedContext = createContext(false);
3
+ import { createStore, useStore } from 'zustand';
4
+ function createMenuStore(props) {
5
+ const { mode, expandTrigger, propsCollapsed, expandMode, collapsedWidth, } = props;
6
+ const isControlledSelected = props.selectedKey !== undefined;
7
+ const isControlledCollapsed = props.collapsed !== undefined;
8
+ return createStore((set, get) => ({
9
+ mode,
10
+ expandTrigger,
11
+ expandMode,
12
+ selectedKey: props.selectedKey ?? props.defaultSelectedKey,
13
+ openKeys: [],
14
+ openKeyParents: {},
15
+ collapsed: props.collapsed ?? props.defaultCollapsed ?? false,
16
+ propsCollapsed,
17
+ collapsedWidth,
18
+ collapsedLabelTooltip: props.collapsedLabelTooltip,
19
+ onSelect: props.onSelect,
20
+ onCollapse: props.onCollapse,
21
+ isControlledSelected,
22
+ isControlledCollapsed,
23
+ setSelectedKey: (key) => {
24
+ const { isControlledSelected, onSelect } = get();
25
+ if (!isControlledSelected) {
26
+ set({ selectedKey: key });
27
+ }
28
+ onSelect?.(key);
29
+ },
30
+ toggleOpenKey: (key, parentKey) => {
31
+ const { openKeys, openKeyParents, expandMode } = get();
32
+ const isOpen = openKeys.includes(key);
33
+ if (expandMode === 'accordion') {
34
+ const nextParents = { ...openKeyParents };
35
+ if (isOpen) {
36
+ delete nextParents[key];
37
+ }
38
+ else {
39
+ const siblings = openKeys.filter((k) => openKeyParents[k] === parentKey);
40
+ siblings.forEach((k) => delete nextParents[k]);
41
+ if (parentKey)
42
+ nextParents[key] = parentKey;
43
+ }
44
+ set({
45
+ openKeys: isOpen
46
+ ? openKeys.filter((k) => k !== key)
47
+ : openKeys.filter((k) => openKeyParents[k] !== parentKey).concat(key),
48
+ openKeyParents: nextParents,
49
+ });
50
+ }
51
+ else {
52
+ if (isOpen) {
53
+ const nextParents = { ...openKeyParents };
54
+ delete nextParents[key];
55
+ set({ openKeys: openKeys.filter((k) => k !== key), openKeyParents: nextParents });
56
+ }
57
+ else {
58
+ set({
59
+ openKeys: [...openKeys, key],
60
+ openKeyParents: parentKey ? { ...openKeyParents, [key]: parentKey } : openKeyParents,
61
+ });
62
+ }
63
+ }
64
+ },
65
+ setCollapsed: (collapsed) => {
66
+ const { isControlledCollapsed, onCollapse } = get();
67
+ if (!isControlledCollapsed) {
68
+ set({ collapsed });
69
+ }
70
+ onCollapse?.(collapsed);
71
+ },
72
+ }));
73
+ }
74
+ const MenuStoreContext = createContext(null);
75
+ export function useMenuStore(selector) {
76
+ const store = useContext(MenuStoreContext);
77
+ if (!store)
78
+ throw new Error('Menu compound components must be used within <Menu>');
79
+ return useStore(store, selector);
80
+ }
81
+ export function createMenuContextValue(overrides) {
82
+ return createMenuStore({
83
+ mode: overrides.mode ?? 'left',
84
+ expandTrigger: overrides.expandTrigger ?? 'click',
85
+ expandMode: overrides.expandMode ?? 'accordion',
86
+ selectedKey: overrides.selectedKey,
87
+ defaultSelectedKey: overrides.defaultSelectedKey,
88
+ collapsed: overrides.collapsed,
89
+ propsCollapsed: overrides.propsCollapsed,
90
+ defaultCollapsed: overrides.defaultCollapsed,
91
+ collapsedWidth: overrides.collapsedWidth ?? 64,
92
+ collapsedLabelTooltip: overrides.collapsedLabelTooltip ?? true,
93
+ onSelect: overrides.onSelect,
94
+ onCollapse: overrides.onCollapse,
95
+ });
96
+ }
97
+ export { MenuStoreContext };
@@ -0,0 +1,3 @@
1
+ import type { MenuItemProps } from "./menuTypes";
2
+ export declare function MenuItem({ eventKey, icon, disabled, danger, onClick, children, className, style, width, minWidth, maxWidth, ...props }: MenuItemProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=MenuItem.d.ts.map
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../../lib/utils";
3
+ import { useCallback, useContext, useRef, useState } from "react";
4
+ import { Button } from "../Button";
5
+ import { CollapsedContext, useMenuStore } from "./MenuContext";
6
+ import { Popup } from "../Popup";
7
+ import { getFirstChar } from "./utils";
8
+ export function MenuItem({ eventKey, icon, disabled, danger, onClick, children, className, style, width, minWidth, maxWidth, ...props }) {
9
+ const mode = useMenuStore((s) => s.mode);
10
+ const selectedKey = useMenuStore((s) => s.selectedKey);
11
+ const setSelectedKey = useMenuStore((s) => s.setSelectedKey);
12
+ const collapsed = useContext(CollapsedContext);
13
+ const collapsedLabelTooltip = useMenuStore((s) => s.collapsedLabelTooltip);
14
+ const isSelected = selectedKey === eventKey;
15
+ const triggerRef = useRef(null);
16
+ const [showTooltip, setShowTooltip] = useState(false);
17
+ const handleClick = useCallback(() => {
18
+ if (disabled)
19
+ return;
20
+ eventKey && setSelectedKey(eventKey);
21
+ onClick?.();
22
+ }, [disabled, eventKey, onClick, setSelectedKey]);
23
+ return (_jsxs("div", { ref: triggerRef, className: "relative", onMouseEnter: () => collapsed && collapsedLabelTooltip && setShowTooltip(true), onMouseLeave: () => collapsed && collapsedLabelTooltip && setShowTooltip(false), children: [_jsxs(Button, { ...props, variant: "text", role: "menuitem", disabled: disabled, onClick: handleClick, className: cn("menuitem group relative flex items-center rounded-lg text-sm outline-none transition-all", "focus-visible:ring-2 focus-visible:ring-theme/30 focus-visible:ring-offset-0", mode === "top" &&
24
+ "h-10 w-auto min-w-fit justify-start gap-3 px-3 py-2 text-left", mode === "left" &&
25
+ collapsed &&
26
+ "h-10 w-full justify-center gap-0 px-0 py-2", mode === "left" &&
27
+ !collapsed &&
28
+ "min-h-10 w-full gap-3 px-3 py-2.5 text-left", isSelected && "bg-theme text-theme-foreground shadow-sm", !isSelected &&
29
+ !danger &&
30
+ "text-foreground hover:bg-gray-200 dark:hover:bg-gray-700", danger && !isSelected && "text-destructive hover:bg-destructive/10", disabled && "cursor-not-allowed opacity-50", className), style: collapsed ? style : { width, minWidth, maxWidth, ...style }, children: [icon && (_jsx("span", { className: cn("flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md transition-colors", isSelected
31
+ ? "bg-theme-foreground/15"
32
+ : "text-muted-foreground group-hover:text-foreground"), children: icon })), !collapsed && (_jsx("span", { className: "min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap", children: children })), collapsed && !icon && collapsedLabelTooltip && (_jsx("span", { className: "absolute left-0 right-0 top-0 flex h-full items-center justify-center text-[10px]", children: getFirstChar(children) }))] }), _jsx(Popup, { open: showTooltip, anchorRef: triggerRef, placement: "right-start", offset: 8, onOpenChange: setShowTooltip, className: "border-0 bg-transparent p-0 shadow-none", keepMounted: true, children: _jsx("div", { className: "whitespace-nowrap rounded-lg bg-gray-900 px-3 py-1.5 text-xs text-white shadow-sm", children: children }) })] }));
33
+ }
@@ -0,0 +1,3 @@
1
+ import type { SubMenuProps } from "./menuTypes";
2
+ export declare function SubMenu({ eventKey, label, icon, disabled, popup: forcePopup, parentKey, children, }: SubMenuProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=SubMenu.d.ts.map