@chayns-components/core 5.0.0-beta.37 → 5.0.0-beta.38

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 (95) hide show
  1. package/lib/components/accordion/Accordion.js +0 -16
  2. package/lib/components/accordion/Accordion.js.map +1 -1
  3. package/lib/components/accordion/Accordion.styles.js +42 -21
  4. package/lib/components/accordion/Accordion.styles.js.map +1 -1
  5. package/lib/components/accordion/accordion-body/AccordionBody.js +0 -6
  6. package/lib/components/accordion/accordion-body/AccordionBody.js.map +1 -1
  7. package/lib/components/accordion/accordion-body/AccordionBody.styles.js +3 -9
  8. package/lib/components/accordion/accordion-body/AccordionBody.styles.js.map +1 -1
  9. package/lib/components/accordion/accordion-content/AccordionContent.js +0 -6
  10. package/lib/components/accordion/accordion-content/AccordionContent.js.map +1 -1
  11. package/lib/components/accordion/accordion-content/AccordionContent.styles.js +6 -11
  12. package/lib/components/accordion/accordion-content/AccordionContent.styles.js.map +1 -1
  13. package/lib/components/accordion/accordion-group/AccordionGroup.js +0 -8
  14. package/lib/components/accordion/accordion-group/AccordionGroup.js.map +1 -1
  15. package/lib/components/accordion/accordion-head/AccordionHead.js +1 -12
  16. package/lib/components/accordion/accordion-head/AccordionHead.js.map +1 -1
  17. package/lib/components/accordion/accordion-head/AccordionHead.styles.js +95 -32
  18. package/lib/components/accordion/accordion-head/AccordionHead.styles.js.map +1 -1
  19. package/lib/components/accordion/accordion-intro/AccordionIntro.js +0 -5
  20. package/lib/components/accordion/accordion-intro/AccordionIntro.js.map +1 -1
  21. package/lib/components/accordion/accordion-intro/AccordionIntro.styles.js +3 -9
  22. package/lib/components/accordion/accordion-intro/AccordionIntro.styles.js.map +1 -1
  23. package/lib/components/accordion/utils.js +1 -5
  24. package/lib/components/accordion/utils.js.map +1 -1
  25. package/lib/components/badge/Badge.js +0 -6
  26. package/lib/components/badge/Badge.js.map +1 -1
  27. package/lib/components/badge/Badge.styles.js +12 -11
  28. package/lib/components/badge/Badge.styles.js.map +1 -1
  29. package/lib/components/button/Button.js +0 -10
  30. package/lib/components/button/Button.js.map +1 -1
  31. package/lib/components/button/Button.styles.js +32 -17
  32. package/lib/components/button/Button.styles.js.map +1 -1
  33. package/lib/components/checkbox/Checkbox.js +0 -8
  34. package/lib/components/checkbox/Checkbox.js.map +1 -1
  35. package/lib/components/checkbox/Checkbox.styles.js +67 -29
  36. package/lib/components/checkbox/Checkbox.styles.js.map +1 -1
  37. package/lib/components/color-scheme-provider/ColorSchemeProvider.js +12 -21
  38. package/lib/components/color-scheme-provider/ColorSchemeProvider.js.map +1 -1
  39. package/lib/components/context-menu/ContextMenu.js +3 -24
  40. package/lib/components/context-menu/ContextMenu.js.map +1 -1
  41. package/lib/components/context-menu/ContextMenu.styles.js +3 -9
  42. package/lib/components/context-menu/ContextMenu.styles.js.map +1 -1
  43. package/lib/components/context-menu/constants/alignment.js +0 -1
  44. package/lib/components/context-menu/constants/alignment.js.map +1 -1
  45. package/lib/components/context-menu/context-menu-content/ContextMenuContent.js +7 -8
  46. package/lib/components/context-menu/context-menu-content/ContextMenuContent.js.map +1 -1
  47. package/lib/components/context-menu/context-menu-content/ContextMenuContent.styles.js +78 -33
  48. package/lib/components/context-menu/context-menu-content/ContextMenuContent.styles.js.map +1 -1
  49. package/lib/components/grid-image/GridImage.js +0 -6
  50. package/lib/components/grid-image/GridImage.js.map +1 -1
  51. package/lib/components/grid-image/GridImage.styles.js +52 -28
  52. package/lib/components/grid-image/GridImage.styles.js.map +1 -1
  53. package/lib/components/icon/Icon.js +0 -13
  54. package/lib/components/icon/Icon.js.map +1 -1
  55. package/lib/components/icon/Icon.styles.js +33 -25
  56. package/lib/components/icon/Icon.styles.js.map +1 -1
  57. package/lib/components/icon/utils.js +0 -3
  58. package/lib/components/icon/utils.js.map +1 -1
  59. package/lib/components/input/Input.js +2 -9
  60. package/lib/components/input/Input.js.map +1 -1
  61. package/lib/components/input/Input.styles.js +31 -20
  62. package/lib/components/input/Input.styles.js.map +1 -1
  63. package/lib/components/list/List.js +0 -8
  64. package/lib/components/list/List.js.map +1 -1
  65. package/lib/components/list/list-item/ListItem.js +0 -14
  66. package/lib/components/list/list-item/ListItem.js.map +1 -1
  67. package/lib/components/list/list-item/ListItem.styles.js +27 -17
  68. package/lib/components/list/list-item/ListItem.styles.js.map +1 -1
  69. package/lib/components/list/list-item/list-item-body/ListItemBody.js +0 -5
  70. package/lib/components/list/list-item/list-item-body/ListItemBody.js.map +1 -1
  71. package/lib/components/list/list-item/list-item-body/ListItemBody.styles.js +3 -9
  72. package/lib/components/list/list-item/list-item-body/ListItemBody.styles.js.map +1 -1
  73. package/lib/components/list/list-item/list-item-content/ListItemContent.js +0 -5
  74. package/lib/components/list/list-item/list-item-content/ListItemContent.js.map +1 -1
  75. package/lib/components/list/list-item/list-item-content/ListItemContent.styles.js +5 -10
  76. package/lib/components/list/list-item/list-item-content/ListItemContent.styles.js.map +1 -1
  77. package/lib/components/list/list-item/list-item-head/ListItemHead.js +0 -12
  78. package/lib/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
  79. package/lib/components/list/list-item/list-item-head/ListItemHead.styles.js +73 -42
  80. package/lib/components/list/list-item/list-item-head/ListItemHead.styles.js.map +1 -1
  81. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.js +0 -6
  82. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.js.map +1 -1
  83. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.styles.js +14 -11
  84. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.styles.js.map +1 -1
  85. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.js +0 -11
  86. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.js.map +1 -1
  87. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js +25 -16
  88. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js.map +1 -1
  89. package/lib/hooks/uuid.js +0 -4
  90. package/lib/hooks/uuid.js.map +1 -1
  91. package/lib/index.js +0 -14
  92. package/lib/index.js.map +1 -1
  93. package/lib/types/chayns.js +0 -1
  94. package/lib/types/chayns.js.map +1 -1
  95. package/package.json +15 -15
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","names":["Checkbox","children","isChecked","isDisabled","onChange","shouldShowAsSwitch","isActive","setIsActive","useState","handleChange","useCallback","event","target","checked","uuid","useUuid","displayName"],"sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FC,\n ReactNode,\n useCallback,\n useState,\n} from 'react';\nimport { useUuid } from '../../hooks/uuid';\nimport { StyledCheckbox, StyledCheckboxInput, StyledCheckboxLabel } from './Checkbox.styles';\n\nexport type CheckboxProps = {\n /**\n * Text for checkbox or switch\n */\n children?: ReactNode;\n /**\n * Indicates whether the checkbox or switch is selected\n */\n isChecked?: boolean;\n /**\n * Disables the checkbox or switch so it cannot be toggled\n */\n isDisabled?: boolean;\n /**\n * Function to be executed if the checked value changes\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Changes the design to use switch instead of checkbox\n */\n shouldShowAsSwitch?: boolean;\n};\n\nconst Checkbox: FC<CheckboxProps> = ({\n children,\n isChecked,\n isDisabled,\n onChange,\n shouldShowAsSwitch,\n}) => {\n const [isActive, setIsActive] = useState(isChecked ?? false);\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setIsActive(event.target.checked);\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [onChange]\n );\n\n const uuid = useUuid();\n\n return (\n <StyledCheckbox>\n <StyledCheckboxInput\n checked={isChecked}\n disabled={isDisabled}\n id={uuid}\n onChange={handleChange}\n type=\"checkbox\"\n />\n <StyledCheckboxLabel\n htmlFor={uuid}\n isChecked={isChecked ?? isActive}\n isDisabled={isDisabled}\n shouldShowAsSwitch={shouldShowAsSwitch}\n >\n {children}\n </StyledCheckboxLabel>\n </StyledCheckbox>\n );\n};\n\nCheckbox.displayName = 'Checkbox';\n\nexport default Checkbox;\n"],"mappings":";;;;;;;AAAA;;AAQA;;AACA;;;;;;AAyBA,MAAMA,QAA2B,GAAG,QAM9B;EAAA,IAN+B;IACjCC,QADiC;IAEjCC,SAFiC;IAGjCC,UAHiC;IAIjCC,QAJiC;IAKjCC;EALiC,CAM/B;EACF,MAAM,CAACC,QAAD,EAAWC,WAAX,IAA0B,IAAAC,eAAA,EAASN,SAAT,aAASA,SAAT,cAASA,SAAT,GAAsB,KAAtB,CAAhC;EAEA,MAAMO,YAAY,GAAG,IAAAC,kBAAA,EAChBC,KAAD,IAA0C;IACtCJ,WAAW,CAACI,KAAK,CAACC,MAAN,CAAaC,OAAd,CAAX;;IAEA,IAAI,OAAOT,QAAP,KAAoB,UAAxB,EAAoC;MAChCA,QAAQ,CAACO,KAAD,CAAR;IACH;EACJ,CAPgB,EAQjB,CAACP,QAAD,CARiB,CAArB;EAWA,MAAMU,IAAI,GAAG,IAAAC,aAAA,GAAb;EAEA,oBACI,6BAAC,wBAAD,qBACI,6BAAC,6BAAD;IACI,OAAO,EAAEb,SADb;IAEI,QAAQ,EAAEC,UAFd;IAGI,EAAE,EAAEW,IAHR;IAII,QAAQ,EAAEL,YAJd;IAKI,IAAI,EAAC;EALT,EADJ,eAQI,6BAAC,6BAAD;IACI,OAAO,EAAEK,IADb;IAEI,SAAS,EAAEZ,SAAF,aAAEA,SAAF,cAAEA,SAAF,GAAeI,QAF5B;IAGI,UAAU,EAAEH,UAHhB;IAII,kBAAkB,EAAEE;EAJxB,GAMKJ,QANL,CARJ,CADJ;AAmBH,CAzCD;;AA2CAD,QAAQ,CAACgB,WAAT,GAAuB,UAAvB;eAEehB,Q"}
1
+ {"version":3,"file":"Checkbox.js","names":["Checkbox","children","isChecked","isDisabled","onChange","shouldShowAsSwitch","isActive","setIsActive","useState","handleChange","useCallback","event","target","checked","uuid","useUuid","displayName"],"sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FC,\n ReactNode,\n useCallback,\n useState,\n} from 'react';\nimport { useUuid } from '../../hooks/uuid';\nimport { StyledCheckbox, StyledCheckboxInput, StyledCheckboxLabel } from './Checkbox.styles';\n\nexport type CheckboxProps = {\n /**\n * Text for checkbox or switch\n */\n children?: ReactNode;\n /**\n * Indicates whether the checkbox or switch is selected\n */\n isChecked?: boolean;\n /**\n * Disables the checkbox or switch so it cannot be toggled\n */\n isDisabled?: boolean;\n /**\n * Function to be executed if the checked value changes\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Changes the design to use switch instead of checkbox\n */\n shouldShowAsSwitch?: boolean;\n};\n\nconst Checkbox: FC<CheckboxProps> = ({\n children,\n isChecked,\n isDisabled,\n onChange,\n shouldShowAsSwitch,\n}) => {\n const [isActive, setIsActive] = useState(isChecked ?? false);\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setIsActive(event.target.checked);\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [onChange]\n );\n\n const uuid = useUuid();\n\n return (\n <StyledCheckbox>\n <StyledCheckboxInput\n checked={isChecked}\n disabled={isDisabled}\n id={uuid}\n onChange={handleChange}\n type=\"checkbox\"\n />\n <StyledCheckboxLabel\n htmlFor={uuid}\n isChecked={isChecked ?? isActive}\n isDisabled={isDisabled}\n shouldShowAsSwitch={shouldShowAsSwitch}\n >\n {children}\n </StyledCheckboxLabel>\n </StyledCheckbox>\n );\n};\n\nCheckbox.displayName = 'Checkbox';\n\nexport default Checkbox;\n"],"mappings":";;;;;;AAAA;AAQA;AACA;AAA6F;AAAA;AAyB7F,MAAMA,QAA2B,GAAG,QAM9B;EAAA,IAN+B;IACjCC,QAAQ;IACRC,SAAS;IACTC,UAAU;IACVC,QAAQ;IACRC;EACJ,CAAC;EACG,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAG,IAAAC,eAAQ,EAACN,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,KAAK,CAAC;EAE5D,MAAMO,YAAY,GAAG,IAAAC,kBAAW,EAC3BC,KAAoC,IAAK;IACtCJ,WAAW,CAACI,KAAK,CAACC,MAAM,CAACC,OAAO,CAAC;IAEjC,IAAI,OAAOT,QAAQ,KAAK,UAAU,EAAE;MAChCA,QAAQ,CAACO,KAAK,CAAC;IACnB;EACJ,CAAC,EACD,CAACP,QAAQ,CAAC,CACb;EAED,MAAMU,IAAI,GAAG,IAAAC,aAAO,GAAE;EAEtB,oBACI,6BAAC,wBAAc,qBACX,6BAAC,6BAAmB;IAChB,OAAO,EAAEb,SAAU;IACnB,QAAQ,EAAEC,UAAW;IACrB,EAAE,EAAEW,IAAK;IACT,QAAQ,EAAEL,YAAa;IACvB,IAAI,EAAC;EAAU,EACjB,eACF,6BAAC,6BAAmB;IAChB,OAAO,EAAEK,IAAK;IACd,SAAS,EAAEZ,SAAS,aAATA,SAAS,cAATA,SAAS,GAAII,QAAS;IACjC,UAAU,EAAEH,UAAW;IACvB,kBAAkB,EAAEE;EAAmB,GAEtCJ,QAAQ,CACS,CACT;AAEzB,CAAC;AAEDD,QAAQ,CAACgB,WAAW,GAAG,UAAU;AAAC,eAEnBhB,QAAQ;AAAA"}
@@ -4,84 +4,122 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.StyledCheckboxLabel = exports.StyledCheckboxInput = exports.StyledCheckbox = void 0;
7
-
8
7
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
-
10
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
11
-
12
8
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
-
14
9
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
-
16
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
17
-
18
- const StyledCheckbox = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n align-items: center;\n display: flex;\n position: relative;\n"])));
19
-
10
+ const StyledCheckbox = _styledComponents.default.div`
11
+ align-items: center;
12
+ display: flex;
13
+ position: relative;
14
+ `;
20
15
  exports.StyledCheckbox = StyledCheckbox;
