diginet-core-ui 1.3.66 → 1.3.68
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.
- package/assets/storybook/avatar01.svg +9 -0
- package/assets/storybook/cover01.svg +9 -0
- package/components/accordion/css.js +6 -6
- package/components/accordion/details.js +13 -18
- package/components/accordion/group.js +16 -17
- package/components/accordion/index.js +17 -22
- package/components/accordion/summary.js +55 -32
- package/components/avatar/index.js +4 -9
- package/components/badge/index.js +4 -9
- package/components/button/icon.js +4 -9
- package/components/button/index.js +287 -292
- package/components/card/body.js +47 -0
- package/components/card/extra.js +47 -0
- package/components/card/footer.js +47 -0
- package/components/card/header.js +50 -0
- package/components/card/index.js +175 -37
- package/components/chart/Pie-v2/Sector.js +2 -2
- package/components/chip/attach.js +5 -5
- package/components/form-control/attachment/index.js +5 -3
- package/components/form-control/calendar/function.js +20 -10
- package/components/form-control/calendar/index.js +16 -16
- package/components/form-control/dropdown/index.js +71 -10
- package/components/form-control/helper-text/index.js +8 -3
- package/components/form-control/input-base/index.js +47 -10
- package/components/form-control/money-input/index.js +6 -2
- package/components/form-control/number-input/index.js +11 -11
- package/components/form-control/number-input/index2.js +13 -4
- package/components/form-control/phone-input/index.js +13 -9
- package/components/form-control/text-input/index.js +13 -3
- package/components/grid/Container.js +110 -0
- package/components/grid/Row.js +1 -1
- package/components/grid/index.js +35 -5
- package/components/index.js +7 -2
- package/components/others/option-wrapper/index.js +21 -27
- package/components/paging/page-info.js +263 -88
- package/components/paging/page-selector2.js +95 -56
- package/components/popover/index.js +8 -6
- package/components/progress/circular.js +12 -12
- package/components/transfer/index.js +3 -3
- package/components/tree-view/index.js +10 -6
- package/icons/basic.js +120 -0
- package/icons/effect.js +19 -24
- package/package.json +1 -1
- package/readme.md +20 -0
- package/styles/color-helper.js +103 -103
- package/styles/utils.js +14 -2
- package/utils/classNames.js +30 -0
- package/utils/error/error.js +2 -2
- package/utils/index.js +1 -0
- package/utils/renderIcon.js +5 -5
- package/utils/useInput.js +1 -8
- package/components/card/body-card.js +0 -65
- package/components/card/card.js +0 -125
- package/components/card/context.js +0 -6
package/readme.md
CHANGED
|
@@ -38,6 +38,26 @@ npm test
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Changelog
|
|
41
|
+
## 1.3.68
|
|
42
|
+
- \[Changed\]: PagingInfo – Update design
|
|
43
|
+
- \[Changed\]: InputBase – Add func auto scale width, apply for NumberInput, TextInput
|
|
44
|
+
- \[Changed\]: PagingSelector – Update functions in PagingSelector
|
|
45
|
+
- \[Changed\]: NumberInput, MoneyInput, PhoneInput – Add prop labelProps
|
|
46
|
+
|
|
47
|
+
## 1.3.67
|
|
48
|
+
- \[Added\]: Icon – ListAlt, PersonSetting, Undo, ViewHeadline
|
|
49
|
+
- \[Changed\]: OptionWrapper – Update OptionWrapper
|
|
50
|
+
- \[Changed\]: Accordion – Change align AccordionSummary content to center
|
|
51
|
+
- \[Changed\]: Dropdown – Add props searchExpr, searchMode
|
|
52
|
+
- \[Changed\]: Row, Container – Update row spacing, Add component Container
|
|
53
|
+
- \[Changed\]: Dropdown – Add hover tooltip when selected text value too long
|
|
54
|
+
- \[Changed\]: Card – Update design
|
|
55
|
+
- \[Changed\]: HelperText – Add props of Typography
|
|
56
|
+
- \[Changed\]: Dropdown – Add hidden render item
|
|
57
|
+
- \[Fixed\]: Button – Fix typography by size
|
|
58
|
+
- \[Fixed\]: TECH – Fix babel warning
|
|
59
|
+
- \[Fixed\]: Dropdown – Fix dropdown render out of screen
|
|
60
|
+
|
|
41
61
|
## 1.3.66
|
|
42
62
|
- \[Changed\]: THEME – Update makestyles
|
|
43
63
|
- \[Changed\]: THEME – Refactoring makeStyles
|
package/styles/color-helper.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* eslint-disable no-undef */
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Returns a number whose value is limited to the given range.
|
|
5
|
-
*
|
|
6
|
-
* @param {number} value The value to be clamped
|
|
7
|
-
* @param {number} min The lower boundary of the output range
|
|
8
|
-
* @param {number} max The upper boundary of the output range
|
|
9
|
-
* @returns {number} A number in the range [min, max]
|
|
3
|
+
/**
|
|
4
|
+
* Returns a number whose value is limited to the given range.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} value The value to be clamped
|
|
7
|
+
* @param {number} min The lower boundary of the output range
|
|
8
|
+
* @param {number} max The upper boundary of the output range
|
|
9
|
+
* @returns {number} A number in the range [min, max]
|
|
10
10
|
*/
|
|
11
11
|
const clamp = (value, min = 0, max = 1) => {
|
|
12
12
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -17,11 +17,11 @@ const clamp = (value, min = 0, max = 1) => {
|
|
|
17
17
|
|
|
18
18
|
return Math.min(Math.max(min, value), max);
|
|
19
19
|
};
|
|
20
|
-
/**
|
|
21
|
-
* Converts a color from CSS hex format to CSS rgb format.
|
|
22
|
-
*
|
|
23
|
-
* @param {string} color - Hex color, i.e. #nnn or #nnnnnn
|
|
24
|
-
* @returns {string} A CSS rgb color string
|
|
20
|
+
/**
|
|
21
|
+
* Converts a color from CSS hex format to CSS rgb format.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} color - Hex color, i.e. #nnn or #nnnnnn
|
|
24
|
+
* @returns {string} A CSS rgb color string
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
|
|
@@ -43,11 +43,11 @@ const intToHex = int => {
|
|
|
43
43
|
const hex = int.toString(16);
|
|
44
44
|
return hex.length === 1 ? `0${hex}` : hex;
|
|
45
45
|
};
|
|
46
|
-
/**
|
|
47
|
-
* Converts a color from CSS rgb format to CSS hex format.
|
|
48
|
-
*
|
|
49
|
-
* @param {string} color - RGB color, i.e. rgb(n, n, n)
|
|
50
|
-
* @returns {string} A CSS rgb color string, i.e. #nnnnnn
|
|
46
|
+
/**
|
|
47
|
+
* Converts a color from CSS rgb format to CSS hex format.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} color - RGB color, i.e. rgb(n, n, n)
|
|
50
|
+
* @returns {string} A CSS rgb color string, i.e. #nnnnnn
|
|
51
51
|
*/
|
|
52
52
|
|
|
53
53
|
|
|
@@ -61,11 +61,11 @@ export const rgbToHex = color => {
|
|
|
61
61
|
} = decomposeColor(color);
|
|
62
62
|
return `#${values.map(n => intToHex(n)).join('')}`;
|
|
63
63
|
};
|
|
64
|
-
/**
|
|
65
|
-
* Converts a color from CSS rgb format to CSS hex format.
|
|
66
|
-
*
|
|
67
|
-
* @param {string} color - RGBA color, i.e. rgba(n, n, n, f)
|
|
68
|
-
* @returns {string} A CSS rgb A color string, i.e. #nnnnnnnn
|
|
64
|
+
/**
|
|
65
|
+
* Converts a color from CSS rgb format to CSS hex format.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} color - RGBA color, i.e. rgba(n, n, n, f)
|
|
68
|
+
* @returns {string} A CSS rgb A color string, i.e. #nnnnnnnn
|
|
69
69
|
*/
|
|
70
70
|
|
|
71
71
|
export const rgbaToHexA = color => {
|
|
@@ -98,11 +98,11 @@ export const rgbaToHexA = color => {
|
|
|
98
98
|
if (a.length == 1) a = '0' + a;
|
|
99
99
|
return '#' + r + g + b + a;
|
|
100
100
|
};
|
|
101
|
-
/**
|
|
102
|
-
* Converts a color from hsl format to rgb format.
|
|
103
|
-
*
|
|
104
|
-
* @param {string} color - HSL color values
|
|
105
|
-
* @returns {string} rgb color values
|
|
101
|
+
/**
|
|
102
|
+
* Converts a color from hsl format to rgb format.
|
|
103
|
+
*
|
|
104
|
+
* @param {string} color - HSL color values
|
|
105
|
+
* @returns {string} rgb color values
|
|
106
106
|
*/
|
|
107
107
|
|
|
108
108
|
export const hslToRgb = color => {
|
|
@@ -130,13 +130,13 @@ export const hslToRgb = color => {
|
|
|
130
130
|
values: rgb
|
|
131
131
|
});
|
|
132
132
|
};
|
|
133
|
-
/**
|
|
134
|
-
* Returns an object with the type and values of a color.
|
|
135
|
-
*
|
|
136
|
-
* Note: Does not support rgb % values.
|
|
137
|
-
*
|
|
138
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
139
|
-
* @returns {object} - A color object: {type: string, values: number[]}
|
|
133
|
+
/**
|
|
134
|
+
* Returns an object with the type and values of a color.
|
|
135
|
+
*
|
|
136
|
+
* Note: Does not support rgb % values.
|
|
137
|
+
*
|
|
138
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
139
|
+
* @returns {object} - A color object: {type: string, values: number[]}
|
|
140
140
|
*/
|
|
141
141
|
|
|
142
142
|
export const decomposeColor = color => {
|
|
@@ -162,13 +162,13 @@ export const decomposeColor = color => {
|
|
|
162
162
|
values
|
|
163
163
|
};
|
|
164
164
|
};
|
|
165
|
-
/**
|
|
166
|
-
* Converts a color object with type and values to a string.
|
|
167
|
-
*
|
|
168
|
-
* @param {object} color - Decomposed color
|
|
169
|
-
* @param {string} color.type - One of: 'rgb', 'rgba', 'hsl', 'hsla'
|
|
170
|
-
* @param {array} color.values - [n,n,n] or [n,n,n,n]
|
|
171
|
-
* @returns {string} A CSS color string
|
|
165
|
+
/**
|
|
166
|
+
* Converts a color object with type and values to a string.
|
|
167
|
+
*
|
|
168
|
+
* @param {object} color - Decomposed color
|
|
169
|
+
* @param {string} color.type - One of: 'rgb', 'rgba', 'hsl', 'hsla'
|
|
170
|
+
* @param {array} color.values - [n,n,n] or [n,n,n,n]
|
|
171
|
+
* @returns {string} A CSS color string
|
|
172
172
|
*/
|
|
173
173
|
|
|
174
174
|
export const recomposeColor = color => {
|
|
@@ -189,14 +189,14 @@ export const recomposeColor = color => {
|
|
|
189
189
|
|
|
190
190
|
return `${type}(${values.join(', ')})`;
|
|
191
191
|
};
|
|
192
|
-
/**
|
|
193
|
-
* Calculates the contrast ratio between two colors.
|
|
194
|
-
*
|
|
195
|
-
* Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
|
|
196
|
-
*
|
|
197
|
-
* @param {string} foreground - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
198
|
-
* @param {string} background - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
199
|
-
* @returns {number} A contrast ratio value in the range 0 - 21.
|
|
192
|
+
/**
|
|
193
|
+
* Calculates the contrast ratio between two colors.
|
|
194
|
+
*
|
|
195
|
+
* Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
|
|
196
|
+
*
|
|
197
|
+
* @param {string} foreground - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
198
|
+
* @param {string} background - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
199
|
+
* @returns {number} A contrast ratio value in the range 0 - 21.
|
|
200
200
|
*/
|
|
201
201
|
|
|
202
202
|
export const getContrastRatio = (foreground, background) => {
|
|
@@ -204,14 +204,14 @@ export const getContrastRatio = (foreground, background) => {
|
|
|
204
204
|
const lumB = getLuminance(background);
|
|
205
205
|
return (Math.max(lumA, lumB) + 0.05) / (Math.min(lumA, lumB) + 0.05);
|
|
206
206
|
};
|
|
207
|
-
/**
|
|
208
|
-
* The relative brightness of any point in a color space,
|
|
209
|
-
* normalized to 0 for darkest black and 1 for lightest white.
|
|
210
|
-
*
|
|
211
|
-
* Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
|
|
212
|
-
*
|
|
213
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
214
|
-
* @returns {number} The relative brightness of the color in the range 0 - 1
|
|
207
|
+
/**
|
|
208
|
+
* The relative brightness of any point in a color space,
|
|
209
|
+
* normalized to 0 for darkest black and 1 for lightest white.
|
|
210
|
+
*
|
|
211
|
+
* Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
|
|
212
|
+
*
|
|
213
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
214
|
+
* @returns {number} The relative brightness of the color in the range 0 - 1
|
|
215
215
|
*/
|
|
216
216
|
|
|
217
217
|
export const getLuminance = color => {
|
|
@@ -225,25 +225,25 @@ export const getLuminance = color => {
|
|
|
225
225
|
|
|
226
226
|
return Number((0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]).toFixed(3));
|
|
227
227
|
};
|
|
228
|
-
/**
|
|
229
|
-
* Darken or lighten a color, depending on its luminance.
|
|
230
|
-
* Light colors are darkened, dark colors are lightened.
|
|
231
|
-
*
|
|
232
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
233
|
-
* @param {number} coefficient=0.15 - multiplier in the range 0 - 1
|
|
234
|
-
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
228
|
+
/**
|
|
229
|
+
* Darken or lighten a color, depending on its luminance.
|
|
230
|
+
* Light colors are darkened, dark colors are lightened.
|
|
231
|
+
*
|
|
232
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
233
|
+
* @param {number} coefficient=0.15 - multiplier in the range 0 - 1
|
|
234
|
+
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
235
235
|
*/
|
|
236
236
|
|
|
237
237
|
export const emphasize = (color, coefficient = 0.15) => {
|
|
238
238
|
return getLuminance(color) > 0.5 ? darken(color, coefficient) : lighten(color, coefficient);
|
|
239
239
|
};
|
|
240
|
-
/**
|
|
241
|
-
* Set the absolute transparency of a color.
|
|
242
|
-
* Any existing alpha values are overwritten.
|
|
243
|
-
*
|
|
244
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
245
|
-
* @param {number} value - value to set the alpha channel to in the range 0 -1
|
|
246
|
-
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
240
|
+
/**
|
|
241
|
+
* Set the absolute transparency of a color.
|
|
242
|
+
* Any existing alpha values are overwritten.
|
|
243
|
+
*
|
|
244
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
245
|
+
* @param {number} value - value to set the alpha channel to in the range 0 -1
|
|
246
|
+
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
247
247
|
*/
|
|
248
248
|
|
|
249
249
|
export const fade = (color, value) => {
|
|
@@ -257,12 +257,12 @@ export const fade = (color, value) => {
|
|
|
257
257
|
color.values[3] = value;
|
|
258
258
|
return recomposeColor(color);
|
|
259
259
|
};
|
|
260
|
-
/**
|
|
261
|
-
* Darkens a color.
|
|
262
|
-
*
|
|
263
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
264
|
-
* @param {number} coefficient - multiplier in the range 0 - 1
|
|
265
|
-
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
260
|
+
/**
|
|
261
|
+
* Darkens a color.
|
|
262
|
+
*
|
|
263
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
264
|
+
* @param {number} coefficient - multiplier in the range 0 - 1
|
|
265
|
+
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
266
266
|
*/
|
|
267
267
|
|
|
268
268
|
export const darken = (color, coefficient) => {
|
|
@@ -281,12 +281,12 @@ export const darken = (color, coefficient) => {
|
|
|
281
281
|
|
|
282
282
|
return recomposeColor(color);
|
|
283
283
|
};
|
|
284
|
-
/**
|
|
285
|
-
* Lightens a color.
|
|
286
|
-
*
|
|
287
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
288
|
-
* @param {number} coefficient - multiplier in the range 0 - 1
|
|
289
|
-
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
284
|
+
/**
|
|
285
|
+
* Lightens a color.
|
|
286
|
+
*
|
|
287
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
288
|
+
* @param {number} coefficient - multiplier in the range 0 - 1
|
|
289
|
+
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
290
290
|
*/
|
|
291
291
|
|
|
292
292
|
export const lighten = (color, coefficient) => {
|
|
@@ -305,22 +305,22 @@ export const lighten = (color, coefficient) => {
|
|
|
305
305
|
|
|
306
306
|
return recomposeColor(color);
|
|
307
307
|
};
|
|
308
|
-
/**
|
|
309
|
-
* Validate a color string.
|
|
310
|
-
*
|
|
311
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
312
|
-
* @returns {boolean} is a color
|
|
308
|
+
/**
|
|
309
|
+
* Validate a color string.
|
|
310
|
+
*
|
|
311
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
312
|
+
* @returns {boolean} is a color
|
|
313
313
|
*/
|
|
314
314
|
|
|
315
315
|
export const isColor = color => {
|
|
316
316
|
const regex = /(^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$|^(rgb|hsl)a\((\d{1,3}%?,\s?){3}(1|0|0?\.\d+)\)$|^(rgb|hsl)\(\d{1,3}%?(,\s?\d{1,3}%?){2}\)$)/gim;
|
|
317
317
|
return regex.test(color);
|
|
318
318
|
};
|
|
319
|
-
/**
|
|
320
|
-
* Detect a color string type.
|
|
321
|
-
*
|
|
322
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
323
|
-
* @returns {string | false} color type, string or false
|
|
319
|
+
/**
|
|
320
|
+
* Detect a color string type.
|
|
321
|
+
*
|
|
322
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
323
|
+
* @returns {string | false} color type, string or false
|
|
324
324
|
*/
|
|
325
325
|
|
|
326
326
|
export const detectColor = color => {
|
|
@@ -335,11 +335,11 @@ export const detectColor = color => {
|
|
|
335
335
|
|
|
336
336
|
return null;
|
|
337
337
|
};
|
|
338
|
-
/**
|
|
339
|
-
* Validate a color name.
|
|
340
|
-
*
|
|
341
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
342
|
-
* @returns {boolean} is a color
|
|
338
|
+
/**
|
|
339
|
+
* Validate a color name.
|
|
340
|
+
*
|
|
341
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
342
|
+
* @returns {boolean} is a color
|
|
343
343
|
*/
|
|
344
344
|
|
|
345
345
|
export const isColorName = color => {
|
|
@@ -347,11 +347,11 @@ export const isColorName = color => {
|
|
|
347
347
|
ctx.fillStyle = color;
|
|
348
348
|
return ctx.fillStyle === '#000000' ? false : ctx.fillStyle;
|
|
349
349
|
};
|
|
350
|
-
/**
|
|
351
|
-
* Convert from #ffffff to rgba()
|
|
352
|
-
* @param hex color - #ffffff
|
|
353
|
-
* @param {number} alpha - 0.5
|
|
354
|
-
* @returns {string} color - rgba()
|
|
350
|
+
/**
|
|
351
|
+
* Convert from #ffffff to rgba()
|
|
352
|
+
* @param hex color - #ffffff
|
|
353
|
+
* @param {number} alpha - 0.5
|
|
354
|
+
* @returns {string} color - rgba()
|
|
355
355
|
*/
|
|
356
356
|
|
|
357
357
|
export const hexToRGBA = (hex, alpha) => {
|
package/styles/utils.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
+
import { color as colors } from './colors';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Parse to pixel
|
|
3
4
|
*
|
|
4
|
-
* @param {number}
|
|
5
|
+
* @param {number} vl
|
|
5
6
|
* @returns {string}
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
export const parseToPixel = vl => {
|
|
8
10
|
if (!vl) return '1px';
|
|
9
11
|
return typeof vl === 'string' ? vl : `${vl}px`;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Get color from CORE colors
|
|
15
|
+
*
|
|
16
|
+
* @param {string} cl
|
|
17
|
+
* @returns {string}
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export const getColor = cl => {
|
|
21
|
+
return colors[cl] || cl;
|
|
10
22
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const hasOwn = {}.hasOwnProperty;
|
|
2
|
+
|
|
3
|
+
const classNames = (...args) => {
|
|
4
|
+
args = args.flat();
|
|
5
|
+
let classes = [];
|
|
6
|
+
|
|
7
|
+
for (let i = 0; i < args.length; i++) {
|
|
8
|
+
let arg = args[i];
|
|
9
|
+
if (!arg) continue;
|
|
10
|
+
let argType = typeof arg;
|
|
11
|
+
|
|
12
|
+
if (argType === 'string' || argType === 'number') {
|
|
13
|
+
classes.push(arg);
|
|
14
|
+
} else if (argType === 'object') {
|
|
15
|
+
if (arg.toString === Object.prototype.toString) {
|
|
16
|
+
for (let key in arg) {
|
|
17
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
18
|
+
classes.push(key);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
classes.push(arg.toString());
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return classes.join(' ');
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default classNames;
|
package/utils/error/error.js
CHANGED
package/utils/index.js
CHANGED
|
@@ -19,4 +19,5 @@ export { default as useOnClickOutside } from './useOnClickOutside';
|
|
|
19
19
|
export { default as usePortal } from './usePortal';
|
|
20
20
|
export * from './validate';
|
|
21
21
|
export { default as onValidate } from './validate';
|
|
22
|
+
export { default as classNames } from './classNames';
|
|
22
23
|
export default utils;
|
package/utils/renderIcon.js
CHANGED
|
@@ -5,11 +5,11 @@ import { jsx } from '@emotion/core';
|
|
|
5
5
|
import { ButtonIcon } from '../components';
|
|
6
6
|
import * as Icons from '../icons';
|
|
7
7
|
import { parseTextToHTML, capitalize } from './';
|
|
8
|
-
/**
|
|
9
|
-
* render icon form source (dynamic type)
|
|
10
|
-
* @param {String|jsx} source data of icon, maybe svg text | image link | name of icon in icons store or a jsx element
|
|
11
|
-
* @param {String} type text to parse text to HTML, img link to use img tag, name to use icon form icons store
|
|
12
|
-
* @param {Object} options properties of Icon component if us type is name {width, height, color, viewBox, ...}
|
|
8
|
+
/**
|
|
9
|
+
* render icon form source (dynamic type)
|
|
10
|
+
* @param {String|jsx} source data of icon, maybe svg text | image link | name of icon in icons store or a jsx element
|
|
11
|
+
* @param {String} type text to parse text to HTML, img link to use img tag, name to use icon form icons store
|
|
12
|
+
* @param {Object} options properties of Icon component if us type is name {width, height, color, viewBox, ...}
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
const renderIcon = (source, type, options = {}) => {
|
package/utils/useInput.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { useState, useRef } from 'react';
|
|
2
2
|
|
|
3
|
-
const useInput =
|
|
4
|
-
let {
|
|
5
|
-
defaultValue,
|
|
6
|
-
valueProp,
|
|
7
|
-
delayOnChange,
|
|
8
|
-
onChange,
|
|
9
|
-
onInput
|
|
10
|
-
} = props || {};
|
|
3
|
+
const useInput = (defaultValue, valueProp, onChange, onInput, delayOnChange) => {
|
|
11
4
|
const [value, setValue] = useState(defaultValue || valueProp);
|
|
12
5
|
const timer = useRef(null);
|
|
13
6
|
delayOnChange = Number(delayOnChange || 0);
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
|
-
/** @jsx jsx */
|
|
4
|
-
import { memo, useMemo, useEffect, forwardRef } from 'react';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import { jsx, css } from '@emotion/core';
|
|
7
|
-
import theme from '../../theme/settings';
|
|
8
|
-
const CardBody = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
9
|
-
children,
|
|
10
|
-
background,
|
|
11
|
-
style,
|
|
12
|
-
refs,
|
|
13
|
-
...props
|
|
14
|
-
}, ref) => {
|
|
15
|
-
const CardBodyBox = css`
|
|
16
|
-
display: block;
|
|
17
|
-
position: relative;
|
|
18
|
-
background-color: ${background};
|
|
19
|
-
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
20
|
-
border-radius: 4px;
|
|
21
|
-
box-sizing: border-box;
|
|
22
|
-
padding: 12px 24px;
|
|
23
|
-
overflow: auto;
|
|
24
|
-
order: 2;
|
|
25
|
-
height: auto;
|
|
26
|
-
width: 100%;
|
|
27
|
-
img{
|
|
28
|
-
object-fit: cover;
|
|
29
|
-
max-width: 100%;
|
|
30
|
-
height: 100%;
|
|
31
|
-
border-radius: 20px;
|
|
32
|
-
}
|
|
33
|
-
&::-webkit-scrollbar {
|
|
34
|
-
width: 8px;
|
|
35
|
-
height: 8px;
|
|
36
|
-
}
|
|
37
|
-
&::-webkit-scrollbar-thumb{
|
|
38
|
-
border-radius: 10px;
|
|
39
|
-
mix-blend-mode: normal;
|
|
40
|
-
background-color: ${theme.colors.dark12};
|
|
41
|
-
background-clip: content-box;
|
|
42
|
-
}
|
|
43
|
-
`;
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
!!refs && refs(ref);
|
|
46
|
-
}, []);
|
|
47
|
-
const Body = useMemo(() => jsx("div", {
|
|
48
|
-
css: CardBodyBox,
|
|
49
|
-
...props,
|
|
50
|
-
style: style,
|
|
51
|
-
ref: ref
|
|
52
|
-
}, children), [children, style]);
|
|
53
|
-
return Body;
|
|
54
|
-
}));
|
|
55
|
-
CardBody.propTypes = {
|
|
56
|
-
/** customize style inline */
|
|
57
|
-
style: PropTypes.object,
|
|
58
|
-
|
|
59
|
-
/** get card header ref by function */
|
|
60
|
-
refs: PropTypes.func,
|
|
61
|
-
|
|
62
|
-
/** child content in header (like title) */
|
|
63
|
-
children: PropTypes.node
|
|
64
|
-
};
|
|
65
|
-
export default CardBody;
|
package/components/card/card.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
|
|
3
|
-
/** @jsxRuntime classic */
|
|
4
|
-
|
|
5
|
-
/** @jsx jsx */
|
|
6
|
-
import { memo, useRef, forwardRef, useMemo } from 'react';
|
|
7
|
-
import { createPortal } from 'react-dom';
|
|
8
|
-
import PropTypes from 'prop-types';
|
|
9
|
-
import { jsx, css } from '@emotion/core';
|
|
10
|
-
import CardContext from './context';
|
|
11
|
-
const Card = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
12
|
-
// open,
|
|
13
|
-
// type,
|
|
14
|
-
// title,
|
|
15
|
-
style,
|
|
16
|
-
top,
|
|
17
|
-
// pressESCToClose,
|
|
18
|
-
// darkTheme,
|
|
19
|
-
// autoFocus,
|
|
20
|
-
// refs,
|
|
21
|
-
onClose,
|
|
22
|
-
// onConfirm,
|
|
23
|
-
// onCancel,
|
|
24
|
-
children,
|
|
25
|
-
width,
|
|
26
|
-
...props
|
|
27
|
-
}, ref) => {
|
|
28
|
-
if (!ref) {
|
|
29
|
-
ref = useRef(null);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const cardBoxRef = useRef(null);
|
|
33
|
-
const CardBox = css`
|
|
34
|
-
background-color: white;
|
|
35
|
-
border-radius: 4px;
|
|
36
|
-
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
37
|
-
box-sizing: border-box;
|
|
38
|
-
border-radius: 10px;
|
|
39
|
-
display: flex;
|
|
40
|
-
position: relative;
|
|
41
|
-
max-height: calc(100% - ${isNaN(top) ? top : +top + 'px'});
|
|
42
|
-
min-width: 150px;
|
|
43
|
-
max-width: 90%;
|
|
44
|
-
margin: 0 auto;
|
|
45
|
-
height: max-content;
|
|
46
|
-
width: ${isNaN(width) ? width : width + 'px'};
|
|
47
|
-
flex-direction: column;
|
|
48
|
-
-webkit-box-orient: vertical;
|
|
49
|
-
-webkit-box-direction: normal;
|
|
50
|
-
/* min-height: 152px; */
|
|
51
|
-
cursor: 'initial';
|
|
52
|
-
`;
|
|
53
|
-
|
|
54
|
-
const onShowCard = () => {
|
|
55
|
-
setOpenState(true);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const onCloseCard = () => {
|
|
59
|
-
if (onClose) onClose();else {
|
|
60
|
-
setTimeout(() => {
|
|
61
|
-
setOpenState(false);
|
|
62
|
-
}, 500);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (ref.current) {
|
|
66
|
-
ref.current.style.opacity = null;
|
|
67
|
-
ref.current.firstChild.classList.remove('show');
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const CardView = useMemo(() => {
|
|
72
|
-
const node = jsx("div", {
|
|
73
|
-
className: 'DGN-UI-Card'
|
|
74
|
-
}, jsx("div", {
|
|
75
|
-
css: CardBox,
|
|
76
|
-
ref: cardBoxRef,
|
|
77
|
-
...props,
|
|
78
|
-
style: style
|
|
79
|
-
}, jsx(CardContext.Provider, {
|
|
80
|
-
value: {
|
|
81
|
-
show: onShowCard,
|
|
82
|
-
close: onCloseCard
|
|
83
|
-
}
|
|
84
|
-
}, children)));
|
|
85
|
-
return /*#__PURE__*/createPortal(node, document.body);
|
|
86
|
-
});
|
|
87
|
-
return CardView;
|
|
88
|
-
}));
|
|
89
|
-
Card.defaultProps = {
|
|
90
|
-
autoFocus: true,
|
|
91
|
-
top: '',
|
|
92
|
-
width: '70%'
|
|
93
|
-
};
|
|
94
|
-
Card.propTypes = {
|
|
95
|
-
/** park a good colored background under the card box if true */
|
|
96
|
-
darkTheme: PropTypes.bool,
|
|
97
|
-
|
|
98
|
-
/** show card if true */
|
|
99
|
-
open: PropTypes.bool,
|
|
100
|
-
|
|
101
|
-
/** focusing after open card */
|
|
102
|
-
autoFocus: PropTypes.bool,
|
|
103
|
-
|
|
104
|
-
/** customize the vertical position of the screen, if not set, the card will be fixed in the middle of the screen */
|
|
105
|
-
top: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
106
|
-
|
|
107
|
-
/** width of the card */
|
|
108
|
-
width: PropTypes.string,
|
|
109
|
-
|
|
110
|
-
/** customize style inline */
|
|
111
|
-
style: PropTypes.object,
|
|
112
|
-
|
|
113
|
-
/** get card ref by function */
|
|
114
|
-
refs: PropTypes.func,
|
|
115
|
-
|
|
116
|
-
/** the function to run when close card */
|
|
117
|
-
onClose: PropTypes.func,
|
|
118
|
-
|
|
119
|
-
/** child content in body */
|
|
120
|
-
children: PropTypes.node,
|
|
121
|
-
|
|
122
|
-
/** any props else */
|
|
123
|
-
props: PropTypes.any
|
|
124
|
-
};
|
|
125
|
-
export default Card;
|