diginet-core-ui 1.4.28 → 1.4.29

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,16 @@
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_1722_36)">
3
+ <path d="M25.1998 14.3265C24.3998 14.625 23.8998 14.9235 23.6998 15.7194C23.1998 17.5102 22.5998 19.301 22.0998 20.9923C21.8998 21.5893 21.3998 22.0867 20.6998 22.1862C20.2998 22.2857 20.1998 22.4847 20.0998 22.7832C19.1998 26.9617 18.2998 31.0408 17.3998 35.2194C17.3998 35.4184 17.2998 35.6173 17.1998 35.9158C16.4998 35.3189 15.6998 35.0204 14.7998 35.2194C13.8998 35.4184 13.3998 36.1148 13.0998 36.9107C11.6998 37.0102 10.5998 35.8163 10.8998 34.4235C11.4998 31.6377 12.0998 28.852 12.6998 25.9668C12.8998 24.8724 13.9998 24.176 15.1998 24.4745C16.2998 24.6735 17.3998 24.9719 18.3998 25.1709C18.3998 25.1709 18.3998 25.1709 18.4998 25.0714C18.6998 24.0765 18.8998 23.0816 19.0998 22.0867C19.0998 21.9872 18.9998 21.7883 18.8998 21.6888C18.1998 21.0918 18.0998 20.3954 18.3998 19.5C18.9998 17.5102 19.5998 15.4209 20.2998 13.4311C20.5998 12.5357 21.1998 11.8393 21.9998 11.4413C23.4998 10.6454 25.0998 9.84948 26.5998 8.95408C26.7998 8.85459 27.0998 8.65561 27.3998 8.55612C29.7998 7.66071 31.8998 9.35204 31.5998 11.8393C31.3998 13.3316 31.1998 14.7245 30.9998 16.2168C30.7998 17.9082 30.4998 19.5995 30.2998 21.1913C30.1998 21.8877 30.3998 22.3852 30.8998 22.7832C31.8998 23.5791 32.7998 24.4745 33.6998 25.2704C34.5998 25.9668 34.9998 26.8622 34.9998 28.0561C35.1998 30.8418 35.3998 33.5281 35.5998 36.3138C35.6998 37.3087 35.2998 38.0051 34.3998 38.5025C33.5998 38.9005 32.7998 38.9005 31.9998 38.4031C31.3998 38.0051 31.0998 37.4082 30.9998 36.7117C30.7998 34.2245 30.5998 31.7372 30.3998 29.1505C30.3998 28.7525 30.1998 28.4541 29.8998 28.2551C28.5998 27.1607 27.2998 25.9668 25.8998 24.8724C23.9998 23.4796 23.6998 21.5893 24.0998 19.4005C24.6998 17.8087 24.8998 16.1173 25.1998 14.3265Z" fill="#2680EB"/>
4
+ <path d="M24.2998 24.6735C25.3998 25.6684 26.5998 26.6633 27.6998 27.6582C27.8998 27.8571 27.9998 28.0561 27.8998 28.3546C26.8998 31.3393 25.8998 34.4235 24.9998 37.4082C24.6998 38.4031 23.8998 39 22.8998 39C21.8998 39 20.9998 38.5025 20.7998 37.6071C20.6998 37.1097 20.5998 36.6122 20.6998 36.1148C21.8998 32.3342 23.0998 28.5536 24.2998 24.773C24.2998 24.6735 24.2998 24.6735 24.2998 24.6735Z" fill="#2680EB"/>
5
+ <path d="M33.8998 3.78061C33.8998 5.7704 32.2998 7.46173 30.2998 7.46173C28.2998 7.46173 26.6998 5.86989 26.6998 3.8801C26.6998 1.8903 28.2998 0.198975 30.2998 0.198975C32.2998 0.198975 33.8998 1.79081 33.8998 3.78061Z" fill="#2680EB"/>
6
+ <path d="M32.4998 13.8291C34.4998 15.4209 36.3998 16.8138 38.2998 18.3061C39.0998 18.9031 39.1998 20.1964 38.5998 20.8929C37.8998 21.6888 36.7998 21.8877 35.8998 21.1913C34.5998 20.1964 33.2998 19.2015 32.0998 18.2066C31.9998 18.1071 31.8998 18.0076 31.8998 17.8087C32.0998 16.5153 32.2998 15.2219 32.4998 13.8291Z" fill="#2680EB"/>
7
+ <path d="M15.4998 36.2143C16.2998 36.2143 16.8998 36.8112 16.8998 37.6071C16.8998 38.4031 16.2998 39 15.4998 39C14.6998 39 14.0998 38.4031 14.0998 37.6071C14.0998 36.8112 14.6998 36.2143 15.4998 36.2143Z" fill="#2680EB"/>
8
+ <path d="M5.2 29.8469C4.5 29.8469 4 30.3444 4 30.9413C4 31.5383 4.5 32.1352 5.2 32.1352H10.5C10.7 31.3393 10.8 30.6429 11 29.8469H5.2ZM5.2 25.2704C4.6 25.2704 4 25.7679 4 26.4643C4 27.0612 4.5 27.5587 5.2 27.5587H11.5C11.6 27.0612 11.7 26.4643 11.9 25.8673C11.9 25.6684 12 25.4694 12.1 25.2704H5.2ZM17.4 20.6939H5.2C4.5 20.6939 4 21.1913 4 21.8878C4 22.4847 4.5 22.9821 5.2 22.9821H18C18 22.7832 18.1 22.5842 18.1 22.3852C17.8 21.9872 17.5 21.3903 17.4 20.6939ZM5.2 29.8469C4.5 29.8469 4 30.3444 4 30.9413C4 31.5383 4.5 32.1352 5.2 32.1352H10.5C10.7 31.3393 10.8 30.6429 11 29.8469H5.2ZM5.2 25.2704C4.6 25.2704 4 25.7679 4 26.4643C4 27.0612 4.5 27.5587 5.2 27.5587H11.5C11.6 27.0612 11.7 26.4643 11.9 25.8673C11.9 25.6684 12 25.4694 12.1 25.2704H5.2ZM17.4 20.6939H5.2C4.5 20.6939 4 21.1913 4 21.8878C4 22.4847 4.5 22.9821 5.2 22.9821H18C18 22.7832 18.1 22.5842 18.1 22.3852C17.8 21.9872 17.5 21.3903 17.4 20.6939ZM5.2 29.8469C4.5 29.8469 4 30.3444 4 30.9413C4 31.5383 4.5 32.1352 5.2 32.1352H10.5C10.7 31.3393 10.8 30.6429 11 29.8469H5.2ZM5.2 25.2704C4.6 25.2704 4 25.7679 4 26.4643C4 27.0612 4.5 27.5587 5.2 27.5587H11.5C11.6 27.0612 11.7 26.4643 11.9 25.8673C11.9 25.6684 12 25.4694 12.1 25.2704H5.2ZM17.4 20.6939H5.2C4.5 20.6939 4 21.1913 4 21.8878C4 22.4847 4.5 22.9821 5.2 22.9821H18C18 22.7832 18.1 22.5842 18.1 22.3852C17.8 21.9872 17.5 21.3903 17.4 20.6939ZM20.3 0.298469C20.1 0.0994898 19.8 0 19.5 0H3.4C1.5 0 0 1.49235 0 3.38265V35.5179C0 37.4082 1.5 38.9005 3.4 38.9005H13.6C13.4 38.602 13.2 38.2041 13.1 37.9056H13C12 37.9056 11.1 37.5077 10.5 36.8112L10.4 36.7117H3.4C2.8 36.7117 2.3 36.2143 2.3 35.6173V3.38265C2.3 2.78571 2.8 2.18878 3.4 2.18878H18.3V7.95918C18.3 9.45153 19.3 10.8444 20.7 11.2423C20.9 11.0434 21.2 10.8444 21.5 10.7449C22.5 10.2474 23.5 9.65051 24.5 9.15306H21.7C21.1 9.15306 20.5 8.65561 20.5 7.95918V3.8801L25.3 8.65561C25.5 8.55612 25.8 8.35714 26 8.25765C26.3 8.05867 26.6 7.95918 26.9 7.85969C27.1 7.7602 27.3 7.66071 27.6 7.66071L20.3 0.298469ZM5.2 20.6939C4.5 20.6939 4 21.1913 4 21.8878C4 22.4847 4.5 22.9821 5.2 22.9821H18C18 22.7832 18.1 22.5842 18.1 22.3852C17.7 21.9872 17.4 21.4898 17.3 20.6939H5.2ZM11.8 25.8673C11.8 25.6684 11.9 25.4694 12 25.2704H5.2C4.6 25.2704 4 25.7679 4 26.4643C4 27.0612 4.5 27.5587 5.2 27.5587H11.5C11.5 27.0612 11.6 26.4643 11.8 25.8673ZM4 30.9413C4 31.5383 4.5 32.1352 5.2 32.1352H10.5C10.7 31.3393 10.8 30.6429 11 29.8469H5.2C4.5 29.8469 4 30.3444 4 30.9413ZM17.4 20.6939H5.2C4.5 20.6939 4 21.1913 4 21.8878C4 22.4847 4.5 22.9821 5.2 22.9821H18C18 22.7832 18.1 22.5842 18.1 22.3852C17.8 21.9872 17.5 21.3903 17.4 20.6939ZM5.2 25.2704C4.6 25.2704 4 25.7679 4 26.4643C4 27.0612 4.5 27.5587 5.2 27.5587H11.5C11.6 27.0612 11.7 26.4643 11.9 25.8673C11.9 25.6684 12 25.4694 12.1 25.2704H5.2ZM5.2 29.8469C4.5 29.8469 4 30.3444 4 30.9413C4 31.5383 4.5 32.1352 5.2 32.1352H10.5C10.7 31.3393 10.8 30.6429 11 29.8469H5.2ZM17.4 20.6939H5.2C4.5 20.6939 4 21.1913 4 21.8878C4 22.4847 4.5 22.9821 5.2 22.9821H18C18 22.7832 18.1 22.5842 18.1 22.3852C17.8 21.9872 17.5 21.3903 17.4 20.6939ZM5.2 25.2704C4.6 25.2704 4 25.7679 4 26.4643C4 27.0612 4.5 27.5587 5.2 27.5587H11.5C11.6 27.0612 11.7 26.4643 11.9 25.8673C11.9 25.6684 12 25.4694 12.1 25.2704H5.2ZM5.2 29.8469C4.5 29.8469 4 30.3444 4 30.9413C4 31.5383 4.5 32.1352 5.2 32.1352H10.5C10.7 31.3393 10.8 30.6429 11 29.8469H5.2ZM5.2 29.8469C4.5 29.8469 4 30.3444 4 30.9413C4 31.5383 4.5 32.1352 5.2 32.1352H10.5C10.7 31.3393 10.8 30.6429 11 29.8469H5.2ZM17.4 20.6939H5.2C4.5 20.6939 4 21.1913 4 21.8878C4 22.4847 4.5 22.9821 5.2 22.9821H18C18 22.7832 18.1 22.5842 18.1 22.3852C17.8 21.9872 17.5 21.3903 17.4 20.6939ZM5.2 25.2704C4.6 25.2704 4 25.7679 4 26.4643C4 27.0612 4.5 27.5587 5.2 27.5587H11.5C11.6 27.0612 11.7 26.4643 11.9 25.8673C11.9 25.6684 12 25.4694 12.1 25.2704H5.2ZM17.4 20.6939H5.2C4.5 20.6939 4 21.1913 4 21.8878C4 22.4847 4.5 22.9821 5.2 22.9821H18C18 22.7832 18.1 22.5842 18.1 22.3852C17.8 21.9872 17.5 21.3903 17.4 20.6939ZM5.2 25.2704C4.6 25.2704 4 25.7679 4 26.4643C4 27.0612 4.5 27.5587 5.2 27.5587H11.5C11.6 27.0612 11.7 26.4643 11.9 25.8673C11.9 25.6684 12 25.4694 12.1 25.2704H5.2ZM5.2 29.8469C4.5 29.8469 4 30.3444 4 30.9413C4 31.5383 4.5 32.1352 5.2 32.1352H10.5C10.7 31.3393 10.8 30.6429 11 29.8469H5.2Z" fill="#FFAA00"/>
9
+ <path d="M8.2 14.824V11.6403C6.9 11.3418 6 10.9439 5.3 10.3469C4.6 9.75 4.4 9.05357 4.4 8.25765C4.4 7.46173 4.7 6.66582 5.4 6.16837C6.1 5.67092 7 5.27296 8.1 5.17347V4.37755H9.5V5.17347C10.6 5.27296 11.4 5.57143 12 5.96939C12.6 6.46684 13 7.06378 13.2 7.7602L10.7 8.05867C10.5 7.46174 10.2 7.06378 9.5 6.8648V9.84949C11.1 10.148 12.2 10.6454 12.7 11.1429C13.3 11.6403 13.6 12.3367 13.6 13.1327C13.6 14.0281 13.2 14.824 12.5 15.5204C11.8 16.1173 10.8 16.5153 9.5 16.7143V18.1071H8.1V16.7143C7 16.6148 6 16.3163 5.3 15.7194C4.6 15.1224 4.1 14.426 3.9 13.4311L6.5 13.2321C6.6 13.6301 6.8 14.0281 7.1 14.3265C7.5 14.5255 7.8 14.7245 8.2 14.824ZM8.2 6.8648C7.8 6.96429 7.5 7.06378 7.2 7.36224C7 7.56122 6.9 7.85969 6.9 8.15816C6.9 8.45663 7 8.65561 7.2 8.95408C7.4 9.15306 7.7 9.35204 8.2 9.55102V6.8648ZM9.6 14.9235C10.1 14.824 10.5 14.625 10.8 14.426C11.1 14.1276 11.3 13.8291 11.3 13.4311C11.3 13.1327 11.2 12.8342 10.9 12.5357C10.6 12.3367 10.2 12.1378 9.6 11.9388V14.9235Z" fill="#FFAA00"/>
10
+ </g>
11
+ <defs>
12
+ <clipPath id="clip0_1722_36">
13
+ <rect width="39" height="39" fill="white"/>
14
+ </clipPath>
15
+ </defs>
16
+ </svg>
@@ -65,13 +65,6 @@ const DetailsRootCSS = ({
65
65
  }
66
66
  }
