diginet-core-ui 1.3.66 → 1.3.67

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 (46) hide show
  1. package/assets/storybook/avatar01.svg +9 -0
  2. package/assets/storybook/cover01.svg +9 -0
  3. package/components/accordion/css.js +6 -6
  4. package/components/accordion/details.js +13 -18
  5. package/components/accordion/group.js +16 -17
  6. package/components/accordion/index.js +17 -22
  7. package/components/accordion/summary.js +55 -32
  8. package/components/avatar/index.js +23 -28
  9. package/components/badge/index.js +9 -14
  10. package/components/button/icon.js +25 -30
  11. package/components/button/index.js +275 -280
  12. package/components/card/body.js +47 -0
  13. package/components/card/extra.js +47 -0
  14. package/components/card/footer.js +47 -0
  15. package/components/card/header.js +50 -0
  16. package/components/card/index.js +175 -37
  17. package/components/chart/Pie-v2/Sector.js +2 -2
  18. package/components/chip/attach.js +5 -5
  19. package/components/form-control/attachment/index.js +26 -24
  20. package/components/form-control/calendar/function.js +133 -123
  21. package/components/form-control/calendar/index.js +16 -16
  22. package/components/form-control/dropdown/index.js +71 -10
  23. package/components/form-control/helper-text/index.js +8 -3
  24. package/components/form-control/number-input/index.js +11 -11
  25. package/components/form-control/phone-input/index.js +7 -7
  26. package/components/grid/Container.js +110 -0
  27. package/components/grid/Row.js +1 -1
  28. package/components/grid/index.js +35 -5
  29. package/components/index.js +7 -2
  30. package/components/others/option-wrapper/index.js +21 -27
  31. package/components/paging/page-info.js +31 -40
  32. package/components/popover/index.js +29 -27
  33. package/components/progress/circular.js +12 -12
  34. package/components/transfer/index.js +3 -3
  35. package/components/tree-view/index.js +10 -6
  36. package/icons/basic.js +120 -0
  37. package/icons/effect.js +4 -9
  38. package/package.json +1 -1
  39. package/readme.md +14 -0
  40. package/styles/color-helper.js +103 -103
  41. package/styles/utils.js +17 -5
  42. package/utils/error/error.js +2 -2
  43. package/utils/renderIcon.js +5 -5
  44. package/components/card/body-card.js +0 -65
  45. package/components/card/card.js +0 -125
  46. package/components/card/context.js +0 -6
@@ -65,8 +65,8 @@ const getDimension = size => {
65
65
  strokeWidth
66
66
  };
67
67
  };
68
- /**
69
- * Determinate circular progress
68
+ /**
69
+ * Determinate circular progress
70
70
  */
71
71
 
72
72
 
@@ -115,8 +115,8 @@ const Determinate = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
115
115
 
116
116
  return angle;
117
117
  };
118
- /**
119
- * style
118
+ /**
119
+ * style
120
120
  */
121
121
 
122
122
 
@@ -218,8 +218,8 @@ Determinate.propTypes = {
218
218
  width: PropTypes.number
219
219
  };
220
220
  export const DeterminateCircularProgress = Determinate;
221
- /**
222
- * Indeterminate circular progress
221
+ /**
222
+ * Indeterminate circular progress
223
223
  */
224
224
 
225
225
  const Indeterminate = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
@@ -256,8 +256,8 @@ const Indeterminate = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
256
256
  stroke-dashoffset: -${r * 124 / 200};
257
257
  }
258
258
  `;
259
- /**
260
- * style
259
+ /**
260
+ * style
261
261
  */
262
262
 
263
263
 
@@ -288,8 +288,8 @@ const Indeterminate = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
288
288
  stroke-linecap: round;
289
289
  stroke-width: ${circleStrokeW};
290
290
  `;
291
- /**
292
- * component
291
+ /**
292
+ * component
293
293
  */
294
294
 
