@hi-ui/time-picker 4.0.10 → 4.0.12

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.
@@ -12,19 +12,15 @@
12
12
  Object.defineProperty(exports, '__esModule', {
13
13
  value: true
14
14
  });
15
-
16
15
  var index = require('../@types/index.js');
17
-
18
16
  var analysisFormat = require('./analysisFormat.js');
19
-
20
17
  var valueChecker = function valueChecker(info) {
21
18
  var _checkerMap, _disabledMap, _stepMap;
22
-
23
19
  var value = info.value,
24
- format = info.format,
25
- filter = info.filter,
26
- panelType = info.panelType,
27
- step = info.step;
20
+ format = info.format,
21
+ filter = info.filter,
22
+ panelType = info.panelType,
23
+ step = info.step;
28
24
  var selectorTypes = analysisFormat.analysisFormat(format);
29
25
  var checkerMap = (_checkerMap = {}, _checkerMap[index.TimePickerSelectorType.hour] = function (e) {
30
26
  return e >= 0 && e <= 23;
@@ -32,31 +28,26 @@ var valueChecker = function valueChecker(info) {
32
28
  return e >= 0 && e <= 59;
33
29
  }, _checkerMap[index.TimePickerSelectorType.second] = function (e) {
34
30
  return e >= 0 && e <= 59;
35
- }, _checkerMap); // 允许为空的情况
36
-
31
+ }, _checkerMap);
32
+ // 允许为空的情况
37
33
  if (value === '') {
38
34
  return true;
39
35
  }
40
-
41
36
  if (!value) {
42
37
  return false;
43
38
  }
44
-
45
39
  var separateParts = value.split(':').filter(function (item) {
46
40
  return !!item && item.length === 2;
47
41
  }).map(function (item) {
48
42
  return Number(item);
49
43
  });
50
-
51
44
  if (separateParts.length !== selectorTypes.length) {
52
45
  return false;
53
46
  }
54
-
55
47
  var getMatchTypeValue = function getMatchTypeValue(selectorType) {
56
48
  var matchIndex = selectorTypes.indexOf(selectorType);
57
49
  return matchIndex >= 0 ? separateParts[matchIndex] : -1;
58
50
  };
59
-
60
51
  var disabledMap = (_disabledMap = {}, _disabledMap[index.TimePickerSelectorType.hour] = function () {
61
52
  return filter.disabledHours(panelType);
62
53
  }, _disabledMap[index.TimePickerSelectorType.minute] = function () {
@@ -65,22 +56,19 @@ var valueChecker = function valueChecker(info) {
65
56
  return filter.disabledSeconds(getMatchTypeValue(index.TimePickerSelectorType.hour), getMatchTypeValue(index.TimePickerSelectorType.minute), panelType);
66
57
  }, _disabledMap);
67
58
  var stepMap = (_stepMap = {}, _stepMap[index.TimePickerSelectorType.hour] = step.hourStep, _stepMap[index.TimePickerSelectorType.minute] = step.minuteStep, _stepMap[index.TimePickerSelectorType.second] = step.secondStep, _stepMap);
68
-
69
59
  for (var counter = 0; counter < separateParts.length; counter++) {
70
60
  var type = selectorTypes[counter];
71
61
  var stepNumber = stepMap[type];
72
62
  var disabledNumbers = disabledMap[type]();
73
63
  var checker = checkerMap[type];
74
- var checkNumber = separateParts[counter]; // 不符合要求的数字
64
+ var checkNumber = separateParts[counter];
65
+ // 不符合要求的数字
75
66
  // 被禁用的数字
76
67
  // 不符合 step 的数字
77
-
78
68
  if (!checker(checkNumber) || disabledNumbers.includes(checkNumber) || checkNumber % stepNumber !== 0) {
79
69
  return false;
80
70
  }
81
71
  }
82
-
83
72
  return true;
84
73
  };
85
-
86
74
  exports.valueChecker = valueChecker;
@@ -8,11 +8,9 @@
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
  var TimePickerSelectorType;
11
-
12
11
  (function (TimePickerSelectorType) {
13
12
  TimePickerSelectorType[TimePickerSelectorType["hour"] = 1] = "hour";
14
13
  TimePickerSelectorType[TimePickerSelectorType["minute"] = 2] = "minute";
15
14
  TimePickerSelectorType[TimePickerSelectorType["second"] = 3] = "second";
16
15
  })(TimePickerSelectorType || (TimePickerSelectorType = {}));
