@zgfe/business-lib 1.0.0-beta.6 → 1.0.3

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 (283) hide show
  1. package/es/analysisLayout/demo/index.js +4 -1
  2. package/es/analysisLayout/index.d.ts +1 -28
  3. package/es/analysisLayout/index.js +38 -48
  4. package/es/analysisLayout/index.less +1 -1
  5. package/es/assets/styles/chunks.less +143 -0
  6. package/es/assets/styles/inner.less +3 -0
  7. package/es/assets/styles/resetAntd.less +398 -0
  8. package/es/assets/styles/variable.less +21 -0
  9. package/es/assets/theme.d.ts +5 -0
  10. package/es/assets/theme.js +4 -0
  11. package/es/attrConditions/components/operateList.d.ts +8 -0
  12. package/es/attrConditions/components/operateList.js +83 -0
  13. package/es/attrConditions/components/stringList.d.ts +9 -0
  14. package/es/attrConditions/components/stringList.js +168 -0
  15. package/es/attrConditions/components/valuesList.d.ts +10 -0
  16. package/es/attrConditions/components/valuesList.js +188 -0
  17. package/es/{attributeSelector/demo/multi.d.ts → attrConditions/demo/group.d.ts} +0 -0
  18. package/es/attrConditions/demo/group.js +82 -0
  19. package/es/{globalAttributes → attrConditions}/demo/index.d.ts +0 -0
  20. package/es/{datePicker/demo/form.js → attrConditions/demo/index.js} +43 -23
  21. package/es/attrConditions/group.d.ts +5 -0
  22. package/es/attrConditions/group.js +183 -0
  23. package/es/attrConditions/index.d.ts +6 -0
  24. package/es/attrConditions/index.js +160 -0
  25. package/es/attrConditions/styles/group.less +49 -0
  26. package/es/attrConditions/styles/index.less +94 -0
  27. package/es/attrConditions/types.d.ts +63 -0
  28. package/es/attrConditions/types.js +19 -0
  29. package/es/attrConditions/utils/operates.d.ts +16 -0
  30. package/es/attrConditions/utils/operates.js +67 -0
  31. package/es/attributeSelector/demo/index.d.ts +3 -0
  32. package/es/attributeSelector/demo/{singleForm.js → index.js} +42 -44
  33. package/es/attributeSelector/index.d.ts +4 -111
  34. package/es/attributeSelector/index.js +88 -543
  35. package/es/attributeSelector/listPanel.d.ts +4 -0
  36. package/es/attributeSelector/listPanel.js +208 -0
  37. package/es/attributeSelector/option.d.ts +15 -0
  38. package/es/attributeSelector/option.js +53 -0
  39. package/es/attributeSelector/styles/index.less +100 -0
  40. package/es/attributeSelector/types.d.ts +79 -0
  41. package/es/attributeSelector/types.js +15 -0
  42. package/es/attributeSelector/util.d.ts +7 -0
  43. package/es/attributeSelector/util.js +69 -0
  44. package/es/chart/demo/pie.js +1 -0
  45. package/es/chart/index.d.ts +2 -96
  46. package/es/chart/index.js +28 -35
  47. package/es/chart/styles/index.less +50 -0
  48. package/es/chart/types.d.ts +46 -0
  49. package/es/chart/{type.js → types.js} +0 -0
  50. package/es/chart/util/{chartConfig.d.ts → chartOptionConfig.d.ts} +4 -35
  51. package/es/chart/util/{chartConfig.js → chartOptionConfig.js} +45 -111
  52. package/es/chart/util/formatData.d.ts +3 -7
  53. package/es/chart/util/formatData.js +47 -26
  54. package/es/chart/util/formatOption.d.ts +2 -1
  55. package/es/chart/util/formatOption.js +22 -9
  56. package/es/chart/util/mapUtil.d.ts +3 -3
  57. package/es/chart/util/mapUtil.js +9 -19
  58. package/es/commonStyle/icon.less +116 -112
  59. package/es/commonStyle/select.less +1 -1
  60. package/es/commonStyle/theme.less +520 -473
  61. package/es/components/iconFont.js +4 -2
  62. package/es/context/index.d.ts +16 -0
  63. package/es/context/index.js +3 -0
  64. package/es/datePicker/datePicker.d.ts +10 -0
  65. package/es/datePicker/datePicker.js +115 -0
  66. package/es/datePicker/demo/index.d.ts +1 -0
  67. package/es/datePicker/demo/index.js +9 -2
  68. package/es/datePicker/index.d.ts +4 -27
  69. package/es/datePicker/index.js +72 -148
  70. package/es/datePicker/styles/index.less +48 -0
  71. package/es/datePicker/types.d.ts +24 -0
  72. package/es/{eventSelector/type.js → datePicker/types.js} +0 -0
  73. package/es/datePicker/utils.d.ts +6 -0
  74. package/es/datePicker/utils.js +70 -0
  75. package/es/dialog/components/itemNode.d.ts +10 -0
  76. package/es/dialog/components/itemNode.js +109 -0
  77. package/es/dialog/components/list.d.ts +3 -13
  78. package/es/dialog/components/list.js +15 -12
  79. package/es/dialog/components/selectToInput.d.ts +4 -48
  80. package/es/dialog/components/selectToInput.js +74 -80
  81. package/es/dialog/components/styles/handle.less +39 -0
  82. package/es/dialog/components/styles/list.less +60 -0
  83. package/es/dialog/components/styles/tab.less +55 -0
  84. package/es/dialog/components/tab.d.ts +3 -7
  85. package/es/dialog/components/tab.js +57 -19
  86. package/es/dialog/data/{chart.d.ts → data.d.ts} +9 -0
  87. package/es/dialog/data/{chart.js → data.js} +11 -0
  88. package/es/dialog/demo/index.d.ts +23 -0
  89. package/es/dialog/demo/index.js +34 -3
  90. package/es/dialog/demo/index2.js +14 -2
  91. package/es/dialog/index.d.ts +4 -97
  92. package/es/dialog/index.js +54 -109
  93. package/es/dialog/styles/index.less +11 -0
  94. package/es/dialog/types.d.ts +77 -0
  95. package/es/{targetConditionGroup/type.js → dialog/types.js} +0 -0
  96. package/es/eventSelector/demo/index.js +26 -44
  97. package/es/eventSelector/index.d.ts +4 -30
  98. package/es/eventSelector/index.js +90 -416
  99. package/es/eventSelector/listPanel.d.ts +4 -0
  100. package/es/eventSelector/listPanel.js +197 -0
  101. package/es/eventSelector/option.d.ts +17 -0
  102. package/es/eventSelector/option.js +54 -0
  103. package/es/eventSelector/styles/index.less +77 -0
  104. package/es/eventSelector/types.d.ts +31 -0
  105. package/es/eventSelector/types.js +1 -0
  106. package/es/index.d.ts +14 -11
  107. package/es/index.js +9 -11
  108. package/es/{attributeSelector/data → mock}/env.d.ts +0 -0
  109. package/es/{attributeSelector/data → mock}/env.js +0 -0
  110. package/es/{attributeSelector/data → mock}/event.d.ts +0 -0
  111. package/es/{attributeSelector/data → mock}/event.js +0 -0
  112. package/es/{attributeSelector/data → mock}/user.d.ts +0 -0
  113. package/es/{attributeSelector/data → mock}/user.js +0 -0
  114. package/es/{multipleSelector → searchInput}/demo/index.d.ts +0 -0
  115. package/es/searchInput/demo/index.js +5 -0
  116. package/es/searchInput/index.d.ts +8 -0
  117. package/es/searchInput/index.js +31 -0
  118. package/es/{attributeSelector/demo/multiForm.d.ts → select/demo/group.d.ts} +0 -0
  119. package/es/{globalAttributes/demo/index.js → select/demo/group.js} +49 -31
  120. package/es/select/demo/index.js +49 -21
  121. package/es/{attributeSelector/demo/single.d.ts → select/demo/multiple.d.ts} +0 -0
  122. package/es/{multipleSelector/demo/index.js → select/demo/multiple.js} +55 -12
  123. package/es/select/handle.d.ts +5 -0
  124. package/es/select/handle.js +119 -0
  125. package/es/select/index.d.ts +4 -49
  126. package/es/select/index.js +168 -122
  127. package/es/select/option.d.ts +4 -0
  128. package/es/select/option.js +59 -0
  129. package/es/select/overlay.d.ts +4 -0
  130. package/es/select/overlay.js +154 -0
  131. package/es/select/styles/handle.less +111 -0
  132. package/es/select/styles/index.less +99 -0
  133. package/es/select/types.d.ts +65 -0
  134. package/es/select/types.js +1 -0
  135. package/es/table/demo/data/table.js +1 -1
  136. package/es/table/demo/index.d.ts +1 -1
  137. package/es/table/demo/index.js +9 -8
  138. package/es/table/demo/index3.js +9 -18
  139. package/es/table/index.d.ts +4 -30
  140. package/es/table/index.js +30 -26
  141. package/es/table/styles/index.less +5 -0
  142. package/es/table/type.d.ts +10 -0
  143. package/es/table/type.js +1 -0
  144. package/es/targetConditionGroup/components/targetDimension.d.ts +8 -0
  145. package/es/targetConditionGroup/components/targetDimension.js +153 -0
  146. package/es/targetConditionGroup/data/operates.d.ts +8 -24
  147. package/es/targetConditionGroup/data/operates.js +26 -69
  148. package/es/targetConditionGroup/demo/group.d.ts +1 -0
  149. package/es/targetConditionGroup/demo/group.js +108 -23
  150. package/es/targetConditionGroup/demo/index.js +34 -34
  151. package/es/targetConditionGroup/demo/styles/index.less +29 -0
  152. package/es/targetConditionGroup/index.d.ts +4 -57
  153. package/es/targetConditionGroup/index.js +177 -274
  154. package/es/targetConditionGroup/styles/index.less +25 -0
  155. package/es/targetConditionGroup/types.d.ts +32 -0
  156. package/es/targetConditionGroup/types.js +1 -0
  157. package/es/targetSelector/demo/index.d.ts +1 -0
  158. package/es/targetSelector/demo/index.js +29 -71
  159. package/es/targetSelector/editBox.d.ts +8 -0
  160. package/es/targetSelector/{components/BizEventNameEditBox.js → editBox.js} +49 -24
  161. package/es/targetSelector/index.d.ts +5 -55
  162. package/es/targetSelector/index.js +103 -214
  163. package/es/targetSelector/optionIcon.d.ts +9 -0
  164. package/es/targetSelector/optionIcon.js +24 -0
  165. package/es/targetSelector/optionMenu.d.ts +7 -0
  166. package/es/targetSelector/optionMenu.js +38 -0
  167. package/es/targetSelector/styles/index.less +88 -0
  168. package/es/targetSelector/types.d.ts +18 -0
  169. package/es/targetSelector/types.js +1 -0
  170. package/es/userCondition/conditionTypeList.d.ts +10 -0
  171. package/es/userCondition/conditionTypeList.js +43 -0
  172. package/es/userCondition/conditionWrap.d.ts +7 -0
  173. package/es/userCondition/conditionWrap.js +18 -0
  174. package/es/userCondition/conditions/eventCondition.d.ts +8 -0
  175. package/es/userCondition/conditions/eventCondition.js +104 -0
  176. package/es/userCondition/conditions/periodCondition.d.ts +11 -0
  177. package/es/userCondition/conditions/periodCondition.js +156 -0
  178. package/es/userCondition/conditions/propCondition.d.ts +11 -0
  179. package/es/userCondition/conditions/propCondition.js +147 -0
  180. package/es/userCondition/conditions/runTimesCondition.d.ts +9 -0
  181. package/es/userCondition/conditions/runTimesCondition.js +78 -0
  182. package/es/userCondition/conditions/styles/eventCondition.less +49 -0
  183. package/es/userCondition/conditions/styles/periodCondition.less +14 -0
  184. package/es/userCondition/conditions/styles/propCondition.less +36 -0
  185. package/es/userCondition/conditions/styles/runTimesCondition.less +16 -0
  186. package/es/{attributeSelector/demo/singleForm.d.ts → userCondition/demo/index.d.ts} +0 -0
  187. package/es/userCondition/demo/index.js +97 -0
  188. package/es/userCondition/index.d.ts +7 -0
  189. package/es/userCondition/index.js +146 -0
  190. package/es/userCondition/orConditions.d.ts +5 -0
  191. package/es/userCondition/orConditions.js +202 -0
  192. package/es/userCondition/relationLabel.d.ts +6 -0
  193. package/es/userCondition/relationLabel.js +12 -0
  194. package/es/userCondition/styles/conditionTypeList.less +31 -0
  195. package/es/userCondition/styles/conditionWrap.less +14 -0
  196. package/es/userCondition/styles/index.less +13 -0
  197. package/es/userCondition/styles/orConditions.less +16 -0
  198. package/es/userCondition/styles/relationLabel.less +18 -0
  199. package/es/userCondition/types.d.ts +79 -0
  200. package/es/userCondition/types.js +1 -0
  201. package/es/userCondition/util.d.ts +2 -0
  202. package/es/userCondition/util.js +54 -0
  203. package/es/{datePicker/demo/form.d.ts → userGroup/demo/group.d.ts} +0 -0
  204. package/es/{targetConditionGroup/demo/form.js → userGroup/demo/group.js} +68 -72
  205. package/es/userGroup/demo/index.d.ts +0 -1
  206. package/es/userGroup/demo/index.js +5 -62
  207. package/es/userGroup/index.d.ts +3 -77
  208. package/es/userGroup/index.js +60 -108
  209. package/es/userGroup/styles/index.less +20 -0
  210. package/es/userGroup/types.d.ts +15 -0
  211. package/es/userGroup/types.js +1 -0
  212. package/es/utils/ajax.js +5 -20
  213. package/es/utils/type.d.ts +42 -44
  214. package/es/utils/util.d.ts +1 -35
  215. package/es/utils/util.js +27 -57
  216. package/package.json +11 -4
  217. package/es/attributeSelector/demo/multi.js +0 -39
  218. package/es/attributeSelector/demo/multiForm.js +0 -64
  219. package/es/attributeSelector/demo/single.js +0 -43
  220. package/es/attributeSelector/group.d.ts +0 -31
  221. package/es/attributeSelector/group.js +0 -225
  222. package/es/attributeSelector/index.less +0 -172
  223. package/es/chart/index.less +0 -38
  224. package/es/chart/style/circle.svg +0 -4
  225. package/es/chart/type.d.ts +0 -22
  226. package/es/datePicker/data.d.ts +0 -9
  227. package/es/datePicker/data.js +0 -65
  228. package/es/datePicker/index.less +0 -364
  229. package/es/dialog/components/style/list.less +0 -59
  230. package/es/dialog/components/style/tab.less +0 -61
  231. package/es/dialog/style/index.less +0 -86
  232. package/es/eventSelector/demo/form.d.ts +0 -2
  233. package/es/eventSelector/demo/form.js +0 -89
  234. package/es/eventSelector/demo/nodata.d.ts +0 -2
  235. package/es/eventSelector/demo/nodata.js +0 -13
  236. package/es/eventSelector/index.less +0 -121
  237. package/es/eventSelector/type.d.ts +0 -41
  238. package/es/globalAttributes/demo/data/env.d.ts +0 -11
  239. package/es/globalAttributes/demo/data/env.js +0 -181
  240. package/es/globalAttributes/demo/data/event.d.ts +0 -237
  241. package/es/globalAttributes/demo/data/event.js +0 -3483
  242. package/es/globalAttributes/demo/data/user.d.ts +0 -22
  243. package/es/globalAttributes/demo/data/user.js +0 -218
  244. package/es/globalAttributes/index.d.ts +0 -47
  245. package/es/globalAttributes/index.js +0 -112
  246. package/es/multipleSelector/index.d.ts +0 -36
  247. package/es/multipleSelector/index.js +0 -131
  248. package/es/multipleSelector/index.less +0 -136
  249. package/es/table/demo/index.less +0 -8
  250. package/es/table/index.less +0 -139
  251. package/es/targetConditionGroup/components/conditionGroup.d.ts +0 -30
  252. package/es/targetConditionGroup/components/conditionGroup.js +0 -112
  253. package/es/targetConditionGroup/components/conditionItem.d.ts +0 -47
  254. package/es/targetConditionGroup/components/conditionItem.js +0 -232
  255. package/es/targetConditionGroup/components/style/group.less +0 -47
  256. package/es/targetConditionGroup/components/style/index.less +0 -16
  257. package/es/targetConditionGroup/demo/data/env.d.ts +0 -11
  258. package/es/targetConditionGroup/demo/data/env.js +0 -181
  259. package/es/targetConditionGroup/demo/data/event.d.ts +0 -237
  260. package/es/targetConditionGroup/demo/data/event.js +0 -3483
  261. package/es/targetConditionGroup/demo/data/user.d.ts +0 -22
  262. package/es/targetConditionGroup/demo/data/user.js +0 -218
  263. package/es/targetConditionGroup/demo/form.d.ts +0 -2
  264. package/es/targetConditionGroup/demo/item.d.ts +0 -2
  265. package/es/targetConditionGroup/demo/item.js +0 -5
  266. package/es/targetConditionGroup/group.d.ts +0 -56
  267. package/es/targetConditionGroup/group.js +0 -204
  268. package/es/targetConditionGroup/index.less +0 -76
  269. package/es/targetConditionGroup/type.d.ts +0 -95
  270. package/es/targetSelector/components/BizCascadeBox.d.ts +0 -34
  271. package/es/targetSelector/components/BizCascadeBox.js +0 -213
  272. package/es/targetSelector/components/BizEventNameEditBox.d.ts +0 -20
  273. package/es/targetSelector/demo/form.d.ts +0 -2
  274. package/es/targetSelector/demo/form.js +0 -133
  275. package/es/targetSelector/demo/nodata.d.ts +0 -2
  276. package/es/targetSelector/demo/nodata.js +0 -13
  277. package/es/targetSelector/index.less +0 -28
  278. package/es/userGroup/demo/cluster.d.ts +0 -3
  279. package/es/userGroup/demo/cluster.js +0 -102
  280. package/es/userGroup/demo/index.less +0 -3
  281. package/es/userGroup/index.less +0 -2
  282. package/es/userGroup/userCluster.d.ts +0 -63
  283. package/es/userGroup/userCluster.js +0 -255
