diginet-core-ui 1.3.85 → 1.3.86

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.
Files changed (51) hide show
  1. package/components/accordion/css.js +10 -10
  2. package/components/accordion/details.js +2 -2
  3. package/components/alert/index.js +3 -3
  4. package/components/alert/notify.js +2 -2
  5. package/components/avatar/index.js +3 -3
  6. package/components/badge/index.js +6 -6
  7. package/components/button/icon.js +9 -9
  8. package/components/button/index.js +9 -9
  9. package/components/button/more.js +2 -2
  10. package/components/card/index.js +6 -6
  11. package/components/chip/index.js +7 -7
  12. package/components/form-control/attachment/index.js +335 -479
  13. package/components/form-control/calendar/function.js +5 -5
  14. package/components/form-control/checkbox/index.js +6 -6
  15. package/components/form-control/date-picker/index.js +2 -2
  16. package/components/form-control/date-range-picker/index.js +2 -2
  17. package/components/form-control/dropdown/index.js +335 -451
  18. package/components/form-control/dropdown-box/index.js +2 -2
  19. package/components/form-control/input-base/index.js +52 -58
  20. package/components/form-control/radio/index.js +4 -4
  21. package/components/form-control/toggle/index.js +2 -2
  22. package/components/grid/index.js +2 -2
  23. package/components/image/index.js +3 -3
  24. package/components/modal/body.js +2 -2
  25. package/components/modal/footer.js +3 -3
  26. package/components/modal/header.js +3 -3
  27. package/components/modal/modal.js +2 -2
  28. package/components/paging/page-info.js +6 -6
  29. package/components/paging/page-selector2.js +3 -3
  30. package/components/popover/footer.js +3 -3
  31. package/components/popover/header.js +3 -3
  32. package/components/popup/v2/index.js +5 -5
  33. package/components/rating/index.js +4 -4
  34. package/components/slider/slider-container.js +5 -5
  35. package/components/status/index.js +4 -4
  36. package/components/tab/tab-header.js +2 -2
  37. package/components/tab/tab-panel.js +2 -2
  38. package/components/tab/tab.js +7 -7
  39. package/components/tooltip/index.js +2 -2
  40. package/components/tree-view/css.js +4 -4
  41. package/components/tree-view/index.js +4 -4
  42. package/global/index.js +12 -0
  43. package/icons/effect.js +57 -59
  44. package/package.json +1 -1
  45. package/readme.md +6 -0
  46. package/styles/general.js +280 -114
  47. package/styles/utils.js +10 -0
  48. package/utils/array/array.js +18 -25
  49. package/utils/sb-template.js +2 -2
  50. package/utils/string/string.js +1 -9
  51. package/utils/validate.js +2 -2
@@ -1,54 +1,49 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
- import { Fragment, memo, useState, useEffect, useMemo, useRef, useImperativeHandle, forwardRef } from 'react';
4
- import ReactDOM from 'react-dom';
5
- import { createPortal } from 'react-dom';
6
- import PropTypes from 'prop-types';
7
- import { jsx, css } from '@emotion/core';
8
- import { InputBase, Chip, CircularProgress, Checkbox, TreeView, HelperText, Label, ButtonIcon, Typography } from "../../";
9
- import { mapParent, randomString, updatePosition } from "../../../utils";
3
+ import { css, jsx } from '@emotion/core';
4
+ import { Avatar, ButtonIcon, Checkbox, Chip, CircularProgress, HelperText, InputBase, Label, TreeView, Typography } from "../..";
10
5
  import { getGlobal } from "../../../global";
11
- import { alignCenter, backgroundTransparent, border, borderBox, borderNone, borderRadius4px, breakWord, cursorPointer, displayBlock, flexColReverse, flexRow, flexWrap, justifyCenter, justifyStart, outlineNone, overflowAuto, overflowHidden, parseWidth, parseWidthHeight, pointerEventsNone, positionAbsolute, positionFixed, positionRelative, userSelectNone } from "../../../styles/general";
12
- import isMobile from "../../../utils/isMobile";
13
- import theme from "../../../theme/settings";
14
- import Avatar from "../../avatar";
6
+ import PropTypes from 'prop-types';
7
+ import { forwardRef, Fragment, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
8
+ import ReactDOM, { createPortal } from 'react-dom';
9
+ import { bgColor, bgTransparent, border, borderNone, borderRadius, borderRadius4px, boxBorder, breakWord, cursorDefault, cursorNotAllowed, cursorPointer, displayBlock, displayFlex, flexColReverse, flexRow, flexWrap, inset, insetX, itemsCenter, justifyCenter, justifyStart, mgb, mgl, mgr, mgt, outlineNone, overflowAuto, overflowHidden, parseHeight, parseMaxHeight, parseMaxWidth, parseMinHeight, parseWidth, parseWidthHeight, pd, pdb, pdl, pdt, pdy, pointerEventsNone, positionAbsolute, positionFixed, positionRelative, userSelectNone, z } from "../../../styles/general";
10
+ import { useTheme } from "../../../theme";
11
+ import { classNames, isMobile, mapParent, randomString, refType as ref, updatePosition } from "../../../utils";
15
12
  const {
16
13
  colors: {
17
14
  system: {
18
- active,
15
+ active: systemActive,
19
16
  disabled: systemDisabled,
20
- rest,
21
- white
17
+ rest: systemRest,
18
+ white: systemWhite
22
19
  },
23
20
  semantic: {
24
- danger
21
+ danger: semanticDanger
25
22
  },
26
23
  fill: {
27
- hover,
28
- 'scrollbar-tabbar': scrollbar
24
+ hover: fillHover,
25
+ 'scrollbar-tabbar': fillScrollbar
29
26
  },
30
27
  line: {
31
- focus
28
+ focus: lineFocus
32
29
  },
33
30
  text: {
34
- main,
35
- sub
31
+ main: textMain,
32
+ sub: textSub
36
33
  }
37
34
  },
38
35
  typography: {
39
- paragraph1,
40
- paragraph3
36
+ paragraph1
41
37
  },
42
- spacing,
43
- zIndex: zIndexCORE
44
- } = theme;
38
+ spacing
39
+ } = useTheme();
45
40
  const timing = {},
46
41
  currentValue = {},
47
42
  currentObjectDefault = {},
48
43
  isSearch = {},
49
44
  allValue = {};
50
45
  const separatorPattern = /\{\w+\}/g;
51
- const regexBetween = /[^{\}]+(?=})/g; // eslint-disable-line
46
+ const regexBetween = /[^{}]+(?=})/g;
52
47
  const regexInclude = /{|}/g;
