assui 3.1.38 → 3.1.40

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.
@@ -0,0 +1,3 @@
1
+ import './index.less';
2
+ import '../../label-condition-input/style';
3
+ import '../../label-select/style';
@@ -0,0 +1,3 @@
1
+ import './index.less';
2
+ import '../../label-condition-input/style';
3
+ import '../../label-select/style';
@@ -0,0 +1,32 @@
1
+ @import '~antd/lib/style/index.less';
2
+ @import '../../style/themes/default.less';
3
+ @import '../../style/variables.less';
4
+
5
+ .label-condition-select {
6
+ display: flex;
7
+ align-items: center;
8
+ width: 100%;
9
+
10
+ &-selector {
11
+ width: 30%;
12
+ margin-right: 8px;
13
+ }
14
+
15
+ &-second-input {
16
+ width: 70%;
17
+ }
18
+
19
+ &-two-select-selector {
20
+ width: 50%;
21
+ margin-right: 8px;
22
+ }
23
+
24
+ &-only-selector {
25
+ width: 100%;
26
+ margin-right: 0;
27
+ }
28
+
29
+ &-second-select {
30
+ width: 50%;
31
+ }
32
+ }
@@ -55,6 +55,10 @@ import LabelRangePicker from '../label-range-picker';
55
55
  import LocaleContext from '../config-provider/context';
56
56
  import formatMessage from '../messages';
57
57
  import { formatMaxScope } from './utils';
58
+ /** 1整天的毫秒数 */
59
+ var ONE_DAY_MILLISECOND = 1000 * 60 * 60 * 24;
60
+ /** 1分钟的毫秒数 */
61
+ var ONE_MINUTE_MILLISECOND = 1000 * 60;
58
62
  var RangePicker = DatePicker.RangePicker;
59
63
  var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
60
64
  var customizeTimeList = props.customizeTimeList,
@@ -151,29 +155,38 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
151
155
  var _c = __read(nextValue || [], 2),
152
156
  start = _c[0],
153
157
  end = _c[1];
154
- var nextStartDate = (_a = showTime ? start === null || start === void 0 ? void 0 : start.clone() : start === null || start === void 0 ? void 0 : start.clone().startOf('day')) !== null && _a !== void 0 ? _a : null;
155
- var nextEndDate = (_b = showTime ? end === null || end === void 0 ? void 0 : end.clone() : end === null || end === void 0 ? void 0 : end.clone().endOf('day')) !== null && _b !== void 0 ? _b : null;
158
+ var nextStartDate = (_a = showTime ? start === null || start === void 0 ? void 0 : start.clone().startOf('minute') : start === null || start === void 0 ? void 0 : start.clone().startOf('day')) !== null && _a !== void 0 ? _a : null;
159
+ var nextEndDate = (_b = showTime ? end === null || end === void 0 ? void 0 : end.clone().endOf('minute') : end === null || end === void 0 ? void 0 : end.clone().endOf('day')) !== null && _b !== void 0 ? _b : null;
156
160
  if (!nextStartDate && !nextEndDate) {
157
161
  return setDate(undefined);
158
162
  }
159
163
  if (!maxScope) {
160
164
  return setDate([nextStartDate, nextEndDate]);
161
165
  }
166
+ var timeDiffOfShowTime = maxScope * ONE_DAY_MILLISECOND - ONE_MINUTE_MILLISECOND;
162
167
  var _d = __read(date || [], 1),
163
168
  startDate = _d[0];
