@giteeteam/apps-team-components 1.2.2 → 1.3.0-alpha.2

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 (314) hide show
  1. package/README.md +21 -28
  2. package/dist/components/common/EmptyField.d.ts +0 -1
  3. package/dist/components/common/EmptyField.js +7 -5
  4. package/dist/components/common/PriceTag.js +26 -23
  5. package/dist/components/common/expand-component/index.d.ts +22 -0
  6. package/dist/components/common/expand-component/index.js +67 -0
  7. package/dist/components/common/expand-component/style.d.ts +2 -0
  8. package/dist/components/common/expand-component/style.js +10 -0
  9. package/dist/components/common/item-icon/ItemIcon.d.ts +7 -0
  10. package/dist/components/common/item-icon/ItemIcon.js +8 -0
  11. package/dist/components/common/overflow-tooltip/BaseOverflowTooltip.d.ts +0 -1
  12. package/dist/components/common/overflow-tooltip/BaseOverflowTooltip.js +9 -6
  13. package/dist/components/common/overflow-tooltip/OverflowTooltip.d.ts +19 -0
  14. package/dist/components/common/overflow-tooltip/OverflowTooltip.js +57 -0
  15. package/dist/components/common/overflow-tooltip/SimpleOverflowToolTip.js +8 -5
  16. package/dist/components/common/overflow-tooltip/style/index.js +16 -14
  17. package/dist/components/common/style/global.js +4 -2
  18. package/dist/components/common/style/mixin.d.ts +2 -0
  19. package/dist/components/common/style/mixin.js +20 -0
  20. package/dist/components/common/user-field/UserAvatar.js +8 -6
  21. package/dist/components/common/user-field/style/index.js +23 -21
  22. package/dist/components/common/utils.d.ts +6 -0
  23. package/dist/components/common/utils.js +63 -5
  24. package/dist/components/default-empty-icon/config.d.ts +2 -0
  25. package/dist/components/default-empty-icon/config.js +24 -0
  26. package/dist/components/default-empty-icon/index.d.ts +5 -0
  27. package/dist/components/default-empty-icon/index.js +24 -0
  28. package/dist/components/default-empty-icon/style.d.ts +11 -0
  29. package/dist/components/default-empty-icon/style.js +67 -0
  30. package/dist/components/default-empty-icon/types.d.ts +29 -0
  31. package/dist/components/default-empty-icon/types.js +8 -0
  32. package/dist/components/field-behavior/fields/type.js +5 -2
  33. package/dist/components/fields/actors/BaseField.js +5 -2
  34. package/dist/components/fields/actors/ReadView.d.ts +0 -1
  35. package/dist/components/fields/actors/ReadView.js +8 -6
  36. package/dist/components/fields/ancestor/ReadView.js +8 -6
  37. package/dist/components/fields/ancestor/utils.js +4 -12
  38. package/dist/components/fields/assignee/ReadView.d.ts +0 -1
  39. package/dist/components/fields/assignee/ReadView.js +13 -11
  40. package/dist/components/fields/base-component/types.d.ts +1 -0
  41. package/dist/components/fields/base-component/utils.d.ts +2 -0
  42. package/dist/components/fields/base-component/utils.js +11 -0
  43. package/dist/components/fields/bind-workspace/ReadView.d.ts +0 -1
  44. package/dist/components/fields/bind-workspace/ReadView.js +11 -9
  45. package/dist/components/fields/bind-workspace/hooks.js +10 -7
  46. package/dist/components/fields/bind-workspace/style/index.js +5 -3
  47. package/dist/components/fields/cascade/ReadView.js +8 -6
  48. package/dist/components/fields/cascade/utils.js +4 -3
  49. package/dist/components/fields/checkbox/ReadView.d.ts +0 -1
  50. package/dist/components/fields/checkbox/ReadView.js +7 -5
  51. package/dist/components/fields/created-at/ReadView.js +10 -8
  52. package/dist/components/fields/created-by/ReadView.d.ts +0 -1
  53. package/dist/components/fields/created-by/ReadView.js +11 -9
  54. package/dist/components/fields/data-quote/ReadView.js +12 -10
  55. package/dist/components/fields/data-quote/utils.js +5 -3
  56. package/dist/components/fields/date/ReadView.d.ts +0 -1
  57. package/dist/components/fields/date/ReadView.js +8 -6
  58. package/dist/components/fields/dropdown/BaseField.d.ts +24 -2
  59. package/dist/components/fields/dropdown/BaseField.js +565 -2
  60. package/dist/components/fields/dropdown/Cell.d.ts +3 -0
  61. package/dist/components/fields/dropdown/Cell.js +8 -0
  62. package/dist/components/fields/dropdown/ReadView.d.ts +0 -1
  63. package/dist/components/fields/dropdown/ReadView.js +10 -8
  64. package/dist/components/fields/dropdown/data.d.ts +9 -0
  65. package/dist/components/fields/dropdown/data.js +29 -0
  66. package/dist/components/fields/dropdown/hook.d.ts +102 -0
  67. package/dist/components/fields/dropdown/hook.js +155 -0
  68. package/dist/components/fields/dropdown/style.d.ts +16 -0
  69. package/dist/components/fields/dropdown/style.js +93 -0
  70. package/dist/components/fields/file/ReadView.d.ts +0 -1
  71. package/dist/components/fields/file/ReadView.js +7 -5
  72. package/dist/components/fields/formula/ReadView.d.ts +0 -1
  73. package/dist/components/fields/formula/ReadView.js +7 -5
  74. package/dist/components/fields/hooks/useViewClass.d.ts +11 -0
  75. package/dist/components/fields/hooks/useViewClass.js +20 -0
  76. package/dist/components/fields/hyper-link/ReadView.d.ts +0 -1
  77. package/dist/components/fields/hyper-link/ReadView.js +8 -6
  78. package/dist/components/fields/hyper-link/style/index.js +18 -15
  79. package/dist/components/fields/item-group/ReadView.d.ts +0 -1
  80. package/dist/components/fields/item-group/ReadView.js +6 -4
  81. package/dist/components/fields/item-type/ItemTypeIcon.d.ts +9 -0
  82. package/dist/components/fields/item-type/ItemTypeIcon.js +31 -0
  83. package/dist/components/fields/item-type/ReadView.d.ts +0 -1
  84. package/dist/components/fields/item-type/ReadView.js +7 -5
  85. package/dist/components/fields/item-type/style/index.d.ts +1 -0
  86. package/dist/components/fields/item-type/style/index.js +8 -0
  87. package/dist/components/fields/key/ReadView.d.ts +0 -1
  88. package/dist/components/fields/key/ReadView.js +7 -5
  89. package/dist/components/fields/long-text/ReadView.d.ts +0 -1
  90. package/dist/components/fields/long-text/ReadView.js +8 -6
  91. package/dist/components/fields/long-text/style/index.js +7 -5
  92. package/dist/components/fields/number/BaseField.js +5 -2
  93. package/dist/components/fields/number/ReadView.d.ts +0 -1
  94. package/dist/components/fields/number/ReadView.js +8 -6
  95. package/dist/components/fields/priority/ReadView.js +12 -10
  96. package/dist/components/fields/priority/style/index.js +54 -51
  97. package/dist/components/fields/radio/ReadView.d.ts +0 -1
  98. package/dist/components/fields/radio/ReadView.js +8 -6
  99. package/dist/components/fields/repo-files/ReadView.js +8 -6
  100. package/dist/components/fields/repo-files/utils.js +5 -3
  101. package/dist/components/fields/reporter/ReadView.d.ts +0 -1
  102. package/dist/components/fields/reporter/ReadView.js +11 -9
  103. package/dist/components/fields/script/BaseField.js +4 -1
  104. package/dist/components/fields/script/ReadView.d.ts +0 -1
  105. package/dist/components/fields/script/ReadView.js +10 -8
  106. package/dist/components/fields/sprint/ReadView.js +7 -5
  107. package/dist/components/fields/status/Cell.js +8 -6
  108. package/dist/components/fields/status/Field.d.ts +0 -1
  109. package/dist/components/fields/status/ReadView.js +10 -8
  110. package/dist/components/fields/status/SelectFlowHandler.js +15 -12
  111. package/dist/components/fields/status/SelectTransition.js +13 -10
  112. package/dist/components/fields/status/Transition.js +18 -15
  113. package/dist/components/fields/status/TransitionButton.js +17 -14
  114. package/dist/components/fields/status/TransitionPanel.js +14 -11
  115. package/dist/components/fields/status/View.js +11 -8
  116. package/dist/components/fields/status/style/index.js +302 -325
  117. package/dist/components/fields/story-point/ReadView.d.ts +0 -1
  118. package/dist/components/fields/story-point/ReadView.js +6 -4
  119. package/dist/components/fields/tag/ReadView.js +10 -8
  120. package/dist/components/fields/tag/style/index.js +7 -5
  121. package/dist/components/fields/team/ReadView.js +10 -8
  122. package/dist/components/fields/team/style/index.js +5 -3
  123. package/dist/components/fields/text/BaseField.d.ts +0 -1
  124. package/dist/components/fields/text/ReadView.js +8 -6
  125. package/dist/components/fields/tree/ReadView.js +10 -8
  126. package/dist/components/fields/tree/utils.js +5 -3
  127. package/dist/components/fields/updated-at/ReadView.js +10 -8
  128. package/dist/components/fields/updated-by/ReadView.d.ts +0 -1
  129. package/dist/components/fields/updated-by/ReadView.js +11 -9
  130. package/dist/components/fields/user/ReadView.d.ts +0 -1
  131. package/dist/components/fields/user/ReadView.js +11 -9
  132. package/dist/components/fields/user/style/index.js +12 -9
  133. package/dist/components/fields/user-group/BaseField.d.ts +0 -1
  134. package/dist/components/fields/user-group/ReadView.js +12 -14
  135. package/dist/components/fields/version/ReadView.js +8 -6
  136. package/dist/components/fields/workspace/ReadView.d.ts +0 -1
  137. package/dist/components/fields/workspace/ReadView.js +10 -8
  138. package/dist/components/filters/filter-search/utils.d.ts +4 -0
  139. package/dist/components/filters/filter-search/utils.js +28 -0
  140. package/dist/components/item/hooks.js +5 -2
  141. package/dist/components/table-components/EditTableCell.d.ts +1 -0
  142. package/dist/components/table-components/EditTableCell.js +8 -4
  143. package/dist/components/table-components/index.js +14 -11
  144. package/dist/components/table-components/style/index.js +7 -5
  145. package/dist/components/table-components/utils.js +50 -45
  146. package/dist/icons/SyncIconFont.d.ts +6 -0
  147. package/dist/icons/SyncIconFont.js +17 -0
  148. package/dist/icons/createFromIconFontClass.d.ts +4 -0
  149. package/dist/icons/createFromIconFontClass.js +35 -0
  150. package/dist/icons/empty-icon/data-empty.png +0 -0
  151. package/dist/icons/empty-icon/forbidden.png +0 -0
  152. package/dist/icons/empty-icon/index.d.ts +8 -0
  153. package/dist/icons/empty-icon/large-item@2x.png +0 -0
  154. package/dist/icons/empty-icon/large-item@2x.png.js +3 -0
  155. package/dist/icons/empty-icon/large-workspace@2x.png +0 -0
  156. package/dist/icons/empty-icon/large-workspace@2x.png.js +3 -0
  157. package/dist/icons/empty-icon/load-error.png +0 -0
  158. package/dist/icons/empty-icon/not-found.png +0 -0
  159. package/dist/icons/empty-icon/small-default@2x.png +0 -0
  160. package/dist/icons/empty-icon/small-default@2x.png.js +3 -0
  161. package/dist/icons/empty-icon/workspace-empty.svg +127 -0
  162. package/dist/icons/index.d.ts +58 -1
  163. package/dist/icons/index.js +315 -19
  164. package/dist/icons/style/index.d.ts +2 -0
  165. package/dist/icons/style/index.js +25 -0
  166. package/dist/icons/svg/ArrowBack.svg.js +3 -0
  167. package/dist/icons/svg/Done.svg.js +3 -0
  168. package/dist/icons/svg/DottedCircle.svg.js +3 -0
  169. package/dist/icons/svg/HollowCircle.svg.js +3 -0
  170. package/dist/icons/svg/Search.svg.js +3 -0
  171. package/dist/icons/svg/Workflow.svg.js +3 -0
  172. package/dist/index.d.ts +1 -0
  173. package/dist/index.js +47 -46
  174. package/dist/lib/app/utils.d.ts +2 -0
  175. package/dist/lib/app/utils.js +18 -0
  176. package/dist/lib/array.js +5 -44
  177. package/dist/lib/config.d.ts +14 -0
  178. package/dist/lib/config.js +47 -0
  179. package/dist/lib/constants/code.d.ts +4 -0
  180. package/dist/lib/constants/code.js +6 -0
  181. package/dist/lib/constants/field.d.ts +1 -0
  182. package/dist/lib/constants/field.js +5 -0
  183. package/dist/lib/contexts/antdConfig.js +10 -7
  184. package/dist/lib/contexts/currentUser.js +7 -4
  185. package/dist/lib/contexts/currentWorkspace.js +7 -4
  186. package/dist/lib/contexts/datetimeFormat.js +7 -4
  187. package/dist/lib/contexts/index.js +16 -13
  188. package/dist/lib/contexts/itemConfig.js +7 -4
  189. package/dist/lib/contexts/teamConfig.d.ts +3 -0
  190. package/dist/lib/contexts/teamConfig.js +25 -7
  191. package/dist/lib/contexts/tenant.js +7 -4
  192. package/dist/lib/contexts/workflowConfig.js +7 -4
  193. package/dist/lib/dataType.js +4 -5
  194. package/dist/lib/date.js +11 -52
  195. package/dist/lib/dayjs.js +2 -1
  196. package/dist/lib/error/index.d.ts +2 -0
  197. package/dist/lib/error/log.d.ts +10 -0
  198. package/dist/lib/error/log.js +28 -0
  199. package/dist/lib/error/utils.d.ts +14 -0
  200. package/dist/lib/error/utils.js +38 -0
  201. package/dist/lib/error/withServerError.d.ts +1 -0
  202. package/dist/lib/error/withServerError.js +3 -0
  203. package/dist/lib/fetch.d.ts +45 -0
  204. package/dist/lib/fetch.js +270 -0
  205. package/dist/lib/global.d.ts +18 -0
  206. package/dist/lib/global.js +28 -8
  207. package/dist/lib/hooks/useAntdConfig.js +4 -2
  208. package/dist/lib/hooks/useCurrentUser.js +4 -2
  209. package/dist/lib/hooks/useCurrentWorkspace.js +4 -2
  210. package/dist/lib/hooks/useDataQuoteStore.js +8 -5
  211. package/dist/lib/hooks/useDateTimeFormatType.js +4 -2
  212. package/dist/lib/hooks/useI18n.d.ts +1 -1
  213. package/dist/lib/hooks/useI18n.js +4 -2
  214. package/dist/lib/hooks/useItemConfig.js +4 -2
  215. package/dist/lib/hooks/useTeamConfig.js +4 -2
  216. package/dist/lib/hooks/useTenant.js +4 -2
  217. package/dist/lib/hooks/useWorkflowConfig.js +4 -2
  218. package/dist/lib/i18n.d.ts +1 -0
  219. package/dist/lib/i18n.js +6 -2
  220. package/dist/lib/icons/utils.d.ts +23 -0
  221. package/dist/lib/icons/utils.js +60 -0
  222. package/dist/lib/isInOne.js +2 -1
  223. package/dist/lib/number.js +3 -1
  224. package/dist/lib/path.d.ts +5 -0
  225. package/dist/lib/path.js +50 -0
  226. package/dist/lib/regExp.js +3 -1
  227. package/dist/lib/router.d.ts +23 -0
  228. package/dist/lib/router.js +23 -0
  229. package/dist/lib/storage.d.ts +10 -0
  230. package/dist/lib/storage.js +27 -0
  231. package/dist/lib/store/dataQuoteStore.js +5 -2
  232. package/dist/lib/swr/constants.js +4 -2
  233. package/dist/lib/swr/hooks.js +6 -3
  234. package/dist/lib/swr/throttleWithCache.d.ts +17 -0
  235. package/dist/lib/swr/throttleWithCache.js +110 -0
  236. package/dist/lib/throttleFetch.d.ts +2 -0
  237. package/dist/lib/throttleFetch.js +68 -0
  238. package/dist/lib/useConfig.d.ts +8 -0
  239. package/dist/lib/useConfig.js +31 -0
  240. package/dist/lib/useUser.js +9 -6
  241. package/dist/lib/users.js +5 -2
  242. package/dist/lib/workflow.js +21 -20
  243. package/dist/locales/index.d.ts +45 -0
  244. package/dist/locales/index.js +50 -3
  245. package/dist/public/icons/BulbIcon.svg +1 -0
  246. package/dist/public/icons/Cloud.svg +1 -0
  247. package/dist/public/icons/ConsultIcon.svg +1 -0
  248. package/dist/public/icons/Demo.svg +1 -0
  249. package/dist/public/icons/ErrorTemplate.svg +1 -0
  250. package/dist/public/icons/Fail.svg +1 -0
  251. package/dist/public/icons/Flag.svg +1 -0
  252. package/dist/public/icons/GiteeIcon.svg +1 -0
  253. package/dist/public/icons/IntelligenceGradient.svg +1 -0
  254. package/dist/public/icons/Issue_Approval.svg +1 -0
  255. package/dist/public/icons/Issue_Bug.svg +1 -0
  256. package/dist/public/icons/Issue_Demand.svg +1 -0
  257. package/dist/public/icons/Issue_Doc.svg +1 -0
  258. package/dist/public/icons/Issue_Idea.svg +1 -0
  259. package/dist/public/icons/Issue_List.svg +1 -0
  260. package/dist/public/icons/Issue_Plan.svg +1 -0
  261. package/dist/public/icons/Issue_Product.svg +1 -0
  262. package/dist/public/icons/Issue_Risk.svg +1 -0
  263. package/dist/public/icons/Issue_Story.svg +1 -0
  264. package/dist/public/icons/Issue_Subtask.svg +1 -0
  265. package/dist/public/icons/Issue_Task.svg +1 -0
  266. package/dist/public/icons/Issue_Test.svg +1 -0
  267. package/dist/public/icons/Issue_TestExcution.svg +1 -0
  268. package/dist/public/icons/Issue_TestPlan.svg +1 -0
  269. package/dist/public/icons/Issue_Time.svg +1 -0
  270. package/dist/public/icons/Issue_develop.svg +1 -0
  271. package/dist/public/icons/KanbanCover.svg +7 -0
  272. package/dist/public/icons/ListCover.svg +118 -0
  273. package/dist/public/icons/ManHour.svg +1 -0
  274. package/dist/public/icons/MobileIcon.svg +1 -0
  275. package/dist/public/icons/NoItemType.svg +10 -0
  276. package/dist/public/icons/ProductIcon.svg +1 -0
  277. package/dist/public/icons/RedFlagIcon.svg +1 -0
  278. package/dist/public/icons/Safe.svg +1 -0
  279. package/dist/public/icons/StarIcon.svg +61 -0
  280. package/dist/public/icons/StructureCover.svg +1 -0
  281. package/dist/public/icons/Success.svg +1 -0
  282. package/dist/public/icons/TeamIcon.svg +1 -0
  283. package/dist/public/icons/WebIcon.svg +1 -0
  284. package/dist/public/icons/iconfont.svg +467 -0
  285. package/dist/public/icons/iconfont.ttf +0 -0
  286. package/dist/public/icons/iconfont.woff +0 -0
  287. package/dist/public/icons/iconfont.woff2 +0 -0
  288. package/dist/public/icons/iconfont_multiple_color.js +1 -0
  289. package/dist/public/icons/iconfont_single_color.css +912 -0
  290. package/dist/public/icons/iconfont_single_color.js +1 -0
  291. package/dist/public/icons/loginBg.svg +1 -0
  292. package/dist/public/mockServiceWorker.js +284 -0
  293. package/dist/style/common.d.ts +1 -0
  294. package/dist/style/common.js +19 -23
  295. package/dist/style/global.d.ts +1 -0
  296. package/dist/style/global.js +10 -0
  297. package/package.json +111 -69
  298. package/dist/components/fields/base-component/types.js +0 -1
  299. package/dist/components/fields/hooks/useParamsAdapter.js +0 -1
  300. package/dist/components/fields/radio/BaseField.js +0 -1
  301. package/dist/components/fields/status/Field.js +0 -1
  302. package/dist/components/fields/tag/BaseField.js +0 -1
  303. package/dist/components/fields/text/BaseField.js +0 -1
  304. package/dist/components/fields/tree/BaseField.js +0 -1
  305. package/dist/components/fields/tree/types.js +0 -1
  306. package/dist/components/fields/types.js +0 -1
  307. package/dist/components/fields/user-group/ActionCell.js +0 -1
  308. package/dist/components/fields/user-group/BaseField.js +0 -1
  309. package/dist/icons/svg/ArrowBack.svg +0 -1
  310. package/dist/icons/svg/Done.svg +0 -1
  311. package/dist/icons/svg/DottedCircle.svg +0 -7
  312. package/dist/icons/svg/HollowCircle.svg +0 -6
  313. package/dist/icons/svg/Search.svg +0 -1
  314. package/dist/icons/svg/Workflow.svg +0 -12
