diginet-core-ui 1.3.50 → 1.3.51

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.
@@ -1,37 +1,37 @@
1
1
  import { css } from '@emotion/core';
2
- import { typography } from '../../styles/typography';
3
- import { color as colors } from '../../styles/colors';
4
- import { alignCenter, backgroundTransparent, borderBox, borderRadius4px, breakWord, cursorPointer, displayInlineBlock, flexRow, flexRowReverse, inlineFlex, justifyBetween, justifyCenter, justifyEnd, pointerEventsNone, positionAbsolute, positionRelative, userSelectNone } from '../../styles/general';
2
+ import theme from '../../theme/settings';
3
+ import { alignCenter, alignStart, backgroundTransparent, borderBox, borderRadius4px, breakWord, cursorPointer, displayInlineBlock, flexRow, flexRowReverse, inlineFlex, justifyBetween, justifyCenter, justifyEnd, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative, userSelectNone } from '../../styles/general';
5
4
  const {
6
- heading3
7
- } = typography;
8
- const {
9
- system: {
10
- active,
11
- disabled: systemDisabled
5
+ colors: {
6
+ system: {
7
+ active,
8
+ disabled: systemDisabled
9
+ },
10
+ fill: {
11
+ disabled: fillDisabled,
12
+ headerbar,
13
+ focus,
14
+ hover,
15
+ pressed
16
+ }
12
17
  },
13
- fill: {
14
- disabled: fillDisabled,
15
- headerbar,
16
- focus,
17
- hover,
18
- pressed
19
- }
20
- } = colors;
21
- export const SummaryRootCSS = css`
18
+ typography: {
19
+ heading3
20
+ },
21
+ spacing
22
+ } = theme;
23
+ export const SummaryRootCSS = background => css`
22
24
  ${flexRow};
23
25
  ${positionRelative};
24
26
  ${justifyBetween};
25
- ${alignCenter};
27
+ ${alignStart};
26
28
  ${cursorPointer};
27
29
  ${borderBox};
28
30
  ${borderRadius4px};
29
31
  width: 100%;
30
32
  min-height: 56px;
31
- padding: 16px 24px;
32
- &.background {
33
- background-color: ${headerbar};
34
- }
33
+ padding: ${spacing(4)}px ${spacing(6)}px;
34
+ ${background && `background-color: ${background === true ? headerbar : theme.colors[background] || background};`};
35
35
  .Accordion-Expand-Icon,
36
36
  .Accordion-Collapse-Icon {
37
37
  ${cursorPointer};
@@ -47,8 +47,7 @@ export const SummaryRootCSS = css`
47
47
  ${flexRow};
48
48
  .Accordion-Icon.rotate-able {
49
49
  ${borderBox};
50
- width: 24px;
51
- height: 24px;
50
+ ${parseWidthHeight(24, 24)};
52
51
  &:not(.TreeView) {
53
52
  transform: rotateZ(0deg);
54
53
  transform-origin: center;
@@ -62,7 +61,7 @@ export const SummaryRootCSS = css`
62
61
  ${flexRowReverse};
63
62
  ${justifyEnd};
64
63
  .Accordion-Icon.rotate-able {
65
- margin-right: 8px;
64
+ margin-right: ${spacing(2)}px;
66
65
  &.TreeView {
67
66
  transform: rotateZ(-90deg);
68
67
  }
@@ -70,7 +69,7 @@ export const SummaryRootCSS = css`
70
69
  }
71
70
  &.end {
72
71
  .Accordion-Icon.rotate-able {
73
- margin-left: 8px;
72
+ margin-left: ${spacing(2)}px;
74
73
  &.TreeView {
75
74
  transform: rotateZ(90deg);
76
75
  }
@@ -144,8 +143,7 @@ export const SummaryRootCSS = css`
144
143
  ${displayInlineBlock};
145
144
  ${positionRelative};
146
145
  ${cursorPointer};
147
- width: 24px;
148
- height: 24px;
146
+ ${parseWidthHeight(24, 24)};
149
147
  transition: transform 200ms linear;
150
148
  .Accordion-Expand-Icon {
151
149
  transform: scale(1);
@@ -169,7 +167,6 @@ export const SummaryRootCSS = css`
169
167
  max-width: 34px;
170
168
  min-height: 24px;
171
169
  max-height: 34px;
172
- padding: 3px;
173
170
  }
174
171
  }
175
172
  `;
@@ -5,16 +5,18 @@ import { memo, forwardRef, useRef, useMemo, useImperativeHandle } from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { jsx, css } from '@emotion/core';
7
7
  import { borderBox, displayBlock, overflowHidden, pointerEventsNone, positionRelative, userSelectNone } from '../../styles/general';
8
- import { typography } from '../../styles/typography';
9
- import { color as colors } from '../../styles/colors';
8
+ import theme from '../../theme/settings';
10
9
  const {
11
- paragraph1
12
- } = typography;
13
- const {
14
- text: {
15
- main
16
- }
17
- } = colors;
10
+ colors: {
11
+ text: {
12
+ main
13
+ }
14
+ },
15
+ typography: {
16
+ paragraph1
17
+ },
18
+ spacing
19
+ } = theme;
18
20
  const AccordionDetails = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
19
21
  children,
20
22
  className,
@@ -52,7 +54,7 @@ const DetailsRootCSS = css`
52
54
  .DGN-UI-Accordion-Details-Content {
53
55
  ${borderBox};
54
56
  ${paragraph1};
55
- padding: 0 24px 16px 24px;
57
+ padding: 0 ${spacing(6)}px ${spacing(4)}px ${spacing(6)}px;
56
58
  color: ${main};
57
59
  &.disabled {
58
60
  ${pointerEventsNone}
@@ -66,13 +68,13 @@ AccordionDetails.defaultProps = {
66
68
  id: ''
67
69
  };
68
70
  AccordionDetails.propTypes = {
69
- /** The element to display in alert like text props (priority) */
71
+ /** The content of the component. */
70
72
  children: PropTypes.node,
71
73
 
72
- /** class for De */
73
- className: PropTypes.string,
74
+ /** Style inline of component. */
75
+ style: PropTypes.object,
74
76
 
75
- /** style inline of component */
76
- style: PropTypes.object
77
+ /** Class for component. */
78
+ className: PropTypes.string
77
79
  };
78
80
  export default AccordionDetails;
@@ -41,10 +41,10 @@ const AccordionGroup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
41
41
  ref: ref,
42
42
  style: style,
43
43
  className: ['DGN-UI-Accordion-Group', className].join(' ').trim().replace(/\s+/g, ' ')
44
- }, Children.map(children, child => /*#__PURE__*/cloneElement(child, {
44
+ }, Children.map(children, child => child && /*#__PURE__*/cloneElement(child, {
45
45
  onExpand: e => onCollapseOther(e, child.props.onExpand)
46
46
  })));
47
- }, [className, children]);
47
+ }, [style, className, children]);
48
48
  }));
49
49
  const AccordionGroupRootCSS = css`
50
50
  ${borderRadius4px};
@@ -113,16 +113,16 @@ AccordionGroup.defaultProps = {
113
113
  style: {}
114
114
  };
115
115
  AccordionGroup.propTypes = {
116
- /** collapse other if true */
117
- collapseOther: PropTypes.bool,
116
+ /** The content of the component. */
117
+ children: PropTypes.node,
118
118
 
119
- /** class on element */
120
- className: PropTypes.string,
119
+ /** Style inline of component. */
120
+ style: PropTypes.object,
121
121
 
122
- /** insist <Accordion /> */
123
- children: PropTypes.node.isRequired,
122
+ /** Class for component. */
123
+ className: PropTypes.string,
124
124
 
125
- /** style inline of component */
126
- style: PropTypes.object
125
+ /** If `true`, collapse other when expand */
126
+ collapseOther: PropTypes.bool
127
127
  };
128
128
  export default AccordionGroup;
@@ -7,13 +7,16 @@ import { jsx, css } from '@emotion/core';
7
7
  import AccordionContext from './context';
8
8
  import Divider from '../divider';
9
9
  import { borderRadius4px, displayBlock, positionRelative } from '../../styles/general';
10
- import { color as colors } from '../../styles/colors';
10
+ import theme from '../../theme/settings';
11
11
  const {
12
- line: {
13
- category
12
+ colors: {
13
+ line: {
14
+ category
15
+ }
14
16
  }
15
- } = colors;
17
+ } = theme;
16
18
  const Accordion = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
19
+ id,
17
20
  disabled,
18
21
  expand,
19
22
  expanded,
@@ -57,6 +60,7 @@ const Accordion = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
57
60
  });
58
61
  return useMemo(() => {
59
62
  return jsx("div", {
63
+ id: id,
60
64
  css: AccordionRootCSS,
61
65
  ref: ref,
62
66
  style: style,
@@ -78,7 +82,7 @@ const Accordion = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
78
82
  display: 'none'
79
83
  }
80
84
  })));