169
+ // 1. start和end都存在时
164
170
  if (nextStartDate && nextEndDate) {
165
- var isChangeStartData = !(startDate === null || startDate === void 0 ? void 0 : startDate.clone().isSame(nextStartDate, 'day'));
171
+ var isChangeStartData = !(startDate === null || startDate === void 0 ? void 0 : startDate.clone().isSame(nextStartDate));
172
+ var momentDiffDay = nextEndDate.diff(nextStartDate) / ONE_DAY_MILLISECOND;
173
+ // 更改start
166
174
  if (isChangeStartData) {
167
- if (nextEndDate.diff(nextStartDate, 'day') > maxScope) {
168
- nextEndDate = nextStartDate.clone().add(maxScope - 1, 'day').endOf('day');
175
+ // 时间差大于maxScope,则将end调整到期望范围
176
+ if (momentDiffDay > maxScope) {
177
+ nextEndDate = showTime ? nextStartDate.clone().add(timeDiffOfShowTime, 'milliseconds').endOf('minute') : nextStartDate.clone().add(maxScope - 1, 'day').endOf('day');
169
178
  }
170
- } else if (nextEndDate.diff(nextStartDate, 'day') > maxScope) {
171
- nextStartDate = nextEndDate.clone().subtract(maxScope - 1, 'day').startOf('day');
179
+ // 更改end
180
+ // 时间差大于maxScope,则将结start调整到期望范围
181
+ } else if (momentDiffDay > maxScope) {
182
+ nextStartDate = showTime ? nextEndDate.clone().subtract(timeDiffOfShowTime, 'milliseconds').startOf('minute') : nextEndDate.clone().subtract(maxScope - 1, 'day').startOf('day');
172
183
  }
184
+ // 2. 仅end存在时,自动填入start
173
185
  } else if (!nextStartDate && nextEndDate) {
174
- nextStartDate = nextEndDate.clone().subtract(maxScope - 1, 'day').startOf('day');
186
+ nextStartDate = showTime ? nextEndDate.clone().subtract(timeDiffOfShowTime, 'milliseconds').startOf('minute') : nextEndDate.clone().subtract(maxScope - 1, 'day').startOf('day');
187
+ // 3. 仅start存在时,自动填入end
175
188
  } else if (nextStartDate && !nextEndDate) {
176
- nextEndDate = nextStartDate.clone().add(maxScope - 1, 'day').endOf('day');
189
+ nextEndDate = showTime ? nextStartDate.clone().add(timeDiffOfShowTime, 'milliseconds').endOf('minute') : nextStartDate.clone().add(maxScope - 1, 'day').endOf('day');
177
190
  }
178
191
  if (nextStartDate && nextEndDate) {
179
192
  return setDate([nextStartDate, nextEndDate]);
@@ -193,7 +206,7 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
193
206
  var _a = __read(item.value, 2),
194
207
  startTime = _a[0],
195
208
  entTime = _a[1];
196
- var space = entTime.diff(startTime, 'days');
209
+ var space = entTime.diff(startTime) / ONE_DAY_MILLISECOND;
197
210
  return space <= maxScope;
198
211
  }) : dataSource;
199
212
  var panelRender = function panelRender(panel) {
@@ -25,7 +25,10 @@ export interface ConditionSelectInputProps {
25
25
  conditionInputProps?: ConditionInputProps;
26
26
  /** 联动selectProps */
27
27
  conditionSelectProps?: SelectProps;
28
+ /** onChange */
28
29
  onChange?: (value: ValueType) => void;
30
+ /** onBlur */
31
+ onBlur?: (value: ValueType) => void;
29
32
  /** 输入框类型 */
30
33
  inputType?: InputTypeEnum;
31
34
  /** select options */
@@ -99,7 +99,8 @@ var ConditionSelectInput = function ConditionSelectInput(props) {
99
99
  _b = props.inputType,
100
100
  inputType = _b === void 0 ? InputTypeEnum.CONDITION_INPUT : _b,
101
101
  _c = props.optionsList,
102
- optionsList = _c === void 0 ? [] : _c;
102
+ optionsList = _c === void 0 ? [] : _c,
103
+ onBlur = props.onBlur;
103
104
  var isInput = inputType === InputTypeEnum.CONDITION_INPUT;
104
105
  var _d = __read((0, useControllableValue_1["default"])(props), 2),
105
106
  selectInputValue = _d[0],
@@ -148,19 +149,24 @@ var ConditionSelectInput = function ConditionSelectInput(props) {
148
149
  inputValue: inputValue
149
150
  });
150
151
  };
152
+ var onConditionSelectInputBlur = function onConditionSelectInputBlur() {
153
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(selectInputValue);
154
+ };
151
155
  // 是否展示输入框
152
156
  var isShowInput = !(0, isNil_1["default"])(selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue) && !(hiddenInputKeys === null || hiddenInputKeys === void 0 ? void 0 : hiddenInputKeys.includes(selectInputValue.selectValue));
153
157
  var typeInput = isInput ? react_1["default"].createElement("div", {
154
158
  className: "condition-select-input"
155
159
  }, react_1["default"].createElement(condition_input_1["default"], __assign({}, conditionInputProps, {
156
160
  onChange: onInputChange,
157
- value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.inputValue
161
+ value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.inputValue,
162
+ onBlur: onConditionSelectInputBlur
158
163
  }))) : react_1["default"].createElement("div", {
159
164
  className: "condition-select-select-input"
160
165
  }, react_1["default"].createElement(select_1["default"], __assign({}, conditionSelectProps, {
161
166
  onChange: onTypeSelectChange,
162
167
  value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.inputValue,
163
- options: subSelectOptions
168
+ options: subSelectOptions,
169
+ onBlur: onConditionSelectInputBlur
164
170
  })));
165
171
  return react_1["default"].createElement("div", {
166
172
  className: "condition-select-wrap"
@@ -172,7 +178,8 @@ var ConditionSelectInput = function ConditionSelectInput(props) {
172
178
  }, react_1["default"].createElement(select_1["default"], __assign({}, selectProps, {
173
179
  onChange: onSelectChange,
174
180
  value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
175
- options: optionsList
181
+ options: optionsList,
182
+ onBlur: onConditionSelectInputBlur
176
183
  }))), isShowInput && typeInput);
177
184
  };
