diginet-core-ui 1.3.94-beta.9 → 1.3.95-beta.1

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
8
  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";
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, refType as ref, 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
- }
223
+ // if (!((multiple || allowSearch) && itemMode === 'normal' && !children)) {
224
+ // inputRef.current.addEventListener('keydown', pressESCHandler);
225
+ // }
235
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,71 +260,102 @@ 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
286
  document.documentElement.style.overflow = 'auto';
295
- if (searchRef.current) lastSearchRef.current = '';
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) {
331
+ var _data$displayExpr;
332
+ displayExpr = typeof renderSelectedItem === 'string' ? renderSelectedItem : displayExpr || valueExpr;
333
+ let mask = (_data$displayExpr = data === null || data === void 0 ? void 0 : data[displayExpr]) !== null && _data$displayExpr !== void 0 ? _data$displayExpr : '';
334
+
335
+ // convert {id} - {name} to {<data[id]>} - {<data[name]>}
336
+ if (!mask && regexBetween.test(displayExpr)) {
337
+ var _displayExpr;
338
+ mask = (_displayExpr = displayExpr) === null || _displayExpr === void 0 ? void 0 : _displayExpr.replace(regexBetween, _ => 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;
@@ -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: {
@@ -986,6 +1034,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
986
1034
  };
987
1035
  }, [valueObjectDefault]);
988
1036
  useEffect(() => {
1037
+ if (ref.current) {
1038
+ const {
1039
+ width
1040
+ } = ref.current.getBoundingClientRect();
1041
+ setPopoverWidth(width);
1042
+ }
989
1043
  allValue[unique] = [];
990
1044
  if (defaultValue !== undefined && JSON.stringify(defaultValue) !== '[]') {
991
1045
  setValueIntoInput(defaultValue);
@@ -1065,11 +1119,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1065
1119
  inputRef.current.addEventListener('click', onClickInput);
1066
1120
  }
1067
1121
  if (dropdownListRef.current) {
1068
- var _dropdownListRef$curr5, _dropdownListRef$curr6, _currentObjectDefault6;
1122
+ var _dropdownListRef$curr2, _dropdownListRef$curr3, _currentObjectDefault6;
1069
1123
  if (!disabled && !readOnly) {
1070
1124
  inputRef.current.addEventListener('input', onChangeInput);
1071
1125
  }
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;
1126
+ 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
1127
  if (length < dataSource.length + ((_currentObjectDefault6 = currentObjectDefault[unique]) === null || _currentObjectDefault6 === void 0 ? void 0 : _currentObjectDefault6.length) && !isSearch[unique]) {
1074
1128
  loadMoreItemsDropdown(length);
1075
1129
  !!onLoadMore && dataSource.length < total && dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
@@ -1122,12 +1176,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1122
1176
  className: 'DGN-UI-Dropdown-Form-Input'
1123
1177
  }, multiple && valueMulti !== null && valueMulti !== void 0 && valueMulti.length ? jsx("div", {
1124
1178
  ...inputProps,
1125
- style: {
1126
- gap: spacing(0.5),
1127
- ...inputStyle
1128
- },
1179
+ style: inputStyle,
1129
1180
  ref: inputRef,
1130
- css: _DropdownInputCSS,
1181
+ css: [_DropdownInputCSS, gap([0.5])],
1131
1182
  className: classNames('dgn-dropdown-multiple', inputProps.className),
1132
1183
  onChange: e => {
1133
1184
  e.preventDefault();
@@ -1139,13 +1190,17 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1139
1190
  let text = '';
1140
1191
  if (data) {
1141
1192
  var _mask;
1142
- displayExpr = typeof renderSelectedItem === 'string' ? renderSelectedItem : displayExpr || valueExpr;
1193
+ displayExpr = displayExpr || valueExpr;
1194
+ // displayExpr =
1195
+ // typeof renderSelectedItem === 'string'
1196
+ // ? renderSelectedItem
1197
+ // : displayExpr || valueExpr;
1143
1198
  let mask = data === null || data === void 0 ? void 0 : data[displayExpr];
1144
1199
 
1145
1200
  // convert {id} - {name} to {<data[id]>} - {<data[name]>}
1146
1201
  if (!mask && regexBetween.test(displayExpr)) {
1147
- var _displayExpr4;
1148
- mask = (_displayExpr4 = displayExpr) === null || _displayExpr4 === void 0 ? void 0 : _displayExpr4.replace(regexBetween, _ => data[_]);
1202
+ var _displayExpr3;
1203
+ mask = (_displayExpr3 = displayExpr) === null || _displayExpr3 === void 0 ? void 0 : _displayExpr3.replace(regexBetween, _ => data[_]);
1149
1204
  }
1150
1205
  text = (_mask = mask) === null || _mask === void 0 ? void 0 : _mask.replace(regexInclude, '');
1151
1206
  }
@@ -1157,6 +1212,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1157
1212
  });
1158
1213
  } else {
1159
1214
  item = jsx(Chip, {
1215
+ css: [parseWidth('100%'), parseMaxWidth('max-content')],
1160
1216
  key: index,
1161
1217
  startIcon: getIconFromData(data, true),
1162
1218
  label: text,
@@ -1203,13 +1259,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1203
1259
  name: 'Close',
1204
1260
  onClick: onClear
1205
1261
  }) : null, !loading ? jsx(ButtonIcon, {
1262
+ key: openState,
1263
+ css: animation,
1206
1264
  viewType: 'ghost',
1207
- name: 'ArrowDown',
1208
- className: 'icon-dropdown',
1209
- onClick: triggerInput,
1210
- style: {
1211
- transition: 'transform 0.5s'
1212
- },
1265
+ name: openState ? 'ArrowUp' : 'ArrowDown',
1266
+ onClick: setShowDropdown,
1213
1267
  disabled: disabled || readOnly
1214
1268
  }) : null));
1215
1269
  }, [openState, showClear, textValue, valueMulti, clearAble, dataSource, disabled, displayExpr, inputProps, inputStyle, loading, multilineSelectedItem, multiple, onChange, placeholder, readOnly, renderSelectedItem, valueExpr, valueObjectDefault, viewType]);
@@ -1220,8 +1274,16 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1220
1274
  }, error) : null;