17
-
18
16
  export { TimePickerSelectorType };
package/lib/esm/Input.js CHANGED
@@ -14,42 +14,39 @@ import { disposeInputValue } from './utils/disposeInputValue.js';
14
14
  import { useLocaleContext } from '@hi-ui/core';
15
15
  var Input = /*#__PURE__*/forwardRef(function (props, ref) {
16
16
  var _cx;
17
-
18
17
  var prefix = props.prefix,
19
- value = props.value,
20
- format = props.format,
21
- hourStep = props.hourStep,
22
- minuteStep = props.minuteStep,
23
- secondStep = props.secondStep,
24
- disabledHours = props.disabledHours,
25
- disabledMinutes = props.disabledMinutes,
26
- disabledSeconds = props.disabledSeconds,
27
- type = props.type,
28
- placeholders = props.placeholders,
29
- _onChange = props.onChange,
30
- _onFocus = props.onFocus,
31
- disabled = props.disabled,
32
- onValidChange = props.onValidChange,
33
- isFitContent = props.isFitContent,
34
- size = props.size;
18
+ value = props.value,
19
+ format = props.format,
20
+ hourStep = props.hourStep,
21
+ minuteStep = props.minuteStep,
22
+ secondStep = props.secondStep,
23
+ disabledHours = props.disabledHours,
24
+ disabledMinutes = props.disabledMinutes,
25
+ disabledSeconds = props.disabledSeconds,
26
+ type = props.type,
27
+ placeholders = props.placeholders,
28
+ _onChange = props.onChange,
29
+ _onFocus = props.onFocus,
30
+ disabled = props.disabled,
31
+ onValidChange = props.onValidChange,
32
+ isFitContent = props.isFitContent,
33
+ size = props.size;
35
34
  var i18n = useLocaleContext();
36
35
  var toText = i18n.get('timePicker.to');
37
36
  var componentClass = useMemo(function () {
38
37
  return prefix + "__input";
39
38
  }, [prefix]);
40
-
41
39
  var _useState = useState(value),
42
- cacheValue = _useState[0],
43
- setCacheValue = _useState[1];
44
-
40
+ cacheValue = _useState[0],
41
+ setCacheValue = _useState[1];
45
42
  var getPanelType = useCallback(function (index) {
46
43
  if (type === 'single') {
47
44
  return 'single';
48
45
  } else {
49
46
  return index === 0 ? 'range-start' : 'range-end';
50
47
  }
51
- }, [type]); // 检查值是否合规
52
-
48
+ }, [type]);
49
+ // 检查值是否合规
53
50
  var validChecker = useCallback(function (checkValue, panelType) {
54
51
  return valueChecker({
55
52
  value: checkValue,
@@ -66,16 +63,14 @@ var Input = /*#__PURE__*/forwardRef(function (props, ref) {
66
63
  },
67
64
  panelType: panelType
68
65
  });
69
- }, [hourStep, minuteStep, secondStep, disabledHours, disabledMinutes, disabledSeconds, format]); // 缓存同步外部
70
-
66
+ }, [hourStep, minuteStep, secondStep, disabledHours, disabledMinutes, disabledSeconds, format]);
67
+ // 缓存同步外部
71
68
  useEffect(function () {
72
69
  setCacheValue(function (pre) {
73
70
  var result = value.slice(0, type === 'single' ? 1 : 2);
74
-
75
71
  if (result.join('') !== pre.join('')) {
76
72
  return result;
77
73
  }
78
-
79
74
  return pre;
80
75
  });
81
76
  }, [value, type]);
