diginet-core-ui 1.3.78 → 1.3.79

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.
Files changed (209) hide show
  1. package/components/accordion/details.js +2 -6
  2. package/components/accordion/group.js +2 -9
  3. package/components/accordion/index.js +2 -15
  4. package/components/accordion/summary.js +4 -27
  5. package/components/alert/index.js +98 -137
  6. package/components/alert/notify.js +97 -166
  7. package/components/avatar/index.js +4 -63
  8. package/components/badge/index.js +7 -34
  9. package/components/button/icon.js +120 -186
  10. package/components/button/index.js +136 -205
  11. package/components/button/more.js +0 -12
  12. package/components/button/ripple-effect.js +46 -44
  13. package/components/card/body.js +2 -7
  14. package/components/card/extra.js +2 -7
  15. package/components/card/footer.js +2 -7
  16. package/components/card/header.js +2 -7
  17. package/components/card/index.js +2 -22
  18. package/components/chart/Pie/Circle.js +0 -1
  19. package/components/chart/Pie/Sector.js +0 -17
  20. package/components/chart/Pie/Sectors.js +0 -10
  21. package/components/chart/Pie/index.js +4 -36
  22. package/components/chart/Pie-v2/Circle.js +0 -1
  23. package/components/chart/Pie-v2/Sector.js +0 -13
  24. package/components/chart/Pie-v2/Sectors.js +0 -20
  25. package/components/chart/Pie-v2/index.js +11 -38
  26. package/components/chart/bar/Axis.js +0 -12
  27. package/components/chart/bar/Bar.js +13 -35
  28. package/components/chart/bar/Grid.js +0 -18
  29. package/components/chart/bar/Labels.js +0 -18
  30. package/components/chart/bar/Points.js +0 -17
  31. package/components/chart/bar/index.js +6 -26
  32. package/components/chart/bar-v2/Axis.js +0 -12
  33. package/components/chart/bar-v2/Bar.js +15 -36
  34. package/components/chart/bar-v2/Grid.js +0 -18
  35. package/components/chart/bar-v2/Labels.js +0 -18
  36. package/components/chart/bar-v2/Points.js +0 -17
  37. package/components/chart/bar-v2/index.js +6 -26
  38. package/components/chart/line/Axis.js +4 -16
  39. package/components/chart/line/Grid.js +2 -19
  40. package/components/chart/line/Labels.js +0 -18
  41. package/components/chart/line/Path.js +23 -33
  42. package/components/chart/line/Point.js +6 -40
  43. package/components/chart/line/Title.js +0 -3
  44. package/components/chart/line/index.js +12 -35
  45. package/components/chart/line-v2/Axis.js +0 -13
  46. package/components/chart/line-v2/Grid.js +0 -18
  47. package/components/chart/line-v2/Labels.js +0 -18
  48. package/components/chart/line-v2/Path.js +23 -33
  49. package/components/chart/line-v2/Point.js +6 -35
  50. package/components/chart/line-v2/Title.js +0 -3
  51. package/components/chart/line-v2/index.js +12 -30
  52. package/components/check-text/index.js +0 -8
  53. package/components/check-text/interview-confirmation.js +0 -7
  54. package/components/check-text/interview-status.js +0 -7
  55. package/components/chip/attach.js +4 -17
  56. package/components/chip/index.js +6 -33
  57. package/components/collapse/index.js +0 -13
  58. package/components/divider/index.js +0 -8
  59. package/components/form-control/attachment/index.js +24 -202
  60. package/components/form-control/calendar/function.js +40 -94
  61. package/components/form-control/calendar/index.js +5 -30
  62. package/components/form-control/calendar/range.js +11 -28
  63. package/components/form-control/checkbox/index.js +4 -37
  64. package/components/form-control/control/index.js +3 -13
  65. package/components/form-control/date-picker/index-old.js +18 -0
  66. package/components/form-control/date-picker/index.js +23 -99
  67. package/components/form-control/date-range-picker/index.js +86 -221
  68. package/components/form-control/dropdown/index.js +72 -289
  69. package/components/form-control/dropdown-box/index.js +6 -35
  70. package/components/form-control/form/index.js +0 -2
  71. package/components/form-control/form-group/index.js +1 -6
  72. package/components/form-control/helper-text/index.js +2 -9
  73. package/components/form-control/input-base/index.js +218 -399
  74. package/components/form-control/label/index.js +2 -12
  75. package/components/form-control/money-input/index.js +43 -132
  76. package/components/form-control/number-input/index.js +15 -113
  77. package/components/form-control/number-input/index2.js +78 -119
  78. package/components/form-control/phone-input/index.js +16 -78
  79. package/components/form-control/radio/index.js +4 -23
  80. package/components/form-control/text-input/index.js +33 -256
  81. package/components/form-control/time-picker/index.js +14 -71
  82. package/components/form-control/time-picker/swiper.js +21 -73
  83. package/components/form-control/toggle/index.js +4 -19
  84. package/components/form-view/helper-text.js +2 -2
  85. package/components/form-view/index.js +0 -14
  86. package/components/form-view/input.js +2 -13
  87. package/components/form-view/label.js +0 -2
  88. package/components/grid/Col.js +2 -15
  89. package/components/grid/Container.js +2 -21
  90. package/components/grid/Row.js +2 -21
  91. package/components/grid/index.js +2 -43
  92. package/components/image/index.js +2 -22
  93. package/components/index.js +62 -31
  94. package/components/list/list-item-action.js +0 -9
  95. package/components/list/list-item-icon.js +0 -9
  96. package/components/list/list-item-text.js +0 -5
  97. package/components/list/list-item.js +0 -11
  98. package/components/list/list.js +0 -13
  99. package/components/list/sub-header.js +0 -4
  100. package/components/modal/body.js +2 -6
  101. package/components/modal/footer.js +2 -11
  102. package/components/modal/header.js +2 -12
  103. package/components/modal/index.js +2 -10
  104. package/components/modal/modal.js +11 -52
  105. package/components/others/extra/index.js +3 -10
  106. package/components/others/import/index.js +0 -7
  107. package/components/others/option-wrapper/index.js +4 -7
  108. package/components/others/scrollbar/index.js +0 -3
  109. package/components/paging/page-info.js +39 -101
  110. package/components/paging/page-selector.js +7 -35
  111. package/components/paging/page-selector2.js +35 -74
  112. package/components/paper/index.js +0 -11
  113. package/components/popover/body.js +2 -6
  114. package/components/popover/footer.js +2 -11
  115. package/components/popover/header.js +2 -7
  116. package/components/popover/index.js +39 -123
  117. package/components/popup/danger_popup.js +0 -19
  118. package/components/popup/index.js +2 -48
  119. package/components/popup/proposals_popup.js +10 -49
  120. package/components/popup/v2/index.js +0 -31
  121. package/components/progress/circular.js +19 -81
  122. package/components/progress/linear.js +4 -20
  123. package/components/rating/index.js +0 -24
  124. package/components/slider/slider-container.js +3 -40
  125. package/components/slider/slider-item.js +10 -25
  126. package/components/status/index.js +2 -16
  127. package/components/tab/tab-container.js +2 -16
  128. package/components/tab/tab-header.js +4 -24
  129. package/components/tab/tab-panel.js +4 -16
  130. package/components/tab/tab.js +4 -28
  131. package/components/tooltip/index.js +12 -97
  132. package/components/tooltip/portal.js +0 -2
  133. package/components/transfer/index.js +22 -67
  134. package/components/tree-view/index.js +62 -202
  135. package/components/typography/index.js +3 -31
  136. package/global/index.js +0 -8
  137. package/icons/basic.js +0 -48
  138. package/icons/effect.js +17 -29
  139. package/icons/general/clock/clock.js +0 -2
  140. package/icons/general/color-handler/background.js +0 -2
  141. package/icons/general/color-handler/text.js +0 -2
  142. package/icons/general/emoji/emoji.js +0 -2
  143. package/icons/general/font-properties/bold.js +0 -2
  144. package/icons/general/font-properties/font-family.js +0 -2
  145. package/icons/general/font-properties/font-size.js +0 -2
  146. package/icons/general/font-properties/italic.js +0 -2
  147. package/icons/general/font-properties/underline.js +0 -2
  148. package/icons/general/hyperlink/hyperlink.js +0 -2
  149. package/icons/general/indent/decrease.js +0 -2
  150. package/icons/general/indent/increase.js +0 -2
  151. package/icons/general/list/bullets.js +0 -2
  152. package/icons/general/list/numbering.js +0 -2
  153. package/icons/general/picture/picture.js +0 -2
  154. package/icons/general/steps/redo.js +0 -2
  155. package/icons/general/steps/undo.js +0 -2
  156. package/icons/general/text-align/center.js +0 -2
  157. package/icons/general/text-align/justify.js +0 -2
  158. package/icons/general/text-align/left.js +0 -2
  159. package/icons/general/text-align/right.js +0 -2
  160. package/icons/menu/dhr.js +2 -1
  161. package/icons/menu/index.js +2 -2
  162. package/icons/menu/v2/index.js +0 -10
  163. package/package.json +1 -1
  164. package/readme.md +11 -1
  165. package/styles/animation.js +15 -58
  166. package/styles/color-helper.js +24 -54
  167. package/styles/colors.js +17 -9
  168. package/styles/general.js +6 -2
  169. package/styles/typography.js +4 -4
  170. package/styles/utils.js +2 -2
  171. package/theme/createBreakpoints.js +7 -18
  172. package/theme/make-styles.js +2 -5
  173. package/theme/set-theme.js +3 -6
  174. package/theme/settings.js +3 -2
  175. package/theme/theme-provider.js +0 -1
  176. package/utils/array/array.js +14 -23
  177. package/utils/classNames.js +0 -5
  178. package/utils/console.js +0 -6
  179. package/utils/date.js +13 -82
  180. package/utils/error/error.js +1 -9
  181. package/utils/error/errors.js +1 -48
  182. package/utils/getFileType.js +0 -9
  183. package/utils/handleBreakpoints.js +0 -5
  184. package/utils/intersectionObserver.js +0 -5
  185. package/utils/iterator.js +0 -9
  186. package/utils/map-parent.js +3 -10
  187. package/utils/object/extend.js +0 -10
  188. package/utils/object/object.js +12 -11
  189. package/utils/parseHTML.js +0 -1
  190. package/utils/promisify.js +0 -5
  191. package/utils/randomString.js +0 -7
  192. package/utils/remove-unicode.js +0 -1
  193. package/utils/render-portal.js +1 -9
  194. package/utils/renderHTML.js +4 -6
  195. package/utils/renderIcon.js +4 -14
  196. package/utils/sb-template.js +6 -5
  197. package/utils/string/capitalize.js +0 -1
  198. package/utils/string/capitalizeSentenceCase.js +0 -2
  199. package/utils/string/string.js +0 -13
  200. package/utils/type.js +0 -21
  201. package/utils/updatePosition.js +4 -5
  202. package/utils/useDelayUnmount.js +0 -4
  203. package/utils/useElementSize.js +9 -3
  204. package/utils/useEventListener.js +12 -6
  205. package/utils/useInput.js +0 -6
  206. package/utils/useMediaQuery.js +8 -10
  207. package/utils/useOnClickOutside.js +0 -2
  208. package/utils/usePortal.js +3 -10
  209. package/utils/validate.js +6 -20
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable no-undef */
2
-
3
2
  /**
4
3
  * Returns a number whose value is limited to the given range.
5
4
  *
@@ -14,48 +13,41 @@ const clamp = (value, min = 0, max = 1) => {
14
13
  console.error(`DigiNet-CORE-UI: The value provided ${value} is out of range [${min}, ${max}].`);
15
14
  }
16
15
  }
17
-
18
16
  return Math.min(Math.max(min, value), max);
19
17
  };
18
+
20
19
  /**
21
20
  * Converts a color from CSS hex format to CSS rgb format.
22
21
  *
23
22
  * @param {string} color - Hex color, i.e. #nnn or #nnnnnn
24
23
  * @returns {string} A CSS rgb color string
25
24
  */