@@ -14,8 +14,7 @@ import React, { useMemo } from 'react';
14
14
  import '../assets/iconfont/iconfont.css';
15
15
 
16
16
  var IconFont = function IconFont(props) {
17
- var _props$className = props.className,
18
- className = _props$className === void 0 ? '' : _props$className,
17
+ var className = props.className,
19
18
  type = props.type,
20
19
  rest = _objectWithoutProperties(props, _excluded);
21
20
 
@@ -27,4 +26,7 @@ var IconFont = function IconFont(props) {
27
26
  }, rest));
28
27
  };
29
28
 
29
+ IconFont.defaultProps = {
30
+ className: ''
31
+ };
30
32
  export default IconFont;
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import { EventGroup, UserProp, EnvProp } from '../attributeSelector/types';
3
+ interface AppInfoProps {
4
+ appId?: string | number;
5
+ platform?: string | number;
6
+ [prop: string]: any;
7
+ }
8
+ export interface GlobalContextProps {
9
+ userGroupList?: Array<any>;
10
+ eventGroupList?: EventGroup[];
11
+ userPropList?: UserProp[];
12
+ eventEnvList?: EnvProp[];
13
+ currentApp?: AppInfoProps;
14
+ }
15
+ declare const BizGlobalDataContext: import("react").Context<GlobalContextProps>;
16
+ export default BizGlobalDataContext;
@@ -0,0 +1,3 @@
1
+ import { createContext } from 'react';
2
+ var BizGlobalDataContext = /*#__PURE__*/createContext({});
3
+ export default BizGlobalDataContext;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { DatePickerTypes } from './types';
3
+ declare const BizDate: React.FC<{
4
+ type: 'hour' | 'day' | 'week' | 'month';
5
+ value?: DatePickerTypes.Range;
6
+ includeToday?: boolean;
7
+ dateCount?: DatePickerTypes.ListOption;
8
+ onChange?: (val: DatePickerTypes.Range, isComeIn?: boolean) => void;
9
+ }>;
10
+ export default BizDate;
@@ -0,0 +1,115 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ import { DatePicker } from 'antd';
14
+ import moment from 'moment';
15
+ import React, { useEffect, useState } from 'react';
16
+ import { classPrefix } from '.';
17
+ import IconFont from '../components/iconFont';
18
+ import locale from 'antd/es/date-picker/locale/zh_CN';
19
+ import { getDateRange } from './utils';
20
+ var RangePicker = DatePicker.RangePicker;
21
+
22
+ var BizDate = function BizDate(props) {
23
+ var includeToday = props.includeToday;
24
+ var initValue = {
25
+ begin: moment().subtract(includeToday ? 0 : 1, 'days').format('YYYY-MM-DD'),
26
+ end: moment().subtract(includeToday ? 0 : 1, 'days').format('YYYY-MM-DD')
27
+ };
28
+
29
+ var _useState = useState(),
30
+ _useState2 = _slicedToArray(_useState, 2),
31
+ dateRange = _useState2[0],
32
+ setDateRange = _useState2[1];
33
+
34
+ useEffect(function () {
35
+ setDateRange(props.value ? props.value : initValue);
36
+ }, []);
37
+ useEffect(function () {
38
+ var _props$dateCount;
39
+
40
+ if (!((_props$dateCount = props.dateCount) === null || _props$dateCount === void 0 ? void 0 : _props$dateCount.count)) return;
41
+ var date = getDateRange(props.type, props.dateCount.count, !!includeToday);
42
+ setDateRange(date);
43
+ if (props.onChange) props.onChange(date, true);
44
+ }, [props.dateCount]);
45
+
46
+ var disabledDate = function disabledDate(current) {
47
+ if (includeToday) {
48
+ return current && current > moment().endOf('day');
49
+ }
50
+
51
+ return current && current > moment().subtract(1, 'days').endOf('day');
52
+ };
53
+
54
+ var onChangeDate = function onChangeDate() {
55
+ var range = {
56
+ begin: arguments.length <= 1 ? undefined : arguments[1],
57
+ end: arguments.length <= 1 ? undefined : arguments[1]
58
+ };
59
+ setDateRange(range);
60
+ if (props.onChange) props.onChange(range);
61
+ };
62
+
63
+ var onChangeRange = function onChangeRange() {
64
+ for (var _len = arguments.length, date = new Array(_len), _key = 0; _key < _len; _key++) {
65
+ date[_key] = arguments[_key];
66
+ }
67
+
68
+ var range = {
69
+ begin: date[1][0],
70
+ end: date[1][1]
71
+ };
72
+ setDateRange(range);
73
+ if (props.onChange) props.onChange(range);
74
+ };
75
+
76
+ if (!dateRange) {
77
+ return /*#__PURE__*/React.createElement(DatePicker, {
78
+ disabled: true
79
+ });
80
+ }
81
+
82
+ return /*#__PURE__*/React.createElement("div", {
83
+ className: "".concat(classPrefix, "-panel")
84
+ }, props.type === 'hour' ? /*#__PURE__*/React.createElement(DatePicker, {
85
+ value: moment(dateRange.begin, 'YYYY-MM-DD'),
86
+ allowClear: false,
87
+ inputReadOnly: true,
88
+ dropdownClassName: "".concat(classPrefix, "-drop"),
89
+ locale: locale,
90
+ showToday: false,
91
+ disabledDate: disabledDate,
92
+ placement: 'bottomRight',
93
+ placeholder: "\u81EA\u5B9A\u4E49",
94
+ suffixIcon: /*#__PURE__*/React.createElement(IconFont, {
95
+ type: 'icon-shijian1'
96
+ }),
97
+ onChange: onChangeDate
98
+ }) : /*#__PURE__*/React.createElement(RangePicker, {
99
+ value: [moment(dateRange.begin, 'YYYY-MM-DD'), moment(dateRange.end, 'YYYY-MM-DD')],
100
+ allowClear: false,
101
+ dropdownClassName: "".concat(classPrefix, "-drop"),
102
+ inputReadOnly: true,
103
+ locale: locale,
104
+ disabledDate: disabledDate,
105
+ placement: 'bottomRight',
106
+ separator: '至',
107
+ suffixIcon: /*#__PURE__*/React.createElement(IconFont, {
108
+ type: 'icon-shijian1'
109
+ }),
110
+ format: 'YYYY-MM-DD',
111
+ onChange: onChangeRange
112
+ }));
113
+ };
114
+
115
+ export default BizDate;
@@ -1,2 +1,3 @@
1
+ import '@zgfe/business-lib/es/assets/styles/resetAntd.less';
1
2
  declare const _default: () => JSX.Element;
