diginet-core-ui 1.3.96 → 1.3.97

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.
@@ -2,28 +2,21 @@
2
2
  /** @jsx jsx */
3
3
  import { css, jsx } from '@emotion/core';
4
4
  import { Avatar, ButtonIcon, Checkbox, Chip, CircularProgress, HelperText, InputBase, Label, TreeView, Typography } from "../..";
5
+ import Popover from "../../popover";
5
6
  import { getGlobal } from "../../../global";
6
7
  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, borderBottom, borderBottomColor, borderColor, borderNone, borderRadius, borderRadius4px, boxBorder, breakWord, cursorDefault, cursorNotAllowed, cursorPointer, displayBlock, displayFlex, fill, flexColReverse, flexRow, flexWrap, inset, insetX, italic, 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, textColor, userSelectNone, z } from "../../../styles/general";
8
+ import { forwardRef, Fragment, memo, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
9
+ import ReactDOM from 'react-dom';
10
+ import { animation, bgColor, border, borderBottom, borderBottomColor, borderColor, borderNone, borderRadius, bottom, boxBorder, breakWord, cursorDefault, cursorNotAllowed, cursorPointer, displayBlock, displayFlex, fill, flexRow, flexWrap, gap, inset, insetX, invisible, italic, itemsCenter, justifyCenter, justifyStart, mgb, mgl, mgr, mgt, outlineNone, overflowAuto, overflowHidden, parseHeight, parseMaxHeight, parseMaxWidth, parseMinHeight, parseWidth, parseWidthHeight, pd, pdb, pdl, pdt, pdy, pointerEventsNone, positionAbsolute, positionRelative, textColor, top, userSelectNone, z } from "../../../styles/general";
10
11
  import { useTheme } from "../../../theme";
11
- import { classNames, isMobile, mapParent, randomString, updatePosition } from "../../../utils";
12
+ import { classNames, isMobile, randomString } from "../../../utils";
12
13
  const {
13
- colors: {
14
- system: {
15
- white: systemWhite
16
- },
17
- fill: {
18
- 'scrollbar-tabbar': fillScrollbar
19
- }
20
- },
21
14
  typography: {
22
15
  paragraph1
23
- },
24
- spacing
16
+ }
25
17
  } = useTheme();
26
- const timing = {},
18
+ const
19
+ // timing = {},
27
20
  currentValue = {},
28
21
  currentObjectDefault = {},
29
22
  isSearch = {},
@@ -95,13 +88,14 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
95
88
  if (typeof searchExpr === 'string') searchExpr = [searchExpr];
96
89
  const ref = useRef(null);
97
90
  const dropdownRef = useRef(null);
91
+ const timer = useRef(null);
98
92
  const timerRef = useRef(null);
99
93
  const formRef = useRef(null);
100
94
  const inputRef = useRef(null);
101
95
  const iconRef = useRef(null);
102
96
  const dropdownListRef = useRef(null);
103
97
  const searchRef = useRef(null);
104
- const lastSearchRef = useRef(null);
98
+ // const lastSearchRef = useRef(null);
105
99
  const timeout = useRef(null);
106
100
  const loadMoreTimer = useRef(null);
107
101
  const dataChosen = useRef([]);
@@ -112,6 +106,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
112
106
  const [openState, setOpenState] = useState(false);
113
107
  const [showClear, setShowClear] = useState(false);
114
108
  const [textValue, setTextValue] = useState('');
109
+ const [txtSearch, setTxtSearch] = useState('');
110
+ const [popoverWidth, setPopoverWidth] = useState(0);
115
111
  let valueTemp = valueProp || defaultValue || [];
116
112
 
117
113
  // only mode multi
@@ -129,19 +125,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
129
125
  const _DropdownRootCSS = DropdownRootCSS(_DropdownFormCSS.name, _DropdownInputCSS.name);
130
126
 
131
127
  /* Start handler */
132
- const triggerInput = e => {
133
- const target = e.currentTarget;
134
- target.style.pointerEvents = 'none';
135
- if (!dropdownListRef.current) {
136
- onClickInput();
137
- } else {
138
- onClickOutsideOfInput({
139
- target: null
140
- });
141
- }
142
- setTimeout(() => {
143
- target.style.pointerEvents = null;
144
- }, 200);
128
+ const setShowDropdown = () => {
129
+ setOpenState(!openState);
145
130
  };
146
131
  const triggerBlur = (blur = true) => {
147
132
  if ((currentValue[unique] || currentValue[unique] === 0) && !multiple) {
@@ -159,58 +144,66 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
159
144
  }
160
145
  }
161
146
  };
162
- const onClickOutsideOfInput = event => {
163
- var _inputRef$current, _iconRef$current, _dropdownListRef$curr, _dropdownListRef$curr2, _dropdownListRef$curr3;
164
- if (inputRef.current && !((_inputRef$current = inputRef.current) !== null && _inputRef$current !== void 0 && _inputRef$current.contains(event === null || event === void 0 ? void 0 : event.target)) && iconRef.current && !((_iconRef$current = iconRef.current) !== null && _iconRef$current !== void 0 && _iconRef$current.contains(event === null || event === void 0 ? void 0 : event.target)) && dropdownListRef.current && !((_dropdownListRef$curr = dropdownListRef.current) !== null && _dropdownListRef$curr !== void 0 && (_dropdownListRef$curr2 = _dropdownListRef$curr.parentNode) !== null && _dropdownListRef$curr2 !== void 0 && (_dropdownListRef$curr3 = _dropdownListRef$curr2.parentNode) !== null && _dropdownListRef$curr3 !== void 0 && _dropdownListRef$curr3.contains(event === null || event === void 0 ? void 0 : event.target))) {
165
- closeDropdown();
166
- triggerBlur(false);
167
- }
168
- };
147
+
148
+ // const onClickOutsideOfInput = event => {
149
+ // if (
150
+ // inputRef.current &&
151
+ // !inputRef.current?.contains(event?.target) &&
152
+ // iconRef.current &&
153
+ // !iconRef.current?.contains(event?.target) &&
154
+ // dropdownListRef.current &&
155
+ // !dropdownListRef.current?.parentNode?.parentNode?.contains(event?.target)
156
+ // ) {
157
+ // closeDropdown();
158
+ // triggerBlur(false);
159
+ // }
160
+ // };
161
+
169
162
  const showDropdown = () => {
170
- var _displayExpr, _searchRef$current;
171
- if (displayExpr && Array.isArray(displayExpr)) {
172
- displayExpr = displayExpr.join(' - ');
173
- }
174
- const keyArr = (_displayExpr = displayExpr) === null || _displayExpr === void 0 ? void 0 : _displayExpr.match(separatorPattern);
163
+ // if (displayExpr && Array.isArray(displayExpr)) {
164
+ // displayExpr = displayExpr.join(' - ');
165
+ // }
166
+ // const keyArr = displayExpr?.match(separatorPattern);
175
167
  const dropdown = children ? jsx("div", {
176
168
  css: _DropdownListCSS,
177
169
  ref: dropdownListRef,
178
170
  className: 'DGN-Dropdown-List',
179
171
  onKeyDown: moveOnItem,
180
172
  tabIndex: -1
181
- }, dataSource !== null && dataSource !== void 0 && dataSource.length ? children : EmptyDataText) : itemMode === 'normal' ? mapDropdown(null, keyArr) : mapTreeView();
182
- const {
183
- innerHeight
184
- } = window;
185
- const {
186
- top,
187
- left,
188
- height,
189
- width
190
- } = formRef.current.getBoundingClientRect();
173
+ }, dataSource !== null && dataSource !== void 0 && dataSource.length ? children : EmptyDataText) : itemMode === 'normal' ? mapDropdown() : mapTreeView();
174
+ // const { innerHeight } = window;
175
+ // const { top, left, height, width } = formRef.current.getBoundingClientRect();
191
176
 