1221
1275
  }, [disabled, error, helperTextProps]);
1222
1276
  const DropdownView = useMemo(() => {
1223
- return openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null;
1224
- }, [openState, valueMulti, dataSource, loading, maximumSelectionLength, multilineSelectedItem, multiple, selectBox]);
1277
+ return jsx(Popover, {
1278
+ css: [mgt([1]), overflowHidden],
1279
+ ref: dropdownRef,
1280
+ open: openState,
1281
+ anchor: ref.current,
1282
+ width: popoverWidth,
1283
+ onClose: closeDropdown
1284
+ }, showDropdown());
1285
+ // return openState ? createPortal(showDropdown(), document.body) : null;
1286
+ }, [openState, popoverWidth, valueMulti, dataSource, loading, maximumSelectionLength, multilineSelectedItem, multiple, selectBox, txtSearch]);
1225
1287
  /* End component */
1226
1288
 
1227
1289
  return jsx(Fragment, null, jsx("div", {
@@ -1242,12 +1304,12 @@ const DropdownInputCSS = (viewType, multiple, placeholder, disabled, readOnly, m
1242
1304
  ${displayFlex};
1243
1305
  ${itemsCenter};
1244
1306
  ${outlineNone};
1245
- ${bgTransparent};
1307
+ ${bgColor('transparent')};
1246
1308
  ${borderNone};
1247
1309
  ${paragraph1};
1248
1310
  ${disabled ? cursorNotAllowed : readOnly ? cursorDefault : cursorPointer};
1249
1311
  ${parseWidth('100%')};
1250
- ${textColor('text.main')};
1312
+ ${textColor('text/main')};
1251
1313
  ${pdt(0)};
1252
1314
  ${pdb([viewType !== 'outlined' ? 0 : 'inherit'])};
1253
1315
  ${pdl([viewType !== 'outlined' ? 0 : 4])};
@@ -1269,14 +1331,14 @@ const DropdownInputCSS = (viewType, multiple, placeholder, disabled, readOnly, m
1269
1331
  ${itemsCenter};
1270
1332
  ${justifyCenter};
1271
1333
  content: '${placeholder}';
1272
- ${textColor('text.sub')};
1334
+ ${textColor('text/sub')};
1273
1335
  }
1274
1336
  &:not(:empty)::after {
1275
- visibility: hidden;
1337
+ ${invisible};
1276
1338
  }
1277
1339
  }
1278
1340
  &:focus {
1279
- ${bgTransparent};
1341
+ ${bgColor('transparent')};
1280
1342
  }
1281
1343
  .dropdown-item {
1282
1344
  &:not(:last-child) {
@@ -1288,7 +1350,7 @@ const DropdownInputCSS = (viewType, multiple, placeholder, disabled, readOnly, m
1288
1350
  }
1289
1351
  }
1290
1352
  .DGN-UI-Typography {
1291
- ${disabled && textColor('system.disabled')};
1353
+ ${disabled && textColor('system/disabled')};
1292
1354
  }
1293
1355
  `;
1294
1356
  const IconCSS = viewType => css`
@@ -1308,52 +1370,47 @@ const DropdownFormCSS = (viewType, multiple, disabled, placeholder, DropdownInpu
1308
1370
  ${!disabled && css`
1309
1371
  &:not(:focus-within):hover {
1310
1372
  &::before {
1311
- ${borderBottomColor('system.active')};
1373
+ ${borderBottomColor('system/active')};
1312
1374
  }
1313
1375
  .css-${DropdownInputCSSName} {
1314
- ${textColor('system.active')};
1376
+ ${textColor('system/active')};
1315
1377
  }
1316
1378
  }
1317
1379
  `}
1318
1380
  &:focus-within {
1319
- ${borderBottomColor('line.focus')};
1381
+ ${borderBottomColor('line/focus')};
1320
1382
  &::after {
1321
1383
  ${borderBottomColor('inherit')};
1322
1384
  transform: scaleX(1);
1323
1385
  }
1324
1386
  .css-${DropdownInputCSSName} {
1325
- ${textColor('system.active')};
1326
- }
1327
- }
1328
- &.dropdown-showing {
1329
- .icon-dropdown {
1330
- transform: rotateX(180deg);
1387
+ ${textColor('system/active')};
1331
1388
  }
1332
1389
  }
1333
1390
  span:empty:before {
1334
1391
  content: '${placeholder}';
1335
1392
  ${parseHeight('100%')};
1336
1393
  ${overflowHidden};
1337
- ${textColor('text.sub')};
1394
+ ${textColor('text/sub')};
1338
1395
  display: -webkit-box;
1339
1396
  -webkit-line-clamp: 1;
1340
1397
  -webkit-box-orient: vertical;
1341
1398
  }
1342
1399
  &::placeholder {
1343
- ${textColor('text.sub')};
1400
+ ${textColor('text/sub')};
1344
1401
  }
1345
1402
  &::before {
1346
1403
  ${positionAbsolute};
1347
1404
  content: '';
1348
1405
  ${insetX(0)};
1349
- bottom: 0;
1350
- ${viewType === 'underlined' && borderBottom(1, disabled ? 'system.disabled' : 'system.rest')}
1406
+ ${bottom(0)};
1407
+ ${viewType === 'underlined' && borderBottom(1, disabled ? 'system/disabled' : 'system/rest')}
1351
1408
  }
1352
1409
  &::after {
1353
1410
  ${positionAbsolute};
1354
1411
  content: '';
1355
1412
  ${insetX(0)};
1356
- bottom: -1px;
1413
+ ${bottom(-1)};
1357
1414
  ${borderBottom(2, 'transparent')};
1358
1415
  transform: scaleX(0);
1359
1416
  transform-origin: center;
@@ -1364,45 +1421,40 @@ const DropdownFormCSS = (viewType, multiple, disabled, placeholder, DropdownInpu
1364
1421
  ${flexRow};
1365
1422
  ${itemsCenter};
1366
1423
  ${positionRelative};
1367
- ${borderRadius4px};
1424
+ ${borderRadius(4)};
1368
1425
  ${boxBorder};
1369
- ${border(1, disabled ? 'system.disabled' : 'system.rest')};
1426
+ ${border(1, disabled ? 'system/disabled' : 'system/rest')};
1370
1427
  ${parseWidth('100%')};
1371
1428
  ${parseMinHeight(40)};
1372
1429
  ${mgt([0.5])};
1373
1430
  ${!disabled && css`
1374
1431
  &:not(:focus-within):hover {
1375
- ${bgColor('fill.hover')};
1376
- ${borderColor('system.active')};
1432
+ ${bgColor('fill/hover')};
1433
+ ${borderColor('system/active')};
1377
1434
  input {
1378
- ${bgColor('fill.hover')};
1435
+ ${bgColor('fill/hover')};
1379
1436
  }
1380
1437
  }
1381
1438
  `}
1382
1439
  &:focus-within {
1383
- ${borderColor('line.focus')};
1384
- }
1385
- &.dropdown-showing {
1386
- .icon-dropdown {
1387
- transform: rotateX(180deg);
1388
- }
1440
+ ${borderColor('line/focus')};
1389
1441
  }
1390
1442
  span:empty:before {
1391
1443
  content: '${placeholder}';
1392
1444
  ${parseHeight('100%')};
1393
1445
  ${overflowHidden};
1394
- ${textColor('text.sub')};
1446
+ ${textColor('text/sub')};
1395
1447
  display: -webkit-box;
1396
1448
  -webkit-line-clamp: 1;
1397
1449
  -webkit-box-orient: vertical;
1398
1450
  }
1399
1451
  &::placeholder {
1400
- ${textColor('text.sub')};
1452
+ ${textColor('text/sub')};
1401
1453
  }
1402
1454
  &::after {
1403
1455
  ${positionAbsolute};
1404
1456
  ${pointerEventsNone};
1405
- ${borderRadius4px};
1457
+ ${borderRadius(4)};
1406
1458
  ${border(2, 'transparent')};
1407
1459
  ${inset(-2)};
1408
1460
  content: '';
@@ -1412,23 +1464,23 @@ const DropdownListCSS = loading => css`
1412
1464
  ${displayBlock};
1413
1465
  ${positionRelative};
1414
1466
  ${boxBorder};
1415
- ${borderRadius4px};
1467
+ ${borderRadius(4)};
1416
1468
  ${parseWidth('100%')};
1417
1469
  ${parseMaxHeight(280)};
1418
1470
  ${loading ? overflowHidden : overflowAuto};
1419
- ${bgColor('system.white')};
1471
+ ${bgColor('system/white')};
1420
1472
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
1421
1473
  ${z(1)};
1422
1474
  &::-webkit-scrollbar {
1423
- ${borderRadius4px};
1475
+ ${borderRadius(4)};
1424
1476
  ${parseWidth(24)};
1425
- background-color: ${systemWhite} !important;
1477
+ ${bgColor('system/white')};
1426
1478
  }
1427
1479
  &::-webkit-scrollbar-thumb {
1428
1480
  ${borderRadius(24)};
1429
1481
  ${border(8, 'transparent')};
1482
+ ${bgColor('fill/scrollbar-tabbar')};
1430
1483
  mix-blend-mode: normal;
1431
- background-color: ${fillScrollbar} !important;
1432
1484
  background-clip: content-box;
1433
1485
  }
1434
1486
  .DGN-UI-TreeView {
@@ -1446,9 +1498,9 @@ const DropdownItemCSS = (multiple, selectBox) => css`
1446
1498
  ${userSelectNone};
1447
1499
  ${parseMinHeight(40)};
1448
1500
  ${parseWidth('100%')};
1449
- ${bgColor('system.white')};
1501
+ ${bgColor('system/white')};
1450
1502
  ${pd([2, multiple && selectBox ? 0 : 4])};
1451
- ${textColor('text.main')};
1503
+ ${textColor('text/main')};
1452
1504
  &.no-data {
1453
1505
  ${justifyCenter};
1454
1506
  ${cursorDefault};
@@ -1457,8 +1509,8 @@ const DropdownItemCSS = (multiple, selectBox) => css`
1457
1509
  &:not(.no-data):hover,
1458
1510
  &:not(.no-data):focus {
1459
1511
  ${outlineNone};
1460
- ${bgColor('fill.hover')};
1461
- ${textColor('system.active')};
1512
+ ${bgColor('fill/hover')};
1513
+ ${textColor('system/active')};
1462
1514
  }
1463
1515
  `;
1464
1516
  const DropdownRootCSS = (DropdownFormCSSName, DropdownInputCSSName) => css`
@@ -1468,21 +1520,21 @@ const DropdownRootCSS = (DropdownFormCSSName, DropdownInputCSSName) => css`
1468
1520
  ${parseHeight('max-content')};
1469
1521
  &.error {
1470
1522
  .css-${DropdownFormCSSName} {
1471
- ${borderColor('semantic.danger')};
1523
+ ${borderColor('semantic/danger')};
1472
1524
  path {
1473
- ${fill('semantic.danger')};
1525
+ ${fill('semantic/danger')};
1474
1526
  }
1475
1527
  &::before {
1476
- ${borderColor('semantic.danger')};
1528
+ ${borderColor('semantic/danger')};
1477
1529
  }
1478
1530
  }
1479
1531
  }
1480
1532
  &.dgn-dropdown-loading,
1481
1533
  &.disabled {
1482
1534
  .css-${DropdownFormCSSName} {
1483
- ${borderColor('system.disabled')};
1535
+ ${borderColor('system/disabled')};
1484
1536
  &::before {
1485
- ${borderColor('system.disabled')};
1537
+ ${borderColor('system/disabled')};
1486
1538
  }
1487
1539
  }
1488
1540
  }
@@ -1494,32 +1546,36 @@ const DropdownRootCSS = (DropdownFormCSSName, DropdownInputCSSName) => css`
1494
1546
  }
1495
1547
  }
1496
1548
  `;
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
- `;
1549
+
1550
+ // const DropdownCSS = (topVl, leftVl, width, isMobile, allowSearch) => css`
1551
+ // ${positionFixed};
1552
+ // ${parseWidth(width)};
1553
+ // ${top(topVl)};
1554
+ // ${left(leftVl)};
1555
+ // ${bgColor('system/white')};
1556
+ // ${z(1)};
1557
+ // ${isMobile &&
1558
+ // allowSearch &&
1559
+ // css`
1560
+ // ${parseHeight('max-content')};
1561
+ // ${displayFlex};
1562
+ // ${flexColReverse};
1563
+ // ${bottom(0)};
1564
+ // ${top('auto')};
1565
+ // `}
1566
+ // `;
1567
+
1512
1568
  const LoadingProgressCSS = css`
1513
1569
  ${displayFlex};
1514
1570
  ${flexRow};
1515
1571
  ${justifyCenter};
1516
1572
  ${itemsCenter};
1517
1573
  ${positionAbsolute};
1518
- ${borderRadius4px};
1574
+ ${borderRadius(4)};
1519
1575
  ${parseWidthHeight('100%')}
1520
1576
  ${bgColor('rgba(255, 255, 255, 0.6)')};
1521
1577
  ${z(2)};
1522
- top: 0;
1578
+ ${top(0)};
1523
1579
  `;
1524
1580
  const DisabledCSS = css`
1525
1581
  pointer-events: none !important;
@@ -1574,9 +1630,9 @@ Dropdown.propTypes = {
1574
1630
  defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1575
1631
  /** If `true`, the component is disabled. */
1576
1632
  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
1633
+ /** Field name used for text display in dropdown list.<br/>
1634
+ * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1635
+ * Note: don't use 'id - name', return undefined
1580
1636
  */
1581
1637
  displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1582
1638
  /** Style inline of dropdown items. */
@@ -1585,14 +1641,14 @@ Dropdown.propTypes = {
1585
1641
  error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
1586
1642
  /** Props applied to the [HelperText](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) element. */
1587
1643
  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;}
1644
+ /** Field name used for icon display.<br/>
1645
+ * Example:<br/>
1646
+ * &nbsp;&nbsp;string: 'icon'<br/>
1647
+ * &nbsp;&nbsp;object: {<br/>
1648
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1649
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1650
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1651
+ * &nbsp;&nbsp;}
1596
1652
  */
1597
1653
  iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
1598
1654
  key: PropTypes.string,
@@ -1626,8 +1682,8 @@ Dropdown.propTypes = {
1626
1682
  onChange: PropTypes.func,
1627
1683
  /** Callback fired when dropdown closed. */
1628
1684
  onClosed: PropTypes.func,
1629
- /** Callback fired when the input value changes.<br/>
1630
- * if undefined: the filter function will run (default)
1685
+ /** Callback fired when the input value changes.<br/>
1686
+ * if undefined: the filter function will run (default)
1631
1687
  */
1632
1688
  onInput: PropTypes.func,
1633
1689
  /** Callback fired when key down input */
@@ -1638,21 +1694,21 @@ Dropdown.propTypes = {
1638
1694
  placeholder: PropTypes.string,
1639
1695
  /** If `true`, the component is read-only. */
1640
1696
  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'}
1697
+ /** Function displays items by custom.<br/>
1698
+ * renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
1699
+ * --> such as: displayExpr={'name - role'}
1644
1700
  */
1645
1701
  renderItem: PropTypes.func,
1646
- /** Function or field name used for display selected items, example:<br/>
1647
- * renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
1702
+ /** Function or field name used for display selected items, example:<br/>
1703
+ * renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
1648
1704
  */
1649
1705
  renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
1650
1706
  /** If `true`, the label will indicate that the input is required. */
1651
1707
  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.
1708
+ /**
1709
+ * Duration wait enter search content on search.<br/>
1710
+ * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1711
+ * If `true`, used default delayOnInput.
1656
1712
  */
1657
1713
  searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
1658
1714
  /** Specifies a data object's field name or an expression whose value is compared to the search string. */
@@ -1678,21 +1734,21 @@ Dropdown.propTypes = {
1678
1734
  /** An object default for value (use for load more). */
1679
1735
  valueObjectDefault: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
1680
1736
  /**The variant to use. */
1681
- 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
1737
+ viewType: PropTypes.oneOf(['underlined', 'outlined', 'none'])
1738
+ /**
1739
+ * ref methods
1740
+ *
1741
+ * how to get component element? ref.current
1742
+ *
1743
+ * how to call method? ref.current.instance.{method}
1744
+ *
1745
+ * * showDropdown(): Show dropdown
1746
+ * * closeDropdown(): Close dropdown
1747
+ * * onClear(): Clear selected value
1748
+ * * setPreviousValue(): Set value to previous value
1749
+ * * setValue(value): Set value of dropdown
1750
+ * * @param {value} - string || number || array
1695
1751
  */
1696
- reference: ref
1697
1752
  };
1753
+
1698
1754
  export default Dropdown;