81
- }, [disabled, className, boxShadow, onClick, children, expanded, onExpand, onCollapse, expandState]);
85
+ }, [id, disabled, className, boxShadow, onClick, children, expanded, onExpand, onCollapse, expandState]);
82
86
  }));
83
87
  const AccordionRootCSS = css`
84
88
  ${displayBlock};
@@ -102,31 +106,31 @@ Accordion.defaultProps = {
102
106
  style: {}
103
107
  };
104
108
  Accordion.propTypes = {
105
- /** prevent all event if true */
109
+ /** The content of the component (insist <AccordionSummary />, <AccordionDetails />). */
110
+ children: PropTypes.node,
111
+
112
+ /** Style inline of component. */
113
+ style: PropTypes.object,
114
+
115
+ /** Class for component. */
116
+ className: PropTypes.string,
117
+
118
+ /** If `true`, the component is disabled. */
106
119
  disabled: PropTypes.bool,
107
120
 
108
- /** expand immediate after render if true (don't use this) */
121
+ /** If `true`, expand immediate after render (shouldn't use this). */
109
122
  expand: PropTypes.bool,
110
123
 
111
- /** expand state of accordion (use this) */
124
+ /** Expand state of accordion (should use this). */
112
125
  expanded: PropTypes.bool,
113
126
 
114
- /** class on element */
115
- className: PropTypes.string,
116
-
117
- /** class on element */
127
+ /** The box-shadow of component. */
118
128
  boxShadow: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
119
129
 
120
- /** The function will run after expand Accordion detail */
130
+ /** Callback fired when Accordion is expanded. */
121
131
  onExpand: PropTypes.func,
122
132
 
123
- /** The function will run after collapse Accordion detail */
124
- onCollapse: PropTypes.func,
125
-
126
- /** insist <AccordionSummary />, <AccordionDetails /> */
127
- children: PropTypes.node,
128
-
129
- /** style inline of component */
130
- style: PropTypes.object
133
+ /** Callback fired when Accordion is collapsed. */
134
+ onCollapse: PropTypes.func
131
135
  };
132
136
  export default Accordion;
@@ -8,6 +8,7 @@ import { renderIcon } from '../../utils';
8
8
  import { SummaryRootCSS } from './css';
9
9
  import AccordionContext from './context';
10
10
  const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
11
+ id,
11
12
  expandIcon,
12
13
  collapseIcon,
13
14
  expandIconAt,
@@ -18,9 +19,6 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
18
19
  expandIconProps,
19
20
  style
20
21
  }, reference) => {
21
- const ref = useRef(null);
22
- const expandIconRef = useRef(null);
23
- const timer = useRef(null);
24
22
  const {
25
23
  expanded,
26
24
  expandState,
@@ -30,8 +28,13 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
30
28
  onCollapse,
31
29
  setExpandState
32
30
  } = useContext(AccordionContext);
31
+ const ref = useRef(null);
32
+ const expandIconRef = useRef(null);
33
+ const timer = useRef(null);
33
34
 
34
- const onClickHandler = e => {
35
+ const _SummaryRootCSS = SummaryRootCSS(background);
36
+
37
+ const _onClick = e => {
35
38
  if (!disabled) {
36
39
  const target = e.target;
37
40
 
@@ -93,19 +96,6 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
93
96
  }
94
97
  };
95
98
 
96
- useEffect(() => {
97
- if (/^(#|rgb)/.test(background)) {
98
- if (ref.current) {
99
- ref.current.style.backgroundColor = background;
100
- }
101
-
102
- return () => {
103
- if (ref.current) {
104
- ref.current.style.backgroundColor = null;
105
- }
106
- };
107
- }
108
- }, [background]);
109
99
  useEffect(() => {
110
100
  if (expandState) {
111
101
  showHideDetailHandler('show');
@@ -124,19 +114,20 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
124
114
  });
125
115
  return useMemo(() => {
126
116
  return jsx("div", {
127
- css: SummaryRootCSS,
117
+ id: id,
118
+ css: _SummaryRootCSS,
128
119
  ref: ref,
129
120
  tabIndex: "-1",
130
- onClick: onClickHandler,
121
+ onClick: _onClick,
131
122
  style: style,
132
- className: ['DGN-UI-Accordion-Summary', disabled ? 'disabled' : '', expandIcon ? expandIconAt : '', className, background === true ? 'background' : '', expandState ? 'expanding' : ''].join(' ').trim().replace(/\s+/g, ' ')
123
+ className: ['DGN-UI-Accordion-Summary', disabled ? 'disabled' : '', expandIcon ? expandIconAt : '', expandState ? 'expanding' : '', className].join(' ').trim().replace(/\s+/g, ' ')
133
124
  }, jsx("div", {
134
125
  className: 'DGN-UI-Accordion-Summary-Content'
135
126
  }, children), !!expandIcon && jsx("div", {
136
127
  className: 'Accordion-Icon-Root'
137
128
  }, jsx("div", { ...expandIconProps,
138
129
  ref: expandIconRef,
139
- className: ['Accordion-Icon', collapseIcon ? '' : 'rotate-able', expandIconProps.className ? expandIconProps.className : ''].join(' ').trim()
130
+ className: ['Accordion-Icon', collapseIcon ? '' : 'rotate-able', expandIconProps.className ? expandIconProps.className : ''].join(' ').trim().replace(/\s+/g, ' ')
140
131
  }, typeof expandIcon === 'string' ? renderIcon(expandIcon, 'effect', {
141
132
  className: 'Accordion-Expand-Icon'
142
133
  }) : jsx("span", {
@@ -146,7 +137,7 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
146
137
  }) : jsx("span", {
147
138
  className: 'Accordion-Collapse-Icon effect'
148
139
  }, collapseIcon)))));
149
- }, [expandIcon, expandIconAt, className, background, children, collapseIcon, expandIconProps, expandState]);
140
+ }, [id, expandIcon, expandIconAt, className, background, children, collapseIcon, expandIconProps, expandState]);
150
141
  }));
151
142
  AccordionSummary.defaultProps = {
152
143
  expandIconAt: 'start',
@@ -156,28 +147,28 @@ AccordionSummary.defaultProps = {
156
147
  style: {}
157
148
  };
158
149
  AccordionSummary.propTypes = {
159
- /** the icon to display for expand icon */
150
+ /** The content of the component. */
151
+ children: PropTypes.node,
152
+
153
+ /** Style inline of component. */
154
+ style: PropTypes.object,
155
+
156
+ /** Class for component. */
157
+ className: PropTypes.string,
158
+
159
+ /** Icon display for expand icon. */
160
160
  expandIcon: PropTypes.any,
161
161
 
162
- /** the icon to display for collapse icon */
162
+ /** Icon display for collapse icon. */
163
163
  collapseIcon: PropTypes.any,
164
164
 
165
- /** the position to render expand icon */
165
+ /** Position to render icon. */
166
166
  expandIconAt: PropTypes.oneOf(['start', 'end']),
167
167
 
168
- /** background for label summary */
168
+ /** Background for label summary. */
169
169
  background: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
170
170
 
171
- /** class for Summary component */
172
- className: PropTypes.string,
173
-
174
- /** The element to display in alert like text props (priority) */
175
- children: PropTypes.node,
176
-
177
- /** props of expand and collapse icons */
178
- expandIconProps: PropTypes.any,
179
-
180
- /** style inline of component */
181
- style: PropTypes.object
171
+ /** Other props of icons. */
172
+ expandIconProps: PropTypes.any
182
173
  };
183
174
  export default AccordionSummary;
@@ -86,7 +86,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
86
86
  padding-top: 4px;
87
87
  &:not(:focus-within):hover {
88
88
  &::before {
89
- border-bottom-color: ${colors.brand};
89
+ ${!readOnly && `border-bottom-color: ${colors.brand}`};
90
90
  }
91
91
  }
92
92
  &:focus-within {
@@ -125,11 +125,13 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
125
125
  box-sizing: border-box;
126
126
  background-color: ${colors.white};
127
127
  &:not(:focus-within):hover {
128
- background-color: ${colors.hover};
129
- border-color: ${colors.brand};
130
- input {
128
+ ${!readOnly && `
131
129
  background-color: ${colors.hover};
