diginet-core-ui 1.4.60 → 1.4.61-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.
@@ -0,0 +1,23 @@
1
+ <svg width="39" height="39" viewBox="0 0 39 39" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_2454_31)">
3
+ <path d="M17.0998 10.7C17.0998 11 17.0998 11.2 16.9998 11.5C16.8998 11.8 16.7998 12 16.5998 12.1C16.3998 12.3 16.0998 12.5 15.7998 12.6C15.4998 12.7 15.1998 12.8 14.6998 12.8H13.7998V14.7H12.2998V8.80005H14.7998C15.1998 8.80005 15.4998 8.80005 15.6998 8.90005C15.9998 9.00005 16.1998 9.10005 16.3998 9.20005C16.5998 9.40005 16.7998 9.60005 16.8998 9.80005C16.9998 10.1 17.0998 10.3 17.0998 10.7ZM15.4998 10.7C15.4998 10.5 15.4998 10.4 15.3998 10.3C15.2998 10.2 15.1998 10.1 15.0998 10.1C14.8998 10 14.7998 10 14.5998 10C14.4998 10 14.2998 10 13.9998 10H13.6998V11.7H14.0998C14.3998 11.7 14.5998 11.7 14.6998 11.7C14.8998 11.7 14.9998 11.6 15.0998 11.5C15.1998 11.4 15.2998 11.3 15.2998 11.2C15.4998 11 15.4998 10.9 15.4998 10.7Z" fill="#2680EB"/>
4
+ <path d="M22.2998 14.7H18.0998V8.80005H19.5998V13.5H22.2998V14.7Z" fill="#2680EB"/>
5
+ <path d="M28.5998 14.7H26.9998L26.5998 13.5H24.3998L23.9998 14.7H22.4998L24.6998 8.90005H26.3998L28.5998 14.7ZM26.2998 12.4L25.5998 10.3L24.8998 12.4H26.2998Z" fill="#2680EB"/>
6
+ <path d="M34.7998 14.7H33.3998L30.8998 10.7V14.7H29.4998V8.80005H31.2998L33.3998 12.1V8.80005H34.7998V14.7Z" fill="#2680EB"/>
7
+ <path d="M30 25C29.7 25 29.5 24.9 29.3 24.7L27.3 22.7C26.9 22.3 26.9 21.7 27.3 21.3C27.7 20.9 28.3 20.9 28.7 21.3L30 22.6L33.3 19.3C33.7 18.9 34.3 18.9 34.7 19.3C35.1 19.7 35.1 20.3 34.7 20.7L30.7 24.7C30.5 24.9 30.3 25 30 25Z" fill="#1CA261"/>
8
+ <path d="M32.4 30.5L34.2 28.7C34.6 28.3 34.6 27.7 34.2 27.3C33.8 26.9 33.2 26.9 32.8 27.3L31 29.1L29.2 27.3C28.8 26.9 28.2 26.9 27.8 27.3C27.4 27.7 27.4 28.3 27.8 28.7L29.6 30.5L27.8 32.3C27.4 32.7 27.4 33.3 27.8 33.7C28 33.9 28.3 34 28.5 34C28.7 34 29 33.9 29.2 33.7L31 31.9L32.8 33.7C33 33.9 33.3 34 33.5 34C33.7 34 34 33.9 34.2 33.7C34.6 33.3 34.6 32.7 34.2 32.3L32.4 30.5Z" fill="#FF4444"/>
9
+ <path d="M26.3 24.9999H20.8C20.4 24.9999 20 24.6999 20 24.1999C20 23.6999 20.3 23.3999 20.8 23.3999H26.3C26.7 23.3999 27.1 23.6999 27.1 24.1999C27.1 24.6999 26.7 24.9999 26.3 24.9999Z" fill="#7BC0F9"/>
10
+ <path d="M26.3 33.9999H20.8C20.4 33.9999 20 33.6999 20 33.1999C20 32.6999 20.3 32.3999 20.8 32.3999H26.3C26.7 32.3999 27.1 32.6999 27.1 33.1999C27.1 33.6999 26.7 33.9999 26.3 33.9999Z" fill="#7BC0F9"/>
11
+ <path d="M7.90004 25.8C4.70004 25.8 2.10004 23.1 2.10004 19.9C2.10004 16.7 4.70004 14 7.90004 14C11.1 14 13.7 16.7 13.7 19.9C13.7 23.1 11.1 25.8 7.90004 25.8Z" fill="#2680EB"/>
12
+ <path d="M15.6 32.6L15.2 31C15 30 14.5 29.4 13.5 29C11.7 28.3 10.6 27.6 10.6 27.6L9.10004 32L8.90004 32.6L8.30004 30.8C9.80004 28.8 8.20004 28.7 7.90004 28.7C7.60004 28.7 6.10004 28.8 7.50004 30.8L6.90004 32.6L6.70004 32L5.30004 27.5C5.30004 27.5 4.20004 28.2 2.40004 28.9C1.50004 29.2 1.10004 29.7 0.800039 30.4L0.400039 32.1C0.300039 32.6 0.200039 33.1 0.100039 33.6C-0.0999609 34.5 0.200039 35.3 1.00004 35.8C2.30004 36.8 3.80004 37.6 5.30004 38.3C6.70004 38.9 8.10004 39.1 9.60004 38.6C11.6 38 13.4 37 15 35.7C15.7 35.2 15.9 34.3 15.8 33.5C15.7 33.3 15.6 33 15.6 32.6Z" fill="#2680EB"/>
13
+ <path d="M34.9999 2H31.9999C31.9999 0.9 31.0999 0 29.9999 0H16.9999C15.8999 0 14.9999 0.9 14.9999 2V4C14.9999 5.1 15.8999 6 16.9999 6H29.9999C31.0999 6 31.9999 5.1 31.9999 4H34.9999C36.0999 4 36.9999 4.9 36.9999 6V35C36.9999 36.1 36.0999 37 34.9999 37H15.1999C14.0999 37.8 12.9999 38.5 11.8999 39H11.9999H34.9999C37.1999 39 38.9999 37.2 38.9999 35V6C38.9999 3.8 37.1999 2 34.9999 2ZM16.9999 4V2H29.9999V4H16.9999Z" fill="#2680EB"/>
14
+ <path d="M10 6C10 4.9 10.9 4 12 4H17V2H12C9.8 2 8 3.8 8 6V13C8.7 13 9.4 13.1 10 13.3V6Z" fill="#2680EB"/>
15
+ <path d="M14.8998 28.4999H17.4998V32.4999H16.5998V32.6999C16.5998 32.8999 16.6998 33.1999 16.6998 33.3999C16.6998 33.5999 16.7998 33.7999 16.7998 33.8999H17.9998C18.5998 33.8999 18.9998 33.4999 18.9998 32.8999V27.8999C18.9998 27.2999 18.5998 26.8999 17.9998 26.8999H12.9998C12.6998 26.8999 12.4998 26.9999 12.2998 27.1999C12.6998 27.3999 13.1998 27.5999 13.7998 27.8999C14.1998 28.0999 14.5998 28.2999 14.8998 28.4999Z" fill="#2680EB"/>
16
+ <path d="M17.5001 19.5V23.5H13.7001C13.4001 24 13.0001 24.5 12.6001 24.9C12.7001 25 12.9001 25 13.0001 25H18.0001C18.6001 25 19.0001 24.6 19.0001 24V19C19.0001 18.4 18.6001 18 18.0001 18H14.5001C14.6001 18.5 14.7001 19 14.7001 19.5H17.5001Z" fill="#2680EB"/>
17
+ </g>
18
+ <defs>
19
+ <clipPath id="clip0_2454_31">
20
+ <rect width="39" height="39" fill="white"/>
21
+ </clipPath>
22
+ </defs>
23
+ </svg>
@@ -0,0 +1,18 @@
1
+ <svg width="39" height="39" viewBox="0 0 39 39" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_2469_36)">
3
+ <path d="M33.6 3.09998H31V5.69998C31 7.39998 29.6 8.69998 28 8.69998C26.3 8.69998 25 7.39998 25 5.69998V3.09998H14V5.69998C14 7.39998 12.7 8.69998 11 8.69998C9.4 8.69998 8 7.39998 8 5.69998V3.09998H5.4C2.4 3.09998 0 5.49998 0 8.39998V33.6C0 36.6 2.4 39 5.4 39H33.6C36.6 39 39 36.6 39 33.6V8.39998C39 5.49998 36.6 3.09998 33.6 3.09998ZM36.5 33.1C36.5 35 34.9 36.5 33 36.5H6C4.1 36.5 2.6 35 2.6 33.1V13H36.5V33.1Z" fill="#2680EB"/>
4
+ <path d="M30 5.9V1.8C30 0.8 29.2 0 28.2 0H27.8C26.8 0 26 0.8 26 1.8V5.9C26 6.9 26.8 7.7 27.8 7.7H28.2C29.2 7.7 30 6.9 30 5.9Z" fill="#7BC0F9"/>
5
+ <path d="M13 5.9V1.8C13 0.8 12.2 0 11.2 0H10.8C9.8 0 9 0.8 9 1.8V5.9C9 6.9 9.8 7.7 10.8 7.7H11.2C12.2 7.7 13 6.9 13 5.9Z" fill="#7BC0F9"/>
6
+ <path d="M13 24H7.6C7.2 24 7 23.8 7 23.5V18C7 17.7 7.2 17.4 7.6 17.4H13C13.3 17.4 13.6 17.6 13.6 18V23.5C13.6 23.8 13.3 24 13 24Z" fill="#1CA261"/>
7
+ <path d="M22.3002 24H16.8002C16.5002 24 16.2002 23.8 16.2002 23.4V18C16.2002 17.7 16.4002 17.4 16.8002 17.4H22.3002C22.6002 17.4 22.9002 17.6 22.9002 18V23.5C22.8002 23.8 22.6002 24 22.3002 24Z" fill="#FFAA00"/>
8
+ <path d="M31.4999 24H25.9999C25.6999 24 25.3999 23.8 25.3999 23.4V18C25.3999 17.7 25.5999 17.4 25.9999 17.4H31.4999C31.7999 17.4 32.0999 17.6 32.0999 18V23.5C31.9999 23.8 31.7999 24 31.4999 24Z" fill="#FF4444"/>
9
+ <path d="M13 32.8H7.6C7.3 32.8 7 32.6 7 32.2V26.7C7 26.4 7.2 26.1 7.6 26.1H13C13.3 26.1 13.6 26.3 13.6 26.7V32.2C13.6 32.5 13.3 32.8 13 32.8Z" fill="#FFAA00"/>
10
+ <path d="M22.3002 32.8H16.8002C16.5002 32.8 16.2002 32.6 16.2002 32.2V26.7C16.2002 26.4 16.4002 26.1 16.8002 26.1H22.3002C22.6002 26.1 22.9002 26.3 22.9002 26.7V32.2C22.8002 32.5 22.6002 32.8 22.3002 32.8Z" fill="#FF4444"/>
11
+ <path d="M31.4999 32.8H25.9999C25.6999 32.8 25.3999 32.6 25.3999 32.2V26.7C25.3999 26.4 25.5999 26.1 25.9999 26.1H31.4999C31.7999 26.1 32.0999 26.3 32.0999 26.7V32.2C31.9999 32.5 31.7999 32.8 31.4999 32.8Z" fill="#1CA261"/>
12
+ </g>
13
+ <defs>
14
+ <clipPath id="clip0_2469_36">
15
+ <rect width="39" height="39" fill="white"/>
16
+ </clipPath>
17
+ </defs>
18
+ </svg>
@@ -652,7 +652,7 @@ const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn,
652
652
  color: 'primary',
