diginet-core-ui 1.3.69-beta.9 → 1.3.70-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.
@@ -5,6 +5,7 @@ import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { jsx } from '@emotion/core';
7
7
  import OptionWrapper from '../others/option-wrapper';
8
+ import { classNames } from '../../utils';
8
9
  const CardBody = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
9
10
  action = {},
10
11
  children,
@@ -30,7 +31,7 @@ const CardBody = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
30
31
  id: id,
31
32
  ref: ref,
32
33
  style: style,
33
- className: [`DGN-UI-Card-Body`, className].join(' ').trim().replace(/\s+/g, ' ')
34
+ className: classNames(`DGN-UI-Card-Body`, className)
34
35
  }, children);
35
36
  }, [children, className, id, style, title]);
36
37
  }));
@@ -5,6 +5,7 @@ import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { jsx } from '@emotion/core';
7
7
  import OptionWrapper from '../others/option-wrapper';
8
+ import { classNames } from '../../utils';
8
9
  const CardExtra = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
9
10
  action = {},
10
11
  children,
@@ -30,7 +31,7 @@ const CardExtra = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
30
31
  id: id,
31
32
  ref: ref,
32
33
  style: style,
33
- className: [`DGN-UI-Card-Extra`, className].join(' ').trim().replace(/\s+/g, ' ')
34
+ className: classNames(`DGN-UI-Card-Extra`, className)
34
35
  }, children);
35
36
  }, [children, className, id, style, title]);
36
37
  }));
@@ -5,6 +5,7 @@ import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { jsx } from '@emotion/core';
7
7
  import OptionWrapper from '../others/option-wrapper';
8
+ import { classNames } from '../../utils';
8
9
  const CardFooter = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
9
10
  action = {},
10
11
  children,
@@ -30,7 +31,7 @@ const CardFooter = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
30
31
  id: id,
31
32
  ref: ref,
32
33
  style: style,
33
- className: [`DGN-UI-Card-Footer`, className].join(' ').trim().replace(/\s+/g, ' ')
34
+ className: classNames(`DGN-UI-Card-Footer`, className)
34
35
  }, children);
35
36
  }, [children, className, id, style, title]);
36
37
  }));
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
6
6
  import { jsx } from '@emotion/core';
7
7
  import OptionWrapper from '../others/option-wrapper';
8
8
  import Typography from '../typography';
9
+ import { classNames } from '../../utils';
9
10
  const CardHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
10
11
  action = {},
11
12
  children,
@@ -31,7 +32,7 @@ const CardHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
31
32
  id: id,
32
33
  ref: ref,
33
34
  style: style,
34
- className: [`DGN-UI-Card-Header`, className].join(' ').trim().replace(/\s+/g, ' ')
35
+ className: classNames(`DGN-UI-Card-Header`, className)
35
36
  }, children || jsx(Typography, {
36
37
  type: 'h3'
37
38
  }, title));
@@ -11,6 +11,7 @@ import CardHeader from './header';
11
11
  import { CardFooter } from './footer';
12
12
  import { CardBody } from './body';
13
13
  import { getColor } from '../../styles/utils';
14
+ import { classNames } from '../../utils';
14
15
  const {
15
16
  colors: {
16
17
  system: {
@@ -29,6 +30,7 @@ const Card = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
29
30
  children,
30
31
  className,
31
32
  dividerColor,
33
+ direction,
32
34
  footer,
33
35
  footerDivider,
34
36
  footerStyle,
@@ -43,7 +45,7 @@ const Card = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
43
45
  }, reference) => {
44
46
  const ref = useRef(null);
45
47
 
46
- const _CardCSS = CardCSS(width, height, headerDivider, footerDivider, dividerColor);
48
+ const _CardCSS = CardCSS(width, height, headerDivider, footerDivider, dividerColor, direction);
47
49
 
48
50
  useImperativeHandle(reference, () => {
49
51
  const currentRef = ref.current || {};
@@ -57,16 +59,16 @@ const Card = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
57
59
  return currentRef;
58
60
  });
59
61
  const head = header || title ? jsx(CardHeader, {
60
- className: (className === null || className === void 0 ? void 0 : className.header) || '',
62
+ className: classNames(className === null || className === void 0 ? void 0 : className.header),
61
63
  style: headerStyle,
62
64
  title: title
63
65
  }, header) : null;
64
66
  const foot = footer ? jsx(CardFooter, {
65
- className: (className === null || className === void 0 ? void 0 : className.footer) || '',
67
+ className: classNames(className === null || className === void 0 ? void 0 : className.footer),
66
68
  style: footerStyle
67
69
  }, footer) : null;
68
70
  const body = bodyProp || children && (head || foot) ? jsx(CardBody, {
69
- className: (className === null || className === void 0 ? void 0 : className.body) || '',
71
+ className: classNames(className === null || className === void 0 ? void 0 : className.body),
70
72
  style: bodyStyle
71
73
  }, bodyProp || children) : null;
72
74
  return useMemo(() => {
@@ -75,13 +77,13 @@ const Card = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
75
77
  ref: ref,
76
78
  css: _CardCSS,
77
79
  style: style,
78
- className: [`DGN-UI-Card`, (className === null || className === void 0 ? void 0 : className.container) || className].join(' ').trim().replace(/\s+/g, ' ')
80
+ className: classNames(`DGN-UI-Card`, (className === null || className === void 0 ? void 0 : className.container) || className)
79
81
  }, head, body || children, foot);
80
- }, [bodyProp, bodyStyle, children, className, dividerColor, footer, footerDivider, footerStyle, header, headerDivider, headerStyle, height, id, style, title, width]);
82
+ }, [bodyProp, bodyStyle, children, className, dividerColor, direction, footer, footerDivider, footerStyle, header, headerDivider, headerStyle, height, id, style, title, width]);
81
83
  }));
