diginet-core-ui 1.4.17-beta.2 → 1.4.17-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.
@@ -8,16 +8,16 @@ import { render } from 'react-dom';
8
8
  import { bgColor, border, borderRadius, boxBorder, cursorDefault, cursorPointer, displayFlex, flexCol, flexRow, insetX, insetY, itemsCenter, justifyBetween, parseHeight, parseMaxWidth, parseMinHeight, parseMinWidth, parseWidth, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative, shadowLarge, shadowNone, textCenter, textColor, userSelectNone } from "../../../styles/general";
9
9
  import { classNames, getProp, date as moment } from "../../../utils";
10
10
 
11
- /**
12
- * START STYLE
11
+ /**
12
+ * START STYLE
13
13
  */
14
14
 
15
- /**
16
- *
17
- * @param {Object} unique
18
- * @param {Boolean} boxShadow
19
- * @param onClickActive
20
- * @returns
15
+ /**
16
+ *
17
+ * @param {Object} unique
18
+ * @param {Boolean} boxShadow
19
+ * @param onClickActive
20
+ * @returns
21
21
  */
22
22
  const generateCalendarCSS = (unique, boxShadow = true, onClickActive = true, {
23
23
  colors,
@@ -216,15 +216,15 @@ const generateCalendarCSS = (unique, boxShadow = true, onClickActive = true, {
216
216
  }
217
217
  }
218
218
  `;
219
- /**
220
- * END STYLE
219
+ /**
220
+ * END STYLE
221
221
  */
222
222
 
223
- /**
224
- *
225
- * @description return props of the typography.
226
- * @param {String} className
227
- * @returns {Object} props of the typography
223
+ /**
224
+ *
225
+ * @description return props of the typography.
226
+ * @param {String} className
227
+ * @returns {Object} props of the typography
228
228
  */
229
229
  const typographyProps = (className, isNotDay) => {
230
230
  return {
@@ -243,11 +243,11 @@ const typographyProps = (className, isNotDay) => {
243
243
  type: isNotDay ? 'p2' : 'h6'
244
244
  };
245
245
  };
246
- /**
247
- *
248
- * @description return props of the button icon.
249
- * @param {String} className
250
- * @returns {Object} props of the button icon
246
+ /**
247
+ *
248
+ * @description return props of the button icon.
249
+ * @param {String} className
250
+ * @returns {Object} props of the button icon
251
251
  */
252
252
  const buttonIconProps = className => {
253
253
  return {
@@ -257,43 +257,43 @@ const buttonIconProps = className => {
257
257
  };
258
258
  };
259
259
 
260
- /**
261
- * @description detect value is a Date object
262
- * @param {String | Number | Array} value
263
- * @returns boolean
260
+ /**
261
+ * @description detect value is a Date object
262
+ * @param {String | Number | Array} value
263
+ * @returns boolean
264
264
  */
265
265
  const isValidDate = value => {
266
266
  return new Date(value) instanceof Date && !isNaN(new Date(value));
267
267
  };
268
- /**
269
- *
270
- * @description set Sunday (0) to the last day of week.
271
- * @param {Date} date
272
- * @returns number of day from 0 (Monday) to 6 (Sunday).
268
+ /**
269
+ *
270
+ * @description set Sunday (0) to the last day of week.
271
+ * @param {Date} date
272
+ * @returns number of day from 0 (Monday) to 6 (Sunday).
273
273
  */
274
274
  const getDateOfWeek = date => {
275
275
  let day = date.getDay();
276
276
  if (day === 0) day = 7;
277
277
  return day - 1;
278
278
  };
279
- /**
280
- *
281
- * @description check day is today.
282
- * @param {Date} day
283
- * @param {Date} today
284
- * @param {String} className
285
- * @returns {Boolean} is today
279
+ /**
280
+ *
281
+ * @description check day is today.
282
+ * @param {Date} day
283
+ * @param {Date} today
284
+ * @param {String} className
285
+ * @returns {Boolean} is today
286
286
  */
287
287
  const isToday = (day, today, className) => {
288
288
  return +moment(day).diff(today) === 0 ? className : '';
289
289
  };
290
- /**
291
- *
292
- * @description check day is active day.
293
- * @param {Date} day
294
- * @param {Date} active
295
- * @param {String} className
296
- * @returns {Boolean} is active day
290
+ /**
291
+ *
292
+ * @description check day is active day.
293
+ * @param {Date} day
294
+ * @param {Date} active
295
+ * @param {String} className
296
+ * @returns {Boolean} is active day
297
297
  */
298
298
  const isActive = (day, active, className, currentZoomLevel) => {
299
299
  switch (currentZoomLevel) {
@@ -336,14 +336,14 @@ const isActive = (day, active, className, currentZoomLevel) => {
336
336
  }
337
337
  return '';
338
338
  };
339
- /**
340
- *
341
- * @description check day is min/max day.
342
- * @param {Date} day
343
- * @param {Date} max
344
- * @param {Date} min
345
- * @param {Object} className
346
- * @returns {Boolean} is limited day
339
+ /**
340
+ *
341
+ * @description check day is min/max day.
342
+ * @param {Date} day
343
+ * @param {Date} max
344
+ * @param {Date} min
345
+ * @param {Object} className
346
+ * @returns {Boolean} is limited day
347
347
  */
348
348
  const isLimit = (day, max, min, className) => {
349
349
  return isBeforeLimit(min, day) || isAfterLimit(max, day) ? className : '';
@@ -366,18 +366,18 @@ const isBeforeLimit = (min, time) => {
366
366
  const isAfterLimit = (max, time) => {
367
367
  return max && isValidDate(max) && moment(new Date(time).setHours(0, 0, 0, 0)).diff(new Date(max).setHours(0, 0, 0, 0)) > 0;
368
368
  };
369
- /**
370
- *
371
- * @description return the table body of the calendar.
372
- * @param {Date} time
373
- * @param {Date} activeValue
374
- * @param {Object} className
375
- * @param {Boolean} displayAnotherMonth
376
- * @param {Function} onTableDataClick
377
- * @param {Date} min
378
- * @param {Date} max
379
- * @param {Number} currentZoomLevel
380
- * @returns {Element}
369
+ /**
370
+ *
371
+ * @description return the table body of the calendar.
372
+ * @param {Date} time
373
+ * @param {Date} activeValue
374
+ * @param {Object} className
375
+ * @param {Boolean} displayAnotherMonth
376
+ * @param {Function} onTableDataClick
377
+ * @param {Date} min
378
+ * @param {Date} max
379
+ * @param {Number} currentZoomLevel
380
+ * @returns {Element}
381
381
  */
382
382
  const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTableDataClick, min, max, currentZoomLevel) => {
383
383
  time = new Date(time);
@@ -425,8 +425,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
425
425
  };
426
426
  switch (currentZoomLevel) {
427
427
  case 1:
428
- /**
429
- * months of this year
428
+ /**
429
+ * months of this year
430
430
  */
431
431
  for (let i = 0; i < 12; i++) {
432
432
  const monthsList = getGlobal(['months']).full;
@@ -435,8 +435,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
435
435
  }
436
436
  break;
437
437
  case 2:
438
- /**
439
- * quarter of this year
438
+ /**
439
+ * quarter of this year
440
440
  */
441
441
  for (let i = 0; i < 4; i++) {
442
442
  const quarter = i + 1;
@@ -446,50 +446,50 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
446
446
  break;
447
447
  case 3:
448
448
  {
449
- /**
450
- * year before this decade
449
+ /**
450
+ * year before this decade
451
451
  */
452
452
  const previousDecadeLastYear = new Date(firstYear - 1, 0, 1);
453
453
  const nextDecadeFirstYear = new Date(firstYear + 10, 0, 1);
454
454
  tableDataPush(`previous_decade-${firstYear - 1}`, previousDecadeLastYear, firstYear - 1, 'previous_month');
455
- /**
456
- * years of this decade
455
+ /**
456
+ * years of this decade
457
457
  */
458
458
  for (let i = 0; i < 10; i++) {
459
459
  const year = new Date(firstYear + i, min ? Number(moment(min).format('MM')) - 1 : 0, 1);
460
460
  tableDataPush(`this-decade-${i + 1}`, year, firstYear + i);
461
461
  }
462
- /**
463
- * year after this decade
462
+ /**
463
+ * year after this decade
464
464
  */
465
465
  tableDataPush(`next_decade-${firstYear + 10}`, nextDecadeFirstYear, firstYear + 10, 'next_month');
466
466
  }
467
467
  break;
468
468
  case 4:
469
469
  {
470
- /**
471
- * decade before this century
470
+ /**
471
+ * decade before this century
472
472
  */
473
473
  const lastDecadeLastCentury = new Date(firstDecade - 10, 0, 1);
474
474
  const nextCenturyFirstDecade = new Date(firstDecade + 100, 0, 1);
475
475
  tableDataPush(`previous_century-${firstYear - 1}`, lastDecadeLastCentury, `${firstDecade - 10} - ${firstDecade - 1}`, 'previous_month');
476
- /**
477
- * decades of this century
476
+ /**
477
+ * decades of this century
478
478
  */
479
479
  for (let i = 0; i < 10; i++) {
480
480
  const decade = new Date(firstDecade + i * 10, 0, 1);
481
481
  tableDataPush(`this-century-${i + 1}`, decade, `${firstDecade + i * 10} - ${firstDecade + i * 10 + 9}`);
482
482
  }
483
- /**
484
- * decade after this century
483
+ /**
484
+ * decade after this century
485
485
  */
486
486
  tableDataPush(`next_century-${firstYear + 10}`, nextCenturyFirstDecade, `${firstDecade + 100} - ${firstDecade + 100 + 9}`, 'next_month');
487
487
  }
488
488
  break;
489
489
  default:
490
490
  if (activeValue && Array.isArray(activeValue) && activeValue.length === 2 && activeValue[0] !== activeValue[1]) {
491
- /**
492
- * days of previous month
491
+ /**
492
+ * days of previous month
493
493
  */
494
494
  active = activeValue;
495
495
  for (let i = weekDateFirst; i > 0; i--) {
@@ -504,8 +504,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
504
504
  ...typographyProps(className.day.day)
505
505
  }, '')));
506
506
  }
507
- /**
508
- * days of this month
507
+ /**
508
+ * days of this month
509
509
  */
510
510
  for (let i = 0; i < lastDate; i++) {
511
511
  const day = new Date(time.getFullYear(), time.getMonth(), i + 1);
@@ -518,8 +518,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
518
518
  ...typographyProps(className.day.day)
519
519
  }, i + 1)));
520
520
  }
521
- /**
522
- * days of next month
521
+ /**
522
+ * days of next month
523
523
  */
524
524
  for (let i = 0; i < 20 - weekDateLast; i++) {
525
525
  const day = new Date(time.getFullYear(), time.getMonth() + 1,
@@ -534,8 +534,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
534
534
  }, '')));
535
535
  }
536
536
  } else {
537
- /**
538
- * days of previous month
537
+ /**
538
+ * days of previous month
539
539
  */
540
540
  for (let i = weekDateFirst; i > 0; i--) {
541
541
  const day = new Date(time.getFullYear(), time.getMonth() - 1, displayAnotherMonth ? prevDate - i + 1 : 1);
@@ -548,8 +548,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
548
548
  ...typographyProps(className.day.day)
549
549
  }, displayAnotherMonth ? prevDate - i + 1 : '')));
550
550
  }
551
- /**
552
- * days of this month
551
+ /**
552
+ * days of this month
553
553
  */
554
554
  for (let i = 0; i < lastDate; i++) {
555
555
  const day = new Date(time.getFullYear(), time.getMonth(), i + 1);
@@ -562,8 +562,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
562
562
  ...typographyProps(className.day.day)
563
563
  }, i + 1)));
564
564
  }
565
- /**
566
- * days of next month
565
+ /**
566
+ * days of next month
567
567
  */
568
568
  for (let i = 0; i < 20 - weekDateLast; i++) {
569
569
  const day = new Date(time.getFullYear(), time.getMonth() + 1, displayAnotherMonth ? i + 1 : 6 - weekDateLast);
@@ -591,11 +591,11 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
591
591
  }
592
592
  return tableBody;
593
593
  };
594
- /**
595
- *
596
- * @param {Object} className
597
- * @param {Number} currentZoomLevel
598
- * @returns
594
+ /**
595
+ *
596
+ * @param {Object} className
597
+ * @param {Number} currentZoomLevel
598
+ * @returns
599
599
  */
600
600
  const renderHeader = (className, currentZoomLevel) => {
601
601
  const weekdays = getGlobal(['weekdaysLong']);
@@ -613,17 +613,17 @@ const renderHeader = (className, currentZoomLevel) => {
613
613
  className: className.table.raw
614
614
  }, !currentZoomLevel && tableHeader));
615
615
  };
616
- /**
617
- *
618
- * @param {Object} className
619
- * @param {Object} refs
620
- * @param {Function} dbLeftFn
621
- * @param {Function} leftFn
622
- * @param {Function} rightFn
623
- * @param {Function} dbRightFn
624
- * @param fn
625
- * @param {Number} currentZoomLevel
626
- * @returns navigator
616
+ /**
617
+ *
618
+ * @param {Object} className
619
+ * @param {Object} refs
620
+ * @param {Function} dbLeftFn
621
+ * @param {Function} leftFn
622
+ * @param {Function} rightFn
623
+ * @param {Function} dbRightFn
624
+ * @param fn
625
+ * @param {Number} currentZoomLevel
626
+ * @returns navigator
627
627
  */
628
628
  const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn, fn, currentZoomLevel = 0) => {
629
629
  const ButtonCSS = css`
@@ -655,7 +655,7 @@ const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn,
655
655
  color: 'primary',
656
656
  type: 'h3',
657
657
  ref: refs.content,
658
- format: ['lowercase']
658
+ format: ['sentence']
659
659
  }))), jsx("div", {
660
660
  className: className.navigator.around
661
661
  }, jsx(ButtonIcon, {
@@ -670,23 +670,23 @@ const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn,
670
670
  ref: refs.doubleRight
671
671
  })));