653
653
  type: 'h3',
654
654
  ref: refs.content,
655
- format: ['lowercase']
655
+ format: ['sentence']
656
656
  }))), jsx("div", {
657
657
  className: className.navigator.around
658
658
  }, jsx(ButtonIcon, {
@@ -226,7 +226,7 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
226
226
  * START EFFECT
227
227
  */
228
228
  useEffect(() => {
229
- if (defaultValue && defaultValue !== '' && isValidDate(defaultValue)) {
229
+ if (defaultValue && defaultValue !== '' && isValidDate(defaultValue) && !value) {
230
230
  if (isBeforeLimit(min, defaultValue)) {
231
231
  onUpdate(min);
232
232
  } else if (isAfterLimit(max, defaultValue)) {
@@ -752,6 +752,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
752
752
  }
753
753
  ipRef.current && ipRef.current.blur();
754
754
  updateTempValues([]);
755
+ setOpenState(false);
755
756
  };
756
757
  const onClickOutside = e => {
757
758
  if (ipConRef.current && !ipConRef.current.contains(e.target) && ipRef.current && !ipRef.current.contains(e.target) && pickerRef.current && !pickerRef.current.contains(e.target)) {
@@ -5,7 +5,7 @@ import { Avatar, ButtonIcon, Checkbox, Chip, CircularProgress, HelperText, Input
5
5
  import Popover from "../../popover";
6
6
  import { getGlobal } from "../../../global";
7
7
  import PropTypes from 'prop-types';
8
- import { Fragment, forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
8
+ import { Fragment, forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useCallback } from 'react';
9
9
  import ReactDOM from 'react-dom';
10
10
  import { animation, bgColor, border, borderBottom, borderBottomColor, borderColor, borderNone, borderRadius, bottom, boxBorder, breakWord, cursorDefault, cursorNotAllowed, cursorPointer, displayBlock, displayFlex, fill, flexRow, flexWrap, inset, insetX, invisible, italic, itemsCenter, justifyCenter, justifyStart, outlineNone, overflowYScroll, overflowHidden, parseHeight, parseMaxHeight, parseMaxWidth, parseMinHeight, parseWidth, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative, textColor, top, userSelectNone, z } from "../../../styles/general";
11
11
  import { useTheme } from "../../../theme";
@@ -89,6 +89,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
89
89
  multiple,
90
90
  noDataText: noDataTextProp,
91
91
  onChange,
92
+ onOpened,
92
93
  onClosed,
93
94
  onInput,
94
95
  onKeyDown,
@@ -201,14 +202,14 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
201
202
  }
202
203
  !!blur && inputRef.current.blur();
203
204
  };
204
- const onClickInput = e => {
205
+ const onClickInput = useCallback(e => {
205
206
  if (disabled || readOnly || loadingState) return;
206
207
  if (!dropdownListRef.current) {
207
208
  if (!multiple || !Array.from(inputRef.current.querySelectorAll('.DGN-UI-Chip')).some(item => item.contains(e === null || e === void 0 ? void 0 : e.target))) {
208
209
  setOpenState(true);
209
210
  }
210
211
  }
211
- };
212
+ }, [disabled, readOnly, loadingState]);
212
213
  const showDropdown = () => {
213
214
  const dropdown = children ? jsx("div", {
214
215
  css: _DropdownListCSS,
@@ -300,10 +301,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
300
301
  });
301
302
  };
302
303
 
303
- /**
304
- * So sánh text đầu vào cáo map với txtSearch
305
- * @param text
306
- * @return {boolean}
304
+ /**
305
+ * So sánh text đầu vào cáo map với txtSearch
306
+ * @param text
307
+ * @return {boolean}
307
308
  */
308
309
  const handleRenderBySearch = (text = '') => {
309
310
  if (text === null || text === undefined) text = '';
@@ -316,10 +317,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
316
317
  } else return text.toLowerCase().includes(txtSearch.toLowerCase());
317
318
  };
318
319
 
319
- /**
320
- * 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
321
- * @param data {object} rowData of dataSource
322
- * @return {string}
320
+ /**
321
+ * 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
322
+ * @param data {object} rowData of dataSource
323
+ * @return {string}
323
324
  */
324
325
  const displayValue = data => {
325
326
  let text = '';
@@ -1110,6 +1111,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1110
1111
  filter.current.strSearch = '';
1111
1112
  handleActionLoadData(true);
1112
1113
  }
1114
+ } else if (openState) {
1115
+ onOpened && onOpened();
1113
1116
  }
1114
1117
  }, [openState]);
1115
1118
  useLayoutEffect(() => {
@@ -1802,9 +1805,9 @@ Dropdown.propTypes = {
1802
1805
  defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1803
1806
  /** If `true`, the component is disabled. */
1804
1807
  disabled: PropTypes.bool,
1805
- /** The field name used for displaying text in the dropdown list.<br/>
1806
- * Examples: 'name', '{id} - {name}', '{age} age(s)'<br/>
1807
- * Note: Do not use 'id - name', as it will return undefined.
1808
+ /** The field name used for displaying text in the dropdown list.<br/>
1809
+ * Examples: 'name', '{id} - {name}', '{age} age(s)'<br/>
1810
+ * Note: Do not use 'id - name', as it will return undefined.
1808
1811
  */
1809
1812
  displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1810
1813
  /** Inline style for dropdown items. */
@@ -1813,14 +1816,14 @@ Dropdown.propTypes = {
1813
1816
  error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
1814
1817
  /** Props applied to the [HelperText](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) element. */
1815
1818
  helperTextProps: PropTypes.object,
1816
- /** The field name used for displaying icons.<br/>
1817
- * Example:<br/>
1818
- * &nbsp;&nbsp;string: 'icon'<br/>
1819
- * &nbsp;&nbsp;object: {<br/>
1820
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1821
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1822
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1823
- * &nbsp;&nbsp;}
1819
+ /** The field name used for displaying icons.<br/>
1820
+ * Example:<br/>
1821
+ * &nbsp;&nbsp;string: 'icon'<br/>
1822
+ * &nbsp;&nbsp;object: {<br/>
1823
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1824
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1825
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1826
+ * &nbsp;&nbsp;}
1824
1827
  */
1825
1828
  iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
1826
1829
  key: PropTypes.string,
@@ -1852,10 +1855,12 @@ Dropdown.propTypes = {
1852
1855
  noDataText: PropTypes.string,
1853
1856
  /** Callback function fired when the value changes. */
1854
1857
  onChange: PropTypes.func,
1858
+ /** Callback function fired when the dropdown is opened. */
1859
+ onOpened: PropTypes.func,
1855
1860
  /** Callback function fired when the dropdown is closed. */
1856
1861
  onClosed: PropTypes.func,
1857
- /** Callback function fired when the input value changes.<br/>
1858
- * If undefined, the filter function will run (default behavior).
1862
+ /** Callback function fired when the input value changes.<br/>
1863
+ * If undefined, the filter function will run (default behavior).
1859
1864
  */
1860
1865
  onInput: PropTypes.func,
1861
1866
  /** Callback function fired when a key is pressed down in the input. */
@@ -1868,21 +1873,21 @@ Dropdown.propTypes = {
1868
1873
  placeholder: PropTypes.string,
1869
1874
  /** If `true`, the component is read-only. */
1870
1875
  readOnly: PropTypes.bool,
1871
- /** Function used for custom rendering of items.<br/>
1872
- * Example: `(data, index) => data.name + ' - ' + data.role`<br/>
1873
- * This can be used as an alternative to `displayExpr`
1876
+ /** Function used for custom rendering of items.<br/>
1877
+ * Example: `(data, index) => data.name + ' - ' + data.role`<br/>
1878
+ * This can be used as an alternative to `displayExpr`
1874
1879
  */
1875
1880
  renderItem: PropTypes.func,
1876
- /** Function or field name used to display selected items.<br/>
1877
- * Example: `(data, index) => index + ' - ' + data.name`<br/>
1881
+ /** Function or field name used to display selected items.<br/>
1882
+ * Example: `(data, index) => index + ' - ' + data.name`<br/>
1878
1883
  */
1879
1884
  renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
1880
1885
  /** If `true`, the label will indicate that the input is required. */
1881
1886
  required: PropTypes.bool,
1882
- /**
1883
- * Duration to wait after entering search content before triggering a search.<br/>
1884
- * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1885
- * If `true`, the default delayOnInput will be used.
1887
+ /**
1888
+ * Duration to wait after entering search content before triggering a search.<br/>
1889
+ * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1890
+ * If `true`, the default delayOnInput will be used.
1886
1891
  */
1887
1892
  searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
1888
1893
  /** Specifies the field name or expression used to compare values with the search string. */
@@ -1915,19 +1920,19 @@ Dropdown.propTypes = {
1915
1920
  viewType: PropTypes.oneOf(['underlined', 'outlined', 'none']),
1916
1921
  /** Custom icon to override the default arrow icon. */
1917
1922
  endIcon: PropTypes.string
1918
- /**
1919
- * ref methods
1920
- *
1921
- * how to get component element? ref.current
1922
- *
1923
- * how to call method? ref.current.instance.{method}
1924
- *
1925
- * * showDropdown(): Show dropdown
1926
- * * closeDropdown(): Close dropdown
1927
- * * onClear(): Clear selected value
1928
- * * setPreviousValue(): Set value to previous value
1929
- * * setValue(value): Set value of dropdown
1930
- * * @param {value} - string || number || array
1923
+ /**
1924
+ * ref methods
1925
+ *
1926
+ * how to get component element? ref.current
1927
+ *
1928
+ * how to call method? ref.current.instance.{method}
1929
+ *
1930
+ * * showDropdown(): Show dropdown
1931
+ * * closeDropdown(): Close dropdown
1932
+ * * onClear(): Clear selected value
1933
+ * * setPreviousValue(): Set value to previous value
1934
+ * * setValue(value): Set value of dropdown
1935
+ * * @param {value} - string || number || array
1931
1936
  */
1932
1937
  };
1933
1938
  export default Dropdown;
@@ -1,13 +1,15 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
3
  import { css, jsx } from '@emotion/core';
4
- import { ButtonIcon, InputBase, Label, Popover, PopoverBody } from "../..";
4
+ import { ButtonIcon, InputBase, Label, Popover, PopoverBody, HelperText } from "../..";
5
5
  import PropTypes from 'prop-types';
6
- import { Fragment, forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
6
+ import { Fragment, forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState, useMemo } from 'react';
7
7
  import { animation, borderColor, displayBlock, overflowHidden, parseHeight, parseMinWidth, positionRelative, scaleX } from "../../../styles/general";
8
8
  import { useTheme } from "../../../theme";
9
9
  import useThemeProps from "../../../theme/utils/useThemeProps";
10
10
  import { classNames, getProp } from "../../../utils";
11
+ const regexBetween = /[^{}]+(?=})/g;
12
+ const regexInclude = /{|}/g;
11
13
  const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
12
14
  if (!reference) reference = useRef(null);
13
15
  const theme = useTheme();
@@ -22,10 +24,14 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referen
22
24
  });
23
25
  const {
24
26
  action = {},
27
+ allowInput,
25
28
  bgColor: bgColorProp,
26
29
  children,
27
30
  className,
28
31
  delayOnInput,
32
+ disabled,
33
+ displayExpr: displayExprProp,
34
+ error,
29
35
  endIcon,
30
36
  inputProps,
31
37
  inputRef,
@@ -39,10 +45,19 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referen
39
45
  placeholder,
40
46
  startIcon,
41
47
  style,
42
- value,
43
- viewType
48
+ value: valueProps,
49
+ valueExpr,
50
+ viewType,
51
+ helperTextProps
44
52
  } = props;
53
+ let displayExpr = displayExprProp;
45
54
  const bgColor = typeof bgColorProp === 'string' ? getProp(colors, bgColorProp, bgColorProp) : bgColorProp;
55
+ const ErrorView = useMemo(() => {
56
+ return error ? jsx(HelperText, {
57
+ ...helperTextProps,
58
+ disabled: disabled
59
+ }, error) : null;
60
+ }, [disabled, error, helperTextProps]);
46
61
  const ref = useRef(null);
47
62
  const dropdownBoxRef = useRef(null);
48
63
  const timer = useRef(null);
@@ -85,6 +100,28 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referen
85
100
  onClosed === null || onClosed === void 0 ? void 0 : onClosed();
86
101
  }
87
102
  };
103
+
104
+ /**
105
+ * 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
106
+ * @param data {object} rowData of dataSource
107
+ * @return {string}
108
+ */
109
+ const displayValue = data => {
110
+ let text = '';
111
+ if (data || data === 0) {
112
+ displayExpr = displayExpr || valueExpr;
113
+ let mask = data === null || data === void 0 ? void 0 : data[displayExpr];
114
+ // convert {id} - {name} to {<data[id]>} - {<data[name]>}
115
+ if (!mask && regexBetween.test(displayExpr)) {
116
+ var _displayExpr;
117
+ mask = (_displayExpr = displayExpr) === null || _displayExpr === void 0 ? void 0 : _displayExpr.replace(regexBetween, _ => (data === null || data === void 0 ? void 0 : data[_]) || '');
118
+ } else if (!mask) {
119
+ mask = typeof data !== 'object' ? data : '';
120
+ }
121
+ text = mask.toString().replace(regexInclude, '');
122
+ }
123
+ return text;
124
+ };
88
125
  useLayoutEffect(() => {
89
126
  if (ref.current) {
90
127
  const {
@@ -130,15 +167,17 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referen
130
167
  onClick: openOnClickAt === 'icon' ? onTriggerDropdown : null
131
168
  }) : null;
132
169
  };
170
+ const value = displayValue(valueProps);
133
171
  return jsx(Fragment, null, jsx("div", {
134
172
  ref: ref,
135
173
  css: _DropdownBoxRootCSS,
136
- className: classNames('DGN-UI-Dropdown-Box', className),
174
+ className: classNames('DGN-UI-Dropdown-Box', className, error && 'error'),
137
175
  style: style
138
176
  }, label ? jsx(Label, {
139
177
  ...labelProps
140
178
  }, label) : null, jsx(InputBase, {
141
179
  ...inputProps,
180
+ readOnly: !allowInput,
142
181
  style: inputStyle,
143
182
  viewType: viewType,
144
183
  inputRef: inputRef,
@@ -157,7 +196,7 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referen
157
196
  anchor: ref.current,
158
197
  width: popoverWidth,
159
198
  onClose: closeDropdownBox
160
- }, jsx(PopoverBody, null, children)));
199
+ }, jsx(PopoverBody, null, children)), ErrorView);
161
200
  }));
162
201
  const DropdownBoxRootCSS = (bgColorProp, {
163
202
  colors
@@ -166,6 +205,17 @@ const DropdownBoxRootCSS = (bgColorProp, {
166
205
  ${positionRelative};
167
206
  ${parseMinWidth(150)};
168
207
  ${parseHeight('max-content')};
208
+ &.error {
209
+ .DGN-UI-InputBase {
210
+ ${borderColor(getProp(colors, 'semantic/danger'))};
211
+ &::before {
212
+ ${borderColor(getProp(colors, 'semantic/danger'))};
213
+ }
214
+ &::after {
215
+ ${borderColor(getProp(colors, 'semantic/danger'))};
216
+ }
217
+ }
218
+ }
169
219
  .DGN-UI-InputBase {
170
220
  background: ${bgColorProp ? bgColorProp === true ? getProp(colors, 'fill/disabled') : bgColorProp : 'inherit'} !important;
171
221
  ${openState && css`
@@ -183,20 +233,6 @@ const DropdownBoxCSS = ({
183
233
  margin-top: ${spacing([1])};
184
234
  ${overflowHidden};
185
235
  `;
186
-
187
- // DropdownBox.defaultProps = {
188
- // className: '',
189
- // label: '',
190
- // placeholder: '',
191
- // startIcon: 'Search',
192
- // endIcon: 'ArrowDown',
193
- // openOnClickAt: 'icon',
194
- // viewType: 'underlined',
195
- // inputProps: {},
196
- // delayOnInput: 700,
197
- // zIndex: zIndexCORE(1),
198
- // };
199
-
200
236
  DropdownBox.propTypes = {
201
237
  /** class for dropdown */
202
238
  className: PropTypes.string,
@@ -233,6 +269,12 @@ DropdownBox.propTypes = {
233
269
  /** the function will run after open */
234
270
  onOpened: PropTypes.func,
235
271
  /** the function will run after close */
236
- onClosed: PropTypes.func
272
+ onClosed: PropTypes.func,
273
+ /** Error message displayed below the input. */
274
+ error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
275
+ /** If `true`, the component is disabled. */
276
+ disabled: PropTypes.bool,
277
+ /** If `true`, the input is enable. */
278
+ allowInput: PropTypes.bool
237
279
  };
238
280
  export default DropdownBox;
@@ -49,7 +49,7 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
49
49
  labelProps,
50
50
  max: maxProp,
51
51
  maxDigit,
52
- min,
52
+ min: minProp,
53
53
  nonStyle,
54
54
  onBlur,
55
55
  onChange,
@@ -69,9 +69,12 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
69
69
  viewType
70
70
  } = props;
71
71
  let max = maxProp;
72
+ let min = minProp;
72
73
  let thousandSymbol = thousandSeparator;
73
74
  let decimalSymbol = decimalSymbolProp;
74
75
  let valueProps = valueProp;
76
+ if (!min && min !== 0) min = -Infinity;
77
+ if (!max && max !== 0) max = Infinity;
75
78
  const pos = useRef(null);
76
79
  const ref = useRef(null);
77
80
  const globalRef = useRef({});
package/package.json CHANGED
@@ -1,44 +1,78 @@
1
- {
2
- "name": "diginet-core-ui",
3
- "version": "1.4.60",
4
- "description": "The DigiNet core ui",
5
- "homepage": "https://diginet.com.vn",
6
- "main": "index.js",
7
- "scripts": {
8
- "start-js": "react-scripts start --max_old_space_size=4096",
9
- "start": "npx npm-run-all -p start-js",
10
- "build": "GENERATE_SOURCEMAP=false && react-scripts build --env=production --max_old_space_size=8192",
11
- "eject": "react-scripts eject",
12
- "test": "echo \"Error: no test specified\" && exit 1"
13
- },
14
- "dependencies": {
15
- "@emotion/core": "^10.0.35",
16
- "prop-types": "^15.7.2",
17
- "@emotion/css": "^11.11.0",
18
- "@emotion/react": "^11.10.6"
19
- },
20
- "repository": {
21
- "type": "git",
22
- "url": "git+https://diginetvn@bitbucket.org/diginetvn/diginet-core-ui.git"
23
- },
24
- "keywords": [
25
- "core ui",
26
- "diginet"
27
- ],
28
- "author": "rocachien",
29
- "contributors": [
30
- {
31
- "name": "Chien Do",
32
- "email": "rocachien@gmail.com"
33
- },
34
- {
35
- "name": "Nhat Tran",
36
- "email": "tranminhnhat1005@gmail.com"
37
- },
38
- {
39
- "name": "Thuan Nguyen",
40
- "email": "nt.thuan.hutech@gmail.com"
41
- }
42
- ],
43
- "license": "MIT"
44
- }
1
+ {
2
+ "name": "diginet-core-ui",
3
+ "version": "1.4.61-beta.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "license": "UNLICENSED",
7
+ "scripts": {
8
+ "start": "npm-run-all --parallel start-sb eslint-test",
9
+ "start-sb": "start-storybook -p 9050",
10
+ "build-storybook": "build-storybook -c .storybook -s src",
11
+ "build": "run-script-os",
12
+ "build:windows": "rimraf dist && mkdirp dist/components && npm run compile && sass --style=compressed src/scss:dist/css && xcopy src\\\\assets dist\\\\assets\\ /e /y",
13
+ "build:darwin:linux:default": "rm -rf dist && npm run compile && sass --style=compressed src/scss:dist/css && cp -rf src/assets dist/assets",
14
+ "compile": "babel src --out-dir dist --ignore **/*.stories.js",
15
+ "pack": "npm run build && cp *.md dist/ && npm run version:bump --silent && npm run version:add --silent && cd dist && npm pack",
16
+ "production-keep-version": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish",
17
+ "beta": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish --tag beta",
18
+ "production": "npm run build && cp *.md dist/ && npm run version:bump --silent && npm run version:add --silent && cd dist && npm publish",
19
+ "version:add": "run-script-os",
20
+ "version:add:windows": "cat package.json.tmp | sed \"s/0.0.0/%npm_package_version%/g\" > dist/package.json",
21
+ "version:add:darwin:linux:default": "VERSION=$(npm run version:extract --silent) && cat package.json.tmp | sed \"s/0.0.0/${VERSION}/g\" > dist/package.json",
22
+ "version:bump": "npm version patch --no-git-tag-version --silent",
23
+ "version:extract": "cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'",
24
+ "test": "echo \"Error: no test specified\" && exit 1",
25
+ "lint": "eslint --fix --config .eslintrc.js \"**/*.js\"",
26
+ "eslint-test": "onchange \"src/**/*.{js,jsx,json}\" -- eslint . --fix",
27
+ "freshtall": "npm cache clean --force && rm -rf node_modules && rm -f package-lock.json && npm install",
28
+ "test-storybook": "test-storybook --url http://localhost:9050",
29
+ "preinstall": "echo {} > package-lock.json"
30
+ },
31
+ "dependencies": {
32
+ "@emotion/core": "^10.0.35",
33
+ "@emotion/css": "^11.11.0",
34
+ "@emotion/react": "^11.10.6",
35
+ "babel-plugin-module-resolver": "^4.1.0",
36
+ "date-fns": "^2.30.0",
37
+ "prop-types": "^15.7.2"
38
+ },
39
+ "lint-staged": {
40
+ "*/**/*.{js,jsx,json}": [
41
+ "prettier --write",
42
+ "git add"
43
+ ]
44
+ },
45
+ "devDependencies": {
46
+ "@babel/cli": "^7.14.3",
47
+ "@babel/plugin-proposal-class-properties": "^7.13.0",
48
+ "@babel/plugin-proposal-logical-assignment-operators": "^7.16.0",
49
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
50
+ "@babel/plugin-proposal-optional-chaining": "^7.14.2",
51
+ "@babel/plugin-proposal-private-methods": "^7.18.6",
52
+ "@babel/plugin-proposal-private-property-in-object": "^7.18.6",
53
+ "@babel/preset-react": "^7.13.13",
54
+ "@storybook/addon-actions": "6.2.9",
55
+ "@storybook/addon-essentials": "6.2.9",
56
+ "@storybook/addon-links": "6.2.9",
57
+ "@storybook/addon-postcss": "^2.0.0",
58
+ "@storybook/react": "6.2.9",
59
+ "@storybook/test-runner": "^0.7.1",
60
+ "autoprefixer": "^10.3.1",
61
+ "babel-loader": "^8.2.2",
62
+ "eslint": "^8.4.1",
63
+ "eslint-plugin-react": "^7.27.1",
64
+ "eslint-plugin-regex": "^1.10.0",
65
+ "husky": "^7.0.4",
66
+ "jest": "^27.5.1",
67
+ "lint-staged": "^12.1.2",
68
+ "mkdirp": "^1.0.4",
69
+ "npm-run-all": "^4.1.5",
70
+ "onchange": "^7.1.0",
71
+ "postcss-flexbugs-fixes": "^5.0.2",
72
+ "react": "^17.0.1",
73
+ "react-dom": "^17.0.1",
74
+ "rimraf": "^3.0.2",
75
+ "run-script-os": "^1.1.6",
76
+ "sass": "1.58.3"
77
+ }
78
+ }
package/readme.md CHANGED
@@ -42,7 +42,12 @@ npm test
42
42
 
43
43
  ## Changelog
44
44
 
45
- ## 1.4.59
45
+ ## 1.4.61
46
+ - \[Added\]: Icon – Add IconMenu MHRM38N1051
47
+ - \[Fixed\]: Dropdown – Dropdown multiple core has a disable bug
48
+ - \[Fixed\]: Dropdown – Add a prop to support callback when clicking on the Dropdown.
49
+
50
+ ## 1.4.60
46
51
  - \[Added\]: Icon – Add IconMenu MHRP09N0039, MHRP09N0040
47
52
  - \[Fixed\]: NumberInput – Negative values can still be pasted when disabledNegative is enabled
48
53
  - \[Fixed\]: Dropdown, NumberInput, TextInput, .... – Updated the default delayOnSearch value to 1200 ms