82
84
 
83
- const CardCSS = (width, height, headerDivider, footerDivider, dividerColor) => css`
84
- ${flexCol};
85
+ const CardCSS = (width, height, headerDivider, footerDivider, dividerColor, direction) => css`
86
+ ${direction === 'vertical' ? flexCol : flexRow};
85
87
  ${positionRelative};
86
88
  ${borderBox};
87
89
  ${borderRadius4px};
@@ -140,6 +142,7 @@ Card.defaultProps = {
140
142
  bodyStyle: {},
141
143
  className: '',
142
144
  dividerColor: category,
145
+ direction: 'vertical',
143
146
  footerDivider: false,
144
147
  footerStyle: {},
145
148
  headerDivider: true,
@@ -3,7 +3,7 @@
3
3
  /** @jsx jsx */
4
4
  import { css, jsx } from '@emotion/core';
5
5
  import PropTypes from 'prop-types';
6
- import { forwardRef, memo, useEffect, useRef, useState, useImperativeHandle } from 'react';
6
+ import React, { forwardRef, memo, useEffect, useRef, useState, useImperativeHandle } from 'react';
7
7
  import { Typography } from '../..';
8
8
  import { alignCenter, alignStart, borderBox, cursorPointer, displayBlock, flexRow, positionAbsolute, positionRelative, cursorNoDrop, parseWidthHeight } from '../../../styles/general';
9
9
  import { randomString } from '../../../utils';
@@ -20,7 +20,10 @@ const {
20
20
  pressed: clFillPressed
21
21
  },
22
22
  disabled: clDisabled,
23
- formal2: clFormal2
23
+ formal2: clFormal2,
24
+ semantic: {
25
+ danger: clDanger
26
+ }
24
27
  },
25
28
  spacing
26
29
  } = theme;
@@ -45,6 +48,7 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
45
48
  labelProps,
46
49
  width,
47
50
  stopPropagation,
51
+ required,
48
52
  ...props
49
53
  }, reference) => {
50
54
  if (!inputRef) {
@@ -150,7 +154,11 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
150
154
  },
151
155
  color: disabled ? clDisabled : '',
152
156
  ...labelProps
153
- }, children || label))));
157
+ }, jsx(React.Fragment, null, children || label, required && jsx("span", {
158
+ style: {
159
+ color: disabled ? clDisabled : clDanger
160
+ }
161
+ }, "*"))))));
154
162
  }));
155
163
 
156
164
  const CheckBoxSquareCSS = (width, clMain) => css`
@@ -316,10 +324,10 @@ Checkbox.propTypes = {
316
324
  /** The name of the Checkbox corresponds to the label displayed on the interface. */
317
325
  name: PropTypes.string,
318
326
 
319
- /**
320
- * Callback fired when the state is changed.
321
- *
322
- * You can pull out the new checked state by accessing `event.value` or `event.target.checked` (boolean).
327
+ /**
328
+ * Callback fired when the state is changed.
329
+ *
330
+ * You can pull out the new checked state by accessing `event.value` or `event.target.checked` (boolean).
323
331
  */
324
332
  onChange: PropTypes.func,
325
333
 
@@ -330,6 +338,9 @@ Checkbox.propTypes = {
330
338
  width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
331
339
 
332
340
  /** The value of input */
333
- value: PropTypes.any
341
+ value: PropTypes.any,
342
+
343
+ /** If `true`, the label will indicate that the checkbox is required. */
344
+ required: PropTypes.bool
334
345
  };
335
346
  export default Checkbox;
@@ -15,9 +15,6 @@ const {
15
15
  system: {
16
16
  disabled: systemDisabled
17
17
  },
18
- semantic: {
19
- danger
20
- },
21
18
  text: {
22
19
  normal_label
23
20
  }
@@ -65,15 +62,13 @@ const Label = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
65
62
  type: type,
66
63
  className: classNames('DGN-UI-Label', className, readOnly && 'read-only', disabled && 'disabled'),
67
64
  ...props
68
- }, children), required && jsx("span", {
69
- className: 'required'
70
- }, " *")), [children, className, color, disabled, hoverTooltip, id, lineClamp, readOnly, required, type, props]);
65
+ }, children), !required && jsx(Typography, {
66
+ type: type,
67
+ color: 'danger'
68
+ }, "*")), [children, className, color, disabled, hoverTooltip, id, lineClamp, readOnly, required, type, props]);
71
69
  }));
72
70
  const LabelContainerCSS = css`