178
185
  exports["default"] = ConditionSelectInput;
package/lib/index.d.ts CHANGED
@@ -78,3 +78,5 @@ export { default as BeautifulDnd } from './beautiful-dnd';
78
78
  export { default as Resizable } from './resizable';
79
79
  export type { FlexProps } from './flex';
80
80
  export { default as Flex } from './flex';
81
+ export type { LabelConditionSelectInputProps } from './label-condition-select-input';
82
+ export { default as LabelConditionSelectInput } from './label-condition-select-input';
package/lib/index.js CHANGED
@@ -8,7 +8,7 @@ var __importDefault = this && this.__importDefault || function (mod) {
8
8
  Object.defineProperty(exports, "__esModule", {
9
9
  value: true
10
10
  });
11
- exports.Flex = exports.Resizable = exports.BeautifulDnd = exports.RichTextEditor = exports.LabelCustomizeRangePicker = exports.TableCol = exports.LabelTreeSelect = exports.LabelConditionInput = exports.LabelNumberInput = exports.LabelAutoComplete = exports.LabelDatePicker = exports.LabelRangePicker = exports.JsonEditor = exports.AreaText = exports.LabelTextArea = exports.ASelect = exports.LabelSelect = exports.ColorSelect = exports.LabelInput = exports.TextInput = exports.TextArea = exports.SplitPane = exports.sortableHoc = exports.SingleImgUpload = exports.RcTransitionGroup = exports.RcQRcode = exports.RcEcharts = exports.StepNumberInput = exports.LabelRangeNumber = exports.NumberInput = exports.RcMotion = exports.KeepTab = exports.ImgCrop = exports.HighlightWords = exports.HighlightTextarea = exports.CopyToClipboard = exports.NumberFormatInput = exports.ConfigProvider = exports.ConditionSelectInput = exports.ConditionInput = exports.ButtonModal = exports.ButtonDrawer = void 0;
11
+ exports.LabelConditionSelectInput = exports.Flex = exports.Resizable = exports.BeautifulDnd = exports.RichTextEditor = exports.LabelCustomizeRangePicker = exports.TableCol = exports.LabelTreeSelect = exports.LabelConditionInput = exports.LabelNumberInput = exports.LabelAutoComplete = exports.LabelDatePicker = exports.LabelRangePicker = exports.JsonEditor = exports.AreaText = exports.LabelTextArea = exports.ASelect = exports.LabelSelect = exports.ColorSelect = exports.LabelInput = exports.TextInput = exports.TextArea = exports.SplitPane = exports.sortableHoc = exports.SingleImgUpload = exports.RcTransitionGroup = exports.RcQRcode = exports.RcEcharts = exports.StepNumberInput = exports.LabelRangeNumber = exports.NumberInput = exports.RcMotion = exports.KeepTab = exports.ImgCrop = exports.HighlightWords = exports.HighlightTextarea = exports.CopyToClipboard = exports.NumberFormatInput = exports.ConfigProvider = exports.ConditionSelectInput = exports.ConditionInput = exports.ButtonModal = exports.ButtonDrawer = void 0;
12
12
  var button_drawer_1 = require("./button-drawer");
13
13
  Object.defineProperty(exports, "ButtonDrawer", {
14
14
  enumerable: true,
@@ -302,4 +302,11 @@ Object.defineProperty(exports, "Flex", {
302
302
  get: function get() {
303
303
  return __importDefault(flex_1)["default"];
304
304
  }
305
+ });
306
+ var label_condition_select_input_1 = require("./label-condition-select-input");
307
+ Object.defineProperty(exports, "LabelConditionSelectInput", {
308
+ enumerable: true,
309
+ get: function get() {
310
+ return __importDefault(label_condition_select_input_1)["default"];
311
+ }
305
312
  });
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import type { LabelConditionInputProps } from '../label-condition-input';
3
+ import type { LabelSelectProps } from '../label-select';
4
+ export declare enum InputTypeEnum {
5
+ CONDITION_INPUT = "conditionInput",
6
+ SELECT = "select"
7
+ }
8
+ declare type SelectOptionsType = {
9
+ value: number;
10
+ label: string;
11
+ };
12
+ export interface MainSelectOptionsType extends SelectOptionsType {
13
+ children?: SelectOptionsType[];
14
+ }
15
+ export interface ValueType {
16
+ selectValue?: number | string | null;
17
+ inputValue?: LabelSelectProps['value'] | LabelConditionInputProps['value'];
18
+ }
19
+ export interface LabelConditionSelectInputProps {
20
+ value?: ValueType;
21
+ /** 不需要展示联动输入框的字段值 */
22
+ hiddenInputKeys?: ValueType['selectValue'][];
23
+ /** selectProps */
24
+ selectProps?: LabelSelectProps;
25
+ /** 联动inputProps */
26
+ conditionInputProps?: LabelConditionInputProps;
27
+ /** 联动selectProps */
28
+ conditionSelectProps?: LabelSelectProps;
29
+ /** onChange */
30
+ onChange?: (value: ValueType) => void;
31
+ /** onBlur */
32
+ onBlur?: (value: ValueType) => void;
33
+ /** 输入框类型 */
34
+ inputType?: InputTypeEnum;
35
+ /** select options */
36
+ optionsList: MainSelectOptionsType[];
37
+ /** label */
38
+ label?: React.ReactNode;
39
+ /** 样式 */
40
+ className?: string;
41
+ }
42
+ declare const LabelConditionSelect: (props: LabelConditionSelectInputProps) => JSX.Element;
43
+ export default LabelConditionSelect;
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) {
8
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
9
+ }
10
+ }
11
+ return t;
12
+ };
13
+ return __assign.apply(this, arguments);
14
+ };
15
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = {
20
+ enumerable: true,
21
+ get: function get() {
22
+ return m[k];
23
+ }
24
+ };
25
+ }
26
+ Object.defineProperty(o, k2, desc);
27
+ } : function (o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ });
31
+ var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
32
+ Object.defineProperty(o, "default", {
33
+ enumerable: true,
34
+ value: v
35
+ });
36
+ } : function (o, v) {
37
+ o["default"] = v;
38
+ });
39
+ var __importStar = this && this.__importStar || function (mod) {
40
+ if (mod && mod.__esModule) return mod;
41
+ var result = {};
42
+ if (mod != null) for (var k in mod) {
43
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
44
+ }
45
+ __setModuleDefault(result, mod);
46
+ return result;
47
+ };
48
+ var __read = this && this.__read || function (o, n) {
49
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
50
+ if (!m) return o;
51
+ var i = m.call(o),
52
+ r,
53
+ ar = [],
54
+ e;
55
+ try {
56
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
57
+ ar.push(r.value);
58
+ }
59
+ } catch (error) {
60
+ e = {
61
+ error: error
62
+ };
63
+ } finally {
64
+ try {
65
+ if (r && !r.done && (m = i["return"])) m.call(i);
66
+ } finally {
67
+ if (e) throw e.error;
68
+ }
69
+ }
70
+ return ar;
71
+ };
72
+ var __importDefault = this && this.__importDefault || function (mod) {
73
+ return mod && mod.__esModule ? mod : {
74
+ "default": mod
75
+ };
76
+ };
77
+ Object.defineProperty(exports, "__esModule", {
78
+ value: true
79
+ });
80
+ exports.InputTypeEnum = void 0;
81
+ var isNil_1 = __importDefault(require("lodash/isNil"));
82
+ var classnames_1 = __importDefault(require("classnames"));
83
+ var react_1 = __importStar(require("react"));
84
+ var useControllableValue_1 = __importDefault(require("ahooks/lib/useControllableValue"));
85
+ var label_condition_input_1 = __importDefault(require("../label-condition-input"));
86
+ var label_select_1 = __importDefault(require("../label-select"));
87
+ var InputTypeEnum;
88
+ (function (InputTypeEnum) {
89
+ InputTypeEnum["CONDITION_INPUT"] = "conditionInput";
90
+ InputTypeEnum["SELECT"] = "select";
91
+ })(InputTypeEnum = exports.InputTypeEnum || (exports.InputTypeEnum = {}));
92
+ var LabelConditionSelect = function LabelConditionSelect(props) {
93
+ var value = props.value,
94
+ _a = props.hiddenInputKeys,
95
+ hiddenInputKeys = _a === void 0 ? [] : _a,
96
+ selectProps = props.selectProps,
97
+ conditionInputProps = props.conditionInputProps,
98
+ conditionSelectProps = props.conditionSelectProps,
99
+ _b = props.inputType,
100
+ inputType = _b === void 0 ? InputTypeEnum.CONDITION_INPUT : _b,
101
+ _c = props.optionsList,
102
+ optionsList = _c === void 0 ? [] : _c,
103
+ label = props.label,
104
+ className = props.className,
105
+ onBlur = props.onBlur;
106
+ var isInput = inputType === InputTypeEnum.CONDITION_INPUT;
107
+ var _d = __read((0, useControllableValue_1["default"])(props), 2),
108
+ selectInputValue = _d[0],
109
+ setSelectInputValue = _d[1];
110
+ var _e = __read((0, react_1.useState)([]), 2),
111
+ subSelectOptions = _e[0],
112
+ setSubSelectOptions = _e[1];
113
+ (0, react_1.useEffect)(function () {
114
+ if (value && value.selectValue && optionsList.length) {
115
+ var _a = __read(optionsList.filter(function (item) {
116
+ return item.value === value.selectValue;
117
+ }), 1),
118
+ selectValueItem = _a[0];
119
+ if (selectValueItem && selectValueItem.children) {
120
+ setSubSelectOptions(selectValueItem.children);
121
+ }
122
+ }
123
+ }, [value, optionsList]);
124
+ var onSelectChange = function onSelectChange(selectValue) {
125
+ var inputValue = isInput ? '' : undefined;
126
+ setSelectInputValue({
127
+ selectValue: selectValue,
128
+ inputValue: inputValue
129
+ });
130
+ if (isInput || (0, isNil_1["default"])(selectValue)) {
131
+ setSubSelectOptions([]);
132
+ return;
133
+ }
134
+ var _a = __read(optionsList.filter(function (item) {
135
+ return item.value === selectValue;
136
+ }), 1),
137
+ selectValueItem = _a[0];
138
+ if (selectValueItem.children) {
139
+ setSubSelectOptions(selectValueItem.children);
140
+ }
141
+ };
142
+ var onInputChange = function onInputChange(inputValue) {
143
+ setSelectInputValue({
144
+ selectValue: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
145
+ inputValue: inputValue
146
+ });
147
+ };
148
+ var onTypeSelectChange = function onTypeSelectChange(inputValue) {
149
+ setSelectInputValue({
150
+ selectValue: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
151
+ inputValue: inputValue
152
+ });
153
+ };
154
+ var onLabelConditionSelectInputBlur = function onLabelConditionSelectInputBlur() {
155
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(selectInputValue);
156
+ };
157
+ // 是否展示输入框
158
+ var isShowInput = !(0, isNil_1["default"])(selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue) && !(hiddenInputKeys === null || hiddenInputKeys === void 0 ? void 0 : hiddenInputKeys.includes(selectInputValue.selectValue));
159
+ var typeInput = isInput ? react_1["default"].createElement(label_condition_input_1["default"], __assign({}, conditionInputProps, {
160
+ onChange: onInputChange,
161
+ className: "label-condition-select-second-input",
162
+ value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.inputValue,
163
+ onBlur: onLabelConditionSelectInputBlur
164
+ })) : react_1["default"].createElement("div", {
165
+ className: "label-condition-select-second-select"
166
+ }, react_1["default"].createElement(label_select_1["default"], __assign({}, conditionSelectProps, {
167
+ onChange: onTypeSelectChange,
168
+ value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.inputValue,
169
+ options: subSelectOptions,
170
+ onBlur: onLabelConditionSelectInputBlur
171
+ })));
172
+ return react_1["default"].createElement("div", {
173
+ className: (0, classnames_1["default"])('label-condition-select', className)
174
+ }, react_1["default"].createElement("div", {
175
+ className: (0, classnames_1["default"])('label-condition-select-selector', {
176
+ 'label-condition-select-two-select-selector': !isInput,
177
+ 'label-condition-select-only-selector': !isShowInput
178
+ })
179
+ }, react_1["default"].createElement(label_select_1["default"], __assign({
180
+ label: label
181
+ }, selectProps, {
182
+ onChange: onSelectChange,
183
+ value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
184
+ options: optionsList,
185
+ onBlur: onLabelConditionSelectInputBlur
186
+ }))), isShowInput && typeInput);
187
+ };
188
+ exports["default"] = LabelConditionSelect;