@aloudata/aloudata-design 0.4.8-beta.1 → 0.4.8-beta.10

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.
@@ -1,4 +1,4 @@
1
- var _excluded = ["mode", "options", "dropdownRender", "onDropdownVisibleChange", "defaultValue", "onChange", "open", "defaultOpen", "prefix", "className", "popupClassName", "notFoundContent", "value", "style"];
1
+ var _excluded = ["mode", "options", "dropdownRender", "onDropdownVisibleChange", "defaultValue", "onChange", "open", "defaultOpen", "prefix", "className", "popupClassName", "listHeight", "listItemHeight", "notFoundContent", "value", "style"];
2
2
 
3
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
 
@@ -28,12 +28,20 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
28
28
 
29
29
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
30
30
 
31
+ import { FoldDownFill } from '@aloudata/icons-react';
31
32
  import { Select as AntdSelect } from 'antd';
32
33
  import classNames from 'classnames';
33
- import React, { forwardRef, useEffect, useLayoutEffect, useMemo } from 'react';
34
+ import List from 'rc-virtual-list';
35
+ import React, { forwardRef, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
34
36
  import Empty from "../Empty";
35
- import MultipleList from "./components/MultipleOption";
37
+ import MultipleOption from "./components/MultipleOption";
36
38
  import SingleOption from "./components/SingleOption";
39
+ import theme from "../style/themes/default/themeColor.module.less";
40
+ var suffixIconSizeMap = {
41
+ large: 20,
42
+ middle: 16,
43
+ small: 14
44
+ };
37
45
 
38
46
  var getSelectedOptionsFromValue = function getSelectedOptionsFromValue(isMultiple, options, value, defaultValue) {
39
47
  if (typeof value !== 'undefined') {
@@ -90,8 +98,15 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
90
98
  prefix = props.prefix,
91
99
  className = props.className,
92
100
  popupClassName = props.popupClassName,
101
+ listHeight = props.listHeight,
102
+ _props$listItemHeight = props.listItemHeight,
103
+ listItemHeight = _props$listItemHeight === void 0 ? 36 : _props$listItemHeight,
93
104
  _props$notFoundConten = props.notFoundContent,
94
- notFoundContent = _props$notFoundConten === void 0 ? /*#__PURE__*/React.createElement(Empty, null) : _props$notFoundConten,
105
+ notFoundContent = _props$notFoundConten === void 0 ? /*#__PURE__*/React.createElement(Empty, {
106
+ image: Empty.PRESENTED_IMAGE_SEARCH_SMALL,
107
+ size: "small",
108
+ title: "No data"
109
+ }) : _props$notFoundConten,
95
110
  value = props.value,
96
111
  _props$style = props.style,
97
112
  style = _props$style === void 0 ? {} : _props$style,
@@ -118,6 +133,8 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
118
133
  prefixWidth = _React$useState6[0],
119
134
  setPrefixWidth = _React$useState6[1];
120
135
 
136
+ var updatedRef = useRef(false);
137
+
121
138
  var onMultipleOptionChange = function onMultipleOptionChange(option, selected) {
122
139
  var newOptions = [];
123
140
 
@@ -144,16 +161,33 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
144
161
  }), newOptions);
145
162
  };
146
163
 
