assui 3.1.38 → 3.1.39

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) {
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,41 @@
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
+ /** 输入框类型 */
32
+ inputType?: InputTypeEnum;
33
+ /** select options */
34
+ optionsList: MainSelectOptionsType[];
35
+ /** label */
36
+ label?: React.ReactNode;
37
+ /** 样式 */
38
+ className?: string;
39
+ }
40
+ declare const LabelConditionSelect: (props: LabelConditionSelectInputProps) => JSX.Element;
41
+ export default LabelConditionSelect;
@@ -0,0 +1,181 @@
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
+ var isInput = inputType === InputTypeEnum.CONDITION_INPUT;
106
+ var _d = __read((0, useControllableValue_1["default"])(props), 2),
107
+ selectInputValue = _d[0],
108
+ setSelectInputValue = _d[1];
109
+ var _e = __read((0, react_1.useState)([]), 2),
110
+ subSelectOptions = _e[0],
111
+ setSubSelectOptions = _e[1];
112
+ (0, react_1.useEffect)(function () {
113
+ if (value && value.selectValue && optionsList.length) {
114
+ var _a = __read(optionsList.filter(function (item) {
115
+ return item.value === value.selectValue;
116
+ }), 1),
117
+ selectValueItem = _a[0];
118
+ if (selectValueItem && selectValueItem.children) {
119
+ setSubSelectOptions(selectValueItem.children);
120
+ }
121
+ }
122
+ }, [value, optionsList]);
123
+ var onSelectChange = function onSelectChange(selectValue) {
124
+ var inputValue = isInput ? '' : undefined;
125
+ setSelectInputValue({
126
+ selectValue: selectValue,
127
+ inputValue: inputValue
128
+ });
129
+ if (isInput || (0, isNil_1["default"])(selectValue)) {
130
+ setSubSelectOptions([]);
131
+ return;
132
+ }
133
+ var _a = __read(optionsList.filter(function (item) {
134
+ return item.value === selectValue;
135
+ }), 1),
136
+ selectValueItem = _a[0];
137
+ if (selectValueItem.children) {
138
+ setSubSelectOptions(selectValueItem.children);
139
+ }
140
+ };
141
+ var onInputChange = function onInputChange(inputValue) {
142
+ setSelectInputValue({
143
+ selectValue: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
144
+ inputValue: inputValue
145
+ });
146
+ };
147
+ var onTypeSelectChange = function onTypeSelectChange(inputValue) {
148
+ setSelectInputValue({
149
+ selectValue: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
150
+ inputValue: inputValue
151
+ });
152
+ };
153
+ // 是否展示输入框
154
+ 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));
155
+ var typeInput = isInput ? react_1["default"].createElement(label_condition_input_1["default"], __assign({}, conditionInputProps, {
156
+ onChange: onInputChange,
157
+ className: "label-condition-select-second-input",
158
+ value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.inputValue
159
+ })) : react_1["default"].createElement("div", {
160
+ className: "label-condition-select-second-select"
161
+ }, react_1["default"].createElement(label_select_1["default"], __assign({}, conditionSelectProps, {
162
+ onChange: onTypeSelectChange,
163
+ value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.inputValue,
164
+ options: subSelectOptions
165
+ })));
166
+ return react_1["default"].createElement("div", {
167
+ className: (0, classnames_1["default"])('label-condition-select', className)
168
+ }, react_1["default"].createElement("div", {
169
+ className: (0, classnames_1["default"])('label-condition-select-selector', {
170
+ 'label-condition-select-two-select-selector': !isInput,
171
+ 'label-condition-select-only-selector': !isShowInput
172
+ })
173
+ }, react_1["default"].createElement(label_select_1["default"], __assign({
174
+ label: label
175
+ }, selectProps, {
176
+ onChange: onSelectChange,
177
+ value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
178
+ options: optionsList
179
+ }))), isShowInput && typeInput);
180
+ };
181
+ exports["default"] = LabelConditionSelect;