diginet-core-ui 1.3.30-beta.3 → 1.3.32-beta.2

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,20 @@
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_13482_11580)">
3
+ <path d="M22.7999 11.97L22.6299 11.4C22.5299 11.08 22.1999 10.91 21.8899 11L7.13993 15.47C6.81993 15.57 6.63993 15.9 6.73993 16.21L6.90993 16.78C7.00993 17.1 7.33993 17.28 7.64993 17.18L22.3999 12.71C22.7199 12.61 22.8999 12.28 22.7999 11.97Z" fill="#2680EB"/>
4
+ <path d="M22.9999 16.24V18.1L9.19993 22.29C8.88993 22.39 8.55993 22.21 8.45993 21.89L8.28993 21.32C8.18993 21.01 8.36993 20.68 8.68993 20.58L22.9999 16.24Z" fill="#2680EB"/>
5
+ <path d="M27.2999 27C27.2599 27.21 27.1099 27.38 26.8899 27.45L22.9299 28.66L12.1399 31.94C11.8299 32.04 11.4999 31.86 11.3999 31.54L11.2299 30.97C11.2099 30.89 11.1999 30.81 11.2099 30.74C11.2299 30.51 11.3899 30.3 11.6299 30.22L22.8199 26.82H22.8299C23.2099 26.94 23.5899 27 23.9999 27H27.2999Z" fill="#2680EB"/>
6
+ <path d="M6.81993 6.30001C7.10993 7.23001 8.08993 7.75001 9.01993 7.47001L16.4299 5.21001C17.3599 4.93001 17.8899 3.95001 17.6099 3.01001L17.5999 2.98001C17.3199 2.05001 16.3299 1.53001 15.3999 1.81001L14.5299 2.08001C14.0699 2.22001 13.5699 1.96001 13.4299 1.49001L13.4199 1.46001C13.0899 0.37001 11.9399 -0.23999 10.8599 0.0900095L10.8099 0.10001C9.71993 0.43001 9.10993 1.58001 9.43993 2.66001V2.69001C9.57993 3.15001 9.31993 3.65001 8.84993 3.79001L7.97993 4.06001C7.04993 4.34001 6.52993 5.33001 6.80993 6.26001L6.81993 6.30001Z" fill="#2680EB"/>
7
+ <path d="M33.5999 29.14L32.9499 27H29.8499L30.7599 30L10.8999 36.03L3.99993 13.33L22.9999 7.56001V6.00001C22.9999 5.60001 23.2399 5.23001 23.6199 5.08001C23.7399 5.02001 23.8699 5.00001 23.9999 5.00001C24.2599 5.00001 24.5199 5.10001 24.7099 5.29001L25.4999 6.09001L26.2899 5.29001C26.2999 5.28001 26.3199 5.27001 26.3299 5.25001L25.6599 3.04001C25.1799 1.47001 23.5299 0.580009 21.9599 1.06001L18.4999 2.11001C18.5899 2.27001 18.6599 2.45001 18.7199 2.64001C19.2099 4.23001 18.3299 5.88001 16.7699 6.35001L9.46993 8.57001C7.97993 9.02001 6.32993 8.31001 5.75993 6.86001C5.65993 6.58001 5.59993 6.31001 5.55993 6.04001L2.09993 7.09001C0.539928 7.56001 -0.350072 9.22001 0.129928 10.79L8.04993 36.89C8.52993 38.46 10.1799 39.35 11.7499 38.87L31.6199 32.84C33.1899 32.36 34.0799 30.71 33.5999 29.14Z" fill="#2680EB"/>
8
+ <path d="M20.1099 23.92V23.93L10.5799 26.82C10.5299 26.84 10.4799 26.84 10.4299 26.84C10.1699 26.85 9.91993 26.7 9.83993 26.43L9.66993 25.86C9.64993 25.78 9.63993 25.7 9.64993 25.63C9.66993 25.39 9.82993 25.19 10.0699 25.11L19.9999 22.1V23C19.9999 23.32 20.0399 23.63 20.1099 23.92Z" fill="#2680EB"/>
9
+ <path d="M32 13H28C27.45 13 27 12.55 27 12C27 11.45 27.45 11 28 11H32C32.55 11 33 11.45 33 12C33 12.55 32.55 13 32 13Z" fill="#FF8C00"/>
10
+ <path d="M32 16H28C27.45 16 27 15.55 27 15C27 14.45 27.45 14 28 14H32C32.55 14 33 14.45 33 15C33 15.55 32.55 16 32 16Z" fill="#FF8C00"/>
11
+ <path d="M37.5 7.5L36 6L34.5 7.5L33 6L31.5 7.5L30 6L28.5 7.5L27 6L25.5 7.5L24 6V20H22C21.45 20 21 20.45 21 21V23C21 24.66 22.34 26 24 26H36C37.66 26 39 24.66 39 23V6L37.5 7.5ZM33 24H24C23.45 24 23 23.55 23 23V22H33V24ZM37 23C37 23.55 36.55 24 36 24C35.45 24 35 23.55 35 23V21C35 20.45 34.55 20 34 20H26V9H37V23Z" fill="#FF8C00"/>
12
+ <path d="M35 13C35.5523 13 36 12.5523 36 12C36 11.4477 35.5523 11 35 11C34.4477 11 34 11.4477 34 12C34 12.5523 34.4477 13 35 13Z" fill="#FF8C00"/>
13
+ <path d="M35 16C35.5523 16 36 15.5523 36 15C36 14.4477 35.5523 14 35 14C34.4477 14 34 14.4477 34 15C34 15.5523 34.4477 16 35 16Z" fill="#FF8C00"/>
14
+ </g>
15
+ <defs>
16
+ <clipPath id="clip0_13482_11580">
17
+ <rect width="39" height="39" fill="white"/>
18
+ </clipPath>
19
+ </defs>
20
+ </svg>
@@ -1636,7 +1636,7 @@ Dropdown.defaultProps = {
1636
1636
  itemMultipleSize: 'medium',
1637
1637
  className: '',
1638
1638
  label: '',
1639
- placeholder: '',
1639
+ placeholder: getGlobal('dropdownPlaceholder'),
1640
1640
  error: '',
1641
1641
  iconExpr: 'none',
1642
1642
  valueExpr: 'id',
@@ -192,9 +192,8 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
192
192
  };
