diginet-core-ui 1.4.21 → 1.4.23

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.
@@ -2,25 +2,33 @@
2
2
  /** @jsx jsx */
3
3
  import { css, jsx } from '@emotion/core';
4
4
  import PropTypes from 'prop-types';
5
- import { forwardRef, memo, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
5
+ import { forwardRef, memo, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react';
6
6
  import { boxBorder, displayFlex, displayNone, flexCol, parseWidthHeight, positionRelative, textColor } from "../../styles/general";
7
7
  import { useTheme } from "../../theme";
8
+ import useThemeProps from "../../theme/utils/useThemeProps";
8
9
  import { classNames, getProp } from "../../utils";
9
10
  import TabContext from "./context";
10
- const TabPanel = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
11
- action = {},
12
- children,
13
- className,
14
- index,
15
- lazyLoading,
16
- style,
17
- ...props
18
- }, reference) => {
11
+ const TabPanel = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
12
+ if (!reference) reference = useRef(null);
13
+
14
+ // props priority: `inProps` > `themeDefaultProps`
15
+ const props = useThemeProps({
16
+ props: inProps,
17
+ name: 'TabPanel'
18
+ });
19
+ const {
20
+ action = {},
21
+ children,
22
+ className,
23
+ index,
24
+ lazyLoading,
25
+ style,
26
+ ...other
27
+ } = props;
19
28
  const {
20
29
  tabIndexState,
21
30
  direction
22
31
  } = useContext(TabContext);
23
- if (!reference) reference = useRef(null);
24
32
  const [isRendered, setIsRendered] = useState(false);
25
33
  const ref = useRef(null);
26
34
  const theme = useTheme();
@@ -40,15 +48,13 @@ const TabPanel = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
40
48
  currentRef.instance = _instance;
41
49
  return currentRef;
42
50
  });
43
- return useMemo(() => {
44
- return jsx("div", {
45
- css: _TabPanelCSS,
46
- ref: ref,
47
- className: classNames('DGN-UI-Tab-Panel', className),
48
- style: style,
49
- ...props
50
- }, isSelected || !lazyLoading || isRendered ? children : null);
51
- }, [children, className, index, lazyLoading, props, style, isSelected, isRendered, tabIndexState, theme]);
51
+ return jsx("div", {
52
+ css: _TabPanelCSS,
53
+ ref: ref,
54
+ className: classNames('DGN-UI-Tab-Panel', className),
55
+ style: style,
56
+ ...other
57
+ }, isSelected || !lazyLoading || isRendered ? children : null);
52
58
  }));