21
-
22
- const StyledCheckboxInput = _styledComponents.default.input(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: none;\n"])));
23
-
16
+ const StyledCheckboxInput = _styledComponents.default.input`
17
+ display: none;
18
+ `;
24
19
  exports.StyledCheckboxInput = StyledCheckboxInput;
25
-
26
- const StyledCheckboxLabel = _styledComponents.default.label(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n cursor: ", ";\n opacity: ", ";\n padding-left: ", ";\n transition: opacity 0.2s ease;\n user-select: none;\n\n &:after {\n ", "\n\n content: ' ';\n position: absolute;\n top: 50%;\n transform-origin: 100% 100%;\n }\n\n &:before {\n background-color: ", ";\n border: 1px solid rgba(", ", 0.5);\n border-radius: ", ";\n content: ' ';\n height: ", ";\n left: ", ";\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n transition: background-color 0.2s ease;\n width: ", ";\n }\n"])), _ref => {
20
+ const StyledCheckboxLabel = _styledComponents.default.label`
21
+ cursor: ${_ref => {
27
22
  let {
28
23
  isDisabled
29
24
  } = _ref;
30
25
  return isDisabled ? 'default' : 'pointer';
31
- }, _ref2 => {
26
+ }};
27
+ opacity: ${_ref2 => {
32
28
  let {
33
29
  isDisabled
34
30
  } = _ref2;
35
31
  return isDisabled ? 0.5 : 1;
36
- }, _ref3 => {
32
+ }};
33
+ padding-left: ${_ref3 => {
37
34
  let {
38
35
  shouldShowAsSwitch
39
36
  } = _ref3;
40
37
  return shouldShowAsSwitch ? '48px' : '20px';
41
- }, _ref4 => {
38
+ }};
39
+ transition: opacity 0.2s ease;
40
+ user-select: none;
41
+
42
+ &:after {
43
+ ${_ref4 => {
42
44
  let {
43
45
  isChecked,
44
46
  shouldShowAsSwitch
45
47
  } = _ref4;
46
- return shouldShowAsSwitch ? (0, _styledComponents.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background-color: white;\n border-radius: 50%;\n box-shadow: 0 1px 4px rgb(0 0 0 / 35%);\n height: 16px;\n left: 7px;\n transform: translateY(-50%) translateX(", ");\n transition: transform 0.2s ease;\n width: 16px;\n "])), isChecked ? '18px' : 0) : (0, _styledComponents.css)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n border-right: 2px solid #fff;\n border-bottom: 2px solid #fff;\n height: 10px;\n left: 1px;\n opacity: ", ";\n transform: translateY(-50%) rotateZ(37deg);\n transition: opacity 0.2s ease;\n width: 5.5px;\n "])), isChecked ? 1 : 0);
47
- }, _ref5 => {
48
+ return shouldShowAsSwitch ? (0, _styledComponents.css)`
49
+ background-color: white;
50
+ border-radius: 50%;
51
+ box-shadow: 0 1px 4px rgb(0 0 0 / 35%);
52
+ height: 16px;
53
+ left: 7px;
54
+ transform: translateY(-50%) translateX(${isChecked ? '18px' : 0});
55
+ transition: transform 0.2s ease;
56
+ width: 16px;
57
+ ` : (0, _styledComponents.css)`
58
+ border-right: 2px solid #fff;
59
+ border-bottom: 2px solid #fff;
60
+ height: 10px;
61
+ left: 1px;
62
+ opacity: ${isChecked ? 1 : 0};
63
+ transform: translateY(-50%) rotateZ(37deg);
64
+ transition: opacity 0.2s ease;
65
+ width: 5.5px;
66
+ `;
67
+ }}
68
+
69
+ content: ' ';
70
+ position: absolute;
71
+ top: 50%;
72
+ transform-origin: 100% 100%;
73
+ }
74
+
75
+ &:before {
76
+ background-color: ${_ref5 => {
48
77
  let {
49
78
  isChecked,
50
79
  shouldShowAsSwitch,
51
80
  theme
52
81
  } = _ref5;
53
-
54
82
  if (shouldShowAsSwitch) {
55
83
  return isChecked ? theme.green : theme.red;
56
84
  }
57
-
58
85
  return isChecked ? theme['408'] : theme['403'];
59
- }, _ref6 => {
86
+ }};
87
+ border: 1px solid rgba(${_ref6 => {
60
88
  let {
61
89
  theme
62
90
  } = _ref6;
63
91
  return theme['409-rgb'];
64
- }, _ref7 => {
92
+ }}, 0.5);
93
+ border-radius: ${_ref7 => {
65
94
  let {
66
95
  shouldShowAsSwitch
67
96
  } = _ref7;
68
97
  return shouldShowAsSwitch ? '100px' : 0;
69
- }, _ref8 => {
98
+ }};
99
+ content: ' ';
100
+ height: ${_ref8 => {
70
101
  let {
71
102
  shouldShowAsSwitch
72
103
  } = _ref8;
73
104
  return shouldShowAsSwitch ? '13px' : '15px';
74
- }, _ref9 => {
105
+ }};
106
+ left: ${_ref9 => {
75
107
  let {
76
108
  shouldShowAsSwitch
77
109
  } = _ref9;
78
110
  return shouldShowAsSwitch ? '10px' : 0;
79
- }, _ref10 => {
111
+ }};
112
+ position: absolute;
113
+ top: 50%;
114
+ transform: translateY(-50%);
115
+ transition: background-color 0.2s ease;
116
+ width: ${_ref10 => {
80
117
  let {
81
118
  shouldShowAsSwitch
82
119
  } = _ref10;
83
120
  return shouldShowAsSwitch ? '28px' : '15px';
84
- });
85
-
121
+ }};
122
+ }
123
+ `;
86
124
  exports.StyledCheckboxLabel = StyledCheckboxLabel;
87
125
  //# sourceMappingURL=Checkbox.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.styles.js","names":["StyledCheckbox","styled","div","StyledCheckboxInput","input","StyledCheckboxLabel","label","isDisabled","shouldShowAsSwitch","isChecked","css","theme","green","red"],"sources":["../../../src/components/checkbox/Checkbox.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { CheckboxProps } from './Checkbox';\n\nexport const StyledCheckbox = styled.div`\n align-items: center;\n display: flex;\n position: relative;\n`;\n\nexport const StyledCheckboxInput = styled.input`\n display: none;\n`;\n\ntype StyledCheckboxLabelProps = WithTheme<Omit<CheckboxProps, 'children' | 'onChange'>>;\n\nexport const StyledCheckboxLabel = styled.label<StyledCheckboxLabelProps>`\n cursor: ${({ isDisabled }) => (isDisabled ? 'default' : 'pointer')};\n opacity: ${({ isDisabled }) => (isDisabled ? 0.5 : 1)};\n padding-left: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '48px' : '20px')};\n transition: opacity 0.2s ease;\n user-select: none;\n\n &:after {\n ${({ isChecked, shouldShowAsSwitch }) =>\n shouldShowAsSwitch\n ? css`\n background-color: white;\n border-radius: 50%;\n box-shadow: 0 1px 4px rgb(0 0 0 / 35%);\n height: 16px;\n left: 7px;\n transform: translateY(-50%) translateX(${isChecked ? '18px' : 0});\n transition: transform 0.2s ease;\n width: 16px;\n `\n : css`\n border-right: 2px solid #fff;\n border-bottom: 2px solid #fff;\n height: 10px;\n left: 1px;\n opacity: ${isChecked ? 1 : 0};\n transform: translateY(-50%) rotateZ(37deg);\n transition: opacity 0.2s ease;\n width: 5.5px;\n `}\n\n content: ' ';\n position: absolute;\n top: 50%;\n transform-origin: 100% 100%;\n }\n\n &:before {\n background-color: ${({\n isChecked,\n shouldShowAsSwitch,\n theme,\n }: StyledCheckboxLabelProps) => {\n if (shouldShowAsSwitch) {\n return isChecked ? theme.green : theme.red;\n }\n\n return isChecked ? theme['408'] : theme['403'];\n }};\n border: 1px solid rgba(${({ theme }: StyledCheckboxLabelProps) => theme['409-rgb']}, 0.5);\n border-radius: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '100px' : 0)};\n content: ' ';\n height: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '13px' : '15px')};\n left: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '10px' : 0)};\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n transition: background-color 0.2s ease;\n width: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '28px' : '15px')};\n }\n`;\n"],"mappings":";;;;;;;AAAA;;;;;;;;;;AAIO,MAAMA,cAAc,GAAGC,yBAAA,CAAOC,GAAV,8IAApB;;;;AAMA,MAAMC,mBAAmB,GAAGF,yBAAA,CAAOG,KAAV,6FAAzB;;;;AAMA,MAAMC,mBAAmB,GAAGJ,yBAAA,CAAOK,KAAV,+rBAClB;EAAA,IAAC;IAAEC;EAAF,CAAD;EAAA,OAAqBA,UAAU,GAAG,SAAH,GAAe,SAA9C;AAAA,CADkB,EAEjB;EAAA,IAAC;IAAEA;EAAF,CAAD;EAAA,OAAqBA,UAAU,GAAG,GAAH,GAAS,CAAxC;AAAA,CAFiB,EAGZ;EAAA,IAAC;IAAEC;EAAF,CAAD;EAAA,OAA6BA,kBAAkB,GAAG,MAAH,GAAY,MAA3D;AAAA,CAHY,EAQtB;EAAA,IAAC;IAAEC,SAAF;IAAaD;EAAb,CAAD;EAAA,OACEA,kBAAkB,OACZE,qBADY,+dAOiCD,SAAS,GAAG,MAAH,GAAY,CAPtD,QAWZC,qBAXY,mdAgBGD,SAAS,GAAG,CAAH,GAAO,CAhBnB,CADpB;AAAA,CARsB,EAsCJ,SAIY;EAAA,IAJX;IACjBA,SADiB;IAEjBD,kBAFiB;IAGjBG;EAHiB,CAIW;;EAC5B,IAAIH,kBAAJ,EAAwB;IACpB,OAAOC,SAAS,GAAGE,KAAK,CAACC,KAAT,GAAiBD,KAAK,CAACE,GAAvC;EACH;;EAED,OAAOJ,SAAS,GAAGE,KAAK,CAAC,KAAD,CAAR,GAAkBA,KAAK,CAAC,KAAD,CAAvC;AACH,CAhDuB,EAiDC;EAAA,IAAC;IAAEA;EAAF,CAAD;EAAA,OAAyCA,KAAK,CAAC,SAAD,CAA9C;AAAA,CAjDD,EAkDP;EAAA,IAAC;IAAEH;EAAF,CAAD;EAAA,OAA6BA,kBAAkB,GAAG,OAAH,GAAa,CAA5D;AAAA,CAlDO,EAoDd;EAAA,IAAC;IAAEA;EAAF,CAAD;EAAA,OAA6BA,kBAAkB,GAAG,MAAH,GAAY,MAA3D;AAAA,CApDc,EAqDhB;EAAA,IAAC;IAAEA;EAAF,CAAD;EAAA,OAA6BA,kBAAkB,GAAG,MAAH,GAAY,CAA3D;AAAA,CArDgB,EA0Df;EAAA,IAAC;IAAEA;EAAF,CAAD;EAAA,OAA6BA,kBAAkB,GAAG,MAAH,GAAY,MAA3D;AAAA,CA1De,CAAzB"}
1
+ {"version":3,"file":"Checkbox.styles.js","names":["StyledCheckbox","styled","div","StyledCheckboxInput","input","StyledCheckboxLabel","label","isDisabled","shouldShowAsSwitch","isChecked","css","theme","green","red"],"sources":["../../../src/components/checkbox/Checkbox.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { CheckboxProps } from './Checkbox';\n\nexport const StyledCheckbox = styled.div`\n align-items: center;\n display: flex;\n position: relative;\n`;\n\nexport const StyledCheckboxInput = styled.input`\n display: none;\n`;\n\ntype StyledCheckboxLabelProps = WithTheme<Omit<CheckboxProps, 'children' | 'onChange'>>;\n\nexport const StyledCheckboxLabel = styled.label<StyledCheckboxLabelProps>`\n cursor: ${({ isDisabled }) => (isDisabled ? 'default' : 'pointer')};\n opacity: ${({ isDisabled }) => (isDisabled ? 0.5 : 1)};\n padding-left: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '48px' : '20px')};\n transition: opacity 0.2s ease;\n user-select: none;\n\n &:after {\n ${({ isChecked, shouldShowAsSwitch }) =>\n shouldShowAsSwitch\n ? css`\n background-color: white;\n border-radius: 50%;\n box-shadow: 0 1px 4px rgb(0 0 0 / 35%);\n height: 16px;\n left: 7px;\n transform: translateY(-50%) translateX(${isChecked ? '18px' : 0});\n transition: transform 0.2s ease;\n width: 16px;\n `\n : css`\n border-right: 2px solid #fff;\n border-bottom: 2px solid #fff;\n height: 10px;\n left: 1px;\n opacity: ${isChecked ? 1 : 0};\n transform: translateY(-50%) rotateZ(37deg);\n transition: opacity 0.2s ease;\n width: 5.5px;\n `}\n\n content: ' ';\n position: absolute;\n top: 50%;\n transform-origin: 100% 100%;\n }\n\n &:before {\n background-color: ${({\n isChecked,\n shouldShowAsSwitch,\n theme,\n }: StyledCheckboxLabelProps) => {\n if (shouldShowAsSwitch) {\n return isChecked ? theme.green : theme.red;\n }\n\n return isChecked ? theme['408'] : theme['403'];\n }};\n border: 1px solid rgba(${({ theme }: StyledCheckboxLabelProps) => theme['409-rgb']}, 0.5);\n border-radius: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '100px' : 0)};\n content: ' ';\n height: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '13px' : '15px')};\n left: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '10px' : 0)};\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n transition: background-color 0.2s ease;\n width: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '28px' : '15px')};\n }\n`;\n"],"mappings":";;;;;;AAAA;AAAgD;AAAA;AAIzC,MAAMA,cAAc,GAAGC,yBAAM,CAACC,GAAI;AACzC;AACA;AACA;AACA,CAAC;AAAC;AAEK,MAAMC,mBAAmB,GAAGF,yBAAM,CAACG,KAAM;AAChD;AACA,CAAC;AAAC;AAIK,MAAMC,mBAAmB,GAAGJ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EAAmB,CAAC;EAAA,OAAMA,kBAAkB,GAAG,MAAM,GAAG,MAAM;AAAA,CAAE;AACrF,gBAAgB;EAAA,IAAC;IAAEA;EAAmB,CAAC;EAAA,OAAMA,kBAAkB,GAAG,MAAM,GAAG,CAAC;AAAA,CAAE;AAC9E;AACA;AACA;AACA;AACA,iBAAiB;EAAA,IAAC;IAAEA;EAAmB,CAAC;EAAA,OAAMA,kBAAkB,GAAG,MAAM,GAAG,MAAM;AAAA,CAAE;AACpF;AACA,CAAC;AAAC"}
@@ -4,31 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _colors = require("@chayns/colors");
9
-
10
8
  var _react = _interopRequireWildcard(require("react"));
11
-
12
9
  var _styledComponents = require("styled-components");
13
-
14
- var _templateObject;
15
-
16
10
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
11
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
21
-
22
12
  var ColorMode;
23
-
24
13
  (function (ColorMode) {
25
14
  ColorMode[ColorMode["Classic"] = 0] = "Classic";
26
15
  ColorMode[ColorMode["Dark"] = 1] = "Dark";
27
16
  ColorMode[ColorMode["Light"] = 2] = "Light";
28
17
  })(ColorMode || (ColorMode = {}));
29
-
30
- const GlobalStyle = (0, _styledComponents.createGlobalStyle)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ellipsis {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n"])));
31
-
18
+ const GlobalStyle = (0, _styledComponents.createGlobalStyle)`
19
+ .ellipsis {
20
+ overflow: hidden;
21
+ text-overflow: ellipsis;
22
+ white-space: nowrap;
23
+ }
24
+ `;
32
25
  const ColorSchemeProvider = _ref => {
33
26
  let {
34
27
  children,
@@ -50,15 +43,13 @@ const ColorSchemeProvider = _ref => {
50
43
  colorMode,
51
44
  secondaryColor
52
45
  });
53
-
54
46
  if (hexColor) {
55
47
  const rgbColor = (0, _colors.hexToRgb255)(hexColor);
56
- newColors["--chayns-color--".concat(colorName)] = hexColor;
48
+ newColors[`--chayns-color--${colorName}`] = hexColor;
57
49
  newThemeColors[colorName] = hexColor;
58
-
59
50
  if (rgbColor) {
60
- newColors["--chayns-color-rgb--".concat(colorName)] = "".concat(rgbColor.r, ", ").concat(rgbColor.g, ", ").concat(rgbColor.b);
61
- newThemeColors["".concat(colorName, "-rgb")] = "".concat(rgbColor.r, ", ").concat(rgbColor.g, ", ").concat(rgbColor.b);
51
+ newColors[`--chayns-color-rgb--${colorName}`] = `${rgbColor.r}, ${rgbColor.g}, ${rgbColor.b}`;
52
+ newThemeColors[`${colorName}-rgb`] = `${rgbColor.r}, ${rgbColor.g}, ${rgbColor.b}`;
62
53
  }
63
54
  }
64
55
  });
@@ -68,13 +59,13 @@ const ColorSchemeProvider = _ref => {
68
59
  return /*#__PURE__*/_react.default.createElement(_styledComponents.ThemeProvider, {
69
60
  theme: themeColors
70
61
  }, /*#__PURE__*/_react.default.createElement("div", {
71
- style: { ...colors,
62
+ style: {
63
+ ...colors,
72
64
  ...cssVariables,
73
65
  ...style
74
66
  }
75
67
  }, children), /*#__PURE__*/_react.default.createElement(GlobalStyle, null));
76
68
  };
77
-
78
69
  ColorSchemeProvider.displayName = 'ColorSchemeProvider';
79
70
  var _default = ColorSchemeProvider;
80
71
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"file":"ColorSchemeProvider.js","names":["ColorMode","GlobalStyle","createGlobalStyle","ColorSchemeProvider","children","color","colorMode","Classic","cssVariables","secondaryColor","style","colors","setColors","useState","themeColors","setThemeColors","useEffect","availableColors","getAvailableColorList","newColors","newThemeColors","forEach","colorName","hexColor","getColorFromPalette","rgbColor","hexToRgb255","r","g","b","displayName"],"sources":["../../../src/components/color-scheme-provider/ColorSchemeProvider.tsx"],"sourcesContent":["import { getAvailableColorList, getColorFromPalette, hexToRgb255 } from '@chayns/colors';\nimport React, { FC, ReactNode, useEffect, useState } from 'react';\nimport { createGlobalStyle, ThemeProvider } from 'styled-components';\n\nenum ColorMode {\n Classic,\n Dark,\n Light,\n}\n\ntype ColorSchemeProviderProps = {\n /**\n * The content of the application or the components for which the styles should be set\n */\n children: ReactNode;\n /**\n * The hex color to be used for the children\n */\n color?: string;\n /**\n * The color mode to be used for the children\n */\n colorMode?: ColorMode;\n /**\n * Css variables to be added in addition to the chayns variables\n */\n cssVariables?: { [key: string]: string | number };\n /**\n * The secondary hex color to be used for the children\n */\n secondaryColor?: string;\n /**\n * Additional styles set on the root element\n */\n style?: { [key: string]: string | number };\n};\n\nexport interface Theme {\n [key: string]: string;\n}\n\nexport type WithTheme<T> = T & {\n theme: Theme;\n};\n\nconst GlobalStyle = createGlobalStyle`\n .ellipsis {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n`;\n\nconst ColorSchemeProvider: FC<ColorSchemeProviderProps> = ({\n children,\n color = '#005EB8',\n colorMode = ColorMode.Classic,\n cssVariables = {},\n secondaryColor,\n style = {},\n}) => {\n const [colors, setColors] = useState<Theme>({});\n const [themeColors, setThemeColors] = useState<Theme>({});\n\n useEffect(() => {\n const availableColors = getAvailableColorList();\n\n const newColors: Theme = {};\n const newThemeColors: Theme = {};\n\n availableColors.forEach((colorName: string) => {\n const hexColor = getColorFromPalette(colorName, {\n color,\n colorMode,\n secondaryColor,\n });\n\n if (hexColor) {\n const rgbColor = hexToRgb255(hexColor);\n\n newColors[`--chayns-color--${colorName}`] = hexColor;\n newThemeColors[colorName] = hexColor;\n\n if (rgbColor) {\n newColors[\n `--chayns-color-rgb--${colorName}`\n ] = `${rgbColor.r}, ${rgbColor.g}, ${rgbColor.b}`;\n newThemeColors[\n `${colorName}-rgb`\n ] = `${rgbColor.r}, ${rgbColor.g}, ${rgbColor.b}`;\n }\n }\n });\n\n setColors(newColors);\n setThemeColors(newThemeColors);\n }, [color, colorMode, secondaryColor]);\n\n return (\n <ThemeProvider theme={themeColors}>\n <div style={{ ...colors, ...cssVariables, ...style }}>{children}</div>\n <GlobalStyle />\n </ThemeProvider>\n );\n};\n\nColorSchemeProvider.displayName = 'ColorSchemeProvider';\n\nexport default ColorSchemeProvider;\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;IAEKA,S;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,KAAAA,S;;AAyCL,MAAMC,WAAW,OAAGC,mCAAH,qLAAjB;;AAQA,MAAMC,mBAAiD,GAAG,QAOpD;EAAA,IAPqD;IACvDC,QADuD;IAEvDC,KAAK,GAAG,SAF+C;IAGvDC,SAAS,GAAGN,SAAS,CAACO,OAHiC;IAIvDC,YAAY,GAAG,EAJwC;IAKvDC,cALuD;IAMvDC,KAAK,GAAG;EAN+C,CAOrD;EACF,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsB,IAAAC,eAAA,EAAgB,EAAhB,CAA5B;EACA,MAAM,C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AApB,GAAkC,qBAAlC;eAEe3B,mB"}
1
+ {"version":3,"file":"ColorSchemeProvider.js","names":["ColorMode","GlobalStyle","createGlobalStyle","ColorSchemeProvider","children","color","colorMode","Classic","cssVariables","secondaryColor","style","colors","setColors","useState","themeColors","setThemeColors","useEffect","availableColors","getAvailableColorList","newColors","newThemeColors","forEach","colorName","hexColor","getColorFromPalette","rgbColor","hexToRgb255","r","g","b","displayName"],"sources":["../../../src/components/color-scheme-provider/ColorSchemeProvider.tsx"],"sourcesContent":["import { getAvailableColorList, getColorFromPalette, hexToRgb255 } from '@chayns/colors';\nimport React, { FC, ReactNode, useEffect, useState } from 'react';\nimport { createGlobalStyle, ThemeProvider } from 'styled-components';\n\nenum ColorMode {\n Classic,\n Dark,\n Light,\n}\n\ntype ColorSchemeProviderProps = {\n /**\n * The content of the application or the components for which the styles should be set\n */\n children: ReactNode;\n /**\n * The hex color to be used for the children\n */\n color?: string;\n /**\n * The color mode to be used for the children\n */\n colorMode?: ColorMode;\n /**\n * Css variables to be added in addition to the chayns variables\n */\n cssVariables?: { [key: string]: string | number };\n /**\n * The secondary hex color to be used for the children\n */\n secondaryColor?: string;\n /**\n * Additional styles set on the root element\n */\n style?: { [key: string]: string | number };\n};\n\nexport interface Theme {\n [key: string]: string;\n}\n\nexport type WithTheme<T> = T & {\n theme: Theme;\n};\n\nconst GlobalStyle = createGlobalStyle`\n .ellipsis {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n`;\n\nconst ColorSchemeProvider: FC<ColorSchemeProviderProps> = ({\n children,\n color = '#005EB8',\n colorMode = ColorMode.Classic,\n cssVariables = {},\n secondaryColor,\n style = {},\n}) => {\n const [colors, setColors] = useState<Theme>({});\n const [themeColors, setThemeColors] = useState<Theme>({});\n\n useEffect(() => {\n const availableColors = getAvailableColorList();\n\n const newColors: Theme = {};\n const newThemeColors: Theme = {};\n\n availableColors.forEach((colorName: string) => {\n const hexColor = getColorFromPalette(colorName, {\n color,\n colorMode,\n secondaryColor,\n });\n\n if (hexColor) {\n const rgbColor = hexToRgb255(hexColor);\n\n newColors[`--chayns-color--${colorName}`] = hexColor;\n newThemeColors[colorName] = hexColor;\n\n if (rgbColor) {\n newColors[\n `--chayns-color-rgb--${colorName}`\n ] = `${rgbColor.r}, ${rgbColor.g}, ${rgbColor.b}`;\n newThemeColors[\n `${colorName}-rgb`\n ] = `${rgbColor.r}, ${rgbColor.g}, ${rgbColor.b}`;\n }\n }\n });\n\n setColors(newColors);\n setThemeColors(newThemeColors);\n }, [color, colorMode, secondaryColor]);\n\n return (\n <ThemeProvider theme={themeColors}>\n <div style={{ ...colors, ...cssVariables, ...style }}>{children}</div>\n <GlobalStyle />\n </ThemeProvider>\n );\n};\n\nColorSchemeProvider.displayName = 'ColorSchemeProvider';\n\nexport default ColorSchemeProvider;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAAqE;AAAA;AAAA,IAEhEA,SAAS;AAAA,WAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;AAAA,GAATA,SAAS,KAATA,SAAS;AAyCd,MAAMC,WAAW,GAAG,IAAAC,mCAAiB,CAAC;AACtC;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,mBAAiD,GAAG,QAOpD;EAAA,IAPqD;IACvDC,QAAQ;IACRC,KAAK,GAAG,SAAS;IACjBC,SAAS,GAAGN,SAAS,CAACO,OAAO;IAC7BC,YAAY,GAAG,CAAC,CAAC;IACjBC,cAAc;IACdC,KAAK,GAAG,CAAC;EACb,CAAC;EACG,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAAQ,CAAC,CAAC,CAAC;EAC/C,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAG,IAAAF,eAAQ,EAAQ,CAAC,CAAC,CAAC;EAEzD,IAAAG,gBAAS,EAAC,MAAM;IACZ,MAAMC,eAAe,GAAG,IAAAC,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ule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _framerMotion = require("framer-motion");
9
-
10
8
  var _react = _interopRequireWildcard(require("react"));
11
-
12
9
  var _reactDom = require("react-dom");
13
-
14
10
  var _uuid = require("../../hooks/uuid");
15
-
16
11
  var _Icon = _interopRequireDefault(require("../icon/Icon"));
17
-
18
12
  var _alignment = require("./constants/alignment");
19
-
20
13
  var _ContextMenuContent = _interopRequireDefault(require("./context-menu-content/ContextMenuContent"));
21
-
22
14
  var _ContextMenu = require("./ContextMenu.styles");
23
-
24
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
-
28
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
-
30
18
  const ContextMenu = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
31
19
  let {
32
20
  alignment,
@@ -45,8 +33,9 @@ const ContextMenu = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
45
33
  });
46
34
  const [internalAlignment, setInternalAlignment] = (0, _react.useState)(_alignment.ContextMenuAlignment.TopLeft);
47
35
  const [isContentShown, setIsContentShown] = (0, _react.useState)(false);
48
- const uuid = (0, _uuid.useUuid)(); // ToDo: Replace with hook if new chayns api is ready
36
+ const uuid = (0, _uuid.useUuid)();
49
37
 
38
+ // ToDo: Replace with hook if new chayns api is ready
50
39
  const contextMenuContentRef = (0, _react.useRef)(null);
51
40
  const contextMenuRef = (0, _react.useRef)(null);
52
41
  const handleHide = (0, _react.useCallback)(() => {
@@ -57,10 +46,8 @@ const ContextMenu = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
57
46
  isMobile,
58
47
  isTablet
59
48
  } = chayns.env;
60
-
61
49
  if (isMobile || isTablet) {
62
50
  var _selection$;
63
-
64
51
  // ToDo: Replace with new api function if new api is ready
65
52
  const {
66
53
  buttonType,
@@ -80,10 +67,8 @@ const ContextMenu = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
80
67
  }),
81
68
  type: 2
82
69
  });
83
-
84
70
  if (buttonType === 1 && typeof ((_selection$ = selection[0]) === null || _selection$ === void 0 ? void 0 : _selection$.value) === 'number') {
85
71
  var _items$selection$0$va;
86
-
87
72
  (_items$selection$0$va = items[selection[0].value]) === null || _items$selection$0$va === void 0 ? void 0 : _items$selection$0$va.onClick();
88
73
  }
89
74
  } else if (contextMenuRef.current) {
@@ -102,7 +87,6 @@ const ContextMenu = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
102
87
  height,
103
88
  width
104
89
  } = rootElement.getBoundingClientRect();
105
-
106
90
  if (x < width / 2) {
107
91
  if (y < height / 2) {
108
92
  setInternalAlignment(_alignment.ContextMenuAlignment.BottomRight);
@@ -114,7 +98,6 @@ const ContextMenu = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
114
98
  } else {
115
99
  setInternalAlignment(_alignment.ContextMenuAlignment.TopLeft);
116
100
  }
117
-
118
101
  setIsContentShown(true);
119
102
  }
120
103
  }, [items]);
