diginet-core-ui 1.3.83-beta.1 → 1.3.84-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.
@@ -1,51 +1,46 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
3
  import { css, jsx } from '@emotion/core';
4
+ import { Icon, Typography } from "./..";
5
+ import OptionWrapper from "../others/option-wrapper";
4
6
  import PropTypes from 'prop-types';
5
7
  import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
6
- import { Typography } from "../";
7
- import Icon from "../../icons";
8
- import { alignCenter, backgroundTransparent, borderBox, flexRow } from "../../styles/general";
9
- import theme from "../../theme/settings";
10
- import OptionWrapper from "../others/option-wrapper";
8
+ import { alignCenter, backgroundTransparent, borderBox, flexRow, parseMinHeight, parseWidth } from "../../styles/general";
9
+ import { useTheme, useColor as colors } from "../../theme";
10
+ import { classNames } from "../../utils";
11
11
  const {
12
12
  colors: {
13
13
  system: {
14
- active,
15
- rest
16
- },
17
- semantic: {
18
- success,
19
- warning,
20
- danger,
21
- info
14
+ rest: systemRest
22
15
  },
23
16
  fill: {
24
- sidebar
17
+ sidebar: fillSidebar
25
18
  }
26
- }
27
- } = theme;
28
- const colorMap = new Map([['default', rest], ['primary', active], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
19
+ },
20
+ spacing
21
+ } = useTheme();
22
+ const colorMap = new Map([['default', systemRest]]);
29
23
  const iconSizeMap = new Map([['small', '16px'], ['medium', '20px'], ['large', '24px']]);
30
24
  const typographySizeMap = new Map([['small', 'p3'], ['medium', 'p2'], ['large', 'p1']]);
31
- const filledPaddingSizeMap = new Map([['small', '2px 8px'], ['medium', '2px 12px'], ['large', '2px 12px']]);
25
+ const filledPaddingSizeMap = new Map([['small', spacing([0.5, 2])], ['medium', spacing([0.5, 2])], ['large', spacing([0.5, 3])]]);
32
26
  const Status = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
33
27
  action = {},
34
28
  className,
35
- color,
29
+ color: colorProp,
36
30
  icon,
31
+ id,
37
32
  size,
33
+ style,
38
34
  text,
39
- viewType,
40
- id,
41
- style
35
+ viewType
42
36
  }, reference) => {
37
+ if (!reference) reference = useRef(null);
43
38
  const ref = useRef(null);
44
39
  const outlinedPaddingSize = filledPaddingSizeMap.get(size);
45
- const _color = colorMap.get(color) || color || rest;
40
+ const color = colorMap.get(colorProp) || colors[colorProp] || colorProp || systemRest;
46
41
  const iconSize = iconSizeMap.get(size);
47
42
  const typographySize = typographySizeMap.get(size);
48
- const _StatusRoot = StatusRoot(iconSize, _color, size, outlinedPaddingSize);
43
+ const _StatusRootCSS = StatusRootCSS(iconSize, color, size, outlinedPaddingSize);
49
44
  useImperativeHandle(reference, () => {
50
45
  const currentRef = ref.current || {};
51
46
  currentRef.element = ref.current;
@@ -56,40 +51,41 @@ const Status = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
56
51
  currentRef.instance = _instance;
57
52
  return currentRef;
58
53
  });
59
- const StatusIcon = typeof icon === 'string' ? jsx(Icon, {
54
+ const StatusIconView = typeof icon === 'string' ? jsx(Icon, {
60
55
  name: icon,
61
56
  width: iconSize,
62
57
  height: iconSize,
63
58
  color: 'currentColor',
64
59
  viewBox: true
65
60
  }) : icon;
66
- const StatusText = jsx(Typography, {
61
+ const StatusTextView = jsx(Typography, {
67
62
  css: TextCSS,
68
63
  type: typographySize,
69
64
  color: 'inherit'
70
65
  }, text);
71
66
  return useMemo(() => {
72
67
  return jsx("div", {
73
- css: _StatusRoot,
68
+ css: _StatusRootCSS,
74
69
  ref: ref,
75
70
  id: id,
76
71
  style: style,
77
- className: ['DGN-UI-Status', viewType, size, className].join(' ').trim().replace(/\s+/g, ' ')
78
- }, StatusIcon, StatusText);
79
- }, [className, color, icon, size, text, viewType, id, style]);
72
+ className: classNames('DGN-UI-Status', viewType, size, className)
73
+ }, StatusIconView, StatusTextView);
74
+ }, [className, colorProp, icon, id, size, style, text, viewType]);
80
75
  }));
