oolib 2.105.0 → 2.107.0

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 (25) hide show
  1. package/dist/components/Container/index.d.ts +13 -13
  2. package/dist/components/Container/index.styled.d.ts +6 -1
  3. package/dist/components/Container/index.styled.js +2 -1
  4. package/dist/components/Dropdowns/comps/OptionsSingle/index.js +30 -27
  5. package/dist/components/Dropdowns/comps/VirtualizedWrapper/index.d.ts +7 -0
  6. package/dist/components/Dropdowns/comps/VirtualizedWrapper/index.js +66 -0
  7. package/dist/components/Dropdowns/comps/VirtualizedWrapper/styled.d.ts +1 -0
  8. package/dist/components/Dropdowns/comps/VirtualizedWrapper/styled.js +45 -0
  9. package/dist/components/EmptyStates/comps/EmptyStatesRenderer.js +6 -4
  10. package/dist/components/EmptyStates/comps/styled.d.ts +5 -5
  11. package/dist/components/ResourceInput/comp/ResourceDisplayBlock.js +1 -1
  12. package/dist/components/ResourceInput/index.js +1 -1
  13. package/dist/components/Tooltip/index.d.ts +24 -8
  14. package/dist/components/Tooltip/index.js +16 -5
  15. package/dist/components/Tooltip/styled.d.ts +27 -6
  16. package/dist/components/Tooltip/styled.js +13 -42
  17. package/dist/components/Tooltip/util/index.d.ts +37 -3
  18. package/dist/components/Tooltip/util/index.js +48 -10
  19. package/dist/utils/customHooks/useContainerQuery.d.ts +5 -3
  20. package/dist/utils/customHooks/useContainerQuery.js +2 -2
  21. package/dist/utils/customHooks/useScroll.d.ts +12 -1
  22. package/dist/utils/customHooks/useScroll.js +3 -2
  23. package/dist/utils/usePopOutOfOverflowHiddenParent.d.ts +55 -4
  24. package/dist/utils/usePopOutOfOverflowHiddenParent.js +16 -10
  25. package/package.json +5 -2
@@ -1,13 +1,13 @@
1
- export function Comp({ children, className, style, enableContainerQuery }: {
2
- children: any;
3
- className: any;
4
- style: any;
5
- enableContainerQuery: any;
6
- }, ref: any): React.JSX.Element;
7
- export const Container: React.ForwardRefExoticComponent<{
8
- children: any;
9
- className: any;
10
- style: any;
11
- enableContainerQuery: any;
12
- } & React.RefAttributes<any>>;
13
- import React from "react";
1
+ import React, { CSSProperties, ReactNode } from "react";
2
+ export declare const Comp: ({ children, className, style, enableContainerQuery }: {
3
+ children?: ReactNode;
4
+ className?: string;
5
+ style?: CSSProperties;
6
+ enableContainerQuery?: boolean;
7
+ }, ref: React.RefObject<HTMLDivElement> | null) => React.JSX.Element;
8
+ export declare const Container: React.ForwardRefExoticComponent<{
9
+ children?: ReactNode;
10
+ className?: string;
11
+ style?: CSSProperties;
12
+ enableContainerQuery?: boolean;
13
+ } & React.RefAttributes<HTMLDivElement>>;
@@ -1 +1,6 @@
1
- export const StyledContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
1
+ import { useContainerQuery } from "../../utils/_EXPORTS";
2
+ interface StyledContainerProps {
3
+ containerQuery?: ReturnType<typeof useContainerQuery>['containerQuery'];
4
+ }
5
+ export declare const StyledContainer: import("styled-components").StyledComponent<"div", any, StyledContainerProps, never>;
6
+ export {};
@@ -32,6 +32,7 @@ var styled_components_1 = __importStar(require("styled-components"));
32
32
  var mixins_1 = require("../../themes/mixins");
33
33
  exports.StyledContainer = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: 0 2rem;\n\n ", "\n"], ["\n padding: 0 2rem;\n\n ", "\n"])), function (_a) {
34
34
  var containerQuery = _a.containerQuery;
35
- return containerQuery ? containerQuery('sm')(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 0 6rem\n "], ["\n padding: 0 6rem\n "]))) : (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", " {\n padding: 0 6rem;\n }\n "], ["\n ", " {\n padding: 0 6rem;\n }\n "])), (0, mixins_1.mediaQuery)("sm"));
35
+ return containerQuery
36
+ ? containerQuery('sm')(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 0 6rem;\n "], ["\n padding: 0 6rem;\n "]))) : (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", " {\n padding: 0 6rem;\n }\n "], ["\n ", " {\n padding: 0 6rem;\n }\n "])), (0, mixins_1.mediaQuery)('sm'));
36
37
  });
37
38
  var templateObject_1, templateObject_2, templateObject_3;
@@ -46,6 +46,7 @@ var TextInputs_1 = require("../../../TextInputs");
46
46
  var TextLoader_1 = require("../../../LoadersAndProgress/TextLoader");
47
47
  var useKeyboardControl_1 = require("../../utils/useKeyboardControl");
48
48
  var useSetYOrientation_1 = require("../../utils/useSetYOrientation");
49
+ var VirtualizedWrapper_1 = require("../VirtualizedWrapper");
49
50
  /**
50
51
  * if used independently, must be used inside a 'position: relative/absolute' div.
51
52
  */
@@ -86,32 +87,34 @@ var OptionsSingle = function (_a) {
86
87
  react_1.default.createElement("div", { style: { padding: "1rem" } },
87
88
  react_1.default.createElement(TextInputs_1.TextInput, { invert: invert, forceFocus: searchBarFocus, type: "text", icon: "MagnifyingGlass", value: searchString, onChange: function (k, v) { return setSearchString(v); }, S: S })),
88
89
  react_1.default.createElement(Divider_1.Divider, { invert: invert }))); };