67
67
  `;
68
-
69
- // AccordionDetails.defaultProps = {
70
- // className: '',
71
- // id: '',
72
- // style: {},
73
- // };
74
-
75
68
  AccordionDetails.propTypes = {
76
69
  /** The content of the component. */
77
70
  children: PropTypes.node,
@@ -120,11 +120,7 @@ const AccordionGroupRootCSS = ({
120
120
  }
121
121
  `;
122
122
 
123
- // AccordionGroup.defaultProps = {
124
- // className: '',
125
- // collapseOther: true,
126
- // style: {},
127
- // };
123
+ //Check defaultProps at src/theme/setting.js
128
124
 
129
125
  AccordionGroup.propTypes = {
130
126
  /** The content of the component. */
@@ -9,15 +9,31 @@ import { useTheme } from "../../theme";
9
9
  import useThemeProps from "../../theme/utils/useThemeProps";
10
10
  import { classNames, getProp } from "../../utils";
11
11
  import AccordionContext from "./context";
12
+
13
+ /**
14
+ * Handles the transition of an element's height with a smooth animation.
15
+ *
16
+ * @param {Object} timer - A timer object used to manage the timeout for setting the final height.
17
+ * @param {HTMLElement} el - The target element on which the transition effect will be applied.
18
+ * @param {number} beginHeight - The initial height of the element in pixels.
19
+ * @param {number|null} [endHeight=null] - The final height of the element in pixels. If not provided, the element's height will remain unchanged.
20
+ */
12
21
  const handleTransition = (timer, el, beginHeight, endHeight = null) => {
22
+ /**
23
+ * Calculates the duration for the transition based on the initial height.
24
+ *
25
+ * @param {number} height - The initial height of the element in pixels.
26
+ * @returns {number} - The rounded duration in milliseconds.
27
+ */
13
28
  const getAutoHeightDuration = height => {
14
29
  if (!height) {
15
30
  return 0;
16
31
  }
17
32
  const constant = height / 36;
18
-
19
33
  // https://www.wolframalpha.com/input/?i=(4+%2B+15+*+(x+%2F+36+)+**+0.25+%2B+(x+%2F+36)+%2F+5)+*+10
20
- return Math.round((4 + 15 * constant ** 0.25 + constant / 5) * 10);
34
+ // Formula: (4 + 15 * (x / 36) ** 0.25 + (x / 36) / 5) * 10
35
+ const constantPart = 4 + 15 * Math.pow(constant, 0.25) + constant / 5;
36
+ return Math.round(constantPart * 10);
21
37
  };
22
38
  const duration = getAutoHeightDuration(beginHeight);
23
39
  el.style.transitionDuration = `${duration}ms`;
@@ -82,6 +98,8 @@ const Accordion = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference
82
98
  const currentRef = ref.current || {};
83
99
  currentRef.element = ref.current;
84
100
  const _instance = {
101
+ expandState: expandState,
102
+ setExpandState: setExpandState,
85
103
  ...action
86
104
  }; // methods
87
105
  _instance.__proto__ = {}; // hidden methods
@@ -133,14 +151,7 @@ const AccordionRootDisabledCSS = css`
133
151
  ${shadowNone};
134
152
  `;
135
153
 
136
- // Accordion.defaultProps = {
137
- // boxShadow: true,
138
- // className: '',
139
- // disabled: false,
140
- // expand: false,
141
- // fullHeight: false,
142
- // style: {},
143
- // };
154
+ //Check defaultProps at src/theme/setting.js
144
155
 
145
156
  Accordion.propTypes = {
146
157
  /** The box-shadow of the component. */
@@ -297,14 +297,7 @@ const SummaryRootCSS = (background, {
297
297
  }
298
298
  `;
299
299
 
300
- // AccordionSummary.defaultProps = {
301
- // background: 'system/standard',
302
- // className: '',
303
- // expandIcon: 'ArrowRight',
304
- // expandIconAt: 'start',
305
- // expandIconProps: {},
306
- // style: {},
307
- // };
300
+ //Check defaultProps at src/theme/setting.js
308
301
 
309
302
  AccordionSummary.propTypes = {
310
303
  /** Background color for the label summary. */
@@ -1471,7 +1471,7 @@ Attachment.propTypes = {
1471
1471
  /** List attachment:<br />
1472
1472
  * [{<br />
1473
1473
  * &nbsp;&nbsp;&nbsp;&nbsp;"AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
1474
- * &nbsp;&nbsp;&nbsp;&nbsp;"URL": "https://apricot.diginet.com.vn/cdn-dev/file/8a07bee1eeff17a14eee.jpg?path=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxlUGF0aCI6Ii8yMDIwLzA4LzQ0YjNhYjQ4LTMwNGQtNDQ3NC05ZDk0LWNkNGVlMDQwOGNlMy5qcGciLCJmaWxlTmFtZSI6IjhhMDdiZWUxZWVmZjE3YTE0ZWVlLmpwZyIsImZpbGVTaXplIjoyNDg4MzcsImZpbGVUeXBlIjoiaW1hZ2UvanBlZyIsImlhdCI6MTU5ODI0NDMwMiwiZXhwIjo4Nzk5ODI0NDMwMn0.fow6O5fp2z3vieA9gom5RRwQ7xxwBx9_7X2Fe8T2YI0",<br />
1474
+ * &nbsp;&nbsp;&nbsp;&nbsp;"URL": "https://apricot.diginet.com.vn/cdn-dev/file/demo.jpg",<br />
1475
1475
  * &nbsp;&nbsp;&nbsp;&nbsp;"FileName": "8a07bee1eeff17a14eee.jpg",<br />
1476
1476
  * &nbsp;&nbsp;&nbsp;&nbsp;"FileSize": 248837,<br />
1477
1477
  * &nbsp;&nbsp;&nbsp;&nbsp;"KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
@@ -44,7 +44,7 @@ export class DateField {
44
44
  /**
45
45
  * Pad a number with zeros to the left.
46
46
  */
47
- function padNumber(number, length) {
47
+ const padNumber = (number, length) => {
48
48
  let numberString = String(number);
49
49
  if (numberString.length >= length) {
50
50
  return numberString;
@@ -54,7 +54,7 @@ function padNumber(number, length) {
54
54
  numberString = '0' + numberString;
55
55
  }
56
56
  return numberString;
57
- }
57
+ };
58
58
  export const useDateField = (format, localize, date) => {
59
59
  const [dateField, dispatch] = useReducer((state, action) => {
60
60
  switch (action.type) {
@@ -105,10 +105,8 @@ export const useDateField = (format, localize, date) => {
105
105
  let value = dateField[key];
106
106
  if (value !== null) {
107
107
  if (pattern === 'MMM' && typeof value === 'number') {
108
- // value = localize?.month(value - 1, { width: 'abbreviated' });
109
108
  value = localize === null || localize === void 0 ? void 0 : localize.months[['notFull']][value - 1];
110
109
  } else if (pattern === 'MMMM' && typeof value === 'number') {
111
- // value = localize?.month(value - 1, { width: 'wide' });
112
110
  value = localize === null || localize === void 0 ? void 0 : localize.months[['full']][value - 1];
113
111
  } else if (pattern === 'aa') {
114
112
  if (typeof hour === 'number') {
@@ -2,19 +2,18 @@
2
2
  /** @jsx jsx */
3
3
  import { css, jsx } from '@emotion/core';
4
4
  import { HelperText, Label } from "../..";
5
+ import { getGlobal } from "../../../global";
6
+ import locale from "../../../locale";
5
7
  import PropTypes from 'prop-types';
6
8
  import { forwardRef, memo, useImperativeHandle, useMemo, useRef, useState } from 'react';
7
9
  import { cursorNotAllowed, displayBlock, positionRelative } from "../../../styles/general";
8
10
  import useThemeProps from "../../../theme/utils/useThemeProps";
9
- import { classNames, refType as ref } from "../../../utils";
11
+ import { classNames, refType as ref, useControlled } from "../../../utils";
12
+ import UncontrolledInputBase from "../input-base/UncontrolledInputBase";
13
+ import useDateInputState from "./useDateInputState";
10
14
  import useIsFocused from "./useIsFocused";
11
15
  import useKeyboardInputEvent from "./useKeyboardInputEvent";
12
16
  import { getInputSelectedState, isFieldFullValue, useEventCallback, useInputSelection, validateDateTime } from "./utils";
13
- import { getGlobal } from "../../../global";
14
- import locale from "../../../locale";
15
- import useDateInputState from "./useDateInputState";
16
- import useControlled from "./useControlled";
17
- import UncontrolledInputBase from "../input-base/UncontrolledInputBase";
18
17
  const DateInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
19
18
  if (!reference) reference = useRef(null);
20
19
 
@@ -60,7 +59,6 @@ const DateInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference
60
59
  });
61
60
  const isError = !!error;
62
61
  const isEnabled = !readOnly && !disabled;
63
- const _DateInputRoot = DateInputRoot();
64
62
  useImperativeHandle(reference, () => {
65
63
  const currentRef = ref.current || {};
66
64
  currentRef.element = ref.current;
@@ -141,12 +139,6 @@ const DateInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference
141
139
  if (validateDateTime(field.name, padValue)) {
142
140
  newValue = padValue;
143
141
  }
144
-
145
- // if (pattern === 'M') {
146
- // // Month cannot be less than 1.
147
- // newValue = Math.max(1, newValue);
148
- // }
149
-
150
142
  setDateField(pattern, newValue, date => handleChange(date, event));
151
143
 
152
144
  // The currently selected month will be retained as a parameter of getInputSelectedState,
@@ -205,7 +197,7 @@ const DateInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference
205
197
  }, [dateString, focused, isEmptyValue]);
206
198
  return jsx("div", {
207
199
  ref: ref,
208
- css: _DateInputRoot,
200
+ css: DateInputRoot,
209
201
  className: classNames('DGN-UI-DateInput', className, disabled && 'disabled'),
210
202
  style: style,
211
203
  ...other
@@ -238,7 +230,7 @@ const DateInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference
238
230
  disabled: disabled
239
231
  }, error));
240
232
  }));
241
- const DateInputRoot = () => css`
233
+ const DateInputRoot = css`
242
234
  ${displayBlock};
243
235
  ${positionRelative};
244
236
  &.disabled {
@@ -1,17 +1,16 @@
1
1
  import { useEffect } from 'react';
2
- // import startCase from 'lodash/startCase';
3
2
  import { addDays, addHours, addMinutes, addMonths, addSeconds, addYears, format, isLastDayOfMonth, isValid, lastDayOfMonth } from 'date-fns';
3
+ import { enUS, vi } from 'date-fns/locale';
4
4
  import { getGlobal } from "../../../global";
5
5
  import { capitalize } from "../../../utils";
6
6
  import { patternMap, useDateField } from "./DateField";
7
7
  import { lowerCaseDayYear } from "./utils";
8
- import { enUS, vi } from 'date-fns/locale';
9
- export function useDateInputState({
8
+ export const useDateInputState = ({
10
9
  formatStr,
11
10
  locale,
12
11
  date,
13
12
  isControlledDate
14
- }) {
13
+ }) => {
15
14
  const {
16
15
  dateField,
17
16
  dispatch,
@@ -80,7 +79,6 @@ export function useDateInputState({
80
79
  };
81
80
  const setDateField = (pattern, value, callback) => {
82
81
  const field = patternMap[pattern];
83
- // const actionName = `set${startCase(field)}`;
84
82
  const actionName = `set${capitalize(field)}`;
85
83
  dispatch({
86
84
  type: actionName,
@@ -97,7 +95,6 @@ export function useDateInputState({
97
95
  };
98
96
  const toControlledDateString = () => {
99
97
  if (date && isValid(date)) {
100
- // return format(date, formatStr, { locale });
101
98
  return format(date, lowerCaseDayYear(formatStr), {
102
99
  locale: locale === 'vi' ? vi : enUS
103
100
  });
@@ -128,5 +125,5 @@ export function useDateInputState({
128
125
  toDateString: isControlledDate ? toControlledDateString : toDateString,
129
126
  isEmptyValue
130
127
  };
131
- }
128
+ };
132
129
  export default useDateInputState;
@@ -1,8 +1,8 @@
1
- import { useState, useCallback } from 'react';
2
- function useIsFocused({
1
+ import { useCallback, useState } from 'react';
2
+ const useIsFocused = ({
3
3
  onFocus: onFocusProp,
4
4
  onBlur: onBlurProp
5
- }) {
5
+ }) => {
6
6
  const [isFocused, setIsFocused] = useState(false);
7
7
  const onFocus = useCallback(event => {
8
8
  setIsFocused(true);
@@ -16,5 +16,5 @@ function useIsFocused({
16
16
  onFocus,
17
17
  onBlur
18
18
  }];
19
- }
19
+ };
20
20
  export default useIsFocused;
@@ -1,10 +1,10 @@
1
- function useKeyboardInputEvent({
1
+ const useKeyboardInputEvent = ({
2
2
  onSegmentChange,
3
3
  onSegmentValueChange,
4
4
  onSegmentValueChangeWithNumericKeys,
5
5
  onSegmentValueRemove,
6
6
  onKeyDown
7
- }) {
7
+ }) => {
8
8
  return event => {
9
9
  var _key$match;
10
10
  const {
@@ -41,5 +41,5 @@ function useKeyboardInputEvent({
41
41
  }
42
42
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
43
43
  };
44
- }
44
+ };
45
45
  export default useKeyboardInputEvent;
@@ -1,11 +1,11 @@
1
- import { setDate, setHours, setMinutes, setMonth, setSeconds, setYear } from 'date-fns';
1
+ import { isValid, parse, setDate, setHours, setMinutes, setMonth, setSeconds, setYear } from 'date-fns';
2
2
  import { useCallback, useEffect, useRef } from 'react';
3
3
 
4
4
  /**
5
5
  * https://github.com/facebook/react/issues/14099#issuecomment-440013892
6
6
  * @param {function} fn
7
7
  */
8
- export function useEventCallback(fn) {
8
+ export const useEventCallback = fn => {
9
9
  const ref = useRef(fn);
10
10
  useEffect(() => {
11
11
  ref.current = fn;
@@ -14,14 +14,13 @@ export function useEventCallback(fn) {
14
14
  var _ref$current;
15
15
  return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.call(ref, ...args);
16
16
  }, []);
17
- }
18
- export function safeSetSelection(element, selectionStart, selectionEnd) {
17
+ };
18
+ export const safeSetSelection = (element, selectionStart, selectionEnd) => {
19
19
  if (document.activeElement === element) {
20
20
  element.setSelectionRange(selectionStart, selectionEnd, 'none');
21
21
  }
22
- }
23
- export default safeSetSelection;
24
- export function getSelectIndexGap(options) {
22
+ };
23
+ export const getSelectIndexGap = options => {
25
24
  const {
26
25
  pattern,
27
26
  formatStr,
@@ -53,17 +52,15 @@ export function getSelectIndexGap(options) {
53
52
  } else if (month === 0) {
54
53
  month = 12;
55
54
  }
56
-
57
- // const monthStr = localize?.months(month - 1, { width: monthIsFull ? 'full' : 'notFull' });
58
55
  const monthStr = localize === null || localize === void 0 ? void 0 : localize.months[[monthIsFull ? 'full' : 'notFull']][month - 1];
59
56
  gap = monthStr.length - (monthIsFull ? 4 : 3);
60
57
  }
61
58
  return gap;
62
- }
63
- export function isCursorAfterMonth(cursorIndex, formatStr) {
59
+ };
60
+ export const isCursorAfterMonth = (cursorIndex, formatStr) => {
64
61
  return cursorIndex > formatStr.indexOf('M');
65
- }
66
- export function getDatePattern(options) {
62
+ };
63
+ export const getDatePattern = options => {
67
64
  const {
68
65
  selectionIndex,
69
66
  positionOffset = -1,
@@ -99,8 +96,8 @@ export function getDatePattern(options) {
99
96
  });
100
97
  }
101
98
  return pattern;
102
- }
103
- export function getInputSelectedState(options) {
99
+ };
100
+ export const getInputSelectedState = options => {
104
101
  const {
105
102
  input,
106
103
  direction,
@@ -176,8 +173,8 @@ export function getInputSelectedState(options) {
176
173
  selectionStart: 0,
177
174
  selectionEnd: 0
178
175
  };
179
- }
180
- export function validateDateTime(type, value) {
176
+ };
177
+ export const validateDateTime = (type, value) => {
181
178
  switch (type) {
182
179
  case 'year':
183
180
  if (value < 1 || value > 9999) {
@@ -215,8 +212,8 @@ export function validateDateTime(type, value) {
215
212
  }
216
213
 
217
214
  return true;
218
- }
219
- export function modifyDate(date, type, value) {
215
+ };
216
+ export const modifyDate = (date, type, value) => {
220
217
  switch (type) {
221
218
  case 'year':
222
219
  return setYear(date, value);
@@ -232,12 +229,12 @@ export function modifyDate(date, type, value) {
232
229
  return setSeconds(date, value);
233
230
  }
234
231
  return date;
235
- }
236
- export function getPatternGroups(format, pattern) {
232
+ };
233
+ export const getPatternGroups = (format, pattern) => {
237
234
  var _format$match;
238
235
  return ((_format$match = format.match(new RegExp(`(${pattern})+`))) === null || _format$match === void 0 ? void 0 : _format$match[0]) || '';
239
- }
240
- export function isFieldFullValue(formatStr, value, pattern) {
236
+ };
237
+ export const isFieldFullValue = (formatStr, value, pattern) => {
241
238
  const patternGroup = getPatternGroups(formatStr, pattern);
242
239
  if (value.toString().length === patternGroup.length) {
243
240
  return true;
@@ -258,14 +255,14 @@ export function isFieldFullValue(formatStr, value, pattern) {
258
255
  default:
259
256
  return false;
260
257
  }
261
- }
262
- export function useInputSelection(input) {
258
+ };
259
+ export const useInputSelection = input => {
263
260
  return function setSelectionRange(selectionStart, selectionEnd) {
264
261
  requestAnimationFrame(() => {
265
262
  safeSetSelection(input.current, selectionStart, selectionEnd);
266
263
  });
267
264
  };
268
- }
265
+ };
269
266
 
270
267
  // use yyyy instead of YYYY for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
271
268
  // use yy instead of YY for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
@@ -283,4 +280,12 @@ export const lowerCaseDayYear = dateString => {
283
280
  }
284
281
  }).join('');
285
282
  return modifiedString;
283
+ };
284
+ export const isValidDate = (dateString, format = 'MM/DD/YYYY') => {
285
+ if (dateString && dateString !== 'Invalid Date') {
286
+ if (isValid(dateString)) return true;
287
+ const parsedDate = parse(dateString, lowerCaseDayYear(format), new Date());
288
+ return isValid(parsedDate);
289
+ }
290
+ return false;
286
291
  };
@@ -11,9 +11,8 @@ import { Fragment, forwardRef, memo, useEffect, useImperativeHandle, useMemo, us
11
11
  import { cursorNotAllowed, displayBlock, displayFlex, flexRow, itemsCenter, justifyEnd, positionRelative } from "../../../styles/general";
12
12
  import { useTheme } from "../../../theme";
13
13
  import useThemeProps from "../../../theme/utils/useThemeProps";
14
- import { capitalizeSentenceCase, classNames, isValidDate } from "../../../utils";
14
+ import { capitalizeSentenceCase, classNames, isValidDate, useControlled } from "../../../utils";
15
15
  import Calendar from "../calendar";
16
- import useControlled from "../date-input/useControlled";
17
16
  import { lowerCaseDayYear } from "../date-input/utils";
18
17
  const unique = {
19
18
  footer: 'DGN-UI-DatePicker-Footer',