2
3
  export default _default;
@@ -12,8 +12,13 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
13
  import { BizDatePicker } from '@zgfe/business-lib';
14
14
  import React, { useState } from 'react';
15
+ import '@zgfe/business-lib/es/assets/styles/resetAntd.less';
15
16
  export default (function () {
16
- var _useState = useState({}),
17
+ var _useState = useState({
18
+ unit: 'week',
19
+ begin: '2022-05-03',
20
+ end: '2022-05-30'
21
+ }),
17
22
  _useState2 = _slicedToArray(_useState, 2),
18
23
  time = _useState2[0],
19
24
  setTime = _useState2[1];
@@ -25,6 +30,8 @@ export default (function () {
25
30
  };
26
31
 
27
32
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(BizDatePicker, {
28
- onChange: handleChange
33
+ onChange: handleChange,
34
+ includeToday: true,
35
+ defaultValue: time
29
36
  }), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("p", null, "\u5F53\u524D\u503C\uFF1A", JSON.stringify(time)));
30
37
  });
@@ -1,29 +1,6 @@
1
1
  import React from 'react';
2
- import './index.less';
3
- import 'moment/locale/zh-cn';
4
- interface PickerProps {
5
- startDate?: any;
6
- endDate?: any;
7
- }
8
- interface ValueType extends PickerProps {
9
- type?: string;
10
- }
11
- interface DatePickerProps {
12
- /**
13
- * @describe 默认值
14
- * @default {type:'hour', startDate:today, endDate:today}
15
- */
16
- defaultValue?: ValueType;
17
- /**
18
- * @describe 默认值
19
- * @default {type:'hour', startDate:today, endDate:today}
20
- */
21
- value?: ValueType;
22
- /**
23
- * @describe 回调
24
- * @default -
25
- */
26
- onChange?: (data: object) => void;
27
- }
28
- declare const BizDatePicker: React.FC<DatePickerProps>;
2
+ import { DatePickerTypes } from './types';
3
+ import './styles/index.less';
4
+ export declare const classPrefix = "biz-date-picker";
5
+ declare const BizDatePicker: React.FC<DatePickerTypes.Props>;
29
6
  export default BizDatePicker;