73
71
  ${flexRow};
74
- .required {
75
- color: ${danger};
76
- }
77
72
  & + .DGN-UI-InputBase.outlined {
78
73
  margin-top: ${spacing([0.5])};
79
74
  }
@@ -550,10 +550,10 @@ MoneyInput.propTypes = {
550
550
  /** style inline of input in MoneyInput component */
551
551
  inputStyle: PropTypes.object,
552
552
 
553
- /** validation value, argument can:<br/>
554
- * * string: the validation rule. Example required.<br/>
555
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
556
- * * array: the validation rule list, insist object/string
553
+ /** validation value, argument can:<br/>
554
+ * * string: the validation rule. Example required.<br/>
555
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
556
+ * * array: the validation rule list, insist object/string
557
557
  */
558
558
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
559
559
 
@@ -566,13 +566,13 @@ MoneyInput.propTypes = {
566
566
  /** on input function */
567
567
  onInput: PropTypes.func,
568
568
 
569
- /**
570
- * on change function, return an object:<br/>
571
- * {<br/>
572
- * &nbsp;&nbsp;&nbsp;&nbsp;value: is a number or null value<br/>
573
- * &nbsp;&nbsp;&nbsp;&nbsp;target.value: value of input<br/>
574
- * &nbsp;&nbsp;&nbsp;&nbsp;...element<br/>
575
- * }
569
+ /**
570
+ * on change function, return an object:<br/>
571
+ * {<br/>
572
+ * &nbsp;&nbsp;&nbsp;&nbsp;value: is a number or null value<br/>
573
+ * &nbsp;&nbsp;&nbsp;&nbsp;target.value: value of input<br/>
574
+ * &nbsp;&nbsp;&nbsp;&nbsp;...element<br/>
575
+ * }
576
576
  */
577
577
  onChange: PropTypes.func,
578
578
 
@@ -80,13 +80,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
80
80
  const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
81
81
 
82
82
  if (valueProps || valueProps === 0) valueProps = clamp(valueProps, min, max);
83
- /**
84
- * Convert number to format money
85
- * @param vl {number} - value
86
- * @type {function(*): number}
87
- * @return {string}
88
- * @example 1200300.123 => 1,200,300.123
89
- * @example 1200300,123 => 1.200.300,123
83
+ /**
84
+ * Convert number to format money
85
+ * @param vl {number} - value
86
+ * @type {function(*): number}
87
+ * @return {string}
88
+ * @example 1200300.123 => 1,200,300.123
89
+ * @example 1200300,123 => 1.200.300,123
90
90
  */
91
91
 
92
92
  const parseNumberToMoney = useCallback((vl, isNumber) => {
@@ -120,13 +120,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
120
120
 
121
121
  return number;
122
122
  }, [decimalSymbol, max, value]);
123
- /**
124
- * Convert money to format number
125
- * @param vl {string} - value
126
- * @type {function(*): number}
127
- * @return {number}
128
- * @example 1,200,300.123 => 1200300.123
129
- * @example 1.200.300,123 => 1200300.123
123
+ /**
124
+ * Convert money to format number
125
+ * @param vl {string} - value
126
+ * @type {function(*): number}
127
+ * @return {number}
128
+ * @example 1,200,300.123 => 1200300.123
129
+ * @example 1.200.300,123 => 1200300.123
130
130
  */
131
131
 
132
132
  const convertMoneyToNumber = useCallback((vl, isNumber) => {
@@ -398,10 +398,10 @@ NumberInput.propTypes = {
398
398
  /** style inline of input in NumberInput component */
399
399
  inputStyle: PropTypes.object,
400
400
 
401
- /** validation value, argument can:<br/>
402
- * * string: the validation rule. Example required.<br/>
403
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
404
- * * array: the validation rule list, insist object/string
401
+ /** validation value, argument can:<br/>
402
+ * * string: the validation rule. Example required.<br/>
403
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
404
+ * * array: the validation rule list, insist object/string
405
405
  */
406
406
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
407
407
 
@@ -398,13 +398,13 @@ PhoneInput.propTypes = {
398
398
  /** on input function */
399
399
  onInput: PropTypes.func,
400
400
 
401
- /**
402
- * on change function. Return a object, example:<br/>
403
- * {<br/>
404
- * &nbsp;&nbsp;&nbsp;&nbsp;target: {value: "(+84) 123 456 789", ...}<br/>
405
- * &nbsp;&nbsp;&nbsp;&nbsp;value: 0123456789<br/>
406
- * &nbsp;&nbsp;&nbsp;&nbsp;countryCode: 84<br/>
407
- * }
401
+ /**
402
+ * on change function. Return a object, example:<br/>
403
+ * {<br/>
404
+ * &nbsp;&nbsp;&nbsp;&nbsp;target: {value: "(+84) 123 456 789", ...}<br/>
405
+ * &nbsp;&nbsp;&nbsp;&nbsp;value: 0123456789<br/>
406
+ * &nbsp;&nbsp;&nbsp;&nbsp;countryCode: 84<br/>
407
+ * }
408
408
  */
409
409
  onChange: PropTypes.func,
410
410
 
@@ -3,7 +3,7 @@
3
3
  /** @jsx jsx */
4
4
  import { css, jsx } from '@emotion/core';
5
5
  import PropTypes from 'prop-types';
6
- import { forwardRef, memo, useState, useRef, useEffect, useMemo } from 'react';
6
+ import React, { forwardRef, memo, useState, useRef, useEffect, useMemo } from 'react';
7
7
  import theme from '../../../theme/settings';
8
8
  import { randomString } from '../../../utils';
9
9
  import Typography from './../../typography';
@@ -18,7 +18,10 @@ const {
18
18
  active: clSystemActive,
19
19
  rest: clSystemRest
20
20
  },
21
- disabled: clDisabled
21
+ disabled: clDisabled,
22
+ semantic: {
23
+ danger: clDanger
24
+ }
22
25
  }
23
26
  } = theme;
24
27
  const Radio = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
@@ -36,6 +39,7 @@ const Radio = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
36
39
  inputRef,
37
40
  inputProps,
38
41
  labelProps,
42
+ required,
39
43
  ...props
40
44
  }, ref) => {
41
45
  if (!inputRef) {
@@ -94,7 +98,11 @@ const Radio = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
94
98
  color: disabled ? clDisabled : '',
95
99
  type: 'p1',
96
100
  ...labelProps
97
- }, label !== null && label !== void 0 ? label : value)));
101
+ }, jsx(React.Fragment, null, label !== null && label !== void 0 ? label : value, required && jsx("span", {
102
+ style: {
103
+ color: disabled ? clDisabled : clDanger
104
+ }
105
+ }, "*")))));
98
106
  }, [disabled, onChange, readOnly, checkedState]);