@@ -83,7 +78,6 @@ var Input = /*#__PURE__*/forwardRef(function (props, ref) {
83
78
  var valueValid = disposeValue.every(function (item, index) {
84
79
  return validChecker(item, getPanelType(index));
85
80
  });
86
-
87
81
  if (type === 'range' && valueValid) {
88
82
  // 数据格式正确,检查范围数据
89
83
  // 全为空字符串,则认为是合法的(还未选择)
@@ -91,9 +85,8 @@ var Input = /*#__PURE__*/forwardRef(function (props, ref) {
91
85
  return item === '';
92
86
  })) {
93
87
  return true;
94
- } // 结束时间要>开始时间
95
-
96
-
88
+ }
89
+ // 结束时间要>开始时间
97
90
  return disposeValue[1] > disposeValue[0];
98
91
  } else {
99
92
  return valueValid;
@@ -104,26 +97,22 @@ var Input = /*#__PURE__*/forwardRef(function (props, ref) {
104
97
  if (needValid === void 0) {
105
98
  needValid = true;
106
99
  }
107
-
108
100
  var newValue = disposeInputValue(format, disposeValue);
109
101
  var result = [].concat(cacheValue);
110
102
  result[index] = newValue;
111
- setCacheValue(result); // 合法,则通知外部
112
-
103
+ setCacheValue(result);
104
+ // 合法,则通知外部
113
105
  if (!needValid || validChecker(newValue, getPanelType(index))) {
114
106
  return [].concat(result);
115
107
  }
116
-
117
108
  return undefined;
118
109
  };
119
-
120
110
  return /*#__PURE__*/React.createElement("div", {
121
111
  className: componentClass + "__wrapper"
122
112
  }, /*#__PURE__*/React.createElement("input", {
123
113
  className: componentClass + "__interact-area",
124
114
  onChange: function onChange(e) {
125
115
  var result = dispose(e.target.value);
126
-
127
116
  if (result) {
128
117
  _onChange(result);
129
118
  }
@@ -137,8 +126,8 @@ var Input = /*#__PURE__*/forwardRef(function (props, ref) {
137
126
  }), /*#__PURE__*/React.createElement("div", {
138
127
  className: componentClass + "__shadow-text"
139
128
  }, matchValue || placeholders[index]));
140
- }, [componentClass, disabled, placeholders, isFitContent, format, cacheValue, validChecker, getPanelType, _onChange, _onFocus]); // 通知外部,输入框内容合法性变更
141
-
129
+ }, [componentClass, disabled, placeholders, isFitContent, format, cacheValue, validChecker, getPanelType, _onChange, _onFocus]);
130
+ // 通知外部,输入框内容合法性变更
142
131
  useEffect(function () {
143
132
  onValidChange(judgeIsValid(cacheValue));
144
133
  }, [judgeIsValid, cacheValue, onValidChange]);
package/lib/esm/Panel.js CHANGED
@@ -12,19 +12,18 @@ import { analysisFormat } from './utils/analysisFormat.js';
12
12
  import { generateSelectorData } from './utils/generateSelectorData.js';
13
13
  import { cx } from '@hi-ui/classname';
14
14
  import { Selector, SelectorPosition } from './Selector.js';
15
-
16
15
  var Panel = function Panel(props) {
17
16
  var hourStep = props.hourStep,
18
- secondStep = props.secondStep,
19
- minuteStep = props.minuteStep,
20
- disabledHours = props.disabledHours,
21
- disabledMinutes = props.disabledMinutes,
22
- disabledSeconds = props.disabledSeconds,
23
- prefix = props.prefix,
24
- format = props.format,
25
- value = props.value,
26
- panel = props.panel,
27
- _onChange = props.onChange;
17
+ secondStep = props.secondStep,
18
+ minuteStep = props.minuteStep,
19
+ disabledHours = props.disabledHours,
20
+ disabledMinutes = props.disabledMinutes,
21
+ disabledSeconds = props.disabledSeconds,
22
+ prefix = props.prefix,
23
+ format = props.format,
24
+ value = props.value,
25
+ panel = props.panel,
26
+ _onChange = props.onChange;
28
27
  var componentPrefix = useMemo(function () {
29
28
  return prefix + "__panel";
30
29
  }, [prefix]);
@@ -55,7 +54,8 @@ var Panel = function Panel(props) {
55
54
  selectorTypes: selectorTypes,
56
55
  separateValue: separateValue
57
56
  });
58
- }, [disabledHours, disabledMinutes, disabledSeconds, secondStep, hourStep, minuteStep, panel, selectorTypes, separateValue]); // const renderHeader = useCallback(() => {
57
+ }, [disabledHours, disabledMinutes, disabledSeconds, secondStep, hourStep, minuteStep, panel, selectorTypes, separateValue]);
58
+ // const renderHeader = useCallback(() => {
59
59
  // return (
60
60
  // <div className={`${componentPrefix}__header`}>
61
61
  // {selectorTypes.map((item) => (