192
177
  // Calculate to set position of Dropdown box
193
- const dropdownHeight = Math.min(Math.max(1, (itemMode === 'normal' ? dropdown.props.children : mapParent(dataSource, treeViewID, treeViewParentID)).length || 1), 7) * 40 + (multiple ? 43 : 0);
194
- let positionTop = top + height + 4;
195
- if (top + height + 4 + dropdownHeight + (allowSearch ? 40 : 0) > innerHeight) {
196
- if (top - dropdownHeight > 0) {
197
- positionTop = top - dropdownHeight;
198
- } else {
199
- positionTop = innerHeight - dropdownHeight;
200
- }
201
- }
202
- const defaultSearch = lastSearchRef.current || (onInput ? (_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 ? void 0 : _searchRef$current.value : '');
203
- const _DropdownCSS = DropdownCSS(positionTop, left, width, _isMobile, allowSearch);
204
- const el = jsx("div", {
205
- css: _DropdownCSS,
206
- ref: dropdownRef,
207
- className: `DGN-UI-Portal DGN-Dropdown-${unique}`
208
- }, (multiple || allowSearch) && itemMode === 'normal' && !children ? jsx("div", {
178
+ // const dropdownHeight =
179
+ // Math.min(
180
+ // Math.max(
181
+ // 1,
182
+ // (itemMode === 'normal'
183
+ // ? dropdown.props.children
184
+ // : mapParent(dataSource, treeViewID, treeViewParentID)
185
+ // ).length || 1
186
+ // ),
187
+ // 7
188
+ // ) *
189
+ // 40 +
190
+ // (multiple ? 43 : 0);
191
+ // let positionTop = top + height + 4;
192
+ // if (top + height + 4 + dropdownHeight + (allowSearch ? 40 : 0) > innerHeight) {
193
+ // if (top - dropdownHeight > 0) {
194
+ // positionTop = top - dropdownHeight;
195
+ // } else {
196
+ // positionTop = innerHeight - dropdownHeight;
197
+ // }
198
+ // }
199
+ // const _DropdownCSS = DropdownCSS(positionTop, left, width, _isMobile, allowSearch);
200
+ const el = jsx(Fragment, null, (multiple || allowSearch) && itemMode === 'normal' && !children ? jsx("div", {
209
201
  className: 'DGN-Dropdown-Search'
210
202
  }, jsx(InputBase, {
211
203
  inputRef: searchRef,
204
+ delayOnChange: searchDelayTime,
212
205
  viewType: 'outlined',
213
- defaultValue: defaultSearch,
206
+ defaultValue: txtSearch,
214
207
  onChange: onChangeInput,
215
208
  style: {
216
209
  marginBottom: 1
@@ -218,9 +211,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
218
211
  onKeyDown: pressESCHandler,
219
212
  autoFocus: true
220
213
  })) : null, multiple && maximumSelectionLength ? jsx(Typography, {
221
- style: {
222
- padding: spacing([2, 4])
223
- }
214
+ css: pd([2, 4])
224
215
  }, getGlobal('selected'), " ", (valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) || 0, "/", maximumSelectionLength) : null, jsx("div", {
225
216
  className: 'DGN-Dropdown-Box'
226
217
  }, dropdown), loading ? jsx("div", {
@@ -229,14 +220,14 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
229
220
  }, jsx(CircularProgress, {
230
221
  size: 24
231
222
  })) : null);
232
- if (!((multiple || allowSearch) && itemMode === 'normal' && !children)) {
233
- inputRef.current.addEventListener('keydown', pressESCHandler);
234
- }
235
- document.documentElement.style.overflow = 'hidden';
223
+ // if (!((multiple || allowSearch) && itemMode === 'normal' && !children)) {
224
+ // inputRef.current.addEventListener('keydown', pressESCHandler);
225
+ // }
226
+ // document.documentElement.style.overflow = 'hidden';
236
227
  setTimeout(() => {
237
228
  window.addEventListener('resize', customizeWidthDropdown);
238
- document.addEventListener('wheel', onWheelHandler);
239
- document.addEventListener('mousedown', onClickOutsideOfInput);
229
+ // document.addEventListener('wheel', onWheelHandler);
230
+ // document.addEventListener('mousedown', onClickOutsideOfInput);
240
231
  if (onLoadMore && dataSource.length < total) {
241
232
  dropdownListRef.current && dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
242
233
  }
@@ -269,76 +260,107 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
269
260
  dropdownListRef.current.firstChild.focus();
270
261
  }
271
262
  };
272
- const onWheelHandler = e => {
273
- var _dropdownRef$current;
274
- if (!dropdownRef.current) {
275
- document.removeEventListener('wheel', onWheelHandler);
276
- return;
277
- }
278
- if (!((_dropdownRef$current = dropdownRef.current) !== null && _dropdownRef$current !== void 0 && _dropdownRef$current.contains(e.target))) {
279
- closeDropdown();
280
- triggerBlur();
281
- }
282
- };
263
+
264
+ // const onWheelHandler = e => {
265
+ // if (!dropdownRef.current) {
266
+ // document.removeEventListener('wheel', onWheelHandler);
267
+ // return;
268
+ // }
269
+ // if (!dropdownRef.current?.contains(e.target)) {
270
+ // closeDropdown();
271
+ // triggerBlur();
272
+ // }
273
+ // };
274
+
283
275
  const closeDropdown = () => {
284
276
  if (dropdownRef.current) {
285
277
  setOpenState(false);
286
- document.removeEventListener('mousedown', onClickOutsideOfInput);
278
+ // document.removeEventListener('mousedown', onClickOutsideOfInput);
287
279
  window.removeEventListener('resize', customizeWidthDropdown);
288
- document.removeEventListener('wheel', onWheelHandler);
280
+ // document.removeEventListener('wheel', onWheelHandler);
289
281
  if (onLoadMore && dropdownListRef.current) {
290
282
  dropdownListRef.current.removeEventListener('scroll', onLoadMoreHandler);
291
283
  dropdownListRef.current = null;
292
284
  }
293
285
  }
294
- document.documentElement.style.overflow = 'auto';
295
- if (searchRef.current) lastSearchRef.current = '';
286
+ // document.documentElement.style.overflow = 'auto';
287
+ setTxtSearch('');
296
288
  onClosed === null || onClosed === void 0 ? void 0 : onClosed();
297
289
  };
298
- const renderDropdown = pattern => {
299
- var _displayExpr2;
300
- const keyArr = (_displayExpr2 = displayExpr) === null || _displayExpr2 === void 0 ? void 0 : _displayExpr2.match(separatorPattern);
301
- const dropdown = mapDropdown(pattern, keyArr);
302
- const el = document.createElement('div');
303
- el.className = `DGN-Dropdown-Box`;
304
- if (dropdownRef.current) {
305
- var _dropdownRef$current$;
306
- (_dropdownRef$current$ = dropdownRef.current.querySelector('.DGN-Dropdown-Box')) === null || _dropdownRef$current$ === void 0 ? void 0 : _dropdownRef$current$.remove();
307
- ReactDOM.render(dropdown, dropdownRef.current.appendChild(el));
308
- setTimeout(() => {
309
- if (onLoadMore && dataSource.length < total) {
310
- dropdownListRef.current && dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
311
- }
312
- updatePositionDropdown();
313
- }, 0);
314
- }
290
+
291
+ // const renderDropdown = pattern => {
292
+ // const keyArr = displayExpr?.match(separatorPattern);
293
+ // const dropdown = mapDropdown(pattern, keyArr);
294
+ // const el = document.createElement('div');
295
+ // el.className = `DGN-Dropdown-Box`;
296
+ // if (dropdownRef.current) {
297
+ // dropdownRef.current.querySelector('.DGN-Dropdown-Box')?.remove();
298
+ // ReactDOM.render(dropdown, dropdownRef.current.appendChild(el));
299
+ // setTimeout(() => {
300
+ // if (onLoadMore && dataSource.length < total) {
301
+ // dropdownListRef.current &&
302
+ // dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
303
+ // }
304
+ // updatePositionDropdown();
305
+ // }, 0);
306
+ // }
307
+ // };
308
+
309
+ /**
310
+ * So sánh text đầu vào cáo map với txtSearch
311
+ * @param text
312
+ * @return {boolean}
313
+ */
314
+ const handleRenderBySearch = (text = '') => {
315
+ if (!txtSearch || typeof text !== 'string') return true;
316
+ if (searchMode === 'startswith') {
317
+ return text.toLowerCase().startsWith(txtSearch.toLowerCase());
318
+ } else if (searchMode === 'equals') {
319
+ return text.toLowerCase() === txtSearch.toLowerCase();
320
+ } else return text.toLowerCase().includes(txtSearch.toLowerCase());
315
321
  };
316
- const handleRenderBySearch = (data, searchValue) => {
317
- let existExpr;
318
- typeof data === 'object' ? existExpr = searchExpr.filter(value => Object.keys(data).includes(value)) : existExpr = [data];
319
- return existExpr.every(key => {
320
- const _data = (data === null || data === void 0 ? void 0 : data[key]) || key.toString();
321
- if (searchMode === 'contains') {
322
- if (_data.indexOf(searchValue) !== -1) return false;
323
- }
324
- if (searchMode === 'startswith') {
325
- if (_data.lastIndexOf(searchValue) === 0) return false;
326
- }
327
- if (searchMode === 'equals') {
328
- if (_data === searchValue) return false;
322
+
323
+ /**
324
+ * Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
325
+ * @param data {object} rowData of dataSource
326
+ * @return {string}
327
+ */
328
+ const displayValue = data => {
329
+ let text = '';
330
+ if (data || data === 0) {
331
+ displayExpr = displayExpr || valueExpr;
332
+ let mask = data === null || data === void 0 ? void 0 : data[displayExpr];
333
+ // convert {id} - {name} to {<data[id]>} - {<data[name]>}
334
+ if (!mask && regexBetween.test(displayExpr)) {
335
+ var _displayExpr;
336
+ mask = (_displayExpr = displayExpr) === null || _displayExpr === void 0 ? void 0 : _displayExpr.replace(regexBetween, _ => data[_]);
337
+ } else if (!mask) {
338
+ mask = typeof data !== 'object' ? data : '';
329
339
  }
330
- return true;
331
- });
340
+ text = mask.toString().replace(regexInclude, '');
341
+ }
342
+ return text;
332
343
  };
333
- const mapDropdown = (pattern, keyArr) => {
334
- var _currentObjectDefault;
344
+ const mapDropdown = () => {
345
+ var _dataSourceUsable, _currentObjectDefault;
335
346
  const items = [];
336
- const dataSourceUsable = [...dataSource];
347
+ let dataSourceUsable = [...dataSource];
348
+
349
+ // search dataSource dựa trên txtSearch
350
+ dataSourceUsable = (_dataSourceUsable = dataSourceUsable) === null || _dataSourceUsable === void 0 ? void 0 : _dataSourceUsable.filter(i => {
351
+ if (searchExpr) {
352
+ // nếu map đc vs 1 trong những <key>(data[key]) của searchExpr
353
+ return !!searchExpr.find(j => handleRenderBySearch(i[j]));
354
+ } else {
355
+ // nếu map đc vs displayValue
356
+ return handleRenderBySearch(displayValue(i));
357
+ }
358
+ });
337
359
  if (currentObjectDefault[unique] && (_currentObjectDefault = currentObjectDefault[unique]) !== null && _currentObjectDefault !== void 0 && _currentObjectDefault.length) {
338
360
  const length = currentObjectDefault[unique].length;
339
361
  let existItemQuantity = 0;
340
362
  for (let index = length - 1; index >= 0; index--) {
341
- if (!dataSourceUsable.some(data => data[valueExpr] === currentObjectDefault[unique][index][valueExpr])) {
363
+ if ((currentObjectDefault[unique][index][valueExpr] || currentObjectDefault[unique][index][valueExpr] === 0) && !dataSourceUsable.some(data => data[valueExpr] === currentObjectDefault[unique][index][valueExpr])) {
342
364
  dataSourceUsable.unshift(currentObjectDefault[unique][index]);
343
365
  } else {
344
366
  // Nếu số lượng phần tử của valueObjectDefault tồn tại trong dataSource nhiều hơn hoặc bằng limit thì không remove nữa
@@ -351,14 +373,15 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
351
373
  }
352
374
  const length = dataSourceUsable.length;
353
375
  for (let index = 0; index < length; index++) {
354
- var _searchExpr;
355
376
  const data = dataSourceUsable[index];
356
377
  const itemHidden = typeof data === 'object' ? data['hidden'] : false;
357
378
  if (itemHidden) continue;
358
- let displayText = typeof data === 'object' ? keyArr ? renderData(data, keyArr) : data[displayExpr] || data[valueExpr] : data;
359
- if (((_searchExpr = searchExpr) === null || _searchExpr === void 0 ? void 0 : _searchExpr.length) > 0 && pattern) {
360
- if (handleRenderBySearch(data, pattern)) continue;
361
- } else if (pattern && !new RegExp(pattern).test(displayText.normalize())) continue;
379
+ let displayText = displayValue(data);
380
+
381
+ // if (searchExpr?.length > 0 && pattern) {
382
+ // if (handleRenderBySearch(data, pattern)) continue;
383
+ // } else if (pattern && !new RegExp(pattern).test(displayText.normalize())) continue;
384
+
362
385
  if (renderItem && typeof renderItem === 'function') {
363
386
  displayText = renderItem({
364
387
  data,
@@ -371,7 +394,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
371
394
  }, displayText), jsx(Typography, {
372
395
  className: 'DGN-UI-Dropdown-SubText',
373
396
  type: 'p3',
374
- color: 'text.sub'
397
+ color: 'text/sub'
375
398
  }, typeof subText === 'function' ? subText({
376
399
  data,
377
400
  index
@@ -464,8 +487,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
464
487
  renderItem: renderItem
465
488
  }) : EmptyDataText);
466
489
  };
490
+
491
+ // remove item cũ và append child item mới khi load more
467
492
  const loadMoreItemsDropdown = (i = 0, pattern) => {
468
- var _currentObjectDefault2, _displayExpr3;
493
+ var _currentObjectDefault2, _displayExpr2;
469
494
  const dataSourceUsable = [...dataSource];
470
495
  // Nếu có load more thì đẩy đội tượng mặc định lên đầu
471
496
  let notExistItem = 0;
@@ -483,7 +508,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
483
508
  if (displayExpr && Array.isArray(displayExpr)) {
484
509
  displayExpr = displayExpr.join(' - ');
485
510
  }
486
- const keyArr = (_displayExpr3 = displayExpr) === null || _displayExpr3 === void 0 ? void 0 : _displayExpr3.match(separatorPattern);
511
+ const keyArr = (_displayExpr2 = displayExpr) === null || _displayExpr2 === void 0 ? void 0 : _displayExpr2.match(separatorPattern);
487
512
  for (i; i < length; i++) {
488
513
  const data = {
489
514
  ...dataSourceUsable[i]
@@ -509,7 +534,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
509
534
  }, displayText), jsx(Typography, {
510
535
  className: 'DGN-UI-Dropdown-SubText',
511
536
  type: 'p3',
512
- color: 'text.sub'
537
+ color: 'text/sub'
513
538
  }, typeof subText === 'function' ? subText({
514
539
  data,
515
540
  index: i
@@ -568,37 +593,52 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
568
593
  _src = prefix + url + suffix;
569
594
  }
570
595
  return jsx(Avatar, {
596
+ css: mgr([insideChip ? 0 : 2]),
571
597
  disabled: true,
572
598
  src: _src,
573
599
  width: insideChip ? 20 : 24,
574
600
  height: insideChip ? 20 : 24,
575
601
  style: {
576
- ...iconExpr.style,
577
- marginRight: spacing([insideChip ? 0 : 2])
602
+ ...iconExpr.style
578
603
  }
579
604
  });
580
605
  };
581
606
  const customizeWidthDropdown = () => {
582
- if (dropdownListRef.current && _isMobile) dropdownListRef.current.style.maxHeight = `${Math.min(280, window.innerHeight) - (allowSearch ? 40 : 0)}px`;
583
- if (!ref.current) {
584
- window.removeEventListener('resize', customizeWidthDropdown);
585
- return;
607
+ // if (dropdownListRef.current && _isMobile)
608
+ // dropdownListRef.current.style.maxHeight = `${
609
+ // Math.min(280, window.innerHeight) - (allowSearch ? 40 : 0)
610
+ // }px`;
611
+ if (timer.current) {
612
+ clearTimeout(timer.current);
586
613
  }
587
- const {
588
- width
589
- } = ref.current.getBoundingClientRect();
590
- if (dropdownRef.current) {
591
- dropdownRef.current.style.width = width + 'px';
592
- }
593
- updatePositionDropdown();
594
- };
595
- const updatePositionDropdown = () => {
596
- if (!formRef.current || !dropdownRef.current) {
597
- document.removeEventListener('wheel', onWheelHandler);
598
- return;
599
- }
600
- _isMobile ? updatePosition(formRef.current, dropdownRef.current, null) : updatePosition(formRef.current, dropdownRef.current, closeDropdown);
614
+ timer.current = setTimeout(() => {
615
+ if (!ref.current) {
616
+ window.removeEventListener('resize', customizeWidthDropdown);
617
+ return;
618
+ } else {
619
+ const {
620
+ width
621
+ } = ref.current.getBoundingClientRect();
622
+ setPopoverWidth(width);
623
+ }
624
+ }, 300);
625
+
626
+ // if (dropdownRef.current) {
627
+ // dropdownRef.current.style.width = width + 'px';
628
+ // }
629
+ // updatePositionDropdown();
601
630
  };
631
+
632
+ // const updatePositionDropdown = () => {
633
+ // if (!formRef.current || !dropdownRef.current) {
634
+ // // document.removeEventListener('wheel', onWheelHandler);
635
+ // return;
636
+ // }
637
+ // _isMobile
638
+ // ? updatePosition(formRef.current, dropdownRef.current, null)
639
+ // : updatePosition(formRef.current, dropdownRef.current, closeDropdown);
640
+ // };
641
+
602
642
  const onLoadMoreHandler = e => {
603
643
  if (loadMoreTimer.current) {
604
644
  clearTimeout(loadMoreTimer.current);
@@ -610,8 +650,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
610
650
  offsetHeight
611
651
  } = e.target;
612
652
  if (scrollHeight === Math.ceil(scrollTop) + offsetHeight && dropdownListRef.current) {
613
- var _dropdownListRef$curr4, _currentObjectDefault3;
614
- const length = ((_dropdownListRef$curr4 = dropdownListRef.current.children) === null || _dropdownListRef$curr4 === void 0 ? void 0 : _dropdownListRef$curr4.length) - (((_currentObjectDefault3 = currentObjectDefault[unique]) === null || _currentObjectDefault3 === void 0 ? void 0 : _currentObjectDefault3.length) || 0);
653
+ var _dropdownListRef$curr, _currentObjectDefault3;
654
+ const length = ((_dropdownListRef$curr = dropdownListRef.current.children) === null || _dropdownListRef$curr === void 0 ? void 0 : _dropdownListRef$curr.length) - (((_currentObjectDefault3 = currentObjectDefault[unique]) === null || _currentObjectDefault3 === void 0 ? void 0 : _currentObjectDefault3.length) || 0);
615
655
  dropdownListRef.current.removeEventListener('scroll', onLoadMoreHandler);
616
656
  !!onLoadMore && onLoadMore({
617
657
  skip: length,
@@ -625,42 +665,48 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
625
665
  return false;
626
666
  };
627
667
  const onChangeInput = e => {
628
- if (searchRef.current) lastSearchRef.current = searchRef.current.value;
629
- const dataFilter = getData();
630
- dataChosen.current = [...dataFilter].filter(i => [...valueMulti].includes(i === null || i === void 0 ? void 0 : i[valueExpr]));
668
+ var _e$target$value;
669
+ if (!dropdownRef.current) return; // Kiểm tra nếu dropdown đóng trước searchDelayTime thì không chạy
670
+ setTxtSearch((_e$target$value = e.target.value) !== null && _e$target$value !== void 0 ? _e$target$value : '');
671
+ // if (searchRef.current) lastSearchRef.current = searchRef.current.value;
672
+ // const dataFilter = getData();
673
+ // dataChosen.current = [...dataFilter].filter(i => [...valueMulti].includes(i?.[valueExpr]));
631
674
  if (onInput) {
632
- isSearch[unique] = true;
675
+ // isSearch[unique] = true;
633
676
  // const valueInput = e.target.value;
634
677
  // const text = (valueInput || e.target.textContent).normalize();
635
- if (timeout.current) {
636
- if (timing[unique]) {
637
- clearTimeout(timing[unique]);
638
- }
639
- timing[unique] = setTimeout(() => {
640
- // e.target.value = text;
641
- onInput(e);
642
- // e.target.value = valueInput;
643
- }, timeout.current || searchDelayTime);
644
- } else {
645
- // e.target.value = text;
646
- onInput(e);
647
- // e.target.value = valueInput;
648
- }
649
-
650
- return;
651
- }
652
- const value = e.target.value || e.target.textContent;
653
- if (typeof renderSelectedItem === 'function' && e.target.childNodes && Array.from(e.target.childNodes).some(node => node.toString() !== '[object Text]')) {
654
- const cursor = document.getSelection().anchorOffset;
655
- e.target.innerHTML = value;
656
- document.getSelection().collapse(e.target, cursor);
678
+ // if (timeout.current) {
679
+ // if (timing[unique]) {
680
+ // clearTimeout(timing[unique]);
681
+ // }
682
+ // timing[unique] = setTimeout(() => {
683
+ // e.target.value = text;
684
+ onInput(e);
685
+ // e.target.value = valueInput;
686
+ // }, timeout.current || searchDelayTime);
687
+ // } else {
688
+ // e.target.value = text;
689
+ // onInput(e);
690
+ // e.target.value = valueInput;
691
+ // }
692
+ // return;
657
693
  }
658
- if (timing[unique]) clearTimeout(timing[unique]);
659
- timing[unique] = setTimeout(() => {
660
- var _searchExpr2;
661
- renderDropdown(((_searchExpr2 = searchExpr) === null || _searchExpr2 === void 0 ? void 0 : _searchExpr2.length) > 0 ? value.normalize() : new RegExp(value.normalize(), 'gim'));
662
- }, timeout.current || searchDelayTime);
694
+ // const value = e.target.value || e.target.textContent;
695
+ // if (
696
+ // typeof renderSelectedItem === 'function' &&
697
+ // e.target.childNodes &&
698
+ // Array.from(e.target.childNodes).some(node => node.toString() !== '[object Text]')
699
+ // ) {
700
+ // const cursor = document.getSelection().anchorOffset;
701
+ // e.target.innerHTML = value;
702
+ // document.getSelection().collapse(e.target, cursor);
703
+ // }
704
+ // if (timing[unique]) clearTimeout(timing[unique]);
705
+ // timing[unique] = setTimeout(() => {
706
+ // renderDropdown(searchExpr?.length > 0 ? value.normalize() : new RegExp(value.normalize(), 'gim'));
707
+ // }, timeout.current || searchDelayTime);
663
708
  };
709
+
664
710
  const onChangeValue = (displayText, value, icon, data) => {
665
711
  if (itemMode === 'treeview') {
666
712
  if (valueProp === undefined) {
@@ -671,16 +717,16 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
671
717
  !!onChange && onChange({
672
718
  value
673
719
  });
674
- setTimeout(() => {
675
- updatePositionDropdown();
676
- }, 0);
720
+ // setTimeout(() => {
721
+ // updatePositionDropdown();
722
+ // }, 0);
677
723
  } else if (multiple) {
678
724
  if (!Array.isArray(currentValue[unique])) currentValue[unique] = [];
679
- const newValueArr = [...currentValue[unique]];
680
- // const newValueArrState = [...valueMulti];
681
- if (!currentValue[unique].some(v => JSON.stringify(v) === JSON.stringify(value))) {
682
- newValueArr.push(value);
683
- // newValueArrState.push(value);
725
+ // const newValueArr = [...currentValue[unique]];
726
+ const newValueArrState = [...valueMulti];
727
+ if (!newValueArrState.some(v => JSON.stringify(v) === JSON.stringify(value))) {
728
+ // newValueArr.push(value);
729
+ newValueArrState.push(value);
684
730
  // if (valueProp === undefined) {
685
731
  // let item = null;
686
732
  // if (typeof renderSelectedItem === 'function') {
@@ -704,22 +750,23 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
704
750
  // ReactDOM.render(item, inputRef.current.appendChild(el));
705
751
  // }
706
752
  } else {
707
- const index = newValueArr.indexOf(value);
708
- newValueArr.splice(index, 1);
709
- // newValueArrState.splice(index, 1);
753
+ const index = newValueArrState.indexOf(value);
754
+ // newValueArr.splice(index, 1);
755
+ newValueArrState.splice(index, 1);
710
756
  // if (valueProp === undefined) {
711
757
  // const nodes = inputRef.current.querySelectorAll('.dropdown-item');
712
758
  // nodes[index]?.remove();
713
759
  // }
714
760
  }
715
- // setValueMulti(newValueArrState);
761
+
762
+ setValueMulti(newValueArrState);
716
763
  !!onChange && onChange({
717
- value: newValueArr,
764
+ value: newValueArrState,
718
765
  data
719
766
  });
720
- setTimeout(() => {
721
- updatePositionDropdown();
722
- }, 0);
767
+ // setTimeout(() => {
768
+ // updatePositionDropdown();
769
+ // }, 0);
723
770
  } else {
724
771
  const isChanged = currentValue[unique] !== value;
725
772
  if (isChanged) {
@@ -739,11 +786,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
739
786
  }
740
787
  if (closeAfterSelect === true || closeAfterSelect === undefined && !multiple) {
741
788
  closeDropdown();
742
- } else {
743
- setTimeout(() => {
744
- updatePositionDropdown();
745
- }, 0);
746
789
  }
790
+ // else {
791
+ // setTimeout(() => {
792
+ // updatePositionDropdown();
793
+ // }, 0);
794
+ // }
747
795
  };
748
796
 
749
797
  // const onChangeValueWithCheckbox = e => {
@@ -785,20 +833,20 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
785
833
  const onClear = e => {
786
834
  if (disabled || readOnly || loading || !clearAble) return;
787
835
  currentValue[unique] = multiple ? [] : '';
788
- if (inputRef.current.tagName.toLowerCase() === 'div') {
836
+ if (multiple) {
837
+ setValueMulti([]);
789
838
  // inputRef.current.innerHTML = '';
790
839
  // if (dropdownListRef.current) {
791
840
  // dropdownListRef.current.querySelectorAll('input').forEach(input => (input.checked = false));
792
841
  // }
793
842
  } else {
794
- inputRef.current.value = '';
795
843
  setTextValue('');
796
844
  }
797
845
  // onChangeValue('', '');
798
846
  setValueMulti([]);
799
847
  setShowClear(false);
800
848
  e && e.target && e.target.blur();
801
- updatePositionDropdown();
849
+ // updatePositionDropdown();
802
850
  onInput === null || onInput === void 0 ? void 0 : onInput({
803
851
  ...(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current),
804
852
  target: {
@@ -1065,11 +1113,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1065
1113
  inputRef.current.addEventListener('click', onClickInput);
1066
1114
  }
1067
1115
  if (dropdownListRef.current) {
1068
- var _dropdownListRef$curr5, _dropdownListRef$curr6, _currentObjectDefault6;
1116
+ var _dropdownListRef$curr2, _dropdownListRef$curr3, _currentObjectDefault6;
1069
1117
  if (!disabled && !readOnly) {
1070
1118
  inputRef.current.addEventListener('input', onChangeInput);
1071
1119
  }
1072
- const length = (_dropdownListRef$curr5 = dropdownListRef.current) === null || _dropdownListRef$curr5 === void 0 ? void 0 : (_dropdownListRef$curr6 = _dropdownListRef$curr5.children) === null || _dropdownListRef$curr6 === void 0 ? void 0 : _dropdownListRef$curr6.length;
1120
+ const length = (_dropdownListRef$curr2 = dropdownListRef.current) === null || _dropdownListRef$curr2 === void 0 ? void 0 : (_dropdownListRef$curr3 = _dropdownListRef$curr2.children) === null || _dropdownListRef$curr3 === void 0 ? void 0 : _dropdownListRef$curr3.length;
1073
1121
  if (length < dataSource.length + ((_currentObjectDefault6 = currentObjectDefault[unique]) === null || _currentObjectDefault6 === void 0 ? void 0 : _currentObjectDefault6.length) && !isSearch[unique]) {
1074
1122
  loadMoreItemsDropdown(length);
1075
1123
  !!onLoadMore && dataSource.length < total && dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
@@ -1089,6 +1137,14 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1089
1137
  !!dropdownListRef.current && dropdownListRef.current.removeEventListener('scroll', onLoadMoreHandler);
1090
1138
  };
1091
1139
  }, [dataSource]);
1140
+ useLayoutEffect(() => {
1141
+ if (ref.current) {
1142
+ const {
1143
+ width
1144
+ } = ref.current.getBoundingClientRect();
1145
+ setPopoverWidth(width);
1146
+ }
1147
+ });
1092
1148
  /* End handler */
1093
1149
 
1094
1150
  /* Start component */
@@ -1122,12 +1178,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1122
1178
  className: 'DGN-UI-Dropdown-Form-Input'
1123
1179
  }, multiple && valueMulti !== null && valueMulti !== void 0 && valueMulti.length ? jsx("div", {
1124
1180
  ...inputProps,
1125
- style: {
1126
- gap: spacing(0.5),
1127
- ...inputStyle
1128
- },
1181
+ style: inputStyle,
1129
1182
  ref: inputRef,
1130
- css: _DropdownInputCSS,
1183
+ css: [_DropdownInputCSS, gap([0.5])],
1131
1184
  className: classNames('dgn-dropdown-multiple', inputProps.className),
1132
1185
  onChange: e => {
1133
1186
  e.preventDefault();
@@ -1135,19 +1188,24 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1135
1188
  }
1136
1189
  }, valueMulti.map((vl, index) => {
1137
1190
  let dataFilter = getData();
1138
- const data = dataFilter.find(v => v[valueExpr] === vl);
1191
+ const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
1139
1192
  let text = '';
1140
- if (data) {
1141
- var _mask;
1142
- displayExpr = typeof renderSelectedItem === 'string' ? renderSelectedItem : displayExpr || valueExpr;
1193
+ if (data || data === 0) {
1194
+ displayExpr = displayExpr || valueExpr;
1195
+ // displayExpr =
1196
+ // typeof renderSelectedItem === 'string'
1197
+ // ? renderSelectedItem
1198
+ // : displayExpr || valueExpr;
1143
1199
  let mask = data === null || data === void 0 ? void 0 : data[displayExpr];
1144
1200
 
1145
1201
  // convert {id} - {name} to {<data[id]>} - {<data[name]>}
1146
1202
  if (!mask && regexBetween.test(displayExpr)) {
1147
- var _displayExpr4;
1148
- mask = (_displayExpr4 = displayExpr) === null || _displayExpr4 === void 0 ? void 0 : _displayExpr4.replace(regexBetween, _ => data[_]);
1203
+ var _displayExpr3;
1204
+ mask = (_displayExpr3 = displayExpr) === null || _displayExpr3 === void 0 ? void 0 : _displayExpr3.replace(regexBetween, _ => data[_]);
1205
+ } else if (!mask) {
1206
+ mask = typeof data !== 'object' ? data : '';
1149
1207
  }
1150
- text = (_mask = mask) === null || _mask === void 0 ? void 0 : _mask.replace(regexInclude, '');
1208
+ text = mask.toString().replace(regexInclude, '');
1151
1209
  }
1152
1210
  let item;
1153
1211
  if (typeof renderSelectedItem === 'function') {
@@ -1157,6 +1215,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1157
1215
  });
1158
1216
  } else {
1159
1217
  item = jsx(Chip, {
1218
+ css: [parseWidth('100%'), parseMaxWidth('max-content')],
1160
1219
  key: index,
1161
1220
  startIcon: getIconFromData(data, true),
1162
1221
  label: text,
@@ -1203,13 +1262,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1203
1262
  name: 'Close',
1204
1263
  onClick: onClear
1205
1264
  }) : null, !loading ? jsx(ButtonIcon, {
1265
+ key: openState,
1266
+ css: animation,
1206
1267
  viewType: 'ghost',
1207
- name: 'ArrowDown',
1208
- className: 'icon-dropdown',
1209
- onClick: triggerInput,
1210
- style: {
1211
- transition: 'transform 0.5s'
1212
- },
1268
+ name: openState ? 'ArrowUp' : 'ArrowDown',
1269
+ onClick: setShowDropdown,
1213
1270
  disabled: disabled || readOnly
1214
1271
  }) : null));
1215
1272
  }, [openState, showClear, textValue, valueMulti, clearAble, dataSource, disabled, displayExpr, inputProps, inputStyle, loading, multilineSelectedItem, multiple, onChange, placeholder, readOnly, renderSelectedItem, valueExpr, valueObjectDefault, viewType]);
@@ -1220,8 +1277,16 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1220
1277
  }, error) : null;
1221
1278
  }, [disabled, error, helperTextProps]);
1222
1279
  const DropdownView = useMemo(() => {
1223
- return openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null;
1224
- }, [openState, valueMulti, dataSource, loading, maximumSelectionLength, multilineSelectedItem, multiple, selectBox]);
1280
+ return jsx(Popover, {
1281
+ css: [mgt([1]), overflowHidden],
1282
+ ref: dropdownRef,
1283
+ open: openState,
1284
+ anchor: ref.current,
1285
+ width: popoverWidth,
1286
+ onClose: closeDropdown
1287
+ }, showDropdown());
1288
+ // return openState ? createPortal(showDropdown(), document.body) : null;
1289
+ }, [openState, popoverWidth, valueMulti, dataSource, loading, maximumSelectionLength, multilineSelectedItem, multiple, selectBox, txtSearch]);
1225
1290
  /* End component */
1226
1291
 
1227
1292
  return jsx(Fragment, null, jsx("div", {
@@ -1242,12 +1307,12 @@ const DropdownInputCSS = (viewType, multiple, placeholder, disabled, readOnly, m
1242
1307
  ${displayFlex};
1243
1308
  ${itemsCenter};
1244
1309
  ${outlineNone};
1245
- ${bgTransparent};
1310
+ ${bgColor('transparent')};
1246
1311
  ${borderNone};
1247
1312
  ${paragraph1};
1248
1313
  ${disabled ? cursorNotAllowed : readOnly ? cursorDefault : cursorPointer};
1249
1314
  ${parseWidth('100%')};
1250
- ${textColor('text.main')};
1315
+ ${textColor('text/main')};
1251
1316
  ${pdt(0)};
1252
1317
  ${pdb([viewType !== 'outlined' ? 0 : 'inherit'])};
1253
1318
  ${pdl([viewType !== 'outlined' ? 0 : 4])};
@@ -1269,14 +1334,14 @@ const DropdownInputCSS = (viewType, multiple, placeholder, disabled, readOnly, m
1269
1334
  ${itemsCenter};
1270
1335
  ${justifyCenter};
1271
1336
  content: '${placeholder}';
1272
- ${textColor('text.sub')};
1337
+ ${textColor('text/sub')};
1273
1338
  }
1274
1339
  &:not(:empty)::after {
1275
- visibility: hidden;
1340
+ ${invisible};
1276
1341
  }
1277
1342
  }
1278
1343
  &:focus {
1279
- ${bgTransparent};
1344
+ ${bgColor('transparent')};
1280
1345
  }
1281
1346
  .dropdown-item {
1282
1347
  &:not(:last-child) {
@@ -1288,7 +1353,7 @@ const DropdownInputCSS = (viewType, multiple, placeholder, disabled, readOnly, m
1288
1353
  }
1289
1354
  }
1290
1355
  .DGN-UI-Typography {
1291
- ${disabled && textColor('system.disabled')};
1356
+ ${disabled && textColor('system/disabled')};
1292
1357
  }
1293
1358
  `;
1294
1359
  const IconCSS = viewType => css`
@@ -1308,52 +1373,47 @@ const DropdownFormCSS = (viewType, multiple, disabled, placeholder, DropdownInpu
1308
1373
  ${!disabled && css`
1309
1374
  &:not(:focus-within):hover {
1310
1375
  &::before {
1311
- ${borderBottomColor('system.active')};
1376
+ ${borderBottomColor('system/active')};
1312
1377
  }
1313
1378
  .css-${DropdownInputCSSName} {
1314
- ${textColor('system.active')};
1379
+ ${textColor('system/active')};
1315
1380
  }
1316
1381
  }
1317
1382
  `}
1318
1383
  &:focus-within {
1319
- ${borderBottomColor('line.focus')};
1384
+ ${borderBottomColor('line/focus')};
1320
1385
  &::after {
1321
1386
  ${borderBottomColor('inherit')};
1322
1387
  transform: scaleX(1);
1323
1388
  }
1324
1389
  .css-${DropdownInputCSSName} {
1325
- ${textColor('system.active')};
1326
- }
1327
- }
1328
- &.dropdown-showing {
1329
- .icon-dropdown {
1330
- transform: rotateX(180deg);
1390
+ ${textColor('system/active')};
1331
1391
  }
1332
1392
  }
1333
1393
  span:empty:before {
1334
1394
  content: '${placeholder}';
1335
1395
  ${parseHeight('100%')};
1336
1396
  ${overflowHidden};
1337
- ${textColor('text.sub')};
1397
+ ${textColor('text/sub')};
1338
1398
  display: -webkit-box;
1339
1399
  -webkit-line-clamp: 1;
1340
1400
  -webkit-box-orient: vertical;
1341
1401
  }
1342
1402
  &::placeholder {
1343
- ${textColor('text.sub')};
1403
+ ${textColor('text/sub')};
1344
1404
  }
1345
1405
  &::before {
1346
1406
  ${positionAbsolute};
1347
1407
  content: '';
1348
1408
  ${insetX(0)};
1349
- bottom: 0;
1350
- ${viewType === 'underlined' && borderBottom(1, disabled ? 'system.disabled' : 'system.rest')}
1409
+ ${bottom(0)};
1410
+ ${viewType === 'underlined' && borderBottom(1, disabled ? 'system/disabled' : 'system/rest')}
1351
1411
  }
1352
1412
  &::after {
1353
1413
  ${positionAbsolute};
1354
1414
  content: '';
1355
1415
  ${insetX(0)};
1356
- bottom: -1px;
1416
+ ${bottom(-1)};
1357
1417
  ${borderBottom(2, 'transparent')};
1358
1418
  transform: scaleX(0);
1359
1419
  transform-origin: center;
@@ -1364,45 +1424,40 @@ const DropdownFormCSS = (viewType, multiple, disabled, placeholder, DropdownInpu
1364
1424
  ${flexRow};
1365
1425
  ${itemsCenter};
1366
1426
  ${positionRelative};
1367
- ${borderRadius4px};
1427
+ ${borderRadius(4)};
1368
1428
  ${boxBorder};
1369
- ${border(1, disabled ? 'system.disabled' : 'system.rest')};
1429
+ ${border(1, disabled ? 'system/disabled' : 'system/rest')};
1370
1430
  ${parseWidth('100%')};
1371
1431
  ${parseMinHeight(40)};
1372
1432
  ${mgt([0.5])};
1373
1433
  ${!disabled && css`
1374
1434
  &:not(:focus-within):hover {
1375
- ${bgColor('fill.hover')};
1376
- ${borderColor('system.active')};
1435
+ ${bgColor('fill/hover')};
1436
+ ${borderColor('system/active')};
1377
1437
  input {
1378
- ${bgColor('fill.hover')};
1438
+ ${bgColor('fill/hover')};
1379
1439
  }
1380
1440
  }
1381
1441
  `}
1382
1442
  &:focus-within {
1383
- ${borderColor('line.focus')};
1384
- }
1385
- &.dropdown-showing {
1386
- .icon-dropdown {
1387
- transform: rotateX(180deg);
1388
- }
1443
+ ${borderColor('line/focus')};
1389
1444
  }
1390
1445
  span:empty:before {
1391
1446
  content: '${placeholder}';
1392
1447
  ${parseHeight('100%')};
1393
1448
  ${overflowHidden};
1394
- ${textColor('text.sub')};
1449
+ ${textColor('text/sub')};
1395
1450
  display: -webkit-box;
1396
1451
  -webkit-line-clamp: 1;
1397
1452
  -webkit-box-orient: vertical;
1398
1453
  }
1399
1454
  &::placeholder {
1400
- ${textColor('text.sub')};
1455
+ ${textColor('text/sub')};
1401
1456
  }
1402
1457
  &::after {
1403
1458
  ${positionAbsolute};
1404
1459
  ${pointerEventsNone};
1405
- ${borderRadius4px};
1460
+ ${borderRadius(4)};
1406
1461
  ${border(2, 'transparent')};
1407
1462
  ${inset(-2)};
1408
1463
  content: '';
@@ -1412,23 +1467,23 @@ const DropdownListCSS = loading => css`
1412
1467
  ${displayBlock};
1413
1468
  ${positionRelative};
1414
1469
  ${boxBorder};
1415
- ${borderRadius4px};
1470
+ ${borderRadius(4)};
1416
1471
  ${parseWidth('100%')};
1417
1472
  ${parseMaxHeight(280)};
1418
1473
  ${loading ? overflowHidden : overflowAuto};
1419
- ${bgColor('system.white')};
1474
+ ${bgColor('system/white')};
1420
1475
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
1421
1476
  ${z(1)};
1422
1477
  &::-webkit-scrollbar {
1423
- ${borderRadius4px};
1478
+ ${borderRadius(4)};
1424
1479
  ${parseWidth(24)};
1425
- background-color: ${systemWhite} !important;
1480
+ ${bgColor('system/white')};
1426
1481
  }
1427
1482
  &::-webkit-scrollbar-thumb {
1428
1483
  ${borderRadius(24)};
1429
1484
  ${border(8, 'transparent')};
1485
+ ${bgColor('fill/scrollbar-tabbar')};
1430
1486
  mix-blend-mode: normal;
1431
- background-color: ${fillScrollbar} !important;
1432
1487
  background-clip: content-box;
1433
1488
  }
1434
1489
  .DGN-UI-TreeView {
@@ -1446,9 +1501,9 @@ const DropdownItemCSS = (multiple, selectBox) => css`
1446
1501
  ${userSelectNone};
1447
1502
  ${parseMinHeight(40)};
1448
1503
  ${parseWidth('100%')};
1449
- ${bgColor('system.white')};
1504
+ ${bgColor('system/white')};
1450
1505
  ${pd([2, multiple && selectBox ? 0 : 4])};
1451
- ${textColor('text.main')};
1506
+ ${textColor('text/main')};
1452
1507
  &.no-data {
1453
1508
  ${justifyCenter};
1454
1509
  ${cursorDefault};
@@ -1457,8 +1512,8 @@ const DropdownItemCSS = (multiple, selectBox) => css`
1457
1512
  &:not(.no-data):hover,
1458
1513
  &:not(.no-data):focus {
1459
1514
  ${outlineNone};
1460
- ${bgColor('fill.hover')};
1461
- ${textColor('system.active')};
1515
+ ${bgColor('fill/hover')};
1516
+ ${textColor('system/active')};
1462
1517
  }
1463
1518
  `;
1464
1519
  const DropdownRootCSS = (DropdownFormCSSName, DropdownInputCSSName) => css`
@@ -1468,21 +1523,21 @@ const DropdownRootCSS = (DropdownFormCSSName, DropdownInputCSSName) => css`
1468
1523
  ${parseHeight('max-content')};
1469
1524
  &.error {
1470
1525
  .css-${DropdownFormCSSName} {
1471
- ${borderColor('semantic.danger')};
1526
+ ${borderColor('semantic/danger')};
1472
1527
  path {
1473
- ${fill('semantic.danger')};
1528
+ ${fill('semantic/danger')};
1474
1529
  }
1475
1530
  &::before {
1476
- ${borderColor('semantic.danger')};
1531
+ ${borderColor('semantic/danger')};
1477
1532
  }
1478
1533
  }
1479
1534
  }
1480
1535
  &.dgn-dropdown-loading,
1481
1536
  &.disabled {
1482
1537
  .css-${DropdownFormCSSName} {
1483
- ${borderColor('system.disabled')};
1538
+ ${borderColor('system/disabled')};
1484
1539
  &::before {
1485
- ${borderColor('system.disabled')};
1540
+ ${borderColor('system/disabled')};
1486
1541
  }
1487
1542
  }
1488
1543
  }
@@ -1494,32 +1549,36 @@ const DropdownRootCSS = (DropdownFormCSSName, DropdownInputCSSName) => css`
1494
1549
  }
1495
1550
  }
1496
1551
  `;
1497
- const DropdownCSS = (top, left, width, isMobile, allowSearch) => css`
1498
- ${positionFixed};
1499
- ${parseWidth(width)};
1500
- top: ${top}px;
1501
- left: ${left}px;
1502
- ${bgColor('system.white')};
1503
- ${z(1)};
1504
- ${isMobile && allowSearch && css`
1505
- ${parseHeight('max-content')};
1506
- ${displayFlex};
1507
- ${flexColReverse};
1508
- bottom: 0;
1509
- top: auto;
1510
- `}
1511
- `;
1552
+
1553
+ // const DropdownCSS = (topVl, leftVl, width, isMobile, allowSearch) => css`
1554
+ // ${positionFixed};
1555
+ // ${parseWidth(width)};
1556
+ // ${top(topVl)};
1557
+ // ${left(leftVl)};
1558
+ // ${bgColor('system/white')};
1559
+ // ${z(1)};
1560
+ // ${isMobile &&
1561
+ // allowSearch &&
1562
+ // css`
1563
+ // ${parseHeight('max-content')};
1564
+ // ${displayFlex};
1565
+ // ${flexColReverse};
1566
+ // ${bottom(0)};
1567
+ // ${top('auto')};
1568
+ // `}
1569
+ // `;
1570
+
1512
1571
  const LoadingProgressCSS = css`
1513
1572
  ${displayFlex};
1514
1573
  ${flexRow};
1515
1574
  ${justifyCenter};
1516
1575
  ${itemsCenter};
1517
1576
  ${positionAbsolute};
1518
- ${borderRadius4px};
1577
+ ${borderRadius(4)};
1519
1578
  ${parseWidthHeight('100%')}
1520
1579
  ${bgColor('rgba(255, 255, 255, 0.6)')};
1521
1580
  ${z(2)};
1522
- top: 0;
1581
+ ${top(0)};
1523
1582
  `;
1524
1583
  const DisabledCSS = css`
1525
1584
  pointer-events: none !important;
@@ -1552,6 +1611,7 @@ Dropdown.defaultProps = {
1552
1611
  placeholder: getGlobal('dropdownPlaceholder'),
1553
1612
  readOnly: false,
1554
1613
  required: false,
1614
+ searchDelayTime: getGlobal('delayOnInput'),
1555
1615
  searchMode: 'contains',
1556
1616
  total: Number.MAX_SAFE_INTEGER,
1557
1617
  valueExpr: 'id',
@@ -1574,9 +1634,9 @@ Dropdown.propTypes = {
1574
1634
  defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1575
1635
  /** If `true`, the component is disabled. */
1576
1636
  disabled: PropTypes.bool,
1577
- /** Field name used for text display in dropdown list.<br/>
1578
- * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1579
- * Note: don't use 'id - name', return undefined
1637
+ /** Field name used for text display in dropdown list.<br/>
1638
+ * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1639
+ * Note: don't use 'id - name', return undefined
1580
1640
  */
1581
1641
  displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1582
1642
  /** Style inline of dropdown items. */
@@ -1585,14 +1645,14 @@ Dropdown.propTypes = {
1585
1645
  error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
1586
1646
  /** Props applied to the [HelperText](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) element. */
1587
1647
  helperTextProps: PropTypes.object,
1588
- /** Field name used for icon display.<br/>
1589
- * Example:<br/>
1590
- * &nbsp;&nbsp;string: 'icon'<br/>
1591
- * &nbsp;&nbsp;object: {<br/>
1592
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1593
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1594
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1595
- * &nbsp;&nbsp;}
1648
+ /** Field name used for icon display.<br/>
1649
+ * Example:<br/>
1650
+ * &nbsp;&nbsp;string: 'icon'<br/>
1651
+ * &nbsp;&nbsp;object: {<br/>
1652
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1653
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1654
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1655
+ * &nbsp;&nbsp;}
1596
1656
  */
1597
1657
  iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
1598
1658
  key: PropTypes.string,
@@ -1626,8 +1686,8 @@ Dropdown.propTypes = {
1626
1686
  onChange: PropTypes.func,
1627
1687
  /** Callback fired when dropdown closed. */
1628
1688
  onClosed: PropTypes.func,
1629
- /** Callback fired when the input value changes.<br/>
1630
- * if undefined: the filter function will run (default)
1689
+ /** Callback fired when the input value changes.<br/>
1690
+ * if undefined: the filter function will run (default)
1631
1691
  */
1632
1692
  onInput: PropTypes.func,
1633
1693
  /** Callback fired when key down input */
@@ -1638,21 +1698,21 @@ Dropdown.propTypes = {
1638
1698
  placeholder: PropTypes.string,
1639
1699
  /** If `true`, the component is read-only. */
1640
1700
  readOnly: PropTypes.bool,
1641
- /** Function displays items by custom.<br/>
1642
- * renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
1643
- * --> such as: displayExpr={'name - role'}
1701
+ /** Function displays items by custom.<br/>
1702
+ * renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
1703
+ * --> such as: displayExpr={'name - role'}
1644
1704
  */
1645
1705
  renderItem: PropTypes.func,
1646
- /** Function or field name used for display selected items, example:<br/>
1647
- * renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
1706
+ /** Function or field name used for display selected items, example:<br/>
1707
+ * renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
1648
1708
  */
1649
1709
  renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
1650
1710
  /** If `true`, the label will indicate that the input is required. */
1651
1711
  required: PropTypes.bool,
1652
- /**
1653
- * Duration wait enter search content on search.<br/>
1654
- * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1655
- * If `true`, used default delayOnInput.
1712
+ /**
1713
+ * Duration wait enter search content on search.<br/>
1714
+ * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1715
+ * If `true`, used default delayOnInput.
1656
1716
  */
1657
1717
  searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
1658
1718
  /** Specifies a data object's field name or an expression whose value is compared to the search string. */
@@ -1679,19 +1739,19 @@ Dropdown.propTypes = {
1679
1739
  valueObjectDefault: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
1680
1740
  /**The variant to use. */
1681
1741
  viewType: PropTypes.oneOf(['underlined', 'outlined', 'none'])
1682
- /**
1683
- * ref methods
1684
- *
1685
- * how to get component element? ref.current
1686
- *
1687
- * how to call method? ref.current.instance.{method}
1688
- *
1689
- * * showDropdown(): Show dropdown
1690
- * * closeDropdown(): Close dropdown
1691
- * * onClear(): Clear selected value
1692
- * * setPreviousValue(): Set value to previous value
1693
- * * setValue(value): Set value of dropdown
1694
- * * @param {value} - string || number || array
1742
+ /**
1743
+ * ref methods
1744
+ *
1745
+ * how to get component element? ref.current
1746
+ *
1747
+ * how to call method? ref.current.instance.{method}
1748
+ *
1749
+ * * showDropdown(): Show dropdown
1750
+ * * closeDropdown(): Close dropdown
1751
+ * * onClear(): Clear selected value
1752
+ * * setPreviousValue(): Set value to previous value
1753
+ * * setValue(value): Set value of dropdown
1754
+ * * @param {value} - string || number || array
1695
1755
  */
1696
1756
  };
1697
1757