99
107
  }));
100
108
  const formCheckCSS = css`
@@ -199,11 +207,11 @@ Radio.propTypes = {
199
207
  /** Props for input. */
200
208
  inputProps: PropTypes.object,
201
209
 
202
- /** Callback fired when the state is changed.
203
- *
204
- * @param {object} event The event source of the callback.
205
- * You can pull out the new value by accessing `event.target.value` (string).
206
- * You can pull out the new checked state by accessing `event.target.checked` (boolean).
210
+ /** Callback fired when the state is changed.
211
+ *
212
+ * @param {object} event The event source of the callback.
213
+ * You can pull out the new value by accessing `event.target.value` (string).
214
+ * You can pull out the new checked state by accessing `event.target.checked` (boolean).
207
215
  * */
208
216
  onChange: PropTypes.func,
209
217
 
@@ -211,6 +219,9 @@ Radio.propTypes = {
211
219
  readOnly: PropTypes.bool,
212
220
 
213
221
  /** Props for Typography of label. */
214
- labelProps: PropTypes.object
222
+ labelProps: PropTypes.object,
223
+
224
+ /** If `true`, the label will indicate that the Radio is required. */
225
+ required: PropTypes.bool
215
226
  };
216
227
  export default Radio;
@@ -430,10 +430,10 @@ TextInput.propTypes = {
430
430
  /** 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). */
431
431
  type: PropTypes.oneOf(['inform', 'edit', 'quickEdit', 'text', 'number', 'password']),
432
432
 
433
- /** Validation value, argument can:<br/>
434
- * * string: the validation rule. Example required.<br/>
435
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
436
- * * array: the validation rule list, insist object/string
433
+ /** Validation value, argument can:<br/>
434
+ * * string: the validation rule. Example required.<br/>
435
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
436
+ * * array: the validation rule list, insist object/string
437
437
  */
438
438
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
439
439
 
@@ -3,7 +3,7 @@
3
3
  /** @jsx jsx */
4
4
  import { css, jsx } from '@emotion/core';
5
5
  import PropTypes from 'prop-types';
6
- import { forwardRef, memo, useEffect, useMemo, useRef, useState } from 'react';
6
+ import React, { forwardRef, memo, useEffect, useMemo, useRef, useState } from 'react';
7
7
  import theme from '../../../theme/settings';
8
8
  import generateRandom from '../../../utils/randomString';
9
9
  import Typography from '../../typography';
@@ -23,7 +23,10 @@ const {
23
23
  primary: clPrimary,
24
24
  hover: clHover,
25
25
  disabled: clDisabled,
26
- white: clWhite
26
+ white: clWhite,
27
+ semantic: {
28
+ danger: clDanger
29
+ }
27
30
  },
28
31
  spacing
29
32
  } = theme;
@@ -42,6 +45,7 @@ const Toggle = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
42
45
  inputProps,
43
46
  lineClamp,
44
47
  hoverTooltip,
48
+ required,
45
49
  ...props
46
50
  }, ref) => {
47
51
  if (!inputRef) {
@@ -180,7 +184,11 @@ const Toggle = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
180
184
  hoverTooltip: hoverTooltip,
181
185
  lineClamp: lineClamp || null,
182
186
  mapping: 'label'
183
- }, label))), [disabled, onChange, checkedState, readOnly]);
187
+ }, jsx(React.Fragment, null, label, required && jsx("span", {
188
+ style: {
189
+ color: disabled ? clDisabled : clDanger
190
+ }
191
+ }, "*"))))), [disabled, onChange, checkedState, readOnly]);
184
192
  }));
185
193
  Toggle.defaultProps = {
186
194
  disabled: false,
@@ -191,7 +199,8 @@ Toggle.defaultProps = {
191
199
  id: '',
192
200
  width: 40,
193
201
  height: 20,
194
- lineClamp: null
202
+ lineClamp: null,
203
+ required: false
195
204
  };
196
205
  Toggle.propTypes = {
197
206
  /** * If `true`, the component is disabled. */
@@ -230,11 +239,14 @@ Toggle.propTypes = {
230
239
  /** Shows tooltip containing Label on hover */
231
240
  hoverTooltip: PropTypes.bool,
232
241
 
233
- /** * Callback fired when the state is changed.
234
- *
235
- * @param {object} event The event source of the callback.
236
- * You can pull out the new checked state by accessing `event.target.checked` (boolean).
242
+ /** * Callback fired when the state is changed.
243
+ *
244
+ * @param {object} event The event source of the callback.
245
+ * You can pull out the new checked state by accessing `event.target.checked` (boolean).
237
246
  */
238
- onChange: PropTypes.func
247
+ onChange: PropTypes.func,
248
+
249
+ /** If `true`, the label will indicate that the checkbox is required. */
250
+ required: PropTypes.bool
239
251
  };
240
252
  export default Toggle;
@@ -38,8 +38,8 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
38
38
  const rowSpacing = rowSpacingProp || spacing;
39
39
  const columnSpacing = columnSpacingProp || spacing;
40
40
  const columns = container ? columnsProp : columnsContext;
41
- const topSpacing = topSpacingProp || rowSpacing;
42
- const leftSpacing = leftSpacingProp || columnSpacing;
41
+ const topSpacing = topSpacingProp !== null && topSpacingProp !== void 0 ? topSpacingProp : rowSpacing;
42
+ const leftSpacing = leftSpacingProp !== null && leftSpacingProp !== void 0 ? leftSpacingProp : columnSpacing;
43
43
  const ref = useRef(null);
44
44
 
45
45
  const _GridCSS = GridCSS(direction, zeroMinWidth, container, item, wrap);
@@ -13,6 +13,9 @@ const {
13
13
  colors: {
14
14
  system: {
15
15
  white
16
+ },
17
+ fill: {
18
+ tooltip: fillTooltip
16
19
  }
17
20
  },
18
21
  typography: {
@@ -129,6 +132,7 @@ const getDirectionPopover = direction => {
129
132
  }
130
133
  };
131
134
 
135
+ const backgroundMap = new Map([['light', white], ['dark', fillTooltip]]);
132
136
  const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
133
137
  action = {},
134
138
  anchor,
@@ -531,8 +535,9 @@ const PopoverContainerCSS = (bgColor, width, height) => css`
531
535
  transition: opacity 0.3s ease;
