@zgfe/business-lib 1.0.21-cdp.4 → 1.0.21-cdp.7

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.
@@ -28,6 +28,7 @@
28
28
  padding: @padding-xss;
29
29
  border: 1px solid @border-color-base;
30
30
  border-radius: @border-radius-small;
31
+ cursor: pointer;
31
32
  }
32
33
 
33
34
  // 下拉组件展开panel样式
@@ -44,6 +45,7 @@
44
45
  padding: 0 @padding-sm;
45
46
  line-height: @option-height;
46
47
  border-radius: @border-radius-normal;
48
+ cursor: pointer;
47
49
  .__default-overflow();
48
50
 
49
51
  &:not(.disabled, .active):hover {
@@ -165,7 +165,7 @@ var StringList = function StringList(props) {
165
165
  multiple: true,
166
166
  enableCreate: true,
167
167
  theme: props.theme,
168
- size: "base",
168
+ size: "middle",
169
169
  className: "".concat(classPrefix, "-multi-select"),
170
170
  options: [],
171
171
  disable: true
@@ -178,7 +178,7 @@ var StringList = function StringList(props) {
178
178
  multiple: true,
179
179
  enableCreate: true,
180
180
  theme: props.theme,
181
- size: "base",
181
+ size: "middle",
182
182
  disable: props.operate === OperateTypes.IsNull || props.operate === OperateTypes.IsNotNull,
183
183
  labelField: "name",
184
184
  keyField: "value",
@@ -0,0 +1,3 @@
1
+ import '@zgfe/business-lib/es/assets/styles/resetAntd.less';
2
+ declare const _default: () => JSX.Element;
3
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { BizCycleTime } from '@zgfe/business-lib';
3
+ import '@zgfe/business-lib/es/assets/styles/resetAntd.less';
4
+ import { Form } from 'antd';
5
+ export default (function () {
6
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(Form.Item, null, /*#__PURE__*/React.createElement(BizCycleTime, null))));
7
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: () => JSX.Element;
2
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { BizCycleTime } from '@zgfe/business-lib';
3
+ export default (function () {
4
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(BizCycleTime, {
5
+ multiple: true
6
+ }));
7
+ });
@@ -0,0 +1,19 @@
1
+ import { SizeType } from 'antd/es/config-provider/SizeContext';
2
+ import React from 'react';
3
+ import './styles/index.less';
4
+ declare enum Unit {
5
+ day = "day",
6
+ week = "week",
7
+ month = "month"
8
+ }
9
+ interface Value {
10
+ unit: Unit;
11
+ day?: number[];
12
+ time?: string;
13
+ }
14
+ declare const BizCycleTime: React.FC<{
15
+ multiple?: boolean;
16
+ onChange?: (val: Value) => void;
17
+ size?: SizeType;
18
+ }>;
19
+ export default BizCycleTime;
@@ -0,0 +1,127 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+
7
+ 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; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ import { DatePicker } from 'antd';
14
+ import React, { useEffect, useState } from 'react';
15
+ import { BizSelect } from '..';
16
+ import MonthDay from './month';
17
+ import './styles/index.less';
18
+ var Unit;
19
+
20
+ (function (Unit) {
21
+ Unit["day"] = "day";
22
+ Unit["week"] = "week";
23
+ Unit["month"] = "month";
24
+ })(Unit || (Unit = {}));
25
+
26
+ var BizCycleTime = function BizCycleTime(props) {
27
+ var multiple = props.multiple,
28
+ size = props.size;
29
+ var classPrefix = 'biz-cycle-time';
30
+ var unitList = [{
31
+ label: '每日',
32
+ value: Unit.day
33
+ }, {
34
+ label: '每周',
35
+ value: Unit.week
36
+ }, {
37
+ label: '每月',
38
+ value: Unit.month
39
+ }];
40
+ var days = [];
41
+
42
+ var _useState = useState(unitList[0]),
43
+ _useState2 = _slicedToArray(_useState, 2),
44
+ unit = _useState2[0],
45
+ setUnit = _useState2[1];
46
+
47
+ var _useState3 = useState([]),
48
+ _useState4 = _slicedToArray(_useState3, 2),
49
+ day = _useState4[0],
50
+ setDay = _useState4[1];
51
+
52
+ var _useState5 = useState(),
53
+ _useState6 = _slicedToArray(_useState5, 2),
54
+ dayList = _useState6[0],
55
+ setDayList = _useState6[1];
56
+
57
+ var _useState7 = useState(),
58
+ _useState8 = _slicedToArray(_useState7, 2),
59
+ time = _useState8[0],
60
+ setTime = _useState8[1];
61
+
62
+ useEffect(function () {
63
+ var res = {
64
+ unit: unit.value,
65
+ day: unit.value === Unit.month ? dayList === null || dayList === void 0 ? void 0 : dayList.map(function (item) {
66
+ return item.value;
67
+ }) : multiple ? day.map(function (item) {
68
+ return item.value;
69
+ }) : [day.value],
70
+ time: time
71
+ };
72
+
73
+ if (unit.value === Unit.day) {
74
+ delete res.day;
75
+ } else {
76
+ delete res.time;
77
+ }
78
+
79
+ if (props.onChange) props.onChange(res);
80
+ }, [unit, day, dayList, time]);
81
+ var nums = ['一', '二', '三', '四', '五', '六', '日'];
82
+
83
+ for (var i = 1; i < 8; i++) {
84
+ days.push({
85
+ label: "\u661F\u671F".concat(nums[i - 1]),
86
+ value: i
87
+ });
88
+ }
89
+
90
+ return /*#__PURE__*/React.createElement("span", {
91
+ className: classPrefix
92
+ }, /*#__PURE__*/React.createElement(BizSelect, {
93
+ options: unitList,
94
+ labelField: "label",
95
+ keyField: "value",
96
+ className: "".concat(classPrefix, "-unit"),
97
+ defaultValue: unit,
98
+ size: size,
99
+ onChange: function onChange(v) {
100
+ setUnit(v);
101
+ }
102
+ }), unit.value === Unit.day && /*#__PURE__*/React.createElement(DatePicker.TimePicker, {
103
+ className: "".concat(classPrefix, "-hour"),
104
+ size: size,
105
+ onChange: function onChange(time) {
106
+ setTime(time === null || time === void 0 ? void 0 : time.format('hh:mm:ss'));
107
+ }
108
+ }), unit.value === Unit.week && /*#__PURE__*/React.createElement(BizSelect, {
109
+ options: days,
110
+ labelField: "label",
111
+ keyField: "value",
112
+ size: size,
113
+ multiple: multiple,
114
+ className: "".concat(classPrefix, "-day"),
115
+ onChange: function onChange(v) {
116
+ setDay(v);
117
+ }
118
+ }), unit.value === Unit.month && /*#__PURE__*/React.createElement(MonthDay, {
119
+ onChange: setDayList
120
+ }));
121
+ };
122
+
123
+ BizCycleTime.defaultProps = {
124
+ multiple: false,
125
+ size: 'middle'
126
+ };
127
+ export default BizCycleTime;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import './styles/month.less';
3
+ import { BaseOption } from '../utils/type';
4
+ import { SizeType } from 'antd/es/config-provider/SizeContext';
5
+ declare const MonthDay: React.FC<{
6
+ size?: SizeType;
7
+ className?: string;
8
+ onChange?: (days: BaseOption<number>[]) => void;
9
+ }>;
10
+ export default MonthDay;
@@ -0,0 +1,100 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+
7
+ 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; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ import { Dropdown, Tag } from 'antd';
14
+ import React, { useEffect, useState } from 'react';
15
+ import { IconFont } from '..';
16
+ import './styles/month.less';
17
+ import _ from 'lodash';
18
+
19
+ var MonthDay = function MonthDay(props) {
20
+ var classPrefix = 'biz-month-day';
21
+
22
+ var _useState = useState([]),
23
+ _useState2 = _slicedToArray(_useState, 2),
24
+ chosenDayList = _useState2[0],
25
+ setChosenDayList = _useState2[1];
26
+
27
+ var _useState3 = useState(false),
28
+ _useState4 = _slicedToArray(_useState3, 2),
29
+ visible = _useState4[0],
30
+ setVisible = _useState4[1];
31
+
32
+ useEffect(function () {
33
+ if (props.onChange) props.onChange(chosenDayList);
34
+ }, [chosenDayList]);
35
+
36
+ function onClickMonthDay(day) {
37
+ setChosenDayList(function (list) {
38
+ var res = _.cloneDeep(list);
39
+
40
+ var daySelected = false;
41
+ res.forEach(function (item, i) {
42
+ if (day === item.value) {
43
+ res.splice(i, 1);
44
+ daySelected = true;
45
+ }
46
+ });
47
+ if (!daySelected) res.push({
48
+ label: String(day === 32 ? '月末' : day),
49
+ value: day
50
+ });
51
+ return res;
52
+ });
53
+ }
54
+
55
+ var dayList = [];
56
+
57
+ for (var i = 1; i < 33; i++) {
58
+ dayList.push({
59
+ label: String(i === 32 ? '月末' : i),
60
+ value: i
61
+ });
62
+ }
63
+
64
+ return /*#__PURE__*/React.createElement(Dropdown, {
65
+ overlay: /*#__PURE__*/React.createElement("div", {
66
+ className: "".concat(classPrefix, "-overlay")
67
+ }, dayList.map(function (item) {
68
+ return /*#__PURE__*/React.createElement("span", {
69
+ key: item.value,
70
+ className: "".concat(classPrefix, "-day ").concat(chosenDayList.map(function (v) {
71
+ return v.value;
72
+ }).indexOf(item.value) > -1 ? 'active' : '', " ").concat(item.value === 32 ? 'lastday' : ''),
73
+ onClick: function onClick() {
74
+ onClickMonthDay(item.value);
75
+ }
76
+ }, item.label);
77
+ })),
78
+ visible: visible,
79
+ onVisibleChange: setVisible,
80
+ trigger: ['click']
81
+ }, /*#__PURE__*/React.createElement("div", {
82
+ className: "".concat(classPrefix, "-wrapper")
83
+ }, /*#__PURE__*/React.createElement("div", {
84
+ className: "".concat(classPrefix, "-handle ").concat(props.size)
85
+ }, /*#__PURE__*/React.createElement("div", {
86
+ className: "".concat(classPrefix, "-val")
87
+ }, chosenDayList.map(function (item) {
88
+ return /*#__PURE__*/React.createElement(Tag, {
89
+ closable: true,
90
+ key: item.value
91
+ }, item.label);
92
+ })), /*#__PURE__*/React.createElement(IconFont, {
93
+ type: "xiangxia"
94
+ }))));
95
+ };
96
+
97
+ MonthDay.defaultProps = {
98
+ size: 'middle'
99
+ };
100
+ export default MonthDay;
@@ -0,0 +1,24 @@
1
+ @import '../../assets//styles/inner.less';
2
+ .biz-cycle-time {
3
+ display: inline-block;
4
+ &-unit {
5
+ width: 129px;
6
+ }
7
+ &-day {
8
+ width: 210px;
9
+ vertical-align: top;
10
+ &.multi {
11
+ width: 470px;
12
+ }
13
+ }
14
+ &-unit,
15
+ &-day,
16
+ &-hour {
17
+ display: inline-block;
18
+ margin-right: @margin-xs;
19
+ }
20
+ &-hour {
21
+ width: 220px;
22
+ vertical-align: top;
23
+ }
24
+ }
@@ -0,0 +1,58 @@
1
+ @import '../../assets//styles/inner.less';
2
+ .biz-month-day {
3
+ &-handle {
4
+ .__select-handle();
5
+ display: flex;
6
+ flex-direction: row;
7
+ width: 280px;
8
+ &:hover,
9
+ &:active {
10
+ .__default-focused();
11
+ }
12
+ &.large {
13
+ min-height: @height-lg;
14
+ }
15
+ &.middle {
16
+ min-height: @height-base;
17
+ }
18
+ &.small {
19
+ min-height: @height-sm;
20
+ }
21
+ .bsicon {
22
+ flex: none;
23
+ }
24
+ }
25
+ &-val {
26
+ flex: 1;
27
+ .ant-tag {
28
+ margin-bottom: @margin-xss;
29
+ }
30
+ }
31
+ &-wrapper {
32
+ display: inline-block;
33
+ vertical-align: top;
34
+ &.ant-dropdown-open > .biz-month-day-handle {
35
+ .__default-focused();
36
+ }
37
+ }
38
+ &-overlay {
39
+ .__select-panel();
40
+ width: 280px;
41
+ padding: @padding-xss @padding-md;
42
+ word-break: break-all;
43
+ }
44
+ &-day {
45
+ .__select-option();
46
+ display: inline-block;
47
+ width: 30px;
48
+ height: 30px;
49
+ margin: 0 @margin-xss + 1 @margin-xss 0;
50
+ padding: 0;
51
+ line-height: 30px;
52
+ text-align: center;
53
+ border-radius: 100%;
54
+ &.lastday {
55
+ .__default-hover();
56
+ }
57
+ }
58
+ }
package/es/index.d.ts CHANGED
@@ -23,7 +23,8 @@ import BizUserTagsSelect from './userTagsSelector';
23
23
  import BizAddToScene from './addToScene';
24
24
  import BizAddToPanel from './addToPanel';
25
25
  import setGlobalConfig from './config';
26
- export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizUserGroup, IconFont, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig, };
26
+ import BizCycleTime from './cycleTime';
27
+ export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizUserGroup, IconFont, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, BizCycleTime, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig, };
27
28
  export type { UserGroupTypes } from './userGroup/types';