@@ -16,184 +16,108 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
16
16
 
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
 
19
- import { DatePicker } from 'antd';
20
19
  import React, { useEffect, useState } from 'react';
21
- import IconFont from '../components/iconFont';
22
- import { dateType, dateList } from './data';
23
- import util from '../utils/util';
24
- import './index.less';
25
- import moment from 'moment';
26
- import 'moment/locale/zh-cn';
27
- import locale from 'antd/es/date-picker/locale/zh_CN';
20
+ import { dateList } from './utils';
28
21
  import BizSelect from '../select';
29
- var RangePicker = DatePicker.RangePicker;
22
+ import BizDate from './datePicker';
23
+ import './styles/index.less';
24
+ import { Skeleton } from 'antd';
25
+ export var classPrefix = 'biz-date-picker';
30
26
 
31
27
  var BizDatePicker = function BizDatePicker(props) {
32
- var _props$defaultValue = props.defaultValue,
33
- defaultValue = _props$defaultValue === void 0 ? {
34
- type: 'hour',
35
- startDate: new Date(),
36
- endDate: new Date()
37
- } : _props$defaultValue,
38
- _props$value = props.value,
39
- value = _props$value === void 0 ? {
40
- type: 'hour',
41
- startDate: new Date(),
42
- endDate: new Date()
43
- } : _props$value,
44
- onChange = props.onChange;
45
-
46
- var _useState = useState(defaultValue.type || value.type || 'hour'),
28
+ var _useState = useState(dateList[0]),
47
29
  _useState2 = _slicedToArray(_useState, 2),
48
30
  currentType = _useState2[0],
49
31
  setCurrentType = _useState2[1];
50
32
 
51
- var _useState3 = useState({}),
33
+ var _useState3 = useState(),
52
34
  _useState4 = _slicedToArray(_useState3, 2),
53
- currentTime = _useState4[0],
54
- setCurrentTime = _useState4[1];
35
+ dateRange = _useState4[0],
36
+ setDateRange = _useState4[1];
55
37
 
56
- var _useState5 = useState({
57
- startDate: defaultValue.startDate || value.startDate || new Date(),
58
- endDate: defaultValue.endDate || value.endDate || new Date()
59
- }),
38
+ var _useState5 = useState(),
60
39
  _useState6 = _slicedToArray(_useState5, 2),
61
- selectedDate = _useState6[0],
62
- setSelectedDate = _useState6[1];
40
+ currentTime = _useState6[0],
41
+ setCurrentTime = _useState6[1];
42
+
43
+ var _useState7 = useState(true),
44
+ _useState8 = _slicedToArray(_useState7, 2),
45
+ ready = _useState8[0],
46
+ setReady = _useState8[1];
63
47
 
64
48
  useEffect(function () {
65
- onChange && onChange(_objectSpread({
66
- type: currentType
67
- }, selectedDate));
68
- }, [selectedDate]);
69
- useEffect(function () {
70
- if (!Object.keys(currentTime).length) return;
71
- var endDate, startDate;
72
- var _currentTime$count = currentTime.count,
73
- count = _currentTime$count === void 0 ? 1 : _currentTime$count,
74
- value = currentTime.value;
75
- var maxDate = new Date(new Date().getTime() - util.dayTime);
76
-
77
- switch (currentType) {
78
- case 'hour':
79
- endDate = startDate = new Date(new Date().getTime() - count * util.dayTime);
80
- break;
81
-
82
- case 'day':
83
- startDate = new Date(new Date().getTime() - count * util.dayTime);
84
- endDate = maxDate;
85
- break;
86
-
87
- case 'week':
88
- endDate = maxDate; // 减一是因为这里以周一为一周的第一天,如果以周日为第一天,则去掉就行
89
-
90
- var firstOfWeek = new Date(maxDate.getTime() - (maxDate.getDay() - 1) * util.dayTime);
91
- startDate = new Date(firstOfWeek.getTime() - count * 7 * util.dayTime);
92
- break;
93
-
94
- case 'month':
95
- endDate = maxDate; // 这里-1是为了将日期置为一号
96
-
97
- var firstOfMonth = new Date(maxDate.getTime() - (maxDate.getDate() - 1) * util.dayTime);
98
- firstOfMonth.setMonth(firstOfMonth.getMonth() - count);
99
- startDate = new Date(firstOfMonth);
100
- break;
49
+ var data = props.defaultValue || props.value;
50
+
51
+ if (data) {
52
+ setCurrentType(function () {
53
+ return dateList.filter(function (item) {
54
+ return item.value === data.unit;
55
+ })[0] || dateList[0];
56
+ });
57
+ setDateRange(function () {
58
+ return {
59
+ begin: data.begin,
60
+ end: data.end
61
+ };
62
+ });
101
63
  }
102
64
 
103
- setSelectedDate(function () {
104
- return {
105
- startDate: util.dateFormat(startDate),
106
- endDate: util.dateFormat(endDate)
107
- };
108
- });
109
- }, [currentTime]);
65
+ setReady(false);
66
+ }, []);
110
67
 