193
193
 
194
194
  const _onChangeInput = e => {
195
- const value = e.target.value;
196
195
  const timeout = setTimeout(() => {
197
- onChangeInput === null || onChangeInput === void 0 ? void 0 : onChangeInput(value);
196
+ onChangeInput === null || onChangeInput === void 0 ? void 0 : onChangeInput(e);
198
197
  }, delayOnInput);
199
198
  return () => clearTimeout(timeout);
200
199
  };
@@ -2,6 +2,7 @@
2
2
 
3
3
  /** @jsx jsx */
4
4
  import { memo, useEffect, useRef, forwardRef, useImperativeHandle } from 'react';
5
+ import useInput from '../../../utils/useInput';
5
6
  import PropTypes from 'prop-types';
6
7
  import { jsx, css } from '@emotion/core';
7
8
  import { renderIcon } from '../../../utils';
@@ -10,11 +11,12 @@ import { typography } from '../../../styles/typography';
10
11
  const {
11
12
  colors
12
13
  } = theme;
14
+ import { getGlobal } from '../../../global';
13
15
  const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
14
16
  type,
15
17
  viewType,
16
18
  defaultValue,
17
- value,
19
+ value: valueProp,
18
20
  placeholder,
19
21
  resize,
20
22
  status,
@@ -42,8 +44,17 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
42
44
  onInput,
43
45
  onKeyDown,
44
46
  onKeyUp,
47
+ delayOnChange,
45
48
  ...props
