diginet-core-ui 1.4.31 → 1.4.33

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,11 @@
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_1765_74)">
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M31.5 7H24.5V3.5C24.5 1.6 22.9 0 21 0H14C12.1 0 10.5 1.6 10.5 3.5V7H3.5C1.6 7 0 8.6 0 10.5V17.2C0.1 18.2 1 19 2 19H13V18C13 16.9 13.9 16 15 16H20C21.1 16 22 16.9 22 18V19H25.8C27.3 17.7 29.3 16.9 31.4 16.9C32.6 16.9 33.8 17.2 34.8 17.6C35 17.4 35 17.2 35 17V10.5C35 8.6 33.4 7 31.5 7ZM21 7H14V3.5H21V7ZM15 18V22H20V18H15ZM24.1 21H22V22C22 23.1 21.1 24 20 24H15C13.9 24 13 23.1 13 22V21H2C1.3 21 0.6 20.8 0 20.5V29.8C0 31.7 1.6 33.3 3.5 33.3H25.5C24 30.8 22.8 28 22.8 25.6C22.8 23.9 23.3 22.3 24.1 21Z" fill="#2680EB"/>
4
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M23.8999 25.5C23.8999 21.3 27.2999 18 31.3999 18C35.4999 18 38.8999 21.4 38.8999 25.5C38.8999 30.1 33.9999 36.4 32.0999 38.6C31.6999 39.1 30.9999 39.1 30.5999 38.6C28.7999 36.4 23.8999 30.1 23.8999 25.5ZM27.5999 24.5C26.8999 27.5 29.4999 30.1 32.4999 29.4C33.8999 29.1 35.0999 27.9 35.3999 26.5C36.0999 23.5 33.4999 20.9 30.4999 21.6C29.0999 22 27.8999 23.1 27.5999 24.5Z" fill="#FF8C00"/>
5
+ </g>
6
+ <defs>
7
+ <clipPath id="clip0_1765_74">
8
+ <rect width="39" height="39" fill="white"/>
9
+ </clipPath>
10
+ </defs>
11
+ </svg>
@@ -119,6 +119,7 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
119
119
  if (isZoomOutAble) {
120
120
  let zoomOutLevel = currentZoomLevel + 1;
121
121
  if (zoomOutLevel === 2 && minZoom !== 'quarter') zoomOutLevel++; // skip quarter
122
+ onUpdate(navigatorValue.current);
122
123
  setCurrentZoomLevel(zoomOutLevel);
123
124
  return;
124
125
  }