532
536
  pointer-events: initial;
533
537
  opacity: 0;
534
- background-color: ${bgColor};
538
+ background-color: ${backgroundMap.get(bgColor) || bgColor};
535
539
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
540
+ ${bgColor === 'dark' && `color: ${white};`}
536
541
  `;
537
542
 
538
543
  const PopoverArrowCSS = bgColor => css`
@@ -541,7 +546,7 @@ const PopoverArrowCSS = bgColor => css`
541
546
  ${parseWidthHeight(0)};
542
547
  border-left: 6px solid transparent;
543
548
  border-right: 6px solid transparent;
544
- border-bottom: 6px solid ${bgColor};
549
+ border-bottom: 6px solid ${backgroundMap.get(bgColor) || bgColor};
545
550
  `;
546
551
 
547
552
  Popover.defaultProps = {
@@ -550,7 +555,7 @@ Popover.defaultProps = {
550
555
  horizontal: 'center'
551
556
  },
552
557
  arrow: false,
553
- bgColor: white,
558
+ bgColor: 'light',
554
559
  className: '',
555
560
  clickOutsideToClose: true,
556
561
  fullScreen: false,
@@ -576,9 +581,9 @@ Popover.propTypes = {
576
581
  /** An HTML element, or a function that returns one. It's used to set the position of the popover. */
577
582
  anchor: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.func, PropTypes.object, PropTypes.node, ref]),