46
49
  }, reference) => {
50
+ const {
51
+ bind
52
+ } = useInput({
53
+ defaultValue,
54
+ valueProp,
55
+ onChange,
56
+ delayOnChange
57
+ });
47
58
  const ref = useRef(null);
48
59
  const inputBaseRef = useRef(null);
49
60
  const valueArray = useRef([]);
@@ -478,9 +489,9 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
478
489
  useEffect(() => {
479
490
  const defaultHeight = 24;
480
491
 
481
- if (value !== undefined) {
482
- valueArray.current.push(value);
483
- inputBaseRef.current.value = value;
492
+ if (valueProp !== undefined) {
493
+ valueArray.current.push(valueProp);
494
+ inputBaseRef.current.value = valueProp;
484
495
 
485
496
  if (multiline && !/\d+/.test(rows)) {
486
497
  inputBaseRef.current.style.height = 0;
@@ -489,11 +500,11 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
489
500
  }
490
501
 
491
502
  return () => {
492
- if (value !== undefined && multiline && !/\d+/.test(rows) && inputBaseRef.current) {
503
+ if (valueProp !== undefined && multiline && !/\d+/.test(rows) && inputBaseRef.current) {
493
504
  inputBaseRef.current.style.height = defaultHeight + 'px';
494
505
  }
495
506
  };
496
- }, [value]);
507
+ }, [valueProp]);
497
508
  useEffect(() => {
498
509
  if (disabled) {
499
510
  if (ref.current) {
@@ -531,9 +542,9 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
531
542
  onKeyDown: onKeyDown,
532
543
  onKeyUp: onKeyUp,
533
544
  onInput: onInputTextArea,
534
- onChange: onChange,
535
545
  onBlur: onBlur,
536
- onFocus: onFocus
546
+ onFocus: onFocus,
547
+ ...bind
537
548
  }));
538
549
  const InputComp = jsx("div", {
539
550
  css: inputBaseRoot,
@@ -568,9 +579,9 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
568
579
  onKeyDown: onKeyDown,
569
580
  onKeyUp: onKeyUp,
570
581
  onInput: onInput,
571
- onChange: onChange,
572
582
  onBlur: onBlur,
573
- onFocus: onFocus
583
+ onFocus: onFocus,
584
+ ...bind
574
585
  })), !!endIcon && jsx("div", {
575
586
  css: inputBaseIconCSS,
576
587
  ...endIconProps,
@@ -609,7 +620,7 @@ InputBase.defaultProps = {
609
620
  autoComplete: 'off',
610
621
  className: '',
611
622
  defaultValue: '',
612
- placeholder: '',
623
+ placeholder: getGlobal('inputPlaceholder'),
613
624
  resize: 'none',
614
625
  status: 'default',
615
626
  type: 'text',
@@ -718,6 +729,9 @@ InputBase.propTypes = {
718
729
  onFocus: PropTypes.func,
719
730
 
720
731
  /** inputRef of InputBase component */
721
- inputRef: PropTypes.any
732
+ inputRef: PropTypes.any,
733
+
734
+ /** delayOnChange of InputBase component */
735
+ delayOnChange: PropTypes.number
722
736
  };
723
737
  export default InputBase;
@@ -334,8 +334,11 @@ const NumberInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
334
334
 
335
335
  if (valueTypeReturn === 'string') {
336
336
  el.value = result;
337
+ el.target.value = result;
337
338
  } else {
338
- el.value = String(+result.replace(',', '.')) !== 'NaN' ? +result.replace(',', '.') : result;
339
+ const newResult = String(+result.replace(',', '.')) !== 'NaN' ? +result.replace(',', '.') : result;
340
+ el.value = newResult;
341
+ el.target.value = newResult;
339
342
  }
340
343
 
341
344
  !!onChange && onChange(el);
@@ -356,7 +359,8 @@ const NumberInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
356
359
  if (v === null || v === undefined) {
357
360
  inputRef.current.value = '';
358
361
  } else {
359
- v = getValueWithDecimal(getValueWithMinMax(v).replace('.', decimalSymbol));
362
+ v = v.toString().replace('.', decimalSymbol);
363
+ v = getValueWithDecimal(getValueWithMinMax(v));
360
364
  inputRef.current.value = format ? getFormat(v) : v;
361
365
  }
362
366
  };
@@ -1,11 +1,12 @@
1
1
  /** @jsxRuntime classic */
2
2
 
3
3
  /** @jsx jsx */
4
- import { memo, useEffect, useRef, forwardRef, useImperativeHandle } from 'react';
4
+ import { memo, useEffect, useRef, forwardRef, useState, useImperativeHandle } from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { jsx, css } from '@emotion/core';
7
7
  import { ButtonIcon, CircularProgress as Circular, HelperText, InputBase, Label } from '../../';
8
8
  import { renderIcon, onValidate } from '../../../utils';
9
+ import { displayBlock, flexRow, positionRelative } from '../../../styles/general';
9
10
  const icons = {
10
11
  default: `<svg width="20" height="19" viewBox="0 0 20 19" fill="none" xmlns="http://www.w3.org/2000/svg">
11
12
  <path fillRule="evenodd" clipRule="evenodd" d="M15.5616 19.0007C15.4036 19.0007 15.2446 18.9637 15.0986 18.8877L9.99962 16.2237L4.90162 18.8877C4.56362 19.0627 4.15562 19.0327 3.84962 18.8087C3.54162 18.5847 3.38862 18.2057 3.45362 17.8307L4.42462 12.2027L0.304623 8.21765C0.030623 7.95265 -0.068377 7.55465 0.048623 7.19065C0.165623 6.82865 0.478623 6.56365 0.856623 6.50965L6.55662 5.68165L9.10462 0.555654C9.44262 -0.124346 10.5576 -0.124346 10.8956 0.555654L13.4436 5.68165L19.1436 6.50965C19.5216 6.56365 19.8346 6.82865 19.9516 7.19065C20.0686 7.55465 19.9696 7.95265 19.6956 8.21765L15.5756 12.2027L16.5466 17.8307C16.6116 18.2057 16.4576 18.5847 16.1506 18.8087C15.9766 18.9367 15.7696 19.0007 15.5616 19.0007Z" fill="#7F828E"/>
@@ -33,7 +34,7 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
33
34
  className,
34
35
  label,
35
36
  defaultValue,
36
- value,
37
+ value: valueProp,
37
38
  placeholder,
38
39
  resize,
39
40
  startIcon,
@@ -77,19 +78,20 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
77
78
 
78
79
  const iconRef = useRef(null);
79
80
  let currentValue = '';
81
+ const [value, setValue] = useState(valueProp || defaultValue);
80
82
  const isError = !!error && !value && value !== 0;
81
83
  /* Start styled */
82
84
 
83
85
  const TextInputRoot = css`
84
- display: block;
85
- position: relative;
86
+ ${displayBlock}
87
+ ${positionRelative}
86
88
  margin-bottom: 20px;
87
89
  `;
88
90
  const TextInputIcon = css`
89
- display: flex;
91
+ ${flexRow}
90
92
  color: inherit;
91
93
  .edit-icon-pen {
92
- display: flex;
94
+ ${flexRow}
93
95
  }
94
96
  .edit-icon-confirm {
95
97
  display: none;
@@ -179,12 +181,12 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
179
181
  inputRef.current.disabled = false;
180
182
  };
181
183
 
184
+ useEffect(() => {
185
+ setValue(valueProp);
186
+ }, [valueProp]);
182
187
  useEffect(() => {
183
188
  !!refs && refs(ref);
184
-
185
- if (defaultValue !== undefined && defaultValue !== '') {
186
- currentValue = defaultValue;
187
- }
189
+ currentValue = defaultValue || "";
188
190
  }, []);
189
191
  useEffect(() => {
190
192
  if (/^(quick)?Edit/i.test(type) && !multiline) {
@@ -329,7 +331,7 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
329
331
  return jsx("div", {
330
332
  ref: ref,
331
333
  css: TextInputRoot,
332
- className: ['DGN-UI-TextInput', className].join(' ').trim(),
334
+ className: ['DGN-UI-TextInput', className].join(' ').trim().replace(/\s+/g, ' '),
333
335
  style: style,
334
336
  ...props
335
337
  }, !!label && jsx(Label, {
@@ -342,7 +344,6 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
342
344
  inputRef: inputRef,
343
345
  viewType: viewType,
344
346
  defaultValue: defaultValue,
345
- value: value,
346
347
  placeholder: placeholder,
347
348
  autoFocus: autoFocus,
348
349
  disabled: disabled,
@@ -363,7 +364,8 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
363
364
  onInput: onInput,
364
365
  onKeyDown: onKeyDown,
365
366
  onKeyUp: onKeyUp,
366
- onPaste: onPaste
367
+ onPaste: onPaste,
368
+ value: valueProp
367
369
  }), isError && jsx(HelperText, {
368
370
  disabled: disabled,
369
371
  status: status
package/global/index.js CHANGED
@@ -63,7 +63,9 @@ const globalObject = {
63
63
  max: 'Vượt quá giá trị tối đa cho phép',
64
64
  min: 'Chưa đạt giá trị tối thiểu cho phép',
65
65
  required: 'Trường này bắt buộc nhập'
66
- }
66
+ },
67
+ inputPlaceholder: "Nhập",
68
+ dropdownPlaceholder: "Chọn"
67
69
  },
68
70
  en: {
69
71
  agree: 'Agree',
@@ -127,8 +129,11 @@ const globalObject = {
127
129
  max: 'Exceeds the maximum value allowed',
128
130
  min: 'The minimum allowed value has not been reached',
129
131
  required: 'This field is required'
130
- }
131
- }
132
+ },
133
+ inputPlaceholder: "Type something",
134
+ dropdownPlaceholder: "Select"
135
+ },
136
+ delayOnInput: 500
132
137
  };
133
138
  export const getGlobal = (key, language = locale.get()) => {
134
139
  var _globalObject$languag;
@@ -147,7 +152,7 @@ export const getGlobal = (key, language = locale.get()) => {
147
152
  return result;
148
153
  }
149
154
 
150
- return (_globalObject$languag = globalObject[language]) === null || _globalObject$languag === void 0 ? void 0 : _globalObject$languag[key];
155
+ return globalObject[key] || ((_globalObject$languag = globalObject[language]) === null || _globalObject$languag === void 0 ? void 0 : _globalObject$languag[key]);
151
156
  };
152
157
  export const setGlobal = global => {
153
158
  if (global && typeof global === 'object') {
@@ -169,8 +174,8 @@ const overrideGlobal = (newGlobal, ingredient, key) => {
169
174
  overrideGlobal(newGlobalValue, rootValue, newKey);
170
175
  }
171
176
  });
172
- } else if (typeof newGlobalValue === 'string' && typeof rootValue === 'string') {
173
- ingredient[key] = newGlobalValue;
177
+ } else {
178
+ globalObject[key] = newGlobalValue;
174
179
  }
175
180
  };
176
181
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.30-beta.3",
3
+ "version": "1.3.32-beta.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",
@@ -15,7 +15,9 @@
15
15
  "production-keep-version": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish",
16
16
  "beta": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish --tag beta",
17
17
  "production": "npm run build && cp *.md dist/ && npm run version:bump --silent && npm run version:add --silent && cd dist && npm publish",
18
- "version:add": "VERSION=$(npm run version:extract --silent) && cat package.json.tmp | sed \"s/0.0.0/${VERSION}/g\" > dist/package.json",
18
+ "version:add": "run-script-os",
19
+ "version:add:windows": "cat package.json.tmp | sed \"s/0.0.0/%npm_package_version%/g\" > dist/package.json",
20
+ "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",
19
21
  "version:bump": "npm version patch --no-git-tag-version --silent",
20
22
  "version:extract": "cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'",
21
23
  "test": "echo \"Error: no test specified\" && exit 1"
package/readme.md CHANGED
@@ -38,7 +38,17 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
- ## 1.3.28
41
+ ## 1.3.31
42
+ - \[Added\]: MenuIcon - W05F0011N0000
43
+ - \[Changed\]: SYSTEM - Replace color text from string to object
44
+ - \[Fixed\]: Toggle - Manage prop checked with useState
45
+ - \[Fixed\]: Checkbox - Fix perfect pixel
46
+ - \[Fixed\]: Button, ButtonIcon - Add Event.stopPropagation()
47
+ - \[Fixed\]: Dropdown - Fix bug clear data Dropdown close DropdownBox
48
+ - \[Fixed\]: NumberInput - Fix bug compare string
49
+ - \[Fixed\]: Accordion - Fix css min-height AccordionSummary
50
+
51
+ ## 1.3.29
42
52
  - \[Added\]: Icon - Bug, Link
43
53
  - \[Added\]: MenuIcon - MHRM09N0004, MHRP29N0023
44
54
  - \[Changed\]: Accordion - Update Accordion, add expended like expend (keep prop expend), fix logic
@@ -0,0 +1,39 @@
1
+ import { useState, useRef } from 'react';
2
+
3
+ const useInput = props => {
4
+ let {
5
+ defaultValue,
6
+ valueProp,
7
+ delayOnChange,
8
+ onChange
9
+ } = props;
10
+ const [value, setValue] = useState(defaultValue || valueProp);
11
+ const timer = useRef(null);
12
+ delayOnChange = Number(delayOnChange ?? 0);
13
+
14
+ const _onChange = e => {
15
+ if (timer.current) clearTimeout(timer.current);
16
+ timer.current = setTimeout(() => {
17
+ setValue(e.target.value);
18
+
19
+ e.reset = () => {
20
+ setValue(e.target.value);
21
+ e.target.value = valueProp;
22
+ };
23
+
24
+ onChange === null || onChange === void 0 ? void 0 : onChange(e);
25
+ }, delayOnChange);
26
+ };
27
+
28
+ return {
29
+ value,
30
+ setValue,
31
+ resetState: () => setValue(value || ''),
32
+ clear: () => setValue(''),
33
+ bind: {
34
+ onChange: _onChange
35
+ }
36
+ };
37
+ };
38
+
39
+ export default useInput;