@chayns-components/core 5.0.0-beta.4 → 5.0.0-beta.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/accordion/Accordion.d.ts +51 -6
- package/lib/components/accordion/Accordion.js +86 -165
- package/lib/components/accordion/Accordion.js.map +1 -1
- package/lib/components/accordion/Accordion.styles.d.ts +7 -0
- package/lib/components/accordion/Accordion.styles.js +81 -0
- package/lib/components/accordion/Accordion.styles.js.map +1 -0
- package/lib/components/accordion/accordion-body/AccordionBody.d.ts +1 -2
- package/lib/components/accordion/accordion-body/AccordionBody.js +12 -18
- package/lib/components/accordion/accordion-body/AccordionBody.js.map +1 -1
- package/lib/components/accordion/accordion-body/AccordionBody.styles.d.ts +1 -0
- package/lib/components/accordion/accordion-body/AccordionBody.styles.js +14 -0
- package/lib/components/accordion/accordion-body/AccordionBody.styles.js.map +1 -0
- package/lib/components/accordion/accordion-content/AccordionContent.d.ts +6 -3
- package/lib/components/accordion/accordion-content/AccordionContent.js +15 -22
- package/lib/components/accordion/accordion-content/AccordionContent.js.map +1 -1
- package/lib/components/accordion/accordion-content/AccordionContent.styles.d.ts +5 -0
- package/lib/components/accordion/accordion-content/AccordionContent.styles.js +24 -0
- package/lib/components/accordion/accordion-content/AccordionContent.styles.js.map +1 -0
- package/lib/components/accordion/accordion-group/AccordionGroup.d.ts +26 -0
- package/lib/components/accordion/accordion-group/AccordionGroup.js +57 -0
- package/lib/components/accordion/accordion-group/AccordionGroup.js.map +1 -0
- package/lib/components/accordion/accordion-head/AccordionHead.d.ts +9 -3
- package/lib/components/accordion/accordion-head/AccordionHead.js +94 -126
- package/lib/components/accordion/accordion-head/AccordionHead.js.map +1 -1
- package/lib/components/accordion/accordion-head/AccordionHead.styles.d.ts +19 -0
- package/lib/components/accordion/accordion-head/AccordionHead.styles.js +158 -0
- package/lib/components/accordion/accordion-head/AccordionHead.styles.js.map +1 -0
- package/lib/components/accordion/accordion-intro/AccordionIntro.d.ts +9 -0
- package/lib/components/accordion/accordion-intro/AccordionIntro.js +21 -0
- package/lib/components/accordion/accordion-intro/AccordionIntro.js.map +1 -0
- package/lib/components/accordion/accordion-intro/AccordionIntro.styles.d.ts +1 -0
- package/lib/components/accordion/accordion-intro/AccordionIntro.styles.js +13 -0
- package/lib/components/accordion/accordion-intro/AccordionIntro.styles.js.map +1 -0
- package/lib/components/accordion/utils.d.ts +11 -0
- package/lib/components/accordion/utils.js +36 -0
- package/lib/components/accordion/utils.js.map +1 -0
- package/lib/components/badge/Badge.d.ts +9 -1
- package/lib/components/badge/Badge.js +14 -26
- package/lib/components/badge/Badge.js.map +1 -1
- package/lib/components/badge/Badge.styles.d.ts +4 -0
- package/lib/components/badge/Badge.styles.js +32 -0
- package/lib/components/badge/Badge.styles.js.map +1 -0
- package/lib/components/button/Button.d.ts +2 -2
- package/lib/components/button/Button.js +15 -44
- package/lib/components/button/Button.js.map +1 -1
- package/lib/components/button/Button.styles.d.ts +7 -0
- package/lib/components/button/Button.styles.js +60 -0
- package/lib/components/button/Button.styles.js.map +1 -0
- package/lib/components/checkbox/Checkbox.d.ts +25 -0
- package/lib/components/checkbox/Checkbox.js +44 -0
- package/lib/components/checkbox/Checkbox.js.map +1 -0
- package/lib/components/checkbox/Checkbox.styles.d.ts +6 -0
- package/lib/components/checkbox/Checkbox.styles.js +125 -0
- package/lib/components/checkbox/Checkbox.styles.js.map +1 -0
- package/lib/components/color-scheme-provider/ColorSchemeProvider.d.ts +6 -0
- package/lib/components/color-scheme-provider/ColorSchemeProvider.js +38 -78
- package/lib/components/color-scheme-provider/ColorSchemeProvider.js.map +1 -1
- package/lib/components/context-menu/ContextMenu.d.ts +51 -0
- package/lib/components/context-menu/ContextMenu.js +154 -0
- package/lib/components/context-menu/ContextMenu.js.map +1 -0
- package/lib/components/context-menu/ContextMenu.styles.d.ts +1 -0
- package/lib/components/context-menu/ContextMenu.styles.js +13 -0
- package/lib/components/context-menu/ContextMenu.styles.js.map +1 -0
- package/lib/components/context-menu/constants/alignment.d.ts +8 -0
- package/lib/components/context-menu/constants/alignment.js +17 -0
- package/lib/components/context-menu/constants/alignment.js.map +1 -0
- package/lib/components/context-menu/context-menu-content/ContextMenuContent.d.ts +10 -0
- package/lib/components/context-menu/context-menu-content/ContextMenuContent.js +78 -0
- package/lib/components/context-menu/context-menu-content/ContextMenuContent.js.map +1 -0
- package/lib/components/context-menu/context-menu-content/ContextMenuContent.styles.d.ts +11 -0
- package/lib/components/context-menu/context-menu-content/ContextMenuContent.styles.js +117 -0
- package/lib/components/context-menu/context-menu-content/ContextMenuContent.styles.js.map +1 -0
- package/lib/components/grid-image/GridImage.d.ts +19 -0
- package/lib/components/grid-image/GridImage.js +46 -0
- package/lib/components/grid-image/GridImage.js.map +1 -0
- package/lib/components/grid-image/GridImage.styles.d.ts +21 -0
- package/lib/components/grid-image/GridImage.styles.js +105 -0
- package/lib/components/grid-image/GridImage.styles.js.map +1 -0
- package/lib/components/icon/Icon.d.ts +11 -3
- package/lib/components/icon/Icon.js +36 -80
- package/lib/components/icon/Icon.js.map +1 -1
- package/lib/components/icon/Icon.styles.d.ts +15 -0
- package/lib/components/icon/Icon.styles.js +76 -0
- package/lib/components/icon/Icon.styles.js.map +1 -0
- package/lib/components/icon/utils.d.ts +1 -0
- package/lib/components/icon/utils.js +13 -0
- package/lib/components/icon/utils.js.map +1 -0
- package/lib/components/input/Input.d.ts +33 -0
- package/lib/components/input/Input.js +72 -0
- package/lib/components/input/Input.js.map +1 -0
- package/lib/components/input/Input.styles.d.ts +6 -0
- package/lib/components/input/Input.styles.js +58 -0
- package/lib/components/input/Input.styles.js.map +1 -0
- package/lib/components/list/List.d.ts +18 -0
- package/lib/components/list/List.js +54 -0
- package/lib/components/list/List.js.map +1 -0
- package/lib/components/list/list-item/ListItem.d.ts +67 -0
- package/lib/components/list/list-item/ListItem.js +90 -0
- package/lib/components/list/list-item/ListItem.js.map +1 -0
- package/lib/components/list/list-item/ListItem.styles.d.ts +6 -0
- package/lib/components/list/list-item/ListItem.styles.js +56 -0
- package/lib/components/list/list-item/ListItem.styles.js.map +1 -0
- package/lib/components/list/list-item/list-item-body/ListItemBody.d.ts +3 -0
- package/lib/components/list/list-item/list-item-body/ListItemBody.js +36 -0
- package/lib/components/list/list-item/list-item-body/ListItemBody.js.map +1 -0
- package/lib/components/list/list-item/list-item-body/ListItemBody.styles.d.ts +1 -0
- package/lib/components/list/list-item/list-item-body/ListItemBody.styles.js +14 -0
- package/lib/components/list/list-item/list-item-body/ListItemBody.styles.js.map +1 -0
- package/lib/components/list/list-item/list-item-content/ListItemContent.d.ts +3 -0
- package/lib/components/list/list-item/list-item-content/ListItemContent.js +21 -0
- package/lib/components/list/list-item/list-item-content/ListItemContent.js.map +1 -0
- package/lib/components/list/list-item/list-item-content/ListItemContent.styles.d.ts +1 -0
- package/lib/components/list/list-item/list-item-content/ListItemContent.styles.js +19 -0
- package/lib/components/list/list-item/list-item-content/ListItemContent.styles.js.map +1 -0
- package/lib/components/list/list-item/list-item-head/ListItemHead.d.ts +18 -0
- package/lib/components/list/list-item/list-item-head/ListItemHead.js +100 -0
- package/lib/components/list/list-item/list-item-head/ListItemHead.js.map +1 -0
- package/lib/components/list/list-item/list-item-head/ListItemHead.styles.d.ts +20 -0
- package/lib/components/list/list-item/list-item-head/ListItemHead.styles.js +110 -0
- package/lib/components/list/list-item/list-item-head/ListItemHead.styles.js.map +1 -0
- package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.d.ts +6 -0
- package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.js +23 -0
- package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.js.map +1 -0
- package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.styles.d.ts +1 -0
- package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.styles.js +32 -0
- package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.styles.js.map +1 -0
- package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.d.ts +7 -0
- package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.js +44 -0
- package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.js.map +1 -0
- package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.d.ts +10 -0
- package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js +52 -0
- package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js.map +1 -0
- package/lib/hooks/uuid.d.ts +1 -0
- package/lib/hooks/uuid.js +14 -0
- package/lib/hooks/uuid.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +75 -11
- package/lib/index.js.map +1 -1
- package/lib/types/chayns.d.ts +56 -0
- package/lib/types/chayns.js +14 -0
- package/lib/types/chayns.js.map +1 -0
- package/package.json +64 -62
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _uuid = require("../../hooks/uuid");
|
|
9
|
+
var _Checkbox = require("./Checkbox.styles");
|
|
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); }
|
|
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; }
|
|
12
|
+
const Checkbox = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
children,
|
|
15
|
+
isChecked,
|
|
16
|
+
isDisabled,
|
|
17
|
+
onChange,
|
|
18
|
+
shouldShowAsSwitch
|
|
19
|
+
} = _ref;
|
|
20
|
+
const [isActive, setIsActive] = (0, _react.useState)(isChecked !== null && isChecked !== void 0 ? isChecked : false);
|
|
21
|
+
const handleChange = (0, _react.useCallback)(event => {
|
|
22
|
+
setIsActive(event.target.checked);
|
|
23
|
+
if (typeof onChange === 'function') {
|
|
24
|
+
onChange(event);
|
|
25
|
+
}
|
|
26
|
+
}, [onChange]);
|
|
27
|
+
const uuid = (0, _uuid.useUuid)();
|
|
28
|
+
return /*#__PURE__*/_react.default.createElement(_Checkbox.StyledCheckbox, null, /*#__PURE__*/_react.default.createElement(_Checkbox.StyledCheckboxInput, {
|
|
29
|
+
checked: isChecked,
|
|
30
|
+
disabled: isDisabled,
|
|
31
|
+
id: uuid,
|
|
32
|
+
onChange: handleChange,
|
|
33
|
+
type: "checkbox"
|
|
34
|
+
}), /*#__PURE__*/_react.default.createElement(_Checkbox.StyledCheckboxLabel, {
|
|
35
|
+
htmlFor: uuid,
|
|
36
|
+
isChecked: isChecked !== null && isChecked !== void 0 ? isChecked : isActive,
|
|
37
|
+
isDisabled: isDisabled,
|
|
38
|
+
shouldShowAsSwitch: shouldShowAsSwitch
|
|
39
|
+
}, children));
|
|
40
|
+
};
|
|
41
|
+
Checkbox.displayName = 'Checkbox';
|
|
42
|
+
var _default = Checkbox;
|
|
43
|
+
exports.default = _default;
|
|
44
|
+
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -0,0 +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;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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CheckboxProps } from './Checkbox';
|
|
2
|
+
export declare const StyledCheckbox: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const StyledCheckboxInput: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
4
|
+
export declare const StyledCheckboxLabel: import("styled-components").StyledComponent<"label", any, Omit<CheckboxProps, "children" | "onChange"> & {
|
|
5
|
+
theme: import("../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
6
|
+
}, never>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledCheckboxLabel = exports.StyledCheckboxInput = exports.StyledCheckbox = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
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); }
|
|
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; }
|
|
10
|
+
const StyledCheckbox = _styledComponents.default.div`
|
|
11
|
+
align-items: center;
|
|
12
|
+
display: flex;
|
|
13
|
+
position: relative;
|
|
14
|
+
`;
|
|
15
|
+
exports.StyledCheckbox = StyledCheckbox;
|
|
16
|
+
const StyledCheckboxInput = _styledComponents.default.input`
|
|
17
|
+
display: none;
|
|
18
|
+
`;
|
|
19
|
+
exports.StyledCheckboxInput = StyledCheckboxInput;
|
|
20
|
+
const StyledCheckboxLabel = _styledComponents.default.label`
|
|
21
|
+
cursor: ${_ref => {
|
|
22
|
+
let {
|
|
23
|
+
isDisabled
|
|
24
|
+
} = _ref;
|
|
25
|
+
return isDisabled ? 'default' : 'pointer';
|
|
26
|
+
}};
|
|
27
|
+
opacity: ${_ref2 => {
|
|
28
|
+
let {
|
|
29
|
+
isDisabled
|
|
30
|
+
} = _ref2;
|
|
31
|
+
return isDisabled ? 0.5 : 1;
|
|
32
|
+
}};
|
|
33
|
+
padding-left: ${_ref3 => {
|
|
34
|
+
let {
|
|
35
|
+
shouldShowAsSwitch
|
|
36
|
+
} = _ref3;
|
|
37
|
+
return shouldShowAsSwitch ? '48px' : '20px';
|
|
38
|
+
}};
|
|
39
|
+
transition: opacity 0.2s ease;
|
|
40
|
+
user-select: none;
|
|
41
|
+
|
|
42
|
+
&:after {
|
|
43
|
+
${_ref4 => {
|
|
44
|
+
let {
|
|
45
|
+
isChecked,
|
|
46
|
+
shouldShowAsSwitch
|
|
47
|
+
} = _ref4;
|
|
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 => {
|
|
77
|
+
let {
|
|
78
|
+
isChecked,
|
|
79
|
+
shouldShowAsSwitch,
|
|
80
|
+
theme
|
|
81
|
+
} = _ref5;
|
|
82
|
+
if (shouldShowAsSwitch) {
|
|
83
|
+
return isChecked ? theme.green : theme.red;
|
|
84
|
+
}
|
|
85
|
+
return isChecked ? theme['408'] : theme['403'];
|
|
86
|
+
}};
|
|
87
|
+
border: 1px solid rgba(${_ref6 => {
|
|
88
|
+
let {
|
|
89
|
+
theme
|
|
90
|
+
} = _ref6;
|
|
91
|
+
return theme['409-rgb'];
|
|
92
|
+
}}, 0.5);
|
|
93
|
+
border-radius: ${_ref7 => {
|
|
94
|
+
let {
|
|
95
|
+
shouldShowAsSwitch
|
|
96
|
+
} = _ref7;
|
|
97
|
+
return shouldShowAsSwitch ? '100px' : 0;
|
|
98
|
+
}};
|
|
99
|
+
content: ' ';
|
|
100
|
+
height: ${_ref8 => {
|
|
101
|
+
let {
|
|
102
|
+
shouldShowAsSwitch
|
|
103
|
+
} = _ref8;
|
|
104
|
+
return shouldShowAsSwitch ? '13px' : '15px';
|
|
105
|
+
}};
|
|
106
|
+
left: ${_ref9 => {
|
|
107
|
+
let {
|
|
108
|
+
shouldShowAsSwitch
|
|
109
|
+
} = _ref9;
|
|
110
|
+
return shouldShowAsSwitch ? '10px' : 0;
|
|
111
|
+
}};
|
|
112
|
+
position: absolute;
|
|
113
|
+
top: 50%;
|
|
114
|
+
transform: translateY(-50%);
|
|
115
|
+
transition: background-color 0.2s ease;
|
|
116
|
+
width: ${_ref10 => {
|
|
117
|
+
let {
|
|
118
|
+
shouldShowAsSwitch
|
|
119
|
+
} = _ref10;
|
|
120
|
+
return shouldShowAsSwitch ? '28px' : '15px';
|
|
121
|
+
}};
|
|
122
|
+
}
|
|
123
|
+
`;
|
|
124
|
+
exports.StyledCheckboxLabel = StyledCheckboxLabel;
|
|
125
|
+
//# sourceMappingURL=Checkbox.styles.js.map
|
|
@@ -0,0 +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;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,yBAAM,CAACK,KAAgC;AAC1E,cAAc;EAAA,IAAC;IAAEC;EAAW,CAAC;EAAA,OAAMA,UAAU,GAAG,SAAS,GAAG,SAAS;AAAA,CAAE;AACvE,eAAe;EAAA,IAAC;IAAEA;EAAW,CAAC;EAAA,OAAMA,UAAU,GAAG,GAAG,GAAG,CAAC;AAAA,CAAE;AAC1D,oBAAoB;EAAA,IAAC;IAAEC;EAAmB,CAAC;EAAA,OAAMA,kBAAkB,GAAG,MAAM,GAAG,MAAM;AAAA,CAAE;AACvF;AACA;AACA;AACA;AACA,UAAU;EAAA,IAAC;IAAEC,SAAS;IAAED;EAAmB,CAAC;EAAA,OAChCA,kBAAkB,GACZ,IAAAE,qBAAG,CAAC;AACtB;AACA;AACA;AACA;AACA;AACA,+DAA+DD,SAAS,GAAG,MAAM,GAAG,CAAE;AACtF;AACA;AACA,mBAAmB,GACD,IAAAC,qBAAG,CAAC;AACtB;AACA;AACA;AACA;AACA,iCAAiCD,SAAS,GAAG,CAAC,GAAG,CAAE;AACnD;AACA;AACA;AACA,mBAAmB;AAAA,CAAC;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,SAIY;EAAA,IAJX;IACjBA,SAAS;IACTD,kBAAkB;IAClBG;EACsB,CAAC;EACvB,IAAIH,kBAAkB,EAAE;IACpB,OAAOC,SAAS,GAAGE,KAAK,CAACC,KAAK,GAAGD,KAAK,CAACE,GAAG;EAC9C;EAEA,OAAOJ,SAAS,GAAGE,KAAK,CAAC,KAAK,CAAC,GAAGA,KAAK,CAAC,KAAK,CAAC;AAClD,CAAE;AACV,iCAAiC;EAAA,IAAC;IAAEA;EAAgC,CAAC;EAAA,OAAKA,KAAK,CAAC,SAAS,CAAC;AAAA,CAAC;AAC3F,yBAAyB;EAAA,IAAC;IAAEH;EAAmB,CAAC;EAAA,OAAMA,kBAAkB,GAAG,OAAO,GAAG,CAAC;AAAA,CAAE;AACxF;AACA,kBAAkB;EAAA,IAAC;IAAEA;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"}
|
|
@@ -34,5 +34,11 @@ declare type ColorSchemeProviderProps = {
|
|
|
34
34
|
[key: string]: string | number;
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
+
export interface Theme {
|
|
38
|
+
[key: string]: string;
|
|
39
|
+
}
|
|
40
|
+
export declare type WithTheme<T> = T & {
|
|
41
|
+
theme: Theme;
|
|
42
|
+
};
|
|
37
43
|
declare const ColorSchemeProvider: FC<ColorSchemeProviderProps>;
|
|
38
44
|
export default ColorSchemeProvider;
|
|
@@ -1,98 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.default = void 0;
|
|
9
|
-
|
|
10
7
|
var _colors = require("@chayns/colors");
|
|
11
|
-
|
|
12
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
9
|
var _styledComponents = require("styled-components");
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
|
-
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; }
|
|
21
|
-
|
|
22
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
-
|
|
24
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
25
|
-
|
|
26
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
27
|
-
|
|
28
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
29
|
-
|
|
30
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
31
|
-
|
|
32
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
33
|
-
|
|
34
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
35
|
-
|
|
36
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
37
|
-
|
|
38
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
39
|
-
|
|
40
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
41
|
-
|
|
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); }
|
|
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; }
|
|
42
12
|
var ColorMode;
|
|
43
|
-
|
|
44
13
|
(function (ColorMode) {
|
|
45
14
|
ColorMode[ColorMode["Classic"] = 0] = "Classic";
|
|
46
15
|
ColorMode[ColorMode["Dark"] = 1] = "Dark";
|
|
47
16
|
ColorMode[ColorMode["Light"] = 2] = "Light";
|
|
48
17
|
})(ColorMode || (ColorMode = {}));
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var newColors = {};
|
|
77
|
-
var newThemeColors = {};
|
|
78
|
-
availableColors.forEach(function (colorName) {
|
|
79
|
-
var hexColor = (0, _colors.getColorFromPalette)(colorName, {
|
|
80
|
-
color: color,
|
|
81
|
-
colorMode: colorMode,
|
|
82
|
-
secondaryColor: secondaryColor
|
|
18
|
+
const GlobalStyle = (0, _styledComponents.createGlobalStyle)`
|
|
19
|
+
.ellipsis {
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
text-overflow: ellipsis;
|
|
22
|
+
white-space: nowrap;
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
const ColorSchemeProvider = _ref => {
|
|
26
|
+
let {
|
|
27
|
+
children,
|
|
28
|
+
color = '#005EB8',
|
|
29
|
+
colorMode = ColorMode.Classic,
|
|
30
|
+
cssVariables = {},
|
|
31
|
+
secondaryColor,
|
|
32
|
+
style = {}
|
|
33
|
+
} = _ref;
|
|
34
|
+
const [colors, setColors] = (0, _react.useState)({});
|
|
35
|
+
const [themeColors, setThemeColors] = (0, _react.useState)({});
|
|
36
|
+
(0, _react.useEffect)(() => {
|
|
37
|
+
const availableColors = (0, _colors.getAvailableColorList)();
|
|
38
|
+
const newColors = {};
|
|
39
|
+
const newThemeColors = {};
|
|
40
|
+
availableColors.forEach(colorName => {
|
|
41
|
+
const hexColor = (0, _colors.getColorFromPalette)(colorName, {
|
|
42
|
+
color,
|
|
43
|
+
colorMode,
|
|
44
|
+
secondaryColor
|
|
83
45
|
});
|
|
84
|
-
|
|
85
|
-
if (colorName === 'text') {// console.debug('textColor', hexColor);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
46
|
if (hexColor) {
|
|
89
|
-
|
|
90
|
-
newColors[
|
|
47
|
+
const rgbColor = (0, _colors.hexToRgb255)(hexColor);
|
|
48
|
+
newColors[`--chayns-color--${colorName}`] = hexColor;
|
|
91
49
|
newThemeColors[colorName] = hexColor;
|
|
92
|
-
|
|
93
50
|
if (rgbColor) {
|
|
94
|
-
newColors[
|
|
95
|
-
newThemeColors[
|
|
51
|
+
newColors[`--chayns-color-rgb--${colorName}`] = `${rgbColor.r}, ${rgbColor.g}, ${rgbColor.b}`;
|
|
52
|
+
newThemeColors[`${colorName}-rgb`] = `${rgbColor.r}, ${rgbColor.g}, ${rgbColor.b}`;
|
|
96
53
|
}
|
|
97
54
|
}
|
|
98
55
|
});
|
|
@@ -102,10 +59,13 @@ var ColorSchemeProvider = function ColorSchemeProvider(_ref) {
|
|
|
102
59
|
return /*#__PURE__*/_react.default.createElement(_styledComponents.ThemeProvider, {
|
|
103
60
|
theme: themeColors
|
|
104
61
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
105
|
-
style:
|
|
62
|
+
style: {
|
|
63
|
+
...colors,
|
|
64
|
+
...cssVariables,
|
|
65
|
+
...style
|
|
66
|
+
}
|
|
106
67
|
}, children), /*#__PURE__*/_react.default.createElement(GlobalStyle, null));
|
|
107
68
|
};
|
|
108
|
-
|
|
109
69
|
ColorSchemeProvider.displayName = 'ColorSchemeProvider';
|
|
110
70
|
var _default = ColorSchemeProvider;
|
|
111
71
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,6BAAqB,GAAE;IAE/C,MAAMC,SAAgB,GAAG,CAAC,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uAlignment } from './constants/alignment';
|
|
3
|
+
export declare type ContextMenuCoordinates = {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
};
|
|
7
|
+
export declare type ContextMenuItem = {
|
|
8
|
+
icons: string[];
|
|
9
|
+
key: string;
|
|
10
|
+
onClick: (event?: MouseEvent<HTMLDivElement>) => void;
|
|
11
|
+
text: string;
|
|
12
|
+
};
|
|
13
|
+
declare type ContextMenuRef = {
|
|
14
|
+
hide: VoidFunction;
|
|
15
|
+
show: VoidFunction;
|
|
16
|
+
};
|
|
17
|
+
declare type ContextMenuProps = {
|
|
18
|
+
/**
|
|
19
|
+
* Optional custom alignment used instead of calculating it using the
|
|
20
|
+
* alignment within the page. The available alignment can be taken from the
|
|
21
|
+
* ContextMenuAlignment enum.
|
|
22
|
+
*/
|
|
23
|
+
alignment?: ContextMenuAlignment;
|
|
24
|
+
/**
|
|
25
|
+
* The element over which the content of the `ContextMenu` should be displayed.
|
|
26
|
+
*/
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* The element where the content of the `ContextMenu` should be rendered via React Portal.
|
|
30
|
+
*/
|
|
31
|
+
container?: Element;
|
|
32
|
+
/**
|
|
33
|
+
* Optional own coordinates to be used instead of calculating the alignment
|
|
34
|
+
* based on the alignment of the children.
|
|
35
|
+
*/
|
|
36
|
+
coordinates?: ContextMenuCoordinates;
|
|
37
|
+
/**
|
|
38
|
+
* The items that will be displayed in the content of the `ContextMenu`.
|
|
39
|
+
*/
|
|
40
|
+
items: ContextMenuItem[];
|
|
41
|
+
/**
|
|
42
|
+
* Function to be executed when the content of the Context menu has been hidden.
|
|
43
|
+
*/
|
|
44
|
+
onHide?: VoidFunction;
|
|
45
|
+
/**
|
|
46
|
+
* Function to be executed when the content of the Context menu has been shown.
|
|
47
|
+
*/
|
|
48
|
+
onShow?: VoidFunction;
|
|
49
|
+
};
|
|
50
|
+
declare const ContextMenu: React.ForwardRefExoticComponent<ContextMenuProps & React.RefAttributes<ContextMenuRef>>;
|
|
51
|
+
export default ContextMenu;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _framerMotion = require("framer-motion");
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactDom = require("react-dom");
|
|
10
|
+
var _uuid = require("../../hooks/uuid");
|
|
11
|
+
var _Icon = _interopRequireDefault(require("../icon/Icon"));
|
|
12
|
+
var _alignment = require("./constants/alignment");
|
|
13
|
+
var _ContextMenuContent = _interopRequireDefault(require("./context-menu-content/ContextMenuContent"));
|
|
14
|
+
var _ContextMenu = require("./ContextMenu.styles");
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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); }
|
|
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; }
|
|
18
|
+
const ContextMenu = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
19
|
+
let {
|
|
20
|
+
alignment,
|
|
21
|
+
children = /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
22
|
+
icons: ['ts-ellipsis_v']
|
|
23
|
+
}),
|
|
24
|
+
container = document.body,
|
|
25
|
+
coordinates,
|
|
26
|
+
items,
|
|
27
|
+
onHide,
|
|
28
|
+
onShow
|
|
29
|
+
} = _ref;
|
|
30
|
+
const [internalCoordinates, setInternalCoordinates] = (0, _react.useState)({
|
|
31
|
+
x: 0,
|
|
32
|
+
y: 0
|
|
33
|
+
});
|
|
34
|
+
const [internalAlignment, setInternalAlignment] = (0, _react.useState)(_alignment.ContextMenuAlignment.TopLeft);
|
|
35
|
+
const [isContentShown, setIsContentShown] = (0, _react.useState)(false);
|
|
36
|
+
const uuid = (0, _uuid.useUuid)();
|
|
37
|
+
|
|
38
|
+
// ToDo: Replace with hook if new chayns api is ready
|
|
39
|
+
const contextMenuContentRef = (0, _react.useRef)(null);
|
|
40
|
+
const contextMenuRef = (0, _react.useRef)(null);
|
|
41
|
+
const handleHide = (0, _react.useCallback)(() => {
|
|
42
|
+
setIsContentShown(false);
|
|
43
|
+
}, []);
|
|
44
|
+
const handleShow = (0, _react.useCallback)(async () => {
|
|
45
|
+
const {
|
|
46
|
+
isMobile,
|
|
47
|
+
isTablet
|
|
48
|
+
} = chayns.env;
|
|
49
|
+
if (isMobile || isTablet) {
|
|
50
|
+
var _selection$;
|
|
51
|
+
// ToDo: Replace with new api function if new api is ready
|
|
52
|
+
const {
|
|
53
|
+
buttonType,
|
|
54
|
+
selection
|
|
55
|
+
} = await chayns.dialog.select({
|
|
56
|
+
buttons: [],
|
|
57
|
+
list: items.map((_ref2, index) => {
|
|
58
|
+
let {
|
|
59
|
+
icons,
|
|
60
|
+
text
|
|
61
|
+
} = _ref2;
|
|
62
|
+
return {
|
|
63
|
+
name: text,
|
|
64
|
+
value: index,
|
|
65
|
+
icon: icons[0]
|
|
66
|
+
};
|
|
67
|
+
}),
|
|
68
|
+
type: 2
|
|
69
|
+
});
|
|
70
|
+
if (buttonType === 1 && typeof ((_selection$ = selection[0]) === null || _selection$ === void 0 ? void 0 : _selection$.value) === 'number') {
|
|
71
|
+
var _items$selection$0$va;
|
|
72
|
+
(_items$selection$0$va = items[selection[0].value]) === null || _items$selection$0$va === void 0 ? void 0 : _items$selection$0$va.onClick();
|
|
73
|
+
}
|
|
74
|
+
} else if (contextMenuRef.current) {
|
|
75
|
+
const rootElement = document.querySelector('.tapp') || document.body;
|
|
76
|
+
const {
|
|
77
|
+
x,
|
|
78
|
+
y,
|
|
79
|
+
height: childrenHeight,
|
|
80
|
+
width: childrenWidth
|
|
81
|
+
} = contextMenuRef.current.getBoundingClientRect();
|
|
82
|
+
setInternalCoordinates({
|
|
83
|
+
x: x + childrenWidth / 2,
|
|
84
|
+
y: y + childrenHeight / 2
|
|
85
|
+
});
|
|
86
|
+
const {
|
|
87
|
+
height,
|
|
88
|
+
width
|
|
89
|
+
} = rootElement.getBoundingClientRect();
|
|
90
|
+
if (x < width / 2) {
|
|
91
|
+
if (y < height / 2) {
|
|
92
|
+
setInternalAlignment(_alignment.ContextMenuAlignment.BottomRight);
|
|
93
|
+
} else {
|
|
94
|
+
setInternalAlignment(_alignment.ContextMenuAlignment.TopRight);
|
|
95
|
+
}
|
|
96
|
+
} else if (y < height / 2) {
|
|
97
|
+
setInternalAlignment(_alignment.ContextMenuAlignment.BottomLeft);
|
|
98
|
+
} else {
|
|
99
|
+
setInternalAlignment(_alignment.ContextMenuAlignment.TopLeft);
|
|
100
|
+
}
|
|
101
|
+
setIsContentShown(true);
|
|
102
|
+
}
|
|
103
|
+
}, [items]);
|
|
104
|
+
const handleClick = (0, _react.useCallback)(event => {
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
event.stopPropagation();
|
|
107
|
+
void handleShow();
|
|
108
|
+
}, [handleShow]);
|
|
109
|
+
const handleDocumentClick = (0, _react.useCallback)(event => {
|
|
110
|
+
var _contextMenuContentRe;
|
|
111
|
+
if (!((_contextMenuContentRe = contextMenuContentRef.current) !== null && _contextMenuContentRe !== void 0 && _contextMenuContentRe.contains(event.target))) {
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
event.stopPropagation();
|
|
114
|
+
}
|
|
115
|
+
handleHide();
|
|
116
|
+
}, [handleHide]);
|
|
117
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
118
|
+
hide: handleHide,
|
|
119
|
+
show: handleShow
|
|
120
|
+
}), [handleHide, handleShow]);
|
|
121
|
+
(0, _react.useEffect)(() => {
|
|
122
|
+
if (isContentShown) {
|
|
123
|
+
document.addEventListener('click', handleDocumentClick, true);
|
|
124
|
+
window.addEventListener('blur', handleHide);
|
|
125
|
+
if (typeof onShow === 'function') {
|
|
126
|
+
onShow();
|
|
127
|
+
}
|
|
128
|
+
} else if (typeof onHide === 'function') {
|
|
129
|
+
onHide();
|
|
130
|
+
}
|
|
131
|
+
return () => {
|
|
132
|
+
document.removeEventListener('click', handleDocumentClick, true);
|
|
133
|
+
window.removeEventListener('blur', handleHide);
|
|
134
|
+
};
|
|
135
|
+
}, [handleDocumentClick, handleHide, isContentShown, onHide, onShow]);
|
|
136
|
+
const portal = (0, _react.useMemo)(() => /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/_react.default.createElement(_framerMotion.AnimatePresence, {
|
|
137
|
+
initial: false
|
|
138
|
+
}, isContentShown && /*#__PURE__*/_react.default.createElement(_ContextMenuContent.default, {
|
|
139
|
+
coordinates: coordinates !== null && coordinates !== void 0 ? coordinates : internalCoordinates,
|
|
140
|
+
items: items,
|
|
141
|
+
key: `contextMenu_${uuid}`,
|
|
142
|
+
alignment: alignment !== null && alignment !== void 0 ? alignment : internalAlignment,
|
|
143
|
+
ref: contextMenuContentRef
|
|
144
|
+
})), container), [container, coordinates, internalCoordinates, internalAlignment, isContentShown, items, alignment, uuid]);
|
|
145
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ContextMenu.StyledContextMenu, {
|
|
146
|
+
className: "beta-chayns-context-menu",
|
|
147
|
+
onClick: handleClick,
|
|
148
|
+
ref: contextMenuRef
|
|
149
|
+
}, children), portal);
|
|
150
|
+
});
|
|
151
|
+
ContextMenu.displayName = 'ContextMenu';
|
|
152
|
+
var _default = ContextMenu;
|
|
153
|
+
exports.default = _default;
|
|
154
|
+
//# sourceMappingURL=ContextMenu.js.map
|
|
@@ -0,0 +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;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,CAAC,CAAC;EACF,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAG,IAAAJ,eAAQ,EACtDK,+BAAoB,CAACC,OAAO,CAC/B;EACD,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAG,IAAAR,eAAQ,EAAC,KAAK,CAAC;EAE3D,MAAMS,IAAI,GAAG,IAAAC,aAAO,GAAE;;EAEtB;EACA,MAAMC,qBAAqB,GAAG,IAAAC,aAAM,EAAiB,IAAI,CAAC;EAC1D,MAAMC,cAAc,GAAG,IAAAD,aAAM,EAAkB,IAAI,CAAC;EAEpD,MAAME,UAAU,GAAG,IAAAC,kBAAW,EAAC,MAAM;IACjCP,iBAAiB,CAAC,KAAK,CAAC;EAC5B,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMQ,UAA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AQ,CACO,EACnBuE,MAAM,CACR;AAEX,CAAC,CACJ;AAED3E,WAAW,CAAC8E,WAAW,GAAG,aAAa;AAAC,eAEzB9E,WAAW;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StyledContextMenu: import("styled-components").StyledComponent<"span", any, {}, never>;
|