28
29
  export type { BizSelectTypes } from './select/types';
29
30
  export type { AttributeSelect } from './attributeSelector/types';
package/es/index.js CHANGED
@@ -22,4 +22,5 @@ import BizUserTagsSelect from './userTagsSelector';
22
22
  import BizAddToScene from './addToScene';
23
23
  import BizAddToPanel from './addToPanel';
24
24
  import setGlobalConfig from './config';
25
- export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizUserGroup, IconFont, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig };
25
+ import BizCycleTime from './cycleTime';
26
+ export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizUserGroup, IconFont, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, BizCycleTime, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig };
@@ -87,20 +87,9 @@ var BizSelect = function BizSelect(props) {
87
87
  };
88
88
  }, []);
89
89
  useEffect(function () {
90
- if (!props.value) {
91
- setCurrent(undefined);
92
- return;
93
- }
94
-
90
+ if (!props.value) return;
95
91
  setCurrent(getValue(props.value));
96
92
  }, [props.value]);
97
- useEffect(function () {
98
- var valid = false;
99
- props.options.forEach(function (item) {
100
- if (current && item[props.keyField] === current[props.keyField]) valid = true;
101
- });
102
- if (!valid) setCurrent(undefined);
103
- }, [props.options]);
104
93
 
105
94
  var getValue = function getValue(data) {
106
95
  if (props.multiple) {
@@ -208,6 +197,6 @@ BizSelect.defaultProps = {
208
197
  keyField: 'id',
209
198
  popupContainer: true,
210
199
  destroyPopupOnHide: true,
211
- size: 'base'
200
+ size: 'middle'
212
201
  };
213
202
  export default BizSelect;
@@ -1,3 +1,4 @@
1
+ import { SizeType } from 'antd/es/config-provider/SizeContext';
1
2
  import { ReactNode } from 'react';
2
3
  export declare namespace BizSelectTypes {
3
4
  interface Group {
@@ -16,7 +17,7 @@ export declare namespace BizSelectTypes {
16
17
  className?: string;
17
18
  type?: 'group' | 'normal';
18
19
  theme?: string;
19
- size?: 'lg' | 'base' | 'sm';
20
+ size?: SizeType;
20
21
  border?: boolean;
21
22
  multiple?: boolean;
22
23
  minDropdownWidth?: number;
@@ -65,7 +66,7 @@ export interface HandlerTypes {
65
66
  keyField?: string | number;
66
67
  disable?: boolean;
67
68
  theme?: string;
68
- size?: 'lg' | 'base' | 'sm';
69
+ size?: SizeType;
69
70
  border?: boolean;
70
71
  onDelete?: (data: BizSelectTypes.Option) => void;
71
72
  onSearch?: (val: string) => void;
@@ -5,6 +5,10 @@ export interface Event {
5
5
  label?: string | number;
6
6
  [prop: string]: any;
7
7
  }
8
+ export interface BaseOption<T> {
9
+ label: string;
10
+ value: T;
11
+ }
8
12
  export interface EventType {
9
13
  aliasName?: string;
10
14
  option?: string | number | Event;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.0.21-cdp.4",
3
+ "version": "1.0.21-cdp.7",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -58,5 +58,5 @@
58
58
  "react": "^16.12.0 || ^17.0.0",
59
59
  "yorkie": "^2.0.0"
60
60
  },
61
- "gitHead": "8e93c85ca8036cffd2fa7ec3562ae142214ecc4c"
61
+ "gitHead": "00a9093d07cfe74ca4f8c8bf379400a86f5601c7"
62
62
  }