53
48
  const checkHasValue = value => {
54
49
  return Array.isArray(value) ? value.length > 0 : value === 0 || !!value;
@@ -60,61 +55,59 @@ const convertData = (dt, valueExpr) => {
60
55
  return valueTemp;
61
56
  };
62
57
  const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
63
- viewType,
64
- itemMode,
65
- required,
58
+ allowSearch,
59
+ children,
66
60
  className,
67
- label,
68
- defaultValue,
69
- value: valueProp,
70
- searchDelayTime,
71
- limit,
72
- total,
73
- placeholder,
74
- error,
75
- displayExpr,
76
- subText,
77
- valueExpr,
78
- noDataText,
79
- iconDefault,
80
- iconExpr,
81
- treeViewID,
82
- treeViewParentID,
83
61
  clearAble,
84
62
  closeAfterSelect,
63
+ dataSource,
64
+ defaultValue,
85
65
  disabled,
86
- readOnly,
87
- multiple,
88
- allowSearch,
89
- selectBox,
66
+ displayExpr,
67
+ dropdownItemStyle,
68
+ error,
69
+ helperTextProps,
70
+ iconExpr,
71
+ inputProps,
72
+ inputStyle,
73
+ itemMode,
74
+ label,
75
+ labelProps,
76
+ limit,
90
77
  loading,
91
- dataSource,
92
- onKeyDown,
93
- onInput,
78
+ maximumSelectionLength,
79
+ multilineSelectedItem,
80
+ multiple,
81
+ noDataText,
94
82
  onChange,
95
- onLoadMore,
96
83
  onClosed,
84
+ onInput,
85
+ onKeyDown,
86
+ onLoadMore,
87
+ placeholder,
88
+ readOnly,
97
89
  renderItem,
98
90
  renderSelectedItem,
99
- valueObjectDefault,
100
- style,
101
- inputProps,
102
- inputStyle,
103
- formStyle,
104
- labelProps,
105
- errorStyle,
106
- children,
107
- dropdownItemStyle,
91
+ required,
92
+ searchDelayTime,
108
93
  searchExpr,
109
94
  searchMode,
110
- maximumSelectionLength,
111
- multilineSelectedItem
95
+ selectBox,
96
+ style,
97
+ subText,
98
+ total,
99
+ treeViewID,
100
+ treeViewParentID,
101
+ value: valueProp,
102
+ valueExpr,
103
+ valueObjectDefault,
104
+ viewType
112
105
  }, reference) => {
106
+ if (!reference) reference = useRef(null);
113
107
  if (multiple && selectBox === undefined) selectBox = true;
114
108
  if (typeof searchExpr === 'string') searchExpr = [searchExpr];
115
109
  const ref = useRef(null);
116
110
  const dropdownRef = useRef(null);
117
- const loadingProgressRef = useRef(null);
118
111
  const timerRef = useRef(null);
119
112
  const formRef = useRef(null);
120
113
  const inputRef = useRef(null);
@@ -141,12 +134,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
141
134
  const [valueMulti, setValueMulti] = useState(valueTemp);
142
135
  const _isMobile = isMobile.any();
143
136
  const _InputCSS = InputCSS(multiple, typeof renderSelectedItem === 'function');
144
- const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, typeof renderSelectedItem === 'function', disabled);
145
- const _IconCSS = IconCSS(viewType, loading, showClear);
137
+ const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, disabled, readOnly);
138
+ const _IconCSS = IconCSS(viewType);
146
139
  const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, disabled, placeholder, _DropdownInputCSS.name);
147
140
  const _DropdownListCSS = DropdownListCSS(loading);
148
141
  const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
149
- const _DropdownRootCSS = DropdownRootCSS(_DropdownFormCSS.name, _IconCSS.name, _DropdownInputCSS.name);
142
+ const _DropdownRootCSS = DropdownRootCSS(_DropdownFormCSS.name, _DropdownInputCSS.name);
150
143
 
151
144
  /* Start handler */
152
145
  const triggerInput = e => {
@@ -175,26 +168,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
175
168
  if (disabled || readOnly || loading) return;
176
169
  if (!dropdownListRef.current) {
177
170
  if (!multiple || !Array.from(inputRef.current.querySelectorAll('.DGN-UI-Chip')).some(item => item.contains(e === null || e === void 0 ? void 0 : e.target))) {
178
- if ((typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none') && !multiple) {
179
- var _inputRef$current$chi;
180
- inputRef.current.innerHTML = inputRef.current.textContent.trim();
181
- // if (!allowSearch) inputRef.current.contentEditable = true;
182
- const caret = (_inputRef$current$chi = inputRef.current.childNodes) !== null && _inputRef$current$chi !== void 0 && _inputRef$current$chi.length ? 1 : 0;
183
- const range = document.createRange();
184
- range.setStart(inputRef.current, caret);
185
- range.setEnd(inputRef.current, caret);
186
- const sel = window.getSelection();
187
- sel.removeAllRanges();
188
- sel.addRange(range);
189
- }
190
171
  setOpenState(true);
191
172
  }
192
- } else if (multiple || itemMode === 'treeview') {
193
- if (searchRef.current) {
194
- searchRef.current.focus();
195
- } else if (children && dropdownListRef.current && dropdownListRef.current.querySelector('input')) {
196
- dropdownListRef.current.querySelector('input').focus();
197
- }
198
173
  }
199
174
  };
200
175
  const onClickOutsideOfInput = event => {
@@ -213,7 +188,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
213
188
  const dropdown = children ? jsx("div", {
214
189
  css: _DropdownListCSS,
215
190
  ref: dropdownListRef,
216
- className: 'DGN-Dropdown-List'
191
+ className: 'DGN-Dropdown-List',
192
+ onKeyDown: moveOnItem,
193
+ tabIndex: -1
217
194
  }, dataSource !== null && dataSource !== void 0 && dataSource.length ? children : EmptyDataText) : itemMode === 'normal' ? mapDropdown(null, keyArr) : mapTreeView();
218
195
  const {
219
196
  innerHeight
@@ -241,7 +218,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
241
218
  css: _DropdownCSS,
242
219
  ref: dropdownRef,
243
220
  className: `DGN-UI-Portal DGN-Dropdown-${unique}`
244
- }, (multiple || allowSearch) && itemMode === 'normal' && !children && jsx("div", {
221
+ }, (multiple || allowSearch) && itemMode === 'normal' && !children ? jsx("div", {
245
222
  className: 'DGN-Dropdown-Search'
246
223
  }, jsx(InputBase, {
247
224
  inputRef: searchRef,
@@ -253,19 +230,18 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
253
230
  },
254
231
  onKeyDown: pressESCHandler,
255
232
  autoFocus: true
256
- })), multiple && maximumSelectionLength && jsx(Typography, {
233
+ })) : null, multiple && maximumSelectionLength ? jsx(Typography, {
257
234
  style: {
258
235
  padding: spacing([2, 4])
259
236
  }
260
- }, getGlobal('selected'), " ", (valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) || 0, "/", maximumSelectionLength), jsx("div", {
237
+ }, getGlobal('selected'), " ", (valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) || 0, "/", maximumSelectionLength) : null, jsx("div", {
261
238
  className: 'DGN-Dropdown-Box'
262
- }, dropdown), loading && jsx("div", {
239
+ }, dropdown), loading ? jsx("div", {
263
240
  css: LoadingProgressCSS,
264
- ref: loadingProgressRef,
265
241
  className: 'DGN-Dropdown-Loading-Progress'
266
242
  }, jsx(CircularProgress, {
267
- size: 'xs'
268
- })));
243
+ size: 24
244
+ })) : null);
269
245
  if (!((multiple || allowSearch) && itemMode === 'normal' && !children)) {
270
246
  inputRef.current.addEventListener('keydown', pressESCHandler);
271
247
  }
@@ -274,7 +250,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
274
250
  window.addEventListener('resize', customizeWidthDropdown);
275
251
  document.addEventListener('wheel', onWheelHandler);
276
252
  document.addEventListener('mousedown', onClickOutsideOfInput);
277
- dropdownListRef.current && dropdownListRef.current.addEventListener('keydown', moveOnItem);
278
253
  if (onLoadMore && dataSource.length < total) {
279
254
  dropdownListRef.current && dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
280
255
  }
@@ -320,15 +295,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
320
295
  };
321
296
  const closeDropdown = () => {
322
297
  if (dropdownRef.current) {
323
- // dropdownRef.current.style.pointerEvents = `none`;
324
- // dropdownRef.current.style.transition = `opacity 0.5s`;
325
- // dropdownRef.current.style.opacity = 0;
326
- // timing[unique + 'Box'] = setTimeout(() => {
327
- // clearTimeout(timing[unique + 'Box']);
328
- // timing[unique + 'Box'] = null;
329
- // dropdownRef.current?.remove();
330
- // dropdownListRef.current = null;
331
- // }, 300);
332
298
  setOpenState(false);
333
299
  document.removeEventListener('mousedown', onClickOutsideOfInput);
334
300
  window.removeEventListener('resize', customizeWidthDropdown);
@@ -337,12 +303,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
337
303
  dropdownListRef.current.removeEventListener('scroll', onLoadMoreHandler);
338
304
  dropdownListRef.current = null;
339
305
  }
340
- // if (!multiple) {
341
- // inputRef.current.removeEventListener('keydown', pressESCHandler);
342
- // inputRef.current.removeEventListener('input', onChangeInput);
343
- // }
344
306
  }