295
295
  const CircleBackgroundMemo = useMemo(() => jsx("circle", {
@@ -332,8 +332,8 @@ Indeterminate.propTypes = {
332
332
  width: PropTypes.number
333
333
  };
334
334
  export const IndeterminateCircularProgress = Indeterminate;
335
- /**
336
- * Circular progress
335
+ /**
336
+ * Circular progress
337
337
  */
338
338
 
339
339
  const CircularProgress = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
@@ -456,9 +456,9 @@ Transfer.propTypes = {
456
456
  /** field name used for icon display */
457
457
  iconExpr: string,
458
458
 
459
- /** field name used for text display<br/>
460
- * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
461
- * Note: don't use 'id - name', return undefined
459
+ /** field name used for text display<br/>
460
+ * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
461
+ * Note: don't use 'id - name', return undefined
462
462
  */
463
463
  displayExpr: oneOfType([string, array]),
464
464
 
@@ -227,8 +227,8 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
227
227
  el.classList[isChecked ? 'add' : 'remove']('disabled');
228
228
 
229
229
  if (el.classList.contains('DGN-UI-Accordion')) {
230
- el.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild.classList[isChecked ? 'add' : 'remove']('disabled');
231
- el.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild.disabled = isChecked;
230
+ el.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild.classList[isChecked ? 'add' : 'remove']('disabled');
231
+ el.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild.disabled = isChecked;
232
232
  Array.from(el.childNodes).forEach(e => {
233
233
  e.classList[isChecked ? 'add' : 'remove']('treeview-disabled');
234
234
  });
@@ -248,7 +248,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
248
248
  if (node.classList.contains('DGN-UI-Accordion') && node.firstChild.classList.contains('DGN-UI-Accordion-Summary')) {
249
249
  var _node$querySelectorAl;
250
250
 
251
- const checkbox = node.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild; // Trường hợp phải set về false để xét các input đã check không bao gồm node này
251
+ const checkbox = node.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild; // Trường hợp phải set về false để xét các input đã check không bao gồm node này
252
252
 
253
253
  checkbox.firstChild.checked = isChecked;
254
254
  const mustDisabled = !!((_node$querySelectorAl = node.querySelectorAll('input:checked')) !== null && _node$querySelectorAl !== void 0 && _node$querySelectorAl.length); // Nếu có ít nhất một input con được check thì phải checked cho input này
@@ -299,14 +299,18 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
299
299
  };
300
300
 
301
301
  const setValueIntoInput = data => {
302
+ var _clearIconRef$current2;
303
+
302
304
  if (!data || !(data !== null && data !== void 0 && data.length)) {
305
+ var _clearIconRef$current;
306
+
303
307
  inputValueRef.current.value = '';
304
- clearIconRef.current.style.opacity = 0;
308
+ if ((_clearIconRef$current = clearIconRef.current) !== null && _clearIconRef$current !== void 0 && _clearIconRef$current.element) clearIconRef.current.element.style.opacity = 0;
305
309
  return;
306
310
  }
307
311
 
308
- if (clearIconRef.current.style.opacity === '0') {
309
- clearIconRef.current.style.opacity = null;
312
+ if ((_clearIconRef$current2 = clearIconRef.current) !== null && _clearIconRef$current2 !== void 0 && _clearIconRef$current2.element && clearIconRef.current.element.style.opacity === '0') {
313
+ clearIconRef.current.element.style.opacity = null;
310
314
  }
311
315
 
312
316
  let result = '';
package/icons/basic.js CHANGED
@@ -2915,6 +2915,34 @@ export const List = /*#__PURE__*/memo(({
2915
2915
  fill: colors[color] || color
2916
2916
  }));
2917
2917
  });
2918
+ export const ListAlt = /*#__PURE__*/memo(({
2919
+ width,
2920
+ height,
2921
+ color = '#7F828E',
2922
+ viewBox = false
2923
+ }) => {
2924
+ return viewBox ? /*#__PURE__*/React.createElement("svg", {
2925
+ width: width || 24,
2926
+ height: height || 24,
2927
+ viewBox: "0 0 24 24",
2928
+ fill: "none"
2929
+ }, /*#__PURE__*/React.createElement("path", {
2930
+ fillRule: "evenodd",
2931
+ clipRule: "evenodd",
2932
+ d: "M20.1 3H3.9C3.4 3 3 3.4 3 3.9V20.1C3 20.5 3.4 21 3.9 21H20.1C20.5 21 21 20.5 21 20.1V3.9C21 3.4 20.5 3 20.1 3ZM9 7H7V9H9V7ZM17 7H11V9H17V7ZM17 11H11V13H17V11ZM11 15H17V17H11V15ZM7 11H9V13H7V11ZM9 15H7V17H9V15ZM5 19H19V5H5V19Z",
2933
+ fill: colors[color] || color
2934
+ })) : /*#__PURE__*/React.createElement("svg", {
2935
+ width: width || 18,
2936
+ height: height || 18,
2937
+ viewBox: "0 0 18 18",
2938
+ fill: "none"
2939
+ }, /*#__PURE__*/React.createElement("path", {
2940
+ fillRule: "evenodd",
2941
+ clipRule: "evenodd",
2942
+ d: "M17.1 0H0.9C0.4 0 0 0.4 0 0.9V17.1C0 17.5 0.4 18 0.9 18H17.1C17.5 18 18 17.5 18 17.1V0.9C18 0.4 17.5 0 17.1 0ZM6 4H4V6H6V4ZM14 4H8V6H14V4ZM14 8H8V10H14V8ZM8 12H14V14H8V12ZM4 8H6V10H4V8ZM6 12H4V14H6V12ZM2 16H16V2H2V16Z",
2943
+ fill: colors[color] || color
2944
+ }));
2945
+ });
2918
2946
  export const ListApproval = /*#__PURE__*/memo(({
2919
2947
  width,
2920
2948
  height,
@@ -3720,6 +3748,30 @@ export const NotificationV2 = /*#__PURE__*/memo(({
3720
3748
  fill: colors[color] || color
3721
3749
  }));
3722
3750
  });
3751
+ export const Undo = /*#__PURE__*/memo(({
3752
+ width,
3753
+ height,
3754
+ color = '#7F828E',
3755
+ viewBox = false
3756
+ }) => {
3757
+ return viewBox ? /*#__PURE__*/React.createElement("svg", {
3758
+ width: width || 24,
3759
+ height: height || 24,
3760
+ viewBox: "0 0 24 24",
3761
+ fill: "none"
3762
+ }, /*#__PURE__*/React.createElement("path", {
3763
+ d: "M12.5 8C9.85 8 7.45 8.99 5.6 10.6L2 7V16H11L7.38 12.38C8.77 11.22 10.54 10.5 12.5 10.5C16.04 10.5 19.05 12.81 20.1 16L22.47 15.22C21.08 11.03 17.15 8 12.5 8Z",
3764
+ fill: colors[color] || color
3765
+ })) : /*#__PURE__*/React.createElement("svg", {
3766
+ width: width || 21,
3767
+ height: height || 9,
3768
+ viewBox: "0 0 21 9",
3769
+ fill: "none"
3770
+ }, /*#__PURE__*/React.createElement("path", {
3771
+ d: "M10.5 1C7.85 1 5.45 1.99 3.6 3.6L0 0V9H9L5.38 5.38C6.77 4.22 8.54 3.5 10.5 3.5C14.04 3.5 17.05 5.81 18.1 9L20.47 8.22C19.08 4.03 15.15 1 10.5 1Z",
3772
+ fill: colors[color] || color
3773
+ }));
3774
+ });
3723
3775
  export const Unlock = /*#__PURE__*/memo(({
3724
3776
  width,
3725
3777
  height,
@@ -4276,6 +4328,46 @@ export const PersonRate = /*#__PURE__*/memo(({
4276
4328
  fill: colors[color] || color
4277
4329
  }));
4278
4330
  });
4331
+ export const PersonSetting = /*#__PURE__*/memo(({
4332
+ width,
4333
+ height,
4334
+ color = '#7F828E',
4335
+ viewBox = false
4336
+ }) => {
4337
+ return viewBox ? /*#__PURE__*/React.createElement("svg", {
4338
+ width: width || 24,
4339
+ height: height || 24,
4340
+ viewBox: "0 0 24 24",
4341
+ fill: "none"
4342
+ }, /*#__PURE__*/React.createElement("path", {
4343
+ d: "M11 11C13.21 11 15 9.21 15 7C15 4.79 13.21 3 11 3C8.79 3 7 4.79 7 7C7 9.21 8.79 11 11 11Z",
4344
+ fill: colors[color] || color
4345
+ }), /*#__PURE__*/React.createElement("path", {
4346
+ d: "M11 13C8.33 13 3 14.34 3 17V19H12.8027C12.2922 18.1175 12 17.0929 12 16C12 14.9646 12.2623 13.9904 12.724 13.1403C12.0912 13.0468 11.4991 13 11 13Z",
4347
+ fill: colors[color] || color
4348
+ }), /*#__PURE__*/React.createElement("path", {
4349
+ fillRule: "evenodd",
4350
+ clipRule: "evenodd",
4351
+ d: "M21.0851 16C21.0851 16.136 21.0727 16.264 21.0563 16.392L21.924 17.052C22.0021 17.112 22.0227 17.22 21.9733 17.308L21.1509 18.692C21.1015 18.78 20.9946 18.816 20.9 18.78L19.8761 18.38C19.6622 18.536 19.432 18.672 19.1811 18.772L19.0248 19.832C19.0125 19.928 18.9262 20 18.8234 20H17.1785C17.0757 20 16.9893 19.928 16.977 19.832L16.8207 18.772C16.5699 18.672 16.3396 18.54 16.1257 18.38L15.1018 18.78C15.0113 18.812 14.9003 18.78 14.851 18.692L14.0285 17.308C13.9792 17.22 13.9997 17.112 14.0779 17.052L14.9455 16.392C14.9291 16.264 14.9167 16.132 14.9167 16C14.9167 15.868 14.9291 15.736 14.9455 15.608L14.0779 14.948C13.9997 14.888 13.9751 14.78 14.0285 14.692L14.851 13.308C14.9003 13.22 15.0072 13.184 15.1018 13.22L16.1257 13.62C16.3396 13.464 16.5699 13.328 16.8207 13.228L16.977 12.168C16.9893 12.072 17.0757 12 17.1785 12H18.8234C18.9262 12 19.0125 12.072 19.0248 12.168L19.1811 13.228C19.432 13.328 19.6622 13.46 19.8761 13.62L20.9 13.22C20.9905 13.188 21.1015 13.22 21.1509 13.308L21.9733 14.692C22.0227 14.78 22.0021 14.888 21.924 14.948L21.0563 15.608C21.0727 15.736 21.0851 15.864 21.0851 16ZM16.5616 16C16.5616 16.772 17.2073 17.4 18.0009 17.4C18.7946 17.4 19.4402 16.772 19.4402 16C19.4402 15.228 18.7946 14.6 18.0009 14.6C17.2073 14.6 16.5616 15.228 16.5616 16Z",
4352
+ fill: colors[color] || color
4353
+ })) : /*#__PURE__*/React.createElement("svg", {
4354
+ width: width || 19,
4355
+ height: height || 17,
4356
+ viewBox: "0 0 19 17",
4357
+ fill: "none"
4358
+ }, /*#__PURE__*/React.createElement("path", {
4359
+ d: "M8 8C10.21 8 12 6.21 12 4C12 1.79 10.21 0 8 0C5.79 0 4 1.79 4 4C4 6.21 5.79 8 8 8Z",
4360
+ fill: colors[color] || color
4361
+ }), /*#__PURE__*/React.createElement("path", {
4362
+ d: "M8 10C5.33 10 0 11.34 0 14V16H9.80269C9.29218 15.1175 9 14.0929 9 13C9 11.9646 9.26227 10.9904 9.724 10.1403C9.09118 10.0468 8.49911 10 8 10Z",
4363
+ fill: colors[color] || color
4364
+ }), /*#__PURE__*/React.createElement("path", {
4365
+ fillRule: "evenodd",
4366
+ clipRule: "evenodd",
4367
+ d: "M18.0851 13C18.0851 13.136 18.0727 13.264 18.0563 13.392L18.924 14.052C19.0021 14.112 19.0227 14.22 18.9733 14.308L18.1509 15.692C18.1015 15.78 17.9946 15.816 17.9 15.78L16.8761 15.38C16.6622 15.536 16.432 15.672 16.1811 15.772L16.0248 16.832C16.0125 16.928 15.9262 17 15.8234 17H14.1785C14.0757 17 13.9893 16.928 13.977 16.832L13.8207 15.772C13.5699 15.672 13.3396 15.54 13.1257 15.38L12.1018 15.78C12.0113 15.812 11.9003 15.78 11.851 15.692L11.0285 14.308C10.9792 14.22 10.9997 14.112 11.0779 14.052L11.9455 13.392C11.9291 13.264 11.9167 13.132 11.9167 13C11.9167 12.868 11.9291 12.736 11.9455 12.608L11.0779 11.948C10.9997 11.888 10.9751 11.78 11.0285 11.692L11.851 10.308C11.9003 10.22 12.0072 10.184 12.1018 10.22L13.1257 10.62C13.3396 10.464 13.5699 10.328 13.8207 10.228L13.977 9.168C13.9893 9.072 14.0757 9 14.1785 9H15.8234C15.9262 9 16.0125 9.072 16.0248 9.168L16.1811 10.228C16.432 10.328 16.6622 10.46 16.8761 10.62L17.9 10.22C17.9905 10.188 18.1015 10.22 18.1509 10.308L18.9733 11.692C19.0227 11.78 19.0021 11.888 18.924 11.948L18.0563 12.608C18.0727 12.736 18.0851 12.864 18.0851 13ZM13.5616 13C13.5616 13.772 14.2073 14.4 15.0009 14.4C15.7946 14.4 16.4402 13.772 16.4402 13C16.4402 12.228 15.7946 11.6 15.0009 11.6C14.2073 11.6 13.5616 12.228 13.5616 13Z",
4368
+ fill: colors[color] || color
4369
+ }));
4370
+ });
4279
4371
  export const PersonSync = /*#__PURE__*/memo(({
4280
4372
  width,
4281
4373
  height,
@@ -5547,6 +5639,34 @@ export const View = /*#__PURE__*/memo(({
5547
5639
  fill: colors[color] || color
5548
5640
  }));
5549
5641
  });
5642
+ export const ViewHeadline = /*#__PURE__*/memo(({
5643
+ width,
5644
+ height,
5645
+ color = '#7F828E',
5646
+ viewBox = false
5647
+ }) => {
5648
+ return viewBox ? /*#__PURE__*/React.createElement("svg", {
5649
+ width: width || 24,
5650
+ height: height || 24,
5651
+ viewBox: "0 0 24 24",
5652
+ fill: "none"
5653
+ }, /*#__PURE__*/React.createElement("path", {
5654
+ fillRule: "evenodd",
5655
+ clipRule: "evenodd",
5656
+ d: "M4 7V5H20V7H4ZM4 11H20V9H4V11ZM20 15H4V13H20V15ZM20 19H4V17H20V19Z",
5657
+ fill: colors[color] || color
5658
+ })) : /*#__PURE__*/React.createElement("svg", {
5659
+ width: width || 16,
5660
+ height: height || 14,
5661
+ viewBox: "0 0 16 14",
5662
+ fill: "none"
5663
+ }, /*#__PURE__*/React.createElement("path", {
5664
+ fillRule: "evenodd",
5665
+ clipRule: "evenodd",
5666
+ d: "M0 2V0H16V2H0ZM0 6H16V4H0V6ZM16 10H0V8H16V10ZM16 14H0V12H16V14Z",
5667
+ fill: colors[color] || color
5668
+ }));
5669
+ });
5550
5670
  export const UnView = /*#__PURE__*/memo(({
5551
5671
  width,
5552
5672
  height,
package/icons/effect.js CHANGED
@@ -45,15 +45,10 @@ const Icon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
45
45
  height: ${width ? isNaN(width) ? width : width + 'px' : '24px'};
46
46
  border: 1px dashed ${rest};
47
47
  `;
48
- useImperativeHandle(reference, () => {
49
- const currentRef = ref.current || {};
50
- const _instance = {}; // methods
51
-
52
- _instance.__proto__ = {}; // hidden methods
53
-
54
- currentRef.instance = _instance;
55
- return currentRef;
56
- });
48
+ useImperativeHandle(reference, () => ({
49
+ element: ref.current,
50
+ instance: {}
51
+ }));
57
52
  return useMemo(() => {
58
53
  if (!name) return null;
59
54
  let node = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.66",
3
+ "version": "1.3.67",
4
4
  "description": "The DigiNet core ui",
5
5
  "homepage": "https://diginet.com.vn",
6
6
  "main": "index.js",
package/readme.md CHANGED
@@ -38,6 +38,20 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
+ ## 1.3.67
42
+ - \[Added\]: Icon – ListAlt, PersonSetting, Undo, ViewHeadline
43
+ - \[Changed\]: OptionWrapper – Update OptionWrapper
44
+ - \[Changed\]: Accordion – Change align AccordionSummary content to center
45
+ - \[Changed\]: Dropdown – Add props searchExpr, searchMode
46
+ - \[Changed\]: Row, Container – Update row spacing, Add component Container
47
+ - \[Changed\]: Dropdown – Add hover tooltip when selected text value too long
48
+ - \[Changed\]: Card – Update design
49
+ - \[Changed\]: HelperText – Add props of Typography
50
+ - \[Changed\]: Dropdown – Add hidden render item
51
+ - \[Fixed\]: Button – Fix typography by size
52
+ - \[Fixed\]: TECH – Fix babel warning
53
+ - \[Fixed\]: Dropdown – Fix dropdown render out of screen
54
+
41
55
  ## 1.3.66
42
56
  - \[Changed\]: THEME – Update makestyles
43
57
  - \[Changed\]: THEME – Refactoring makeStyles
@@ -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
- /**
2
- * parse to pixel
3
- *
4
- * @param {number} value
5
- * @returns {string}
1
+ import { color as colors } from './colors';
2
+ /**
3
+ * Parse to pixel
4
+ *
5
+ * @param {number} vl
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
  };