diginet-core-ui 1.4.11-beta.2 → 1.4.11-beta.3

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.
@@ -304,11 +304,22 @@ const isActive = (day, active, className, currentZoomLevel) => {
304
304
  }
305
305
  break;
306
306
  case 2:
307
- if (+moment(day).diff(active, 'years') === 0) {
308
- return className;
307
+ {
308
+ const quarter = Math.floor(active.getMonth() / 3);
309
+ const startFullQuarter = new Date(active.getFullYear(), quarter * 3, 1);
310
+ if (renderNavigatorContent(day)[0] === renderNavigatorContent(startFullQuarter)[0]) {
311
+ return className;
312
+ }
313
+ break;
309
314
  }
310
- break;
311
315
  case 3:
316
+ {
317
+ if (+moment(day).diff(active, 'years') === 0) {
318
+ return className;
319
+ }
320
+ break;
321
+ }
322
+ case 4:
312
323
  if (renderNavigatorContent(day)[1] === Math.floor(renderNavigatorContent(active)[1] / 10) * 10) {
313
324
  return className;
314
325
  }
@@ -371,16 +382,26 @@ const isAfterLimit = (max, time) => {
371
382
  */
372
383
  const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTableDataClick, min, max, currentZoomLevel) => {
373
384
  time = new Date(time);
374
- const firstDay = new Date(new Date(time).setDate(1)),
375
- lastDay = new Date(firstDay.getFullYear(), firstDay.getMonth() + 1, 0),
376
- prevDay = new Date(firstDay.getFullYear(), firstDay.getMonth(), 0),
377
- today = new Date().setHours(0, 0, 0, 0),
378
- lastDate = lastDay.getDate(),
379
- prevDate = prevDay.getDate(),
380
- firstYear = Math.floor(time.getFullYear() / 10) * 10,
381
- firstDecade = Math.floor(time.getFullYear() / 100) * 100,
382
- rowCount = currentZoomLevel !== 0 ? 3 : 6,
383
- colCount = currentZoomLevel !== 0 ? 4 : 7;
385
+ const firstDay = new Date(new Date(time).setDate(1));
386
+ const lastDay = new Date(firstDay.getFullYear(), firstDay.getMonth() + 1, 0);
387
+ const prevDay = new Date(firstDay.getFullYear(), firstDay.getMonth(), 0);
388
+ const today = new Date().setHours(0, 0, 0, 0);
389
+ const lastDate = lastDay.getDate();
390
+ const prevDate = prevDay.getDate();
391
+ const firstYear = Math.floor(time.getFullYear() / 10) * 10;
392
+ const firstDecade = Math.floor(time.getFullYear() / 100) * 100;
393
+ const rowCountMap = new Map([[0, 6],
394
+ // day
395
+ [2, 1] // quarter
396
+ ]);
397
+
398
+ const colCountMap = new Map([[0, 7],
399
+ // day
400
+ [2, 4] // quarter
401
+ ]);
402
+
403
+ const rowCount = rowCountMap.get(currentZoomLevel) || 3;
404
+ const colCount = colCountMap.get(currentZoomLevel) || 4;
384
405
  let active = Array.isArray(activeValue) ? new Date(activeValue[0]) : new Date(activeValue);
385
406
  let tableBody = [],
386
407
  tableRaw = [],
@@ -388,7 +409,12 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
388
409
  weekDateFirst = getDateOfWeek(firstDay),
389
410
  weekDateLast = getDateOfWeek(lastDay);
390
411
  const tableDataPush = (key, dataTime, text, customClass) => {
391
- const currentTime = new Date(new Date().getFullYear(), currentZoomLevel === 1 ? new Date().getMonth() : dataTime.getMonth(), 1);
412
+ const currentMonthIndexMap = new Map([[1, new Date().getMonth()],
413
+ //month
414
+ [2, 3 * (Math.floor((new Date().getMonth() + 3) / 3) - 1)] //quarter
415
+ ]);
416
+
417
+ const currentTime = new Date(new Date().getFullYear(), currentMonthIndexMap.get(currentZoomLevel) || dataTime.getMonth(), 1);
392
418
  tableData.push(jsx("td", {
393
419
  key: key,
394
420
  "data-time": Date.parse(dataTime),
@@ -410,6 +436,16 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
410
436
  }
411
437
  break;
412
438
  case 2:
439
+ /**
440
+ * quarter of this year
441
+ */
442
+ for (let i = 0; i < 4; i++) {
443
+ const quarter = i + 1;
444
+ const firstDateOfQuarter = new Date(time.getFullYear(), i * 3, 1);
445
+ tableDataPush(`this_quarter-${quarter}`, firstDateOfQuarter, `Q${quarter}`);
446
+ }
447
+ break;
448
+ case 3:
413
449
  {
414
450
  /**
415
451
  * year before this decade
@@ -430,7 +466,7 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
430
466
  tableDataPush(`next_decade-${firstYear + 10}`, nextDecadeFirstYear, firstYear + 10, 'next_month');
431
467
  }
432
468
  break;
433
- case 3:
469
+ case 4:
434
470
  {
435
471
  /**
436
472
  * decade before this century
@@ -590,44 +626,46 @@ const renderHeader = (className, currentZoomLevel) => {
590
626
  * @param {Number} currentZoomLevel
591
627
  * @returns navigator
592
628
  */
593
- const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn, fn, currentZoomLevel = 0) => jsx("div", {
594
- className: className.navigator.navigator
595
- }, jsx("div", {
596
- className: className.navigator.around
597
- }, !currentZoomLevel && jsx(ButtonIcon, {
598
- ...buttonIconProps(className.icon),
599
- name: 'ArrowDoubleLeft',
600
- onClick: dbLeftFn,
601
- ref: refs.doubleLeft
602
- }), jsx(ButtonIcon, {
603
- ...buttonIconProps(className.icon),
604
- name: 'ArrowLeft',
605
- onClick: leftFn,
606
- ref: refs.left
607
- })), jsx("div", {
608
- className: className.navigator.center
609
- }, jsx(Button, {
610
- css: [borderRadius(20), parseWidth('100%'), pd(0)],
611
- size: 'tiny',
612
- onClick: fn
613
- }, jsx(Typography, {
614
- color: 'primary',
615
- type: 'h3',
616
- ref: refs.content,
617
- format: ['lowercase']
618
- }))), jsx("div", {
619
- className: className.navigator.around
620
- }, jsx(ButtonIcon, {
621
- ...buttonIconProps(className.icon),
622
- name: 'ArrowRight',
623
- onClick: rightFn,
624
- ref: refs.right
625
- }), !currentZoomLevel && jsx(ButtonIcon, {
626
- ...buttonIconProps(className.icon),
627
- name: 'ArrowDoubleRight',
628
- onClick: dbRightFn,
629
- ref: refs.doubleRight
630
- })));
629
+ const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn, fn, currentZoomLevel = 0) => {
630
+ return jsx("div", {
631
+ className: className.navigator.navigator
632
+ }, jsx("div", {
633
+ className: className.navigator.around
634
+ }, !currentZoomLevel && jsx(ButtonIcon, {
635
+ ...buttonIconProps(className.icon),
636
+ name: 'ArrowDoubleLeft',
637
+ onClick: dbLeftFn,
638
+ ref: refs.doubleLeft
639
+ }), jsx(ButtonIcon, {
640
+ ...buttonIconProps(className.icon),
641
+ name: 'ArrowLeft',
642
+ onClick: leftFn,
643
+ ref: refs.left
644
+ })), jsx("div", {
645
+ className: className.navigator.center
646
+ }, jsx(Button, {
647
+ css: [borderRadius(20), parseWidth('100%'), pd(0)],
648
+ size: 'tiny',
649
+ onClick: fn
650
+ }, jsx(Typography, {
651
+ color: 'primary',
652
+ type: 'h3',
653
+ ref: refs.content,
654
+ format: ['lowercase']
655
+ }))), jsx("div", {
656
+ className: className.navigator.around
657
+ }, jsx(ButtonIcon, {
658
+ ...buttonIconProps(className.icon),
659
+ name: 'ArrowRight',
660
+ onClick: rightFn,
661
+ ref: refs.right
662
+ }), !currentZoomLevel && jsx(ButtonIcon, {
663
+ ...buttonIconProps(className.icon),
664
+ name: 'ArrowDoubleRight',
665
+ onClick: dbRightFn,
666
+ ref: refs.doubleRight
667
+ })));
668
+ };
631
669
  /**
632
670
  *
633
671
  * @param {Date} time
@@ -651,8 +689,8 @@ const onUpdateNavigator = (time, refs, min, max, currentZoomLevel = 0) => {
651
689
  const el = refs.content.current;
652
690
  const vl = renderNavigatorContent(time);
653
691
  const year = locale.get() === 'vi' ? ` ${getGlobal(['year'])} ` : '';
654
- const firstValue = new Map([[0, `${vl[0]} ${year} ${vl[1]}`], [1, vl[1]], [2, Math.floor(vl[1] / 10) * 10], [3, Math.floor(vl[1] / 100) * 100]]);
655
- const lastValue = new Map([[2, Math.floor(vl[1] / 10) * 10 + 9], [3, Math.floor(vl[1] / 100) * 100 + 99]]);
692
+ const firstValue = new Map([[0, `${vl[0]} ${year} ${vl[1]}`], [1, vl[1]], [2, vl[1]], [3, Math.floor(vl[1] / 10) * 10], [4, Math.floor(vl[1] / 100) * 100]]);
693
+ const lastValue = new Map([[3, Math.floor(vl[1] / 10) * 10 + 9], [4, Math.floor(vl[1] / 100) * 100 + 99]]);
656
694
  if (el) {
657
695
  el.innerHTML = `${firstValue.get(currentZoomLevel)} ${lastValue.get(currentZoomLevel) ? `- ${lastValue.get(currentZoomLevel)}` : ``}`;
658
696
  }
@@ -58,7 +58,7 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
58
58
  const navigatorValue = useRef(null);
59
59
  const [, setActiveValue] = useState(Date.now());
60
60
  const [, setNavigatorValue] = useState(Date.now());
61
- const zoomLevel = new Map([['day', 0], ['month', 1], ['year', 2], ['decade', 3]]);
61
+ const zoomLevel = new Map([['day', 0], ['month', 1], ['quarter', 2], ['year', 3], ['decade', 4]]);
62
62
  const maxZoomLevel = (_zoomLevel$get = zoomLevel.get(`${maxZoom}`)) !== null && _zoomLevel$get !== void 0 ? _zoomLevel$get : 3;
63
63
  const minZoomLevel = (_zoomLevel$get2 = zoomLevel.get(`${minZoom}`)) !== null && _zoomLevel$get2 !== void 0 ? _zoomLevel$get2 : 0;
64
64
  const [currentZoomLevel, setCurrentZoomLevel] = useState(minZoomLevel);
@@ -107,7 +107,8 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
107
107
  };
108
108
  const zoomOut = () => {
109
109
  if (isZoomOutAble) {
110
- const zoomOutLevel = currentZoomLevel + 1;
110
+ let zoomOutLevel = currentZoomLevel + 1;
111
+ if (zoomOutLevel === 2 && minZoom !== 'quarter') zoomOutLevel++; // skip quarter
111
112
  setCurrentZoomLevel(zoomOutLevel);
112
113
  return;
113
114
  }
@@ -118,7 +119,8 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
118
119
  const timeStamp = Number(node.dataset.time);
119
120
  const objNewDate = new Date(timeStamp);
120
121
  activeValue.current = objNewDate;
121
- const zoomInLevel = currentZoomLevel - 1;
122
+ let zoomInLevel = currentZoomLevel - 1;
123
+ if (zoomInLevel === 2 && minZoom !== 'quarter') zoomInLevel--; // skip quarter
122
124
  setCurrentZoomLevel(zoomInLevel);
123
125
  }
124
126
  return;
@@ -161,13 +163,13 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
161
163
  const setPrevMonth = e => {
162
164
  let time = null;
163
165
  switch (currentZoomLevel) {
164
- case 1:
166
+ case (1, 2):
165
167
  time = new Date(getCurrentTime()[2] - 1, getCurrentTime()[1]); // set year = current year - 1
166
168
  break;
167
- case 2:
169
+ case 3:
168
170
  time = new Date(getCurrentTime()[2] - 10, getCurrentTime()[1]); // set year = current year - 10
169
171
  break;
170
- case 3:
172
+ case 4:
171
173
  time = new Date(getCurrentTime()[2] - 100, getCurrentTime()[1]); // set year = current year - 100
172
174
  break;
173
175
  default:
@@ -183,13 +185,13 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
183
185
  const setNextMonth = e => {
184
186
  let time = null;
185
187
  switch (currentZoomLevel) {
186
- case 1:
188
+ case (1, 2):
187
189
  time = new Date(getCurrentTime()[2] + 1, getCurrentTime()[1]); // set year = current year + 1
188
190
  break;
189
- case 2:
191
+ case 3:
190
192
  time = new Date(getCurrentTime()[2] + 10, getCurrentTime()[1]); // set year = current year + 10
191
193
  break;
192
- case 3:
194
+ case 4:
193
195
  time = new Date(getCurrentTime()[2] + 100, getCurrentTime()[1]); // set year = current year + 100
194
196
  break;
195
197
  default:
@@ -289,7 +291,7 @@ Calendar.propTypes = {
289
291
  /** the minimum date that can be selected within the UI component. */
290
292
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.array]),
291
293
  /** Min zoom level of DatePicker */
292
- minZoom: PropTypes.oneOf(['day', 'month', 'year']),
294
+ minZoom: PropTypes.oneOf(['day', 'month', 'quarter', 'year']),
293
295
  /** Max zoom level of DatePicker */
294
296
  maxZoom: PropTypes.oneOf(['day', 'month', 'year', 'decade']),
295
297
  /** a callback function when click on a day of calendar */
@@ -21,6 +21,8 @@ const cancelText = getGlobal(['cancel']);
21
21
  const formatValue = (value, format, utc = false) => {
22
22
  return moment(value).format(format, utc);
23
23
  };
24
+ const viDisplayFormat = new Map([['year', 'YYYY'], ['quarter', 'Q-YYYY'], ['month', 'MM-YYYY']]);
25
+ const pickerReturnFormat = new Map([['year', 'YYYY'], ['quarter', 'YYYY-Q'], ['month', 'YYYY-MM']]);
24
26
  const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
25
27
  action = {},
26
28
  actionIconAt,
@@ -52,8 +54,10 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
52
54
  viewType,
53
55
  ...props
54
56
  }, reference) => {
55
- var _placeholder, _ipRef$current, _ipRef$current2;
57
+ var _ref, _pickerReturnFormat$g, _placeholder, _ipRef$current, _ipRef$current2;
56
58
  if (!reference) reference = useRef(null);
59
+ displayFormat = (_ref = locale.get() === 'vi' ? viDisplayFormat.get(minZoom) : pickerReturnFormat.get(minZoom)) !== null && _ref !== void 0 ? _ref : displayFormat;
60
+ returnFormat = (_pickerReturnFormat$g = pickerReturnFormat.get(minZoom)) !== null && _pickerReturnFormat$g !== void 0 ? _pickerReturnFormat$g : returnFormat;
57
61
  placeholder = (_placeholder = placeholder) !== null && _placeholder !== void 0 ? _placeholder : displayFormat;
58
62
  const [id] = useState(randomString(6, {
59
63
  allowSymbol: false
@@ -606,7 +610,7 @@ DatePicker.propTypes = {
606
610
  /** View type of the form control. */
607
611
  viewType: PropTypes.oneOf(['outlined', 'underlined']),
608
612
  /** Min zoom level of DatePicker */
609
- minZoom: PropTypes.oneOf(['day', 'month', 'year']),
613
+ minZoom: PropTypes.oneOf(['day', 'month', 'quarter', 'year']),
610
614
  /** Max zoom level of DatePicker */
611
615
  maxZoom: PropTypes.oneOf(['day', 'month', 'year', 'decade'])
612
616
  };
@@ -346,10 +346,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
346
346
  // }
347
347
  // };
348
348
 
349
- /**
350
- * So sánh text đầu vào cáo map với txtSearch
351
- * @param text
352
- * @return {boolean}
349
+ /**
350
+ * So sánh text đầu vào cáo map với txtSearch
351
+ * @param text
352
+ * @return {boolean}
353
353
  */
354
354
  const handleRenderBySearch = (text = '') => {
355
355
  if (typeof text !== 'string') text = text.toString();
@@ -361,10 +361,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
361
361
  } else return text.toLowerCase().includes(txtSearch.toLowerCase());
362
362
  };
363
363
 
364
- /**
365
- * 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
366
- * @param data {object} rowData of dataSource
367
- * @return {string}
364
+ /**
365
+ * 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
366
+ * @param data {object} rowData of dataSource
367
+ * @return {string}
368
368
  */
369
369
  const displayValue = data => {
370
370
  let text = '';
@@ -1809,9 +1809,9 @@ Dropdown.propTypes = {
1809
1809
  defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1810
1810
  /** If `true`, the component is disabled. */
1811
1811
  disabled: PropTypes.bool,
1812
- /** Field name used for text display in dropdown list.<br/>
1813
- * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1814
- * Note: don't use 'id - name', return undefined
1812
+ /** Field name used for text display in dropdown list.<br/>
1813
+ * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1814
+ * Note: don't use 'id - name', return undefined
1815
1815
  */
1816
1816
  displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1817
1817
  /** Style inline of dropdown items. */
@@ -1820,14 +1820,14 @@ Dropdown.propTypes = {
1820
1820
  error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
1821
1821
  /** Props applied to the [HelperText](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) element. */
1822
1822
  helperTextProps: PropTypes.object,
1823
- /** Field name used for icon display.<br/>
1824
- * Example:<br/>
1825
- * &nbsp;&nbsp;string: 'icon'<br/>
1826
- * &nbsp;&nbsp;object: {<br/>
1827
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1828
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1829
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1830
- * &nbsp;&nbsp;}
1823
+ /** Field name used for icon display.<br/>
1824
+ * Example:<br/>
1825
+ * &nbsp;&nbsp;string: 'icon'<br/>
1826
+ * &nbsp;&nbsp;object: {<br/>
1827
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1828
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1829
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1830
+ * &nbsp;&nbsp;}
1831
1831
  */
1832
1832
  iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
1833
1833
  key: PropTypes.string,
@@ -1861,8 +1861,8 @@ Dropdown.propTypes = {
1861
1861
  onChange: PropTypes.func,
1862
1862
  /** Callback fired when dropdown closed. */
1863
1863
  onClosed: PropTypes.func,
1864
- /** Callback fired when the input value changes.<br/>
1865
- * if undefined: the filter function will run (default)
1864
+ /** Callback fired when the input value changes.<br/>
1865
+ * if undefined: the filter function will run (default)
1866
1866
  */
1867
1867
  onInput: PropTypes.func,
1868
1868
  /** Callback fired when key down input */
@@ -1873,21 +1873,21 @@ Dropdown.propTypes = {
1873
1873
  placeholder: PropTypes.string,
1874
1874
  /** If `true`, the component is read-only. */
1875
1875
  readOnly: PropTypes.bool,
1876
- /** Function displays items by custom.<br/>
1877
- * renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
1878
- * --> such as: displayExpr={'name - role'}
1876
+ /** Function displays items by custom.<br/>
1877
+ * renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
1878
+ * --> such as: displayExpr={'name - role'}
1879
1879
  */
1880
1880
  renderItem: PropTypes.func,
1881
- /** Function or field name used for display selected items, example:<br/>
1882
- * renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
1881
+ /** Function or field name used for display selected items, example:<br/>
1882
+ * renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
1883
1883
  */
1884
1884
  renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
1885
1885
  /** If `true`, the label will indicate that the input is required. */
1886
1886
  required: PropTypes.bool,
1887
- /**
1888
- * Duration wait enter search content on search.<br/>
1889
- * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1890
- * If `true`, used default delayOnInput.
1887
+ /**
1888
+ * Duration wait enter search content on search.<br/>
1889
+ * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1890
+ * If `true`, used default delayOnInput.
1891
1891
  */
1892
1892
  searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
1893
1893
  /** Specifies a data object's field name or an expression whose value is compared to the search string. */
@@ -1914,19 +1914,19 @@ Dropdown.propTypes = {
1914
1914
  valueObjectDefault: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
1915
1915
  /**The variant to use. */
1916
1916
  viewType: PropTypes.oneOf(['underlined', 'outlined', 'none'])
1917
- /**
1918
- * ref methods
1919
- *
1920
- * how to get component element? ref.current
1921
- *
1922
- * how to call method? ref.current.instance.{method}
1923
- *
1924
- * * showDropdown(): Show dropdown
1925
- * * closeDropdown(): Close dropdown
1926
- * * onClear(): Clear selected value
1927
- * * setPreviousValue(): Set value to previous value
1928
- * * setValue(value): Set value of dropdown
1929
- * * @param {value} - string || number || array
1917
+ /**
1918
+ * ref methods
1919
+ *
1920
+ * how to get component element? ref.current
1921
+ *
1922
+ * how to call method? ref.current.instance.{method}
1923
+ *
1924
+ * * showDropdown(): Show dropdown
1925
+ * * closeDropdown(): Close dropdown
1926
+ * * onClear(): Clear selected value
1927
+ * * setPreviousValue(): Set value to previous value
1928
+ * * setValue(value): Set value of dropdown
1929
+ * * @param {value} - string || number || array
1930
1930
  */
1931
1931
  };
1932
1932
 
@@ -217,10 +217,10 @@ PasswordInput.propTypes = {
217
217
  status: PropTypes.oneOf(['default', 'warning', 'success', 'danger']),
218
218
  /** Style inline of component. */
219
219
  style: PropTypes.object,
220
- /** Validation value, argument can:<br/>
221
- * * string: the validation rule. Example required.<br/>
222
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
223
- * * array: the validation rule list, insist object/string
220
+ /** Validation value, argument can:<br/>
221
+ * * string: the validation rule. Example required.<br/>
222
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
223
+ * * array: the validation rule list, insist object/string
224
224
  */
225
225
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
226
226
  /** The value of the input element, required for a controlled component. */
@@ -216,10 +216,10 @@ TextInput.propTypes = {
216
216
  style: PropTypes.object,
217
217
  /** Type of the input element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types). */
218
218
  type: PropTypes.oneOf(['inform', 'edit', 'text', 'number', 'password']),
219
- /** Validation value, argument can:<br/>
220
- * * string: the validation rule. Example required.<br/>
221
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
222
- * * array: the validation rule list, insist object/string
219
+ /** Validation value, argument can:<br/>
220
+ * * string: the validation rule. Example required.<br/>
221
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
222
+ * * array: the validation rule list, insist object/string
223
223
  */
224
224
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
225
225
  /** The value of the input element, required for a controlled component. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.4.11-beta.2",
3
+ "version": "1.4.11-beta.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",
package/utils/date.js CHANGED
@@ -5,7 +5,7 @@ const localeName = language === 'en' ? 'en-US' : 'vi-VN';
5
5
  const units = ['year', 'month', 'day', 'hour', 'minute', 'second', 'millisecond'];
6
6
 
7
7
  /**
8
- *
8
+ *
9
9
  * @param {Date|String|Array} value is a date time
10
10
  * @param {String} format the input date format
11
11
  * @param {Boolean} setNow return current time if true
@@ -144,7 +144,7 @@ export const formatDate = (value, formatOutput = 'DD/MM/YYYY', utc = false) => {
144
144
  // 2 - day of week
145
145
  E: day + 1,
146
146
  // 3
147
- Q: Math.ceil((month + 1) / 3),
147
+ Q: `Q${Math.ceil((month + 1) / 3)}`,
148
148
  // 1
149
149
 
150
150
  // Hour + Minute + second
@@ -272,7 +272,7 @@ const date = (value, formatInput = 'MM/DD/YYYY') => {
272
272
  const decimalOfMonth = decimalTotal / (endDayOfMonth * 86400000);
273
273
  result = result[0] * 12 + result[1] + decimalOfMonth;
274
274
  if (unit.toLowerCase() === 'years') {
275
- result = result / 12;
275
+ result = Math.ceil(result / 12);
276
276
  }
277
277
  } else {
278
278
  const getValueOfUnit = (week = 1) => {
@@ -339,7 +339,7 @@ const date = (value, formatInput = 'MM/DD/YYYY') => {
339
339
  };
340
340
 
341
341
  /**
342
- *
342
+ *
343
343
  * @param {Date|String|Number|Array} compareDate date to calculate moment, undefined will compare with now
344
344
  * @param {String|Array} unit year|month|day|hour|minute|second|millisecond, allow undefined
345
345
  * @param {Boolean|Number} floating allow odd numbers
@@ -371,7 +371,7 @@ const date = (value, formatInput = 'MM/DD/YYYY') => {
371
371
  num = (+num).toFixed(floating ? typeof floating === 'number' ? floating : 2 : 0);
372
372
  try {
373
373
  return new Intl.RelativeTimeFormat(language, {
374
- numeric: "auto"
374
+ numeric: 'auto'
375
375
  }).format(-num, unit);
376
376
  } catch (e) {
377
377
  return e.message;