578
583
 
579
- /**
580
- * This is the point on the anchor where the popover's anchor will attach to.
581
- * Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
584
+ /**
585
+ * This is the point on the anchor where the popover's anchor will attach to.
586
+ * Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
582
587
  */
583
588
  anchorOrigin: PropTypes.shape({
584
589
  horizontal: PropTypes.oneOf(['center', 'left', 'right']),
@@ -589,7 +594,7 @@ Popover.propTypes = {
589
594
  arrow: PropTypes.bool,
590
595
 
591
596
  /** Background color of the component. */
592
- bgColor: PropTypes.string,
597
+ bgColor: PropTypes.oneOfType(PropTypes.oneOf(['light', 'dark']), PropTypes.string),
593
598
 
594
599
  /** The content of the component. */
595
600
  children: PropTypes.node,
@@ -600,14 +605,14 @@ Popover.propTypes = {
600
605
  /** If `true`, click outside will close component. */
601
606
  clickOutsideToClose: PropTypes.bool,
602
607
 
603
- /**
604
- * Direction when Popover shown.
605
- * Note: This prop will overwrite anchorOrigin & transformOrigin.
606
- *
607
- * * top: anchorOrigin: { vertical: 'top', horizontal: 'center' }, transformOrigin: { vertical: 'bottom', horizontal: 'center' }
608
- * * left: anchorOrigin: { vertical: 'center', horizontal: 'left' }, transformOrigin: { vertical: 'center', horizontal: 'right' }
609
- * * right: anchorOrigin: { vertical: 'center', horizontal: 'right' }, transformOrigin: { vertical: 'center', horizontal: 'left' }
610
- * * bottom: anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }
608
+ /**
609
+ * Direction when Popover shown.
610
+ * Note: This prop will overwrite anchorOrigin & transformOrigin.
611
+ *
612
+ * * top: anchorOrigin: { vertical: 'top', horizontal: 'center' }, transformOrigin: { vertical: 'bottom', horizontal: 'center' }
613
+ * * left: anchorOrigin: { vertical: 'center', horizontal: 'left' }, transformOrigin: { vertical: 'center', horizontal: 'right' }
614
+ * * right: anchorOrigin: { vertical: 'center', horizontal: 'right' }, transformOrigin: { vertical: 'center', horizontal: 'left' }
615
+ * * bottom: anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }
611
616
  */
612
617
  direction: PropTypes.oneOf(['top', 'left', 'right', 'bottom']),
613
618
 
@@ -626,9 +631,9 @@ Popover.propTypes = {
626
631
  /** Style inline of component. */
627
632
  style: PropTypes.object,
628
633
 
629
- /**
630
- * This is the point on the popover which will attach to the anchor's origin.
631
- * Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
634
+ /**
635
+ * This is the point on the popover which will attach to the anchor's origin.
636
+ * Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
632
637
  */
633
638
  transformOrigin: PropTypes.shape({
634
639
  horizontal: PropTypes.oneOf(['center', 'left', 'right']),
@@ -641,13 +646,13 @@ Popover.propTypes = {
641
646
  /** Config z-index of the component. */
642
647
  zIndex: PropTypes.number,
643
648
 
644
- /**
645
- * ref methods (ref.current.instance.*method*)
646
- *
647
- * * show: Show popover
648
- * * close: Close popover
649
- * * setPosition(element): Set position of popover
650
- * * @param {element} - element
649
+ /**
650
+ * ref methods (ref.current.instance.*method*)
651
+ *
652
+ * * show: Show popover
653
+ * * close: Close popover
654
+ * * setPosition(element): Set position of popover
655
+ * * @param {element} - element
651
656
  */
652
657
  reference: ref
653
658
  };
@@ -7,8 +7,8 @@ import PropTypes from 'prop-types';
7
7
  import { randomString } from '../../utils';
8
8
  import TabContext from './context';
9
9
  import { isNumeric } from '../../utils/type';
10
- import Typography from '../typography';
11
10
  import { flexCol, flexRow, positionRelative, parseWidth } from '../../styles/general';
11
+ import { arrTypeTypography as typesTypography } from '../typography';
12
12
  const TabContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
13
13
  children,
14
14
  tabIndex,
@@ -75,7 +75,6 @@ TabContainer.defaultProps = {
75
75
  className: '',
76
76
  style: {}
77
77
  };
78
- const typesTypography = Typography.propTypes.type;
79
78
  TabContainer.propTypes = {
80
79
  /** Width of component. */
81
80
  width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -90,7 +89,7 @@ TabContainer.propTypes = {
90
89
  direction: PropTypes.oneOf(['vertical', 'horizontal']),
91
90
 
92
91
  /** Direction change the size typography of Tab (typesTypography is types of Typography - exp: h1, h2, h3, p1 ...). */
93
- level: PropTypes.oneOfType([PropTypes.oneOf(['level1', 'level2']), typesTypography]),
92
+ level: PropTypes.oneOfType([PropTypes.oneOf(['level1', 'level2', ...typesTypography])]),
94
93
 
95
94
  /** Class for component */
96
95
  className: PropTypes.string,
@@ -4,9 +4,9 @@
4
4
  import { memo, useRef, forwardRef, useImperativeHandle, Fragment, useMemo, useState } from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { jsx, css } from '@emotion/core';
7
- import { renderHTML } from '../../utils';
7
+ import { classNames, renderHTML } from '../../utils';
8
8
  import { Popover } from '..';
9
- import { breakWord, displayBlock, displayInlineBlock, overflowHidden, positionRelative, textCapitalize, textCenter, textUppercase } from '../../styles/general';
9
+ import { breakWord, cursorPointer, displayBlock, displayInlineBlock, overflowHidden, positionRelative, textCapitalize, textCenter, textUppercase } from '../../styles/general';
10
10
  import { color as colors } from '../../styles/colors';
11
11
  import theme from '../../theme/settings';
12
12
  const {
@@ -44,24 +44,25 @@ const colorMap = new Map([['default', main], ['secondary', rest]]);
44
44
  const isTextClamped = elm => (elm === null || elm === void 0 ? void 0 : elm.scrollHeight) > (elm === null || elm === void 0 ? void 0 : elm.clientHeight);
45
45
 
46
46
  const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
47
- type,
48
- color,
49
- center,
50
- uppercase,
51
47
  capitalize,
52
- fullWidth,
53
- mapping,
54
- className,
55
- lineClamp,
48
+ center,
56
49
  children,
50
+ className,
51
+ color,
52
+ fullWidth,
57
53
  hoverTooltip,
54
+ lineClamp,
55
+ mapping,
56
+ onClick,
58
57
  tooltipDirection,
58
+ type,
59
+ uppercase,
59
60
  ...props
60
61
  }, reference) => {
61
62
  const ref = useRef(null);
62
63
  const [openTooltip, setOpenTooltip] = useState(false);
63
64
 
64
- const _TextRootCSS = TextRootCSS(color, type, lineClamp);
65
+ const _TextRootCSS = TextRootCSS(color, type, lineClamp, onClick);
65
66
 
66
67
  useImperativeHandle(reference, () => {
67
68
  const currentRef = ref.current || {};
@@ -73,7 +74,7 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
73
74
  return currentRef;
74
75
  });
75
76
 
76
- const classNames = inTooltip => ['DGN-UI-Typography', center && 'DGN-Typography-center', fullWidth && 'DGN-Typography-fullWidth', `DGN-Typography-${type}`, uppercase && `DGN-Typography-Uppercase`, capitalize && 'DGN-Typography-Capitalize', !inTooltip && lineClamp && 'DGN-Typography-Clamp', className].join(' ').trim().replace(/\s+/g, ' ');
77
+ const classes = inTooltip => classNames('DGN-UI-Typography', center && 'DGN-Typography-center', fullWidth && 'DGN-Typography-fullWidth', `DGN-Typography-${type}`, uppercase && `DGN-Typography-Uppercase`, capitalize && 'DGN-Typography-Capitalize', !inTooltip && lineClamp && 'DGN-Typography-Clamp', className);
77
78
 
78
79
  const setHoverTooltip = (open, isTooltip) => {
79
80
  !isTooltip && setOpenTooltip(false);
@@ -105,28 +106,30 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
105
106
  direction: tooltipDirection
106
107
  }, renderHTML(renderChildren(), mapping, {
107
108
  css: _TextRootCSS,
108
- className: classNames(true),
109
+ className: classes(true),
109
110
  style: {
110
111
  color: textTooltip,
111
112
  padding: '4px 6px'
112
113
  }
113
114
  }));
114
- }, [openTooltip, tooltipDirection, children, mapping, color, type, lineClamp]);
115
+ }, [openTooltip, tooltipDirection, children, mapping, color, type, lineClamp, onClick]);
115
116
  return jsx(Fragment, null, renderHTML(renderChildren(), mapping, {
116
117
  ref: ref,
117
118
  css: _TextRootCSS,
118
- className: classNames(false),
119
+ className: classes(false),
119
120
  onMouseEnter: () => setHoverTooltip(true),
120
121
  onMouseLeave: () => setHoverTooltip(false),
122
+ onClick: onClick,
121
123
  ...props
122
124
  }), hoverTooltip && renderTooltip);
123
125
  }));
124
126
 
125
- const TextRootCSS = (color, type, lineClamp) => css`
127
+ const TextRootCSS = (color, type, lineClamp, onClick) => css`
126
128
  ${displayInlineBlock};
127
129
  ${positionRelative};
128
130
  ${breakWord};
129
131
  ${paragraph1};
132
+ ${onClick && cursorPointer};
130
133
  white-space: break-spaces;
131
134
  color: ${colorMap.get(color) || colors[color] || color};
132
135
  max-width: max-content;
@@ -155,14 +158,14 @@ const TextRootCSS = (color, type, lineClamp) => css`
155
158
  `;
156
159
 
157
160
  Typography.defaultProps = {
158
- type: 'p1',
159
- color: 'default',
160
161
  center: false,
161
- fullWidth: true,
162
- mapping: 'span',
163
162
  className: '',
163
+ color: 'default',
164
+ fullWidth: true,
164
165
  hoverTooltip: false,
165
- tooltipDirection: 'bottom'
166
+ mapping: 'span',
167
+ tooltipDirection: 'bottom',
168
+ type: 'p1'
166
169
  };
167
170
  /** type of text<br/>
168
171
  * h1: Title <br/>
@@ -193,7 +196,7 @@ Typography.propTypes = {
193
196
  /** Color of text ['primary', 'secondary', 'success', 'warning', 'danger', 'info', '#hex', rgb(#,#,#)]. */
194
197
  color: PropTypes.string,
195
198
 
196
- /** If true, the component will take up the full width of its container. */
199
+ /** If `true`, the component will take up the full width of its container. */
197
200
  fullWidth: PropTypes.bool,
198
201
 
199
202
  /** If `true`, hover will show tooltip when text clamped. */
@@ -205,6 +208,9 @@ Typography.propTypes = {
205
208
  /** The component used for the root node. Either a string to use a HTML element or a component. */
206
209
  mapping: PropTypes.string,
207
210
 
211
+ /** Callback fired when the component is clicked. */
212
+ onClick: PropTypes.func,
213
+
208
214
  /** Accepts all props which `mapping` tag support. */
209
215
  props: PropTypes.object,
210
216
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.69-beta.9",
3
+ "version": "1.3.70-beta.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",
package/readme.md CHANGED
@@ -38,6 +38,15 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
+ ## 1.3.70
42
+ - \[Changed\]: Checkbox – Add prop required
43
+ - \[Changed\]: Radio – Add prop required
44
+ - \[Changed\]: Toggle – Add prop required
45
+ - \[Changed\]: Storybook – Add template storybook
46
+ - \[Changed\]: MoneyInput, NumberInput, PhoneInput, TextInput – Add helperTextProps
47
+ - \[Fixed\]: Tooltip – Add display flex
48
+ - \[Fixed\]: Checkbox – Fix bug not show value when label is empty string
49
+
41
50
  ## 1.3.69
42
51
  - \[Fixed\]: DatePicker – Fix not show placeholder
43
52
  - \[Fixed\]: DatePicker – Fix set value when select date