26
-
27
-
28
25
  export const hexToRgb = color => {
29
26
  color = color.substr(1);
30
27
  const re = new RegExp(`.{1,${color.length >= 6 ? 2 : 1}}`, 'g');
31
28
  let colors = color.match(re);
32
-
33
29
  if (colors && colors[0].length === 1) {
34
30
  colors = colors.map(n => n + n);
35
31
  }
36
-
37
32
  return colors ? `rgb${colors.length === 4 ? 'a' : ''}(${colors.map((n, index) => {
38
33
  return index < 3 ? parseInt(n, 16) : Math.round(parseInt(n, 16) / 255 * 1000) / 1000;
39
34
  }).join(', ')})` : '';
40
35
  };
41
-
42
36
  const intToHex = int => {
43
37
  const hex = int.toString(16);
44
38
  return hex.length === 1 ? `0${hex}` : hex;
45
39
  };
40
+
46
41
  /**
47
42
  * Converts a color from CSS rgb format to CSS hex format.
48
43
  *
49
44
  * @param {string} color - RGB color, i.e. rgb(n, n, n)
50
45
  * @returns {string} A CSS rgb color string, i.e. #nnnnnn
51
46
  */
52
-
53
-
54
47
  export const rgbToHex = color => {
55
48
  if (color.indexOf('#') === 0) {
56
49
  return color;
57
50
  }
58
-
59
51
  const {
60
52
  values
61
53
  } = decomposeColor(color);
@@ -67,19 +59,16 @@ export const rgbToHex = color => {
67
59
  * @param {string} color - RGBA color, i.e. rgba(n, n, n, f)
68
60
  * @returns {string} A CSS rgb A color string, i.e. #nnnnnnnn
69
61
  */
70
-
71
62
  export const rgbaToHexA = color => {
72
63
  let sep = color.indexOf(',') > -1 ? ',' : ' ';
73
- color = color.substr(5).split(')')[0].split(sep); // Strip the slash if using space-separated syntax
64
+ color = color.substr(5).split(')')[0].split(sep);
74
65
 
66
+ // Strip the slash if using space-separated syntax
75
67
  if (color.indexOf('/') > -1) color.splice(3, 1);
76
-
77
68
  for (let R in color) {
78
69
  let r = color[R];
79
-
80
70
  if (r.indexOf('%') > -1) {
81
71
  let p = r.substr(0, r.length - 1) / 100;
82
-
83
72
  if (R < 3) {
84
73
  color[R] = Math.round(p * 255);
85
74
  } else {
@@ -87,24 +76,23 @@ export const rgbaToHexA = color => {
87
76
  }
88
77
  }
89
78
  }
90
-
91
79
  let r = (+color[0]).toString(16),
92
- g = (+color[1]).toString(16),
93
- b = (+color[2]).toString(16),
94
- a = Math.round(+color[3] * 255).toString(16);
80
+ g = (+color[1]).toString(16),
81
+ b = (+color[2]).toString(16),
82
+ a = Math.round(+color[3] * 255).toString(16);
95
83
  if (r.length == 1) r = '0' + r;
96
84
  if (g.length == 1) g = '0' + g;
97
85
  if (b.length == 1) b = '0' + b;
98
86
  if (a.length == 1) a = '0' + a;
99
87
  return '#' + r + g + b + a;
100
88
  };
89
+
101
90
  /**
102
91
  * Converts a color from hsl format to rgb format.
103
92
  *
104
93
  * @param {string} color - HSL color values
105
94
  * @returns {string} rgb color values
106
95
  */
107
-
108
96
  export const hslToRgb = color => {
109
97
  color = decomposeColor(color);
110
98
  const {
@@ -114,22 +102,19 @@ export const hslToRgb = color => {
114
102
  const s = values[1] / 100;
115
103
  const l = values[2] / 100;
116
104
  const a = s * Math.min(l, 1 - l);
117
-
118
105
  const f = (n, k = (n + h / 30) % 12) => l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
119
-
120
106
  let type = 'rgb';
121
107
  const rgb = [Math.round(f(0) * 255), Math.round(f(8) * 255), Math.round(f(4) * 255)];
122
-
123
108
  if (color.type === 'hsla') {
124
109
  type += 'a';
125
110
  rgb.push(values[3]);
126
111
  }
127
-
128
112
  return recomposeColor({
129
113
  type,
130
114
  values: rgb
131
115
  });
132
116
  };
117
+
133
118
  /**
134
119
  * Returns an object with the type and values of a color.
135
120
  *
@@ -138,23 +123,18 @@ export const hslToRgb = color => {
138
123
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
139
124
  * @returns {object} - A color object: {type: string, values: number[]}
140
125
  */
141
-
142
126
  export const decomposeColor = color => {
143
127
  if (color.type) {
144
128
  return color;
145
129
  }
146
-
147
130
  if (color.charAt(0) === '#') {
148
131
  return decomposeColor(hexToRgb(color));
149
132
  }
150
-
151
133
  const marker = color.indexOf('(');
152
134
  const type = color.substring(0, marker);
153
-
154
135
  if (['rgb', 'rgba', 'hsl', 'hsla'].indexOf(type) === -1) {
155
136
  throw 'DigiNet-CORE-UI: Unsupported `%s` color.\n' + 'We support the following formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla().', color;
156
137
  }
157
-
158
138
  let values = color.substring(marker + 1, color.length - 1).split(',');
159
139
  values = values.map(value => parseFloat(value));
160
140
  return {
@@ -162,6 +142,7 @@ export const decomposeColor = color => {
162
142
  values
163
143
  };
164
144
  };
145
+
165
146
  /**
166
147
  * Converts a color object with type and values to a string.
167
148
  *
@@ -170,7 +151,6 @@ export const decomposeColor = color => {
170
151
  * @param {array} color.values - [n,n,n] or [n,n,n,n]
171
152
  * @returns {string} A CSS color string
172
153
  */
173
-
174
154
  export const recomposeColor = color => {
175
155
  const {
176
156
  type
@@ -178,7 +158,6 @@ export const recomposeColor = color => {
178
158
  let {
179
159
  values
180
160
  } = color;
181
-
182
161
  if (type.indexOf('rgb') !== -1) {
183
162
  // Only convert the first 3 values to int (i.e. not alpha)
184
163
  values = values.map((n, i) => i < 3 ? parseInt(n, 10) : n);
@@ -186,9 +165,9 @@ export const recomposeColor = color => {
186
165
  values[1] = `${values[1]}%`;
187
166
  values[2] = `${values[2]}%`;
188
167
  }
189
-
190
168
  return `${type}(${values.join(', ')})`;
191
169
  };
170
+
192
171
  /**
193
172
  * Calculates the contrast ratio between two colors.
194
173
  *
@@ -198,12 +177,12 @@ export const recomposeColor = color => {
198
177
  * @param {string} background - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
199
178
  * @returns {number} A contrast ratio value in the range 0 - 21.
200
179
  */
201
-
202
180
  export const getContrastRatio = (foreground, background) => {
203
181
  const lumA = getLuminance(foreground);
204
182
  const lumB = getLuminance(background);
205
183
  return (Math.max(lumA, lumB) + 0.05) / (Math.min(lumA, lumB) + 0.05);
206
184
  };
185
+
207
186
  /**
208
187
  * The relative brightness of any point in a color space,
209
188
  * normalized to 0 for darkest black and 1 for lightest white.
@@ -213,18 +192,18 @@ export const getContrastRatio = (foreground, background) => {
213
192
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
214
193
  * @returns {number} The relative brightness of the color in the range 0 - 1
215
194
  */
216
-
217
195
  export const getLuminance = color => {
218
196
  color = decomposeColor(color);
219
197
  let rgb = color.type === 'hsl' ? decomposeColor(hslToRgb(color)).values : color.values;
220
198
  rgb = rgb.map(val => {
221
199
  val /= 255; // normalized
222
-
223
200
  return val <= 0.03928 ? val / 12.92 : ((val + 0.055) / 1.055) ** 2.4;
224
- }); // Truncate at 3 digits
201
+ });
225
202
 
203
+ // Truncate at 3 digits
226
204
  return Number((0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]).toFixed(3));
227
205
  };
206
+
228
207
  /**
229
208
  * Darken or lighten a color, depending on its luminance.
230
209
  * Light colors are darkened, dark colors are lightened.
@@ -233,10 +212,10 @@ export const getLuminance = color => {
233
212
  * @param {number} coefficient=0.15 - multiplier in the range 0 - 1
234
213
  * @returns {string} A CSS color string. Hex input values are returned as rgb
235
214
  */
236
-
237
215
  export const emphasize = (color, coefficient = 0.15) => {
238
216
  return getLuminance(color) > 0.5 ? darken(color, coefficient) : lighten(color, coefficient);
239
217
  };
218
+
240
219
  /**
241
220
  * Set the absolute transparency of a color.
242
221
  * Any existing alpha values are overwritten.
@@ -245,18 +224,16 @@ export const emphasize = (color, coefficient = 0.15) => {
245
224
  * @param {number} value - value to set the alpha channel to in the range 0 -1
246
225
  * @returns {string} A CSS color string. Hex input values are returned as rgb
247
226
  */
248
-
249
227
  export const fade = (color, value) => {
250
228
  color = decomposeColor(color);
251
229
  value = clamp(value);
252
-
253
230
  if (color.type === 'rgb' || color.type === 'hsl') {
254
231
  color.type += 'a';
255
232
  }
256
-
257
233
  color.values[3] = value;
258
234
  return recomposeColor(color);
259
235
  };
236
+
260
237
  /**
261
238
  * Darkens a color.
262
239
  *
@@ -264,13 +241,11 @@ export const fade = (color, value) => {
264
241
  * @param {number} coefficient - multiplier in the range 0 - 1
265
242
  * @returns {string} A CSS color string. Hex input values are returned as rgb
266
243
  */
267
-
268
244
  export const darken = (color, coefficient) => {
269
245
  if (isColorName(color)) color = isColorName(color);
270
246
  if (!isColor(color)) return;
271
247
  color = decomposeColor(color);
272
248
  coefficient = clamp(coefficient);
273
-
274
249
  if (color.type.indexOf('hsl') !== -1) {
275
250
  color.values[2] *= 1 - coefficient;
276
251
  } else if (color.type.indexOf('rgb') !== -1) {
@@ -278,9 +253,9 @@ export const darken = (color, coefficient) => {
278
253
  color.values[i] *= 1 - coefficient;
279
254
  }
280
255
  }
281
-
282
256
  return recomposeColor(color);
283
257
  };
258
+
284
259
  /**
285
260
  * Lightens a color.
286
261
  *
@@ -288,13 +263,11 @@ export const darken = (color, coefficient) => {
288
263
  * @param {number} coefficient - multiplier in the range 0 - 1
289
264
  * @returns {string} A CSS color string. Hex input values are returned as rgb
290
265
  */
291
-
292
266
  export const lighten = (color, coefficient) => {
293
267
  if (isColorName(color)) color = isColorName(color);
294
268
  if (!isColor(color)) return;
295
269
  color = decomposeColor(color);
296
270
  coefficient = clamp(coefficient);
297
-
298
271
  if (color.type.indexOf('hsl') !== -1) {
299
272
  color.values[2] += (100 - color.values[2]) * coefficient;
300
273
  } else if (color.type.indexOf('rgb') !== -1) {
@@ -302,27 +275,26 @@ export const lighten = (color, coefficient) => {
302
275
  color.values[i] += (255 - color.values[i]) * coefficient;
303
276
  }
304
277
  }
305
-
306
278
  return recomposeColor(color);
307
279
  };
280
+
308
281
  /**
309
282
  * Validate a color string.
310
283
  *
311
284
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
312
285
  * @returns {boolean} is a color
313
286
  */
314
-
315
287
  export const isColor = color => {
316
288
  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
289
  return regex.test(color);
318
290
  };
291
+
319
292
  /**
320
293
  * Detect a color string type.
321
294
  *
322
295
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
323
296
  * @returns {string | false} color type, string or false
324
297
  */
325
-
326
298
  export const detectColor = color => {
327
299
  if (color && isColor(color)) {
328
300
  if (/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(color)) return 'hex';
@@ -332,35 +304,33 @@ export const detectColor = color => {
332
304
  if (/^hsl\(\d{1,3}%?(,\s?\d{1,3}%?){2}\)$/i.test(color)) return 'hsl';
333
305
  if (/^hsla\((\d{1,3}%?,\s?){3}(1|0|0?\.\d+)\)$/i.test(color)) return 'hsla';
334
306
  }
335
-
336
307
  return null;
337
308
  };
309
+
338
310
  /**
339
311
  * Validate a color name.
340
312
  *
341
313
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
342
314
  * @returns {boolean} is a color
343
315
  */
344
-
345
316
  export const isColorName = color => {
346
317
  let ctx = document.createElement('canvas').getContext('2d');
347
318
  ctx.fillStyle = color;
348
319
  return ctx.fillStyle === '#000000' ? false : ctx.fillStyle;
349
320
  };
321
+
350
322
  /**
351
323
  * Convert from #ffffff to rgba()
352
324
  * @param hex color - #ffffff
353
325
  * @param {number} alpha - 0.5
354
326
  * @returns {string} color - rgba()
355
327
  */
356
-
357
328
  export const hexToRGBA = (hex, alpha) => {
358
329
  if (isColorName(hex)) hex = isColorName(hex);
359
330
  if (!isColor(hex)) return;
360
331
  var r = parseInt(hex.slice(1, 3), 16),
361
- g = parseInt(hex.slice(3, 5), 16),
362
- b = parseInt(hex.slice(5, 7), 16);
363
-
332
+ g = parseInt(hex.slice(3, 5), 16),
333
+ b = parseInt(hex.slice(5, 7), 16);
364
334
  if (alpha) {
365
335
  return 'rgba(' + r + ', ' + g + ', ' + b + ', ' + alpha + ')';
366
336
  } else {
package/styles/colors.js CHANGED
@@ -1,5 +1,6 @@
1
- import { hexToRGBA } from './color-helper'; //color brand
1
+ import { hexToRGBA } from './color-helper';
2
2
 
3
+ //color brand
3
4
  export const white = '#fff';
4
5
  export const brand1 = '#E9EAF0';
5
6
  export const brand2 = '#D4D6E2';
@@ -31,8 +32,8 @@ export const brand26 = '#E4E5ED';
31
32
  export const brand27 = '#E0E1EA';
32
33
  export const brand28 = '#DBDDE7';
33
34
  export const brand29 = '#D7D8E4';
34
- export const brand30 = '#D2D4E1'; //// blue
35
-
35
+ export const brand30 = '#D2D4E1';
36
+ //// blue
36
37
  export const blue1 = '#E8F3FF';
37
38
  export const blue2 = '#D1E7FF';
38
39
  export const blue3 = '#B9DBFF';
@@ -53,7 +54,8 @@ export const blue16 = '#C0DEFF';
53
54
  export const blue17 = '#B5D9FF';
54
55
  export const blue18 = '#ABD3FF';
55
56
  export const blue19 = '#A0CEFF';
56
- export const blue20 = '#96C8FF'; ///dark
57
+ export const blue20 = '#96C8FF';
58
+ ///dark
57
59
 
58
60
  export const dark1 = '#EAEAEC';
59
61
  export const dark2 = '#D4D5D9';
@@ -75,7 +77,9 @@ export const dark16 = '#C5C6CC';
75
77
  export const dark17 = '#BCBDC3';
76
78
  export const dark18 = '#B2B3BB';
77
79
  export const dark19 = '#A8AAB2';
78
- export const dark20 = '#9FA0AA'; /// Info
80
+ export const dark20 = '#9FA0AA';
81
+
82
+ /// Info
79
83
 
80
84
  export const info1 = '#CCF5FF';
81
85
  export const info2 = '#99E6FF';
@@ -85,8 +89,9 @@ export const info5 = '#0095FF';
85
89
  export const info6 = '#0073DB';
86
90
  export const info7 = '#0056B7';
87
91
  export const info8 = '#003C93';
88
- export const info9 = '#002B7A'; // success
92
+ export const info9 = '#002B7A';
89
93
 
94
+ // success
90
95
  export const success1 = '#C9FCD3';
91
96
  export const success2 = '#95F9B2';
92
97
  export const success3 = '#5FEE96';
@@ -95,8 +100,9 @@ export const success5 = '#00C875';
95
100
  export const success6 = '#00AC75';
96
101
  export const success7 = '#009070';
97
102
  export const success8 = '#007466';
98
- export const success9 = '#00605E'; //warning
103
+ export const success9 = '#00605E';
99
104
 
105
+ //warning
100
106
  export const warning1 = '#FFF4CC';
101
107
  export const warning2 = '#FFE799';
102
108
  export const warning3 = '#FFD666';
@@ -105,8 +111,9 @@ export const warning5 = '#FFAA00';
105
111
  export const warning6 = '#DB8A00';
106
112
  export const warning7 = '#B76D00';
107
113
  export const warning8 = '#935300';
108
- export const warning9 = '#7A4000'; //danger
114
+ export const warning9 = '#7A4000';
109
115
 
116
+ //danger
110
117
  export const danger1 = '#FFDCD8';
111
118
  export const danger2 = '#FFB3B1';
112
119
  export const danger3 = '#FF8A93';
@@ -115,8 +122,9 @@ export const danger5 = '#FF3D71';
115
122
  export const danger6 = '#DB2C6C';
116
123
  export const danger7 = '#B71E65';
117
124
  export const danger8 = '#93135B';
118
- export const danger9 = '#7A0B54'; //FORMAL
125
+ export const danger9 = '#7A0B54';
119
126
 
127
+ //FORMAL
120
128
  export const formal1 = '#CED7F6';
121
129
  export const formal2 = '#A0B0EE';
122
130
  export const formal3 = '#697ccE';
package/styles/general.js CHANGED
@@ -5,17 +5,18 @@ import { parseToPixel } from './utils';
5
5
  export const rootSpacing = 4;
6
6
  export let rootZIndex = 1500;
7
7
  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
+
8
9
  /**
9
10
  * get value spacing with rootZIndex
10
11
  * @param number
11
12
  * @return {number}
12
13
  */
13
-
14
14
  export const zIndex = number => {
15
15
  number = Number(number || 0);
16
16
  if (isNaN(number)) return rootZIndex;
17
17
  return rootZIndex + number;
18
18
  };
19
+
19
20
  /**
20
21
  * get value spacing with rootSpacing
21
22
  * @param {(number|number[])} vl - default 1
@@ -28,11 +29,11 @@ export const getSpacing = (vl = 1) => {
28
29
  return vl.flatMap(i => isNaN(i) ? i : i * rootSpacing + 'px').join(' ');
29
30
  }
30
31
  };
32
+
31
33
  /**
32
34
  * replace rootZIndex
33
35
  * @param number
34
36
  */
35
-
36
37
  export const setZIndex = number => {
37
38
  number = Number(number || 0);
38
39
  if (!isNaN(number)) rootZIndex = number;
@@ -100,6 +101,9 @@ export const borderRadius4px = css`
100
101
  export const borderRadius50 = css`
101
102
  border-radius: 50%;
102
103
  `;
104
+ export const borderRadius100 = css`
105
+ border-radius: 100%;
106
+ `;
103
107
  export const borderBox = css`
104
108
  box-sizing: border-box;
105
109
  `;
@@ -18,13 +18,13 @@ const fontWeightRegular = css`
18
18
  `;
19
19
  const fontWeightNormal = css`
20
20
  font-weight: normal;
21
- `; // follow rules line-height = fontsize + 4
21
+ `;
22
22
 
23
+ // follow rules line-height = fontsize + 4
23
24
  const getFontSize = size => css`
24
25
  font-size: ${parseToPixel(size)};
25
26
  line-height: ${parseToPixel(size + 4)};
26
27
  `;
27
-
28
28
  const title1 = css`
29
29
  ${fontNormal};
30
30
  ${fontWeightBold};
@@ -103,10 +103,10 @@ const helperText = css`
103
103
  `;
104
104
  export const typography = [[title1, ['title1', 't1']], [title2, ['title2', 't2']], [title3, ['title3', 't3']], [title4, ['title4', 't4']], [heading1, ['heading1', 'h1']], [heading2, ['heading2', 'h2']], [heading3, ['heading3', 'h3']], [heading4, ['heading4', 'h4']], [heading5, ['heading5', 'h5']], [heading6, ['heading6', 'h6']], [paragraph1, ['paragraph1', 'p1']], [paragraph2, ['paragraph2', 'p2']], [paragraph3, ['paragraph3', 'p3']], [uppercase, ['uppercase']], [label, ['label']], [helperText, ['helperText']]].reduce((obj, [value, keys]) => {
105
105
  for (const key of keys) {
106
- obj = { ...obj,
106
+ obj = {
107
+ ...obj,
107
108
  [key]: value
108
109
  };
109
110
  }
110
-
111
111
  return obj;
112
112
  }, {});
package/styles/utils.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import { color as colors } from './colors';
2
+
2
3
  /**
3
4
  * Parse to pixel
4
5
  *
5
6
  * @param {number} vl
6
7
  * @returns {string}
7
8
  */
8
-
9
9
  export const parseToPixel = vl => {
10
10
  if (!vl) return '1px';
11
11
  return typeof vl === 'string' ? vl : `${vl}px`;
12
12
  };
13
+
13
14
  /**
14
15
  * Get color from CORE colors
15
16
  *
16
17
  * @param {string} cl
17
18
  * @returns {string}
18
19
  */
19
-
20
20
  export const getColor = cl => {
21
21
  return colors[cl] || cl;
22
22
  };
@@ -1,22 +1,22 @@
1
1
  // Sorted ASC by size. That's important.
2
2
  // It can't be configured as it's used statically for propTypes.
3
3
  export const breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
4
-
5
4
  const sortBreakpointsValues = values => {
6
5
  const breakpointsAsArray = Object.keys(values).map(key => ({
7
6
  key,
8
7
  val: values[key]
9
- })) || []; // Sort in ascending order
10
-
8
+ })) || [];
9
+ // Sort in ascending order
11
10
  breakpointsAsArray.sort((breakpoint1, breakpoint2) => breakpoint1.val - breakpoint2.val);
12
11
  return breakpointsAsArray.reduce((acc, obj) => {
13
- return { ...acc,
12
+ return {
13
+ ...acc,
14
14
  [obj.key]: obj.val
15
15
  };
16
16
  }, {});
17
- }; // Keep in mind that @media is inclusive by the CSS specification.
18
-
17
+ };
19
18
 
19
+ // Keep in mind that @media is inclusive by the CSS specification.
20
20
  const createBreakpoints = breakpoints => {
21
21
  const {
22
22
  // The breakpoint **start** at this value.
@@ -31,53 +31,43 @@ const createBreakpoints = breakpoints => {
31
31
  lg: 1200,
32
32
  // large
33
33
  xl: 1536 // extra-large
34
-
35
34
  },
35
+
36
36
  unit = 'px',
37
37
  step = 5,
38
38
  ...other
39
39
  } = breakpoints;
40
40
  const sortedValues = sortBreakpointsValues(values);
41
41
  const keys = Object.keys(sortedValues);
42
-
43
42
  const up = (key, removeMedia = false) => {
44
43
  const value = typeof values[key] === 'number' ? values[key] : key;
45
44
  return `${removeMedia ? '' : '@media '}(min-width:${value}${unit})`;
46
45
  };
47
-
48
46
  const down = (key, removeMedia = false) => {
49
47
  const value = typeof values[key] === 'number' ? values[key] : key;
50
48
  return `${removeMedia ? '' : '@media '}(max-width:${value - step / 100}${unit})`;
51
49
  };
52
-
53
50
  const between = (start, end, removeMedia = false) => {
54
51
  const endIndex = keys.indexOf(end);
55
52
  return `${removeMedia ? '' : '@media '}(min-width:${typeof values[start] === 'number' ? values[start] : start}${unit}) and ` + `(max-width:${(endIndex !== -1 && typeof values[keys[endIndex]] === 'number' ? values[keys[endIndex]] : end) - step / 100}${unit})`;
56
53
  };
57
-
58
54
  const only = (key, removeMedia = false) => {
59
55
  if (keys.indexOf(key) + 1 < keys.length) {
60
56
  return between(key, keys[keys.indexOf(key) + 1], removeMedia);
61
57
  }
62
-
63
58
  return up(key, removeMedia);
64
59
  };
65
-
66
60
  const not = (key, removeMedia = false) => {
67
61
  // handle first and last key separately, for better readability
68
62
  const keyIndex = keys.indexOf(key);
69
-
70
63
  if (keyIndex === 0) {
71
64
  return up(keys[1], removeMedia);
72
65
  }
73
-
74
66
  if (keyIndex === keys.length - 1) {
75
67
  return down(keys[keyIndex], removeMedia);
76
68
  }
77
-
78
69
  return between(key, keys[keys.indexOf(key) + 1]).replace('@media', removeMedia ? 'not all and' : '@media not all and');
79
70
  };
80
-
81
71
  return {
82
72
  keys,
83
73
  values: sortedValues,
@@ -90,5 +80,4 @@ const createBreakpoints = breakpoints => {
90
80
  ...other
91
81
  };
92
82
  };
93
-
94
83
  export default createBreakpoints;
@@ -5,17 +5,15 @@ import theme from './settings';
5
5
  export const makeStylesCache = createCache({
6
6
  key: 'css'
7
7
  });
8
-
9
8
  const makeStyles = styles => {
10
9
  return (props = {}) => {
11
10
  const cache = makeStylesCache;
12
-
13
11
  if (typeof styles === 'function') {
14
12
  styles = styles(theme);
15
13
  }
16
-
17
14
  const result = Object.keys(styles).reduce((acc, key) => {
18
- const _styles = { ...styles[key]
15
+ const _styles = {
16
+ ...styles[key]
19
17
  };
20
18
  Object.keys(_styles).forEach(item => {
21
19
  if (typeof _styles[item] === 'function') _styles[item] = _styles[item](props);
@@ -28,5 +26,4 @@ const makeStyles = styles => {
28
26
  return result;
29
27
  };
30
28
  };
31
-
32
29
  export default makeStyles;
@@ -1,9 +1,8 @@
1
1
  import Settings from './settings';
2
-
3
2
  const saveNewTheme = (newTheme, ingredient) => {
4
3
  if (typeof newTheme === 'object' && typeof ingredient === 'object') {
5
- const newThemeArr = Object.keys(newTheme); // const ingredientArr = Object.keys(ingredient);
6
-
4
+ const newThemeArr = Object.keys(newTheme);
5
+ // const ingredientArr = Object.keys(ingredient);
7
6
  newThemeArr.forEach(key => {
8
7
  if (newTheme[key] && ingredient[key]) {
9
8
  if (typeof newTheme[key] === 'object' && typeof ingredient[key] === 'object') {
@@ -17,19 +16,17 @@ const saveNewTheme = (newTheme, ingredient) => {
17
16
  });
18
17
  }
19
18
  };
19
+
20
20
  /**
21
21
  * set theme setting as global
22
22
  * @param {Object} theme
23
23
  */
24
-
25
-
26
24
  export const setTheme = theme => {
27
25
  if (theme && typeof theme === 'object') {
28
26
  const themeKeys = Object.keys(theme);
29
27
  themeKeys.forEach(key => {
30
28
  const newTheme = theme[key];
31
29
  const ingredient = Settings[key];
32
-
33
30
  if (newTheme && ingredient) {
34
31
  saveNewTheme(newTheme, ingredient);
35
32
  }