672
672
  };
673
- /**
674
- *
675
- * @param {Date} time
676
- * @returns {String} month year
673
+ /**
674
+ *
675
+ * @param {Date} time
676
+ * @returns {String} month year
677
677
  */
678
678
  const renderNavigatorContent = time => {
679
679
  const value = new Date(time);
680
680
  const months = getGlobal(['months', 'full']);
681
681
  return [months[value.getMonth()], value.getFullYear()];
682
682
  };
683
- /**
684
- *
685
- * @param {Date} time
686
- * @param {Object} refs
687
- * @param {Date} min
688
- * @param {Date} max
689
- * @param {Number} currentZoomLevel
683
+ /**
684
+ *
685
+ * @param {Date} time
686
+ * @param {Object} refs
687
+ * @param {Date} min
688
+ * @param {Date} max
689
+ * @param {Number} currentZoomLevel
690
690
  */
691
691
  const onUpdateNavigator = (time, refs, min, max, currentZoomLevel = 0) => {
692
692
  var _refs$doubleLeft$curr, _refs$doubleLeft$curr2, _refs$doubleRight$cur, _refs$doubleRight$cur2, _refs$left$current, _refs$left$current$in, _refs$right$current, _refs$right$current$i;
@@ -729,19 +729,19 @@ const onUpdateNavigator = (time, refs, min, max, currentZoomLevel = 0) => {
729
729
  }
730
730
  });