@@ -125,12 +108,10 @@ const ContextMenu = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
125
108
  }, [handleShow]);
126
109
  const handleDocumentClick = (0, _react.useCallback)(event => {
127
110
  var _contextMenuContentRe;
128
-
129
111
  if (!((_contextMenuContentRe = contextMenuContentRef.current) !== null && _contextMenuContentRe !== void 0 && _contextMenuContentRe.contains(event.target))) {
130
112
  event.preventDefault();
131
113
  event.stopPropagation();
132
114
  }
133
-
134
115
  handleHide();
135
116
  }, [handleHide]);
136
117
  (0, _react.useImperativeHandle)(ref, () => ({
@@ -141,14 +122,12 @@ const ContextMenu = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
141
122
  if (isContentShown) {
142
123
  document.addEventListener('click', handleDocumentClick, true);
143
124
  window.addEventListener('blur', handleHide);
144
-
145
125
  if (typeof onShow === 'function') {
146
126
  onShow();
147
127
  }
148
128
  } else if (typeof onHide === 'function') {
149
129
  onHide();
150
130
  }
151
-
152
131
  return () => {
153
132
  document.removeEventListener('click', handleDocumentClick, true);
154
133
  window.removeEventListener('blur', handleHide);
@@ -159,7 +138,7 @@ const ContextMenu = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
159
138
  }, isContentShown && /*#__PURE__*/_react.default.createElement(_ContextMenuContent.default, {
160
139
  coordinates: coordinates !== null && coordinates !== void 0 ? coordinates : internalCoordinates,
161
140
  items: items,
162
- key: "contextMenu_".concat(uuid),
141
+ key: `contextMenu_${uuid}`,
163
142
  alignment: alignment !== null && alignment !== void 0 ? alignment : internalAlignment,
164
143
  ref: contextMenuContentRef
165
144
  })), container), [container, coordinates, internalCoordinates, internalAlignment, isContentShown, items, alignment, uuid]);
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenu.js","names":["ContextMenu","forwardRef","ref","alignment","children","container","document","body","coordinates","items","onHide","onShow","internalCoordinates","setInternalCoordinates","useState","x","y","internalAlignment","setInternalAlignment","ContextMenuAlignment","TopLeft","isContentShown","setIsContentShown","uuid","useUuid","contextMenuContentRef","useRef","contextMenuRef","handleHide","useCallback","handleShow","isMobile","isTablet","chayns","env","buttonType","selection","dialog","select","buttons","list","map","index","icons","text","name","value","icon","type","onClick","current","rootElement","querySelector","height","childrenHeight","width","childrenWidth","getBoundingClientRect","BottomRight","TopRight","BottomLeft","handleClick","event","preventDefault","stopPropagation","handleDocumentClick","contains","target","useImperativeHandle","hide","show","useEffect","addEventListener","window","removeEventListener","portal","useMemo","createPortal","displayName"],"sources":["../../../src/components/context-menu/ContextMenu.tsx"],"sourcesContent":["import { AnimatePresence } from 'framer-motion';\nimport React, {\n forwardRef,\n MouseEvent,\n MouseEventHandler,\n ReactNode,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport Icon from '../icon/Icon';\nimport { ContextMenuAlignment } from './constants/alignment';\nimport ContextMenuContent from './context-menu-content/ContextMenuContent';\nimport { StyledContextMenu } from './ContextMenu.styles';\n\nexport type ContextMenuCoordinates = {\n x: number;\n y: number;\n};\n\nexport type ContextMenuItem = {\n icons: string[];\n key: string;\n onClick: (event?: MouseEvent<HTMLDivElement>) => void;\n text: string;\n};\n\ntype ContextMenuRef = {\n hide: VoidFunction;\n show: VoidFunction;\n};\n\ntype ContextMenuProps = {\n /**\n * Optional custom alignment used instead of calculating it using the\n * alignment within the page. The available alignment can be taken from the\n * ContextMenuAlignment enum.\n */\n alignment?: ContextMenuAlignment;\n /**\n * The element over which the content of the `ContextMenu` should be displayed.\n */\n children?: ReactNode;\n /**\n * The element where the content of the `ContextMenu` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * Optional own coordinates to be used instead of calculating the alignment\n * based on the alignment of the children.\n */\n coordinates?: ContextMenuCoordinates;\n /**\n * The items that will be displayed in the content of the `ContextMenu`.\n */\n items: ContextMenuItem[];\n /**\n * Function to be executed when the content of the Context menu has been hidden.\n */\n onHide?: VoidFunction;\n /**\n * Function to be executed when the content of the Context menu has been shown.\n */\n onShow?: VoidFunction;\n};\n\nconst ContextMenu = forwardRef<ContextMenuRef, ContextMenuProps>(\n (\n {\n alignment,\n children = <Icon icons={['ts-ellipsis_v']} />,\n container = document.body,\n coordinates,\n items,\n onHide,\n onShow,\n },\n ref\n ) => {\n const [internalCoordinates, setInternalCoordinates] = useState<ContextMenuCoordinates>({\n x: 0,\n y: 0,\n });\n const [internalAlignment, setInternalAlignment] = useState<ContextMenuAlignment>(\n ContextMenuAlignment.TopLeft\n );\n const [isContentShown, setIsContentShown] = useState(false);\n\n const uuid = useUuid();\n\n // ToDo: Replace with hook if new chayns api is ready\n const contextMenuContentRef = useRef<HTMLDivElement>(null);\n const contextMenuRef = useRef<HTMLSpanElement>(null);\n\n const handleHide = useCallback(() => {\n setIsContentShown(false);\n }, []);\n\n const handleShow = useCallback(async () => {\n const { isMobile, isTablet } = chayns.env;\n\n if (isMobile || isTablet) {\n // ToDo: Replace with new api function if new api is ready\n const { buttonType, selection } = await chayns.dialog.select({\n buttons: [],\n list: items.map(({ icons, text }, index) => ({\n name: text,\n value: index,\n icon: icons[0],\n })),\n type: 2,\n });\n\n if (buttonType === 1 && typeof selection[0]?.value === 'number') {\n items[selection[0].value]?.onClick();\n }\n } else if (contextMenuRef.current) {\n const rootElement = document.querySelector('.tapp') || document.body;\n\n const {\n x,\n y,\n height: childrenHeight,\n width: childrenWidth,\n } = contextMenuRef.current.getBoundingClientRect();\n\n setInternalCoordinates({ x: x + childrenWidth / 2, y: y + childrenHeight / 2 });\n\n const { height, width } = rootElement.getBoundingClientRect();\n\n if (x < width / 2) {\n if (y < height / 2) {\n setInternalAlignment(ContextMenuAlignment.BottomRight);\n } else {\n setInternalAlignment(ContextMenuAlignment.TopRight);\n }\n } else if (y < height / 2) {\n setInternalAlignment(ContextMenuAlignment.BottomLeft);\n } else {\n setInternalAlignment(ContextMenuAlignment.TopLeft);\n }\n\n setIsContentShown(true);\n }\n }, [items]);\n\n const handleClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n event.preventDefault();\n event.stopPropagation();\n\n void handleShow();\n },\n [handleShow]\n );\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!contextMenuContentRef.current?.contains(event.target as Node)) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n handleHide();\n },\n [handleHide]\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow]\n );\n\n useEffect(() => {\n if (isContentShown) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n\n if (typeof onShow === 'function') {\n onShow();\n }\n } else if (typeof onHide === 'function') {\n onHide();\n }\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n };\n }, [handleDocumentClick, handleHide, isContentShown, onHide, onShow]);\n\n const portal = useMemo(\n () =>\n createPortal(\n <AnimatePresence initial={false}>\n {isContentShown && (\n <ContextMenuContent\n coordinates={coordinates ?? internalCoordinates}\n items={items}\n key={`contextMenu_${uuid}`}\n alignment={alignment ?? internalAlignment}\n ref={contextMenuContentRef}\n />\n )}\n </AnimatePresence>,\n container\n ),\n [\n container,\n coordinates,\n internalCoordinates,\n internalAlignment,\n isContentShown,\n items,\n alignment,\n uuid,\n ]\n );\n\n return (\n <>\n <StyledContextMenu\n className=\"beta-chayns-context-menu\"\n onClick={handleClick}\n ref={contextMenuRef}\n >\n {children}\n </StyledContextMenu>\n {portal}\n </>\n );\n }\n);\n\nContextMenu.displayName = 'ContextMenu';\n\nexport default ContextMenu;\n"],"mappings":";;;;;;;AAAA;;AACA;;AAYA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAqDA,MAAMA,WAAW,gBAAG,IAAAC,iBAAA,EAChB,OAUIC,GAVJ,KAWK;EAAA,IAVD;IACIC,SADJ;IAEIC,QAAQ,gBAAG,6BAAC,aAAD;MAAM,KAAK,EAAE,CAAC,eAAD;IAAb,EAFf;IAGIC,SAAS,GAAG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AsBrC,UAAtB,EAAkCP,cAAlC,EAAkDX,MAAlD,EAA0DC,MAA1D,CAhBH;EAkBA,MAAMgE,MAAM,GAAG,IAAAC,cAAA,EACX,mBACI,IAAAC,sBAAA,gBACI,6BAAC,6BAAD;IAAiB,OAAO,EAAE;EAA1B,GACKxD,cAAc,iBACX,6BAAC,2BAAD;IACI,WAAW,EAAEb,WAAF,aAAEA,WAAF,cAAEA,WAAF,GAAiBI,mBADhC;IAEI,KAAK,EAAEH,KAFX;IAGI,GAAG,wBAAiBc,IAAjB,CAHP;IAII,SAAS,EAAEpB,SAAF,aAAEA,SAAF,cAAEA,SAAF,GAAec,iBAJ5B;IAKI,GAAG,EAAEQ;EALT,EAFR,CADJ,EAYIpB,SAZJ,CAFO,EAgBX,CACIA,SADJ,EAEIG,WAFJ,EAGII,mBAHJ,EAIIK,iBAJJ,EAKII,cALJ,EAMIZ,KANJ,EAOIN,SAPJ,EAQIoB,IARJ,CAhBW,CAAf;EA4BA,oBACI,yEACI,6BAAC,8BAAD;IACI,SAAS,EAAC,0BADd;IAEI,OAAO,EAAEsC,WAFb;IAGI,GAAG,EAAElC;EAHT,GAKKvB,QALL,CADJ,EAQKuE,MARL,CADJ;AAYH,CAzKe,CAApB;AA4KA3E,WAAW,CAAC8E,WAAZ,GAA0B,aAA1B;eAEe9E,W"}
1
+ {"version":3,"file":"ContextMenu.js","names":["ContextMenu","forwardRef","ref","alignment","children","container","document","body","coordinates","items","onHide","onShow","internalCoordinates","setInternalCoordinates","useState","x","y","internalAlignment","setInternalAlignment","ContextMenuAlignment","TopLeft","isContentShown","setIsContentShown","uuid","useUuid","contextMenuContentRef","useRef","contextMenuRef","handleHide","useCallback","handleShow","isMobile","isTablet","chayns","env","buttonType","selection","dialog","select","buttons","list","map","index","icons","text","name","value","icon","type","onClick","current","rootElement","querySelector","height","childrenHeight","width","childrenWidth","getBoundingClientRect","BottomRight","TopRight","BottomLeft","handleClick","event","preventDefault","stopPropagation","handleDocumentClick","contains","target","useImperativeHandle","hide","show","useEffect","addEventListener","window","removeEventListener","portal","useMemo","createPortal","displayName"],"sources":["../../../src/components/context-menu/ContextMenu.tsx"],"sourcesContent":["import { AnimatePresence } from 'framer-motion';\nimport React, {\n forwardRef,\n MouseEvent,\n MouseEventHandler,\n ReactNode,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport Icon from '../icon/Icon';\nimport { ContextMenuAlignment } from './constants/alignment';\nimport ContextMenuContent from './context-menu-content/ContextMenuContent';\nimport { StyledContextMenu } from './ContextMenu.styles';\n\nexport type ContextMenuCoordinates = {\n x: number;\n y: number;\n};\n\nexport type ContextMenuItem = {\n icons: string[];\n key: string;\n onClick: (event?: MouseEvent<HTMLDivElement>) => void;\n text: string;\n};\n\ntype ContextMenuRef = {\n hide: VoidFunction;\n show: VoidFunction;\n};\n\ntype ContextMenuProps = {\n /**\n * Optional custom alignment used instead of calculating it using the\n * alignment within the page. The available alignment can be taken from the\n * ContextMenuAlignment enum.\n */\n alignment?: ContextMenuAlignment;\n /**\n * The element over which the content of the `ContextMenu` should be displayed.\n */\n children?: ReactNode;\n /**\n * The element where the content of the `ContextMenu` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * Optional own coordinates to be used instead of calculating the alignment\n * based on the alignment of the children.\n */\n coordinates?: ContextMenuCoordinates;\n /**\n * The items that will be displayed in the content of the `ContextMenu`.\n */\n items: ContextMenuItem[];\n /**\n * Function to be executed when the content of the Context menu has been hidden.\n */\n onHide?: VoidFunction;\n /**\n * Function to be executed when the content of the Context menu has been shown.\n */\n onShow?: VoidFunction;\n};\n\nconst ContextMenu = forwardRef<ContextMenuRef, ContextMenuProps>(\n (\n {\n alignment,\n children = <Icon icons={['ts-ellipsis_v']} />,\n container = document.body,\n coordinates,\n items,\n onHide,\n onShow,\n },\n ref\n ) => {\n const [internalCoordinates, setInternalCoordinates] = useState<ContextMenuCoordinates>({\n x: 0,\n y: 0,\n });\n const [internalAlignment, setInternalAlignment] = useState<ContextMenuAlignment>(\n ContextMenuAlignment.TopLeft\n );\n const [isContentShown, setIsContentShown] = useState(false);\n\n const uuid = useUuid();\n\n // ToDo: Replace with hook if new chayns api is ready\n const contextMenuContentRef = useRef<HTMLDivElement>(null);\n const contextMenuRef = useRef<HTMLSpanElement>(null);\n\n const handleHide = useCallback(() => {\n setIsContentShown(false);\n }, []);\n\n const handleShow = useCallback(async () => {\n const { isMobile, isTablet } = chayns.env;\n\n if (isMobile || isTablet) {\n // ToDo: Replace with new api function if new api is ready\n const { buttonType, selection } = await chayns.dialog.select({\n buttons: [],\n list: items.map(({ icons, text }, index) => ({\n name: text,\n value: index,\n icon: icons[0],\n })),\n type: 2,\n });\n\n if (buttonType === 1 && typeof selection[0]?.value === 'number') {\n items[selection[0].value]?.onClick();\n }\n } else if (contextMenuRef.current) {\n const rootElement = document.querySelector('.tapp') || document.body;\n\n const {\n x,\n y,\n height: childrenHeight,\n width: childrenWidth,\n } = contextMenuRef.current.getBoundingClientRect();\n\n setInternalCoordinates({ x: x + childrenWidth / 2, y: y + childrenHeight / 2 });\n\n const { height, width } = rootElement.getBoundingClientRect();\n\n if (x < width / 2) {\n if (y < height / 2) {\n setInternalAlignment(ContextMenuAlignment.BottomRight);\n } else {\n setInternalAlignment(ContextMenuAlignment.TopRight);\n }\n } else if (y < height / 2) {\n setInternalAlignment(ContextMenuAlignment.BottomLeft);\n } else {\n setInternalAlignment(ContextMenuAlignment.TopLeft);\n }\n\n setIsContentShown(true);\n }\n }, [items]);\n\n const handleClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n event.preventDefault();\n event.stopPropagation();\n\n void handleShow();\n },\n [handleShow]\n );\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!contextMenuContentRef.current?.contains(event.target as Node)) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n handleHide();\n },\n [handleHide]\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow]\n );\n\n useEffect(() => {\n if (isContentShown) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n\n if (typeof onShow === 'function') {\n onShow();\n }\n } else if (typeof onHide === 'function') {\n onHide();\n }\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n };\n }, [handleDocumentClick, handleHide, isContentShown, onHide, onShow]);\n\n const portal = useMemo(\n () =>\n createPortal(\n <AnimatePresence initial={false}>\n {isContentShown && (\n <ContextMenuContent\n coordinates={coordinates ?? internalCoordinates}\n items={items}\n key={`contextMenu_${uuid}`}\n alignment={alignment ?? internalAlignment}\n ref={contextMenuContentRef}\n />\n )}\n </AnimatePresence>,\n container\n ),\n [\n container,\n coordinates,\n internalCoordinates,\n internalAlignment,\n isContentShown,\n items,\n alignment,\n uuid,\n ]\n );\n\n return (\n <>\n <StyledContextMenu\n className=\"beta-chayns-context-menu\"\n onClick={handleClick}\n ref={contextMenuRef}\n >\n {children}\n </StyledContextMenu>\n {portal}\n </>\n );\n }\n);\n\nContextMenu.displayName = 'ContextMenu';\n\nexport default ContextMenu;\n"],"mappings":";;;;;;AAAA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AAAyD;AAAA;AAAA;AAqDzD,MAAMA,WAAW,gBAAG,IAAAC,iBAAU,EAC1B,OAUIC,GAAG,KACF;EAAA,IAVD;IACIC,SAAS;IACTC,QAAQ,gBAAG,6BAAC,aAAI;MAAC,KAAK,EAAE,CAAC,eAAe;IAAE,EAAG;IAC7CC,SAAS,GAAGC,QAAQ,CAACC,IAAI;IACzBC,WAAW;IACXC,KAAK;IACLC,MAAM;IACNC;EACJ,CAAC;EAGD,MAAM,CAACC,mBAAmB,EAAEC,sBAAsB,CAAC,GAAG,IAAAC,eAAQ,EAAyB;IACnFC,CAAC,EAAE,CAAC;IACJC,CAAC,EAAE;EACP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C,2BAAkB;IACf,WAAW,EAAEb,WAAW,aAAXA,WAAW,cAAXA,WAAW,GAAII,mBAAoB;IAChD,KAAK,EAAEH,KAAM;IACb,GAAG,EAAG,eAAcc,IAAK,EAAE;IAC3B,SAAS,EAAEpB,SAAS,aAATA,SAAS,cAATA,SAAS,GAAIc,iBAAkB;IAC1C,GAAG,EAAEQ;EAAsB,EAElC,CACa,EAClBpB,SAAS,CACZ,EACL,CACIA,SAAS,EACTG,WAAW,EACXI,mBAAmB,EACnBK,iBAAiB,EACjBI,cAAc,EACdZ,KAAK,EACLN,SAAS,EACToB,IAAI,CACP,CACJ;EAED,oBACI,yEACI,6BAAC,8BAAiB;IACd,SAAS,EAAC,0BAA0B;IACpC,OAAO,EAAEsC,WAAY;IACrB,GAAG,EAAElC;EAAe,GAEnBvB,QAAQ,CACO,EACnBuE,MAAM,CACR;AAEX,CAAC,CACJ;AAED3E,WAAW,CAAC8E,WAAW,GAAG,aAAa;AAAC,eAEzB9E,WAAW;AAAA"}
@@ -4,16 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.StyledContextMenu = void 0;
7
-
8
7
  var _styledComponents = _interopRequireDefault(require("styled-components"));
9
-
10
- var _templateObject;
11
-
12
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
15
-
16
- const StyledContextMenu = _styledComponents.default.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n"])));
17
-
9
+ const StyledContextMenu = _styledComponents.default.span`
10
+ cursor: pointer;
11
+ `;
18
12
  exports.StyledContextMenu = StyledContextMenu;
19
13
  //# sourceMappingURL=ContextMenu.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenu.styles.js","names":["StyledContextMenu","styled","span"],"sources":["../../../src/components/context-menu/ContextMenu.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const StyledContextMenu = styled.span`\n cursor: pointer;\n`;\n"],"mappings":";;;;;;;AAAA;;;;;;;;AAEO,MAAMA,iBAAiB,GAAGC,yBAAA,CAAOC,IAAV,6FAAvB"}
1
+ {"version":3,"file":"ContextMenu.styles.js","names":["StyledContextMenu","styled","span"],"sources":["../../../src/components/context-menu/ContextMenu.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const StyledContextMenu = styled.span`\n cursor: pointer;\n`;\n"],"mappings":";;;;;;AAAA;AAAuC;AAEhC,MAAMA,iBAAiB,GAAGC,yBAAM,CAACC,IAAK;AAC7C;AACA,CAAC;AAAC"}
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ContextMenuAlignment = void 0;
7
7
  let ContextMenuAlignment;
8
8
  exports.ContextMenuAlignment = ContextMenuAlignment;
9
-
10
9
  (function (ContextMenuAlignment) {
11
10
  ContextMenuAlignment[ContextMenuAlignment["TopLeft"] = 0] = "TopLeft";
12
11
  ContextMenuAlignment[ContextMenuAlignment["BottomLeft"] = 1] = "BottomLeft";
@@ -1 +1 @@
1
- {"version":3,"file":"alignment.js","names":["ContextMenuAlignment"],"sources":["../../../../src/components/context-menu/constants/alignment.ts"],"sourcesContent":["export enum ContextMenuAlignment {\n TopLeft,\n BottomLeft,\n TopRight,\n BottomRight,\n TopCenter,\n BottomCenter,\n}\n"],"mappings":";;;;;;IAAYA,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB"}
1
+ {"version":3,"file":"alignment.js","names":["ContextMenuAlignment"],"sources":["../../../../src/components/context-menu/constants/alignment.ts"],"sourcesContent":["export enum ContextMenuAlignment {\n TopLeft,\n BottomLeft,\n TopRight,\n BottomRight,\n TopCenter,\n BottomCenter,\n}\n"],"mappings":";;;;;;IAAYA,oBAAoB;AAAA;AAAA,WAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;AAAA,GAApBA,oBAAoB,oCAApBA,oBAAoB"}
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = _interopRequireDefault(require("react"));
9
-
10
8
  var _Icon = _interopRequireDefault(require("../../icon/Icon"));
11
-
12
9
  var _alignment = require("../constants/alignment");
13
-
14
10
  var _ContextMenuContent = require("./ContextMenuContent.styles");
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  const ContextMenuContent = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
19
13
  let {
20
14
  alignment,
@@ -55,7 +49,13 @@ const ContextMenuContent = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
55
49
  let {
56
50
  y = '0px'
57
51
  } = _ref2;
58
- return "\n translateX(".concat(percentageOffsetX, "%)\n translateY(").concat(percentageOffsetY, "%)\n translateX(").concat(anchorOffsetX, "px)\n translateY(").concat(anchorOffsetY, "px)\n translateY(").concat(y, ")\n ");
52
+ return `
53
+ translateX(${percentageOffsetX}%)
54
+ translateY(${percentageOffsetY}%)
55
+ translateX(${anchorOffsetX}px)
56
+ translateY(${anchorOffsetY}px)
57
+ translateY(${y})
58
+ `;
59
59
  }
60
60
  }, items.map(_ref3 => {
61
61
  let {
@@ -72,7 +72,6 @@ const ContextMenuContent = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
72
72
  })), /*#__PURE__*/_react.default.createElement(_ContextMenuContent.StyledContextMenuContentItemText, null, text));
73
73
  }));