package/dist/lib/i18n.js CHANGED
@@ -1,4 +1,5 @@
1
- import { en, ru, zh } from '../locales';
1
+ import { zh, ru, en } from '../locales/index.js';
2
+
2
3
  let locale = 'zh';
3
4
  const getTranslate = () => {
4
5
  switch (locale) {
@@ -15,7 +16,7 @@ const getTranslate = () => {
15
16
  return zh;
16
17
  }
17
18
  };
18
- export const i18n = {
19
+ const i18n = {
19
20
  t: (key, opts) => {
20
21
  var _a;
21
22
  const translate = getTranslate();
@@ -32,3 +33,6 @@ export const i18n = {
32
33
  locale = _locale;
33
34
  },
34
35
  };
36
+ const nsSeparator = '@';
37
+
38
+ export { i18n, nsSeparator };
@@ -0,0 +1,23 @@
1
+ export declare const polyfillItemTypeIconMap: {
2
+ BookMark: string;
3
+ Book: string;
4
+ Flask: string;
5
+ Archive: string;
6
+ EmptyTag: string;
7
+ Branch: string;
8
+ Checked: string;
9
+ Flag: string;
10
+ LightBulb: string;
11
+ List: string;
12
+ Bug: string;
13
+ Task: string;
14
+ Signet: string;
15
+ Risk: string;
16
+ ManHour: string;
17
+ };
18
+ export declare const takeIconFromUrl: (url: string) => string;
19
+ export declare const useIsIconFont: (url: string) => boolean;
20
+ export declare const isServerUrl: (url: string) => boolean;
21
+ export declare const usePolyFillIcon: (url: string, defaultIconFontType?: string) => [boolean, string];
22
+ export declare const joinIconColorSuffix: (icon: string, colored: boolean) => string;
23
+ export declare const isBase64Img: (str: string) => boolean;
@@ -0,0 +1,60 @@
1
+ import { useMemo } from 'react';
2
+ import { useGetBasePath } from '../path.js';
3
+
4
+ const polyfillItemTypeIconMap = {
5
+ BookMark: 'Issue_Story',
6
+ Book: 'Issue_Demand',
7
+ Flask: 'Issue_Test',
8
+ Archive: 'Issue_Doc',
9
+ EmptyTag: 'Issue_develop',
10
+ Branch: 'Issue_Subtask',
11
+ Checked: 'Issue_Task',
12
+ Flag: 'Issue_Plan',
13
+ LightBulb: 'Issue_Idea',
14
+ List: 'Issue_List',
15
+ Bug: 'Issue_Bug',
16
+ Task: 'Issue_Product',
17
+ Signet: 'Issue_Approval',
18
+ Risk: 'Issue_Risk',
19
+ ManHour: 'Issue_Time',
20
+ };
21
+ const takeIconFromUrl = (url) => {
22
+ const arr = url.split('/');
23
+ const last = arr[arr.length - 1];
24
+ const [icon] = last.split('.');
25
+ return icon;
26
+ };
27
+ const useIsIconFont = (url) => {
28
+ const basePath = useGetBasePath();
29
+ return !(url.startsWith('/icons') || url.endsWith('.svg') || url.startsWith(basePath) || url.startsWith('/project'));
30
+ };
31
+ const isServerUrl = (url) => {
32
+ return url.startsWith('http') || url.startsWith('/parse/files');
33
+ };
34
+ const usePolyFillIcon = (url, defaultIconFontType) => {
35
+ const isIconFont = useIsIconFont(url);
36
+ const data = useMemo(() => {
37
+ if (!url) {
38
+ return [false, defaultIconFontType];
39
+ }
40
+ if (isServerUrl(url)) {
41
+ return [true, url];
42
+ }
43
+ else {
44
+ if (isIconFont) {
45
+ return [false, url];
46
+ }
47
+ else {
48
+ let icon = takeIconFromUrl(url);
49
+ icon = polyfillItemTypeIconMap[icon] ? polyfillItemTypeIconMap[icon] : icon;
50
+ return [false, icon || defaultIconFontType];
51
+ }
52
+ }
53
+ }, [defaultIconFontType, isIconFont, url]);
54
+ return data;
55
+ };
56
+ const isBase64Img = (str) => {
57
+ return /^data:image\/(png|jpeg|jpg|gif|svg\+xml);base64,/.test(str);
58
+ };
59
+
60
+ export { isBase64Img, isServerUrl, polyfillItemTypeIconMap, takeIconFromUrl, useIsIconFont, usePolyFillIcon };
@@ -11,4 +11,5 @@ const isInOne = (gateway, isMicroApp) => {
11
11
  return gateway.startsWith('/api');
12
12
  }
13
13
  };
14
- export default isInOne;
14
+
15
+ export { isInOne as default };
@@ -1,3 +1,5 @@
1
- export const numberPrecisionInit = (value, precision) => {
1
+ const numberPrecisionInit = (value, precision) => {
2
2
  return Math.round(value * Math.pow(10, precision)) / Math.pow(10, precision);
3
3
  };
4
+
5
+ export { numberPrecisionInit };
@@ -0,0 +1,5 @@
1
+ export declare const iconBasePath = "/icons";
2
+ export declare const startsWithIconPath: any;
3
+ export declare const useGetBasePath: () => string;
4
+ export declare const useGetSourcePath: () => ((path: string) => string);
5
+ export declare const usePatchIconUrl: () => ((path: string) => string);
@@ -0,0 +1,50 @@
1
+ import { useCallback, useContext } from 'react';
2
+ import { startsWith } from 'lodash-es';
3
+ import { TeamConfigContext } from './contexts/teamConfig.js';
4
+
5
+ const iconBasePath = '/icons';
6
+ const startsWithIconPath = startsWith(iconBasePath);
7
+ const removeExtraSlash = (paths) => {
8
+ if (!paths)
9
+ return '';
10
+ const isEndsWithSlash = paths.endsWith('/');
11
+ const isStartsWithSlash = paths.startsWith('/');
12
+ const result = paths.split('/').filter(Boolean).join('/');
13
+ return `${isStartsWithSlash ? '/' : ''}${result}${isEndsWithSlash ? '/' : ''}`;
14
+ };
15
+ const mergePath = (path1, path2) => {
16
+ const paths = [path1, path2].filter(Boolean).join('/');
17
+ let result = '';
18
+ try {
19
+ const urlObj = new URL(paths);
20
+ urlObj.pathname = removeExtraSlash(urlObj.pathname);
21
+ result = urlObj.toString();
22
+ }
23
+ catch (error) {
24
+ result = removeExtraSlash(paths);
25
+ }
26
+ return result;
27
+ };
28
+ const useGetBasePath = () => {
29
+ const { publicRuntimeConfig } = useContext(TeamConfigContext);
30
+ return (publicRuntimeConfig === null || publicRuntimeConfig === void 0 ? void 0 : publicRuntimeConfig.basePath) || '';
31
+ };
32
+ const useGetSourcePath = () => {
33
+ const basePath = useGetBasePath();
34
+ const getSourcePath = useCallback((path) => {
35
+ return mergePath(basePath, path);
36
+ }, [basePath]);
37
+ return getSourcePath;
38
+ };
39
+ const usePatchIconUrl = () => {
40
+ const getSourcePath = useGetSourcePath();
41
+ const patchIconUrl = useCallback((iconUrl) => {
42
+ if (startsWithIconPath(iconUrl)) {
43
+ return getSourcePath(iconUrl);
44
+ }
45
+ return iconUrl;
46
+ }, [getSourcePath]);
47
+ return patchIconUrl;
48
+ };
49
+
50
+ export { iconBasePath, startsWithIconPath, useGetBasePath, useGetSourcePath, usePatchIconUrl };
@@ -1 +1,3 @@
1
- export const REG_EN_NUMBER = /^[A-Za-z0-9]+$/;
1
+ const REG_EN_NUMBER = /^[A-Za-z0-9]+$/;
2
+
3
+ export { REG_EN_NUMBER };
@@ -0,0 +1,23 @@
1
+ import { RouterQuery } from './types/models';
2
+ export type IRouteReplace = (url: string | {
3
+ pathname?: string;
4
+ query: RouterQuery;
5
+ }, state?: any) => void;
6
+ interface IUserRouterRes {
7
+ asPath: string;
8
+ query: {
9
+ [x: string]: string | string[];
10
+ };
11
+ search: {
12
+ [x: string]: string | string[];
13
+ };
14
+ routePath: string;
15
+ push: (url: string | {
16
+ pathname?: string;
17
+ query: RouterQuery;
18
+ }) => void;
19
+ replace: IRouteReplace;
20
+ back: () => void;
21
+ }
22
+ export declare const getCurLocationInfo: () => IUserRouterRes;
23
+ export {};
@@ -0,0 +1,23 @@
1
+ import queryString from 'query-string';
2
+
3
+ const getCurLocationInfo = () => {
4
+ const { pathname, search } = window.location;
5
+ const basePath = window.__PROXIMA_BASE_NAME__ || '';
6
+ const pathWithoutBasePath = basePath !== '/' && pathname.startsWith(basePath) ? pathname.slice(basePath.length) : pathname;
7
+ const router = {
8
+ asPath: pathWithoutBasePath + search,
9
+ query: {
10
+ ...queryString.parse(search),
11
+ },
12
+ search: {
13
+ ...queryString.parse(search),
14
+ },
15
+ routePath: '',
16
+ push: history.push,
17
+ replace: history.replace,
18
+ back: history.back,
19
+ };
20
+ return router;
21
+ };
22
+
23
+ export { getCurLocationInfo };
@@ -0,0 +1,10 @@
1
+ export declare const getLocalStorageItem: (key: string, defaults?: any) => any;
2
+ export declare const setLocalStorageItem: (key: string, value: unknown) => boolean;
3
+ export declare const removeParseItems: () => void;
4
+ declare const _default: {
5
+ getItem: (key: string, defaults?: any) => any;
6
+ setItem: (key: string, value: unknown) => boolean;
7
+ removeParseItems: () => void;
8
+ };
9
+ export default _default;
10
+ export declare const getLocalStorageState: (key: string, fn: () => any) => Promise<any>;
@@ -0,0 +1,27 @@
1
+ const getLocalStorageItem = (key, defaults = '') => {
2
+ let item;
3
+ try {
4
+ item = localStorage.getItem(key);
5
+ return (item && JSON.parse(item)) || defaults;
6
+ }
7
+ catch (e) {
8
+ return item !== null && item !== void 0 ? item : defaults;
9
+ }
10
+ };
11
+ const getStorageKeys = () => {
12
+ return Object.keys(localStorage);
13
+ };
14
+ const removeParseItems = () => {
15
+ try {
16
+ const keys = getStorageKeys();
17
+ const parseKeys = keys.filter(fieldKey => fieldKey.startsWith('Parse/') && fieldKey.endsWith('/currentUser'));
18
+ parseKeys.forEach(paresKey => {
19
+ localStorage.removeItem(paresKey);
20
+ });
21
+ }
22
+ catch (error) {
23
+ console.error('removeParseItems', error);
24
+ }
25
+ };
26
+
27
+ export { getLocalStorageItem, removeParseItems };
@@ -1,9 +1,12 @@
1
1
  import { atom } from 'recoil';
2
- export const dataQuoteState = atom({
2
+
3
+ const dataQuoteState = atom({
3
4
  key: 'dataQuoteState',
4
5
  default: [],
5
6
  });
6
- export const currentDeleteState = atom({
7
+ const currentDeleteState = atom({
7
8
  key: 'currentDeleteState',
8
9
  default: '',
9
10
  });
11
+
12
+ export { currentDeleteState, dataQuoteState };
@@ -1,4 +1,4 @@
1
- export var API_KEY;
1
+ var API_KEY;
2
2
  (function (API_KEY) {
3
3
  API_KEY["GET_SEARCH_ITEM_GROUP"] = "GET_SEARCH_ITEM_GROUP";
4
4
  API_KEY["GET_SEARCH_ITEM_TYPE"] = "GET_SEARCH_ITEM_TYPE";
@@ -24,9 +24,11 @@ export var API_KEY;
24
24
  API_KEY["GET_TABLE_DEMO_CUSTOM_FIELDS"] = "GET_TABLE_DEMO_CUSTOM_FIELDS";
25
25
  API_KEY["GET_SETTINGS_FIELDS_LIST"] = "GET_SETTINGS_FIELDS_LIST";
26
26
  })(API_KEY || (API_KEY = {}));
27
- export var FetchCustomFieldTypeBySchemeType;
27
+ var FetchCustomFieldTypeBySchemeType;
28
28
  (function (FetchCustomFieldTypeBySchemeType) {
29
29
  FetchCustomFieldTypeBySchemeType["table"] = "tableView";
30
30
  FetchCustomFieldTypeBySchemeType["criteriaList"] = "criteriaList";
31
31
  FetchCustomFieldTypeBySchemeType["default"] = "default";
32
32
  })(FetchCustomFieldTypeBySchemeType || (FetchCustomFieldTypeBySchemeType = {}));
33
+
34
+ export { API_KEY, FetchCustomFieldTypeBySchemeType };
@@ -1,7 +1,8 @@
1
1
  import useSWR from 'swr';
2
- import useItemConfig from '../hooks/useItemConfig';
3
- import { API_KEY } from './constants';
4
- export const useFetchItemById = ({ id, disable = false, detail, }) => {
2
+ import useItemConfig from '../hooks/useItemConfig.js';
3
+ import { API_KEY } from './constants.js';
4
+
5
+ const useFetchItemById = ({ id, disable = false, detail, }) => {
5
6
  const { fetchItemById } = useItemConfig();
6
7
  const res = useSWR(!disable && id && [API_KEY.GET_ITEM_BY_ID, id], async () => {
7
8
  let result;
@@ -12,3 +13,5 @@ export const useFetchItemById = ({ id, disable = false, detail, }) => {
12
13
  });
13
14
  return res;
14
15
  };
16
+
17
+ export { useFetchItemById };
@@ -0,0 +1,17 @@
1
+ export declare const DISABLE_THROTTLE_API_FETCH = "DISABLE_THROTTLE_API_FETCH";
2
+ declare const throttleWithCache: ({ type, params, fn, method, }: {
3
+ type: THROTTLE_TYPE;
4
+ params: unknown;
5
+ fn: () => Promise<any>;
6
+ method?: string;
7
+ }) => Promise<any>;
8
+ export declare enum THROTTLE_TYPE {
9
+ PLUGIN_RESOURCE_FETCH = "PLUGIN_RESOURCE_FETCH",
10
+ QUERY_FETCH = "QUERY_FETCH",
11
+ CUSTOM_FETCH = "CUSTOM_FETCH"
12
+ }
13
+ export declare const createKeyByParams: ({ type, params }: {
14
+ type: THROTTLE_TYPE;
15
+ params: any;
16
+ }) => string;
17
+ export default throttleWithCache;
@@ -0,0 +1,110 @@
1
+ import debug from 'debug';
2
+ import { getLocalStorageItem } from '../storage.js';
3
+
4
+ const DISABLE_THROTTLE_API_FETCH = 'DISABLE_THROTTLE_API_FETCH';
5
+ const log = debug('repeat-api');
6
+ const disableThrottle = !!getLocalStorageItem(DISABLE_THROTTLE_API_FETCH) || false;
7
+ let cacheKeys = [];
8
+ let results = [];
9
+ let resolves = [];
10
+ const THROTTLE_TIME = 3000;
11
+ let postPending = false;
12
+ let postPendingTime = 0;
13
+ const refreshCache = () => {
14
+ const dirtyIds = [];
15
+ cacheKeys.forEach(item => {
16
+ if (Date.now() - item.time > THROTTLE_TIME) {
17
+ dirtyIds.push(item.id);
18
+ }
19
+ });
20
+ cacheKeys = cacheKeys.filter(item => !dirtyIds.includes(item.id));
21
+ results = results.filter(item => !dirtyIds.includes(item.id));
22
+ resolves = resolves.filter(item => !dirtyIds.includes(item.id));
23
+ };
24
+ const refreshPostPending = () => {
25
+ if (postPending) {
26
+ const curTime = Date.now();
27
+ if (curTime - postPendingTime > THROTTLE_TIME) {
28
+ postPending = false;
29
+ }
30
+ }
31
+ };
32
+ const throttleWithCache = ({ type, params, fn, method, }) => {
33
+ if (disableThrottle) {
34
+ return fn();
35
+ }
36
+ const key = createKeyByParams({ type, params });
37
+ refreshCache();
38
+ refreshPostPending();
39
+ if (postPending) {
40
+ return fn();
41
+ }
42
+ const _method = String(method).toLowerCase();
43
+ if (_method !== 'get') {
44
+ postPending = true;
45
+ postPendingTime = +new Date();
46
+ return fn();
47
+ }
48
+ return new Promise((resolve, reject) => {
49
+ var _a;
50
+ const findItem = cacheKeys.find(item => item.key === key && +new Date() - item.time < THROTTLE_TIME);
51
+ if (findItem) {
52
+ try {
53
+ const getStackTrace = (limitFrames = 50) => {
54
+ const obj = { stack: '' };
55
+ const stackTraceLimit = Error.stackTraceLimit;
56
+ Error.stackTraceLimit = stackTraceLimit < limitFrames ? limitFrames : stackTraceLimit;
57
+ Error.captureStackTrace(obj, getStackTrace);
58
+ Error.stackTraceLimit = stackTraceLimit;
59
+ return obj.stack.split('\n');
60
+ };
61
+ const stackFrames = getStackTrace();
62
+ log('stackFrame', stackFrames, key);
63
+ }
64
+ catch (e) {
65
+ console.error(e);
66
+ }
67
+ const result = (_a = results.find(item => item.key === findItem.key)) === null || _a === void 0 ? void 0 : _a.data;
68
+ if (result) {
69
+ resolve(result);
70
+ }
71
+ else {
72
+ resolves.push({
73
+ key: findItem.key,
74
+ resolve,
75
+ id: findItem.id,
76
+ });
77
+ }
78
+ }
79
+ else {
80
+ const curTime = +new Date();
81
+ cacheKeys.push({ key, time: curTime, id: `${key}${curTime}` });
82
+ fn()
83
+ .then(res => {
84
+ results.push({ key, data: res, id: `${key}${curTime}` });
85
+ resolve(res);
86
+ resolves.forEach(item => {
87
+ if (item.key === key) {
88
+ item.resolve(res);
89
+ }
90
+ });
91
+ })
92
+ .catch(_error => {
93
+ reject(_error);
94
+ });
95
+ }
96
+ });
97
+ };
98
+ var THROTTLE_TYPE;
99
+ (function (THROTTLE_TYPE) {
100
+ THROTTLE_TYPE["PLUGIN_RESOURCE_FETCH"] = "PLUGIN_RESOURCE_FETCH";
101
+ THROTTLE_TYPE["QUERY_FETCH"] = "QUERY_FETCH";
102
+ THROTTLE_TYPE["CUSTOM_FETCH"] = "CUSTOM_FETCH";
103
+ })(THROTTLE_TYPE || (THROTTLE_TYPE = {}));
104
+ const createKeyByParams = ({ type, params }) => {
105
+ if (!params)
106
+ return `${+new Date()}`;
107
+ return `${type}_${JSON.stringify(params)}`;
108
+ };
109
+
110
+ export { DISABLE_THROTTLE_API_FETCH, THROTTLE_TYPE, createKeyByParams, throttleWithCache as default };
@@ -0,0 +1,2 @@
1
+ export declare const generateHash: (content: any) => string;
2
+ export declare function throttleFetch<Key = any, Data = any>(key: Key, fetcher: () => Promise<Data>): Promise<Data>;
@@ -0,0 +1,68 @@
1
+ class PubSub {
2
+ constructor() {
3
+ this.events = {};
4
+ }
5
+ subscribe(event, resolve, reject) {
6
+ if (!(event in this.events)) {
7
+ this.events[event] = [];
8
+ }
9
+ this.events[event].push([resolve, reject]);
10
+ }
11
+ publish(event, data, err) {
12
+ if (!(event in this.events)) {
13
+ return;
14
+ }
15
+ while (this.events[event].length) {
16
+ const [resolve, reject] = this.events[event].shift();
17
+ if (err) {
18
+ reject(err);
19
+ }
20
+ else {
21
+ resolve(data);
22
+ }
23
+ }
24
+ delete this.events[event];
25
+ }
26
+ }
27
+ const pubSub = new PubSub();
28
+ const generateHash = (content) => {
29
+ if (content && typeof content === 'object')
30
+ try {
31
+ content = JSON.stringify(content);
32
+ }
33
+ catch (e) {
34
+ content = content === null || content === void 0 ? void 0 : content.toString();
35
+ console.error('[Error] getStringHash JSON.stringify(content)', e);
36
+ }
37
+ if (!content)
38
+ return;
39
+ let hash = 0;
40
+ let chr;
41
+ if (content.length === 0)
42
+ return '';
43
+ for (let i = 0; i < content.length; i++) {
44
+ chr = content.charCodeAt(i);
45
+ hash = (hash << 5) - hash + chr;
46
+ hash |= 0;
47
+ }
48
+ return btoa('hash-' + hash);
49
+ };
50
+ async function throttleFetch(key, fetcher) {
51
+ return new Promise((resolve, reject) => {
52
+ const hashKey = generateHash(key);
53
+ const hasEvent = hashKey in pubSub.events;
54
+ pubSub.subscribe(hashKey, resolve, reject);
55
+ if (!hasEvent) {
56
+ pubSub.subscribe(hashKey, resolve, reject);
57
+ fetcher()
58
+ .then(data => {
59
+ pubSub.publish(hashKey, data);
60
+ })
61
+ .catch(err => {
62
+ pubSub.publish(hashKey, undefined, err);
63
+ });
64
+ }
65
+ });
66
+ }
67
+
68
+ export { generateHash, throttleFetch };
@@ -0,0 +1,8 @@
1
+ export declare const LOCALE_KEY = "lang";
2
+ export declare const PROXIMA_TENANT_KEY = "team_tenant";
3
+ export declare const SESSION_KEY = "sessionToken";
4
+ export declare const useAppProps: () => {
5
+ locale: string;
6
+ sessionToken: string;
7
+ appId: string;
8
+ };
@@ -0,0 +1,31 @@
1
+ import { useContext, useMemo } from 'react';
2
+ import Cookie from 'js-cookie';
3
+ import { TeamConfigContext } from './contexts/teamConfig.js';
4
+ import { getAcceptLanguageHeader } from './config.js';
5
+
6
+ const LOCALE_KEY = 'lang';
7
+ const PROXIMA_TENANT_KEY = 'team_tenant';
8
+ const SESSION_KEY = 'sessionToken';
9
+ const useAppProps = () => {
10
+ const { userConfig = {}, publicRuntimeConfig = {} } = useContext(TeamConfigContext);
11
+ const locale = useMemo(() => {
12
+ const userLocale = userConfig.locale;
13
+ const [defaultLang] = navigator.languages;
14
+ const locale = userLocale || Cookie.get(LOCALE_KEY) || defaultLang;
15
+ return getAcceptLanguageHeader(locale);
16
+ }, [userConfig.locale]);
17
+ const { sessionToken, appId } = useMemo(() => {
18
+ const { userTenant, sessionToken } = userConfig;
19
+ return {
20
+ appId: userTenant || Cookie.get(PROXIMA_TENANT_KEY) || publicRuntimeConfig.appId,
21
+ sessionToken: sessionToken || Cookie.get(SESSION_KEY),
22
+ };
23
+ }, [publicRuntimeConfig.appId, userConfig]);
24
+ return {
25
+ locale,
26
+ sessionToken,
27
+ appId,
28
+ };
29
+ };
30
+
31
+ export { LOCALE_KEY, PROXIMA_TENANT_KEY, SESSION_KEY, useAppProps };
@@ -1,8 +1,9 @@
1
- import { toBoolean } from './dataType';
2
- import { i18n } from './i18n';
3
- export const isUserDeleted = (user) => toBoolean(user === null || user === void 0 ? void 0 : user.deleted, false) === true;
4
- export const isUserDisabled = (user) => toBoolean(user === null || user === void 0 ? void 0 : user.enabled, true) === false;
5
- export const generateUserDisplayName = (user, onlyNickname = false) => {
1
+ import { toBoolean } from './dataType.js';
2
+ import { i18n } from './i18n.js';
3
+
4
+ const isUserDeleted = (user) => toBoolean(user === null || user === void 0 ? void 0 : user.deleted, false) === true;
5
+ const isUserDisabled = (user) => toBoolean(user === null || user === void 0 ? void 0 : user.enabled, true) === false;
6
+ const generateUserDisplayName = (user, onlyNickname = false) => {
6
7
  const getDisplaySuffix = () => {
7
8
  if (isUserDeleted(user)) {
8
9
  return i18n.t('pages.users.default.delete');
@@ -20,7 +21,7 @@ export const generateUserDisplayName = (user, onlyNickname = false) => {
20
21
  return `${(user === null || user === void 0 ? void 0 : user.nickname) || (user === null || user === void 0 ? void 0 : user.username)}${displaySuffix}`;
21
22
  return (user === null || user === void 0 ? void 0 : user.nickname) ? `${user === null || user === void 0 ? void 0 : user.nickname}${displaySuffix}` : user === null || user === void 0 ? void 0 : user.username;
22
23
  };
23
- export const userDataFormat = (user) => {
24
+ const userDataFormat = (user) => {
24
25
  var _a;
25
26
  return ({
26
27
  label: generateUserDisplayName(user),
@@ -31,3 +32,5 @@ export const userDataFormat = (user) => {
31
32
  enabled: user.enabled,
32
33
  });
33
34
  };
35
+
36
+ export { generateUserDisplayName, isUserDeleted, isUserDisabled, userDataFormat };
package/dist/lib/users.js CHANGED
@@ -1,8 +1,11 @@
1
- import { generateUserDisplayName } from './useUser';
2
- export const userOptionAdapter = (user) => {
1
+ import { generateUserDisplayName } from './useUser.js';
2
+
3
+ const userOptionAdapter = (user) => {
3
4
  return {
4
5
  label: generateUserDisplayName(user),
5
6
  value: user === null || user === void 0 ? void 0 : user.objectId,
6
7
  key: user === null || user === void 0 ? void 0 : user.username,
7
8
  };
8
9
  };
10
+
11
+ export { userOptionAdapter };