diginet-core-ui 1.3.74 → 1.3.75-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.
@@ -437,15 +437,15 @@ Avatar.propTypes = {
437
437
  /** If `true`, display remove avatar icon. */
438
438
  clearAble: PropTypes.bool,
439
439
 
440
- /**
441
- * data to display when hoverAble is true<br />
442
- * data is an object or function return a jsx element
440
+ /**
441
+ * data to display when hoverAble is true<br />
442
+ * data is an object or function return a jsx element
443
443
  */
444
444
  data: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
445
445
 
446
- /**
447
- * it is used to display the default if there is no src<br />
448
- * if undefined, will display icons available in the icons store
446
+ /**
447
+ * it is used to display the default if there is no src<br />
448
+ * if undefined, will display icons available in the icons store
449
449
  */
450
450
  defaultSrc: PropTypes.string,
451
451
 
@@ -500,19 +500,19 @@ Avatar.propTypes = {
500
500
  /** the error to show on wrong type */
501
501
  wrongTypeError: PropTypes.string,
502
502
 
503
- /**
504
- * ref methods
505
- *
506
- * * option(): Gets all UI component properties
507
- * * Returns value - object
508
- * * option(optionName): Gets the value of a single property
509
- * * @param {optionName} - string
510
- * * Returns value - any
511
- * * option(optionName, optionValue): Updates the value of a single property
512
- * * @param {optionName} - string
513
- * * @param {optionValue} - any
514
- * * option(options): Updates the values of several properties
515
- * * @param {options} - object
503
+ /**
504
+ * ref methods
505
+ *
506
+ * * option(): Gets all UI component properties
507
+ * * Returns value - object
508
+ * * option(optionName): Gets the value of a single property
509
+ * * @param {optionName} - string
510
+ * * Returns value - any
511
+ * * option(optionName, optionValue): Updates the value of a single property
512
+ * * @param {optionName} - string
513
+ * * @param {optionValue} - any
514
+ * * option(options): Updates the values of several properties
515
+ * * @param {options} - object
516
516
  */
517
517
  reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
518
518
  current: PropTypes.instanceOf(Element)
@@ -1774,12 +1774,14 @@ Attachment.defaultProps = {
1774
1774
  maxFile: Infinity,
1775
1775
  multiple: true,
1776
1776
  readOnly: false,
1777
+ style: {},
1777
1778
  uploadErrorInfo: {
1778
1779
  maxFile: getGlobal(['errorDefault', 'maxFile']),
1779
1780
  maxSize: getGlobal(['errorDefault', 'maxSize']),
1780
1781
  fileType: getGlobal(['errorDefault', 'fileType']),
1781
1782
  existingFile: getGlobal(['errorDefault', 'existingFile'])
1782
- }
1783
+ },
1784
+ viewType: 'detail'
1783
1785
  };
1784
1786
  Attachment.propTypes = {
1785
1787
  /** File types that can be accepted. */
@@ -1791,17 +1793,17 @@ Attachment.propTypes = {
1791
1793
  /** Class for component. */
1792
1794
  className: PropTypes.string,
1793
1795
 
1794
- /** List attachment:<br />
1795
- * [{<br />
1796
- * &nbsp;&nbsp;&nbsp;&nbsp;"AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
1797
- * &nbsp;&nbsp;&nbsp;&nbsp;"URL": "https://apricot.diginet.com.vn/cdn-dev/file/8a07bee1eeff17a14eee.jpg?path=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxlUGF0aCI6Ii8yMDIwLzA4LzQ0YjNhYjQ4LTMwNGQtNDQ3NC05ZDk0LWNkNGVlMDQwOGNlMy5qcGciLCJmaWxlTmFtZSI6IjhhMDdiZWUxZWVmZjE3YTE0ZWVlLmpwZyIsImZpbGVTaXplIjoyNDg4MzcsImZpbGVUeXBlIjoiaW1hZ2UvanBlZyIsImlhdCI6MTU5ODI0NDMwMiwiZXhwIjo4Nzk5ODI0NDMwMn0.fow6O5fp2z3vieA9gom5RRwQ7xxwBx9_7X2Fe8T2YI0",<br />
1798
- * &nbsp;&nbsp;&nbsp;&nbsp;"FileName": "8a07bee1eeff17a14eee.jpg",<br />
1799
- * &nbsp;&nbsp;&nbsp;&nbsp;"FileSize": 248837,<br />
1800
- * &nbsp;&nbsp;&nbsp;&nbsp;"KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
1801
- * &nbsp;&nbsp;&nbsp;&nbsp;"CreateUserID": "LEMONADMIN",<br />
1802
- * &nbsp;&nbsp;&nbsp;&nbsp;"CreateDate": "2020-08-24T11:54:04.307Z",<br />
1803
- * &nbsp;&nbsp;&nbsp;&nbsp;"UserName": "Quản trị hệ thống"<br />
1804
- * }, ...]
1796
+ /** List attachment:<br />
1797
+ * [{<br />
1798
+ * &nbsp;&nbsp;&nbsp;&nbsp;"AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
1799
+ * &nbsp;&nbsp;&nbsp;&nbsp;"URL": "https://apricot.diginet.com.vn/cdn-dev/file/8a07bee1eeff17a14eee.jpg?path=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxlUGF0aCI6Ii8yMDIwLzA4LzQ0YjNhYjQ4LTMwNGQtNDQ3NC05ZDk0LWNkNGVlMDQwOGNlMy5qcGciLCJmaWxlTmFtZSI6IjhhMDdiZWUxZWVmZjE3YTE0ZWVlLmpwZyIsImZpbGVTaXplIjoyNDg4MzcsImZpbGVUeXBlIjoiaW1hZ2UvanBlZyIsImlhdCI6MTU5ODI0NDMwMiwiZXhwIjo4Nzk5ODI0NDMwMn0.fow6O5fp2z3vieA9gom5RRwQ7xxwBx9_7X2Fe8T2YI0",<br />
1800
+ * &nbsp;&nbsp;&nbsp;&nbsp;"FileName": "8a07bee1eeff17a14eee.jpg",<br />
1801
+ * &nbsp;&nbsp;&nbsp;&nbsp;"FileSize": 248837,<br />
1802
+ * &nbsp;&nbsp;&nbsp;&nbsp;"KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
1803
+ * &nbsp;&nbsp;&nbsp;&nbsp;"CreateUserID": "LEMONADMIN",<br />
1804
+ * &nbsp;&nbsp;&nbsp;&nbsp;"CreateDate": "2020-08-24T11:54:04.307Z",<br />
1805
+ * &nbsp;&nbsp;&nbsp;&nbsp;"UserName": "Quản trị hệ thống"<br />
1806
+ * }, ...]
1805
1807
  */
1806
1808
  data: PropTypes.array,
1807
1809
 
@@ -1844,16 +1846,16 @@ Attachment.propTypes = {
1844
1846
  /** Download attached event, if not it will use default. */
1845
1847
  onDownload: PropTypes.func,
1846
1848
 
1847
- /**
1848
- * event when removed file(s)
1849
- *
1850
- * return data: {<br/>
1851
- * &nbsp;&nbsp;&nbsp;&nbsp;attached: [Files] (insist old and all new files )<br/>
1852
- * &nbsp;&nbsp;&nbsp;&nbsp;allNewAttached: [Files]<br/>
1853
- * &nbsp;&nbsp;&nbsp;&nbsp;oldAttached: [Files]<br/>
1854
- * &nbsp;&nbsp;&nbsp;&nbsp;removedAttached: [Files]<br/>
1855
- * &nbsp;&nbsp;&nbsp;&nbsp;element: [NodeList (just removed)]<br/>
1856
- * }
1849
+ /**
1850
+ * event when removed file(s)
1851
+ *
1852
+ * return data: {<br/>
1853
+ * &nbsp;&nbsp;&nbsp;&nbsp;attached: [Files] (insist old and all new files )<br/>
1854
+ * &nbsp;&nbsp;&nbsp;&nbsp;allNewAttached: [Files]<br/>
1855
+ * &nbsp;&nbsp;&nbsp;&nbsp;oldAttached: [Files]<br/>
1856
+ * &nbsp;&nbsp;&nbsp;&nbsp;removedAttached: [Files]<br/>
1857
+ * &nbsp;&nbsp;&nbsp;&nbsp;element: [NodeList (just removed)]<br/>
1858
+ * }
1857
1859
  */
1858
1860
  onRemove: PropTypes.func,
1859
1861
 
@@ -5,8 +5,8 @@ import { css, jsx } from '@emotion/core';
5
5
  import PropTypes from 'prop-types';
6
6
  import { forwardRef, memo, useEffect, useRef, useState, useImperativeHandle, Fragment } from 'react';
7
7
  import { Typography } from '../..';
8
- import { alignCenter, alignStart, borderBox, cursorPointer, displayBlock, flexRow, positionAbsolute, positionRelative, cursorNoDrop, parseWidthHeight } from '../../../styles/general';
9
- import { randomString } from '../../../utils';
8
+ import { alignCenter, alignStart, borderBox, cursorPointer, displayBlock, flexRow, positionAbsolute, positionRelative, cursorNoDrop, parseWidthHeight, border } from '../../../styles/general';
9
+ import { classNames, randomString, refType as ref } from '../../../utils';
10
10
  import { color as colors } from '../../../styles/colors';
11
11
  import theme from '../../../theme/settings';
12
12
  const {
@@ -29,26 +29,27 @@ const {
29
29
  } = theme;
30
30
  const padding = spacing(0.75);
31
31
  const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
32
- id,
32
+ action = {},
33
+ checked,
34
+ children,
33
35
  className,
34
- disabled,
35
- readOnly,
36
- name,
37
- label,
38
36
  color,
39
- value,
40
- checked,
41
37
  defaultChecked,
42
38
  determinate,
43
- onChange,
44
- inputRef,
45
- children,
46
- inputProps,
39
+ disabled,
47
40
  forTreeView,
48
- width,
41
+ id,
42
+ inputProps,
43
+ inputRef,
44
+ label,
49
45
  labelProps,
50
- stopPropagation,
46
+ name,
47
+ onChange,
48
+ readOnly,
51
49
  required,
50
+ stopPropagation,
51
+ value,
52
+ width,
52
53
  ...props
53
54
  }, reference) => {
54
55
  if (!inputRef) {
@@ -82,11 +83,11 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
82
83
  }
83
84
 
84
85
  setChecked(checked !== undefined ? Boolean(checked) : !checkedState);
86
+ const currentInputRef = inputRef.current;
87
+ if (!forTreeView) inputRef.current.checked = !checkedState;
85
88
  const e = {
86
89
  value: forTreeView ? oldLogicChecked : !checkedState,
87
- target: forTreeView ? inputRef.current : { ...inputRef.current,
88
- checked: !checkedState
89
- }
90
+ target: currentInputRef
90
91
  };
91
92
  if (onChange) onChange(e, checkedState);
92
93
  };
@@ -102,10 +103,12 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
102
103
  }, [checked]);
103
104
  useImperativeHandle(reference, () => {
104
105
  const currentRef = ref.current || {};
106
+ currentRef.element = ref.current;
105
107
  const _instance = {
106
108
  determinate: determinate,
107
109
  setChecked: setChecked,
108
- getChecked: () => checkedState
110
+ getChecked: () => checkedState,
111
+ ...action
109
112
  }; // methods
110
113
 
111
114
  _instance.__proto__ = {}; // hidden methods
@@ -121,17 +124,17 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
121
124
  return jsx("div", {
122
125
  id: 'DGN-UI-Checkbox-' + id.replace('DGN-UI-', ''),
123
126
  css: CheckboxContainerCSS,
124
- className: ['DGN-UI-Checkbox', className].join(' ').trim().replace(/\s+/g, ' '),
127
+ className: classNames('DGN-UI-Checkbox', className),
125
128
  ref: ref,
126
129
  ...props,
127
130
  onClick: handleChange
128
131
  }, jsx("div", {
129
132
  css: CheckBoxRootCSS,
130
- className: ['DGN-UI-Checkbox-Root', disabled ? 'disabled' : readOnly ? 'read-only' : ''].join(' ').trim().replace(/\s+/g, ' ')
133
+ className: classNames('DGN-UI-Checkbox-Root', disabled && 'disabled', readOnly && 'read-only')
131
134
  }, jsx("input", {
132
135
  value: value,
133
136
  ...inputProps,
134
- className: [determinate ? 'determinate' : 'indeterminate', inputProps.className || ''].join(' ').trim().replace(/\s+/g, ' '),
137
+ className: classNames(determinate ? 'determinate' : 'indeterminate', inputProps === null || inputProps === void 0 ? void 0 : inputProps.className),
135
138
  readOnly: readOnly || inputProps.readOnly,
136
139
  disabled: disabled || inputProps.disabled,
137
140
  ref: inputRef,
@@ -145,7 +148,7 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
145
148
  }), jsx("label", {
146
149
  css: CheckBoxLabelCSS
147
150
  }, jsx("span", {
148
- className: [determinate ? 'determinate' : 'indeterminate', readOnly ? 'read-only' : '', disabled ? 'disabled' : ''].join(' '),
151
+ className: classNames(determinate ? 'determinate' : 'indeterminate', readOnly && 'read-only', disabled && 'disabled'),
149
152
  css: _CheckBoxSquareCSS
150
153
  }), (children || label) && jsx(Typography, {
151
154
  type: 'p1',
@@ -167,35 +170,33 @@ const CheckBoxSquareCSS = (width, clMain) => css`
167
170
  ${cursorPointer};
168
171
  ${borderBox};
169
172
  ${parseWidthHeight(width, width)};
173
+ ${border(2, rest)};
170
174
  min-width: ${width};
171
175
  min-height: ${width};
172
176
  background-color: ${white};
173
- border: 2px solid ${rest};
174
177
  border-radius: 2px;
175
178
  margin: ${padding}px;
176
179
  &.determinate {
177
180
  &::after {
178
181
  ${displayBlock};
179
182
  ${positionAbsolute};
183
+ ${parseWidthHeight(12.6, 7)};
180
184
  content: '';
181
- height: 7px;
182
185
  left: 50%;
183
186
  top: 43%;
184
187
  transform: translate(-50%, -50%) scale(0) rotate(45deg);
185
188
  transition: transform 0.3s;
186
- width: 12.6px;
187
189
  }
188
190
  }
189
191
  &.indeterminate {
190
192
  &::after {
191
193
  ${flexRow};
192
194
  ${positionAbsolute};
195
+ ${parseWidthHeight(10, 2)};
193
196
  content: '';
194
197
  background-color: white;
195
198
  left: 2px;
196
199
  top: 6px;
197
- width: 10px;
198
- height: 2px;
199
200
  transition: transform 0.3s;
200
201
  transform: scale(0);
201
202
  }
@@ -278,17 +279,17 @@ const CheckboxContainerCSS = css`
278
279
  width: fit-content;
279
280
  `;
280
281
  Checkbox.defaultProps = {
281
- label: '',
282
282
  className: '',
283
283
  color: 'primary',
284
- disabled: false,
285
- readOnly: false,
286
284
  defaultChecked: false,
287
285
  determinate: true,
286
+ disabled: false,
288
287
  inputProps: {},
288
+ label: '',
289
289
  labelProps: {},
290
- width: 18,
291
- stopPropagation: true
290
+ readOnly: false,
291
+ stopPropagation: true,
292
+ width: 18
292
293
  };
293
294
  Checkbox.propTypes = {
294
295
  /** If `true`, the component is checked. */
@@ -315,6 +316,9 @@ Checkbox.propTypes = {
315
316
  /** [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element. */
316
317
  inputProps: PropTypes.object,
317
318
 
319
+ /** Pass a ref to the input element. */
320
+ inputRef: ref,
321
+
318
322
  /** The name of the Radio is displayed on the interface. */
319
323
  label: PropTypes.string,
320
324
 
@@ -334,13 +338,13 @@ Checkbox.propTypes = {
334
338
  /** If `true`, the component is readonly. */
335
339
  readOnly: PropTypes.bool,
336
340
 
337
- /** The width of checkbox. */
338
- width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
341
+ /** If `true`, the label will indicate that the checkbox is required. */
342
+ required: PropTypes.bool,
339
343
 
340
344
  /** The value of input */
341
345
  value: PropTypes.any,
342
346
 
343
- /** If `true`, the label will indicate that the checkbox is required. */
344
- required: PropTypes.bool
347
+ /** The width of checkbox. */
348
+ width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
345
349
  };
346
350
  export default Checkbox;