89
- return (react_1.default.createElement(OptionsShell_1.OptionsShell, __assign({ ref: optionsRef }, {
90
- yOrientation: yOrientation,
91
- lightboxHeight: lightboxHeight,
92
- lightboxStyle: lightboxStyle,
93
- options: options,
94
- optionsAnchor: optionsAnchor,
95
- showOptions: showOptions,
96
- SelectComp: SelectComp,
97
- handleHideOptions: handleHideOptions,
98
- label: label,
99
- optionsModalLabel: optionsModalLabel,
100
- invert: invert,
101
- relativeToRef: relativeToRef,
102
- popOutOfOverflowHiddenParent: popOutOfOverflowHiddenParent,
103
- S: S
104
- }),
105
- isSearchable && genSearchBar(),
106
- options.length === 0
107
- ? react_1.default.createElement(NoOptionResultsComp_1.NoOptionResultsComp, { S: S })
108
- : options.map(function (d, i) {
109
- return (react_1.default.createElement(styled_1.StyledOption, { key: d.value, invert: invert, isSelected: !d.loading && (value === null || value === void 0 ? void 0 : value.value) === d.value, isFocussed: focussedOp === i, className: 'OKE-Dropdown__option', ref: function (el) { return focussedOp === i && el && scrollFocussedOpIntoView(el); }, onClick: function (e) {
110
- if (!d.loading)
111
- handleSelect(d);
112
- setSearchString && setSearchString('');
113
- }, S: S }, d.loading ? (react_1.default.createElement(TextLoader_1.TextLoader, { style: { width: "8rem", height: "1.5rem" } })) : (react_1.default.createElement(OptionContent_1.OptionContent, __assign({}, { option: d, optionsClassName: optionsClassName, invert: invert, S: S })))));
114
- }),
115
- genCreateTagButton && genCreateTagButton(options)));
90
+ return (react_1.default.createElement(react_1.default.Fragment, null,
91
+ react_1.default.createElement(OptionsShell_1.OptionsShell, __assign({ ref: optionsRef }, {
92
+ yOrientation: yOrientation,
93
+ lightboxHeight: lightboxHeight,
94
+ lightboxStyle: lightboxStyle,
95
+ options: options,
96
+ optionsAnchor: optionsAnchor,
97
+ showOptions: showOptions,
98
+ SelectComp: SelectComp,
99
+ handleHideOptions: handleHideOptions,
100
+ label: label,
101
+ optionsModalLabel: optionsModalLabel,
102
+ invert: invert,
103
+ relativeToRef: relativeToRef,
104
+ popOutOfOverflowHiddenParent: popOutOfOverflowHiddenParent,
105
+ S: S
106
+ }),
107
+ isSearchable && genSearchBar(),
108
+ options.length === 0 ?
109
+ react_1.default.createElement(NoOptionResultsComp_1.NoOptionResultsComp, { S: S })
110
+ :
111
+ react_1.default.createElement(VirtualizedWrapper_1.VirtualizedWrapper, { options: options, lightboxHeight: lightboxHeight, searchString: searchString }, function (option, index, style) {
112
+ return react_1.default.createElement(styled_1.StyledOption, { key: option.value, invert: invert, isSelected: !option.loading && (value === null || value === void 0 ? void 0 : value.value) === option.value, isFocussed: focussedOp === index, className: 'OKE-Dropdown__option', ref: function (el) { return focussedOp === index && el && scrollFocussedOpIntoView(el); }, onClick: function (e) {
113
+ if (!option.loading)
114
+ handleSelect(option);
115
+ setSearchString && setSearchString('');
116
+ }, S: S, style: style && style }, option.loading ? (react_1.default.createElement(TextLoader_1.TextLoader, { style: { width: "8rem", height: "1.5rem" } })) : (react_1.default.createElement(OptionContent_1.OptionContent, __assign({}, { option: option, optionsClassName: optionsClassName, invert: invert, S: S }))));
117
+ }),
118
+ genCreateTagButton && genCreateTagButton(options))));
116
119
  };
117
120
  exports.OptionsSingle = OptionsSingle;
@@ -0,0 +1,7 @@
1
+ export function VirtualizedWrapper({ children, options, lightboxHeight, searchString }: {
2
+ children: any;
3
+ options: any;
4
+ lightboxHeight: any;
5
+ searchString: any;
6
+ }): React.JSX.Element;
7
+ import React from "react";
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.VirtualizedWrapper = void 0;
27
+ var react_1 = __importStar(require("react"));
28
+ var styled_1 = require("./styled");
29
+ var react_virtualized_1 = require("react-virtualized");
30
+ var VirtualizedWrapper = function (_a) {
31
+ var children = _a.children, options = _a.options, lightboxHeight = _a.lightboxHeight, searchString = _a.searchString;
32
+ // Create a cache for measuring row heights
33
+ var cache = (0, react_1.useRef)(new react_virtualized_1.CellMeasurerCache({
34
+ fixedWidth: true,
35
+ defaultHeight: 50, // default height for each row before height is calculated
36
+ }));
37
+ (0, react_1.useEffect)(function () {
38
+ }, [options.length, searchString]);
39
+ return (react_1.default.createElement(react_1.default.Fragment, null, options.length > 30 ?
40
+ react_1.default.createElement(styled_1.StyledOptionsShellWrapper, { lightboxHeight: lightboxHeight },
41
+ react_1.default.createElement(react_virtualized_1.AutoSizer, null, function (_a) {
42
+ var width = _a.width, height = _a.height;
43
+ return (react_1.default.createElement(react_virtualized_1.List, { width: width, height: height, rowHeight: cache.current.rowHeight, deferredMeasurementCache: cache.current, rowCount: options.length, rowRenderer: function (_a) {
44
+ var key = _a.key, index = _a.index, style = _a.style, parent = _a.parent;
45
+ var option = options[index];
46
+ return (react_1.default.createElement(react_virtualized_1.CellMeasurer, { key: key, cache: cache.current, parent: parent, columnIndex: 0, rowIndex: index }, children(option, index, style)));
47
+ } }));
48
+ }))
49
+ :
50
+ options.map(function (option, index) { return (children(option, index)); })));
51
+ };
52
+ exports.VirtualizedWrapper = VirtualizedWrapper;
53
+ // ################ AutoSizer #######
54
+ // The AutoSizer component is used to automatically calculate and adjust
55
+ // the size of its child components based on the available space.
56
+ // It wraps around the List component to dynamically resize the list based on the dimensions of its parent container.
57
+ // ################ List ##########
58
+ // The List component is a virtualized list that efficiently renders a
59
+ // large number of items by only rendering the visible items on the screen.
60
+ // It accepts a rowCount prop to specify the total number of items in the list,
61
+ // and a rowRenderer prop to define how each item should be rendered.
62
+ // ################ Cell Measurer #############
63
+ // The CellMeasurer component is used within the rowRenderer function
64
+ // to measure the dimensions of each item in the list.
65
+ // It calculates the height and width of each cell and provides this information to the List component,
66
+ // allowing it to efficiently render the list with variable-sized items.
@@ -0,0 +1 @@
1
+ export const StyledOptionsShellWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || function (mod) {
23
+ if (mod && mod.__esModule) return mod;
24
+ var result = {};
25
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26
+ __setModuleDefault(result, mod);
27
+ return result;
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.StyledOptionsShellWrapper = void 0;
31
+ var styled_components_1 = __importStar(require("styled-components"));
32
+ var mixins_1 = require("../../../../themes/mixins");
33
+ exports.StyledOptionsShellWrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n width: 100%;\n \n ", " {\n width: 36rem;\n }\n height: ", ";\n\n"], ["\n \n width: 100%;\n \n ", " {\n width: 36rem;\n }\n height: ", ";\n\n"])), (0, mixins_1.mediaQuery)("md"), function (_a) {
34
+ var lightboxHeight = _a.lightboxHeight;
35
+ switch (lightboxHeight) {
36
+ case 'large':
37
+ return '33rem';
38
+ case 'small':
39
+ return '20rem';
40
+ case 'medium':
41
+ default:
42
+ return '24rem';
43
+ }
44
+ });
45
+ var templateObject_1;
@@ -36,6 +36,7 @@ var ThumbsUpSVG_1 = require("../PublishedSucccessful/comps/ThumbsUpSVG");
36
36
  var _EXPORTS_1 = require("../../../utils/_EXPORTS");