@@ -66,21 +66,17 @@ var Panel = function Panel(props) {
66
66
  // </div>
67
67
  // )
68
68
  // }, [selectorTypes, componentPrefix])
69
-
70
69
  var renderSelectors = useCallback(function () {
71
70
  return /*#__PURE__*/React.createElement("div", {
72
71
  className: componentPrefix + "__selector-container"
73
72
  }, selectorTypes.map(function (type, index) {
74
73
  var _cx;
75
-
76
74
  var position = selectorTypes.length === 1 ? SelectorPosition.single : SelectorPosition.middle;
77
-
78
75
  if (selectorTypes.length > 1 && index === 0) {
79
76
  position = SelectorPosition.left;
80
77
  } else if (selectorTypes.length > 1 && index === selectorTypes.length - 1) {
81
78
  position = SelectorPosition.right;
82
79
  }
83
-
84
80
  return /*#__PURE__*/React.createElement("div", {
85
81
  className: componentPrefix + "__selector-content",
86
82
  key: type
@@ -91,15 +87,13 @@ var Panel = function Panel(props) {
91
87
  // itemHeight={itemHeight}
92
88
  // fullDisplayItemNumber={fullDisplayItemNumber}
93
89
  onChange: function onChange(e) {
94
- var result = [].concat(separateValue).slice(0, selectorTypes.length); // 如果 value = '',则代表为空值
90
+ var result = [].concat(separateValue).slice(0, selectorTypes.length);
91
+ // 如果 value = '',则代表为空值
95
92
  // 此时选择任意项,其他项直接视作 0
96
-
97
93
  if (value === '') {
98
94
  result = [0, 0, 0].slice(0, selectorTypes.length);
99
95
  }
100
-
101
96
  result[index] = Number(e.id);
102
-
103
97
  _onChange(result.map(function (item) {
104
98
  return String(item).padStart(2, '0');
105
99
  }).join(':'));
@@ -109,12 +103,12 @@ var Panel = function Panel(props) {
109
103
  className: cx(componentPrefix + "__indicator", (_cx = {}, _cx[componentPrefix + "__indicator--left"] = index === 0, _cx[componentPrefix + "__indicator--right"] = index === selectorTypes.length - 1, _cx))
110
104
  }));
111
105
  }));
112
- }, [selectorTypes, componentPrefix, prefix, getSelectorData, _onChange, separateValue, // itemHeight,
106
+ }, [selectorTypes, componentPrefix, prefix, getSelectorData, _onChange, separateValue,
107
+ // itemHeight,
113
108
  // fullDisplayItemNumber,
114
109
  value]);
115
110
  return /*#__PURE__*/React.createElement("div", {
116
111
  className: componentPrefix
117
112
  }, renderSelectors());
118
113
  };
119
-
120
114
  export { Panel };
@@ -15,39 +15,36 @@ import { analysisFormat } from './utils/analysisFormat.js';
15
15
  import { getFormatDefault } from './utils/getFormatDefault.js';
16
16
  import { timePickerPrefix } from './TimePicker.js';
17
17
  import { useFilter } from './hooks/useFilter.js';
18
-
19
18
  var DefaultDisabledFunc = function DefaultDisabledFunc() {
20
19
  return [];
21
20
  };
22
-
23
21
  var PopContent = function PopContent(props) {
24
22
  var _props$prefix = props.prefix,
25
- prefix = _props$prefix === void 0 ? timePickerPrefix : _props$prefix,
26
- dangerousValue = props.value,
27
- _onChange = props.onChange,
28
- format = props.format,
29
- type = props.type,
30
- hourStep = props.hourStep,
31
- minuteStep = props.minuteStep,
32
- secondStep = props.secondStep,
33
- _props$disabledHours = props.disabledHours,
34
- originalDisabledHours = _props$disabledHours === void 0 ? DefaultDisabledFunc : _props$disabledHours,
35
- _props$disabledSecond = props.disabledSeconds,
36
- originalDisabledSeconds = _props$disabledSecond === void 0 ? DefaultDisabledFunc : _props$disabledSecond,
37
- _props$disabledMinute = props.disabledMinutes,
38
- originalDisabledMinutes = _props$disabledMinute === void 0 ? DefaultDisabledFunc : _props$disabledMinute,
39
- style = props.style; // 将值统一转化为函数
23
+ prefix = _props$prefix === void 0 ? timePickerPrefix : _props$prefix,
24
+ dangerousValue = props.value,
25
+ _onChange = props.onChange,
26
+ format = props.format,
27
+ type = props.type,
28
+ hourStep = props.hourStep,
29
+ minuteStep = props.minuteStep,
30
+ secondStep = props.secondStep,
31
+ _props$disabledHours = props.disabledHours,
32
+ originalDisabledHours = _props$disabledHours === void 0 ? DefaultDisabledFunc : _props$disabledHours,
33
+ _props$disabledSecond = props.disabledSeconds,
34
+ originalDisabledSeconds = _props$disabledSecond === void 0 ? DefaultDisabledFunc : _props$disabledSecond,
35
+ _props$disabledMinute = props.disabledMinutes,
36
+ originalDisabledMinutes = _props$disabledMinute === void 0 ? DefaultDisabledFunc : _props$disabledMinute,
37
+ style = props.style;
38
+ // 将值统一转化为函数
40
39
  // 由于 pop content 会被 date-picker 直接调用,故而在此多做一次兼容处理
41
-
42
40
  var _useFilter = useFilter({
43
- disabledHours: originalDisabledHours,
44
- disabledMinutes: originalDisabledMinutes,
45
- disabledSeconds: originalDisabledSeconds
46
- }),
47
- disabledHours = _useFilter.disabledHours,
48
- disabledMinutes = _useFilter.disabledMinutes,
49
- disabledSeconds = _useFilter.disabledSeconds;
50
-
41
+ disabledHours: originalDisabledHours,
42
+ disabledMinutes: originalDisabledMinutes,
43
+ disabledSeconds: originalDisabledSeconds
44
+ }),
45
+ disabledHours = _useFilter.disabledHours,
46
+ disabledMinutes = _useFilter.disabledMinutes,
47
+ disabledSeconds = _useFilter.disabledSeconds;
51
48
  var value = useMemo(function () {
52
49
  return dangerousValue.map(function (item) {
53
50
  return item || getFormatDefault(format);
@@ -76,75 +73,68 @@ var PopContent = function PopContent(props) {
76
73
  }, [selectorTypes]);
77
74
  var customDisabledHours = useCallback(function (panel) {
78
75
  var result = disabledHours(panel);
79
-
80
76
  if (panel === 'range-end') {
81
77
  var startHour = getMatchTypeValue(0, TimePickerSelectorType.hour);
82
- var isLastOne = judgeTypeIsLastOne(TimePickerSelectorType.hour); // 当当前类型为最后一个类型的时候
78
+ var isLastOne = judgeTypeIsLastOne(TimePickerSelectorType.hour);
79
+ // 当当前类型为最后一个类型的时候
83
80
  // 不能够选择与开始一致的值
84
-
85
81
  result = [].concat(result, getRange(0, isLastOne ? startHour : startHour - 1));
86
82
  }
87
-
88
83
  return result;
89
84
  }, [getMatchTypeValue, disabledHours, judgeTypeIsLastOne]);
90
85
  var customDisabledMinute = useCallback(function (hour, panel) {
91
86
  var result = disabledMinutes(hour, panel);
92
-
93
87
  if (panel === 'range-end') {
94
88
  var startHour = getMatchTypeValue(0, TimePickerSelectorType.hour);
95
- var startMinute = getMatchTypeValue(0, TimePickerSelectorType.minute); // 当前类型中包含了小时
89
+ var startMinute = getMatchTypeValue(0, TimePickerSelectorType.minute);
90
+ // 当前类型中包含了小时
96
91
  // minute 有值
97
-
98
92
  if (hour >= 0) {
99
93
  // 开始时间等于结束时间,则直接禁用开始时间之前的时间
100
94
  if (startHour === hour) {
101
- var isLastOne = judgeTypeIsLastOne(TimePickerSelectorType.minute); // 当当前类型为最后一个类型的时候
95
+ var isLastOne = judgeTypeIsLastOne(TimePickerSelectorType.minute);
96
+ // 当当前类型为最后一个类型的时候
102
97
  // 不能够选择与开始一致的值
103
-
104
98
  result = [].concat(result, getRange(0, isLastOne ? startMinute : startMinute - 1));
105
- } // 开始时间大于结束时间,直接禁用所有
99
+ }
100
+ // 开始时间大于结束时间,直接禁用所有
106
101
  else if (startHour > hour) {
107
102
  result = [].concat(result, getRange(0, 59));
108
103
  }
109
104
  }
110
105
  }
111
-
112
106
  return result;
113
107
  }, [getMatchTypeValue, judgeTypeIsLastOne, disabledMinutes]);
114
108
  var customDisabledSeconds = useCallback(function (hour, minute, panel) {
115
109
  var result = disabledSeconds(hour, minute, panel);
116
-
117
110
  if (panel === 'range-end') {
118
111
  var startHour = getMatchTypeValue(0, TimePickerSelectorType.hour);
119
112
  var startMinute = getMatchTypeValue(0, TimePickerSelectorType.minute);
120
113
  var startSecond = getMatchTypeValue(0, TimePickerSelectorType.second);
121
- var allDisabled = false; // 如果小时存在,并且开始小时大于结束,禁用所有秒
122
-
114
+ var allDisabled = false;
115
+ // 如果小时存在,并且开始小时大于结束,禁用所有秒
123
116
  if (hour >= 0 && startHour > hour) {
124
117
  allDisabled = true;
125
- } // 如果小时存在,并且开始结束小时一样,并且开始分钟大于结束分钟,禁用所有秒
126
-
127
-
118
+ }
119
+ // 如果小时存在,并且开始结束小时一样,并且开始分钟大于结束分钟,禁用所有秒
128
120
  if (hour >= 0 && startHour === hour && minute >= 0 && startMinute > minute) {
129
121
  allDisabled = true;
130
122
  }
131
-
132
123
  if (allDisabled) {
133
124
  result = [].concat(result, getRange(0, 59));
134
125
  } else {
135
126
  // hour 不存在 或者存在并且开始与结束相同
136
127
  // 则视作,小时相等
137
- var isHourEqual = hour < 0 || startHour === hour; // minute 不存在 或者存在并且开始与结束相同
128
+ var isHourEqual = hour < 0 || startHour === hour;
129
+ // minute 不存在 或者存在并且开始与结束相同
138
130
  // 则视作,分钟相等
139
-
140
- var isMinuteEqual = minute < 0 || startMinute === minute; // 分钟小时相等,则需要根据 开始 秒 做禁用处理
141
-
131
+ var isMinuteEqual = minute < 0 || startMinute === minute;
132
+ // 分钟小时相等,则需要根据 开始 秒 做禁用处理
142
133
  if (isHourEqual && isMinuteEqual) {
143
134
  result = [].concat(result, getRange(0, startSecond));
144
135
  }
145
136
  }
146
137
  }
147
-
148
138
  return result;
149
139
  }, [getMatchTypeValue, disabledSeconds]);
150
140
  var componentClass = useMemo(function () {
@@ -153,7 +143,8 @@ var PopContent = function PopContent(props) {
153
143
  var renderPanel = useCallback(function (index) {
154
144
  return /*#__PURE__*/React.createElement("div", {
155
145
  className: componentClass + "__panel-container"
156
- }, /*#__PURE__*/React.createElement(Panel // itemHeight={itemHeight}
146
+ }, /*#__PURE__*/React.createElement(Panel
147
+ // itemHeight={itemHeight}
157
148
  // fullDisplayItemNumber={fullDisplayItemNumber}
158
149
  , {
159
150
  // itemHeight={itemHeight}
@@ -171,11 +162,11 @@ var PopContent = function PopContent(props) {
171
162
  onChange: function onChange(e) {
172
163
  var result = [].concat(value);
173
164
  result[index] = e;
174
-
175
165
  _onChange(result);
176
166
  }
177
167
  }));
178
- }, [hourStep, minuteStep, secondStep, customDisabledHours, customDisabledMinute, customDisabledSeconds, format, prefix, type, value, _onChange, // fullDisplayItemNumber,
168
+ }, [hourStep, minuteStep, secondStep, customDisabledHours, customDisabledMinute, customDisabledSeconds, format, prefix, type, value, _onChange,
169
+ // fullDisplayItemNumber,
179
170
  // itemHeight,
180
171
  componentClass]);
181
172
  return /*#__PURE__*/React.createElement("div", {
@@ -185,5 +176,4 @@ var PopContent = function PopContent(props) {
185
176
  className: componentClass + "__separator"
186
177
  }), type === 'range' && renderPanel(1));
187
178
  };
188
-
189
179
  export { PopContent };
@@ -10,23 +10,21 @@
10
10
  import React, { useRef, useCallback, useEffect } from 'react';
11
11
  import { cx } from '@hi-ui/classname';
12
12
  var SelectorPosition;
13
-
14
13
  (function (SelectorPosition) {
15
14
  SelectorPosition["left"] = "left";
16
15
  SelectorPosition["right"] = "right";
17
16
  SelectorPosition["middle"] = "middle";
18
17
  SelectorPosition["single"] = "single";
19
18
  })(SelectorPosition || (SelectorPosition = {}));
20
-
21
19
  var Selector = function Selector(props) {
22
20
  var prefix = props.prefix,
23
- value = props.value,
24
- data = props.data,
25
- onChange = props.onChange,
26
- position = props.position;
21
+ value = props.value,
22
+ data = props.data,
23
+ onChange = props.onChange,
24
+ position = props.position;
27
25
  var componentPrefix = prefix + "__selector";
28
- var stopScrollTimeoutHandler = useRef(-1); // 滚动容器引用
29
-
26
+ var stopScrollTimeoutHandler = useRef(-1);
27
+ // 滚动容器引用
30
28
  var scrollContainerRef = useRef(null);
31
29
  var topItemGagerRef = useRef(null);
32
30
  var bottomItemGagerRef = useRef(null);
@@ -41,22 +39,20 @@ var Selector = function Selector(props) {
41
39
  }, []);
42
40
  var onScroll = useCallback(function (e) {
43
41
  e.persist();
44
- e.stopPropagation(); // 清除用做判断是否滚动停止的定时器
45
-
46
- clearTimeout(stopScrollTimeoutHandler.current); // 计算当前选中的 index 下标
47
-
42
+ e.stopPropagation();
43
+ // 清除用做判断是否滚动停止的定时器
44
+ clearTimeout(stopScrollTimeoutHandler.current);
45
+ // 计算当前选中的 index 下标
48
46
  var currentIndex = calcCurrentIndex(e.target.scrollTop);
49
-
50
47
  if (currentIndex > data.length) {
51
48
  currentIndex = data.length - 1;
52
- } // 200ms 后如果事件没有再次响应,则视作滚动停止
49
+ }
50
+ // 200ms 后如果事件没有再次响应,则视作滚动停止
53
51
  // 不论是否禁用,我们都需要自动滚动到对应 index
54
-
55
-
56
52
  stopScrollTimeoutHandler.current = setTimeout(function () {
57
- scrollToMatchIndex(currentIndex); // 通知外部改变
53
+ scrollToMatchIndex(currentIndex);
54
+ // 通知外部改变
58
55
  // 如果当前 item 被禁用了,则无通知
59
-
60
56
  if (!data[currentIndex].disabled) {
61
57
  onChange(data[currentIndex]);
62
58
  }
@@ -70,9 +66,9 @@ var Selector = function Selector(props) {
70
66
  useEffect(function () {
71
67
  var currentIndex = data.findIndex(function (item) {
72
68
  return item.id === value;
73
- }); // 避免非法值跳转
69
+ });
70
+ // 避免非法值跳转
74
71
  // 避免重复执行操作,只有当 value 对应的下标改变的时候才需要执行
75
-
76
72
  if (currentIndex >= 0 && lastValueMatchIndexCache.current !== currentIndex) {
77
73
  lastValueMatchIndexCache.current = currentIndex;
78
74
  scrollToMatchIndex(currentIndex);
@@ -88,7 +84,6 @@ var Selector = function Selector(props) {
88
84
  className: cx(componentPrefix + "__scroll-part", componentPrefix + "__demarcate")
89
85
  }, data.map(function (item, index) {
90
86
  var _cx;
91
-
92
87
  return /*#__PURE__*/React.createElement("div", {
93
88
  className: cx(componentPrefix + "__item", componentPrefix + "__demarcate", (_cx = {}, _cx[componentPrefix + "__item--disabled"] = item.disabled, _cx[componentPrefix + "__item--active"] = item.id === value, _cx)),
94
89
  key: item.id,
@@ -113,5 +108,4 @@ var Selector = function Selector(props) {
113
108
  ref: bottomItemGagerRef
114
109
  }))));
115
110
  };
116
-
117
111
  export { Selector, SelectorPosition };