@@ -173,7 +174,8 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
173
174
  const setPrevMonth = e => {
174
175
  let time = null;
175
176
  switch (currentZoomLevel) {
176
- case (1, 2):
177
+ case 1:
178
+ case 2:
177
179
  time = new Date(getCurrentTime()[2] - 1, getCurrentTime()[1]); // set year = current year - 1
178
180
  break;
179
181
  case 3:
@@ -195,7 +197,8 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
195
197
  const setNextMonth = e => {
196
198
  let time = null;
197
199
  switch (currentZoomLevel) {
198
- case (1, 2):
200
+ case 1:
201
+ case 2:
199
202
  time = new Date(getCurrentTime()[2] + 1, getCurrentTime()[1]); // set year = current year + 1
200
203
  break;
201
204
  case 3:
@@ -726,6 +726,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
726
726
  }
727
727
  };
728
728
  const onInputFocus = () => {
729
+ if (!isEnable) return;
729
730
  const el = ipConRef.current;
730
731
  if (!el.classList.contains(unique.focus)) {
731
732
  el.classList.add(unique.focus);
@@ -3,36 +3,14 @@
3
3
  import { css, jsx } from '@emotion/core';
4
4
  import { Typography } from "../..";
5
5
  import PropTypes from 'prop-types';
6
- import { Fragment, forwardRef, memo, useEffect, useMemo, useRef, useState } from 'react';
7
- import { cursorNoDrop, cursorPointer, displayBlock, flexRow, itemsCenter, positionAbsolute, positionRelative } from "../../../styles/general";
6
+ import { Fragment, forwardRef, memo, useEffect, useRef, useState } from 'react';
7
+ import { borderRadius, cursorNoDrop, cursorPointer, displayBlock, flexRow, itemsCenter, parseMinHeight, parseMinWidth, parseWidthHeight, positionAbsolute, positionRelative } from "../../../styles/general";
8
8
  import { useTheme } from "../../../theme";
9
9
  import useThemeProps from "../../../theme/utils/useThemeProps";
10
- import { randomString as generateRandom } from "../../../utils";
10
+ import { classNames, getProp } from "../../../utils";
11
11
  const Toggle = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
12
12
  if (!reference) reference = useRef(null);
13
13
  const theme = useTheme();
14
- const {
15
- colors: {
16
- system: {
17
- rest: clRest,
18
- active: clActive,
19
- disabled: systemDisabled,
20
- active: systemActive
21
- },
22
- text: {
23
- main: clTextMain
24
- },
25
- fill: {
26
- focus: clFillFocus,
27
- hover: fillHover
28
- },
29
- standard: clStandard,
30
- semantic: {
31
- danger: clDanger
32
- }
33
- },
34
- spacing
35
- } = theme;
36
14
 
37
15
  // props priority: `inProps` > `themeDefaultProps`
38
16
  const props = useThemeProps({
@@ -40,113 +18,32 @@ const Toggle = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) =
40
18
  name: 'Toggle'
41
19
  });
42
20
  const {
43
- id,
21
+ checked,
44
22
  disabled,
45
- readOnly,
46
- name,
47
23
  height,
48
- width,
49
- label,
50
- checked,
51
- defaultChecked,
52
- onChange,
53
- inputRef: inputRefProp,
24
+ hoverTooltip,
25
+ id,
54
26
  inputProps,
27
+ inputRef: inputRefProp,
28
+ label,
55
29
  lineClamp,
56
- hoverTooltip,
30
+ name,
31
+ readOnly,
57
32
  required,
33
+ width,
34
+ defaultChecked,
35
+ onChange,
58
36
  ...other
59
37
  } = props;
60
38
  const ref = useRef(null);
61
39
  const inputRef = inputRefProp || useRef(null);
62
40
  const [checkedState, setCheckedState] = useState(Boolean(checked !== undefined ? checked : defaultChecked));
63
- const padding = spacing(0.5);
64
- const formCheck = css`
65
- ${positionRelative};
66
- min-height: ${height}px;
67
- padding: ${padding}px;
68
- `;
69
- const toggle = css`
70
- ${flexRow};
71
- ${itemsCenter};
72
- ${positionRelative};
73
- ${cursorPointer};
74
- margin: 0;
75
- `;
76
- const slider = css`
77
- ${positionRelative};
78
- ${displayBlock};
79
- height: ${height}px;
80
- width: ${width}px;
81
- min-width: ${width}px;
82
- border-radius: ${height}px;
83
- background: ${clStandard};
84
- outline: 1px solid ${clRest};
85
- &.disabled {
86
- outline: 1px solid ${systemDisabled} !important;
87
- }
88
- &.disabled,
89
- &.read-only {
90
- ${cursorNoDrop};
91
- }
92
- &::after {
93
- ${positionAbsolute};
94
- background: ${clRest};
95
- width: ${height - spacing(1)}px;
96
- height: ${height - spacing(1)}px;
97
- content: '';
98
- top: 2px;
99
- left: 2px;
100
- border-radius: 100%;
101
- transition: 0.3s ease-in-out;
102
- margin: 0px auto;
103
- }
104
- &:not(.disabled):not(.read-only) {
105
- &:active,
106
- &:focus {
107
- box-shadow: 0 0 0 2px ${clFillFocus};
108
- }
109
- }
110
- `;
111
- const checkbox = css`
112
- left: 0;
113
- &:checked + label > span.css-${slider.name} {
114
- background: ${systemActive};
115
- outline-color: ${systemActive};
116
- &::after {
117
- background: ${clStandard};
118
- left: ${width - height}px;
119
- }
120
- &.disabled {
121
- background: ${systemDisabled} !important;
122
- }
123
- }
124
- &:not(:checked) + label > span.css-${slider.name} {
125
- &:not(.disabled):not(.read-only) {
126
- &:hover {
127
- box-shadow: 0 0 0 2px ${fillHover};
128
- outline-color: ${systemActive};
129
- background-color: ${fillHover};
130
- }
131
- &:hover:after {
132
- background-color: ${clActive};
133
- }
134
- &:active,
135
- &:focus {
136
- background-color: ${clFillFocus};
137
- }
138
- }
139
- &.disabled:after {
140
- background: ${systemDisabled} !important;
141
- }
142
- }
143
- `;
144
- const idDefault = generateRandom(10, {
145
- allowNumber: false,
146
- allowSymbol: false
147
- });
41
+ const isEnable = !readOnly && !disabled;
42
+ const _FormCheckCSS = FormCheckCSS(height, theme);
43
+ const _ToggleCSS = ToggleCSS(theme);
44
+ const _SliderCSS = SliderCSS(checkedState, disabled, isEnable, width, height, theme);
148
45
  const handleChange = () => {
149
- if (disabled || readOnly) return;
46
+ if (!isEnable) return;
150
47
  setCheckedState(checked !== undefined ? Boolean(checked) : !checkedState);
151
48
  const e = {
152
49
  value: !checkedState,
@@ -160,10 +57,10 @@ const Toggle = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) =
160
57
  useEffect(() => {
161
58
  if (checked !== undefined) setCheckedState(Boolean(checked));
162
59
  }, [checked]);
163
- return useMemo(() => jsx("div", {
164
- id: 'DGN-Core-Toggle-' + (id ? id : idDefault),
165
- css: formCheck,
60
+ return jsx("div", {
61
+ css: _FormCheckCSS,
166
62
  ref: ref,
63
+ id: 'DGN-Core-Toggle' + (id ? `-${id}` : ''),
167
64
  ...other
168
65
  }, jsx("input", {
169
66
  ...inputProps,
@@ -173,31 +70,107 @@ const Toggle = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) =
173
70
  type: "checkbox",
174
71
  disabled: disabled,
175
72
  readOnly: readOnly,
176
- css: checkbox,
177
73
  checked: checkedState,
178
74
  onChange: handleChange
179
75
  }), jsx("label", {
180
- css: toggle,
76
+ css: _ToggleCSS,
181
77
  onClick: handleChange
182
78
  }, jsx("span", {
183
- css: slider,
184
- className: `${disabled ? 'disabled' : ''} ${readOnly ? 'read-only' : ''}`
79
+ css: _SliderCSS,
80
+ className: classNames(disabled && 'disabled', readOnly && 'readOnly')
185
81
  }), label !== undefined && jsx(Typography, {
186
82
  type: 'p1',
187
- style: {
188
- color: disabled ? systemDisabled : clTextMain,
189
- marginBottom: 0,
190
- marginLeft: spacing(2.5)
191
- },
83
+ color: disabled ? 'system/disabled' : 'text/main',
192
84
  hoverTooltip: hoverTooltip,
193
85
  lineClamp: lineClamp || null,
194
86
  mapping: 'label'
195
- }, jsx(Fragment, null, label, required && jsx("span", {
196
- style: {
197
- color: disabled ? systemDisabled : clDanger
198
- }
199
- }, "*"))))), [disabled, onChange, checkedState, readOnly, theme]);
87
+ }, jsx(Fragment, null, label, required && jsx(Typography, {
88
+ color: 'danger',
89
+ fullWidth: false
90
+ }, "*")))));
200
91
  }));