37
37
  var mixins_1 = require("../../../themes/mixins");
38
38
  var PublishedSuccessfullySVGShapes_1 = require("../PublishedSucccessful/comps/PublishedSuccessfullySVGShapes");
39
+ var utilsOolib_1 = require("../../../utilsOolib");
39
40
  var EmptyStatesRenderer = function (_a) {
40
41
  var _image = _a.image, _b = _a.align, align = _b === void 0 ? "center" : _b, _title = _a.title, _subtitle = _a.subtitle, link = _a.link, button = _a.button, onClick = _a.onClick, preset = _a.preset;
41
42
  var imagesLookup = {
@@ -50,6 +51,7 @@ var EmptyStatesRenderer = function (_a) {
50
51
  searchDashBoardListing: searchDashBoardListing_svg_1.default,
51
52
  dashboardListing: dashboardListing_svg_1.default,
52
53
  };
54
+ var localize = (0, utilsOolib_1.useLocale)();
53
55
  //basically image prop can be either the src string or an object with more properties
54
56
  var image = typeof _image === "string" ? { src: _image } : _image; // src + style
55
57
  var title = typeof _title === "string" ? { text: _title } : _title; // text + style
@@ -63,10 +65,10 @@ var EmptyStatesRenderer = function (_a) {
63
65
  preset === "successFullyPublish" &&
64
66
  react_1.default.createElement(styled_2.StyledPublishedSVGWrapper, null,
65
67
  react_1.default.createElement(ThumbsUpSVG_1.ThumbsUpSVG, null)),
66
- (title === null || title === void 0 ? void 0 : title.text) && (react_1.default.createElement(styled_1.StyledSERIF_4_5, { style: title.style, preset: preset }, title.text)),
67
- (subtitle === null || subtitle === void 0 ? void 0 : subtitle.text) && (react_1.default.createElement(Typo_1.SANS_3, { style: subtitle.style }, subtitle.text)),
68
+ (title === null || title === void 0 ? void 0 : title.text) && (react_1.default.createElement(styled_1.StyledSERIF_4_5, { style: title.style, preset: preset }, localize(title.text))),
69
+ (subtitle === null || subtitle === void 0 ? void 0 : subtitle.text) && (react_1.default.createElement(Typo_1.SANS_3, { style: subtitle.style }, localize(subtitle.text))),
68
70
  link && (react_1.default.createElement(Typo_1.SANS_3, { style: { paddingTop: '1rem' } },
69
- react_1.default.createElement(OKELink_1.OKELink, { text: link.text, onClick: onClick }))),
70
- button && (react_1.default.createElement(Buttons_1.ButtonPrimary, { onClick: onClick, style: { marginTop: "2rem" } }, button.text)))));
71
+ react_1.default.createElement(OKELink_1.OKELink, { text: localize(link.text), onClick: onClick }))),
72
+ button && (react_1.default.createElement(Buttons_1.ButtonPrimary, { onClick: onClick, style: { marginTop: "2rem" } }, localize(button.text))))));
71
73
  };
72
74
  exports.EmptyStatesRenderer = EmptyStatesRenderer;
@@ -1,8 +1,8 @@
1
1
  export const StyledSERIF_4_5: import("styled-components").StyledComponent<(props: any) => import("react").JSX.Element, any, {}, never>;
2
2
  export const StyledFlexWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