81
- const StatusRoot = (iconSize, color, size, outlinedPaddingSize) => css`
76
+ const StatusRootCSS = (iconSize, color, size, outlinedPaddingSize) => css`
82
77
  ${flexRow};
83
78
  ${alignCenter};
84
79
  ${backgroundTransparent};
85
80
  ${borderBox};
86
- gap: ${size === 'small' ? '2px' : '4px'};
87
- min-height: ${iconSize};
81
+ ${parseWidth('fit-content')};
82
+ ${parseMinHeight(iconSize)};
83
+ gap: ${spacing([size === 'small' ? 0.5 : 1])};
88
84
  color: ${color};
89
85
  &.filled {
90
- color: ${sidebar};
86
+ color: ${fillSidebar};
91
87
  background-color: ${color};
92
- border-radius: 12px;
88
+ border-radius: 20px;
93
89
  &.${size} {
94
90
  padding: ${outlinedPaddingSize};
95
91
  }
@@ -99,12 +95,12 @@ const TextCSS = css`
99
95
  white-space: nowrap;
100
96
  `;
101
97
  Status.defaultProps = {
102
- viewType: 'ghost',
103
- text: '',
98
+ className: '',
104
99
  icon: '',
105
100
  size: 'medium',
106
- className: '',
107
- style: {}
101
+ style: {},
102
+ text: '',
103
+ viewType: 'ghost'
108
104
  };
109
105
  Status.propTypes = {
110
106
  /** Class for component. */
@@ -115,12 +111,12 @@ Status.propTypes = {
115
111
  icon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
116
112
  /** The size of the component. */
117
113
  size: PropTypes.oneOf(['small', 'medium', 'large']),
114
+ /** Style inline of component. */
115
+ style: PropTypes.object,
118
116
  /** The content of the component. */
119
117
  text: PropTypes.string,
120
118
  /** The variant to use. */
121
- viewType: PropTypes.oneOf(['filled', 'default', 'ghost']),
122
- /** Style inline of component. */
123
- style: PropTypes.object
119
+ viewType: PropTypes.oneOf(['filled', 'ghost'])
124
120
  };
125
121
  export { Status };
126
122
  export default OptionWrapper(Status);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.83-beta.1",
3
+ "version": "1.3.84-beta.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",
package/readme.md CHANGED
@@ -38,6 +38,10 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
+ ## 1.3.84
42
+ - \[Fixed\]: Badge – Remove animation, conditional rendering with prop invisible
43
+ - \[Fixed\]: InputBase – Fix css focus when readOnly
44
+
41
45
  ## 1.3.83
42
46
  - \[Changed\]: IconMenu – Add prop className, style
43
47
  - \[Changed\]: Grid – Add prop verticalAlign
package/styles/general.js CHANGED
@@ -1,15 +1,14 @@
1
- /* eslint-disable no-unused-vars */
2
- import { css, jsx } from '@emotion/core';
1
+ import { css } from '@emotion/core';
3
2
  import { color } from "./colors";
4
3
  import { parseToPixel } from "./utils";
5
4
  export const rootSpacing = 4;
6
5
  export let rootZIndex = 1500;
7
6
  export const typographyTypes = ['t1', 't2', 't3', 't4', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p1', 'p2', 'p3', 'title1', 'title2', 'title3', 'title4', 'heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6', 'paragraph1', 'paragraph2', 'paragraph3'];
8
7
 
9
- /**
10
- * get value spacing with rootZIndex
11
- * @param number
12
- * @return {number}
8
+ /**
9
+ * get value spacing with rootZIndex
10
+ * @param number
11
+ * @return {number}
13
12
  */
14
13
  export const zIndex = number => {
15
14
  number = Number(number || 0);
@@ -17,10 +16,10 @@ export const zIndex = number => {
17
16
  return rootZIndex + number;
18
17
  };
19
18
 
20
- /**
21
- * get value spacing with rootSpacing
22
- * @param {(number|number[])} vl - default 1
23
- * @returns {(number|string)}
19
+ /**
20
+ * get value spacing with rootSpacing
21
+ * @param {(number|number[])} vl - default 1
22
+ * @returns {(number|string)}
24
23
  */
25
24
 
26
25
  export const getSpacing = (vl = 1) => {
@@ -30,191 +29,194 @@ export const getSpacing = (vl = 1) => {
30
29
  }
31
30
  };
32
31
 
33
- /**
34
- * replace rootZIndex
35
- * @param number
32
+ /**
33
+ * replace rootZIndex
34
+ * @param number
36
35
  */
37
36
  export const setZIndex = number => {
38
37
  number = Number(number || 0);
39
38
  if (!isNaN(number)) rootZIndex = number;
40
39
  };
41
- export const flexRow = css`
42
- display: flex;
43
- flex-direction: row;
44
- `;
45
- export const inlineFlex = css`
46
- display: inline-flex;
47
- `;
48
- export const flexCol = css`
49
- display: flex;
50
- flex-direction: column;
51
- `;
52
- export const flexColReverse = css`
53
- display: flex;
54
- flex-direction: column-reverse;
55
- `;
56
- export const flexRowReverse = css`
57
- flex-direction: row-reverse;
58
- `;
59
- export const flexWrap = css`
60
- display: flex;
61
- flex-wrap: wrap;
62
- `;
63
- export const alignStart = css`
64
- align-items: flex-start;
65
- `;
66
- export const alignCenter = css`
40
+
41
+ // Common CSS
42
+ const alignCenter = css`
67
43
  align-items: center;
68
44
  `;
69
- export const alignEnd = css`
45
+ const alignEnd = css`
70
46
  align-items: flex-end;
71
47
  `;
72
- export const justifyStart = css`
73
- justify-content: flex-start;
74
- `;
75
- export const justifyCenter = css`
76
- justify-content: center;
77
- `;
78
- export const justifyEnd = css`
79
- justify-content: flex-end;
80
- `;
81
- export const justifyBetween = css`
82
- justify-content: space-between;
48
+ const alignStart = css`
49
+ align-items: flex-start;
83
50
  `;
84
- export const displayBlock = css`
85
- display: block;
51
+ const backgroundTransparent = css`
52
+ background-color: transparent;
86
53
  `;
87
- export const displayInlineBlock = css`
88
- display: inline-block;
54
+ const border = (withVl, colorVl) => css`
55
+ border: ${parseToPixel(withVl)} solid ${colorVl || color.dark};
89
56
  `;
90
- export const positionRelative = css`
91
- position: relative;
57
+ const borderBox = css`
58
+ box-sizing: border-box;
92
59
  `;
93
- export const positionAbsolute = css`
94
- position: absolute;
60
+ const borderNone = css`
61
+ border: none;
95
62
  `;
96
- export const positionFixed = css`
97
- position: fixed;
63
+ const borderRadius100 = css`
64
+ border-radius: 100%;
98
65
  `;
99
- export const borderRadius4px = css`
66
+ const borderRadius4px = css`
100
67
  border-radius: 4px;
101
68
  `;
102
- export const borderRadius50 = css`
69
+ const borderRadius50 = css`
103
70
  border-radius: 50%;
104
71
  `;
105
- export const borderRadius100 = css`
106
- border-radius: 100%;
72
+ const boxShadowNone = css`
73
+ box-shadow: none;
107
74
  `;
108
- export const borderBox = css`
109
- box-sizing: border-box;
75
+ const breakAll = css`
76
+ word-break: break-all;
77
+ `;
78
+ const breakWord = css`
79
+ word-break: break-word;
110
80
  `;
111
- export const cursorDefault = css`
81
+ const cursorDefault = css`
112
82
  cursor: default;
113
83
  `;
114
- export const cursorInherit = css`
84
+ const cursorInherit = css`
115
85
  cursor: inherit;
116
86
  `;
117
- export const cursorNotAllowed = css`
87
+ const cursorNoDrop = css`
88
+ cursor: no-drop !important;
89
+ `;
90
+ const cursorNotAllowed = css`
118
91
  cursor: not-allowed;
119
92
  `;
120
- export const cursorPointer = css`
93
+ const cursorPointer = css`
121
94
  cursor: pointer;
122
95
  `;
123
- export const overflowAuto = css`
124
- overflow: auto;
96
+ const displayBlock = css`
97
+ display: block;
125
98
  `;
126
- export const overflowHidden = css`
127
- overflow: hidden;
99
+ const displayInlineBlock = css`
100
+ display: inline-block;
128
101
  `;
129
- export const backgroundTransparent = css`
130
- background-color: transparent;
102
+ const displayNone = css`
103
+ display: none;
131
104
  `;
132
- export const ellipsis = css`
105
+ const ellipsis = css`
133
106
  white-space: nowrap;
134
107
  text-overflow: ellipsis;
135
108
  overflow: hidden;
136
109
  `;
137
- export const whiteSpaceNoWrap = css`
138
- white-space: nowrap;
139
- `;
140
- export const breakAll = css`
141
- word-break: break-all;
110
+ const flexCol = css`
111
+ display: flex;
112
+ flex-direction: column;
142
113
  `;
143
- export const breakWord = css`
144
- word-break: break-word;
114
+ const flexColReverse = css`
115
+ display: flex;
116
+ flex-direction: column-reverse;
145
117
  `;
146
- export const textCapitalize = css`
147
- text-transform: capitalize;
118
+ const flexRow = css`
119
+ display: flex;
120
+ flex-direction: row;
148
121
  `;
149
- export const textUppercase = css`
150
- text-transform: uppercase;
122
+ const flexRowReverse = css`
123
+ flex-direction: row-reverse;
151
124
  `;
152
- export const textCenter = css`
153
- text-align: center;
125
+ const flexWrap = css`
126
+ display: flex;
127
+ flex-wrap: wrap;
154
128
  `;
155
- export const outlineNone = css`
156
- outline: none;
129
+ const inlineFlex = css`
130
+ display: inline-flex;
157
131
  `;
158
- export const userSelectNone = css`
159
- user-select: none;
132
+ const justifyBetween = css`
133
+ justify-content: space-between;
160
134
  `;
161
- export const cursorNoDrop = css`
162
- cursor: no-drop !important;
135
+ const justifyCenter = css`
136
+ justify-content: center;
163
137
  `;
164
- export const pointerEventsNone = css`
165
- pointer-events: none;
138
+ const justifyEnd = css`
139
+ justify-content: flex-end;
166
140
  `;
167
- export const borderNone = css`
168
- border: none;
141
+ const justifyStart = css`
142
+ justify-content: flex-start;
169
143
  `;
170
- export const boxShadowNone = css`
171
- box-shadow: none;
144
+ const noBorder = css`
145
+ border: none !important;
172
146
  `;
173
- export const displayNone = css`
174
- display: none;
147
+ const noBoxShadow = css`
148
+ box-shadow: none !important;
175
149
  `;
176
- export const noMargin = css`
150
+ const noMargin = css`
177
151
  margin: 0 !important;
178
152
  `;
179
- export const noPadding = css`
153
+ const noPadding = css`
180
154
  padding: 0 !important;
181
155
  `;
182
- export const noBorder = css`
183
- border: none !important;
184
- `;
185
- export const noBoxShadow = css`
186
- box-shadow: none !important;
156
+ const outlineNone = css`
157
+ outline: none;
187
158
  `;
188
- export const border = (withVl, colorVl) => css`
189
- border: ${parseToPixel(withVl)} solid ${colorVl || color.dark};
159
+ const overflowAuto = css`
160
+ overflow: auto;
190
161
  `;
191
- export const parseWidth = width => css`
192
- width: ${isNaN(width) ? width : width + 'px'};
162
+ const overflowHidden = css`
163
+ overflow: hidden;
193
164
  `;
194
- export const parseHeight = height => css`
165
+ const parseHeight = height => css`
195
166
  height: ${isNaN(height) ? height : height + 'px'};
196
167
  `;
197
- export const parseWidthHeight = (width, height = width) => css`
198
- width: ${isNaN(width) ? width : width + 'px'};
199
- height: ${isNaN(height) ? height : height + 'px'};
168
+ const parseMaxHeight = height => css`
169
+ max-height: ${isNaN(height) ? height : height + 'px'};
200
170
  `;
201
- export const parseMinWidth = width => css`
202
- min-width: ${isNaN(width) ? width : width + 'px'};
171
+ const parseMaxWidth = width => css`
172
+ max-width: ${isNaN(width) ? width : width + 'px'};
173
+ `;
174
+ const parseMaxWidthHeight = (width, height = width) => css`
175
+ max-width: ${isNaN(width) ? width : width + 'px'};
176
+ max-height: ${isNaN(height) ? height : height + 'px'};
203
177
  `;
204
- export const parseMinHeight = height => css`
178
+ const parseMinHeight = height => css`
205
179
  min-height: ${isNaN(height) ? height : height + 'px'};
206
180
  `;
207
- export const parseMinWidthHeight = (width, height = width) => css`
181
+ const parseMinWidth = width => css`
182
+ min-width: ${isNaN(width) ? width : width + 'px'};
183
+ `;
184
+ const parseMinWidthHeight = (width, height = width) => css`
208
185
  min-width: ${isNaN(width) ? width : width + 'px'};
209
186
  min-height: ${isNaN(height) ? height : height + 'px'};
210
187
  `;
211
- export const parseMaxWidth = width => css`
212
- max-width: ${isNaN(width) ? width : width + 'px'};
188
+ const parseWidth = width => css`
189
+ width: ${isNaN(width) ? width : width + 'px'};
213
190
  `;
214
- export const parseMaxHeight = height => css`
215
- max-height: ${isNaN(height) ? height : height + 'px'};
191
+ const parseWidthHeight = (width, height = width) => css`
192
+ width: ${isNaN(width) ? width : width + 'px'};
193
+ height: ${isNaN(height) ? height : height + 'px'};
216
194
  `;
217
- export const parseMaxWidthHeight = (width, height = width) => css`
218
- max-width: ${isNaN(width) ? width : width + 'px'};
219
- max-height: ${isNaN(height) ? height : height + 'px'};
220
- `;
195
+ const pointerEventsNone = css`
196
+ pointer-events: none;
197
+ `;
198
+ const positionAbsolute = css`
199
+ position: absolute;
200
+ `;
201
+ const positionFixed = css`
202
+ position: fixed;
203
+ `;
204
+ const positionRelative = css`
205
+ position: relative;
206
+ `;
207
+ const textCapitalize = css`
208
+ text-transform: capitalize;
209
+ `;
210
+ const textCenter = css`
211
+ text-align: center;
212
+ `;
213
+ const textUppercase = css`
214
+ text-transform: uppercase;
215
+ `;
216
+ const userSelectNone = css`
217
+ user-select: none;
218
+ `;
219
+ const whiteSpaceNoWrap = css`
220
+ white-space: nowrap;
221
+ `;
222
+ export { alignCenter, alignEnd, alignStart, backgroundTransparent, border, borderBox, borderNone, borderRadius100, borderRadius4px, borderRadius50, boxShadowNone, breakAll, breakWord, cursorDefault, cursorInherit, cursorNoDrop, cursorNotAllowed, cursorPointer, displayBlock, displayInlineBlock, displayNone, ellipsis, flexCol, flexColReverse, flexRow, flexRowReverse, flexWrap, inlineFlex, justifyBetween, justifyCenter, justifyEnd, justifyStart, noBorder, noBoxShadow, noMargin, noPadding, outlineNone, overflowAuto, overflowHidden, parseHeight, parseMaxHeight, parseMaxWidth, parseMaxWidthHeight, parseMinHeight, parseMinWidth, parseMinWidthHeight, parseWidth, parseWidthHeight, pointerEventsNone, positionAbsolute, positionFixed, positionRelative, textCapitalize, textCenter, textUppercase, userSelectNone, whiteSpaceNoWrap };