731
731
  };
732
- /**
733
- *
734
- * @param {Date} time
735
- * @param {Object} navigatorRefs
736
- * @param {Date} min
737
- * @param {Date} max
738
- * @param {Element} table
739
- * @param {Date} activeValue
740
- * @param {Object} className
741
- * @param {Boolean} displayAnotherMonth
742
- * @param {Function} onTableDataClick
743
- * @param {Function} onUpdateNavigatorValue
744
- * @param {Number} currentZoomLevel
732
+ /**
733
+ *
734
+ * @param {Date} time
735
+ * @param {Object} navigatorRefs
736
+ * @param {Date} min
737
+ * @param {Date} max
738
+ * @param {Element} table
739
+ * @param {Date} activeValue
740
+ * @param {Object} className
741
+ * @param {Boolean} displayAnotherMonth
742
+ * @param {Function} onTableDataClick
743
+ * @param {Function} onUpdateNavigatorValue
744
+ * @param {Number} currentZoomLevel
745
745
  */
746
746
  const onUpdateCalendar = (time, navigatorRefs, min, max, table, activeValue, className, displayAnotherMonth, onTableDataClick, onUpdateNavigatorValue, currentZoomLevel) => {
747
747
  onUpdateNavigator(time, navigatorRefs, min, max, currentZoomLevel);
@@ -58,15 +58,12 @@ const PasswordInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, refer
58
58
  } = props;