92
+ const FormCheckCSS = (height, {
93
+ spacing
94
+ }) => css`
95
+ ${positionRelative};
96
+ ${parseMinHeight(height)};
97
+ padding: ${spacing([0.5])};
98
+ `;
99
+ const ToggleCSS = ({
100
+ spacing
101
+ }) => css`
102
+ ${flexRow};
103
+ ${itemsCenter};
104
+ ${positionRelative};
105
+ ${cursorPointer};
106
+ gap: ${spacing([1.5])};
107
+ `;
108
+ const CheckedSliderCSS = (isEnable, disabled, width, height, colors) => css`
109
+ background: ${getProp(colors, disabled ? 'system/disabled' : 'system/active')};
110
+ outline: 1px solid ${getProp(colors, disabled ? 'system/disabled' : 'system/active')};
111
+ &::after {
112
+ left: ${width - height}px;
113
+ background: ${getProp(colors, 'system/standard')};
114
+ }
115
+ ${isEnable && css`
116
+ &:hover {
117
+ box-shadow: 0 0 0 2px ${getProp(colors, 'fill/hover')};
118
+ }
119
+ &:focus {
120
+ box-shadow: 0 0 0 2px ${getProp(colors, 'fill/focus')};
121
+ }
122
+ &:active {
123
+ box-shadow: 0 0 0 2px ${getProp(colors, 'fill/pressed')};
124
+ }
125
+ `}
126
+ `;
127
+ const NotCheckedSliderCSS = (isEnable, disabled, colors) => css`
128
+ background: ${getProp(colors, 'system/standard')};
129
+ outline: 1px solid ${getProp(colors, disabled ? 'system/disabled' : 'system/rest')};
130
+ &::after {
131
+ left: 2px;
132
+ background: ${getProp(colors, disabled ? 'system/disabled' : 'system/rest')};
133
+ }
134
+ ${isEnable && css`
135
+ &:hover {
136
+ box-shadow: 0 0 0 2px ${getProp(colors, 'fill/hover')};
137
+ outline-color: ${getProp(colors, 'system/active')};
138
+ background-color: ${getProp(colors, 'fill/hover')};
139
+ }
140
+ &:focus {
141
+ box-shadow: 0 0 0 2px ${getProp(colors, 'fill/focus')};
142
+ background-color: ${getProp(colors, 'fill/focus')};
143
+ }
144
+ &:active {
145
+ box-shadow: 0 0 0 2px ${getProp(colors, 'fill/pressed')};
146
+ background-color: ${getProp(colors, 'fill/pressed')};
147
+ }
148
+ &:hover:after {
149
+ background-color: ${getProp(colors, 'system/active')};
150
+ }
151
+ `}
152
+ `;
153
+ const SliderCSS = (checkedState, disabled, isEnable, width, height, {
154
+ colors,
155
+ spacing
156
+ }) => css`
157
+ ${positionRelative};
158
+ ${displayBlock};
159
+ ${parseWidthHeight(width, height)};
160
+ ${parseMinWidth(width)};
161
+ ${borderRadius(height)};
162
+ ${!isEnable && cursorNoDrop}
163
+ &::after {
164
+ ${positionAbsolute};
165
+ ${parseWidthHeight(height - spacing(1), height - spacing(1))};
166
+ content: '';
167
+ top: 2px;
168
+ border-radius: 100%;
169
+ transition: 0.3s ease-in-out;
170
+ margin: 0px auto;
171
+ }
172
+ ${checkedState ? CheckedSliderCSS(isEnable, disabled, width, height, colors) : NotCheckedSliderCSS(isEnable, disabled, colors)};
173
+ `;
201
174
 
