hc-busin-components 1.0.0

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 (185) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/Actions/index.d.ts +20 -0
  4. package/dist/Actions/index.js +142 -0
  5. package/dist/Actions/index.less +9 -0
  6. package/dist/AuthComponents/authDivider.d.ts +15 -0
  7. package/dist/AuthComponents/authDivider.js +104 -0
  8. package/dist/AuthComponents/index.d.ts +4 -0
  9. package/dist/AuthComponents/index.js +14 -0
  10. package/dist/BasicFilesRead/images/back.png +0 -0
  11. package/dist/BasicFilesRead/images/excel.png +0 -0
  12. package/dist/BasicFilesRead/images/folder.png +0 -0
  13. package/dist/BasicFilesRead/images/image.png +0 -0
  14. package/dist/BasicFilesRead/images/jpeg.png +0 -0
  15. package/dist/BasicFilesRead/images/jpg.png +0 -0
  16. package/dist/BasicFilesRead/images/normal.png +0 -0
  17. package/dist/BasicFilesRead/images/png.png +0 -0
  18. package/dist/BasicFilesRead/images/tar.png +0 -0
  19. package/dist/BasicFilesRead/images/text.png +0 -0
  20. package/dist/BasicFilesRead/images/zip.png +0 -0
  21. package/dist/BasicFilesRead/index.d.ts +31 -0
  22. package/dist/BasicFilesRead/index.js +286 -0
  23. package/dist/BasicFilesRead/styles/index.d.ts +3 -0
  24. package/dist/BasicFilesRead/styles/index.js +9 -0
  25. package/dist/CombinTable/components/RenderContent.d.ts +9 -0
  26. package/dist/CombinTable/components/RenderContent.js +201 -0
  27. package/dist/CombinTable/hooks/useTableParams.d.ts +20 -0
  28. package/dist/CombinTable/hooks/useTableParams.js +75 -0
  29. package/dist/CombinTable/hooks/useTableState.d.ts +5 -0
  30. package/dist/CombinTable/hooks/useTableState.js +22 -0
  31. package/dist/CombinTable/index.d.ts +4 -0
  32. package/dist/CombinTable/index.js +225 -0
  33. package/dist/CombinTable/styles/index.d.ts +3 -0
  34. package/dist/CombinTable/styles/index.js +11 -0
  35. package/dist/CombinTable/types/index.d.ts +21 -0
  36. package/dist/CombinTable/types/index.js +1 -0
  37. package/dist/CombineSearch/components/Content.d.ts +13 -0
  38. package/dist/CombineSearch/components/Content.js +249 -0
  39. package/dist/CombineSearch/components/Tags.d.ts +14 -0
  40. package/dist/CombineSearch/components/Tags.js +115 -0
  41. package/dist/CombineSearch/hooks/useCombineState.d.ts +5 -0
  42. package/dist/CombineSearch/hooks/useCombineState.js +17 -0
  43. package/dist/CombineSearch/index.d.ts +4 -0
  44. package/dist/CombineSearch/index.js +168 -0
  45. package/dist/CombineSearch/style/edit.svg +1 -0
  46. package/dist/CombineSearch/style/index.d.ts +14 -0
  47. package/dist/CombineSearch/style/index.js +26 -0
  48. package/dist/CombineSearch/types/index.d.ts +46 -0
  49. package/dist/CombineSearch/types/index.js +0 -0
  50. package/dist/ComponentUninstalled/assets/comp-unintall-background.png +0 -0
  51. package/dist/ComponentUninstalled/assets/comp-unintall-bg.png +0 -0
  52. package/dist/ComponentUninstalled/index.d.ts +32 -0
  53. package/dist/ComponentUninstalled/index.js +164 -0
  54. package/dist/ComponentUninstalled/index.less +108 -0
  55. package/dist/ComponentUninstalled/locale.d.ts +14 -0
  56. package/dist/ComponentUninstalled/locale.js +21 -0
  57. package/dist/DataCountPopover/index.d.ts +23 -0
  58. package/dist/DataCountPopover/index.js +121 -0
  59. package/dist/DataCountPopover/index.less +62 -0
  60. package/dist/DateRangePicker/index.d.ts +38 -0
  61. package/dist/DateRangePicker/index.js +483 -0
  62. package/dist/DateRangePicker/index.less +196 -0
  63. package/dist/DeleteConfirm/index.d.ts +23 -0
  64. package/dist/DeleteConfirm/index.js +109 -0
  65. package/dist/DeleteConfirm/index.less +44 -0
  66. package/dist/DeleteConfirm/locale.d.ts +7 -0
  67. package/dist/DeleteConfirm/locale.js +7 -0
  68. package/dist/DisplayButton/index.d.ts +7 -0
  69. package/dist/DisplayButton/index.js +23 -0
  70. package/dist/FileRead/images/back.png +0 -0
  71. package/dist/FileRead/images/excel.png +0 -0
  72. package/dist/FileRead/images/folder.png +0 -0
  73. package/dist/FileRead/images/image.png +0 -0
  74. package/dist/FileRead/images/jpeg.png +0 -0
  75. package/dist/FileRead/images/jpg.png +0 -0
  76. package/dist/FileRead/images/normal.png +0 -0
  77. package/dist/FileRead/images/png.png +0 -0
  78. package/dist/FileRead/images/tar.png +0 -0
  79. package/dist/FileRead/images/text.png +0 -0
  80. package/dist/FileRead/images/zip.png +0 -0
  81. package/dist/FileRead/index.d.ts +31 -0
  82. package/dist/FileRead/index.js +417 -0
  83. package/dist/FileRead/styles/index.d.ts +3 -0
  84. package/dist/FileRead/styles/index.js +9 -0
  85. package/dist/Icon/iconfont.d.ts +1 -0
  86. package/dist/Icon/iconfont.js +1 -0
  87. package/dist/Icon/index.d.ts +10 -0
  88. package/dist/Icon/index.js +20 -0
  89. package/dist/Icon/index.less +11 -0
  90. package/dist/IconPopTips/index.d.ts +10 -0
  91. package/dist/IconPopTips/index.js +26 -0
  92. package/dist/IconPopTips/index.less +33 -0
  93. package/dist/IconText/index.d.ts +15 -0
  94. package/dist/IconText/index.js +19 -0
  95. package/dist/IconText/index.less +38 -0
  96. package/dist/LogCenter/assets/empty.png +0 -0
  97. package/dist/LogCenter/context.d.ts +24 -0
  98. package/dist/LogCenter/context.js +66 -0
  99. package/dist/LogCenter/history-log.d.ts +35 -0
  100. package/dist/LogCenter/history-log.js +1214 -0
  101. package/dist/LogCenter/index.d.ts +8 -0
  102. package/dist/LogCenter/index.js +130 -0
  103. package/dist/LogCenter/index.less +577 -0
  104. package/dist/LogCenter/locale.d.ts +3 -0
  105. package/dist/LogCenter/locale.js +81 -0
  106. package/dist/LogCenter/realtime-log.d.ts +35 -0
  107. package/dist/LogCenter/realtime-log.js +641 -0
  108. package/dist/LogCenter/select-with-all.d.ts +28 -0
  109. package/dist/LogCenter/select-with-all.js +337 -0
  110. package/dist/LogCenter/select-with-all.less +81 -0
  111. package/dist/LogCenter/services.d.ts +27 -0
  112. package/dist/LogCenter/services.js +93 -0
  113. package/dist/LogCenter/tools.d.ts +9 -0
  114. package/dist/LogCenter/tools.js +137 -0
  115. package/dist/LogCenter/types.d.ts +133 -0
  116. package/dist/LogCenter/types.js +1 -0
  117. package/dist/LogicalResourceFilter/index.d.ts +7 -0
  118. package/dist/LogicalResourceFilter/index.js +426 -0
  119. package/dist/LogicalResourceFilter/index.less +139 -0
  120. package/dist/LogicalResourceFilter/locale.d.ts +2 -0
  121. package/dist/LogicalResourceFilter/locale.js +10 -0
  122. package/dist/LogicalResourceFilter/types.d.ts +58 -0
  123. package/dist/LogicalResourceFilter/types.js +1 -0
  124. package/dist/MetadataCount/index.d.ts +16 -0
  125. package/dist/MetadataCount/index.js +97 -0
  126. package/dist/MetadataCount/index.less +40 -0
  127. package/dist/MetadataForm/index.d.ts +18 -0
  128. package/dist/MetadataForm/index.js +85 -0
  129. package/dist/MetadataForm/index.less +108 -0
  130. package/dist/MetadataForm/label.d.ts +13 -0
  131. package/dist/MetadataForm/label.js +447 -0
  132. package/dist/MetadataPopoverList/fetchArray.d.ts +3 -0
  133. package/dist/MetadataPopoverList/fetchArray.js +74 -0
  134. package/dist/MetadataPopoverList/index.d.ts +13 -0
  135. package/dist/MetadataPopoverList/index.js +98 -0
  136. package/dist/MetadataPopoverList/index.less +74 -0
  137. package/dist/MetadataTags/index.d.ts +17 -0
  138. package/dist/MetadataTags/index.js +109 -0
  139. package/dist/MetadataTags/index.less +26 -0
  140. package/dist/OverFlow/index.d.ts +4 -0
  141. package/dist/OverFlow/index.js +66 -0
  142. package/dist/OverFlow/types/index.d.ts +11 -0
  143. package/dist/OverFlow/types/index.js +1 -0
  144. package/dist/PageHeader/index.d.ts +16 -0
  145. package/dist/PageHeader/index.js +41 -0
  146. package/dist/PageHeader/index.less +89 -0
  147. package/dist/ResourceProgress/index.d.ts +6 -0
  148. package/dist/ResourceProgress/index.js +102 -0
  149. package/dist/ResourceProgress/index.less +86 -0
  150. package/dist/ResourceProgress/types/index.d.ts +15 -0
  151. package/dist/ResourceProgress/types/index.js +1 -0
  152. package/dist/Terminal/index.d.ts +44 -0
  153. package/dist/Terminal/index.js +390 -0
  154. package/dist/Terminal/index.less +39 -0
  155. package/dist/TextCopy/index.d.ts +21 -0
  156. package/dist/TextCopy/index.js +38 -0
  157. package/dist/TextCopy/index.less +51 -0
  158. package/dist/TextEllipsis/index.d.ts +18 -0
  159. package/dist/TextEllipsis/index.js +31 -0
  160. package/dist/TextEllipsis/index.less +3 -0
  161. package/dist/ThemeForm/index.d.ts +6 -0
  162. package/dist/ThemeForm/index.js +15 -0
  163. package/dist/ThemeForm/index.less +15 -0
  164. package/dist/ThemeSubmit/index.d.ts +16 -0
  165. package/dist/ThemeSubmit/index.js +60 -0
  166. package/dist/ThemeSubmit/index.less +30 -0
  167. package/dist/TooltipSpan/index.d.ts +6 -0
  168. package/dist/TooltipSpan/index.js +72 -0
  169. package/dist/UsageCycle/index.d.ts +12 -0
  170. package/dist/UsageCycle/index.js +71 -0
  171. package/dist/UsageCycle/index.less +56 -0
  172. package/dist/Yaml/CodeMirrorWrapper.d.ts +14 -0
  173. package/dist/Yaml/CodeMirrorWrapper.js +106 -0
  174. package/dist/Yaml/index.d.ts +6 -0
  175. package/dist/Yaml/index.js +470 -0
  176. package/dist/Yaml/index.less +190 -0
  177. package/dist/Yaml/types.d.ts +38 -0
  178. package/dist/Yaml/types.js +1 -0
  179. package/dist/index.d.ts +52 -0
  180. package/dist/index.js +32 -0
  181. package/dist/metadata/locale.d.ts +52 -0
  182. package/dist/metadata/locale.js +69 -0
  183. package/dist/showMore/index.d.ts +6 -0
  184. package/dist/showMore/index.js +40 -0
  185. package/package.json +121 -0