132
- }
130
+ border-color: ${colors.brand};
131
+ input {
132
+ background-color: ${colors.hover};
133
+ }
134
+ `};
133
135
  }
134
136
  &:focus-within {
135
137
  ${!readOnly && `
@@ -203,9 +205,9 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
203
205
  &.outlined {
204
206
  background-color: ${colors.dark12};
205
207
  }
206
- input {
208
+ /* input {
207
209
  color: ${colors.disabled};
208
- }
210
+ } */
209
211
  .start-icon,
210
212
  .end-icon {
211
213
  &:not(.non-effect),
@@ -276,15 +278,17 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
276
278
  position: relative;
277
279
  resize: ${resize};
278
280
  box-sizing: border-box;
279
- &:disabled {
281
+ /* &:disabled {
280
282
  color: ${colors.disabled};
281
- }
283
+ } */
282
284
  &:hover:not(:focus-within) {
283
- border-color: ${colors.brand};
284
- color: ${colors.primary};
285
- ::placeholder {
285
+ ${!readOnly && `
286
+ border-color: ${colors.brand};
286
287
  color: ${colors.primary};
287
- }
288
+ ::placeholder {
289
+ color: ${colors.primary};
290
+ }
291
+ `};
288
292
  }
289
293
  &:focus-within {
290
294
  color: ${colors.primary};
@@ -316,11 +320,13 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
316
320
  height: 24px;
317
321
  }
318
322
  &:not(:focus-within):hover {
319
- background-color: ${colors.hover};
320
- border-color: ${colors.brand};
321
- input {
323
+ ${!readOnly && `
322
324
  background-color: ${colors.hover};
323
- }
325
+ border-color: ${colors.brand};
326
+ input {
327
+ background-color: ${colors.hover};
328
+ }
329
+ `};
324
330
  }
325
331
  &:focus-within {
326
332
  ${!readOnly && `
@@ -351,17 +357,19 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
351
357
  height: 24px;
352
358
  }
353
359
  &:not(:focus-within):hover {
354
- &::before {
360
+ ${!readOnly && `
361
+ &::before {
355
362
  border-bottom-color: ${colors.brand};
356
- }
363
+ }
364
+ `};
357
365
  }
358
366
  &:focus-within {
359
367
  ${!readOnly && `
360
- &::after {
361
- border-bottom-color: ${colors.info5};
362
- transform: scaleX(1);
363
- }
364
- `}
368
+ &::after {
369
+ border-bottom-color: ${colors.info5};
370
+ transform: scaleX(1);
371
+ }
372
+ `}
365
373
  }
366
374
  &::before {
367
375
  content: '';
@@ -386,7 +394,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
386
394
  &.disabled {
387
395
  pointer-events: none;
388
396
  resize: none;
389
- color: ${colors.disabled};
397
+ /* color: ${colors.disabled}; */
390
398
  &.outlined {
391
399
  background-color: ${colors.dark12};
392
400
  }
@@ -7,6 +7,7 @@ export const TreeViewRootCSS = css`
7
7
  .DGN-UI-Accordion {
8
8
  box-shadow: none !important;
9
9
  .DGN-UI-Accordion-Summary {
10
+ ${alignCenter};
10
11
  min-height: 40px;
11
12
  padding: 0;
12
13
  border-radius: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.50",
3
+ "version": "1.3.51",
4
4
  "description": "The DigiNet core ui",
5
5
  "homepage": "https://diginet.com.vn",
6
6
  "main": "index.js",
@@ -13,10 +13,7 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@emotion/core": "^10.0.35",
16
- "@emotion/styled": "^10.0.27",
17
- "prop-types": "^15.7.2",
18
- "react": "^16.12.0",
19
- "react-dom": "^16.12.0"
16
+ "prop-types": "^15.7.2"
20
17
  },
21
18
  "repository": {
22
19
  "type": "git",
package/readme.md CHANGED
@@ -38,6 +38,11 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
+ ## 1.3.51
42
+ - \[Fixed\]: THEME – Fix bug makeStyles add duplicate style tag into head tag
43
+ - \[Fixed\]: Accordion – Change css AccordionSummary; Fix when children of AccordionGroup null
44
+ - \[Fixed\]: InputBase – Fix disabled css
45
+
41
46
  ## 1.3.50
42
47
  - \[Fixed\]: Dropdown – Fix dropdown onInput search
43
48
 
package/styles/general.js CHANGED
@@ -177,7 +177,7 @@ export const parseWidth = width => css`
177
177
  export const parseHeight = height => css`
178
178
  height: ${isNaN(height) ? height : height + 'px'};
179
179
  `;
180
- export const parseWidthHeight = (width, height) => css`
180
+ export const parseWidthHeight = (width, height = width) => css`
181
181
  width: ${isNaN(width) ? width : width + 'px'};
182
182
  height: ${isNaN(height) ? height : height + 'px'};
183
183
  `;
@@ -1,6 +1,12 @@
1
1
  import { css } from '@emotion/core';
2
2
  import theme from './settings';
3
- export const makeStylesEls = [];
3
+ let makeStylesEls = [];
4
+
5
+ const setMakeStylesEls = value => {
6
+ makeStylesEls = value;
7
+ };
8
+
9
+ export { makeStylesEls, setMakeStylesEls };
4
10
 
5
11
  const makeStyle = obj => {
6
12
  if (typeof obj === 'function') {
@@ -65,11 +71,14 @@ const separateStyle = (className, style) => {
65
71
  };
66
72
 
67
73
  const createStyle = (className, style) => {
74
+ const styleInnerHTML = `${/@media/.test(className) ? '' : '.'}${className} {${style}}`; // Nếu đã có style trong head thì không thêm vào nữa
75
+
76
+ if (checkExist(styleInnerHTML)) return;
68
77
  const styleEl = document.createElement('style');
69
78
  styleEl.type = 'text/css';
70
79
  styleEl.dataMeta = 'makeStyles';
71
80
  document.head.appendChild(styleEl);
72
- styleEl.appendChild(document.createTextNode(`${/@media/.test(className) ? '' : '.'}${className} {${style}}`));
81
+ styleEl.appendChild(document.createTextNode(styleInnerHTML));
73
82
  makeStylesEls.push(styleEl);
74
83
  };
75
84
 
@@ -92,4 +101,12 @@ const getEndBraces = (str, start) => {
92
101
  return temp;
93
102
  };
94
103
 
104
+ const checkExist = styleInnerHTML => {
105
+ let isExist = false;
106
+ makeStylesEls.some(el => {
107
+ if (el.innerHTML === styleInnerHTML) isExist = true;
108
+ });
109
+ return isExist;
110
+ };
111
+
95
112
  export default makeStyle;
@@ -4,7 +4,7 @@
4
4
  import { memo, useEffect } from 'react';
5
5
  import { jsx, css } from '@emotion/core';
6
6
  import { setTheme } from './set-theme';
7
- import { makeStylesEls } from './make-styles';
7
+ import { makeStylesEls, setMakeStylesEls } from './make-styles';
8
8
  import { string, object, node } from 'prop-types';
9
9
  import { font } from '../styles/font';
10
10
  const {
@@ -50,6 +50,7 @@ const ThemeProvider = /*#__PURE__*/memo(({
50
50
  children
51
51
  }) => {
52
52
  useEffect(() => {
53
+ setMakeStylesEls([]);
53
54
  return () => {
54
55
  if (makeStylesEls.length) {
55
56
  makeStylesEls.forEach(el => el && el.remove && el.remove());
@@ -0,0 +1,19 @@
1
+ import { useState, useEffect } from 'react';
2
+
3
+ const useDelayUnmount = (isMounted, delayTime) => {
4
+ const [show, setShow] = useState(false);
5
+ useEffect(() => {
6
+ let timeoutId;
7
+
8
+ if (isMounted && !show) {
9
+ setShow(true);
10
+ } else if (!isMounted && show) {
11
+ timeoutId = setTimeout(() => setShow(false), delayTime);
12
+ }
13
+
14
+ return () => clearTimeout(timeoutId);
15
+ }, [isMounted, delayTime, show]);
16
+ return show;
17
+ };
18
+
19
+ export default useDelayUnmount;