345
-
346
307
  document.documentElement.style.overflow = 'auto';
347
308
  if (searchRef.current) lastSearchRef.current = '';
348
309
  onClosed === null || onClosed === void 0 ? void 0 : onClosed();
@@ -358,7 +319,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
358
319
  (_dropdownRef$current$ = dropdownRef.current.querySelector('.DGN-Dropdown-Box')) === null || _dropdownRef$current$ === void 0 ? void 0 : _dropdownRef$current$.remove();
359
320
  ReactDOM.render(dropdown, dropdownRef.current.appendChild(el));
360
321
  setTimeout(() => {
361
- dropdownListRef.current && dropdownListRef.current.addEventListener('keydown', moveOnItem);
362
322
  if (onLoadMore && dataSource.length < total) {
363
323
  dropdownListRef.current && dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
364
324
  }
@@ -367,10 +327,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
367
327
  }
368
328
  };
369
329
  const handleRenderBySearch = (data, searchValue) => {
370
- let existExpr = [];
330
+ let existExpr;
371
331
  typeof data === 'object' ? existExpr = searchExpr.filter(value => Object.keys(data).includes(value)) : existExpr = [data];
372
332
  return existExpr.every(key => {
373
- // return searchByMode(data?.[key] || key.toString(), searchValue);
374
333
  const _data = (data === null || data === void 0 ? void 0 : data[key]) || key.toString();
375
334
  if (searchMode === 'contains') {
376
335
  if (_data.indexOf(searchValue) !== -1) return false;
@@ -379,7 +338,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
379
338
  if (_data.lastIndexOf(searchValue) === 0) return false;
380
339
  }
381
340
  if (searchMode === 'equals') {
382
- if (_data == searchValue) return false;
341
+ if (_data === searchValue) return false;
383
342
  }
384
343
  return true;
385
344
  });
@@ -419,10 +378,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
419
378
  index
420
379
  });
421
380
  } else if (subText) {
422
- displayText = jsx(Fragment, null, jsx("span", {
423
- className: 'DGN-UI-Dropdown-PrimaryText'
424
- }, displayText), jsx("span", {
425
- className: 'DGN-UI-Dropdown-SubText'
381
+ displayText = jsx(Fragment, null, jsx(Typography, {
382
+ className: 'DGN-UI-Dropdown-PrimaryText',
383
+ type: 'p1'
384
+ }, displayText), jsx(Typography, {
385
+ className: 'DGN-UI-Dropdown-SubText',
386
+ type: 'p3',
387
+ color: textSub
426
388
  }, typeof subText === 'function' ? subText({
427
389
  data,
428
390
  index
@@ -431,6 +393,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
431
393
  const value = typeof data === 'object' ? data[valueExpr] : data;
432
394
  let itemDisabled = typeof data === 'object' ? data['disabled'] : false;
433
395
  const icon = getIconFromData(data);
396
+ const text = jsx(Typography, {
397
+ type: 'p1'
398
+ }, displayText);
434
399
  if (multiple && selectBox) {
435
400
  const checked = Array.isArray(valueMulti) ? valueMulti.includes(value) : valueMulti.includes(value);
436
401
  const isMaximumSelection = maximumSelectionLength === (valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length);
@@ -453,19 +418,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
453
418
 
454
419
  tabIndex: -1
455
420
  }, jsx(Checkbox, {
421
+ css: CheckBoxCSS,
456
422
  forTreeView: true,
457
423
  checked: checked,
458
- style: {
459
- width: '100%',
460
- height: '100%',
461
- padding: '0 16px'
462
- },
463
424
  value: value,
464
425
  disabled: itemDisabled,
465
426
  onChange: () => onChangeValue(displayText, value, icon, data, index)
466
- }, icon && icon, jsx("div", {
467
- css: DropdownTextCSS
468
- }, displayText))));
427
+ }, icon, text)));
469
428
  } else {
470
429
  items.push(jsx("div", {
471
430
  key: index,
@@ -481,30 +440,24 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
481
440
  },
482
441
  tabIndex: -1,
483
442
  style: dropdownItemStyle
484
- }, icon && icon, jsx("div", {
485
- css: DropdownTextCSS
486
- }, displayText)));
443
+ }, icon, text));
487
444
  }
488
- // if (items?.length === limit) {
489
- // timerRef.current = setTimeout(() => {
490
- // loadMoreItemsDropdown(index + 1, pattern);
491
- // }, 1000);
492
- // break;
493
- // }
494
445
  }
495
-
496
446
  return jsx("div", {
497
447
  css: _DropdownListCSS,
498
448
  ref: dropdownListRef,
499
- className: 'DGN-Dropdown-List'
449
+ className: 'DGN-Dropdown-List',
450
+ onKeyDown: moveOnItem,
451
+ tabIndex: -1
500
452
  }, items !== null && items !== void 0 && items.length ? items : EmptyDataText);
501
453
  };
502
454
  const mapTreeView = () => {
503
- // if (!treeView[unique]) {
504
455
  return jsx("div", {
505
456
  css: _DropdownListCSS,
506
457
  ref: dropdownListRef,
507
- className: 'DGN-Dropdown-List'
458
+ className: 'DGN-Dropdown-List',
459
+ onKeyDown: moveOnItem,
460
+ tabIndex: -1
508
461
  }, dataSource !== null && dataSource !== void 0 && dataSource.length ? jsx(TreeView, {
509
462
  dataSource: dataSource,
510
463
  displayExpr: displayExpr,
@@ -523,10 +476,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
523
476
  onChange: (e, value) => onChangeValue('', multiple ? value : e.value),
524
477
  renderItem: renderItem
525
478
  }) : EmptyDataText);
526
- // }
527
- // return treeView[unique];
528
479
  };