@@ -0,0 +1,483 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
+ 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."); }
13
+ 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); }
14
+ 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; }
15
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
+ import { CalendarOutlined, CloseOutlined } from '@ant-design/icons';
18
+ import { Button, ConfigProvider, DatePicker, Input, Popover, Radio, Slider, Switch } from 'antd';
19
+ import dayjs from 'dayjs';
20
+ import customParseFormat from 'dayjs/plugin/customParseFormat';
21
+ import moment from 'moment';
22
+ import RangeCalendar from 'rc-calendar/lib/RangeCalendar';
23
+ import enUS from 'rc-calendar/lib/locale/en_US';
24
+ import zhCN from 'rc-calendar/lib/locale/zh_CN';
25
+ import zhHK from 'rc-calendar/lib/locale/zh_TW';
26
+ import TimePickerPanel from 'rc-time-picker/lib/Panel';
27
+ import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
28
+ import 'rc-calendar/assets/index.css';
29
+ import 'rc-time-picker/assets/index.css';
30
+ import "./index.less";
31
+ dayjs.extend(customParseFormat);
32
+ var RangePicker = DatePicker.RangePicker;
33
+ var DEFAULT_DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
34
+ var DEFAULT_QUICK_TIME_OPTIONS = [{
35
+ id: 1,
36
+ value: 1,
37
+ label: '5分钟',
38
+ diff: 5 * 60 * 1000,
39
+ interval: 1,
40
+ timeUnitId: 1
41
+ }, {
42
+ id: 2,
43
+ value: 2,
44
+ label: '1小时',
45
+ diff: 60 * 60 * 1000,
46
+ interval: 2,
47
+ timeUnitId: 2
48
+ }, {
49
+ id: 3,
50
+ value: 3,
51
+ label: '6小时',
52
+ diff: 6 * 60 * 60 * 1000,
53
+ interval: 4,
54
+ timeUnitId: 2
55
+ }, {
56
+ id: 4,
57
+ value: 4,
58
+ label: '12小时',
59
+ diff: 12 * 60 * 60 * 1000,
60
+ interval: 5,
61
+ timeUnitId: 4
62
+ }, {
63
+ id: 5,
64
+ value: 5,
65
+ label: '1天',
66
+ diff: 24 * 60 * 60 * 1000,
67
+ interval: 6,
68
+ timeUnitId: 5
69
+ }, {
70
+ id: 6,
71
+ value: 6,
72
+ label: '7天',
73
+ diff: 7 * 24 * 60 * 60 * 1000,
74
+ interval: 5,
75
+ timeUnitId: 5
76
+ }];
77
+ var LOCALE_TEXT = {
78
+ 'zh-CN': {
79
+ recent: '最近',
80
+ custom: '指定时间',
81
+ confirm: '确定'
82
+ },
83
+ 'zh-HK': {
84
+ recent: '最近',
85
+ custom: '指定時間',
86
+ confirm: '確定'
87
+ },
88
+ 'en-US': {
89
+ recent: 'Recent',
90
+ custom: 'Custom',
91
+ confirm: 'Confirm'
92
+ }
93
+ };
94
+ var CALENDAR_LOCALE_MAP = {
95
+ 'zh-CN': zhCN,
96
+ 'zh-HK': zhHK,
97
+ 'en-US': enUS
98
+ };
99
+ var PRIMARY = 'var(--ant-color-primary, #1677ff)';
100
+ var TEXT_SECONDARY = 'rgba(0, 0, 0, 0.65)';
101
+ var DateRangePicker = function DateRangePicker(props) {
102
+ var _quickTimeOptions$2;
103
+ var onChange = props.onChange,
104
+ value = props.value,
105
+ _props$format = props.format,
106
+ format = _props$format === void 0 ? DEFAULT_DATE_TIME_FORMAT : _props$format,
107
+ _props$placement = props.placement,
108
+ placement = _props$placement === void 0 ? 'bottomLeft' : _props$placement,
109
+ _props$quickTimeOptio = props.quickTimeOptions,
110
+ quickTimeOptions = _props$quickTimeOptio === void 0 ? DEFAULT_QUICK_TIME_OPTIONS : _props$quickTimeOptio,
111
+ disabledDate = props.disabledDate,
112
+ width = props.width,
113
+ disabled = props.disabled,
114
+ _props$flat = props.flat,
115
+ flat = _props$flat === void 0 ? false : _props$flat;
116
+ var _useContext = useContext(ConfigProvider.ConfigContext),
117
+ antdLocale = _useContext.locale;
118
+ var currentLocale = useMemo(function () {
119
+ var localeName = antdLocale === null || antdLocale === void 0 ? void 0 : antdLocale.locale;
120
+ if (localeName === 'zh-cn' || localeName === 'zh_CN') {
121
+ return 'zh-CN';
122
+ }
123
+ if (localeName === 'zh-hk' || localeName === 'zh_HK' || localeName === 'zh-tw' || localeName === 'zh_TW') {
124
+ return 'zh-HK';
125
+ }
126
+ if (localeName === 'en' || localeName === 'en-us' || localeName === 'en_US') {
127
+ return 'en-US';
128
+ }
129
+ return 'zh-CN';
130
+ }, [antdLocale]);
131
+ var i18n = useMemo(function () {
132
+ return LOCALE_TEXT[currentLocale];
133
+ }, [currentLocale]);
134
+ var _useState = useState(false),
135
+ _useState2 = _slicedToArray(_useState, 2),
136
+ visible = _useState2[0],
137
+ setVisible = _useState2[1];
138
+ var _useState3 = useState(true),
139
+ _useState4 = _slicedToArray(_useState3, 2),
140
+ isRecent = _useState4[0],
141
+ setIsRecent = _useState4[1];
142
+ var _useState5 = useState(function () {
143
+ var _quickTimeOptions$0$v, _quickTimeOptions$;
144
+ return (_quickTimeOptions$0$v = (_quickTimeOptions$ = quickTimeOptions[0]) === null || _quickTimeOptions$ === void 0 ? void 0 : _quickTimeOptions$.value) !== null && _quickTimeOptions$0$v !== void 0 ? _quickTimeOptions$0$v : DEFAULT_QUICK_TIME_OPTIONS[0].value;
145
+ }),
146
+ _useState6 = _slicedToArray(_useState5, 2),
147
+ sliderValue = _useState6[0],
148
+ setSliderValue = _useState6[1];
149
+ var _useState7 = useState([dayjs().subtract(1, 'day'), dayjs()]),
150
+ _useState8 = _slicedToArray(_useState7, 2),
151
+ selectTimeRange = _useState8[0],
152
+ setSelectTimeRange = _useState8[1];
153
+ var _useState9 = useState([moment().subtract(1, 'days'), moment()]),
154
+ _useState10 = _slicedToArray(_useState9, 2),
155
+ customTimeRange = _useState10[0],
156
+ setCustomTimeRange = _useState10[1];
157
+ var _useState11 = useState(''),
158
+ _useState12 = _slicedToArray(_useState11, 2),
159
+ displayValue = _useState12[0],
160
+ setDisplayValue = _useState12[1];
161
+ var _useState13 = useState((_quickTimeOptions$2 = quickTimeOptions[0]) === null || _quickTimeOptions$2 === void 0 ? void 0 : _quickTimeOptions$2.id),
162
+ _useState14 = _slicedToArray(_useState13, 2),
163
+ flatRadioValue = _useState14[0],
164
+ setFlatRadioValue = _useState14[1];
165
+ var marks = useMemo(function () {
166
+ var marksObj = {};
167
+ quickTimeOptions.forEach(function (option) {
168
+ marksObj[option.value] = option.label;
169
+ });
170
+ return marksObj;
171
+ }, [quickTimeOptions]);
172
+ var sliderRange = useMemo(function () {
173
+ var values = quickTimeOptions.map(function (opt) {
174
+ return opt.value;
175
+ });
176
+ return {
177
+ min: Math.min.apply(Math, _toConsumableArray(values)),
178
+ max: Math.max.apply(Math, _toConsumableArray(values))
179
+ };
180
+ }, [quickTimeOptions]);
181
+ var setRangeByDate = useCallback(function (from, to) {
182
+ setSelectTimeRange([from, to]);
183
+ setCustomTimeRange([moment(from.valueOf()), moment(to.valueOf())]);
184
+ }, []);
185
+ var calculateInterval = useCallback(function (fromTime, toTime) {
186
+ var diff = dayjs(toTime).valueOf() - dayjs(fromTime).valueOf();
187
+ var hours = diff / (60 * 60 * 1000);
188
+ if (hours <= 1) {
189
+ return {
190
+ interval: 1,
191
+ timeUnitId: 1
192
+ };
193
+ }
194
+ if (hours <= 6) {
195
+ return {
196
+ interval: 2,
197
+ timeUnitId: 2
198
+ };
199
+ }
200
+ if (hours <= 24) {
201
+ return {
202
+ interval: 5,
203
+ timeUnitId: 4
204
+ };
205
+ }
206
+ if (hours <= 72) {
207
+ return {
208
+ interval: 15,
209
+ timeUnitId: 4
210
+ };
211
+ }
212
+ return {
213
+ interval: 30,
214
+ timeUnitId: 4
215
+ };
216
+ }, []);
217
+ useEffect(function () {
218
+ if (value) {
219
+ var sValue = value.sliderValue,
220
+ from = value.from,
221
+ to = value.to;
222
+ var fromD = dayjs(from, format, true);
223
+ var toD = dayjs(to, format, true);
224
+ var safeFrom = fromD.isValid() ? fromD : dayjs(from);
225
+ var safeTo = toD.isValid() ? toD : dayjs(to);
226
+ setRangeByDate(safeFrom, safeTo);
227
+ if (sValue !== null && sValue !== undefined) {
228
+ setIsRecent(true);
229
+ setSliderValue(sValue);
230
+ var option = quickTimeOptions.find(function (opt) {
231
+ return opt.id === value.id || opt.value === sValue;
232
+ });
233
+ if (option) {
234
+ setDisplayValue(option.label);
235
+ if (flat) {
236
+ setFlatRadioValue(option.id);
237
+ }
238
+ }
239
+ } else {
240
+ setIsRecent(false);
241
+ setDisplayValue("".concat(from, " - ").concat(to));
242
+ if (flat) {
243
+ setFlatRadioValue(undefined);
244
+ }
245
+ }
246
+ } else if (quickTimeOptions.length > 0) {
247
+ var defaultOption = quickTimeOptions[0];
248
+ var _to = dayjs();
249
+ var _from = dayjs().subtract(defaultOption.diff, 'millisecond');
250
+ setSliderValue(defaultOption.value);
251
+ setDisplayValue(defaultOption.label);
252
+ setRangeByDate(_from, _to);
253
+ if (flat) {
254
+ setFlatRadioValue(defaultOption.id);
255
+ }
256
+ }
257
+ }, [value, quickTimeOptions, flat, format, setRangeByDate]);
258
+ var handleRecentSave = useCallback(function () {
259
+ var option = quickTimeOptions.find(function (opt) {
260
+ return opt.value === sliderValue;
261
+ });
262
+ if (!option) {
263
+ return;
264
+ }
265
+ var to = Date.now();
266
+ var from = to - option.diff;
267
+ var fromDay = dayjs(from);
268
+ var toDay = dayjs(to);
269
+ setRangeByDate(fromDay, toDay);
270
+ var timeInfo = {
271
+ inputValue: option.label,
272
+ from: fromDay.format(format),
273
+ to: toDay.format(format),
274
+ diff: option.diff,
275
+ sliderValue: sliderValue,
276
+ interval: option.interval,
277
+ timeUnitId: option.timeUnitId,
278
+ id: option.id
279
+ };
280
+ setDisplayValue(timeInfo.inputValue);
281
+ setVisible(false);
282
+ onChange === null || onChange === void 0 || onChange(timeInfo);
283
+ }, [sliderValue, format, onChange, quickTimeOptions, setRangeByDate]);
284
+ var handleCustomRangeChange = useCallback(function (dates) {
285
+ if ((dates === null || dates === void 0 ? void 0 : dates.length) === 2) {
286
+ setCustomTimeRange(dates);
287
+ }
288
+ }, []);
289
+ var commitCustomRange = useCallback(function () {
290
+ var from = customTimeRange[0].format(format);
291
+ var to = customTimeRange[1].format(format);
292
+ var diff = customTimeRange[1].valueOf() - customTimeRange[0].valueOf();
293
+ var interval = calculateInterval(from, to);
294
+ var inputValue = "".concat(from, " - ").concat(to);
295
+ setSelectTimeRange([dayjs(customTimeRange[0].valueOf()), dayjs(customTimeRange[1].valueOf())]);
296
+ var timeInfo = _objectSpread({
297
+ inputValue: inputValue,
298
+ from: from,
299
+ to: to,
300
+ diff: diff,
301
+ sliderValue: null
302
+ }, interval);
303
+ setDisplayValue(inputValue);
304
+ setVisible(false);
305
+ onChange === null || onChange === void 0 || onChange(timeInfo);
306
+ }, [customTimeRange, format, calculateInterval, onChange]);
307
+ var wrappedDisabledDateForCalendar = useCallback(function (current, options) {
308
+ var _options$from$map, _options$from;
309
+ if (!disabledDate) {
310
+ return false;
311
+ }
312
+ var fromArr = (_options$from$map = options === null || options === void 0 || (_options$from = options.from) === null || _options$from === void 0 ? void 0 : _options$from.map(function (item) {
313
+ return dayjs(item.valueOf());
314
+ })) !== null && _options$from$map !== void 0 ? _options$from$map : [];
315
+ var currentDayjs = current ? dayjs(current.valueOf()) : null;
316
+ return disabledDate(currentDayjs, {
317
+ from: fromArr
318
+ });
319
+ }, [disabledDate]);
320
+ var wrappedDisabledDateForAntd = useCallback(function (current, info) {
321
+ if (!disabledDate) {
322
+ return false;
323
+ }
324
+ var fromArr = info.from ? [info.from] : [];
325
+ return disabledDate(current, {
326
+ from: fromArr
327
+ });
328
+ }, [disabledDate]);
329
+ var handleFlatRadioChange = useCallback(function (e) {
330
+ var selectedId = e.target.value;
331
+ setFlatRadioValue(selectedId);
332
+ var option = quickTimeOptions.find(function (opt) {
333
+ return opt.id === selectedId;
334
+ });
335
+ if (!option) {
336
+ return;
337
+ }
338
+ var to = dayjs();
339
+ var from = dayjs().subtract(option.diff, 'millisecond');
340
+ setRangeByDate(from, to);
341
+ var timeInfo = {
342
+ inputValue: option.label,
343
+ from: from.format(format),
344
+ to: to.format(format),
345
+ diff: option.diff,
346
+ sliderValue: option.value,
347
+ interval: option.interval,
348
+ timeUnitId: option.timeUnitId,
349
+ id: option.id
350
+ };
351
+ onChange === null || onChange === void 0 || onChange(timeInfo);
352
+ }, [quickTimeOptions, format, onChange, setRangeByDate]);
353
+ var handleFlatRangeChange = useCallback(function (dates) {
354
+ if (!(dates !== null && dates !== void 0 && dates[0]) || !(dates !== null && dates !== void 0 && dates[1])) {
355
+ return;
356
+ }
357
+ var _dates = _slicedToArray(dates, 2),
358
+ from = _dates[0],
359
+ to = _dates[1];
360
+ setRangeByDate(from, to);
361
+ setFlatRadioValue(undefined);
362
+ var diff = to.valueOf() - from.valueOf();
363
+ var interval = calculateInterval(from.format(format), to.format(format));
364
+ var timeInfo = _objectSpread({
365
+ inputValue: "".concat(from.format(format), " - ").concat(to.format(format)),
366
+ from: from.format(format),
367
+ to: to.format(format),
368
+ diff: diff,
369
+ sliderValue: null
370
+ }, interval);
371
+ onChange === null || onChange === void 0 || onChange(timeInfo);
372
+ }, [format, calculateInterval, onChange, setRangeByDate]);
373
+ var popoverContent = /*#__PURE__*/React.createElement("div", {
374
+ className: "hc-date-range-picker-content"
375
+ }, /*#__PURE__*/React.createElement("div", {
376
+ className: "hc-date-range-picker-header",
377
+ style: isRecent ? undefined : {
378
+ borderBottom: 'none'
379
+ }
380
+ }, /*#__PURE__*/React.createElement("div", {
381
+ className: "hc-date-range-picker-switch"
382
+ }, /*#__PURE__*/React.createElement("span", {
383
+ style: {
384
+ color: isRecent ? PRIMARY : TEXT_SECONDARY
385
+ }
386
+ }, i18n.recent), /*#__PURE__*/React.createElement(Switch, {
387
+ checked: !isRecent,
388
+ onChange: function onChange(checked) {
389
+ return setIsRecent(!checked);
390
+ },
391
+ size: "small",
392
+ style: {
393
+ margin: '0 8px'
394
+ }
395
+ }), /*#__PURE__*/React.createElement("span", {
396
+ style: {
397
+ color: isRecent ? TEXT_SECONDARY : PRIMARY
398
+ }
399
+ }, i18n.custom)), /*#__PURE__*/React.createElement(CloseOutlined, {
400
+ className: "hc-date-range-picker-close",
401
+ onClick: function onClick() {
402
+ return setVisible(false);
403
+ }
404
+ })), /*#__PURE__*/React.createElement("div", {
405
+ className: "hc-date-range-picker-body"
406
+ }, isRecent ? /*#__PURE__*/React.createElement("div", {
407
+ className: "hc-date-range-picker-recent"
408
+ }, /*#__PURE__*/React.createElement(Slider, {
409
+ marks: marks,
410
+ max: sliderRange.max,
411
+ min: sliderRange.min,
412
+ step: null,
413
+ value: sliderValue,
414
+ onChange: setSliderValue,
415
+ tooltip: {
416
+ open: false
417
+ }
418
+ }), /*#__PURE__*/React.createElement("div", {
419
+ className: "hc-date-range-picker-footer"
420
+ }, /*#__PURE__*/React.createElement(Button, {
421
+ type: "primary",
422
+ size: "small",
423
+ onClick: handleRecentSave
424
+ }, i18n.confirm))) : /*#__PURE__*/React.createElement("div", {
425
+ className: "hc-date-range-picker-custom"
426
+ }, /*#__PURE__*/React.createElement(RangeCalendar, {
427
+ showToday: false,
428
+ showWeekNumber: false,
429
+ disabledDate: disabledDate ? wrappedDisabledDateForCalendar : undefined,
430
+ selectedValue: customTimeRange,
431
+ onOk: commitCustomRange,
432
+ locale: CALENDAR_LOCALE_MAP[currentLocale],
433
+ showOk: true,
434
+ onChange: handleCustomRangeChange,
435
+ format: format,
436
+ timePicker: /*#__PURE__*/React.createElement(TimePickerPanel, null)
437
+ }))));
438
+ return /*#__PURE__*/React.createElement("div", {
439
+ className: "hc-date-range-picker-wrapper ".concat(flat ? 'hc-date-range-picker-flat' : '')
440
+ }, flat ? /*#__PURE__*/React.createElement("div", {
441
+ className: "hc-date-range-picker-flat-content"
442
+ }, /*#__PURE__*/React.createElement(Radio.Group, {
443
+ className: "hc-date-range-picker-flat-radio-group",
444
+ buttonStyle: "solid",
445
+ value: flatRadioValue,
446
+ onChange: handleFlatRadioChange
447
+ }, quickTimeOptions.map(function (item) {
448
+ return /*#__PURE__*/React.createElement(Radio.Button, {
449
+ key: item.id,
450
+ value: item.id
451
+ }, item.label);
452
+ })), /*#__PURE__*/React.createElement(RangePicker, {
453
+ allowClear: false,
454
+ disabledDate: disabledDate ? wrappedDisabledDateForAntd : undefined,
455
+ format: format,
456
+ showTime: true,
457
+ style: {
458
+ minWidth: 320
459
+ },
460
+ value: selectTimeRange,
461
+ onChange: handleFlatRangeChange
462
+ })) : /*#__PURE__*/React.createElement(Popover, {
463
+ content: popoverContent,
464
+ trigger: "click",
465
+ open: visible && !disabled,
466
+ onOpenChange: function onOpenChange(open) {
467
+ return !disabled && setVisible(open);
468
+ },
469
+ placement: placement,
470
+ overlayClassName: "hc-date-range-picker-popover"
471
+ }, /*#__PURE__*/React.createElement(Input, {
472
+ value: displayValue,
473
+ readOnly: true,
474
+ suffix: /*#__PURE__*/React.createElement(CalendarOutlined, null),
475
+ className: "hc-date-range-picker-input",
476
+ style: {
477
+ width: width,
478
+ cursor: disabled ? 'not-allowed' : 'pointer'
479
+ },
480
+ disabled: disabled
481
+ })));
482
+ };
483
+ export default DateRangePicker;
@@ -0,0 +1,196 @@
1
+ @hc-primary: var(--ant-color-primary, #1677ff);
2
+
3
+ .hc-date-range-picker-wrapper {
4
+ position: relative;
5
+ display: inline-block;
6
+
7
+ .hc-date-range-picker-input {
8
+ cursor: pointer;
9
+
10
+ .ant-input[disabled] {
11
+ color: rgba(0, 0, 0, 25%);
12
+ background-color: #f5f5f5;
13
+ cursor: not-allowed;
14
+ }
15
+ }
16
+
17
+ &.hc-date-range-picker-flat {
18
+ display: block;
19
+
20
+ .hc-date-range-picker-flat-content {
21
+ display: flex;
22
+ gap: 8px;
23
+ align-items: center;
24
+ }
25
+
26
+ .hc-date-range-picker-flat-radio-group {
27
+ display: inline-flex;
28
+ flex-wrap: nowrap;
29
+ gap: 3px;
30
+ margin: 0;
31
+ padding: 3px;
32
+ background: rgba(40, 105, 246, 10%);
33
+ border-radius: 4px;
34
+
35
+ .ant-radio-button-wrapper {
36
+ height: 26px;
37
+ padding: 0 12px;
38
+ line-height: 26px;
39
+ background: none;
40
+ border: none;
41
+ border-radius: 4px;
42
+
43
+ &:not(:first-child)::before {
44
+ width: 0;
45
+ }
46
+
47
+ &.ant-radio-button-wrapper-checked {
48
+ color: @hc-primary;
49
+ font-weight: 500;
50
+ background: #fff;
51
+ box-shadow: 0 1px 10px #00000014;
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ .hc-date-range-picker-popover {
59
+ .ant-popover-inner-content {
60
+ padding: 0;
61
+ }
62
+
63
+ .hc-date-range-picker-content {
64
+ min-width: 424px;
65
+ background: #fff;
66
+
67
+ .hc-date-range-picker-header {
68
+ display: flex;
69
+ align-items: center;
70
+ justify-content: space-between;
71
+ height: 55px;
72
+ padding: 0 16px;
73
+ border-bottom: 1px solid #d9d9d9;
74
+
75
+ .hc-date-range-picker-switch {
76
+ display: flex;
77
+ align-items: center;
78
+ font-size: 14px;
79
+
80
+ span {
81
+ transition: color 0.3s;
82
+ }
83
+ }
84
+
85
+ .hc-date-range-picker-close {
86
+ color: rgba(0, 0, 0, 45%);
87
+ font-size: 14px;
88
+ cursor: pointer;
89
+ transition: color 0.3s;
90
+
91
+ &:hover {
92
+ color: rgba(0, 0, 0, 75%);
93
+ }
94
+ }
95
+ }
96
+
97
+ .hc-date-range-picker-body {
98
+ padding: 0;
99
+
100
+ .hc-date-range-picker-recent {
101
+ padding: 16px;
102
+
103
+ .ant-slider {
104
+ margin: 10px 20px 45px;
105
+ }
106
+
107
+ .hc-date-range-picker-footer {
108
+ display: flex;
109
+ justify-content: flex-end;
110
+ margin-top: 16px;
111
+ }
112
+ }
113
+
114
+ .hc-date-range-picker-custom {
115
+ .hc-date-range-picker-range {
116
+ width: 100%;
117
+ }
118
+
119
+ .hc-date-range-picker-tip {
120
+ margin-top: 8px;
121
+ color: #ff4d4f;
122
+ font-size: 12px;
123
+ }
124
+
125
+ .hc-date-range-picker-footer {
126
+ display: flex;
127
+ justify-content: flex-end;
128
+ margin-top: 16px;
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+ .hc-date-range-picker-custom {
136
+ .rc-calendar {
137
+ border: none;
138
+ box-shadow: none;
139
+ }
140
+
141
+ .rc-calendar-range {
142
+ width: fit-content;
143
+ }
144
+
145
+ .rc-calendar-input-wrap {
146
+ border-top: 1px solid #d9d9d9;
147
+ }
148
+
149
+ .rc-calendar-footer {
150
+ display: flex;
151
+ align-items: center;
152
+ justify-content: flex-end;
153
+
154
+ .rc-calendar-footer-btn {
155
+ display: flex;
156
+ align-items: center;
157
+
158
+ .rc-calendar-ok-btn {
159
+ line-height: 24px;
160
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 12%);
161
+ background-color: @hc-primary;
162
+ border-color: @hc-primary;
163
+ border-radius: 4px;
164
+ box-shadow: 0 2px 0 rgba(0, 0, 0, 4.5%);
165
+
166
+ &:hover {
167
+ background: #528eff;
168
+ border-color: #528eff;
169
+ }
170
+ }
171
+ }
172
+ }
173
+
174
+ .rc-calendar-ok-btn {
175
+ height: 24px;
176
+ padding: 0 15px;
177
+ color: #fff;
178
+ font-size: 12px;
179
+ background-color: #1890ff;
180
+ border-color: #1890ff;
181
+ border-radius: 2px;
182
+
183
+ &:hover {
184
+ background-color: #40a9ff;
185
+ border-color: #40a9ff;
186
+ }
187
+ }
188
+
189
+ .rc-calendar-today-btn {
190
+ color: #1890ff;
191
+
192
+ &:hover {
193
+ color: #40a9ff;
194
+ }
195
+ }
196
+ }
@@ -0,0 +1,23 @@
1
+ import type { ButtonProps, PopoverProps } from 'antd';
2
+ import React from 'react';
3
+ import './index.less';
4
+ export interface DeleteConfirmProps {
5
+ onDelete: () => void;
6
+ title?: string;
7
+ content?: string;
8
+ placement?: PopoverProps['placement'];
9
+ type?: ButtonProps['type'];
10
+ danger?: boolean;
11
+ size?: ButtonProps['size'];
12
+ ghost?: boolean;
13
+ disabled?: boolean;
14
+ className?: string;
15
+ /** 是否为图标删除按钮(仅 isDelete 为 true 时生效) */
16
+ isIcon?: boolean;
17
+ deleteText?: string;
18
+ /** 是否为删除二次确认,false 时确认按钮为主按钮样式 */
19
+ isDelete?: boolean;
20
+ }
21
+ declare const DeleteConfirm: React.FC<DeleteConfirmProps>;
22
+ export { deleteConfirmLocaleZhCN } from './locale';
23
+ export default DeleteConfirm;