53
59
  const TabPanelCSS = (isVertical, isSelected, {
54
60
  colors,
@@ -63,23 +69,23 @@ const TabPanelCSS = (isVertical, isSelected, {
63
69
  ${textColor(getProp(colors, 'text/main'))};
64
70
  padding: ${spacing([0, isVertical ? 3 : 2.5])};
65
71
  `;
66
- TabPanel.defaultProps = {
67
- className: '',
68
- lazyLoading: false,
69
- style: {}
70
- };
72
+
73
+ // TabPanel.defaultProps = {
74
+ // className: '',
75
+ // lazyLoading: false,
76
+ // style: {},
77
+ // };
78
+
71
79
  TabPanel.propTypes = {
72
80
  /** The content of the component. */
73
81
  children: PropTypes.node,
74
- /** Class for component. */
82
+ /** CSS class for the component. */
75
83
  className: PropTypes.string,
76
- /** Index received in position of TabHeaderButton. */
84
+ /** The index corresponding to the position of the TabHeaderButton. */
77
85
  index: PropTypes.number,
78
- /** Lazy loading mode. */
86
+ /** Enables lazy loading mode. */
79
87
  lazyLoading: PropTypes.bool,
80
- /** Style inline of component. */
81
- style: PropTypes.object,
82
- /** Any props else. */
83
- props: PropTypes.any
88
+ /** Inline style object for the component. */
89
+ style: PropTypes.object
84
90
  };
85
91
  export default TabPanel;
@@ -4,33 +4,42 @@ import { css, jsx } from '@emotion/core';
4
4
  import { Icon, Typography } from "./..";
5
5
  import Ripple from "../button/ripple-effect";
6
6
  import PropTypes from 'prop-types';
7
- import { forwardRef, memo, useContext, useImperativeHandle, useMemo, useRef } from 'react';
7
+ import { forwardRef, memo, useContext, useImperativeHandle, useRef } from 'react';
8
8
  import { bgColor, borderRadius, bottom, boxBorder, breakWord, cursorDefault, cursorPointer, displayFlex, flexRow, itemsCenter, justifyCenter, justifyStart, left, outlineNone, overflowHidden, parseHeight, parseMaxWidth, parseMaxWidthHeight, parseMinWidth, parseWidth, pointerEventsAuto, pointerEventsNone, positionAbsolute, positionRelative, scale, shadowNone, textCenter, textColor, userSelectNone, whiteSpaceNoWrap } from "../../styles/general";
9
9
  import { useTheme } from "../../theme";
10
+ import useThemeProps from "../../theme/utils/useThemeProps";
10
11
  import { classNames, getProp } from "../../utils";
11
12
  import TabContext from "./context";
12
- const TabItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
13
- action = {},
14
- children,
15
- className,
16
- color: colorProp,
17
- disabled,
18
- endIcon,
19
- index,
20
- label,
21
- labelProps,
22
- level,
23
- onClick,
24
- startIcon,
25
- style,
26
- ...props
27
- }, reference) => {
13
+ const TabItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
14
+ if (!reference) reference = useRef(null);
15
+
16
+ // props priority: `inProps` > `themeDefaultProps`
17
+ const props = useThemeProps({
18
+ props: inProps,
19
+ name: 'TabItem'
20
+ });
21
+ const {
22
+ action = {},
23
+ children,
24
+ className,
25
+ color: colorProp,
26
+ disabled,
27
+ endIcon,
28
+ index,
29
+ label,
30
+ labelProps,
31
+ level,
32
+ onClick,
33
+ startIcon,
34
+ style,
35
+ ...other
36
+ } = props;
28
37
  const {
29
38
  tabIndexState,
30
39
  setTabIndexState,
31
- direction
40
+ direction,
41
+ onChange
32
42
  } = useContext(TabContext);
33
- if (!reference) reference = useRef(null);
34
43
  const ref = useRef(null);
35
44
  const rippleRef = useRef(null);
36
45
  const isVertical = direction === 'vertical';
@@ -45,6 +54,7 @@ const TabItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
45
54
  if (disabled) return;
46
55
  rippleRef.current.start(e);
47
56
  onClick ? onClick(e, index) : setTabIndexState(index);
57
+ onChange === null || onChange === void 0 ? void 0 : onChange(e, index);
48
58
  };
49
59
  useImperativeHandle(reference, () => {
50
60
  const currentRef = ref.current || {};
@@ -68,28 +78,26 @@ const TabItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
68
78
  css: [_IconCSS, isEndIcon && EndIconCSS(theme)]
69
79
  }, node);
70
80
  };
71
- return useMemo(() => {
72
- return jsx("div", {
73
- css: [_TabItemCSS, disabled && _TabItemDisabledCSS, index === tabIndexState && !disabled && _TabItemSelectedCSS],
74
- ref: ref,
75
- className: classNames('DGN-UI-Tab-Item', disabled && 'disabled', index === tabIndexState && !disabled && 'selected', className),
76
- style: style,
77
- onClick: _onClick,
78
- ...props
79
- }, startIcon && renderIcon(startIcon), jsx(Typography, {
80
- type: level,
81
- color: 'inherit',
82
- lineClamp: 1,
83
- hoverTooltip: true,
84
- ...labelProps
85
- }, label), children, endIcon && renderIcon(endIcon, true), jsx(Ripple, {
86
- ref: rippleRef,
87
- css: pointerEventsNone
88
- }), jsx("span", {
89
- css: _IndicatorCSS,
90
- className: 'Indicator'
91
- }));
92
- }, [children, className, color, disabled, endIcon, index, label, labelProps, level, onClick, props, startIcon, style, isVertical, tabIndexState, theme]);
81
+ return jsx("div", {
82
+ css: [_TabItemCSS, disabled && _TabItemDisabledCSS, index === tabIndexState && !disabled && _TabItemSelectedCSS],
83
+ ref: ref,
84
+ className: classNames('DGN-UI-Tab-Item', disabled && 'disabled', index === tabIndexState && !disabled && 'selected', className),
85
+ style: style,
86
+ onClick: _onClick,
87
+ ...other
88
+ }, startIcon && renderIcon(startIcon), jsx(Typography, {
89
+ type: level,
90
+ color: 'inherit',
91
+ lineClamp: 1,
92
+ hoverTooltip: true,
93
+ ...labelProps
94
+ }, label), children, endIcon && renderIcon(endIcon, true), jsx(Ripple, {
95
+ ref: rippleRef,
96
+ css: pointerEventsNone
97
+ }), jsx("span", {
98
+ css: _IndicatorCSS,
99
+ className: 'Indicator'
100
+ }));
93
101
  }));
94
102
  const TabItemCSS = (color, isVertical, {
95
103
  colors,
@@ -166,37 +174,37 @@ const EndIconCSS = ({
166
174
  margin-right: unset;
167
175
  margin-left: ${spacing([1])};
168
176
  `;
169
- TabItem.defaultProps = {
170
- className: '',
171
- color: 'system/rest',
172
- disabled: false,
173
- label: '',
174
- style: {}
175
- };
177
+
178
+ // TabItem.defaultProps = {
179
+ // className: '',
180
+ // color: 'system/rest',
181
+ // disabled: false,
182
+ // label: '',
183
+ // style: {},
184
+ // };
185
+
176
186
  TabItem.propTypes = {
177
- /** Element to display in Tabs (like label). */
187
+ /** Content to display in the Tabs (like a label). */
178
188
  children: PropTypes.node,
179
- /** Class for component. */
189
+ /** CSS class for the component. */
180
190
  className: PropTypes.string,
181
- /** Color for Tabs. */
191
+ /** Color for the Tabs. */
182
192
  color: PropTypes.string,
183
- /** If true, the component is disabled. */
193
+ /** If `true`, the component is disabled. */
184
194
  disabled: PropTypes.bool,
185
- /** Icon to the right of the button. */
195
+ /** Icon to display on the right side of the button. */
186
196
  endIcon: PropTypes.node,
187
- /** Index received in position of TabHeaderButton. */
197
+ /** Index corresponding to the position of the TabHeaderButton. */
188
198
  index: PropTypes.number,
189
- /** Data string, if any. */
199
+ /** The content of the component. */
190
200
  label: PropTypes.string,
191
201
  /** [Props](https://core.diginet.com.vn/ui/?path=/docs/typography--title) applied to the `Typography` label. */
192
202
  labelProps: PropTypes.object,
193
- /** Callback fired when a "click" event is detected. */
203
+ /** Callback function fired when a "click" event is detected. */
194
204
  onClick: PropTypes.func,
195
- /** Icon to the left of the button. */
205
+ /** Icon to display on the left side of the button. */
196
206
  startIcon: PropTypes.node,
197
- /** Style inline of component. */
198
- style: PropTypes.object,
199
- /** Any props else. */
200
- props: PropTypes.any
207
+ /** Inline style object for the component. */
208
+ style: PropTypes.object
201
209
  };
202
210
  export default TabItem;
package/global/index.js CHANGED
@@ -58,6 +58,8 @@ const globalObject = {
58
58
  day: 'ngày',
59
59
  month: 'tháng',
60
60
  year: 'năm',
61
+ save: 'Lưu',
62
+ now: 'Hiện tại',
61
63
  // Localize
62
64
  selectAll: 'Chọn tất cả',
63
65
  thisFieldIsRequired: 'Trường này bắt buộc nhập',
@@ -131,6 +133,8 @@ const globalObject = {
131
133
  day: 'day',
132
134
  month: 'month',
133
135
  year: 'year',
136
+ save: 'Save',
137
+ now: 'Now',
134
138
  // Localize
135
139
  selectAll: 'Select all',
136
140
  thisFieldIsRequired: 'This field is required',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.4.21",
3
+ "version": "1.4.23",
4
4
  "description": "The DigiNet core ui",
5
5
  "homepage": "https://diginet.com.vn",
6
6
  "main": "index.js",
package/readme.md CHANGED
@@ -42,6 +42,19 @@ npm test
42
42
 
43
43
  ## Changelog
44
44
 
45
+ ## 1.4.22
46
+
47
+ - \[Changed\]: TabHeader – Add full width
48
+
49
+ ## 1.4.22
50
+
51
+ - \[Added\]: IconMenu – Add MHRP39N0020, MHRP39N0021
52
+ - \[Changed\]: Tab – Add prop onChange in TabContainer
53
+ - \[Changed\]: Accordion – Update AccordionSummary propTypes
54
+ - \[Fixed\]: TimePicker – Fix cannot select time by arrow keys
55
+ - \[Fixed\]: Modal – Fix warning call Hooks inside useMemo
56
+ - \[Fixed\]: Image – Fix render img tag when src empty
57
+
45
58
  ## 1.4.21
46
59
 
47
60
  - \[Changed\]: Theme – Setup switch theme Dark Light
@@ -65,7 +78,7 @@ npm test
65
78
 
66
79
  ## 1.4.16
67
80
 
68
- - \[Changed\]: IconMenu – Add MHRM15N0001
81
+ - \[Added\]: IconMenu – Add MHRM15N0001
69
82
  - \[Changed\]: Dropdown – Return recent search in onClosed callback
70
83
 
71
84
  ## 1.4.15
@@ -88,7 +101,7 @@ npm test
88
101
 
89
102
  ## 1.4.12
90
103
 
91
- - \[Changed\]: IconMenu – Add, Update icon for DIGINET EO
104
+ - \[Added\]: IconMenu – Add, Update icon for DIGINET EO
92
105
  - \[Changed\]: Attachment – Add viewType Picture
93
106
  - \[Changed\]: Calendar – Update design
94
107
  - \[Changed\]: DatePicker – Add picker month, year, quarter
@@ -114,7 +127,7 @@ npm test
114
127
 
115
128
  ## 1.4.9
116
129
 
117
- - \[Changed\]: IconMenu – Add 16 icon menu of HR Mobile App
130
+ - \[Added\]: IconMenu – Add 16 icon menu of HR Mobile App
118
131
  - \[Fixed\]: Chip – Fix width of TabHeader
119
132
 
120
133
  ## 1.4.8
@@ -284,7 +297,7 @@ npm test
284
297
 
285
298
  ## 1.3.83
286
299
 
287
- - \[Changed\]: IconMenu – Add prop className, style
300
+ - \[Added\]: IconMenu – Add prop className, style
288
301
  - \[Changed\]: Grid – Add prop verticalAlign
289
302
  - \[Changed\]: Label– Add lineClamp auto
290
303
  - \[Fixed\]: Popover – Fix bug not save last position of anchor
package/theme/settings.js CHANGED
@@ -680,6 +680,41 @@ const settings = {
680
680
  zeroMinWidth: false
681
681
  }
682
682
  },
683
+ TabContainer: {
684
+ defaultProps: {
685
+ className: '',
686
+ direction: 'horizontal',
687
+ level: 'level1',
688
+ style: {},
689
+ tabIndex: 0,
690
+ width: '100%'
691
+ }
692
+ },
693
+ TabHeader: {
694
+ defaultProps: {
695
+ centered: false,
696
+ className: '',
697
+ scrollButtons: false,
698
+ style: {},
699
+ width: '100%'
700
+ }
701
+ },
702
+ TabPanel: {
703
+ defaultProps: {
704
+ className: '',
705
+ lazyLoading: false,
706
+ style: {}
707
+ }
708
+ },
709
+ TabItem: {
710
+ defaultProps: {
711
+ className: '',
712
+ color: 'system/rest',
713
+ disabled: false,
714
+ label: '',
715
+ style: {}
716
+ }
717
+ },
683
718
  TextInput: {
684
719
  defaultProps: {
685
720
  autoComplete: 'off',
@@ -699,6 +734,25 @@ const settings = {
699
734
  viewType: 'underlined'
700
735
  }
701
736
  },
737
+ TimePicker: {
738
+ defaultProps: {
739
+ actionIconAt: 'end',
740
+ className: '',
741
+ disabled: false,
742
+ displayFormat: 'HH:mm:ss',
743
+ mode12h: false,
744
+ readOnly: false,
745
+ required: false,
746
+ returnFormat: 'HH:mm:ss',
747
+ error: '',
748
+ minuteStep: 1,
749
+ min: '',
750
+ max: '',
751
+ label: '',
752
+ value: '',
753
+ viewType: 'underlined'
754
+ }
755
+ },
702
756
  Toggle: {
703
757
  defaultProps: {
704
758
  disabled: false,