111
- var disabledDate = function disabledDate(current) {
112
- return current && current > moment().endOf('day');
68
+ var onChangeDateType = function onChangeDateType(data) {
69
+ setCurrentType(data);
70
+ setCurrentTime(data.children[0]);
113
71
  };
114
72
 
115
- var _onChange = function _onChange(date, dateString) {
116
- setSelectedDate(function () {
117
- return {
118
- startDate: dateString,
119
- endDate: dateString
120
- };
121
- });
122
- setCurrentTime(function () {
123
- return {};
124
- });
73
+ var _onClick = function onClick(value) {
74
+ setCurrentTime(value);
125
75
  };
126
76
 
127
- var _onRangeChange = function _onRangeChange(dates, dateStrings) {
128
- setSelectedDate(function () {
129
- return {
130
- startDate: dateStrings[0],
131
- endDate: dateStrings[1]
132
- };
133
- });
134
- setCurrentTime(function () {
135
- return {};
136
- });
77
+ var onChangeRange = function onChangeRange(value, changed) {
78
+ setDateRange(value);
79
+
80
+ if (!changed) {
81
+ setCurrentTime(undefined);
82
+ }
83
+
84
+ if (props.onChange) props.onChange(_objectSpread({
85
+ unit: currentType.value
86
+ }, value));
137
87
  };
138
88
 
139
89
  return /*#__PURE__*/React.createElement("div", {
140
- className: "biz-date-container"
141
- }, /*#__PURE__*/React.createElement(BizSelect, {
142
- className: "biz-date-type",
143
- defaultValue: currentType,
144
- options: dateType,
145
- dropdownSize: "small",
146
- size: "small",
147
- onChange: function onChange(operate) {
148
- setCurrentType(function () {
149
- return operate;
150
- });
151
- setCurrentTime(function () {
152
- return dateList[operate][0];
153
- });
90
+ className: classPrefix
91
+ }, /*#__PURE__*/React.createElement(Skeleton, {
92
+ loading: ready,
93
+ active: true,
94
+ paragraph: {
95
+ rows: 1
154
96
  }
97
+ }, /*#__PURE__*/React.createElement(BizSelect, {
98
+ className: "".concat(classPrefix, "-type"),
99
+ value: currentType,
100
+ labelField: "label",
101
+ keyField: "value",
102
+ theme: "secondary",
103
+ options: dateList,
104
+ onChange: onChangeDateType
155
105
  }), /*#__PURE__*/React.createElement("div", {
156
- className: "biz-date-list"
157
- }, dateList[currentType].map(function (item, index) {
106
+ className: "".concat(classPrefix, "-list")
107
+ }, currentType.children.map(function (item, index) {
158
108
  return /*#__PURE__*/React.createElement("div", {
159
109
  key: index,
160
- className: "biz-date-item ".concat(currentTime.value === item.value ? 'active' : ''),
110
+ className: "".concat(classPrefix, "-item ").concat(currentTime && currentTime.value === item.value ? 'active' : ''),
161
111
  onClick: function onClick() {
162
- setCurrentTime(function () {
163
- return _objectSpread({}, item);
164
- });
112
+ return _onClick(item);
165
113
  }
166
114
  }, item.value);
167
- })), /*#__PURE__*/React.createElement("div", {
168
- className: "biz-date-picker"
169
- }, currentType === 'hour' ? /*#__PURE__*/React.createElement(DatePicker, {
170
- value: moment(selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.startDate, 'YYYY-MM-DD'),
171
- allowClear: false,
172
- inputReadOnly: true,
173
- dropdownClassName: "biz-date-ant-picker",
174
- locale: locale,
175
- showToday: false,
176
- disabledDate: disabledDate,
177
- placement: 'bottomRight',
178
- placeholder: "\u81EA\u5B9A\u4E49",
179
- suffixIcon: /*#__PURE__*/React.createElement(IconFont, {
180
- type: 'icon-shijian1'
181
- }),
182
- onChange: _onChange
183
- }) : /*#__PURE__*/React.createElement(RangePicker, {
184
- value: [moment(selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.startDate, 'YYYY-MM-DD'), moment(selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.endDate, 'YYYY-MM-DD')],
185
- allowClear: false,
186
- dropdownClassName: "biz-date-ant-picker",
187
- inputReadOnly: true,
188
- locale: locale,
189
- disabledDate: disabledDate,
190
- placement: 'bottomRight',
191
- separator: '至',
192
- suffixIcon: /*#__PURE__*/React.createElement(IconFont, {
193
- type: 'icon-shijian1'
194
- }),
195
- format: 'YYYY-MM-DD',
196
- onChange: _onRangeChange
115
+ })), /*#__PURE__*/React.createElement(BizDate, {
116
+ type: currentType.value,
117
+ dateCount: currentTime,
118
+ value: dateRange,
119
+ includeToday: props.includeToday,
120
+ onChange: onChangeRange
197
121
  })));
198
122
  };
199
123
 
@@ -0,0 +1,48 @@
1
+ @import '../../assets/styles/inner.less';
2
+ .biz-date-picker {
3
+ display: flex;
4
+
5
+ &-type {
6
+ width: 88px;
7
+ }
8
+
9
+ &-list {
10
+ display: flex;
11
+ margin: 0 16px;
12
+ }
13
+ .biz-select-handle {
14
+ padding: 0;
15
+ }
16
+ &-item {
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+ width: 58px;
21
+ height: @height-base;
22
+ border: 1px solid @border-color-base;
23
+ cursor: pointer;
24
+
25
+ &:first-child {
26
+ border-radius: @border-radius-small 0px 0px @border-radius-small;
27
+ }
28
+
29
+ &:last-child {
30
+ border-radius: 0px @border-radius-small @border-radius-small 0px;
31
+ }
32
+
33
+ &:not(:last-child) {
34
+ border-right: none;
35
+ }
36
+
37
+ &:hover {
38
+ .__default-hover();
39
+ border-color: @border-color-base;
40
+ }
41
+
42
+ &.active {
43
+ color: @primary-color;
44
+ background: @primary-1;
45
+ border: 1px solid @primary-color;
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,24 @@
1
+ export declare namespace DatePickerTypes {
2
+ interface Range {
3
+ begin: string;
4
+ end: string;
5
+ }
6
+ interface Value extends Range {
7
+ unit: 'hour' | 'day' | 'week' | 'month';
8
+ }
9
+ interface Props {
10
+ defaultValue?: Value;
11
+ value?: Value;
12
+ includeToday?: boolean;
13
+ onChange?: (data: object) => void;
14
+ }
15
+ interface Option {
16
+ label: string;
17
+ value: 'hour' | 'day' | 'week' | 'month';
18
+ children: ListOption[];
19
+ }
20
+ interface ListOption {
21
+ count: number;
22
+ value: string;
23
+ }
24
+ }
@@ -0,0 +1,6 @@
1
+ import { DatePickerTypes } from './types';
2
+ export declare const dateList: DatePickerTypes.Option[];
3
+ export declare const getDateRange: (type: 'hour' | 'day' | 'week' | 'month', count: number, includeToday: boolean) => {
4
+ begin: string;
5
+ end: string;
6
+ };
@@ -0,0 +1,70 @@
1
+ import moment from 'moment';
2
+ export var dateList = [{
3
+ label: '按小时',
4
+ value: 'hour',
5
+ children: [{
6
+ value: '昨天',
7
+ count: 1
8
+ }, {
9
+ value: '前天',
10
+ count: 2
11
+ }]
12
+ }, {
13
+ label: '按天',
14
+ value: 'day',
15
+ children: [{
16
+ value: '7天',
17
+ count: 7
18
+ }, {
19
+ value: '14天',
20
+ count: 14
21
+ }, {
22
+ value: '30天',
23
+ count: 30
24
+ }]
25
+ }, {
26
+ label: '按周',
27
+ value: 'week',
28
+ children: [{
29
+ value: '4周',
30
+ count: 4
31
+ }, {
32
+ value: '8周',
33
+ count: 8
34
+ }, {
35
+ value: '12周',
36
+ count: 12
37
+ }]
38
+ }, {
39
+ label: '按月',
40
+ value: 'month',
41
+ children: [{
42
+ value: '1个月',
43
+ count: 1
44
+ }, {
45
+ value: '2个月',
46
+ count: 2
47
+ }, {
48
+ value: '3个月',
49
+ count: 3
50
+ }]
51
+ }];
52
+ export var getDateRange = function getDateRange(type, count, includeToday) {
53
+ var endDate = moment().subtract(includeToday ? 0 : 1, 'days').format('YYYY-MM-DD'),
54
+ startDate = '';
55
+
56
+ if (type === 'month') {
57
+ startDate = moment().subtract(count, 'months').format('YYYY-MM-DD');
58
+ } else if (type === 'week') {
59
+ startDate = moment().subtract(count, 'weeks').format('YYYY-MM-DD');
60
+ } else if (type === 'day') {
61
+ startDate = moment().subtract(count, 'days').format('YYYY-MM-DD');
62
+ } else {
63
+ startDate = endDate = moment().subtract(count, 'days').format('YYYY-MM-DD');
64
+ }
65
+
66
+ return {
67
+ begin: startDate,
68
+ end: endDate
69
+ };
70
+ };
@@ -0,0 +1,10 @@
1
+ import { FormItemProps } from 'antd';
2
+ import React from 'react';
3
+ import { DialogTypes } from '../types';
4
+ declare const ItemNode: React.FC<{
5
+ value?: any;
6
+ field: DialogTypes.FieldProps & FormItemProps;
7
+ fieldNames?: DialogTypes.FieldOption;
8
+ onChange?: (value: any) => void;
9
+ }>;
10
+ export default ItemNode;