202
175
  // Toggle.defaultProps = {
203
176
  // disabled: false,
@@ -67,7 +67,7 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
67
67
  className: IDs.frame,
68
68
  css: _FrameCSS,
69
69
  frameBorder: 0,
70
- src: `https://view.officeapps.live.com/op/view.aspx?src=${filePath}`,
70
+ src: `https://view.officeapps.live.com/op/view.aspx?src=${filePath}&activeCell=A1`,
71
71
  title: fileName
72
72
  });
73
73
  }
package/icons/basic.js CHANGED
@@ -1700,7 +1700,7 @@ export const Colors = /*#__PURE__*/memo(({
1700
1700
  rx: "2.79582",
1701
1701
  ry: "2.78742",
1702
1702
  transform: "matrix(0.497747 0.867322 -0.864719 0.502257 3.80195 13.6001)",
1703
- fill: "system/active"
1703
+ fill: "#111D5E"
1704
1704
  }), /*#__PURE__*/React.createElement("ellipse", {
1705
1705
  rx: "2.79582",
1706
1706
  ry: "2.78742",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.4.31",
3
+ "version": "1.4.33",
4
4
  "description": "The DigiNet core ui",
5
5
  "homepage": "https://diginet.com.vn",
6
6
  "main": "index.js",
package/readme.md CHANGED
@@ -41,7 +41,19 @@ npm test
41
41
  ```
42
42
 
43
43
  ## Changelog
44
+ ## 1.4.33
45
+
46
+ - \[Added\]: IconMenu – Add MHRP29N0030
47
+
48
+ ## 1.4.32
49
+
50
+ - \[Fixed\]: Slider – Fix show excel not focus first cell
51
+ - \[Fixed\]: Toggle – Fix color not match design
52
+ - \[Fixed\]: DateRangePicker – Fix still open picker when read-only
53
+ - \[Fixed\]: DatePicker – Fix wrong navigation content
54
+
44
55
  ## 1.4.31
56
+
45
57
  - \[Added\]: Skeleton – Add the new Skeleton library
46
58
 
47
59
  ## 1.4.30