59
59
  const ref = useRef(null);
60
60
  const [value, setValue] = useState(valueProp || defaultValue);
61
- const [secureTextState, setSecureTextState] = useState(secureText);
61
+ const [showPassword, setShowPassword] = useState(false);
62
62
  const _PasswordInputRoot = PasswordInputRoot(theme);
63
63
  const isError = !!error;
64
64
  useEffect(() => {
65
65
  setValue(valueProp);
66
66
  }, [valueProp]);
67
- useEffect(() => {
68
- setSecureTextState(secureText);
69
- }, [secureText]);
70
67
  useImperativeHandle(reference, () => {
71
68
  const currentRef = ref.current || {};
72
69
  currentRef.element = ref.current;
@@ -79,11 +76,11 @@ const PasswordInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, refer
79
76
  });
80
77
  const validateResult = validates && onValidate(value, validates, true);
81
78
  const setShowHide = () => {
82
- setSecureTextState(!secureTextState);
79
+ setShowPassword(prevState => !prevState);
83
80
  };
84
- const VisibilityIcon = secureText && visibilityToggle ? jsx(ButtonIcon, {
81
+ const VisibilityIcon = visibilityToggle ? jsx(ButtonIcon, {
85
82
  viewType: 'ghost',
86
- name: secureTextState ? 'View' : 'UnView',
83
+ name: showPassword ? 'View' : 'UnView',
87
84
  onClick: setShowHide
88
85
  }) : null;
89
86
  return jsx("div", {
@@ -100,7 +97,7 @@ const PasswordInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, refer
100
97
  autoComplete: autoComplete,
101
98
  autoFocus: autoFocus,
102
99
  autoWidth: autoWidth,
103
- className: classNames(secureTextState && 'DGN-UI-PasswordInput-SecureText'),
100
+ className: classNames(secureText && !showPassword && 'DGN-UI-PasswordInput-SecureText'),
104
101
  defaultValue: defaultValue,
105
102
  delayOnChange: delayOnChange,
106
103
  disabled: disabled,
@@ -122,7 +119,7 @@ const PasswordInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, refer
122
119
  startIcon: startIcon,
123
120
  startIconProps: startIconProps,
124
121
  status: isError || validateResult ? 'danger' : status,
125
- type: secureText ? 'text' : 'password',
122
+ type: secureText || showPassword ? 'text' : 'password',
126
123
  value: valueProp,
127
124
  viewType: viewType
128
125
  }), isError && jsx(HelperText, {
@@ -152,6 +149,10 @@ const PasswordInputRoot = ({
152
149
  ${typography.fontFamilySecurity};
153
150
  }
154
151
  }
152
+ input::-ms-reveal,
153
+ input::-ms-clear {
154
+ display: none;
155
+ }
155
156
  `;
156
157
 
157
158
  // PasswordInput.defaultProps = {
@@ -225,10 +226,10 @@ PasswordInput.propTypes = {
225
226
  status: PropTypes.oneOf(['default', 'warning', 'success', 'danger']),
226
227
  /** Style inline of component. */
227
228
  style: PropTypes.object,
228
- /** Validation value, argument can:<br/>
229
- * * string: the validation rule. Example required.<br/>
230
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
231
- * * array: the validation rule list, insist object/string
229
+ /** Validation value, argument can:<br/>
230
+ * * string: the validation rule. Example required.<br/>
231
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
232
+ * * array: the validation rule list, insist object/string
232
233
  */
233
234
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
234
235
  /** The value of the input element, required for a controlled component. */
package/global/index.js CHANGED
@@ -188,7 +188,7 @@ const overrideGlobal = (newGlobal, ingredient, key) => {
188
188
  }
189
189
  });
190
190
  } else {
191
- globalObject[key] = newGlobalValue;
191
+ ingredient[key] = newGlobalValue;
192
192
  }
193
193
  };
194
194
  export default globalObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.4.17-beta.2",
3
+ "version": "1.4.17-beta.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",