3
3
  export const StyledContainer: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<{
4
- children: any;
5
- className: any;
6
- style: any;
7
- enableContainerQuery: any;
8
- } & import("react").RefAttributes<any>>, any, {}, never>;
4
+ children?: import("react").ReactNode;
5
+ className?: string;
6
+ style?: import("react").CSSProperties;
7
+ enableContainerQuery?: boolean;
8
+ } & import("react").RefAttributes<HTMLDivElement>>, any, {}, never>;
@@ -95,7 +95,7 @@ var ResourceDisplayBlock = function (_a) {
95
95
  resources.map(function (file) { return (react_1.default.createElement(styled_1.StyledBlock, { style: { position: 'relative' }, invert: invert, key: file === null || file === void 0 ? void 0 : file.id },
96
96
  genResourceBlock(file),
97
97
  react_1.default.createElement("div", { style: { position: 'absolute', top: '0', right: '0' } },
98
- react_1.default.createElement(ActionMenu_1.ActionMenu, { popOutOfOverflowHiddenParent: true, ButtonComp: "ButtonPrimary", invert: invert, actions: [
98
+ react_1.default.createElement(ActionMenu_1.ActionMenu, { ButtonComp: "ButtonPrimary", invert: invert, actions: [
99
99
  {
100
100
  display: "Delete",
101
101
  onClick: function () { return removeResource(file === null || file === void 0 ? void 0 : file.id); },
@@ -61,7 +61,7 @@ var ResourceInput = function (props) {
61
61
  var SET_ALERT_BANNER = (0, bannerContext_1.useBannerContext)().SET_ALERT_BANNER;
62
62
  var _c = (0, react_1.useState)(undefined), uploadProgress = _c[0], setUploadProgress = _c[1];
63
63
  var _d = (0, react_1.useState)(0), filesLength = _d[0], setFilesLength = _d[1];
64
- var _e = (0, react_1.useState)(__spreadArray([], value, true)), resources = _e[0], setResources = _e[1];
64
+ var _e = (0, react_1.useState)(value ? __spreadArray([], value, true) : []), resources = _e[0], setResources = _e[1];
65
65
  var handleUploadProgess = function (progress) { return setUploadProgress(progress); };
66
66
  var upload = ((theme === null || theme === void 0 ? void 0 : theme.useUploadMedia({
67
67
  mediaConfigs: {
@@ -1,11 +1,27 @@
1
- export function Tooltip({ text, position, style, children, popOutOfOverflowHiddenParent, invert, debug, presetTarget, }: {
2
- text: any;
3
- position?: string;
4
- style: any;
5
- children: any;
1
+ import React from "react";
2
+ interface TooltipProps {
3
+ text: string;
4
+ position?: 'top' | 'bottom' | 'left' | 'right';
5
+ style?: React.CSSProperties;
6
+ children: React.ReactNode;
6
7
  popOutOfOverflowHiddenParent?: boolean;
7
8
  invert?: boolean;
8
9
  debug?: boolean;
9
- presetTarget: any;
10
- }): React.JSX.Element;
11
- import React from "react";
10
+ presetTarget?: 'infoIcon';
11
+ }
12
+ /**
13
+ * Renders a tooltip component with customizable text and styling.
14
+ *
15
+ * @param props - The props object containing the following properties:
16
+ * - text: The text to be displayed in the tooltip.
17
+ * - position: The position of the tooltip relative to the target element. Defaults to "top".
18
+ * - style: Additional CSS styles to apply to the tooltip.
19
+ * - children: The content to be rendered inside the tooltip target element.
20
+ * - popOutOfOverflowHiddenParent: A boolean indicating whether the tooltip should pop out of an overflow:hidden parent element. Defaults to false.
21
+ * - invert: A boolean indicating whether to invert the tooltip colors. Defaults to false.
22
+ * - debug: A boolean indicating whether to enable debug mode for the tooltip. Defaults to false.
23
+ * - presetTarget: A string indicating a preset target for the tooltip. Defaults to infoIcon.
24
+ * @return {ReactElement} The rendered tooltip component.
25
+ */
26
+ export declare const Tooltip: React.FunctionComponent<TooltipProps>;
27
+ export {};
@@ -41,6 +41,20 @@ var themes_1 = require("../../themes");
41
41
  var usePopOutOfOverflowHiddenParent_1 = require("../../utils/usePopOutOfOverflowHiddenParent");
42
42
  var Typo_1 = require("../Typo");
43
43
  var styled_1 = require("./styled");
44
+ /**
45
+ * Renders a tooltip component with customizable text and styling.
46
+ *
47
+ * @param props - The props object containing the following properties:
48
+ * - text: The text to be displayed in the tooltip.
49
+ * - position: The position of the tooltip relative to the target element. Defaults to "top".
50
+ * - style: Additional CSS styles to apply to the tooltip.
51
+ * - children: The content to be rendered inside the tooltip target element.
52
+ * - popOutOfOverflowHiddenParent: A boolean indicating whether the tooltip should pop out of an overflow:hidden parent element. Defaults to false.
53
+ * - invert: A boolean indicating whether to invert the tooltip colors. Defaults to false.
54
+ * - debug: A boolean indicating whether to enable debug mode for the tooltip. Defaults to false.
55
+ * - presetTarget: A string indicating a preset target for the tooltip. Defaults to infoIcon.
56
+ * @return {ReactElement} The rendered tooltip component.
57
+ */
44
58
  var Tooltip = function (_a) {
45
59
  var text = _a.text, _b = _a.position, position = _b === void 0 ? "top" : _b, style = _a.style, children = _a.children, _c = _a.popOutOfOverflowHiddenParent, popOutOfOverflowHiddenParent = _c === void 0 ? false : _c, _d = _a.invert, invert = _d === void 0 ? false : _d, _e = _a.debug, debug = _e === void 0 ? false : _e, presetTarget = _a.presetTarget;
46
60
  var _f = (0, react_1.useState)(debug ? true : false), isClicked = _f[0], setIsClicked = _f[1];
@@ -73,13 +87,10 @@ var Tooltip = function (_a) {
73
87
  setIsClicked(true), setShowTooltip(true);
74
88
  }, onBlur: function () {
75
89
  setIsClicked(false), setShowTooltip(false);
76
- }, ref: targetRef,
77
- // isFocused={isFocused}
78
- tabIndex: 0 }, presetTarget === "infoIcon" ? (react_1.default.createElement(styled_1.StyledIconButton, { type: showTooltip ? "none" : "fill" },
90
+ }, ref: targetRef, tabIndex: 0 }, presetTarget === "infoIcon" ? (react_1.default.createElement(styled_1.StyledIconButton, null,
79
91
  react_1.default.createElement(phosphor_react_1.Info, { color: invert ? themes_1.colors.white : themes_1.colors.greyColor100, size: 20, weight: showTooltip ? 'fill' : 'regular' }))) : (children)),
80
92
  showTooltip && (react_1.default.createElement(styled_1.StyledTooltipBox, { fixPos: fixPos, isOpen: showTooltip, position: position, show: showTooltip, style: style, invert: invert },
81
- text.split('\n').filter(Boolean).map(function (singleline, i) { return ( // this detects line breaks in text and renders them properly
82
- react_1.default.createElement(Typo_1.SANS_2, __assign({}, (i !== 0 ? { style: { marginTop: '0.5rem' } } : {})), singleline)); }),
93
+ text.split('\n').filter(Boolean).map(function (singleline, i) { return (react_1.default.createElement(Typo_1.SANS_2, __assign({}, (i !== 0 ? { style: { marginTop: '0.5rem' } } : {})), singleline)); }),
83
94
  react_1.default.createElement(styled_1.StyledArrowOutline, { position: position },
84
95
  react_1.default.createElement(styled_1.StyledArrow, { position: position, invert: invert }))))));
85
96
  };
@@ -1,6 +1,27 @@
1
- export const StyledWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export const StyledTooltipBox: import("styled-components").StyledComponent<"div", any, {}, never>;
3
- export const StyledTooltipTarget: import("styled-components").StyledComponent<"button", any, {}, never>;
4
- export const StyledArrowOutline: import("styled-components").StyledComponent<"span", any, {}, never>;
5
- export const StyledArrow: import("styled-components").StyledComponent<"span", any, {}, never>;
6
- export const StyledIconButton: import("styled-components").StyledComponent<"button", any, {}, never>;
1
+ export declare const StyledWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ interface StyledTooltipBoxProps {
3
+ show: boolean;
4
+ invert: boolean;
5
+ fixPos?: {
6
+ x: number;
7
+ y: number;
8
+ } | undefined;
9
+ position: string;
10
+ isOpen: boolean;
11
+ }
12
+ export declare const StyledTooltipBox: import("styled-components").StyledComponent<"div", any, StyledTooltipBoxProps, never>;
13
+ interface StyledTooltipTargetProps {
14
+ isFocused?: boolean;
15
+ }
16
+ export declare const StyledTooltipTarget: import("styled-components").StyledComponent<"button", any, StyledTooltipTargetProps, never>;
17
+ interface StyledArrowOutlineProps {
18
+ position: string;
19
+ }
20
+ export declare const StyledArrowOutline: import("styled-components").StyledComponent<"span", any, StyledArrowOutlineProps, never>;
21
+ interface StyledArrowProps {
22
+ position: string;
23
+ invert: boolean;
24
+ }
25
+ export declare const StyledArrow: import("styled-components").StyledComponent<"span", any, StyledArrowProps, never>;
26
+ export declare const StyledIconButton: import("styled-components").StyledComponent<"button", any, {}, never>;
27
+ export {};
@@ -3,36 +3,15 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
3
3
  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
4
  return cooked;
5
5
  };
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
- Object.defineProperty(o, "default", { enumerable: true, value: v });
19
- }) : function(o, v) {
20
- o["default"] = v;
21
- });
22
- var __importStar = (this && this.__importStar) || function (mod) {
23
- if (mod && mod.__esModule) return mod;
24
- var result = {};
25
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26
- __setModuleDefault(result, mod);
27
- return result;
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
8
  };
29
9
  Object.defineProperty(exports, "__esModule", { value: true });
30
10
  exports.StyledIconButton = exports.StyledArrow = exports.StyledArrowOutline = exports.StyledTooltipTarget = exports.StyledTooltipBox = exports.StyledWrapper = void 0;
31
- var styled_components_1 = __importStar(require("styled-components"));
11
+ var styled_components_1 = __importDefault(require("styled-components"));
32
12
  var themes_1 = require("../../themes");
33
13
  var mixins_1 = require("../../themes/mixins");
34
14
  var util_1 = require("./util");
35
- exports.StyledWrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative; // made this wrapper with styled.component to ensure its\n width: fit-content; // engine will make this 'fit-content' compatible with firefox/safari\n text-align: left;\n cursor: pointer;\n"], ["\n position: relative; // made this wrapper with styled.component to ensure its\n width: fit-content; // engine will make this 'fit-content' compatible with firefox/safari\n text-align: left;\n cursor: pointer;\n"])));
36
15
  var greyColor15 = themes_1.colors.greyColor15, greyColor100 = themes_1.colors.greyColor100, white = themes_1.colors.white, greyColor10 = themes_1.colors.greyColor10;
37
16
  var clipPaths = {
38
17
  top: "0% 0%, 47% 65.4%, 52% 65.4%, 100% 0",
@@ -40,27 +19,19 @@ var clipPaths = {
40
19
  right: '100% 0%, 50% 47%, 50% 52%, 100% 100%',
41
20
  left: '0% 0%, 50% 47%, 50% 52%, 0% 100%',
42
21
  };
43
- exports.StyledTooltipBox = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", ";\n ", "\n\n padding: 1rem;\n background-color: ", ";\n color: ", ";\n border: 1px solid ", ";\n border-radius: 5px;\n /* position: ", "; */\n /* left: ", "px; */\n /* top: ", "px; */\n z-index: 50000000;\n ", "\n width: max-content;\n max-width: 20rem;\n word-wrap:break-word;\n"], ["\n ", ";\n ", "\n\n padding: 1rem;\n background-color: ", ";\n color: ", ";\n border: 1px solid ", ";\n border-radius: 5px;\n /* position: ", "; */\n /* left: ", "px; */\n /* top: ", "px; */\n z-index: 50000000;\n ", "\n width: max-content;\n max-width: 20rem;\n word-wrap:break-word;\n"])), function (_a) {
44
- var show = _a.show;
45
- return show ? (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["display:'visible'; z-index: 5000000;"], ["display:'visible'; z-index: 5000000;"]))) : (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["display:'none'; z-index: -5;"], ["display:'none'; z-index: -5;"])));
46
- }, (0, mixins_1.transition)('opacity 0.1s'), function (props) { return props.invert ? greyColor10 : greyColor100; }, function (props) { return props.invert ? greyColor100 : white; }, greyColor15, function (props) { return !props.fixPos ? 'fixed' : 'absolute'; }, function (props) { var _a; return (_a = props.fixPos) === null || _a === void 0 ? void 0 : _a.x; }, function (props) { var _a; return (_a = props.fixPos) === null || _a === void 0 ? void 0 : _a.y; }, function (_a) {
22
+ exports.StyledWrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n width: fit-content;\n text-align: left;\n cursor: pointer;\n"], ["\n position: relative;\n width: fit-content;\n text-align: left;\n cursor: pointer;\n"])));
23
+ exports.StyledTooltipBox = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: ", ";\n z-index: ", ";\n ", "\n\n padding: 1rem;\n background-color: ", ";\n color: ", ";\n border: 1px solid ", ";\n border-radius: 5px;\n z-index: 50000000;\n ", "\n width: max-content;\n max-width: 20rem;\n word-wrap: break-word;\n"], ["\n display: ", ";\n z-index: ", ";\n ", "\n\n padding: 1rem;\n background-color: ", ";\n color: ", ";\n border: 1px solid ", ";\n border-radius: 5px;\n z-index: 50000000;\n ", "\n width: max-content;\n max-width: 20rem;\n word-wrap: break-word;\n"])), function (props) { return (props.show ? "block" : "none"); }, function (props) { return (props.show ? 5000000 : -5); }, (0, mixins_1.transition)("opacity 0.1s"), function (props) { return (props.invert ? greyColor10 : greyColor100); }, function (props) { return (props.invert ? greyColor100 : white); }, greyColor15, function (_a) {
47
24
  var position = _a.position, fixPos = _a.fixPos;
48
- return (0, util_1.positionTooltip)(position, fixPos);
25
+ return (0, util_1.positionTooltip)({ position: position, fixPos: fixPos });
49
26
  });
50
- exports.StyledTooltipTarget = styled_components_1.default.button(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n border: none;\n background: inherit;\n font-size: inherit;\n /* color: inherit; */\n cursor: inherit;\n /* background : ", "; */\n /* color : ", "; */\n /* border-radius : ", "; */\n /* border-radius: 2px; */\n"], ["\n border: none;\n background: inherit;\n font-size: inherit;\n /* color: inherit; */\n cursor: inherit;\n /* background : ", "; */\n /* color : ", "; */\n /* border-radius : ", "; */\n /* border-radius: 2px; */\n"])), function (props) { return props.isFocused ? greyColor100 : 'none'; }, function (props) { return props.isFocused ? 'white' : 'inherit'; }, function (props) { return props.isFocused ? '50%' : 'none'; });
51
- exports.StyledArrowOutline = styled_components_1.default.span(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n background-color: ", ";\n width: 1rem;\n height: 1rem;\n position: absolute;\n clip-path: polygon(", ");\n ", ";\n"], ["\n background-color: ", ";\n width: 1rem;\n height: 1rem;\n position: absolute;\n clip-path: polygon(", ");\n ", ";\n"])), greyColor15, function (_a) {
27
+ exports.StyledTooltipTarget = styled_components_1.default.button(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n border: none;\n background: inherit;\n font-size: inherit;\n"], ["\n border: none;\n background: inherit;\n font-size: inherit;\n"])));
28
+ exports.StyledArrowOutline = styled_components_1.default.span(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background-color: ", ";\n width: 1rem;\n height: 1rem;\n position: absolute;\n clip-path: polygon(", ");\n ", ";\n"], ["\n background-color: ", ";\n width: 1rem;\n height: 1rem;\n position: absolute;\n clip-path: polygon(", ");\n ", ";\n"])), greyColor15, function (_a) {
52
29
  var position = _a.position;
53
30
  return clipPaths[position];
54
- }, function (_a) {
55
- var position = _a.position;
56
- return (0, util_1.positionArrowBorder)(position);
57
- });
58
- exports.StyledArrow = styled_components_1.default.span(templateObject_7 || (templateObject_7 = __makeTemplateObject([" // the the white part\n background-color: ", ";\n color: ", ";\n display:inline-block;\n width: 0.85rem;\n height: 0.85rem;\n position: absolute;\n clip-path: polygon(", ");\n ", ";\n"], [" // the the white part\n background-color: ", ";\n color: ", ";\n display:inline-block;\n width: 0.85rem;\n height: 0.85rem;\n position: absolute;\n clip-path: polygon(", ");\n ", ";\n"])), function (props) { return props.invert ? greyColor10 : greyColor100; }, function (props) { return props.invert ? greyColor100 : white; }, function (_a) {
31
+ }, util_1.positionArrowBorder);
32
+ exports.StyledArrow = styled_components_1.default.span(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n background-color: ", ";\n color: ", ";\n display: inline-block;\n width: 0.85rem;\n height: 0.85rem;\n position: absolute;\n clip-path: polygon(", ");\n ", ";\n"], ["\n background-color: ", ";\n color: ", ";\n display: inline-block;\n width: 0.85rem;\n height: 0.85rem;\n position: absolute;\n clip-path: polygon(", ");\n ", ";\n"])), function (props) { return (props.invert ? greyColor10 : greyColor100); }, function (props) { return (props.invert ? greyColor100 : white); }, function (_a) {
59
33
  var position = _a.position;
60
34
  return clipPaths[position];
61
- }, function (_a) {
62
- var position = _a.position;
63
- return (0, util_1.positionArrow)(position);
64
- });
65
- exports.StyledIconButton = styled_components_1.default.button(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n background-color: ", ";\n border: none; \n outline: none; \n cursor: pointer;\n"], ["\n background-color: ", ";\n border: none; \n outline: none; \n cursor: pointer;\n"])), themes_1.colors.none);
66
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
35
+ }, util_1.positionArrow);
36
+ exports.StyledIconButton = styled_components_1.default.button(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n background-color: ", ";\n border: none;\n outline: none;\n cursor: pointer;\n"], ["\n background-color: ", ";\n border: none;\n outline: none;\n cursor: pointer;\n"])), themes_1.colors.none);
37
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
@@ -1,3 +1,37 @@
1
- export function positionTooltip(position: any, fixPos: any): import("styled-components").FlattenSimpleInterpolation;
2
- export function positionArrowBorder(position: any): import("styled-components").FlattenSimpleInterpolation;
3
- export function positionArrow(position: any): import("styled-components").FlattenSimpleInterpolation;
1
+ import { CSSObject } from "styled-components";
2
+ interface PositionTooltipProps {
3
+ position: string;
4
+ fixPos?: {
5
+ x: number;
6
+ y: number;
7
+ } | undefined;
8
+ }
9
+ interface PositionArrowBorderProps {
10
+ position: string;
11
+ }
12
+ interface PositionArrowProps {
13
+ position: string;
14
+ }
15
+ /**
16
+ * Generates the CSS object for positioning a tooltip based on the provided position and fix position.
17
+ *
18
+ * @param {PositionTooltipProps} position - The position of the tooltip ('top', 'bottom', 'left', 'right').
19
+ * @param {PositionTooltipProps} fixPos - The fix position of the tooltip. If provided, the tooltip will be fixed at this position.
20
+ * @return {CSSObject} The CSS object for positioning the tooltip.
21
+ */
22
+ export declare const positionTooltip: ({ position, fixPos, }: PositionTooltipProps) => CSSObject;
23
+ /**
24
+ * Generates the CSS object for positioning the arrow border based on the given position.
25
+ *
26
+ * @param {PositionArrowBorderProps} position - The position of the arrow border.
27
+ * @return {CSSObject} The CSS object for positioning the arrow border.
28
+ */
29
+ export declare const positionArrowBorder: ({ position, }: PositionArrowBorderProps) => CSSObject;
30
+ /**
31
+ * Generates the CSS object for positioning the arrow based on the given position.
32
+ *
33
+ * @param {PositionArrowProps} position - The position of the arrow.
34
+ * @return {CSSObject} The CSS object for positioning the arrow.
35
+ */
36
+ export declare const positionArrow: ({ position, }: PositionArrowProps) => CSSObject;
37
+ export {};
@@ -6,16 +6,26 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.positionArrow = exports.positionArrowBorder = exports.positionTooltip = void 0;
8
8
  var styled_components_1 = require("styled-components");
9
- var positionTooltip = function (position, fixPos) {
9
+ /**
10
+ * Generates the CSS object for positioning a tooltip based on the provided position and fix position.
11
+ *
12
+ * @param {PositionTooltipProps} position - The position of the tooltip ('top', 'bottom', 'left', 'right').
13
+ * @param {PositionTooltipProps} fixPos - The fix position of the tooltip. If provided, the tooltip will be fixed at this position.
14
+ * @return {CSSObject} The CSS object for positioning the tooltip.
15
+ */
16
+ // This function calculates the CSS styles for positioning a tooltip based on the given position and fixPos values
17
+ var positionTooltip = function (_a) {
18
+ var position = _a.position, fixPos = _a.fixPos;
10
19
  switch (position) {
11
20
  case 'top':
12
21
  if (fixPos) {
13
- return (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: fixed;\n top: ", "px;\n left: ", "px;\n transform: translateX(-50%);\n "], ["\n position: fixed;\n top: ", "px;\n left: ", "px;\n transform: translateX(-50%);\n "])), fixPos.y - 50, fixPos.x + 10);
22
+ // If fixPos is truthy, return CSS styles for a fixed position tooltip
23
+ return (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: fixed;\n top: ", "px;\n left: ", "px;\n transform: translateX(-50%);\n "], ["\n position: fixed;\n top: ", "px;\n left: ", "px;\n transform: translateX(-50%);\n "])), fixPos.y - 50, fixPos.x + 10);
14
24
  }
15
- return (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n bottom: calc(100% + 8.5px);\n left: 50%;\n transform: translateX(-50%);\n "], ["\n position: absolute;\n bottom: calc(100% + 8.5px);\n left: 50%;\n transform: translateX(-50%);\n "])));
25
+ return (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n // If fixPos is falsy, return CSS styles for an absolute position tooltip\n position: absolute;\n bottom: calc(100% + 8.5px);\n left: 50%;\n transform: translateX(-50%);\n "], ["\n // If fixPos is falsy, return CSS styles for an absolute position tooltip\n position: absolute;\n bottom: calc(100% + 8.5px);\n left: 50%;\n transform: translateX(-50%);\n "])));
16
26
  case 'bottom':
17
27
  if (fixPos) {
18
- return (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: fixed;\n top: ", "px;\n left: ", "px;\n transform: translateX(-50%);\n "], ["\n position: fixed;\n top: ", "px;\n left: ", "px;\n transform: translateX(-50%);\n "])), fixPos.y + 30, fixPos.x + 12);
28
+ return (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: fixed;\n top: ", "px;\n left: ", "px;\n transform: translateX(-50%);\n "], ["\n position: fixed;\n top: ", "px;\n left: ", "px;\n transform: translateX(-50%);\n "])), fixPos.y + 30, fixPos.x + 12);
19
29
  }
20
30
  return (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: absolute;\n top: calc(100% + 8.5px);\n left: 50%;\n transform: translateX(-50%);\n "], ["\n position: absolute;\n top: calc(100% + 8.5px);\n left: 50%;\n transform: translateX(-50%);\n "])));
21
31
  case 'left':
@@ -28,28 +38,56 @@ var positionTooltip = function (position, fixPos) {
28
38
  return (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n position: fixed;\n top: ", "px;\n left: ", "px;\n transform: translateY(-50%);\n "], ["\n position: fixed;\n top: ", "px;\n left: ", "px;\n transform: translateY(-50%);\n "])), fixPos.y + 8.5, fixPos.x + 30);
29
39
  }
30
40
  return (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n position: absolute;\n left: calc(100% + 8.5px);\n top: 50%;\n transform: translateY(-50%);\n "], ["\n position: absolute;\n left: calc(100% + 8.5px);\n top: 50%;\n transform: translateY(-50%);\n "])));
41
+ default:
42
+ return {};
31
43
  }
32
44
  };
33
45
  exports.positionTooltip = positionTooltip;
34
- var positionArrowBorder = function (position) {
46
+ /**
47
+ * Generates the CSS object for positioning the arrow border based on the given position.
48
+ *
49
+ * @param {PositionArrowBorderProps} position - The position of the arrow border.
50
+ * @return {CSSObject} The CSS object for positioning the arrow border.
51
+ */
52
+ var positionArrowBorder = function (_a) {
53
+ var position = _a.position;
54
+ // Check the position of the arrow border
35
55
  switch (position) {
36
56
  case 'top':
37
57
  case 'bottom':
38
- return (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n ", ";\n left: 50%;\n transform: translateX(-5px); // 13/2 - 1.5 of the arrow itself \n "], ["\n ", ";\n left: 50%;\n transform: translateX(-5px); // 13/2 - 1.5 of the arrow itself \n "])), position + ': 100%');
58
+ // Position the arrow border at the top or bottom of the tooltip
59
+ return (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n ", ": 100%;\n left: 50%;\n transform: translateX(-5px);\n "], ["\n ", ": 100%;\n left: 50%;\n transform: translateX(-5px);\n "])), position);
39
60
  case 'left':
40
61
  case 'right':
41
- return (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n ", ";\n top: 50%;\n transform: translateY(-5px); // 13/2\n "], ["\n ", ";\n top: 50%;\n transform: translateY(-5px); // 13/2\n "])), position + ': 100%');
62
+ // Position the arrow border at the left or right of the tooltip
63
+ return (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n ", ": 100%;\n top: 50%;\n transform: translateY(-5px);\n "], ["\n ", ": 100%;\n top: 50%;\n transform: translateY(-5px);\n "])), position);
64
+ default:
65
+ // Return an empty object if the position is not recognized
66
+ return {};
42
67
  }
43
68
  };
44
69
  exports.positionArrowBorder = positionArrowBorder;
45
- var positionArrow = function (position) {
70
+ /**
71
+ * Generates the CSS object for positioning the arrow based on the given position.
72
+ *
73
+ * @param {PositionArrowProps} position - The position of the arrow.
74
+ * @return {CSSObject} The CSS object for positioning the arrow.
75
+ */
76
+ var positionArrow = function (_a) {
77
+ var position = _a.position;
78
+ // Check the position value
46
79
  switch (position) {
47
80
  case 'top':
48
81
  case 'bottom':
49
- return (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n ", ";\n left: 8%;\n "], ["\n ", ";\n left: 8%;\n "])), position + ': -2%');
82
+ // If the position is 'top' or 'bottom', set the CSS properties accordingly
83
+ return (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n ", ": -2%;\n left: 8%;\n "], ["\n ", ": -2%;\n left: 8%;\n "])), position);
50
84
  case 'left':
51
85
  case 'right':
52
- return (0, styled_components_1.css)(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n ", ";\n top: 8%;\n "], ["\n ", ";\n top: 8%;\n "])), position + ': -2%');
86
+ // If the position is 'left' or 'right', set the CSS properties accordingly
87
+ return (0, styled_components_1.css)(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n ", ": -2%;\n top: 8%;\n "], ["\n ", ": -2%;\n top: 8%;\n "])), position);
88
+ default:
89
+ // If the position is not recognized, return an empty object
90
+ return {};
53
91
  }
54
92
  };
55
93
  exports.positionArrow = positionArrow;
@@ -1,6 +1,8 @@
1
- export function useContainerQuery(options?: {}): {
2
- ref: import("react").MutableRefObject<any>;
3
- containerQuery: (point: any) => (styles: any) => any;
1
+ export declare const useContainerQuery: (options?: {
2
+ enabled?: boolean;
3
+ }) => {
4
+ ref?: React.RefObject<HTMLDivElement>;
5
+ containerQuery?: (point: string) => (styles: string | TemplateStringsArray) => string;
4
6
  containerWidth: number;
5
7
  containerHeight: number;
6
8
  };
@@ -31,13 +31,13 @@ var useContainerQuery = function (options) {
31
31
  //query and so on. Else bugs will happen.
32
32
  var containerQuery = function (point) { return function (styles) {
33
33
  var breakpointWidth = (0, mixins_1.getBreakPoint)(point);
34
- return containerSize.width >= breakpointWidth ? styles : '';
34
+ return containerSize.width >= breakpointWidth ? styles : "";
35
35
  }; };
36
36
  return {
37
37
  ref: enabled ? ref : undefined,
38
38
  containerQuery: enabled ? containerQuery : undefined,
39
39
  containerWidth: containerSize.width,
40
- containerHeight: containerSize.height
40
+ containerHeight: containerSize.height,
41
41
  };
42
42
  };
43
43
  exports.useContainerQuery = useContainerQuery;
@@ -1 +1,12 @@
1
- export function useScroll(scrollFn: Function, options?: any): void;
1
+ interface ScrollOptions {
2
+ noThrottle?: boolean;
3
+ detectScrollInAllDivs?: boolean;
4
+ loading?: any;
5
+ }
6
+ /**
7
+ * @param {Function} scrollFn
8
+ * @param {*} options
9
+ * @summary if you dont use options.detectScrollInAllDivs, scroll is detected only at the 'window' level
10
+ */
11
+ export declare const useScroll: (scrollFn: () => void, options?: ScrollOptions) => void;
12
+ export {};
@@ -11,10 +11,11 @@ var react_1 = require("react");
11
11
  var useScroll = function (scrollFn, options) {
12
12
  if (options === void 0) { options = {}; }
13
13
  (0, react_1.useLayoutEffect)(function () {
14
- scrollFn(); //run the scroll fn once before any scroll to set initial states
14
+ var _a;
15
+ scrollFn(); // Run the scroll function once before any scroll to set initial states
15
16
  var throttledScrollFn = (0, lodash_1.throttle)(scrollFn, 100);
16
17
  var fnToUse = options.noThrottle ? scrollFn : throttledScrollFn;
17
- window.addEventListener('scroll', fnToUse, options.detectScrollInAllDivs); // <-- why 'true' : https://stackoverflow.com/a/32954565
18
+ window.addEventListener('scroll', fnToUse, (_a = options.detectScrollInAllDivs) !== null && _a !== void 0 ? _a : true); // <-- why 'true' : https://stackoverflow.com/a/32954565 // Use a default value of `true` if `detectScrollInAllDivs` is not provided.
18
19
  return function () { return window.removeEventListener('scroll', fnToUse, options.detectScrollInAllDivs); };
19
20
  }, [options.loading]);
20
21
  };
@@ -1,6 +1,57 @@
1
- export function usePopOutOfOverflowHiddenParent(popOutOfOverflowHiddenParent: any): {
2
- trackerRef: import("react").MutableRefObject<any>;
1
+ /// <reference types="react" />
2
+ interface PopOutOfOverflowHiddenParentResult {
3
+ trackerRef: React.MutableRefObject<HTMLDivElement | null>;
3
4
  applyFixedPos: () => void;
4
5
  removeFixedPos: () => void;
5
- fixPos: any;
6
- };
6
+ fixPos: DOMRect | undefined;
7
+ }
8
+ /**
9
+ * this utility is useful when action menus or dropdowns are
10
+ * used inside parents that have overflow hidden.
11
+ *
12
+ * When the dropdown / menu opens, we need it to show,
13
+ * and sometimes its not possible to reposition the dropdown / menu
14
+ * outside of the overflow hidden container.
15
+ *
16
+ * In such cases, we can use this hook.
17
+ * The way to use is this:
18
+ *
19
+ * 1// initiate -> (see what it returns below)
20
+ *
21
+ * 2// attach the ref & pass fixPos as a prop to whatever
22
+ * wrapper is wrapping the menu or dropdown.
23
+ *
24
+ * 3// whereever you are tracking the dropdown/menu opening or closing,
25
+ * there you can write a function to
26
+ * trigger applyFixedPos() when open
27
+ * and removeFixedPos() when closed
28
+ * for example in ActionMenu we can pass a prop called 'setShowActions'
29
+ * which listens to open-close changes
30
+ *
31
+ * And thats it. it should work.
32
+ *
33
+ * Current Usage :
34
+ * 1. In ImageEditor component > to make the ActionMenu stick out of parent
35
+ * 2. In TableRowElem component > to make the ActionMenu stick out of parent
36
+ *
37
+ * Known Issues :
38
+ * 1. If you scroll while the menu is open, it remains fixed to that part of the
39
+ * screen since we are using fixed positioning.
40
+ * 2. When you close the menu, fixed position is removed, so momentarily you see the
41
+ * menu disappearing behind the overflow hidden parent. Minor, but an issue none the less.
42
+ *
43
+ *
44
+ *
45
+ */
46
+ /**
47
+ * Creates a custom hook that enables an element to pop out of its overflow hidden parent.
48
+ *
49
+ * @param {boolean} popOutOfOverflowHiddenParent - Determines if the element should pop out of its overflow hidden parent.
50
+ * @return {object} An object containing the following properties:
51
+ * - {RefObject<HTMLDivElement>} trackerRef: A ref to the tracker div element.
52
+ * - {Function} applyFixedPos: A function that applies the fixed position to the element.
53
+ * - {Function} removeFixedPos: A function that removes the fixed position from the element.
54
+ * - {undefined | ClientRect} fixPos: The fixed position of the element.
55
+ */
56
+ export declare const usePopOutOfOverflowHiddenParent: (popOutOfOverflowHiddenParent: boolean) => PopOutOfOverflowHiddenParentResult;
57
+ export {};
@@ -42,23 +42,29 @@ var useScroll_1 = require("./customHooks/useScroll");
42
42
  *
43
43
  *
44
44
  */
45
+ /**
46
+ * Creates a custom hook that enables an element to pop out of its overflow hidden parent.
47
+ *
48
+ * @param {boolean} popOutOfOverflowHiddenParent - Determines if the element should pop out of its overflow hidden parent.
49
+ * @return {object} An object containing the following properties:
50
+ * - {RefObject<HTMLDivElement>} trackerRef: A ref to the tracker div element.
51
+ * - {Function} applyFixedPos: A function that applies the fixed position to the element.
52
+ * - {Function} removeFixedPos: A function that removes the fixed position from the element.
53
+ * - {undefined | ClientRect} fixPos: The fixed position of the element.
54
+ */
45
55
  var usePopOutOfOverflowHiddenParent = function (popOutOfOverflowHiddenParent) {
46
- var enabled = popOutOfOverflowHiddenParent; // is either true or falsw
56
+ var enabled = popOutOfOverflowHiddenParent;
47
57
  var trackerRef = (0, react_1.useRef)(null);
48
- var _a = (0, react_1.useState)(undefined), fixPos = _a[0], setFixPos = _a[1];
58
+ var _a = (0, react_1.useState)(), fixPos = _a[0], setFixPos = _a[1];
49
59
  var getBoundingClientRect = function () { var _a; return (_a = trackerRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(); };
50
60
  var applyFixedPos = function () { return enabled && setFixPos(getBoundingClientRect()); };
51
- var updateFixedPos = function (e) {
52
- /**
53
- * only if popOut... prop is enabled, AND
54
- * if an initial fixedPos has been applied,
55
- * then update it
56
- */
57
- if (popOutOfOverflowHiddenParent)
61
+ var updateFixedPos = function () {
62
+ if (popOutOfOverflowHiddenParent) {
58
63
  setFixPos(function (prev) { return prev && getBoundingClientRect(); });
64
+ }
59
65
  };
60
66
  var removeFixedPos = function () { return enabled && setFixPos(undefined); };
61
67
  (0, useScroll_1.useScroll)(updateFixedPos, { noThrottle: true, detectScrollInAllDivs: true });
62
- return ({ trackerRef: trackerRef, applyFixedPos: applyFixedPos, removeFixedPos: removeFixedPos, fixPos: fixPos });
68
+ return { trackerRef: trackerRef, applyFixedPos: applyFixedPos, removeFixedPos: removeFixedPos, fixPos: fixPos };
63
69
  };
64
70
  exports.usePopOutOfOverflowHiddenParent = usePopOutOfOverflowHiddenParent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.105.0",
3
+ "version": "2.107.0",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -85,6 +85,7 @@
85
85
  "access": "public"
86
86
  },
87
87
  "dependencies": {
88
+ "@faker-js/faker": "^8.3.1",
88
89
  "@react-hook/resize-observer": "^1.2.6",
89
90
  "babel-polyfill": "^6.26.0",
90
91
  "d3": "^7.8.5",
@@ -92,11 +93,13 @@
92
93
  "d3-geo": "^3.1.0",
93
94
  "draft-js": "^0.11.7",
94
95
  "draftjs-conductor": "^2.2.0",
96
+ "faker": "^6.6.6",
95
97
  "immutable": "^3.7.6",
96
98
  "lodash": "^4.17.21",
97
99
  "modularscale-js": "^3.0.1",
98
100
  "moment": "^2.24.0",
99
101
  "phosphor-react": "^1.4.1",
100
- "react-player": "^2.12.0"
102
+ "react-player": "^2.12.0",
103
+ "react-virtualized": "^9.22.5"
101
104
  }
102
105
  }