hc-busin-components 1.0.2 → 1.0.4
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.
- package/dist/CascaderCluster/index.js +46 -37
- package/dist/CombinTable/index.js +30 -8
- package/dist/CombinTable/styles/index.d.ts +6 -0
- package/dist/CombinTable/styles/index.js +9 -5
- package/dist/CombinTable/types/index.d.ts +7 -4
- package/dist/CombineSearch/components/Tags.js +18 -8
- package/dist/CombineSearch/style/index.d.ts +1 -0
- package/dist/CombineSearch/style/index.js +4 -3
- package/dist/DateRangePicker/index.d.ts +17 -1
- package/dist/DateRangePicker/index.js +221 -103
- package/dist/DateRangePicker/index.less +50 -17
- package/dist/HCDrawer/index.d.ts +14 -0
- package/dist/HCDrawer/index.js +307 -0
- package/dist/HCDrawer/index.less +30 -0
- package/dist/HCModal/index.d.ts +9 -0
- package/dist/HCModal/index.js +50 -0
- package/dist/HCModal/index.less +29 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +2 -0
- package/package.json +1 -1
|
@@ -1,9 +1,3 @@
|
|
|
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
1
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
2
|
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
3
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -14,8 +8,14 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
14
8
|
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
9
|
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
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
|
+
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); }
|
|
17
17
|
import { CalendarOutlined, CloseOutlined } from '@ant-design/icons';
|
|
18
|
-
import { Button, ConfigProvider, DatePicker, Input, Popover,
|
|
18
|
+
import { Button, ConfigProvider, DatePicker, Input, Popover, Segmented, Slider, Switch } from 'antd';
|
|
19
19
|
import dayjs from 'dayjs';
|
|
20
20
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
21
21
|
import moment from 'moment';
|
|
@@ -24,56 +24,55 @@ import enUS from 'rc-calendar/lib/locale/en_US';
|
|
|
24
24
|
import zhCN from 'rc-calendar/lib/locale/zh_CN';
|
|
25
25
|
import zhHK from 'rc-calendar/lib/locale/zh_TW';
|
|
26
26
|
import TimePickerPanel from 'rc-time-picker/lib/Panel';
|
|
27
|
-
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
27
|
+
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
28
28
|
import 'rc-calendar/assets/index.css';
|
|
29
29
|
import 'rc-time-picker/assets/index.css';
|
|
30
30
|
import "./index.less";
|
|
31
31
|
dayjs.extend(customParseFormat);
|
|
32
32
|
var RangePicker = DatePicker.RangePicker;
|
|
33
33
|
var DEFAULT_DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
|
|
34
|
-
var
|
|
34
|
+
var DEFAULT_QUICK_TIME_OPTION_PRESETS = [{
|
|
35
35
|
id: 1,
|
|
36
36
|
value: 1,
|
|
37
|
-
label: '5分钟',
|
|
38
37
|
diff: 5 * 60 * 1000,
|
|
39
38
|
interval: 1,
|
|
40
39
|
timeUnitId: 1
|
|
41
40
|
}, {
|
|
42
41
|
id: 2,
|
|
43
42
|
value: 2,
|
|
44
|
-
label: '1小时',
|
|
45
43
|
diff: 60 * 60 * 1000,
|
|
46
44
|
interval: 2,
|
|
47
45
|
timeUnitId: 2
|
|
48
46
|
}, {
|
|
49
47
|
id: 3,
|
|
50
48
|
value: 3,
|
|
51
|
-
label: '6小时',
|
|
52
49
|
diff: 6 * 60 * 60 * 1000,
|
|
53
50
|
interval: 4,
|
|
54
51
|
timeUnitId: 2
|
|
55
52
|
}, {
|
|
56
53
|
id: 4,
|
|
57
54
|
value: 4,
|
|
58
|
-
label: '12小时',
|
|
59
55
|
diff: 12 * 60 * 60 * 1000,
|
|
60
56
|
interval: 5,
|
|
61
57
|
timeUnitId: 4
|
|
62
58
|
}, {
|
|
63
59
|
id: 5,
|
|
64
60
|
value: 5,
|
|
65
|
-
label: '1天',
|
|
66
61
|
diff: 24 * 60 * 60 * 1000,
|
|
67
62
|
interval: 6,
|
|
68
63
|
timeUnitId: 5
|
|
69
64
|
}, {
|
|
70
65
|
id: 6,
|
|
71
66
|
value: 6,
|
|
72
|
-
label: '7天',
|
|
73
67
|
diff: 7 * 24 * 60 * 60 * 1000,
|
|
74
68
|
interval: 5,
|
|
75
69
|
timeUnitId: 5
|
|
76
70
|
}];
|
|
71
|
+
var DEFAULT_QUICK_TIME_OPTION_LABELS = {
|
|
72
|
+
'zh-CN': ['5分钟', '1小时', '6小时', '12小时', '1天', '7天'],
|
|
73
|
+
'zh-HK': ['5分鐘', '1小時', '6小時', '12小時', '1天', '7天'],
|
|
74
|
+
'en-US': ['5m', '1h', '6h', '12h', '1d', '7d']
|
|
75
|
+
};
|
|
77
76
|
var LOCALE_TEXT = {
|
|
78
77
|
'zh-CN': {
|
|
79
78
|
recent: '最近',
|
|
@@ -98,21 +97,83 @@ var CALENDAR_LOCALE_MAP = {
|
|
|
98
97
|
};
|
|
99
98
|
var PRIMARY = 'var(--ant-color-primary, #1677ff)';
|
|
100
99
|
var TEXT_SECONDARY = 'rgba(0, 0, 0, 0.65)';
|
|
100
|
+
var getDefaultQuickTimeOptions = function getDefaultQuickTimeOptions(locale) {
|
|
101
|
+
return DEFAULT_QUICK_TIME_OPTION_PRESETS.map(function (item, index) {
|
|
102
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
103
|
+
label: DEFAULT_QUICK_TIME_OPTION_LABELS[locale][index]
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
var getSafeDayjs = function getSafeDayjs(value, format) {
|
|
108
|
+
var strictValue = dayjs(value, format, true);
|
|
109
|
+
return strictValue.isValid() ? strictValue : dayjs(value);
|
|
110
|
+
};
|
|
111
|
+
var getPickerStateSnapshot = function getPickerStateSnapshot(value, format, quickTimeOptions) {
|
|
112
|
+
var _quickTimeOptions$;
|
|
113
|
+
var defaultOption = (_quickTimeOptions$ = quickTimeOptions[0]) !== null && _quickTimeOptions$ !== void 0 ? _quickTimeOptions$ : getDefaultQuickTimeOptions('zh-CN')[0];
|
|
114
|
+
var defaultTo = dayjs();
|
|
115
|
+
var defaultFrom = dayjs().subtract(defaultOption.diff, 'millisecond');
|
|
116
|
+
if (!value) {
|
|
117
|
+
return {
|
|
118
|
+
isRecent: true,
|
|
119
|
+
sliderValue: defaultOption.value,
|
|
120
|
+
selectTimeRange: [defaultFrom, defaultTo],
|
|
121
|
+
customTimeRange: [moment(defaultFrom.valueOf()), moment(defaultTo.valueOf())],
|
|
122
|
+
displayValue: defaultOption.label,
|
|
123
|
+
flatRadioValue: defaultOption.id
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
var safeFrom = getSafeDayjs(value.from, format);
|
|
127
|
+
var safeTo = getSafeDayjs(value.to, format);
|
|
128
|
+
if (value.sliderValue !== null && value.sliderValue !== undefined) {
|
|
129
|
+
var _matchedOption$value, _ref, _matchedOption$label;
|
|
130
|
+
var matchedOption = quickTimeOptions.find(function (option) {
|
|
131
|
+
return option.id === value.id || option.value === value.sliderValue;
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
isRecent: true,
|
|
135
|
+
sliderValue: (_matchedOption$value = matchedOption === null || matchedOption === void 0 ? void 0 : matchedOption.value) !== null && _matchedOption$value !== void 0 ? _matchedOption$value : value.sliderValue,
|
|
136
|
+
selectTimeRange: [safeFrom, safeTo],
|
|
137
|
+
customTimeRange: [moment(safeFrom.valueOf()), moment(safeTo.valueOf())],
|
|
138
|
+
displayValue: (_ref = (_matchedOption$label = matchedOption === null || matchedOption === void 0 ? void 0 : matchedOption.label) !== null && _matchedOption$label !== void 0 ? _matchedOption$label : value.inputValue) !== null && _ref !== void 0 ? _ref : "".concat(value.from, " - ").concat(value.to),
|
|
139
|
+
flatRadioValue: matchedOption === null || matchedOption === void 0 ? void 0 : matchedOption.id
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
isRecent: false,
|
|
144
|
+
sliderValue: defaultOption.value,
|
|
145
|
+
selectTimeRange: [safeFrom, safeTo],
|
|
146
|
+
customTimeRange: [moment(safeFrom.valueOf()), moment(safeTo.valueOf())],
|
|
147
|
+
displayValue: value.inputValue || "".concat(value.from, " - ").concat(value.to),
|
|
148
|
+
flatRadioValue: undefined
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
var normalizeDisabledDateFrom = function normalizeDisabledDateFrom(source) {
|
|
152
|
+
if (!source) {
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
var rawFrom = _typeof(source) === 'object' && !Array.isArray(source) && 'from' in source ? source.from : source;
|
|
156
|
+
var fromList = Array.isArray(rawFrom) ? rawFrom : [rawFrom];
|
|
157
|
+
return fromList.filter(function (item) {
|
|
158
|
+
return Boolean(item);
|
|
159
|
+
}).map(function (item) {
|
|
160
|
+
return dayjs(item.valueOf());
|
|
161
|
+
});
|
|
162
|
+
};
|
|
101
163
|
var DateRangePicker = function DateRangePicker(props) {
|
|
102
|
-
var _quickTimeOptions$2;
|
|
103
164
|
var onChange = props.onChange,
|
|
104
165
|
value = props.value,
|
|
105
166
|
_props$format = props.format,
|
|
106
167
|
format = _props$format === void 0 ? DEFAULT_DATE_TIME_FORMAT : _props$format,
|
|
107
168
|
_props$placement = props.placement,
|
|
108
169
|
placement = _props$placement === void 0 ? 'bottomLeft' : _props$placement,
|
|
109
|
-
|
|
110
|
-
quickTimeOptions = _props$quickTimeOptio === void 0 ? DEFAULT_QUICK_TIME_OPTIONS : _props$quickTimeOptio,
|
|
170
|
+
quickTimeOptionsProp = props.quickTimeOptions,
|
|
111
171
|
disabledDate = props.disabledDate,
|
|
112
172
|
width = props.width,
|
|
113
173
|
disabled = props.disabled,
|
|
114
174
|
_props$flat = props.flat,
|
|
115
|
-
flat = _props$flat === void 0 ? false : _props$flat
|
|
175
|
+
flat = _props$flat === void 0 ? false : _props$flat,
|
|
176
|
+
localeProp = props.locale;
|
|
116
177
|
var _useContext = useContext(ConfigProvider.ConfigContext),
|
|
117
178
|
antdLocale = _useContext.locale;
|
|
118
179
|
var currentLocale = useMemo(function () {
|
|
@@ -128,40 +189,53 @@ var DateRangePicker = function DateRangePicker(props) {
|
|
|
128
189
|
}
|
|
129
190
|
return 'zh-CN';
|
|
130
191
|
}, [antdLocale]);
|
|
131
|
-
var
|
|
132
|
-
return
|
|
192
|
+
var defaultQuickTimeOptions = useMemo(function () {
|
|
193
|
+
return getDefaultQuickTimeOptions(currentLocale);
|
|
133
194
|
}, [currentLocale]);
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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;
|
|
195
|
+
var quickTimeOptions = useMemo(function () {
|
|
196
|
+
return quickTimeOptionsProp !== null && quickTimeOptionsProp !== void 0 && quickTimeOptionsProp.length ? quickTimeOptionsProp : defaultQuickTimeOptions;
|
|
197
|
+
}, [quickTimeOptionsProp, defaultQuickTimeOptions]);
|
|
198
|
+
var mergedLocale = useMemo(function () {
|
|
199
|
+
return _objectSpread(_objectSpread({}, LOCALE_TEXT[currentLocale]), localeProp);
|
|
200
|
+
}, [currentLocale, localeProp]);
|
|
201
|
+
var _useState = useState(function () {
|
|
202
|
+
return getPickerStateSnapshot(value, format, quickTimeOptions);
|
|
145
203
|
}),
|
|
204
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
205
|
+
initialState = _useState2[0];
|
|
206
|
+
var _useState3 = useState(false),
|
|
207
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
208
|
+
visible = _useState4[0],
|
|
209
|
+
setVisible = _useState4[1];
|
|
210
|
+
var _useState5 = useState(initialState.isRecent),
|
|
146
211
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
var _useState7 = useState(
|
|
212
|
+
isRecent = _useState6[0],
|
|
213
|
+
setIsRecent = _useState6[1];
|
|
214
|
+
var _useState7 = useState(initialState.sliderValue),
|
|
150
215
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
var _useState9 = useState(
|
|
216
|
+
sliderValue = _useState8[0],
|
|
217
|
+
setSliderValue = _useState8[1];
|
|
218
|
+
var _useState9 = useState(initialState.selectTimeRange),
|
|
154
219
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
var _useState11 = useState(
|
|
220
|
+
selectTimeRange = _useState10[0],
|
|
221
|
+
setSelectTimeRange = _useState10[1];
|
|
222
|
+
var _useState11 = useState(initialState.customTimeRange),
|
|
158
223
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
var _useState13 = useState(
|
|
224
|
+
customTimeRange = _useState12[0],
|
|
225
|
+
setCustomTimeRange = _useState12[1];
|
|
226
|
+
var _useState13 = useState(initialState.displayValue),
|
|
162
227
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
163
|
-
|
|
164
|
-
|
|
228
|
+
displayValue = _useState14[0],
|
|
229
|
+
setDisplayValue = _useState14[1];
|
|
230
|
+
var _useState15 = useState(initialState.flatRadioValue),
|
|
231
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
232
|
+
flatRadioValue = _useState16[0],
|
|
233
|
+
setFlatRadioValue = _useState16[1];
|
|
234
|
+
var flatSegmentedRef = useRef(null);
|
|
235
|
+
var _useState17 = useState({}),
|
|
236
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
237
|
+
flatSegmentedThumbStyle = _useState18[0],
|
|
238
|
+
setFlatSegmentedThumbStyle = _useState18[1];
|
|
165
239
|
var marks = useMemo(function () {
|
|
166
240
|
var marksObj = {};
|
|
167
241
|
quickTimeOptions.forEach(function (option) {
|
|
@@ -178,10 +252,70 @@ var DateRangePicker = function DateRangePicker(props) {
|
|
|
178
252
|
max: Math.max.apply(Math, _toConsumableArray(values))
|
|
179
253
|
};
|
|
180
254
|
}, [quickTimeOptions]);
|
|
255
|
+
var flatSegmentedOptions = useMemo(function () {
|
|
256
|
+
return quickTimeOptions.map(function (item) {
|
|
257
|
+
return {
|
|
258
|
+
label: item.label,
|
|
259
|
+
value: item.id
|
|
260
|
+
};
|
|
261
|
+
});
|
|
262
|
+
}, [quickTimeOptions]);
|
|
263
|
+
var flatSegmentedTheme = useMemo(function () {
|
|
264
|
+
return {
|
|
265
|
+
cssVar: {
|
|
266
|
+
key: 'hc-date-range-picker-flat-segmented'
|
|
267
|
+
},
|
|
268
|
+
token: {
|
|
269
|
+
borderRadius: 4,
|
|
270
|
+
borderRadiusSM: 4,
|
|
271
|
+
boxShadowTertiary: '0 1px 10px rgba(0, 0, 0, 0.08)',
|
|
272
|
+
colorBgElevated: '#FFFFFF'
|
|
273
|
+
},
|
|
274
|
+
components: {
|
|
275
|
+
Segmented: {
|
|
276
|
+
trackBg: 'rgba(40, 105, 246, 0.1)',
|
|
277
|
+
trackPadding: 3,
|
|
278
|
+
itemColor: 'rgba(0, 0, 0, 0.85)',
|
|
279
|
+
itemHoverColor: 'rgba(0, 0, 0, 0.85)',
|
|
280
|
+
itemSelectedColor: '#2869F6'
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}, []);
|
|
285
|
+
var quickTimeOptionsSignature = useMemo(function () {
|
|
286
|
+
return quickTimeOptions.map(function (item) {
|
|
287
|
+
var _item$interval, _item$timeUnitId;
|
|
288
|
+
return "".concat(item.id, ":").concat(item.value, ":").concat(item.label, ":").concat(item.diff, ":").concat((_item$interval = item.interval) !== null && _item$interval !== void 0 ? _item$interval : '', ":").concat((_item$timeUnitId = item.timeUnitId) !== null && _item$timeUnitId !== void 0 ? _item$timeUnitId : '');
|
|
289
|
+
}).join('|');
|
|
290
|
+
}, [quickTimeOptions]);
|
|
181
291
|
var setRangeByDate = useCallback(function (from, to) {
|
|
182
292
|
setSelectTimeRange([from, to]);
|
|
183
293
|
setCustomTimeRange([moment(from.valueOf()), moment(to.valueOf())]);
|
|
184
294
|
}, []);
|
|
295
|
+
var updateFlatSegmentedThumb = useCallback(function () {
|
|
296
|
+
var _items$find;
|
|
297
|
+
if (!flatSegmentedRef.current || flatRadioValue === undefined) {
|
|
298
|
+
setFlatSegmentedThumbStyle(_defineProperty({}, '--hc-date-range-picker-flat-segmented-thumb-opacity', 0));
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
var rootElement = flatSegmentedRef.current;
|
|
302
|
+
var items = Array.from(rootElement.querySelectorAll('.ant-segmented-item'));
|
|
303
|
+
var targetItem = (_items$find = items.find(function (item) {
|
|
304
|
+
var input = item.querySelector('.ant-segmented-item-input');
|
|
305
|
+
return input === null || input === void 0 ? void 0 : input.checked;
|
|
306
|
+
})) !== null && _items$find !== void 0 ? _items$find : items.find(function (item) {
|
|
307
|
+
var input = item.querySelector('.ant-segmented-item-input');
|
|
308
|
+
return Number(input === null || input === void 0 ? void 0 : input.value) === flatRadioValue;
|
|
309
|
+
});
|
|
310
|
+
var targetLabel = targetItem === null || targetItem === void 0 ? void 0 : targetItem.querySelector('.ant-segmented-item-label');
|
|
311
|
+
if (!targetItem || !targetLabel) {
|
|
312
|
+
setFlatSegmentedThumbStyle(_defineProperty({}, '--hc-date-range-picker-flat-segmented-thumb-opacity', 0));
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
var rootRect = rootElement.getBoundingClientRect();
|
|
316
|
+
var labelRect = targetLabel.getBoundingClientRect();
|
|
317
|
+
setFlatSegmentedThumbStyle(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, '--hc-date-range-picker-flat-segmented-thumb-left', "".concat(labelRect.left - rootRect.left, "px")), '--hc-date-range-picker-flat-segmented-thumb-top', "".concat(labelRect.top - rootRect.top, "px")), '--hc-date-range-picker-flat-segmented-thumb-width', "".concat(labelRect.width, "px")), '--hc-date-range-picker-flat-segmented-thumb-height', "".concat(labelRect.height, "px")), '--hc-date-range-picker-flat-segmented-thumb-opacity', 1));
|
|
318
|
+
}, [flatRadioValue]);
|
|
185
319
|
var calculateInterval = useCallback(function (fromTime, toTime) {
|
|
186
320
|
var diff = dayjs(toTime).valueOf() - dayjs(fromTime).valueOf();
|
|
187
321
|
var hours = diff / (60 * 60 * 1000);
|
|
@@ -215,46 +349,34 @@ var DateRangePicker = function DateRangePicker(props) {
|
|
|
215
349
|
};
|
|
216
350
|
}, []);
|
|
217
351
|
useEffect(function () {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
|
-
}
|
|
352
|
+
var nextState = getPickerStateSnapshot(value, format, quickTimeOptions);
|
|
353
|
+
setIsRecent(nextState.isRecent);
|
|
354
|
+
setSliderValue(nextState.sliderValue);
|
|
355
|
+
setSelectTimeRange(nextState.selectTimeRange);
|
|
356
|
+
setCustomTimeRange(nextState.customTimeRange);
|
|
357
|
+
setDisplayValue(nextState.displayValue);
|
|
358
|
+
setFlatRadioValue(flat ? nextState.flatRadioValue : undefined);
|
|
359
|
+
}, [value, quickTimeOptionsSignature, flat, format, quickTimeOptions]);
|
|
360
|
+
useEffect(function () {
|
|
361
|
+
if (!flat) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
var frameId = window.requestAnimationFrame(function () {
|
|
365
|
+
updateFlatSegmentedThumb();
|
|
366
|
+
});
|
|
367
|
+
var resizeObserver = typeof ResizeObserver === 'undefined' || !flatSegmentedRef.current ? null : new ResizeObserver(function () {
|
|
368
|
+
updateFlatSegmentedThumb();
|
|
369
|
+
});
|
|
370
|
+
if (flatSegmentedRef.current) {
|
|
371
|
+
resizeObserver === null || resizeObserver === void 0 || resizeObserver.observe(flatSegmentedRef.current);
|
|
256
372
|
}
|
|
257
|
-
|
|
373
|
+
window.addEventListener('resize', updateFlatSegmentedThumb);
|
|
374
|
+
return function () {
|
|
375
|
+
window.cancelAnimationFrame(frameId);
|
|
376
|
+
resizeObserver === null || resizeObserver === void 0 || resizeObserver.disconnect();
|
|
377
|
+
window.removeEventListener('resize', updateFlatSegmentedThumb);
|
|
378
|
+
};
|
|
379
|
+
}, [flat, flatSegmentedOptions, updateFlatSegmentedThumb]);
|
|
258
380
|
var handleRecentSave = useCallback(function () {
|
|
259
381
|
var option = quickTimeOptions.find(function (opt) {
|
|
260
382
|
return opt.value === sliderValue;
|
|
@@ -305,13 +427,10 @@ var DateRangePicker = function DateRangePicker(props) {
|
|
|
305
427
|
onChange === null || onChange === void 0 || onChange(timeInfo);
|
|
306
428
|
}, [customTimeRange, format, calculateInterval, onChange]);
|
|
307
429
|
var wrappedDisabledDateForCalendar = useCallback(function (current, options) {
|
|
308
|
-
var _options$from$map, _options$from;
|
|
309
430
|
if (!disabledDate) {
|
|
310
431
|
return false;
|
|
311
432
|
}
|
|
312
|
-
var fromArr = (
|
|
313
|
-
return dayjs(item.valueOf());
|
|
314
|
-
})) !== null && _options$from$map !== void 0 ? _options$from$map : [];
|
|
433
|
+
var fromArr = normalizeDisabledDateFrom(options);
|
|
315
434
|
var currentDayjs = current ? dayjs(current.valueOf()) : null;
|
|
316
435
|
return disabledDate(currentDayjs, {
|
|
317
436
|
from: fromArr
|
|
@@ -326,8 +445,8 @@ var DateRangePicker = function DateRangePicker(props) {
|
|
|
326
445
|
from: fromArr
|
|
327
446
|
});
|
|
328
447
|
}, [disabledDate]);
|
|
329
|
-
var
|
|
330
|
-
var selectedId =
|
|
448
|
+
var handleFlatSegmentedChange = useCallback(function (selectedValue) {
|
|
449
|
+
var selectedId = Number(selectedValue);
|
|
331
450
|
setFlatRadioValue(selectedId);
|
|
332
451
|
var option = quickTimeOptions.find(function (opt) {
|
|
333
452
|
return opt.id === selectedId;
|
|
@@ -383,7 +502,7 @@ var DateRangePicker = function DateRangePicker(props) {
|
|
|
383
502
|
style: {
|
|
384
503
|
color: isRecent ? PRIMARY : TEXT_SECONDARY
|
|
385
504
|
}
|
|
386
|
-
},
|
|
505
|
+
}, mergedLocale.recent), /*#__PURE__*/React.createElement(Switch, {
|
|
387
506
|
checked: !isRecent,
|
|
388
507
|
onChange: function onChange(checked) {
|
|
389
508
|
return setIsRecent(!checked);
|
|
@@ -396,7 +515,7 @@ var DateRangePicker = function DateRangePicker(props) {
|
|
|
396
515
|
style: {
|
|
397
516
|
color: isRecent ? TEXT_SECONDARY : PRIMARY
|
|
398
517
|
}
|
|
399
|
-
},
|
|
518
|
+
}, mergedLocale.custom)), /*#__PURE__*/React.createElement(CloseOutlined, {
|
|
400
519
|
className: "hc-date-range-picker-close",
|
|
401
520
|
onClick: function onClick() {
|
|
402
521
|
return setVisible(false);
|
|
@@ -421,7 +540,7 @@ var DateRangePicker = function DateRangePicker(props) {
|
|
|
421
540
|
type: "primary",
|
|
422
541
|
size: "small",
|
|
423
542
|
onClick: handleRecentSave
|
|
424
|
-
},
|
|
543
|
+
}, mergedLocale.confirm))) : /*#__PURE__*/React.createElement("div", {
|
|
425
544
|
className: "hc-date-range-picker-custom"
|
|
426
545
|
}, /*#__PURE__*/React.createElement(RangeCalendar, {
|
|
427
546
|
showToday: false,
|
|
@@ -439,16 +558,15 @@ var DateRangePicker = function DateRangePicker(props) {
|
|
|
439
558
|
className: "hc-date-range-picker-wrapper ".concat(flat ? 'hc-date-range-picker-flat' : '')
|
|
440
559
|
}, flat ? /*#__PURE__*/React.createElement("div", {
|
|
441
560
|
className: "hc-date-range-picker-flat-content"
|
|
442
|
-
}, /*#__PURE__*/React.createElement(
|
|
443
|
-
|
|
444
|
-
|
|
561
|
+
}, /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
562
|
+
theme: flatSegmentedTheme
|
|
563
|
+
}, /*#__PURE__*/React.createElement(Segmented, {
|
|
564
|
+
ref: flatSegmentedRef,
|
|
565
|
+
className: "hc-date-range-picker-flat-segmented",
|
|
445
566
|
value: flatRadioValue,
|
|
446
|
-
onChange:
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
key: item.id,
|
|
450
|
-
value: item.id
|
|
451
|
-
}, item.label);
|
|
567
|
+
onChange: handleFlatSegmentedChange,
|
|
568
|
+
options: flatSegmentedOptions,
|
|
569
|
+
style: flatSegmentedThumbStyle
|
|
452
570
|
})), /*#__PURE__*/React.createElement(RangePicker, {
|
|
453
571
|
allowClear: false,
|
|
454
572
|
disabledDate: disabledDate ? wrappedDisabledDateForAntd : undefined,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@hc-primary: var(--ant-color-primary, #
|
|
1
|
+
@hc-primary: var(--ant-color-primary, #2869f6);
|
|
2
2
|
|
|
3
3
|
.hc-date-range-picker-wrapper {
|
|
4
4
|
position: relative;
|
|
@@ -23,33 +23,66 @@
|
|
|
23
23
|
align-items: center;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
.hc-date-range-picker-flat-
|
|
26
|
+
.hc-date-range-picker-flat-segmented {
|
|
27
|
+
position: relative;
|
|
27
28
|
display: inline-flex;
|
|
28
29
|
flex-wrap: nowrap;
|
|
29
|
-
gap: 3px;
|
|
30
30
|
margin: 0;
|
|
31
|
-
|
|
32
|
-
background: rgba(40, 105, 246, 10%);
|
|
31
|
+
border: none;
|
|
33
32
|
border-radius: 4px;
|
|
33
|
+
box-shadow: none;
|
|
34
|
+
|
|
35
|
+
&::before {
|
|
36
|
+
position: absolute;
|
|
37
|
+
top: var(--hc-date-range-picker-flat-segmented-thumb-top, 3px);
|
|
38
|
+
left: var(--hc-date-range-picker-flat-segmented-thumb-left, 3px);
|
|
39
|
+
z-index: 0;
|
|
40
|
+
width: var(--hc-date-range-picker-flat-segmented-thumb-width, 0);
|
|
41
|
+
height: var(--hc-date-range-picker-flat-segmented-thumb-height, 26px);
|
|
42
|
+
background: var(--ant-color-bg-elevated, #fff);
|
|
43
|
+
border-radius: var(--ant-border-radius-sm, 4px);
|
|
44
|
+
box-shadow: var(--ant-box-shadow-tertiary, 0 1px 10px #00000014);
|
|
45
|
+
opacity: var(--hc-date-range-picker-flat-segmented-thumb-opacity, 0);
|
|
46
|
+
transition:
|
|
47
|
+
left 0.2s ease,
|
|
48
|
+
top 0.2s ease,
|
|
49
|
+
width 0.2s ease,
|
|
50
|
+
height 0.2s ease,
|
|
51
|
+
opacity 0.2s ease;
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
content: '';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.ant-segmented-group {
|
|
57
|
+
position: relative;
|
|
58
|
+
z-index: 1;
|
|
59
|
+
gap: 3px;
|
|
60
|
+
}
|
|
34
61
|
|
|
35
|
-
.ant-
|
|
62
|
+
.ant-segmented-item {
|
|
36
63
|
height: 26px;
|
|
64
|
+
padding: 0;
|
|
65
|
+
background: transparent;
|
|
66
|
+
box-shadow: none;
|
|
67
|
+
border-radius: 4px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.ant-segmented-item-label {
|
|
71
|
+
min-height: 26px;
|
|
37
72
|
padding: 0 12px;
|
|
38
73
|
line-height: 26px;
|
|
39
|
-
background: none;
|
|
40
|
-
border: none;
|
|
41
74
|
border-radius: 4px;
|
|
75
|
+
}
|
|
42
76
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
77
|
+
.ant-segmented-thumb {
|
|
78
|
+
pointer-events: none;
|
|
79
|
+
opacity: 0;
|
|
80
|
+
}
|
|
46
81
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
box-shadow: 0 1px 10px #00000014;
|
|
52
|
-
}
|
|
82
|
+
.ant-segmented-item-selected,
|
|
83
|
+
.ant-segmented-item-selected:hover {
|
|
84
|
+
background: transparent;
|
|
85
|
+
box-shadow: none;
|
|
53
86
|
}
|
|
54
87
|
}
|
|
55
88
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DrawerProps } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import './index.less';
|
|
4
|
+
export interface HCDrawerProps extends DrawerProps {
|
|
5
|
+
showFooter?: boolean;
|
|
6
|
+
onOk?: () => void | Promise<void>;
|
|
7
|
+
okText?: React.ReactNode;
|
|
8
|
+
cancelText?: React.ReactNode;
|
|
9
|
+
resizable?: boolean;
|
|
10
|
+
minWidth?: number;
|
|
11
|
+
maxWidth?: number;
|
|
12
|
+
}
|
|
13
|
+
declare const HCDrawer: React.FC<HCDrawerProps>;
|
|
14
|
+
export default HCDrawer;
|