529
-
530
480
  const loadMoreItemsDropdown = (i = 0, pattern) => {
531
481
  var _currentObjectDefault2, _displayExpr3;
532
482
  const dataSourceUsable = [...dataSource];
@@ -557,16 +507,22 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
557
507
  if (pattern && !new RegExp(pattern).test(displayText.normalize())) continue;
558
508
  const value = typeof data === 'object' ? data[valueExpr] : data;
559
509
  const icon = getIconFromData(data);
510
+ const text = jsx(Typography, {
511
+ type: 'p1'
512
+ }, displayText);
560
513
  if (renderItem && typeof renderItem === 'function') {
561
514
  displayText = renderItem({
562
515
  data,
563
516
  index: i
564
517
  });
565
518
  } else if (subText) {
566
- displayText = jsx(Fragment, null, jsx("span", {
567
- className: 'DGN-UI-Dropdown-PrimaryText'
568
- }, displayText), jsx("span", {
569
- className: 'DGN-UI-Dropdown-SubText'
519
+ displayText = jsx(Fragment, null, jsx(Typography, {
520
+ className: 'DGN-UI-Dropdown-PrimaryText',
521
+ type: 'p1'
522
+ }, displayText), jsx(Typography, {
523
+ className: 'DGN-UI-Dropdown-SubText',
524
+ type: 'p3',
525
+ color: textSub
570
526
  }, typeof subText === 'function' ? subText({
571
527
  data,
572
528
  index: i
@@ -583,20 +539,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
583
539
  if (multiple && selectBox) {
584
540
  const checked = Array.isArray(currentValue[unique]) ? currentValue[unique].includes(value) : [currentValue[unique]].includes(value);
585
541
  item = jsx(Checkbox, {
542
+ css: CheckBoxCSS,
586
543
  forTreeView: true,
587
- checked: checked,
588
- style: {
589
- width: '100%',
590
- height: '100%',
591
- padding: '0 16px'
592
- }
593
- }, icon && icon, jsx("div", {
594
- css: DropdownTextCSS
595
- }, displayText));
544
+ checked: checked
545
+ }, icon, text);
596
546
  } else {
597
- item = jsx(Fragment, null, icon && icon, jsx("div", {
598
- css: DropdownTextCSS
599
- }, displayText));
547
+ item = jsx(Fragment, null, icon, text);
600
548
  }
601
549
  if (!dropdownListRef.current) {
602
550
  return;
@@ -622,7 +570,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
622
570
  };
623
571
  const getIconFromData = (data, insideChip = false) => {
624
572
  if (!iconExpr || iconExpr === 'none') return null;
625
- let _src = iconDefault;
573
+ let _src;
626
574
  if (typeof iconExpr === 'string') _src = data[iconExpr];else {
627
575
  let prefix = iconExpr.prefix || '';
628
576
  const suffix = iconExpr.suffix || '';
@@ -723,10 +671,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
723
671
  if (timing[unique]) clearTimeout(timing[unique]);
724
672
  timing[unique] = setTimeout(() => {
725
673
  var _searchExpr2;
726
- // if (timerRef.current) {
727
- // clearTimeout(timerRef.current);
728
- // timerRef.current = null;
729
- // }
730
674
  renderDropdown(((_searchExpr2 = searchExpr) === null || _searchExpr2 === void 0 ? void 0 : _searchExpr2.length) > 0 ? value.normalize() : new RegExp(value.normalize(), 'gim'));
731
675
  }, timeout.current || searchDelayTime);
732
676
  };
@@ -746,10 +690,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
746
690
  } else if (multiple) {
747
691
  if (!Array.isArray(currentValue[unique])) currentValue[unique] = [];
748
692
  const newValueArr = [...currentValue[unique]];
749
- const newValueArrState = [...valueMulti];
693
+ // const newValueArrState = [...valueMulti];
750
694
  if (!currentValue[unique].some(v => JSON.stringify(v) === JSON.stringify(value))) {
751
695
  newValueArr.push(value);
752
- newValueArrState.push(value);
696
+ // newValueArrState.push(value);
753
697
  // if (valueProp === undefined) {
754
698
  // let item = null;
755
699
  // if (typeof renderSelectedItem === 'function') {
@@ -775,16 +719,15 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
775
719
  } else {
776
720
  const index = newValueArr.indexOf(value);
777
721
  newValueArr.splice(index, 1);
778
- newValueArrState.splice(index, 1);
722
+ // newValueArrState.splice(index, 1);
779
723
  // if (valueProp === undefined) {
780
724
  // const nodes = inputRef.current.querySelectorAll('.dropdown-item');
781
725
  // nodes[index]?.remove();
782
726
  // }
783
727
  }
784
-
785
- setValueMulti(newValueArrState);
728
+ // setValueMulti(newValueArrState);
786
729
  !!onChange && onChange({
787
- value: newValueArrState,
730
+ value: newValueArr,
788
731
  data
789
732
  });
790
733
  setTimeout(() => {
@@ -1098,15 +1041,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1098
1041
  useEffect(() => {
1099
1042
  inputRef.current.readOnly = readOnly || inputProps.readOnly;
1100
1043
  if (!readOnly && !disabled) {
1101
- inputRef.current.addEventListener('click', onClickInput);
1102
- inputRef.current.addEventListener('input', onChangeInput);
1103
1044
  !!onLoadMore && dropdownListRef.current && dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
1104
1045
  }
1105
- // else {
1106
- // if (multiple || allowSearch) {
1107
- // inputRef.current.contentEditable = false;
1108
- // }
1109
- // }
1110
1046
  if (disabled || readOnly || children) {
1111
1047
  inputRef.current.addEventListener('keydown', onPreventKeyDownHandler);
1112
1048
  } else {
@@ -1114,15 +1050,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1114
1050
  }
1115
1051
  return () => {
1116
1052
  if (!ref.current || !inputRef.current || !iconRef.current) return;
1117
- if (!readOnly && !disabled) {
1118
- inputRef.current.removeEventListener('click', onClickInput);
1119
- inputRef.current.removeEventListener('input', onChangeInput);
1120
- }
1121
- // else {
1122
- // if (multiple && !allowSearch) {
1123
- // inputRef.current.contentEditable = true;
1124
- // }
1125
- // }
1126
1053
  if (disabled || readOnly || children) {
1127
1054
  inputRef.current.removeEventListener('keydown', onPreventKeyDownHandler);
1128
1055
  } else {
@@ -1178,7 +1105,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1178
1105
  const EmptyDataText = jsx("div", {
1179
1106
  css: _DropdownItemCSS,
1180
1107
  className: 'no-data'
1181
- }, ' ', noDataText, ' ');
1108
+ }, noDataText);
1182
1109
  const LabelView = useMemo(() => label ? jsx(Label, {
1183
1110
  required: required,
1184
1111
  disabled: disabled,
@@ -1199,21 +1126,19 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1199
1126
  return jsx("div", {
1200
1127
  css: _DropdownFormCSS,
1201
1128
  ref: formRef,
1202
- className: ['DGN-UI-Dropdown-Form', openState && 'dropdown-showing'].join(' ').trim().replace(/\s+/g, ' '),
1203
- style: formStyle
1129
+ className: classNames('DGN-UI-Dropdown-Form', openState && 'dropdown-showing')
1204
1130
  }, jsx("div", {
1205
1131
  css: _InputCSS,
1206
1132
  className: 'DGN-UI-Dropdown-Form-Input'
1207
1133
  }, multiple && valueMulti !== null && valueMulti !== void 0 && valueMulti.length ? jsx("div", {
1208
1134
  ...inputProps,
1209
1135
  style: {
1210
- cursor: 'text',
1211
1136
  gap: spacing(0.5),
1212
1137
  ...inputStyle
1213
1138
  },
1214
1139
  ref: inputRef,
1215
1140
  css: _DropdownInputCSS,
1216
- className: 'dgn-dropdown-multiple ' + (inputProps.className || ''),
1141
+ className: classNames('dgn-dropdown-multiple', inputProps.className),
1217
1142
  onChange: e => {
1218
1143
  e.preventDefault();
1219
1144
  return false;
@@ -1234,7 +1159,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1234
1159
  }
1235
1160
  text = (_mask = mask) === null || _mask === void 0 ? void 0 : _mask.replace(regexInclude, '');
1236
1161
  }
1237
- let item = null;
1162
+ let item;
1238
1163
  if (typeof renderSelectedItem === 'function') {
1239
1164
  item = renderSelectedItem({
1240
1165
  data,
@@ -1254,11 +1179,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1254
1179
  return item;
1255
1180
  })) : typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' ? jsx("div", {
1256
1181
  ...inputProps,
1257
- // contentEditable={!disabled && !allowSearch}
1258
1182
  style: inputStyle,
1259
1183
  ref: inputRef,
1260
1184
  css: _DropdownInputCSS,
1261
- className: 'dgn-dropdown-multiple ' + (inputProps.className || ''),
1185
+ className: classNames('dgn-dropdown-multiple', inputProps.className),
1262
1186
  onKeyDown: e => {
1263
1187
  if (e.key === 'Enter') {
1264
1188
  e.preventDefault();
@@ -1272,7 +1196,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1272
1196
  lineClamp: multilineSelectedItem ? undefined : 1,
1273
1197
  type: 'p1',
1274
1198
  style: {
1275
- lineHeight: '24px'
1199
+ lineHeight: multiple ? '30px' : '24px'
1276
1200
  },
1277
1201
  onClick: onClickInput,
1278
1202
  tabIndex: -1
@@ -1280,17 +1204,14 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1280
1204
  ref: iconRef,
1281
1205
  css: _IconCSS,
1282
1206
  className: 'DGN-UI-Dropdown-Icon'
1283
- }, jsx("span", {
1284
- className: 'dgn-dropdown-loading'
1285
- }, jsx(CircularProgress, {
1286
- width: 24,
1287
- strokeWidth: 2
1288
- })), jsx(ButtonIcon, {
1207
+ }, loading ? jsx(CircularProgress, {
1208
+ size: 24
1209
+ }) : null, showClear ? jsx(ButtonIcon, {
1210
+ css: mgr([1]),
1289
1211
  viewType: 'ghost',
1290
1212
  name: 'Close',
1291
- className: 'icon-close',
1292
1213
  onClick: onClear
1293
- }), !loading && jsx(ButtonIcon, {
1214
+ }) : null, !loading ? jsx(ButtonIcon, {
1294
1215
  viewType: 'ghost',
1295
1216
  name: 'ArrowDown',
1296
1217
  className: 'icon-dropdown',
@@ -1299,125 +1220,117 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1299
1220
  transition: 'transform 0.5s'
1300
1221
  },
1301
1222
  disabled: disabled || readOnly
1302
- })));
1303
- }, [viewType, inputProps, inputStyle, multiple, clearAble, onChange, disabled, readOnly, loading, renderSelectedItem, placeholder, dataSource, valueObjectDefault, valueExpr, displayExpr, multilineSelectedItem, openState, showClear, textValue, valueMulti]);
1304
- const ErrorView = useMemo(() => error && jsx(HelperText, {
1305
- disabled: disabled,
1306
- style: {
1307
- minHeight: '16px',
1308
- position: 'absolute',
1309
- top: '100%',
1310
- ...errorStyle
1311
- }
1312
- }, error), [error, disabled, errorStyle]);
1223
+ }) : null));
1224
+ }, [openState, showClear, textValue, valueMulti, clearAble, dataSource, disabled, displayExpr, inputProps, inputStyle, loading, multilineSelectedItem, multiple, onChange, placeholder, readOnly, renderSelectedItem, valueExpr, valueObjectDefault, viewType]);
1225
+ const ErrorView = useMemo(() => {
1226
+ return error ? jsx(HelperText, {
1227
+ ...helperTextProps,
1228
+ disabled: disabled
1229
+ }, error) : null;
1230
+ }, [disabled, error, helperTextProps]);
1313
1231
  const DropdownView = useMemo(() => {
1314
1232
  return openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null;
1315
- }, [openState, valueMulti, dataSource, loading, multiple, selectBox, maximumSelectionLength, multilineSelectedItem]);
1233
+ }, [openState, valueMulti, dataSource, loading, maximumSelectionLength, multilineSelectedItem, multiple, selectBox]);
1316
1234
  /* End component */
1317
1235
 
1318
1236
  return jsx(Fragment, null, jsx("div", {
1319
1237
  ref: ref,
1320
1238
  css: _DropdownRootCSS,
1321
1239
  style: style,
1322
- className: ['DGN-UI-Dropdown', className, error && 'error', loading && 'dgn-dropdown-loading', disabled ? 'disabled' : readOnly && 'readOnly'].join(' ').trim().replace(/\s+/g, ' ')
1240
+ className: classNames('DGN-UI-Dropdown', className, error && 'error', loading && 'dgn-dropdown-loading', disabled ? 'disabled' : readOnly && 'readOnly')
1323
1241
  }, LabelView, InputView, ErrorView), DropdownView);
1324
1242
  }));
1325
1243
 
1326
1244
  /* Start styled */
1327
1245
  const InputCSS = (multiple, renderSelectedItem) => css`
1328
- ${flexRow};
1246
+ ${displayFlex};
1329
1247
  ${positionRelative};
1330
- width: 100%;
1331
- ${!multiple && renderSelectedItem ? `width: calc(100% - 34px)` : ''}
1248
+ ${parseWidth(!multiple && renderSelectedItem ? 'calc(100% - 34px)' : '100%')};
1332
1249
  `;
1333
- const DropdownInputCSS = (viewType, multiple, placeholder, renderSelectedItem, disabled) => css`
1334
- ${flexRow};
1335
- ${alignCenter};
1250
+ const DropdownInputCSS = (viewType, multiple, placeholder, disabled, readOnly) => css`
1251
+ ${displayFlex};
1252
+ ${itemsCenter};
1336
1253
  ${outlineNone};
1337
- ${backgroundTransparent};
1254
+ ${bgTransparent};
1338
1255
  ${borderNone};
1339
1256
  ${paragraph1};
1340
- width: 100%;
1341
- color: ${main};
1342
- padding-top: 0;
1343
- padding-bottom: ${viewType !== 'outlined' ? 0 : 'inherit'};
1344
- padding-left: ${viewType !== 'outlined' ? 0 : spacing([4])};
1345
- min-height: ${multiple ? 30 : 24}px;
1257
+ ${disabled ? cursorNotAllowed : readOnly ? cursorDefault : cursorPointer};
1258
+ ${parseWidth('100%')};
1259
+ color: ${textMain};
1260
+ ${pdt(0)};
1261
+ ${pdb([viewType !== 'outlined' ? 0 : 'inherit'])};
1262
+ ${pdl([viewType !== 'outlined' ? 0 : 4])};
1263
+ ${parseMinHeight(multiple ? 30 : 24)};
1346
1264
  &.dgn-dropdown-multiple {
1265
+ ${displayFlex};
1347
1266
  ${flexWrap};
1348
1267
  ${overflowHidden};
1349
1268
  ${breakWord};
1350
- ${!multiple ? 'min-height: 24px; max-width: 100%;' : ''}
1269
+ ${!multiple && `
1270
+ ${parseMinHeight(24)};
1271
+ ${parseMaxWidth('100%')};
1272
+ `};
1351
1273
  &::after {
1274
+ ${displayFlex};
1352
1275
  ${flexRow};
1353
1276
  ${positionAbsolute};
1354
- ${alignCenter};
1277
+ ${itemsCenter};
1355
1278
  ${justifyCenter};
1356
1279
  content: '${placeholder}';
1357
- color: ${sub};
1280
+ color: ${textSub};
1358
1281
  }
1359
1282
  &:not(:empty)::after {
1360
1283
  visibility: hidden;
1361
1284
  }
1362
1285
  }
1363
1286
  &:focus {
1364
- ${backgroundTransparent};
1287
+ ${bgTransparent};
1365
1288
  }
1366
1289
  .dropdown-item {
1367
1290
  &:not(:last-child) {
1368
- margin-right: 5px;
1291
+ ${mgr([1.25])};
1369
1292
  }
1370
1293
  svg {
1371
- ${borderBox};
1372
- padding: 2px;
1294
+ ${boxBorder};
1295
+ ${pd([0.5])};
1373
1296
  }
1374
1297
  }
1375
1298
  .DGN-UI-Typography {
1376
- ${disabled && `
1377
- color: ${systemDisabled}
1378
- `}
1299
+ ${disabled && `color: ${systemDisabled}`};
1379
1300
  }
1380
1301
  `;
1381
- const IconCSS = (viewType, loading, showClear) => css`
1382
- ${flexRow};
1383
- ${alignCenter};
1384
- margin-left: ${spacing([2])};
1385
- margin-right: ${viewType !== 'outlined' ? 0 : spacing([4])};
1386
- color: inherit;
1387
- .icon-close {
1388
- display: ${showClear ? 'flex' : 'none'};
1389
- margin-right: ${spacing([1])};
1390
- }
1391
- .dgn-dropdown-loading {
1392
- display: ${loading ? 'flex' : 'none'};
1393
- }
1302
+ const IconCSS = viewType => css`
1303
+ ${displayFlex};
1304
+ ${itemsCenter};
1305
+ ${mgl([2])};
1306
+ ${mgr([viewType !== 'outlined' ? 0 : 4])};
1394
1307
  `;
1395
1308
  const DropdownFormCSS = (viewType, multiple, disabled, placeholder, DropdownInputCSSName) => viewType !== 'outlined' ? css`
1309
+ ${displayFlex};
1396
1310
  ${flexRow};
1397
- ${alignCenter};
1311
+ ${itemsCenter};
1398
1312
  ${positionRelative};
1399
- ${borderBox};
1400
- width: 100%;
1401
- padding-bottom: ${multiple ? 1 : 4}px;
1402
- padding-top: ${multiple ? 1 : 4}px;
1313
+ ${boxBorder};
1314
+ ${parseWidth('100%')};
1315
+ ${pdy([multiple ? 0.25 : 1])};
1403
1316
  ${!disabled && `
1404
1317
  &:not(:focus-within):hover {
1405
1318
  &::before {
1406
- border-bottom-color: ${active};
1319
+ border-bottom-color: ${systemActive};
1407
1320
  }
1408
1321
  .css-${DropdownInputCSSName} {
1409
- color: ${active};
1322
+ color: ${systemActive};
1410
1323
  }
1411
1324
  }
1412
1325
  `}
1413
1326
  &:focus-within {
1414
- border-bottom-color: ${focus};
1327
+ border-bottom-color: ${lineFocus};
1415
1328
  &::after {
1416
1329
  border-bottom-color: inherit;
1417
1330
  transform: scaleX(1);
1418
1331
  }
1419
1332
  .css-${DropdownInputCSSName} {
1420
- color: ${active};
1333
+ color: ${systemActive};
1421
1334
  }
1422
1335
  }
1423
1336
  &.dropdown-showing {
@@ -1427,29 +1340,27 @@ const DropdownFormCSS = (viewType, multiple, disabled, placeholder, DropdownInpu
1427
1340
  }
1428
1341
  span:empty:before {
1429
1342
  content: '${placeholder}';
1430
- color: ${sub};
1431
- height: 100%;
1432
- ${overflowHidden}
1343
+ ${parseHeight('100%')};
1344
+ ${overflowHidden};
1345
+ color: ${textSub};
1433
1346
  display: -webkit-box;
1434
1347
  -webkit-line-clamp: 1;
1435
1348
  -webkit-box-orient: vertical;
1436
1349
  }
1437
1350
  &::placeholder {
1438
- color: ${sub};
1351
+ color: ${textSub};
1439
1352
  }
1440
1353
  &::before {
1441
1354
  ${positionAbsolute};
1442
1355
  content: '';
1443
- left: 0;
1444
- right: 0;
1356
+ ${insetX(0)};
1445
1357
  bottom: 0;
1446
- ${viewType === 'underlined' && `border-bottom: 1px solid ${disabled ? systemDisabled : rest};`}
1358
+ ${viewType === 'underlined' && `border-bottom: 1px solid ${disabled ? systemDisabled : systemRest};`}
1447
1359
  }
1448
1360
  &::after {
1449
1361
  ${positionAbsolute};
1450
1362
  content: '';
1451
- left: 0px;
1452
- right: 0px;
1363
+ ${insetX(0)};
1453
1364
  bottom: -1px;
1454
1365
  border-bottom: 2px solid transparent;
1455
1366
  transform: scaleX(0);
@@ -1457,25 +1368,27 @@ const DropdownFormCSS = (viewType, multiple, disabled, placeholder, DropdownInpu
1457
1368
  transition: all 0.2s ease;
1458
1369
  }
1459
1370
  ` : css`
1371
+ ${displayFlex};
1460
1372
  ${flexRow};
1461
- ${alignCenter};
1373
+ ${itemsCenter};
1462
1374
  ${positionRelative};
1463
1375
  ${borderRadius4px};
1464
- ${borderBox};
1465
- ${border(1, disabled ? systemDisabled : rest)};
1466
- width: 100%;
1467
- min-height: 40px;
1376
+ ${boxBorder};
1377
+ ${border(1, disabled ? systemDisabled : systemRest)};
1378
+ ${parseWidth('100%')};
1379
+ ${parseMinHeight(40)};
1380
+ ${mgt([0.5])};
1468
1381
  ${!disabled && `
1469
1382
  &:not(:focus-within):hover {
1470
- background-color: ${hover};
1471
- border-color: ${active};
1383
+ ${bgColor(fillHover)};
1384
+ border-color: ${systemActive};
1472
1385
  input {
1473
- background-color: ${hover};
1386
+ ${bgColor(fillHover)};
1474
1387
  }
1475
1388
  }
1476
1389
  `}
1477
1390
  &:focus-within {
1478
- border-color: ${focus};
1391
+ border-color: ${lineFocus};
1479
1392
  }
1480
1393
  &.dropdown-showing {
1481
1394
  .icon-dropdown {
@@ -1484,107 +1397,91 @@ const DropdownFormCSS = (viewType, multiple, disabled, placeholder, DropdownInpu
1484
1397
  }
1485
1398
  span:empty:before {
1486
1399
  content: '${placeholder}';
1487
- color: ${sub};
1488
- height: 100%;
1489
- ${overflowHidden}
1400
+ ${parseHeight('100%')};
1401
+ ${overflowHidden};
1402
+ color: ${textSub};
1490
1403
  display: -webkit-box;
1491
1404
  -webkit-line-clamp: 1;
1492
1405
  -webkit-box-orient: vertical;
1493
1406
  }
1494
1407
  &::placeholder {
1495
- color: ${sub};
1408
+ color: ${textSub};
1496
1409
  }
1497
1410
  &::after {
1498
1411
  ${positionAbsolute};
1499
1412
  ${pointerEventsNone};
1500
1413
  ${borderRadius4px};
1414
+ ${border(2, 'transparent')};
1415
+ ${inset(-2)};
1501
1416
  content: '';
1502
- left: -2px;
1503
- right: -2px;
1504
- top: -2px;
1505
- bottom: -2px;
1506
- border: 2px solid transparent;
1507
1417
  }
1508
1418
  `;
1509
1419
  const DropdownListCSS = loading => css`
1510
1420
  ${displayBlock};
1511
1421
  ${positionRelative};
1512
- ${borderBox};
1422
+ ${boxBorder};
1513
1423
  ${borderRadius4px};
1514
- width: 100%;
1515
- max-height: 280px;
1424
+ ${parseWidth('100%')};
1425
+ ${parseMaxHeight(280)};
1516
1426
  ${loading ? overflowHidden : overflowAuto};
1517
- background-color: ${white};
1427
+ ${bgColor(systemWhite)};
1518
1428
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
1519
- z-index: ${zIndexCORE(1)};
1429
+ ${z(1)};
1520
1430
  &::-webkit-scrollbar {
1521
1431
  ${borderRadius4px};
1522
1432
  ${parseWidth(24)};
1523
- background-color: ${white} !important;
1433
+ background-color: ${systemWhite} !important;
1524
1434
  }
1525
1435
  &::-webkit-scrollbar-thumb {
1526
- border-radius: 24px;
1527
- border: 8px solid transparent;
1436
+ ${borderRadius(24)};
1437
+ ${border(8, 'transparent')};
1528
1438
  mix-blend-mode: normal;
1529
- background-color: ${scrollbar} !important;
1439
+ background-color: ${fillScrollbar} !important;
1530
1440
  background-clip: content-box;
1531
1441
  }
1532
1442
  .DGN-UI-TreeView {
1533
- padding: 1px;
1443
+ ${pd([0.25])};
1534
1444
  }
1535
1445
  `;
1536
1446
  const DropdownItemCSS = (multiple, selectBox) => css`
1447
+ ${displayFlex};
1537
1448
  ${flexRow};
1538
1449
  ${positionRelative};
1539
- ${alignCenter};
1450
+ ${itemsCenter};
1540
1451
  ${justifyStart};
1541
- ${borderBox};
1452
+ ${boxBorder};
1542
1453
  ${cursorPointer};
1543
1454
  ${userSelectNone};
1544
- min-height: 40px;
1545
- width: 100%;
1546
- background-color: ${white};
1547
- padding: ${spacing([2, multiple && selectBox ? 0 : 4])};
1548
- padding: 8px ${multiple && selectBox ? 0 : '16px'};
1549
- color: ${main};
1455
+ ${parseMinHeight(40)};
1456
+ ${parseWidth('100%')};
1457
+ ${bgColor(systemWhite)};
1458
+ ${pd([2, multiple && selectBox ? 0 : 4])};
1459
+ color: ${textMain};
1550
1460
  &.no-data {
1551
1461
  ${justifyCenter};
1462
+ ${cursorDefault};
1552
1463
  font-style: italic;
1553
- cursor: initial;
1554
1464
  }
1555
1465
  &:not(.no-data):hover,
1556
1466
  &:not(.no-data):focus {
1557
1467
  ${outlineNone};
1558
- background-color: ${hover};
1559
- color: ${active};
1468
+ ${bgColor(fillHover)};
1469
+ color: ${systemActive};
1560
1470
  }
1561
1471
  `;
1562
- const DropdownTextCSS = css`
1563
- ${paragraph1};
1564
- color: inherit;
1565
- .DGN-UI-Dropdown-PrimaryText {
1566
- ${paragraph1};
1567
- ${displayBlock};
1568
- }
1569
- .DGN-UI-Dropdown-SubText {
1570
- ${paragraph3};
1571
- ${displayBlock};
1572
- color: ${sub};
1573
- }
1574
- `;
1575
- const DropdownRootCSS = (DropdownFormCSSName, IconCSSName, DropdownInputCSSName) => css`
1472
+ const DropdownRootCSS = (DropdownFormCSSName, DropdownInputCSSName) => css`
1576
1473
  ${displayBlock};
1577
1474
  ${positionRelative};
1578
- margin-bottom: 20px;
1579
- height: max-content;
1475
+ ${mgb([5])};
1476
+ ${parseHeight('max-content')};
1580
1477
  &.error {
1581
1478
  .css-${DropdownFormCSSName} {
1582
- border-color: ${danger};
1479
+ border-color: ${semanticDanger};
1583
1480
  path {
1584
- fill: ${danger};
1481
+ fill: ${semanticDanger};
1585
1482
  }
1586
1483
  &::before {
1587
- border-color: ${danger};
1484
+ border-color: ${semanticDanger};
1588
1485
  }
1589
1486
  }
1590
1487
  }
@@ -1592,20 +1489,12 @@ const DropdownRootCSS = (DropdownFormCSSName, IconCSSName, DropdownInputCSSName)
1592
1489
  &.disabled {
1593
1490
  .css-${DropdownFormCSSName} {
1594
1491
  border-color: ${systemDisabled};
1595
- .css-${IconCSSName} {
1596
- path {
1597
- fill: transparent;
1598
- }
1599
- }
1600
1492
  &::before {
1601
1493
  border-color: ${systemDisabled};
1602
1494
  }
1603
1495
  }
1604
1496
  }
1605
1497
  &.readOnly {
1606
- .css-${IconCSSName} {
1607
- ${pointerEventsNone};
1608
- }
1609
1498
  .css-${DropdownInputCSSName} {
1610
1499
  .dropdown-item {
1611
1500
  ${pointerEventsNone};
@@ -1618,81 +1507,91 @@ const DropdownCSS = (top, left, width, isMobile, allowSearch) => css`
1618
1507
  ${parseWidth(width)};
1619
1508
  top: ${top}px;
1620
1509
  left: ${left}px;
1621
- background-color: ${white};
1622
- z-index: ${zIndexCORE(1)};
1510
+ ${bgColor(systemWhite)};
1511
+ ${z(1)};
1623
1512
  ${isMobile && allowSearch && `
1513
+ ${parseHeight('max-content')};
1514
+ ${flexColReverse};
1624
1515
  bottom: 0;
1625
1516
  top: auto;
1626
- height: max-content;
1627
- ${flexColReverse.styles};
1628
1517
  `}
1629
1518
  `;
1630
1519
  const LoadingProgressCSS = css`
1520
+ ${displayFlex};
1631
1521
  ${flexRow};
1632
1522
  ${justifyCenter};
1633
- ${alignCenter};
1523
+ ${itemsCenter};
1634
1524
  ${positionAbsolute};
1635
1525
  ${borderRadius4px};
1636
1526
  ${parseWidthHeight('100%')}
1527
+ ${bgColor('rgba(255, 255, 255, 0.6)')};
1528
+ ${z(2)};
1637
1529
  top: 0;
1638
- background-color: rgba(255, 255, 255, 0.6);
1639
- z-index: ${zIndexCORE(2)};
1640
1530
  `;
1641
1531
  const DisabledCSS = css`
1642
1532
  pointer-events: none !important;
1643
1533
  opacity: 0.4 !important;
1644
1534
  `;
1535
+ const CheckBoxCSS = css`
1536
+ ${parseWidthHeight('100%')};
1537
+ ${pd([0, 4])};
1538
+ `;
1645
1539
  /* End styled */
1646
1540
 
1647
1541
  Dropdown.defaultProps = {
1648
- viewType: 'underlined',
1649
- itemMode: 'normal',
1542
+ allowSearch: true,
1650
1543
  className: '',
1651
- label: '',
1652
- placeholder: getGlobal('dropdownPlaceholder'),
1544
+ clearAble: false,
1545
+ dataSource: [],
1546
+ disabled: false,
1547
+ displayExpr: 'name',
1653
1548
  error: '',
1654
1549
  iconExpr: 'none',
1655
- valueExpr: 'id',
1656
- displayExpr: 'name',
1657
- noDataText: getGlobal('noDataText'),
1658
- skip: 0,
1550
+ inputProps: {},
1551
+ itemMode: 'normal',
1552
+ label: '',
1659
1553
  limit: 50,
1660
- total: Number.MAX_SAFE_INTEGER,
1661
- clearAble: false,
1662
1554
  loading: false,
1663
- disabled: false,
1664
- readOnly: false,
1665
- required: false,
1555
+ multilineSelectedItem: false,
1666
1556
  multiple: false,
1667
- allowSearch: true,
1668
- inputProps: {},
1669
- formStyle: {},
1670
- dataSource: [],
1557
+ noDataText: getGlobal('noDataText'),
1671
1558
  onInput: null,
1559
+ placeholder: getGlobal('dropdownPlaceholder'),
1560
+ readOnly: false,
1561
+ required: false,
1672
1562
  searchMode: 'contains',
1673
- multilineSelectedItem: false
1563
+ total: Number.MAX_SAFE_INTEGER,
1564
+ valueExpr: 'id',
1565
+ viewType: 'underlined'
1674
1566
  };
1675
1567
  Dropdown.propTypes = {
1676
- /**The variant to use. */
1677
- viewType: PropTypes.oneOf(['underlined', 'outlined', 'none']),
1678
- /** The mode of item when rendering. */
1679
- itemMode: PropTypes.oneOf(['normal', 'table', 'treeview']),
1568
+ /** If `true`, display input box search. */
1569
+ allowSearch: PropTypes.bool,
1570
+ /** The contents in Dropdown box (Exp: TreeView). */
1571
+ children: PropTypes.node,
1680
1572
  /** Class for component. */
1681
1573
  className: PropTypes.string,
1682
- /** The label of the input. */
1683
- label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
1684
- /** The short hint displayed in the input before the user select a value. */
1685
- placeholder: PropTypes.string,
1574
+ /** If `true`, display clear icon.*/
1575
+ clearAble: PropTypes.bool,
1576
+ /** If `true`, dropdown will close after select an item. */
1577
+ closeAfterSelect: PropTypes.bool,
1578
+ /** The array of elements that appear in the dropdown list. */
1579
+ dataSource: PropTypes.array,
1580
+ /** Default value displayed when first render. */
1581
+ defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1582
+ /** If `true`, the component is disabled. */
1583
+ disabled: PropTypes.bool,
1584
+ /** Field name used for text display in dropdown list.<br/>
1585
+ * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1586
+ * Note: don't use 'id - name', return undefined
1587
+ */
1588
+ displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1589
+ /** Style inline of dropdown items. */
1590
+ dropdownItemStyle: PropTypes.object,
1686
1591
  /** Error displayed below input. */
1687
1592
  error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
1688
- /** Used to identify the parent key (only used for `itemMode` is 'treeview'). */
1689
- treeViewID: PropTypes.string,
1690
- /** Used for mapping into a nested list (only used for `itemMode` is 'treeview'). */
1691
- treeViewParentID: PropTypes.string,
1692
- /** Specifies a text string shown when there is no data. */
1693
- noDataText: PropTypes.string,
1694
- /** The icon to display if not found the icon follow `iconExpr`. */
1695
- iconDefault: PropTypes.string,
1593
+ /** Props applied to the [HelperText](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) element. */
1594
+ helperTextProps: PropTypes.object,
1696
1595
  /** Field name used for icon display.<br/>
1697
1596
  * Example:<br/>
1698
1597
  * &nbsp;&nbsp;string: 'icon'<br/>
@@ -1708,67 +1607,44 @@ Dropdown.propTypes = {
1708
1607
  suffix: PropTypes.string,
1709
1608
  style: PropTypes.object
1710
1609
  })]),
1711
- /** Default value displayed when first render. */
1712
- defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1713
- /** The displayed value of component. */
1714
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1715
- /** Field name used for text display in dropdown list.<br/>
1716
- * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1717
- * Note: don't use 'id - name', return undefined
1718
- */
1719
- displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1720
- /** Display sub content. */
1721
- subText: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
1722
- /** The field name used for the returned result. */
1723
- valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
1724
- /**
1725
- * Duration wait enter search content on search.<br/>
1726
- * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1727
- * If `true`, used default delayOnInput.
1728
- */
1729
- searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
1730
- /** Number of items is ignored. */
1731
- skip: PropTypes.number,
1732
- /** Number of items that are rendered each time. */
1733
- limit: PropTypes.number,
1734
- /** The total number of items in the dropdown list. */
1735
- total: PropTypes.number,
1736
- /** If `true`, display clear icon.*/
1737
- clearAble: PropTypes.bool,
1738
- /** If true, the loading indicator is shown. */
1739
- loading: PropTypes.bool,
1740
- /** If true, the component is disabled. */
1741
- disabled: PropTypes.bool,
1742
- /** If true, the component is read-only. */
1743
- readOnly: PropTypes.bool,
1744
- /** If `true`, dropdown will close after select an item. */
1745
- closeAfterSelect: PropTypes.bool,
1746
- /** If `true`, the label will indicate that the input is required. */
1747
- required: PropTypes.bool,
1748
- /** If `true`, value must be an array and the dropdown will support multiple selections. */
1749
- multiple: PropTypes.bool,
1750
- /** If `true`, display input box search. */
1751
- allowSearch: PropTypes.bool,
1752
- /** If `true`, show checkbox in each dropdown item. */
1753
- selectBox: PropTypes.bool,
1754
- /** An object default for value (use for load more). */
1755
- valueObjectDefault: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
1756
- /** Style inline of component. */
1757
- style: PropTypes.object,
1758
1610
  /** Attributes applied to the input element. */
1759
1611
  inputProps: PropTypes.object,
1760
1612
  /** Style inline of input element. */
1761
1613
  inputStyle: PropTypes.object,
1762
- /** Style inline of box contain input and icon. */
1763
- formStyle: PropTypes.object,
1764
- /** Style inline of label. */
1614
+ /** The mode of item when rendering. */
1615
+ itemMode: PropTypes.oneOf(['normal', 'table', 'treeview']),
1616
+ /** The label of the input. */
1617
+ label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
1618
+ /** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label--simple) of label. */
1765
1619
  labelProps: PropTypes.object,
1766
- /** Style inline of error. */
1767
- errorStyle: PropTypes.object,
1768
- /** Style inline of dropdown items. */
1769
- dropdownItemStyle: PropTypes.object,
1770
- /** The array of elements that appear in the dropdown list. */
1771
- dataSource: PropTypes.array,
1620
+ /** Number of items that are rendered each time. */
1621
+ limit: PropTypes.number,
1622
+ /** If `true`, the loading indicator is shown. */
1623
+ loading: PropTypes.bool,
1624
+ /** Set restrictions regarding the maximum number of options that can be selected. (Use with prop `multiple`) */
1625
+ maximumSelectionLength: PropTypes.number,
1626
+ /** If `true`, show multi-line selected item(s). */
1627
+ multilineSelectedItem: PropTypes.bool,
1628
+ /** If `true`, value must be an array and the dropdown will support multiple selections. */
1629
+ multiple: PropTypes.bool,
1630
+ /** Specifies a text string shown when there is no data. */
1631
+ noDataText: PropTypes.string,
1632
+ /** Callback fired when the value changes. */
1633
+ onChange: PropTypes.func,
1634
+ /** Callback fired when dropdown closed. */
1635
+ onClosed: PropTypes.func,
1636
+ /** Callback fired when the input value changes.<br/>
1637
+ * if undefined: the filter function will run (default)
1638
+ */
1639
+ onInput: PropTypes.func,
1640
+ /** Callback fired when key down input */
1641
+ onKeyDown: PropTypes.func,
1642
+ /** Callback fired when scroll near the end. */
1643
+ onLoadMore: PropTypes.func,
1644
+ /** The short hint displayed in the input before the user select a value. */
1645
+ placeholder: PropTypes.string,
1646
+ /** If `true`, the component is read-only. */
1647
+ readOnly: PropTypes.bool,
1772
1648
  /** Function displays items by custom.<br/>
1773
1649
  * renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
1774
1650
  * --> such as: displayExpr={'name - role'}
@@ -1778,28 +1654,38 @@ Dropdown.propTypes = {
1778
1654
  * renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
1779
1655
  */
1780
1656
  renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
1781
- /** Callback fired when the input value changes.<br/>
1782
- * if undefined: the filter function will run (default)
1657
+ /** If `true`, the label will indicate that the input is required. */
1658
+ required: PropTypes.bool,
1659
+ /**
1660
+ * Duration wait enter search content on search.<br/>
1661
+ * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1662
+ * If `true`, used default delayOnInput.
1783
1663
  */
1784
- onInput: PropTypes.func,
1785
- /** Callback fired when key down input */
1786
- onKeyDown: PropTypes.func,
1787
- /** Callback fired when the value changes. */
1788
- onChange: PropTypes.func,
1789
- /** Callback fired when scroll near the end. */
1790
- onLoadMore: PropTypes.func,
1791
- /** Callback fired when dropdown closed. */
1792
- onClosed: PropTypes.func,
1793
- /** The contents in Dropdown box (Exp: TreeView). */
1794
- children: PropTypes.node,
1664
+ searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
1795
1665
  /** Specifies a data object's field name or an expression whose value is compared to the search string. */
1796
1666
  searchExpr: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
1797
1667
  /** Specifies a comparison operation used to search items. */
1798
1668
  searchMode: PropTypes.oneOf(['contains', 'startswith', 'equals']),
1799
- /** Set restrictions regarding the maximum number of options that can be selected. (Use with prop `multiple`) */
1800
- maximumSelectionLength: PropTypes.number,
1801
- /** If `true`, show multi-line selected item(s). */
1802
- multilineSelectedItem: PropTypes.bool,
1669
+ /** If `true`, show checkbox in each dropdown item. */
1670
+ selectBox: PropTypes.bool,
1671
+ /** Style inline of component. */
1672
+ style: PropTypes.object,
1673
+ /** Display sub content. */
1674
+ subText: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
1675
+ /** The total number of items in the dropdown list. */
1676
+ total: PropTypes.number,
1677
+ /** Used to identify the parent key (only used for `itemMode` is 'treeview'). */
1678
+ treeViewID: PropTypes.string,
1679
+ /** Used for mapping into a nested list (only used for `itemMode` is 'treeview'). */
1680
+ treeViewParentID: PropTypes.string,
1681
+ /** The displayed value of component. */
1682
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1683
+ /** The field name used for the returned result. */
1684
+ valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
1685
+ /** An object default for value (use for load more). */
1686
+ valueObjectDefault: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
1687
+ /**The variant to use. */
1688
+ viewType: PropTypes.oneOf(['underlined', 'outlined', 'none']),
1803
1689
  /**
1804
1690
  * ref methods
1805
1691
  *
@@ -1814,8 +1700,6 @@ Dropdown.propTypes = {
1814
1700
  * * setValue(value): Set value of dropdown
1815
1701
  * * @param {value} - string || number || array
1816
1702
  */
1817
- reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
1818
- current: PropTypes.instanceOf(Element)
1819
- })])
1703
+ reference: ref
1820
1704
  };
1821
1705
  export default Dropdown;