@giteeteam/apps-team-components 1.3.0-alpha.1 → 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 (219) hide show
  1. package/dist/components/common/EmptyField.d.ts +0 -1
  2. package/dist/components/common/EmptyField.js +7 -5
  3. package/dist/components/common/PriceTag.js +11 -8
  4. package/dist/components/common/expand-component/index.d.ts +0 -1
  5. package/dist/components/common/expand-component/index.js +12 -10
  6. package/dist/components/common/expand-component/style.js +4 -2
  7. package/dist/components/common/item-icon/ItemIcon.d.ts +0 -1
  8. package/dist/components/common/item-icon/ItemIcon.js +6 -4
  9. package/dist/components/common/overflow-tooltip/BaseOverflowTooltip.d.ts +0 -1
  10. package/dist/components/common/overflow-tooltip/BaseOverflowTooltip.js +9 -6
  11. package/dist/components/common/overflow-tooltip/OverflowTooltip.js +9 -6
  12. package/dist/components/common/overflow-tooltip/SimpleOverflowToolTip.js +8 -5
  13. package/dist/components/common/overflow-tooltip/style/index.js +5 -3
  14. package/dist/components/common/style/global.js +3 -1
  15. package/dist/components/common/style/mixin.js +6 -3
  16. package/dist/components/common/user-field/UserAvatar.js +8 -6
  17. package/dist/components/common/user-field/style/index.js +5 -3
  18. package/dist/components/common/utils.js +13 -9
  19. package/dist/components/default-empty-icon/config.js +11 -6
  20. package/dist/components/default-empty-icon/index.js +10 -9
  21. package/dist/components/default-empty-icon/style.js +15 -12
  22. package/dist/components/default-empty-icon/types.js +3 -1
  23. package/dist/components/field-behavior/fields/type.js +5 -2
  24. package/dist/components/fields/actors/BaseField.js +5 -2
  25. package/dist/components/fields/actors/ReadView.d.ts +0 -1
  26. package/dist/components/fields/actors/ReadView.js +8 -6
  27. package/dist/components/fields/ancestor/ReadView.js +8 -6
  28. package/dist/components/fields/ancestor/utils.js +4 -12
  29. package/dist/components/fields/assignee/ReadView.d.ts +0 -1
  30. package/dist/components/fields/assignee/ReadView.js +13 -11
  31. package/dist/components/fields/base-component/utils.js +3 -1
  32. package/dist/components/fields/bind-workspace/ReadView.d.ts +0 -1
  33. package/dist/components/fields/bind-workspace/ReadView.js +11 -9
  34. package/dist/components/fields/bind-workspace/hooks.js +7 -4
  35. package/dist/components/fields/bind-workspace/style/index.js +3 -1
  36. package/dist/components/fields/cascade/ReadView.js +8 -6
  37. package/dist/components/fields/cascade/utils.js +4 -3
  38. package/dist/components/fields/checkbox/ReadView.d.ts +0 -1
  39. package/dist/components/fields/checkbox/ReadView.js +7 -5
  40. package/dist/components/fields/created-at/ReadView.js +10 -8
  41. package/dist/components/fields/created-by/ReadView.d.ts +0 -1
  42. package/dist/components/fields/created-by/ReadView.js +11 -9
  43. package/dist/components/fields/data-quote/ReadView.js +12 -10
  44. package/dist/components/fields/data-quote/utils.js +5 -3
  45. package/dist/components/fields/date/ReadView.d.ts +0 -1
  46. package/dist/components/fields/date/ReadView.js +8 -6
  47. package/dist/components/fields/dropdown/BaseField.js +42 -40
  48. package/dist/components/fields/dropdown/Cell.d.ts +0 -1
  49. package/dist/components/fields/dropdown/Cell.js +6 -4
  50. package/dist/components/fields/dropdown/ReadView.d.ts +0 -1
  51. package/dist/components/fields/dropdown/ReadView.js +10 -8
  52. package/dist/components/fields/dropdown/data.d.ts +1 -1
  53. package/dist/components/fields/dropdown/data.js +6 -3
  54. package/dist/components/fields/dropdown/hook.d.ts +0 -1
  55. package/dist/components/fields/dropdown/hook.js +11 -8
  56. package/dist/components/fields/dropdown/style.js +21 -18
  57. package/dist/components/fields/file/ReadView.d.ts +0 -1
  58. package/dist/components/fields/file/ReadView.js +7 -5
  59. package/dist/components/fields/formula/ReadView.d.ts +0 -1
  60. package/dist/components/fields/formula/ReadView.js +7 -5
  61. package/dist/components/fields/hooks/useViewClass.js +4 -2
  62. package/dist/components/fields/hyper-link/ReadView.d.ts +0 -1
  63. package/dist/components/fields/hyper-link/ReadView.js +8 -6
  64. package/dist/components/fields/hyper-link/style/index.js +7 -4
  65. package/dist/components/fields/item-group/ReadView.d.ts +0 -1
  66. package/dist/components/fields/item-group/ReadView.js +6 -4
  67. package/dist/components/fields/item-type/ItemTypeIcon.js +15 -17
  68. package/dist/components/fields/item-type/ReadView.d.ts +0 -1
  69. package/dist/components/fields/item-type/ReadView.js +7 -5
  70. package/dist/components/fields/item-type/style/index.js +3 -1
  71. package/dist/components/fields/key/ReadView.d.ts +0 -1
  72. package/dist/components/fields/key/ReadView.js +7 -5
  73. package/dist/components/fields/long-text/ReadView.d.ts +0 -1
  74. package/dist/components/fields/long-text/ReadView.js +8 -6
  75. package/dist/components/fields/long-text/style/index.js +3 -1
  76. package/dist/components/fields/number/BaseField.js +5 -2
  77. package/dist/components/fields/number/ReadView.d.ts +0 -1
  78. package/dist/components/fields/number/ReadView.js +8 -6
  79. package/dist/components/fields/priority/ReadView.js +12 -10
  80. package/dist/components/fields/priority/style/index.js +11 -8
  81. package/dist/components/fields/radio/ReadView.d.ts +0 -1
  82. package/dist/components/fields/radio/ReadView.js +8 -6
  83. package/dist/components/fields/repo-files/ReadView.js +8 -6
  84. package/dist/components/fields/repo-files/utils.js +5 -3
  85. package/dist/components/fields/reporter/ReadView.d.ts +0 -1
  86. package/dist/components/fields/reporter/ReadView.js +11 -9
  87. package/dist/components/fields/script/BaseField.js +4 -1
  88. package/dist/components/fields/script/ReadView.d.ts +0 -1
  89. package/dist/components/fields/script/ReadView.js +10 -8
  90. package/dist/components/fields/sprint/ReadView.js +7 -5
  91. package/dist/components/fields/status/Cell.js +8 -6
  92. package/dist/components/fields/status/Field.d.ts +0 -1
  93. package/dist/components/fields/status/ReadView.js +10 -8
  94. package/dist/components/fields/status/SelectFlowHandler.js +15 -12
  95. package/dist/components/fields/status/SelectTransition.js +13 -10
  96. package/dist/components/fields/status/Transition.js +18 -15
  97. package/dist/components/fields/status/TransitionButton.js +17 -14
  98. package/dist/components/fields/status/TransitionPanel.js +14 -11
  99. package/dist/components/fields/status/View.js +11 -8
  100. package/dist/components/fields/status/style/index.js +36 -59
  101. package/dist/components/fields/story-point/ReadView.d.ts +0 -1
  102. package/dist/components/fields/story-point/ReadView.js +6 -4
  103. package/dist/components/fields/tag/ReadView.js +10 -8
  104. package/dist/components/fields/tag/style/index.js +3 -1
  105. package/dist/components/fields/team/ReadView.js +10 -8
  106. package/dist/components/fields/team/style/index.js +4 -2
  107. package/dist/components/fields/text/BaseField.d.ts +0 -1
  108. package/dist/components/fields/text/ReadView.js +8 -6
  109. package/dist/components/fields/tree/ReadView.js +10 -8
  110. package/dist/components/fields/tree/utils.js +5 -3
  111. package/dist/components/fields/updated-at/ReadView.js +10 -8
  112. package/dist/components/fields/updated-by/ReadView.d.ts +0 -1
  113. package/dist/components/fields/updated-by/ReadView.js +11 -9
  114. package/dist/components/fields/user/ReadView.d.ts +0 -1
  115. package/dist/components/fields/user/ReadView.js +11 -9
  116. package/dist/components/fields/user/style/index.js +7 -4
  117. package/dist/components/fields/user-group/BaseField.d.ts +0 -1
  118. package/dist/components/fields/user-group/ReadView.js +11 -13
  119. package/dist/components/fields/version/ReadView.js +8 -6
  120. package/dist/components/fields/workspace/ReadView.d.ts +0 -1
  121. package/dist/components/fields/workspace/ReadView.js +10 -8
  122. package/dist/components/filters/filter-search/utils.js +6 -6
  123. package/dist/components/item/hooks.js +5 -2
  124. package/dist/components/table-components/EditTableCell.js +6 -3
  125. package/dist/components/table-components/index.js +14 -11
  126. package/dist/components/table-components/style/index.js +3 -1
  127. package/dist/components/table-components/utils.js +49 -46
  128. package/dist/icons/SyncIconFont.js +7 -5
  129. package/dist/icons/createFromIconFontClass.js +3 -1
  130. package/dist/icons/empty-icon/index.d.ts +8 -1
  131. package/dist/icons/empty-icon/large-item@2x.png.js +3 -0
  132. package/dist/icons/empty-icon/large-workspace@2x.png.js +3 -0
  133. package/dist/icons/empty-icon/small-default@2x.png.js +3 -0
  134. package/dist/icons/index.d.ts +1 -1
  135. package/dist/icons/index.js +37 -35
  136. package/dist/icons/style/index.js +4 -2
  137. package/dist/icons/svg/ArrowBack.svg.js +3 -0
  138. package/dist/icons/svg/Done.svg.js +3 -0
  139. package/dist/icons/svg/DottedCircle.svg.js +3 -0
  140. package/dist/icons/svg/HollowCircle.svg.js +3 -0
  141. package/dist/icons/svg/Search.svg.js +3 -0
  142. package/dist/icons/svg/Workflow.svg.js +3 -0
  143. package/dist/index.js +47 -47
  144. package/dist/lib/app/utils.d.ts +0 -1
  145. package/dist/lib/app/utils.js +4 -2
  146. package/dist/lib/array.js +5 -44
  147. package/dist/lib/config.js +8 -6
  148. package/dist/lib/constants/code.js +3 -1
  149. package/dist/lib/constants/field.js +5 -2
  150. package/dist/lib/contexts/antdConfig.js +10 -7
  151. package/dist/lib/contexts/currentUser.js +7 -4
  152. package/dist/lib/contexts/currentWorkspace.js +7 -4
  153. package/dist/lib/contexts/datetimeFormat.js +7 -4
  154. package/dist/lib/contexts/index.js +16 -13
  155. package/dist/lib/contexts/itemConfig.js +7 -4
  156. package/dist/lib/contexts/teamConfig.js +8 -5
  157. package/dist/lib/contexts/tenant.js +7 -4
  158. package/dist/lib/contexts/workflowConfig.js +7 -4
  159. package/dist/lib/dataType.js +4 -5
  160. package/dist/lib/date.js +11 -52
  161. package/dist/lib/dayjs.js +2 -1
  162. package/dist/lib/error/log.js +7 -4
  163. package/dist/lib/error/utils.d.ts +1 -1
  164. package/dist/lib/error/utils.js +8 -20
  165. package/dist/lib/error/withServerError.js +3 -1
  166. package/dist/lib/fetch.js +23 -54
  167. package/dist/lib/global.js +16 -14
  168. package/dist/lib/hooks/useAntdConfig.js +4 -2
  169. package/dist/lib/hooks/useCurrentUser.js +4 -2
  170. package/dist/lib/hooks/useCurrentWorkspace.js +4 -2
  171. package/dist/lib/hooks/useDataQuoteStore.js +8 -5
  172. package/dist/lib/hooks/useDateTimeFormatType.js +4 -2
  173. package/dist/lib/hooks/useI18n.d.ts +1 -1
  174. package/dist/lib/hooks/useI18n.js +4 -2
  175. package/dist/lib/hooks/useItemConfig.js +4 -2
  176. package/dist/lib/hooks/useTeamConfig.js +4 -2
  177. package/dist/lib/hooks/useTenant.js +4 -2
  178. package/dist/lib/hooks/useWorkflowConfig.js +4 -2
  179. package/dist/lib/i18n.js +6 -3
  180. package/dist/lib/icons/utils.js +10 -9
  181. package/dist/lib/isInOne.js +2 -1
  182. package/dist/lib/number.js +3 -1
  183. package/dist/lib/path.d.ts +2 -2
  184. package/dist/lib/path.js +9 -6
  185. package/dist/lib/regExp.js +3 -1
  186. package/dist/lib/router.js +4 -1
  187. package/dist/lib/storage.js +4 -39
  188. package/dist/lib/store/dataQuoteStore.js +5 -2
  189. package/dist/lib/swr/constants.js +4 -2
  190. package/dist/lib/swr/hooks.js +6 -3
  191. package/dist/lib/swr/throttleWithCache.js +7 -5
  192. package/dist/lib/throttleFetch.js +4 -2
  193. package/dist/lib/useConfig.js +9 -6
  194. package/dist/lib/useUser.js +9 -6
  195. package/dist/lib/users.js +5 -2
  196. package/dist/lib/workflow.js +21 -20
  197. package/dist/locales/index.js +5 -3
  198. package/dist/style/common.js +11 -24
  199. package/dist/style/global.js +3 -1
  200. package/package.json +8 -2
  201. package/dist/components/fields/base-component/types.js +0 -1
  202. package/dist/components/fields/hooks/useParamsAdapter.js +0 -1
  203. package/dist/components/fields/radio/BaseField.js +0 -1
  204. package/dist/components/fields/status/Field.js +0 -1
  205. package/dist/components/fields/tag/BaseField.js +0 -1
  206. package/dist/components/fields/text/BaseField.js +0 -1
  207. package/dist/components/fields/tree/BaseField.js +0 -1
  208. package/dist/components/fields/tree/types.js +0 -1
  209. package/dist/components/fields/types.js +0 -1
  210. package/dist/components/fields/user-group/ActionCell.js +0 -1
  211. package/dist/components/fields/user-group/BaseField.js +0 -1
  212. package/dist/icons/empty-icon/index.js +0 -8
  213. package/dist/icons/svg/ArrowBack.svg +0 -1
  214. package/dist/icons/svg/Done.svg +0 -1
  215. package/dist/icons/svg/DottedCircle.svg +0 -7
  216. package/dist/icons/svg/HollowCircle.svg +0 -6
  217. package/dist/icons/svg/Search.svg +0 -1
  218. package/dist/icons/svg/Workflow.svg +0 -12
  219. package/dist/lib/error/index.js +0 -2