164
+ var getListHeight = function getListHeight() {
165
+ if (typeof listHeight === 'number' && options !== null && options !== void 0 && options.length) {
166
+ if (listHeight <= options.length * listItemHeight) {
167
+ return listHeight;
168
+ }
169
+ }
170
+
171
+ return 0;
172
+ };
173
+
147
174
  var multipleRender = function multipleRender() {
148
175
  return /*#__PURE__*/React.createElement("div", {
149
176
  className: "ald-multiple-option-list"
150
- }, options === null || options === void 0 ? void 0 : options.map(function (option) {
177
+ }, /*#__PURE__*/React.createElement(List, {
178
+ data: options || [],
179
+ "data-id": "list",
180
+ height: getListHeight(),
181
+ itemHeight: listItemHeight,
182
+ itemKey: "value"
183
+ }, function (option) {
151
184
  var isSelected = selectedOptions.some(function (selectedOption) {
152
185
  return selectedOption.value === option.value;
153
186
  });
154
- return /*#__PURE__*/React.createElement(MultipleList, {
187
+ return /*#__PURE__*/React.createElement(MultipleOption, {
155
188
  key: option.value,
156
189
  selected: isSelected,
190
+ className: option.className,
157
191
  option: option,
158
192
  disabled: option.disabled,
159
193
  onChange: function onChange(selected) {
@@ -178,13 +212,20 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
178
212
  var singleRender = function singleRender() {
179
213
  return /*#__PURE__*/React.createElement("div", {
180
214
  className: "ald-single-option-list"
181
- }, options === null || options === void 0 ? void 0 : options.map(function (option) {
215
+ }, /*#__PURE__*/React.createElement(List, {
216
+ data: options || [],
217
+ "data-id": "list",
218
+ height: getListHeight(),
219
+ itemHeight: listItemHeight,
220
+ itemKey: "value"
221
+ }, function (option) {
182
222
  var isSelected = selectedOptions.some(function (selectedOption) {
183
223
  return selectedOption.value === option.value;
184
224
  });
185
225
  return /*#__PURE__*/React.createElement(SingleOption, {
186
226
  key: option.value,
187
227
  selected: isSelected,
228
+ className: option.className,
188
229
  option: option,
189
230
  disabled: option.disabled,
190
231
  onChange: function onChange() {
@@ -196,7 +237,18 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
196
237
 
197
238
  var getDropdownRender = function getDropdownRender() {
198
239
  if (dropdownRender) {
199
- return dropdownRender;
240
+ if (isMultiple) {
241
+ var menu = multipleRender();
242
+ return function () {
243
+ return dropdownRender(menu);
244
+ };
245
+ } else {
246
+ var _menu = singleRender();
247
+
248
+ return function () {
249
+ return dropdownRender(_menu);
250
+ };
251
+ }
200
252
  } else if (Array.isArray(options) && options.length > 0) {
201
253
  if (!isMultiple) {
202
254
  return singleRender;
@@ -245,7 +297,11 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
245
297
  };
246
298
 
247
299
  useEffect(function () {
248
- setSelectedOptions(getSelectedOptionsFromValue(isMultiple, options, value));
300
+ if (updatedRef.current) {
301
+ setSelectedOptions(getSelectedOptionsFromValue(isMultiple, options, value));
302
+ } else {
303
+ updatedRef.current = true;
304
+ }
249
305
  }, [value]);
250
306
  return /*#__PURE__*/React.createElement("div", {
251
307
  className: classNames('ald-select', className, {
@@ -274,6 +330,7 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
274
330
  maxTagCount: "responsive",
275
331
  ref: ref,
276
332
  tagRender: tagRender,
333
+ onChange: onChange,
277
334
  popupClassName: classNames('ald-select-popup', popupClassName),
278
335
  maxTagPlaceholder: maxTagPlaceholder,
279
336
  className: classNames({
@@ -285,6 +342,10 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
285
342
  style: {
286
343
  width: '100%'
287
344
  },
345
+ suffixIcon: /*#__PURE__*/React.createElement(FoldDownFill, {
346
+ size: suffixIconSizeMap[props.size || 'middle'],
347
+ fill: theme.NL50
348
+ }),
288
349
  onDropdownVisibleChange: function onDropdownVisibleChange(open) {
289
350
  setIsOpen(open);
290
351
 
@@ -11,7 +11,7 @@
11
11
  padding-right: 0;
12
12
 
13
13
  &.ald-select-popup {
14
- max-height: 264px;
14
+ // max-height: 264px;
15
15
  overflow-y: auto;
16
16
  overflow-y: overlay;
17
17
  }
@@ -23,9 +23,14 @@
23
23
  box-sizing: border-box;
24
24
  border: 1px solid @BG60;
25
25
  border-radius: 4px;
26
+ background-color: @BG100;
26
27
  // padding: 0 4px;
27
28
  cursor: pointer;
28
- width:100%;
29
+ width: 100%;
30
+
31
+ .ant-select-selector {
32
+ color: @NL0;
33
+ }
29
34
 
30
35
  .ald-select-prefix {
31
36
  color: @NL40;
@@ -50,7 +55,6 @@
50
55
  border: none;
51
56
  }
52
57
  }
53
-
54
58
  }
55
59
 
56
60
  .ant-select-selection-overflow {
@@ -5,20 +5,31 @@
5
5
  justify-content: space-between;
6
6
  flex-direction: column;
7
7
  color: @NL0;
8
- font-size: 14px;
8
+ font-size: 13px;
9
9
  line-height: 20px;
10
10
 
11
11
  }
12
12
 
13
13
  .ald-multiple-option{
14
14
  padding: 8px 14px;
15
- height: 20px;
15
+ // height: 20px;
16
16
  margin-left: 0;
17
17
  display: flex;
18
+ height: 36px;
19
+ box-sizing: border-box;
18
20
 
19
21
  &:hover{
20
22
  background-color: @BG90;
21
23
  }
24
+
25
+ &.ald-multiple-option-disabled{
26
+ opacity: 0.5;
27
+
28
+ &:hover{
29
+ background: none;
30
+ cursor: default;
31
+ }
32
+ }
22
33
  }
23
34
 
24
35
  .ald-multiple-option-label{
@@ -1,6 +1,6 @@
1
1
  .ald-single-option-list{
2
2
  color: @NL0;
3
- font-size: 14px;
3
+ font-size: 13px;
4
4
  line-height: 20px;
5
5
 
6
6
  .ald-single-option{
@@ -8,6 +8,8 @@
8
8
  display: flex;
9
9
  align-items: center;
10
10
  margin-left: 0;
11
+ height: 36px;
12
+ box-sizing: border-box;
11
13
 
12
14
  &:hover{
13
15
  background-color: @BG90;
@@ -23,5 +25,14 @@
23
25
  .ald-single-option-text{
24
26
  white-space: nowrap;
25
27
  }
28
+
29
+ &.ald-single-option-disabled{
30
+ opacity: 0.5;
31
+
32
+ &:hover{
33
+ background: none;
34
+ cursor: default;
35
+ }
36
+ }
26
37
  }
27
38
  }
@@ -63,8 +63,10 @@
63
63
  &-thead {
64
64
  flex: 1;
65
65
  overflow: hidden;
66
- font-size: 14px;
66
+ font-size: 13px;
67
67
  font-weight: 600;
68
+ background-color: @BG80;
69
+ mix-blend-mode: multiply;
68
70
 
69
71
  .ald-table-row {
70
72
  min-width: 9999px; // 防止拖动时的闪动
@@ -76,7 +78,6 @@
76
78
  padding: 6px 16px;
77
79
  color: @NL0;
78
80
  line-height: 20px;
79
- background-color: @BG80;
80
81
  height: 100%;
81
82
 
82
83
  .ald-table-cell-content {
@@ -92,7 +93,7 @@
92
93
  z-index: 1;
93
94
  display: inline-block;
94
95
  width: 12px;
95
- height: 14px;
96
+ height: 1em;
96
97
  transform: translateY(-50%);
97
98
  touch-action: none;
98
99
 
@@ -101,6 +102,7 @@
101
102
  width: 1px;
102
103
  height: 100%;
103
104
  background-color: @BG70;
105
+ mix-blend-mode: multiply;
104
106
  content: '';
105
107
  }
106
108
  }
@@ -130,7 +132,7 @@
130
132
  display: flex;
131
133
  align-items: center;
132
134
  padding-left: 16px;
133
- color: @NL40;
135
+ color: @NL0;
134
136
 
135
137
  .ald-table-cell-container {
136
138
  width: 100%;
@@ -192,8 +194,8 @@
192
194
 
193
195
  &-left {
194
196
  color: @NL0;
195
- font-weight: 500;
196
- font-size: 14px;
197
+ font-weight: 600;
198
+ font-size: 13px;
197
199
  }
198
200
 
199
201
  &-right {
@@ -202,7 +204,7 @@
202
204
  justify-content: flex-end;
203
205
  height: 28px;
204
206
  color: @NL0;
205
- font-size: 14px;
207
+ font-size: 13px;
206
208
  }
207
209
  }
208
210
 
@@ -39,6 +39,21 @@ export interface ITabsProps extends Omit<TabsProps, 'size'> {
39
39
  tabPosition?: 'left' | 'right' | 'top' | 'bottom';
40
40
  className?: string;
41
41
  children?: React.ReactNode;
42
+ /**
43
+ * @description header行背景颜色
44
+ * @default -
45
+ */
46
+ headerBackgroundColor?: string;
47
+ /**
48
+ * @description tab 宽度等分,只有tabPosition 为top的时候生效
49
+ * @default false
50
+ */
51
+ monospace?: boolean;
52
+ /**
53
+ * @description tab 填充padding,默认false
54
+ * @default false
55
+ */
56
+ padding?: boolean | number;
42
57
  }
43
58
  declare function Tabs(props: ITabsProps): JSX.Element;
44
59
  declare namespace Tabs {
@@ -1,4 +1,4 @@
1
- var _excluded = ["size", "className", "popupClassName", "adaptHeight"];
1
+ var _excluded = ["size", "className", "popupClassName", "adaptHeight", "style", "monospace", "headerBackgroundColor", "tabPosition", "padding"];
2
2
 
3
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
 
@@ -12,17 +12,25 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
12
12
 
13
13
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
14
14
 
15
- import React from 'react'; // import AntdTabs, { TabsProps } from 'antd/lib/tabs';
15
+ import React, { useMemo } from 'react'; // import AntdTabs, { TabsProps } from 'antd/lib/tabs';
16
16
 
17
- import { Tabs as AntdTabs } from 'antd';
18
17
  import { MoreVerticalLine } from '@aloudata/icons-react';
19
- import TabPane from "./TabPane";
18
+ import { Tabs as AntdTabs } from 'antd';
20
19
  import classNames from 'classnames';
20
+ import TabPane from "./TabPane";
21
21
  export default function Tabs(props) {
22
22
  var size = props.size,
23
23
  className = props.className,
24
24
  popupClassName = props.popupClassName,
25
25
  adaptHeight = props.adaptHeight,
26
+ _props$style = props.style,
27
+ style = _props$style === void 0 ? {} : _props$style,
28
+ monospace = props.monospace,
29
+ headerBackgroundColor = props.headerBackgroundColor,
30
+ _props$tabPosition = props.tabPosition,
31
+ tabPosition = _props$tabPosition === void 0 ? 'top' : _props$tabPosition,
32
+ _props$padding = props.padding,
33
+ padding = _props$padding === void 0 ? false : _props$padding,
26
34
  otherProps = _objectWithoutProperties(props, _excluded);
27
35
 
28
36
  var tabsProps = _objectSpread({}, otherProps);
@@ -31,17 +39,40 @@ export default function Tabs(props) {
31
39
  tabsProps.size = size;
32
40
  }
33
41
 
42
+ var _monospace = tabPosition !== 'top' ? false : monospace;
43
+
44
+ var _padding = useMemo(function () {
45
+ if (tabPosition !== 'top') return 0;
46
+
47
+ if (typeof padding === 'number') {
48
+ return padding;
49
+ }
50
+
51
+ if (typeof padding === 'boolean' && padding) {
52
+ return 16;
53
+ }
54
+
55
+ return 0;
56
+ }, [padding, tabPosition]);
57
+
34
58
  return /*#__PURE__*/React.createElement(AntdTabs, _extends({
35
59
  moreIcon: /*#__PURE__*/React.createElement("div", {
36
60
  className: "ald-tabs-more-icon"
37
61
  }, /*#__PURE__*/React.createElement(MoreVerticalLine, {
38
62
  color: "currentColor"
39
63
  })),
40
- tabBarGutter: 24,
64
+ style: Object.assign(style, {
65
+ '--header-bg-color': headerBackgroundColor,
66
+ '--tabs-padding': "".concat(_padding, "px")
67
+ }),
68
+ tabPosition: tabPosition,
69
+ tabBarGutter: _monospace ? 0 : 24,
41
70
  popupClassName: classNames(popupClassName, 'ald-tabs-dropdown'),
42
71
  className: classNames('ald-tabs', className, {
43
72
  'ald-adapt-height': adaptHeight,
44
- 'ald-tabs-default': size !== 'large'
73
+ 'ald-tabs-default': size !== 'large',
74
+ 'ald-tabs-monospace': _monospace,
75
+ 'ald-tabs-padding': !!padding
45
76
  })
46
77
  }, tabsProps));
47
78
  }
@@ -22,6 +22,10 @@
22
22
  .ant-tabs.ald-tabs {
23
23
  &.ant-tabs {
24
24
  color: @NL40;
25
+
26
+ .ant-tabs-nav {
27
+ background-color: var(--header-bg-color);
28
+ }
25
29
  }
26
30
 
27
31
  .ant-tabs-tab {
@@ -125,12 +129,18 @@
125
129
  &.ant-tabs-bottom > .ant-tabs-nav,
126
130
  &.ant-tabs-top > div > .ant-tabs-nav,
127
131
  &.ant-tabs-bottom > div > .ant-tabs-nav {
128
- margin: 0 0 20px;
132
+ margin-bottom: 16px;
129
133
 
130
134
  &::before {
131
135
  border-color: @BG70;
132
136
  }
133
137
  }
138
+
139
+ &.ant-tabs-left {
140
+ .ant-tabs-nav-list{
141
+ padding-right: 24px;
142
+ }
143
+ }
134
144
  }
135
145
 
136
146
  .ald-tabs-dropdown {
@@ -166,3 +176,30 @@
166
176
  }
167
177
  }
168
178
  }
179
+
180
+ .ald-tabs-monospace {
181
+ .ant-tabs-nav {
182
+ .ant-tabs-nav-wrap {
183
+ .ant-tabs-nav-list {
184
+ width: 100%;
185
+
186
+ .ant-tabs-tab {
187
+ flex-grow: 1;
188
+ justify-content: center;
189
+ }
190
+ }
191
+ }
192
+ }
193
+ }
194
+
195
+ .ald-tabs-padding {
196
+ .ant-tabs-nav {
197
+ .ant-tabs-nav-wrap{
198
+ margin: 0 var(--tabs-padding);
199
+ }
200
+ }
201
+
202
+ .ant-tabs-content-holder{
203
+ padding: 0 var(--tabs-padding) var(--tabs-padding);
204
+ }
205
+ }
@@ -1,13 +1,30 @@
1
- import { Button, notification } from "../..";
1
+ import { Button, notification, Space } from "../..";
2
2
  import React from 'react';
3
3
  export default (function () {
4
- var notices = function notices() {
5
- notification.error({
6
- message: 'Notification Title'
4
+ var notices = function notices(type) {
5
+ notification[type]({
6
+ message: 'Notification Message',
7
+ description: 'description,description,description,description,description,description,description,description'
7
8
  });
8
9
  };
9
10
 
10
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
11
- onClick: notices
12
- }, "Notification error"));
11
+ return /*#__PURE__*/React.createElement(Space, {
12
+ direction: "vertical"
13
+ }, /*#__PURE__*/React.createElement(Button, {
14
+ onClick: function onClick() {
15
+ return notices('success');
16
+ }
17
+ }, "Notification success with message\u3001description"), /*#__PURE__*/React.createElement(Button, {
18
+ onClick: function onClick() {
19
+ return notices('error');
20
+ }
21
+ }, "Notification error with message\u3001description"), /*#__PURE__*/React.createElement(Button, {
22
+ onClick: function onClick() {
23
+ return notices('warning');
24
+ }
25
+ }, "Notification warning with message\u3001description"), /*#__PURE__*/React.createElement(Button, {
26
+ onClick: function onClick() {
27
+ return notices('info');
28
+ }
29
+ }, "Notification info with message\u3001description"));
13
30
  });
@@ -1,2 +1,10 @@
1
- import { notification } from 'antd';
1
+ import type { ArgsProps } from 'antd/es/notification/interface';
2
+ declare const notification: {
3
+ open: (config: ArgsProps) => void;
4
+ success: (config: ArgsProps) => void;
5
+ error: (config: ArgsProps) => void;
6
+ warning: (config: ArgsProps) => void;
7
+ info: (config: ArgsProps) => void;
8
+ destroy: (key?: string) => void;
9
+ };
2
10
  export default notification;