74
74
  });
75
-
76
75
  ContextMenuContent.displayName = 'ContextMenuContent';
77
76
  var _default = ContextMenuContent;
78
77
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenuContent.js","names":["ContextMenuContent","React","forwardRef","ref","alignment","coordinates","items","isBottomLeftAlignment","ContextMenuAlignment","BottomLeft","isTopLeftAlignment","TopLeft","isTopRightAlignment","TopRight","percentageOffsetX","percentageOffsetY","anchorOffsetX","anchorOffsetY","exitAndInitialY","opacity","y","left","x","top","type","map","icons","key","onClick","text","displayName"],"sources":["../../../../src/components/context-menu/context-menu-content/ContextMenuContent.tsx"],"sourcesContent":["import React from 'react';\nimport Icon from '../../icon/Icon';\nimport { ContextMenuAlignment } from '../constants/alignment';\nimport type { ContextMenuCoordinates, ContextMenuItem } from '../ContextMenu';\nimport {\n StyledContextMenuContentItem,\n StyledContextMenuContentItemIconWrapper,\n StyledContextMenuContentItemText,\n StyledMotionContextMenuContent,\n} from './ContextMenuContent.styles';\n\ntype ContextMenuContentProps = {\n alignment: ContextMenuAlignment;\n coordinates: ContextMenuCoordinates;\n items: ContextMenuItem[];\n};\n\nconst ContextMenuContent = React.forwardRef<HTMLDivElement, ContextMenuContentProps>(\n ({ alignment, coordinates, items }, ref) => {\n const isBottomLeftAlignment = alignment === ContextMenuAlignment.BottomLeft;\n const isTopLeftAlignment = alignment === ContextMenuAlignment.TopLeft;\n const isTopRightAlignment = alignment === ContextMenuAlignment.TopRight;\n\n const percentageOffsetX = isBottomLeftAlignment || isTopLeftAlignment ? -100 : 0;\n const percentageOffsetY = isTopRightAlignment || isTopLeftAlignment ? -100 : 0;\n\n const anchorOffsetX = isBottomLeftAlignment || isTopLeftAlignment ? 21 : -21;\n const anchorOffsetY = isTopRightAlignment || isTopLeftAlignment ? -21 : 21;\n\n const exitAndInitialY = isTopLeftAlignment || isTopRightAlignment ? -16 : 16;\n\n return (\n <StyledMotionContextMenuContent\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: exitAndInitialY }}\n initial={{ opacity: 0, y: exitAndInitialY }}\n position={alignment}\n ref={ref}\n style={{ left: coordinates.x, top: coordinates.y }}\n transition={{ type: 'tween' }}\n transformTemplate={({ y = '0px' }) => `\n translateX(${percentageOffsetX}%)\n translateY(${percentageOffsetY}%)\n translateX(${anchorOffsetX}px)\n translateY(${anchorOffsetY}px)\n translateY(${y})\n `}\n >\n {items.map(({ icons, key, onClick, text }) => (\n <StyledContextMenuContentItem key={key} onClick={onClick}>\n <StyledContextMenuContentItemIconWrapper>\n <Icon icons={icons} />\n </StyledContextMenuContentItemIconWrapper>\n <StyledContextMenuContentItemText>{text}</StyledContextMenuContentItemText>\n </StyledContextMenuContentItem>\n ))}\n </StyledMotionContextMenuContent>\n );\n }\n);\n\nContextMenuContent.displayName = 'ContextMenuContent';\n\nexport default ContextMenuContent;\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;AAaA,MAAMA,kBAAkB,gBAAGC,cAAA,CAAMC,UAAN,CACvB,OAAoCC,GAApC,KAA4C;EAAA,IAA3C;IAAEC,SAAF;IAAaC,WAAb;IAA0BC;EAA1B,CAA2C;EACxC,MAAMC,qBAAqB,GAAGH,SAAS,KAAKI,+BAAA,CAAqBC,UAAjE;EACA,MAAMC,kBAAkB,GAAGN,SAAS,KAAKI,+BAAA,CAAqBG,OAA9D;EACA,MAAMC,mBAAmB,GAAGR,SAAS,KAAKI,+BAAA,CAAqBK,QAA/D;EAEA,MAAMC,iBAAiB,GAAGP,qBAAqB,IAAIG,kBAAzB,GAA8C,CAAC,GAA/C,GAAqD,CAA/E;EACA,MAAMK,iBAAiB,GAAGH,mBAAmB,IAAIF,kBAAvB,GAA4C,CAAC,GAA7C,GAAmD,CAA7E;EAEA,MAAMM,aAAa,GAAGT,qBAAqB,IAAIG,kBAAzB,GAA8C,EAA9C,GAAmD,CAAC,EAA1E;EACA,MAAMO,aAAa,GAAGL,mBAAmB,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ignment","coordinates","items","isBottomLeftAlignment","ContextMenuAlignment","BottomLeft","isTopLeftAlignment","TopLeft","isTopRightAlignment","TopRight","percentageOffsetX","percentageOffsetY","anchorOffsetX","anchorOffsetY","exitAndInitialY","opacity","y","left","x","top","type","map","icons","key","onClick","text","displayName"],"sources":["../../../../src/components/context-menu/context-menu-content/ContextMenuContent.tsx"],"sourcesContent":["import React from 'react';\nimport Icon from '../../icon/Icon';\nimport { ContextMenuAlignment } from '../constants/alignment';\nimport type { ContextMenuCoordinates, ContextMenuItem } from '../ContextMenu';\nimport {\n StyledContextMenuContentItem,\n StyledContextMenuContentItemIconWrapper,\n StyledContextMenuContentItemText,\n StyledMotionContextMenuContent,\n} from './ContextMenuContent.styles';\n\ntype ContextMenuContentProps = {\n alignment: ContextMenuAlignment;\n coordinates: ContextMenuCoordinates;\n items: ContextMenuItem[];\n};\n\nconst ContextMenuContent = React.forwardRef<HTMLDivElement, ContextMenuContentProps>(\n ({ alignment, coordinates, items }, ref) => {\n const isBottomLeftAlignment = alignment === ContextMenuAlignment.BottomLeft;\n const isTopLeftAlignment = alignment === ContextMenuAlignment.TopLeft;\n const isTopRightAlignment = alignment === ContextMenuAlignment.TopRight;\n\n const percentageOffsetX = isBottomLeftAlignment || isTopLeftAlignment ? -100 : 0;\n const percentageOffsetY = isTopRightAlignment || isTopLeftAlignment ? -100 : 0;\n\n const anchorOffsetX = isBottomLeftAlignment || isTopLeftAlignment ? 21 : -21;\n const anchorOffsetY = isTopRightAlignment || isTopLeftAlignment ? -21 : 21;\n\n const exitAndInitialY = isTopLeftAlignment || isTopRightAlignment ? -16 : 16;\n\n return (\n <StyledMotionContextMenuContent\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: exitAndInitialY }}\n initial={{ opacity: 0, y: exitAndInitialY }}\n position={alignment}\n ref={ref}\n style={{ left: coordinates.x, top: coordinates.y }}\n transition={{ type: 'tween' }}\n transformTemplate={({ y = '0px' }) => `\n translateX(${percentageOffsetX}%)\n translateY(${percentageOffsetY}%)\n translateX(${anchorOffsetX}px)\n translateY(${anchorOffsetY}px)\n translateY(${y})\n `}\n >\n {items.map(({ icons, key, onClick, text }) => (\n <StyledContextMenuContentItem key={key} onClick={onClick}>\n <StyledContextMenuContentItemIconWrapper>\n <Icon icons={icons} />\n </StyledContextMenuContentItemIconWrapper>\n <StyledContextMenuContentItemText>{text}</StyledContextMenuContentItemText>\n </StyledContextMenuContentItem>\n ))}\n </StyledMotionContextMenuContent>\n );\n }\n);\n\nContextMenuContent.displayName = 'ContextMenuContent';\n\nexport default ContextMenuContent;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AAKqC;AAQrC,MAAMA,kBAAkB,gBAAGC,cAAK,CAACC,UAAU,CACvC,OAAoCC,GAAG,KAAK;EAAA,IAA3C;IAAEC,SAAS;IAAEC,WAAW;IAAEC;EAAM,CAAC;EAC9B,MAAMC,qBAAqB,GAAGH,SAAS,KAAKI,+BAAoB,CAACC,UAAU;EAC3E,MAAMC,kBAAkB,GAAGN,SAAS,KAAKI,+BAAoB,CAACG,OAAO;EACrE,MAAMC,mBAAmB,GAAGR,SAAS,KAAKI,+BAAoB,CAACK,QAAQ;EAEvE,MAAMC,iBAAiB,GAAGP,qBAAqB,IAAIG,kBAAkB,GAAG,CAAC,GAAG,GAAG,CAAC;EAChF,MAAMK,iBAAiB,GAAGH,mBAAmB,IAAIF,kBAAkB,GAAG,CAAC,GAAG,GAAG,CAAC;EAE9E,MAAMM,aAAa,GAAGT,qBAAqB,IAAIG,kBAAkB,GAAG,EAAE,GAAG,CAAC,EAAE;EAC5E,MAAMO,aAAa,GAAGL,mBAAmB,IAAIF,kBAAkB,GAAG,CAAC,EAAE,GAAG,EAAE;EAE1E,MAAMQ,eAAe,GAAGR,kBAAkB,IAAIE,mBAAmB,GAAG,CAAC,EAAE,GAAG,EAAE;EAE5E,oBACI,6BAAC,kDAA8B;IAC3B,OAAO,EAAE;MAAEO,OAAO,EAAE,CAAC;MAAEC,C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