@@ -1,9 +1,6 @@
1
1
  import { isNil } from 'lodash-es';
2
- export const toNumber = (num, defaultNum = 0) => {
3
- const number = Number(num);
4
- return isNaN(number) ? defaultNum : number;
5
- };
6
- export const toBoolean = (flag, defaultFlag = true) => {
2
+
3
+ const toBoolean = (flag, defaultFlag = true) => {
7
4
  if (isNil(flag))
8
5
  return defaultFlag;
9
6
  if (flag === 'true')
@@ -14,3 +11,5 @@ export const toBoolean = (flag, defaultFlag = true) => {
14
11
  return flag;
15
12
  return defaultFlag;
16
13
  };
14
+
15
+ export { toBoolean };
package/dist/lib/date.js CHANGED
@@ -1,8 +1,10 @@
1
- import { isNaN, isNumber } from 'lodash-es';
2
- import dayjs from './dayjs';
3
- import { DATE_FORMAT, DATE_TYPE, FIELD_TYPE_KEY_MAPPINGS } from './global';
4
- import { i18n } from './i18n';
5
- export const getDateType = (pickerType) => {
1
+ import 'lodash-es';
2
+ import './dayjs.js';
3
+ import { DATE_FORMAT, DATE_TYPE } from './global.js';
4
+ import { i18n } from './i18n.js';
5
+ import dayjs from 'dayjs';
6
+
7
+ const getDateType = (pickerType) => {
6
8
  switch (pickerType) {
7
9
  case DATE_TYPE.DATETIME:
8
10
  return DATE_FORMAT.DATETIME;
@@ -17,35 +19,10 @@ export const getDateType = (pickerType) => {
17
19
  return DATE_FORMAT.DATE;
18
20
  }
19
21
  };
20
- export const getDateTypeName = (dateType) => i18n.t(`date.${dateType}`);
21
- export const getStartOfDayUnix = (date) => {
22
- return dayjs(date).startOf('day').valueOf();
23
- };
24
- export const getStartOfDayToDate = (date) => {
25
- return dayjs(date).startOf('day').toDate();
26
- };
27
- export const getEndOfDayUnix = (date) => {
28
- return dayjs(date).endOf('day').valueOf();
29
- };
30
- export const getEndOfDayToDate = (date) => {
31
- return dayjs(date).endOf('day').toDate();
32
- };
33
- export const getStartOfWeekUnix = (date) => {
34
- return dayjs(date).startOf('week').valueOf();
35
- };
36
- export const getEndOfWeekUnix = (date) => {
37
- return dayjs(date).endOf('week').valueOf();
38
- };
39
- export const getStartOfMonthUnix = (date) => {
40
- return dayjs(date).startOf('month').valueOf();
41
- };
42
- export const getEndOfMonthUnix = (date) => {
43
- return dayjs(date).endOf('month').valueOf();
44
- };
45
- export const getFormat = (date, format) => {
22
+ const getFormat = (date, format) => {
46
23
  return dayjs(date).format(format);
47
24
  };
48
- export var DateTypeEnum;
25
+ var DateTypeEnum;
49
26
  (function (DateTypeEnum) {
50
27
  DateTypeEnum["dateTime"] = "second";
51
28
  DateTypeEnum["date"] = "date";
@@ -53,23 +30,5 @@ export var DateTypeEnum;
53
30
  DateTypeEnum["month"] = "month";
54
31
  DateTypeEnum["year"] = "year";
55
32
  })(DateTypeEnum || (DateTypeEnum = {}));
56
- export const isDate = (key) => {
57
- return [FIELD_TYPE_KEY_MAPPINGS.CreatedAt, FIELD_TYPE_KEY_MAPPINGS.UpdatedAt, FIELD_TYPE_KEY_MAPPINGS.Date].includes(key);
58
- };
59
- export const dateToMillisecond = (date, days) => {
60
- return getStartOfDayUnix(date.subtract(days, 'day'));
61
- };
62
- export const countDuration = (stoppedAt, startedAt) => {
63
- const duration = dayjs(stoppedAt).diff(startedAt, 'ms');
64
- return isNumber(duration) ? duration / 1000 : 0;
65
- };
66
- export const getMonthEndDate = (time, format = '-') => {
67
- var _a;
68
- const [year, month, date] = time.split(format);
69
- const endMonthDate = (_a = new Date(+year, +month, 0)) === null || _a === void 0 ? void 0 : _a.getDate();
70
- if (isNaN(endMonthDate)) {
71
- throw new TypeError(i18n.t('date.invalidate'));
72
- }
73
- const isEqualMonth = +date <= endMonthDate;
74
- return [endMonthDate, isEqualMonth];
75
- };
33
+
34
+ export { DateTypeEnum, getDateType, getFormat };
package/dist/lib/dayjs.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import dayjs from 'dayjs';
2
+ export { default } from 'dayjs';
2
3
  import relativeTime from 'dayjs/plugin/relativeTime';
4
+
3
5
  dayjs.extend(relativeTime);
4
- export default dayjs;
@@ -1,10 +1,11 @@
1
1
  import { message } from 'antd';
2
2
  import debug from 'debug';
3
3
  import { throttle } from 'lodash-es';
4
- import { isChinese } from 'components/common/utils';
5
- import { i18n, nsSeparator } from 'lib/i18n';
4
+ import { isChinese } from '../../components/common/utils.js';
5
+ import { nsSeparator, i18n } from '../i18n.js';
6
+
6
7
  const logger = debug('lib:error');
7
- export class ErrorLog {
8
+ class ErrorLog {
8
9
  constructor(options) {
9
10
  this.show = (msg) => {
10
11
  logger('errorMessage', msg);
@@ -22,4 +23,6 @@ export class ErrorLog {
22
23
  }, timeout, { trailing: false });
23
24
  }
24
25
  }
25
- export default new ErrorLog();
26
+ var ErrorLog$1 = new ErrorLog();
27
+
28
+ export { ErrorLog, ErrorLog$1 as default };
@@ -5,7 +5,7 @@ export type ErrorResponse = any;
5
5
  type GetErrorMessageHandler = (errorData: ErrorData, defaultMessage?: string) => string;
6
6
  export declare const getRedirectURI: (errorPageURL: string | URL, baseAPI?: string) => string;
7
7
  export declare const getRedirectURL: (redirectConfig: {
8
- enabled: 'true' | 'false' | undefined;
8
+ enabled: "true" | "false" | undefined;
9
9
  }, errorPageURL: string | URL) => string;
10
10
  export declare const getKeycloakErrorMsg: GetErrorMessageHandler;
11
11
  export declare const getParseErrorMsg: GetErrorMessageHandler;
@@ -1,25 +1,11 @@
1
- import { isEmpty } from 'lodash-es';
2
- export const LOGIN_PAGE_URL = '/login';
3
- export const REDIRECT_API = '/frame';
4
- export const getRedirectURI = (errorPageURL, baseAPI = LOGIN_PAGE_URL) => {
5
- const redirectApi = new URL(baseAPI, errorPageURL);
6
- redirectApi.searchParams.append('redirect_uri', errorPageURL);
7
- return encodeURIComponent(redirectApi.toString());
8
- };
9
- export const getRedirectURL = (redirectConfig, errorPageURL) => {
10
- if (isEmpty(redirectConfig))
11
- return LOGIN_PAGE_URL;
12
- if ((redirectConfig === null || redirectConfig === void 0 ? void 0 : redirectConfig.enabled) !== 'true')
13
- return LOGIN_PAGE_URL;
14
- const redirectUri = getRedirectURI(errorPageURL);
15
- return redirectUri;
16
- };
17
- export const getKeycloakErrorMsg = errorData => {
1
+ import 'lodash-es';
2
+
3
+ const getKeycloakErrorMsg = errorData => {
18
4
  if (!(errorData === null || errorData === void 0 ? void 0 : errorData.error_description) || !(errorData === null || errorData === void 0 ? void 0 : errorData.error))
19
5
  return null;
20
6
  return `${errorData.error}: ${errorData.error_description}`;
21
7
  };
22
- export const getParseErrorMsg = errorData => {
8
+ const getParseErrorMsg = errorData => {
23
9
  if (!(errorData === null || errorData === void 0 ? void 0 : errorData.code) || !(errorData === null || errorData === void 0 ? void 0 : errorData.error))
24
10
  return null;
25
11
  if ('string' === typeof errorData.error) {
@@ -38,8 +24,8 @@ export const getParseErrorMsg = errorData => {
38
24
  return null;
39
25
  }
40
26
  };
41
- export const getNormalErrorMsg = errorData => 'string' === typeof errorData ? errorData : null;
42
- export const getErrorMessage = (errorData, defaultMsg = '请求失败.') => {
27
+ const getNormalErrorMsg = errorData => 'string' === typeof errorData ? errorData : null;
28
+ const getErrorMessage = (errorData, defaultMsg = '请求失败.') => {
43
29
  const errorMessage = getNormalErrorMsg(errorData) ||
44
30
  (errorData === null || errorData === void 0 ? void 0 : errorData.message) ||
45
31
  (errorData === null || errorData === void 0 ? void 0 : errorData.error) ||
@@ -48,3 +34,5 @@ export const getErrorMessage = (errorData, defaultMsg = '请求失败.') => {
48
34
  defaultMsg;
49
35
  return errorMessage;
50
36
  };
37
+
38
+ export { getErrorMessage, getKeycloakErrorMsg, getNormalErrorMsg, getParseErrorMsg };
@@ -1 +1,3 @@
1
- export const IGNORE_URL = ['/', '/login', '/register', '/resetPassword', '/configuration-guide', '/reset-config'];
1
+ const IGNORE_URL = ['/', '/login', '/register', '/resetPassword', '/configuration-guide', '/reset-config'];
2
+
3
+ export { IGNORE_URL };
package/dist/lib/fetch.js CHANGED
@@ -1,44 +1,36 @@
1
- import { useCallback, useContext, useEffect, useMemo } from 'react';
1
+ import { useMemo, useCallback, useContext, useEffect } from 'react';
2
2
  import axios, { HttpStatusCode } from 'axios';
3
3
  import cjson from 'compressed-json';
4
4
  import debug from 'debug';
5
5
  import { toNumber } from 'lodash-es';
6
- import { CANCEL_FETCH_STRING, REDIRECT_URL_KEY } from 'lib/global';
7
- import throttleWithCache, { THROTTLE_TYPE } from 'lib/swr/throttleWithCache';
8
- import { ParseErrorCode } from './constants/code';
9
- import { TeamConfigContext } from './contexts/teamConfig';
10
- import { IGNORE_URL } from './error/withServerError';
11
- import { getErrorMessage, log as ErrorLog } from './error';
12
- import { i18n } from './i18n';
13
- import isInOne from './isInOne';
14
- import { useGetSourcePath } from './path';
15
- import { getCurLocationInfo } from './router';
16
- import { removeParseItems } from './storage';
17
- import { useAppProps } from './useConfig';
6
+ import { CANCEL_FETCH_STRING, REDIRECT_URL_KEY } from './global.js';
7
+ import throttleWithCache, { THROTTLE_TYPE } from './swr/throttleWithCache.js';
8
+ import { ParseErrorCode } from './constants/code.js';
9
+ import { TeamConfigContext } from './contexts/teamConfig.js';
10
+ import { IGNORE_URL } from './error/withServerError.js';
11
+ import ErrorLog from './error/log.js';
12
+ import { getErrorMessage } from './error/utils.js';
13
+ import { i18n } from './i18n.js';
14
+ import isInOne from './isInOne.js';
15
+ import { useGetSourcePath } from './path.js';
16
+ import { getCurLocationInfo } from './router.js';
17
+ import { removeParseItems } from './storage.js';
18
+ import { useAppProps } from './useConfig.js';
19
+
18
20
  const Blob = window.Blob;
19
- const isDev = process.env.NODE_ENV === 'development';
21
+ process.env.NODE_ENV === 'development';
20
22
  const DEFAULT_TIMEOUT = 15 * 1000;
21
- export const useGetConfigTimeout = () => {
23
+ const useGetConfigTimeout = () => {
22
24
  const { publicRuntimeConfig = {} } = useContext(TeamConfigContext);
23
25
  const { globalFetchTimeout } = publicRuntimeConfig;
24
26
  return toNumber(globalFetchTimeout) || DEFAULT_TIMEOUT;
25
27
  };
26
- export const baseApi = '/parse/api';
27
- export const useGetLoginBasePath = () => {
28
- const { publicRuntimeConfig = {} } = useContext(TeamConfigContext);
29
- const basePath = useMemo(() => {
30
- const { basePath = '' } = publicRuntimeConfig;
31
- if (isDev)
32
- return basePath;
33
- return '';
34
- }, [publicRuntimeConfig]);
35
- return basePath;
36
- };
37
- export const useGetServerGateway = () => {
28
+ const baseApi = '/parse/api';
29
+ const useGetServerGateway = () => {
38
30
  const { publicRuntimeConfig } = useContext(TeamConfigContext);
39
31
  return (publicRuntimeConfig === null || publicRuntimeConfig === void 0 ? void 0 : publicRuntimeConfig.gateway) || '';
40
32
  };
41
- export const useGetGateway = (extraPath = '') => {
33
+ const useGetGateway = (extraPath = '') => {
42
34
  const gateway = useGetServerGateway();
43
35
  const result = useMemo(() => {
44
36
  const inOne = isInOne(gateway);
@@ -50,23 +42,7 @@ export const useGetGateway = (extraPath = '') => {
50
42
  }, [extraPath, gateway]);
51
43
  return result;
52
44
  };
53
- export function useGetRequestConfig({ sessionToken, tenant, Cookie }) {
54
- const gateway = useGetServerGateway();
55
- const baseURL = useMemo(() => {
56
- return `${gateway}${baseApi}`;
57
- }, [gateway]);
58
- return {
59
- baseURL,
60
- headers: {
61
- 'X-Parse-Session-Token': sessionToken,
62
- 'X-Parse-Application-Id': tenant,
63
- ...(Cookie && {
64
- Cookie,
65
- }),
66
- },
67
- };
68
- }
69
- export const useAxiosConfig = () => {
45
+ const useAxiosConfig = () => {
70
46
  const gateway = useGetGateway();
71
47
  const baseURL = useMemo(() => {
72
48
  return `${gateway}${baseApi}`;
@@ -80,14 +56,6 @@ export const useAxiosConfig = () => {
80
56
  const errorLog = msg => {
81
57
  return ErrorLog.show(msg);
82
58
  };
83
- export const LOCALE_KEY = 'lang';
84
- export const useGetHeaderLang = () => {
85
- const { locale } = useAppProps();
86
- return locale;
87
- };
88
- export const getGlobalEnv = () => {
89
- return window.env || {};
90
- };
91
59
  const checkLog = debug('lib:fetch:checkSessionToken');
92
60
  const NO_SESSION_KEY = 'sessionToken is required';
93
61
  const CHECK_WHITE_LIST = [
@@ -298,4 +266,5 @@ const useFetch = () => {
298
266
  useAddResponseInterceptors(fetch);
299
267
  return fetch;
300
268
  };
301
- export default useFetch;
269
+
270
+ export { baseApi, useFetch as default, useAxiosConfig, useGetConfigTimeout, useGetGateway, useGetServerGateway };
@@ -1,4 +1,4 @@
1
- export const FIELD_TYPE_KEY_MAPPINGS = {
1
+ const FIELD_TYPE_KEY_MAPPINGS = {
2
2
  Text: 'Text',
3
3
  User: 'User',
4
4
  LongText: 'LongText',
@@ -58,34 +58,34 @@ export const FIELD_TYPE_KEY_MAPPINGS = {
58
58
  Cascade: 'Cascade',
59
59
  RepoFiles: 'RepoFiles',
60
60
  };
61
- export const DATE_TYPE = {
61
+ const DATE_TYPE = {
62
62
  DATETIME: 'dateTime',
63
63
  DATE: 'date',
64
64
  WEEK: 'week',
65
65
  MONTH: 'month',
66
66
  YEAR: 'year',
67
67
  };
68
- export const DATE_FORMAT = {
68
+ const DATE_FORMAT = {
69
69
  DATETIME: 'YYYY-MM-DD HH:mm:ss',
70
70
  DATE: 'YYYY-MM-DD',
71
71
  WEEK: 'YYYY 第W周',
72
72
  MONTH: 'YYYY-MM',
73
73
  YEAR: 'YYYY',
74
74
  };
75
- export const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm';
76
- export const DATE_TIME_FORMAT_SEC = 'YYYY-MM-DD HH:mm:ss';
77
- export var WorkflowStatusType;
75
+ const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm';
76
+ const DATE_TIME_FORMAT_SEC = 'YYYY-MM-DD HH:mm:ss';
77
+ var WorkflowStatusType;
78
78
  (function (WorkflowStatusType) {
79
79
  WorkflowStatusType["Start"] = "Start";
80
80
  WorkflowStatusType["InProgress"] = "InProgress";
81
81
  WorkflowStatusType["Finished"] = "Finished";
82
82
  })(WorkflowStatusType || (WorkflowStatusType = {}));
83
- export const WorkFlowStatusColor = {
83
+ const WorkFlowStatusColor = {
84
84
  [WorkflowStatusType.Start]: { color: '#0C62FF', bgColor: '#E6F3FF' },
85
85
  [WorkflowStatusType.InProgress]: { color: '#FFAA0C', bgColor: '#FEF5D0' },
86
86
  [WorkflowStatusType.Finished]: { color: '#09B866', bgColor: '#DFF7E8' },
87
87
  };
88
- export const CustomFieldComponentTypes = {
88
+ const CustomFieldComponentTypes = {
89
89
  Date: 'Date',
90
90
  Dropdown: 'Dropdown',
91
91
  User: 'User',
@@ -98,9 +98,9 @@ export const CustomFieldComponentTypes = {
98
98
  Radio: 'Radio',
99
99
  Checkbox: 'Checkbox',
100
100
  };
101
- export const BASE_FIELD_WIDTH = 104;
102
- export const CURRENT_WORKSPACE = 'currentWorkspace()';
103
- export const FIELD_CONTAINERS_PAGE = {
101
+ const BASE_FIELD_WIDTH = 104;
102
+ const CURRENT_WORKSPACE = 'currentWorkspace()';
103
+ const FIELD_CONTAINERS_PAGE = {
104
104
  DETAIL: 'detail',
105
105
  MODAL: 'modal',
106
106
  DRAWER: 'drawer',
@@ -109,10 +109,12 @@ export const FIELD_CONTAINERS_PAGE = {
109
109
  AUTOMATION_FIELD: 'automation_field',
110
110
  VIEW_MODAL: 'view_modal',
111
111
  };
112
- export const SCREEN_TYPE = {
112
+ const SCREEN_TYPE = {
113
113
  View: 'view',
114
114
  Create: 'create',
115
115
  Edit: 'edit',
116
116
  };
117
- export const CANCEL_FETCH_STRING = 'cancel_fetch_string';
118
- export const REDIRECT_URL_KEY = 'team_redirect_url';
117
+ const CANCEL_FETCH_STRING = 'cancel_fetch_string';
118
+ const REDIRECT_URL_KEY = 'team_redirect_url';
119
+
120
+ export { BASE_FIELD_WIDTH, CANCEL_FETCH_STRING, CURRENT_WORKSPACE, CustomFieldComponentTypes, DATE_FORMAT, DATE_TIME_FORMAT, DATE_TIME_FORMAT_SEC, DATE_TYPE, FIELD_CONTAINERS_PAGE, FIELD_TYPE_KEY_MAPPINGS, REDIRECT_URL_KEY, SCREEN_TYPE, WorkFlowStatusColor, WorkflowStatusType };
@@ -1,7 +1,9 @@
1
1
  import { useContext } from 'react';
2
- import { AntdConfigContext } from '../../lib/contexts/antdConfig';
2
+ import { AntdConfigContext } from '../contexts/antdConfig.js';
3
+
3
4
  const useAntdConfig = () => {
4
5
  const antdConfig = useContext(AntdConfigContext);
5
6
  return antdConfig;
6
7
  };
7
- export default useAntdConfig;
8
+
9
+ export { useAntdConfig as default };
@@ -1,7 +1,9 @@
1
1
  import { useContext } from 'react';
2
- import { CurrentUserContext } from '../../lib/contexts/currentUser';
2
+ import { CurrentUserContext } from '../contexts/currentUser.js';
3
+
3
4
  const useCurrentUser = () => {
4
5
  const { currentUser } = useContext(CurrentUserContext);
5
6
  return currentUser;
6
7
  };
7
- export default useCurrentUser;
8
+
9
+ export { useCurrentUser as default };
@@ -1,7 +1,9 @@
1
1
  import { useContext } from 'react';
2
- import { CurrentWorkspaceContext } from '../../lib/contexts/currentWorkspace';
2
+ import { CurrentWorkspaceContext } from '../contexts/currentWorkspace.js';
3
+
3
4
  const useCurrentWorkspace = () => {
4
5
  const currentWorkspace = useContext(CurrentWorkspaceContext);
5
6
  return currentWorkspace;
6
7
  };
7
- export default useCurrentWorkspace;
8
+
9
+ export { useCurrentWorkspace as default };
@@ -1,10 +1,11 @@
1
- import { useEffect, useMemo } from 'react';
2
- import { clone, isEmpty } from 'lodash-es';
1
+ import { useMemo, useEffect } from 'react';
2
+ import { isEmpty, clone } from 'lodash-es';
3
3
  import { useRecoilState } from 'recoil';
4
- import { REG_EN_NUMBER } from '../regExp';
5
- import { currentDeleteState, dataQuoteState } from '../store/dataQuoteStore';
4
+ import { REG_EN_NUMBER } from '../regExp.js';
5
+ import { dataQuoteState, currentDeleteState } from '../store/dataQuoteStore.js';
6
+
6
7
  const OBJECT_ID_LENGTH = 10;
7
- export const useDataQuoteStore = (dataSources, getOptionsByValues) => {
8
+ const useDataQuoteStore = (dataSources, getOptionsByValues) => {
8
9
  const [dataQuoteList, setDataQuoteList] = useRecoilState(dataQuoteState);
9
10
  const [currentDeleteItem, setCurrentDeleteItem] = useRecoilState(currentDeleteState);
10
11
  const dataSourcesDep = useMemo(() => {
@@ -64,3 +65,5 @@ export const useDataQuoteStore = (dataSources, getOptionsByValues) => {
64
65
  setCurrentDeleteItem('');
65
66
  }, [currentDeleteItem, setDataQuoteList, dataQuoteList, dataSourcesDep, setCurrentDeleteItem]);
66
67
  };
68
+
69
+ export { useDataQuoteStore };
@@ -1,7 +1,9 @@
1
1
  import { useContext, useMemo } from 'react';
2
- import { DatetimeFormatContext } from '../../lib/contexts/datetimeFormat';
2
+ import { DatetimeFormatContext } from '../contexts/datetimeFormat.js';
3
+
3
4
  const useDateTimeFormatType = () => {
4
5
  const { datetimeFormat } = useContext(DatetimeFormatContext);
5
6
  return useMemo(() => datetimeFormat, [datetimeFormat]);
6
7
  };
7
- export default useDateTimeFormatType;
8
+
9
+ export { useDateTimeFormatType as default };
@@ -1,3 +1,3 @@
1
1
  import { i18n } from '../i18n';
2
- declare const useI18n: () => Pick<typeof i18n, 't'>;
2
+ declare const useI18n: () => Pick<typeof i18n, "t">;
3
3
  export default useI18n;
@@ -1,7 +1,9 @@
1
- import { i18n } from '../i18n';
1
+ import { i18n } from '../i18n.js';
2
+
2
3
  const useI18n = () => {
3
4
  return {
4
5
  t: i18n.t,
5
6
  };
6
7
  };
7
- export default useI18n;
8
+
9
+ export { useI18n as default };
@@ -1,7 +1,9 @@
1
1
  import { useContext } from 'react';
2
- import { ItemConfigContext } from '../../lib/contexts/itemConfig';
2
+ import { ItemConfigContext } from '../contexts/itemConfig.js';
3
+
3
4
  const useItemConfig = () => {
4
5
  const { item } = useContext(ItemConfigContext);
5
6
  return item;
6
7
  };
7
- export default useItemConfig;
8
+
9
+ export { useItemConfig as default };
@@ -1,7 +1,9 @@
1
1
  import { useContext } from 'react';
2
- import { TeamConfigContext } from '../../lib/contexts/teamConfig';
2
+ import { TeamConfigContext } from '../contexts/teamConfig.js';
3
+
3
4
  const useTeamConfig = () => {
4
5
  const teamConfig = useContext(TeamConfigContext);
5
6
  return teamConfig;
6
7
  };
7
- export default useTeamConfig;
8
+
9
+ export { useTeamConfig as default };
@@ -1,7 +1,9 @@
1
1
  import { useContext } from 'react';
2
- import { TenantContext } from '../../lib/contexts/tenant';
2
+ import { TenantContext } from '../contexts/tenant.js';
3
+
3
4
  const useTenant = () => {
4
5
  const { tenant } = useContext(TenantContext);
5
6
  return tenant;
6
7
  };
7
- export default useTenant;
8
+
9
+ export { useTenant as default };
@@ -1,7 +1,9 @@
1
1
  import { useContext } from 'react';
2
- import { WorkflowConfigContext } from '../../lib/contexts/workflowConfig';
2
+ import { WorkflowConfigContext } from '../contexts/workflowConfig.js';
3
+
3
4
  const useWorkflowConfig = () => {
4
5
  const { workflow } = useContext(WorkflowConfigContext);
5
6
  return workflow;
6
7
  };
7
- export default useWorkflowConfig;
8
+
9
+ export { useWorkflowConfig as default };
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,4 +33,6 @@ export const i18n = {
32
33
  locale = _locale;
33
34
  },
34
35
  };
35
- export const nsSeparator = '@';
36
+ const nsSeparator = '@';
37
+
38
+ export { i18n, nsSeparator };
@@ -1,6 +1,7 @@
1
1
  import { useMemo } from 'react';
2
- import { useGetBasePath } from 'lib/path';
3
- export const polyfillItemTypeIconMap = {
2
+ import { useGetBasePath } from '../path.js';
3
+
4
+ const polyfillItemTypeIconMap = {
4
5
  BookMark: 'Issue_Story',
5
6
  Book: 'Issue_Demand',
6
7
  Flask: 'Issue_Test',
@@ -17,20 +18,20 @@ export const polyfillItemTypeIconMap = {
17
18
  Risk: 'Issue_Risk',
18
19
  ManHour: 'Issue_Time',
19
20
  };
20
- export const takeIconFromUrl = (url) => {
21
+ const takeIconFromUrl = (url) => {
21
22
  const arr = url.split('/');
22
23
  const last = arr[arr.length - 1];
23
24
  const [icon] = last.split('.');
24
25
  return icon;
25
26
  };
26
- export const useIsIconFont = (url) => {
27
+ const useIsIconFont = (url) => {
27
28
  const basePath = useGetBasePath();
28
29
  return !(url.startsWith('/icons') || url.endsWith('.svg') || url.startsWith(basePath) || url.startsWith('/project'));
29
30
  };
30
- export const isServerUrl = (url) => {
31
+ const isServerUrl = (url) => {
31
32
  return url.startsWith('http') || url.startsWith('/parse/files');
32
33
  };
33
- export const usePolyFillIcon = (url, defaultIconFontType) => {
34
+ const usePolyFillIcon = (url, defaultIconFontType) => {
34
35
  const isIconFont = useIsIconFont(url);
35
36
  const data = useMemo(() => {
36
37
  if (!url) {
@@ -52,8 +53,8 @@ export const usePolyFillIcon = (url, defaultIconFontType) => {
52
53
  }, [defaultIconFontType, isIconFont, url]);
53
54
  return data;
54
55
  };
55
- const SUFFIX = 'B';
56
- export const joinIconColorSuffix = (icon, colored) => (colored ? `${icon}${SUFFIX}` : icon);
57
- export const isBase64Img = (str) => {
56
+ const isBase64Img = (str) => {
58
57
  return /^data:image\/(png|jpeg|jpg|gif|svg\+xml);base64,/.test(str);
59
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 };
@@ -1,5 +1,5 @@
1
1
  export declare const iconBasePath = "/icons";
2
2
  export declare const startsWithIconPath: any;
3
3
  export declare const useGetBasePath: () => string;
4
- export declare const useGetSourcePath: () => (path: string) => string;
5
- export declare const usePatchIconUrl: () => (path: string) => string;
4
+ export declare const useGetSourcePath: () => ((path: string) => string);
5
+ export declare const usePatchIconUrl: () => ((path: string) => string);