@quen-ui/components 0.0.14
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/README.md +43 -0
- package/dist/Alert/Alert.cjs.js +54 -0
- package/dist/Alert/Alert.d.ts +4 -0
- package/dist/Alert/Alert.es.js +55 -0
- package/dist/Alert/index.d.ts +2 -0
- package/dist/Alert/styles.cjs.js +90 -0
- package/dist/Alert/styles.d.ts +10 -0
- package/dist/Alert/styles.es.js +90 -0
- package/dist/Alert/types.d.ts +25 -0
- package/dist/Avatar/Avatar.cjs.js +65 -0
- package/dist/Avatar/Avatar.d.ts +4 -0
- package/dist/Avatar/Avatar.es.js +66 -0
- package/dist/Avatar/AvatarIcon.svg.cjs.js +21 -0
- package/dist/Avatar/AvatarIcon.svg.es.js +5 -0
- package/dist/Avatar/helpers.cjs.js +18 -0
- package/dist/Avatar/helpers.d.ts +1 -0
- package/dist/Avatar/helpers.es.js +18 -0
- package/dist/Avatar/index.d.ts +2 -0
- package/dist/Avatar/styles.cjs.js +31 -0
- package/dist/Avatar/styles.d.ts +9 -0
- package/dist/Avatar/styles.es.js +31 -0
- package/dist/Avatar/types.d.ts +31 -0
- package/dist/Badge/Badge.cjs.js +53 -0
- package/dist/Badge/Badge.d.ts +4 -0
- package/dist/Badge/Badge.es.js +54 -0
- package/dist/Badge/index.d.ts +3 -0
- package/dist/Badge/styles.cjs.js +70 -0
- package/dist/Badge/styles.d.ts +7 -0
- package/dist/Badge/styles.es.js +70 -0
- package/dist/Badge/types.cjs.js +10 -0
- package/dist/Badge/types.d.ts +22 -0
- package/dist/Badge/types.es.js +10 -0
- package/dist/Breadcrumbs/BreadcrumbItem.cjs.js +42 -0
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts +4 -0
- package/dist/Breadcrumbs/BreadcrumbItem.es.js +43 -0
- package/dist/Breadcrumbs/Breadcrumbs.cjs.js +48 -0
- package/dist/Breadcrumbs/Breadcrumbs.d.ts +4 -0
- package/dist/Breadcrumbs/Breadcrumbs.es.js +49 -0
- package/dist/Breadcrumbs/helpers.cjs.js +18 -0
- package/dist/Breadcrumbs/helpers.d.ts +16 -0
- package/dist/Breadcrumbs/helpers.es.js +18 -0
- package/dist/Breadcrumbs/index.d.ts +2 -0
- package/dist/Breadcrumbs/styles.cjs.js +50 -0
- package/dist/Breadcrumbs/styles.d.ts +4 -0
- package/dist/Breadcrumbs/styles.es.js +50 -0
- package/dist/Breadcrumbs/types.d.ts +56 -0
- package/dist/Button/Button.cjs.js +66 -0
- package/dist/Button/Button.d.ts +4 -0
- package/dist/Button/Button.es.js +67 -0
- package/dist/Button/index.d.ts +2 -0
- package/dist/Button/styles.cjs.js +177 -0
- package/dist/Button/styles.d.ts +7 -0
- package/dist/Button/styles.es.js +177 -0
- package/dist/Button/types.d.ts +38 -0
- package/dist/Card/Card.cjs.js +38 -0
- package/dist/Card/Card.d.ts +3 -0
- package/dist/Card/Card.es.js +39 -0
- package/dist/Card/index.d.ts +2 -0
- package/dist/Card/styles.cjs.js +55 -0
- package/dist/Card/styles.d.ts +11 -0
- package/dist/Card/styles.es.js +55 -0
- package/dist/Card/types.d.ts +26 -0
- package/dist/Checkbox/Checkbox.cjs.js +39 -0
- package/dist/Checkbox/Checkbox.d.ts +4 -0
- package/dist/Checkbox/Checkbox.es.js +40 -0
- package/dist/Checkbox/CheckboxGroup.cjs.js +82 -0
- package/dist/Checkbox/CheckboxGroup.d.ts +4 -0
- package/dist/Checkbox/CheckboxGroup.es.js +83 -0
- package/dist/Checkbox/helpers.cjs.js +14 -0
- package/dist/Checkbox/helpers.d.ts +18 -0
- package/dist/Checkbox/helpers.es.js +14 -0
- package/dist/Checkbox/index.cjs.js +7 -0
- package/dist/Checkbox/index.d.ts +8 -0
- package/dist/Checkbox/index.es.js +7 -0
- package/dist/Checkbox/styles.cjs.js +147 -0
- package/dist/Checkbox/styles.d.ts +13 -0
- package/dist/Checkbox/styles.es.js +147 -0
- package/dist/Checkbox/types.d.ts +67 -0
- package/dist/Divider/Divider.cjs.js +27 -0
- package/dist/Divider/Divider.d.ts +4 -0
- package/dist/Divider/Divider.es.js +28 -0
- package/dist/Divider/index.d.ts +2 -0
- package/dist/Divider/styles.cjs.js +121 -0
- package/dist/Divider/styles.d.ts +3 -0
- package/dist/Divider/styles.es.js +121 -0
- package/dist/Divider/types.d.ts +17 -0
- package/dist/Drawer/Drawer.cjs.js +67 -0
- package/dist/Drawer/Drawer.d.ts +4 -0
- package/dist/Drawer/Drawer.es.js +68 -0
- package/dist/Drawer/index.d.ts +2 -0
- package/dist/Drawer/styles.cjs.js +85 -0
- package/dist/Drawer/styles.d.ts +18 -0
- package/dist/Drawer/styles.es.js +85 -0
- package/dist/Drawer/types.d.ts +24 -0
- package/dist/Dropdown/Dropdown.cjs.js +65 -0
- package/dist/Dropdown/Dropdown.d.ts +4 -0
- package/dist/Dropdown/Dropdown.es.js +66 -0
- package/dist/Dropdown/DropdownItem.cjs.js +32 -0
- package/dist/Dropdown/DropdownItem.d.ts +4 -0
- package/dist/Dropdown/DropdownItem.es.js +33 -0
- package/dist/Dropdown/DropdownList.cjs.js +85 -0
- package/dist/Dropdown/DropdownList.d.ts +6 -0
- package/dist/Dropdown/DropdownList.es.js +86 -0
- package/dist/Dropdown/DropdownPortal.cjs.js +41 -0
- package/dist/Dropdown/DropdownPortal.d.ts +4 -0
- package/dist/Dropdown/DropdownPortal.es.js +42 -0
- package/dist/Dropdown/helpers.cjs.js +112 -0
- package/dist/Dropdown/helpers.d.ts +35 -0
- package/dist/Dropdown/helpers.es.js +112 -0
- package/dist/Dropdown/index.d.ts +2 -0
- package/dist/Dropdown/styles.cjs.js +150 -0
- package/dist/Dropdown/styles.d.ts +33 -0
- package/dist/Dropdown/styles.es.js +150 -0
- package/dist/Dropdown/types.d.ts +81 -0
- package/dist/Flex/Flex.cjs.js +10 -0
- package/dist/Flex/Flex.d.ts +4 -0
- package/dist/Flex/Flex.es.js +11 -0
- package/dist/Flex/index.d.ts +2 -0
- package/dist/Flex/styles.cjs.js +32 -0
- package/dist/Flex/styles.d.ts +2 -0
- package/dist/Flex/styles.es.js +32 -0
- package/dist/Flex/types.d.ts +23 -0
- package/dist/Image/Image.cjs.js +79 -0
- package/dist/Image/Image.d.ts +4 -0
- package/dist/Image/Image.es.js +80 -0
- package/dist/Image/index.d.ts +2 -0
- package/dist/Image/styles.cjs.js +87 -0
- package/dist/Image/styles.d.ts +13 -0
- package/dist/Image/styles.es.js +87 -0
- package/dist/Image/types.d.ts +20 -0
- package/dist/InputNumber/InputNumber.cjs.js +145 -0
- package/dist/InputNumber/InputNumber.d.ts +4 -0
- package/dist/InputNumber/InputNumber.es.js +146 -0
- package/dist/InputNumber/index.d.ts +2 -0
- package/dist/InputNumber/styles.cjs.js +136 -0
- package/dist/InputNumber/styles.d.ts +21 -0
- package/dist/InputNumber/styles.es.js +136 -0
- package/dist/InputNumber/types.d.ts +61 -0
- package/dist/Layout/Content.cjs.js +7 -0
- package/dist/Layout/Content.d.ts +4 -0
- package/dist/Layout/Content.es.js +8 -0
- package/dist/Layout/Footer.cjs.js +7 -0
- package/dist/Layout/Footer.d.ts +4 -0
- package/dist/Layout/Footer.es.js +8 -0
- package/dist/Layout/Header.cjs.js +47 -0
- package/dist/Layout/Header.d.ts +4 -0
- package/dist/Layout/Header.es.js +48 -0
- package/dist/Layout/Layout.cjs.js +49 -0
- package/dist/Layout/Layout.d.ts +5 -0
- package/dist/Layout/Layout.es.js +49 -0
- package/dist/Layout/Sidebar.cjs.js +57 -0
- package/dist/Layout/Sidebar.d.ts +4 -0
- package/dist/Layout/Sidebar.es.js +58 -0
- package/dist/Layout/index.cjs.js +13 -0
- package/dist/Layout/index.d.ts +14 -0
- package/dist/Layout/index.es.js +13 -0
- package/dist/Layout/styles.cjs.js +150 -0
- package/dist/Layout/styles.d.ts +32 -0
- package/dist/Layout/styles.es.js +150 -0
- package/dist/Layout/types.d.ts +75 -0
- package/dist/Loader/Loader.cjs.js +34 -0
- package/dist/Loader/Loader.d.ts +4 -0
- package/dist/Loader/Loader.es.js +35 -0
- package/dist/Loader/index.d.ts +2 -0
- package/dist/Loader/loaders/Bars.cjs.js +12 -0
- package/dist/Loader/loaders/Bars.d.ts +6 -0
- package/dist/Loader/loaders/Bars.es.js +13 -0
- package/dist/Loader/loaders/Dots.cjs.js +12 -0
- package/dist/Loader/loaders/Dots.d.ts +6 -0
- package/dist/Loader/loaders/Dots.es.js +13 -0
- package/dist/Loader/loaders/Oval.cjs.js +8 -0
- package/dist/Loader/loaders/Oval.d.ts +6 -0
- package/dist/Loader/loaders/Oval.es.js +9 -0
- package/dist/Loader/styles.cjs.js +95 -0
- package/dist/Loader/styles.d.ts +9 -0
- package/dist/Loader/styles.es.js +95 -0
- package/dist/Loader/types.d.ts +11 -0
- package/dist/Modal/Modal.cjs.js +67 -0
- package/dist/Modal/Modal.d.ts +4 -0
- package/dist/Modal/Modal.es.js +68 -0
- package/dist/Modal/index.d.ts +2 -0
- package/dist/Modal/styles.cjs.js +52 -0
- package/dist/Modal/styles.d.ts +14 -0
- package/dist/Modal/styles.es.js +52 -0
- package/dist/Modal/types.d.ts +31 -0
- package/dist/Notification/Notification.cjs.js +73 -0
- package/dist/Notification/Notification.d.ts +4 -0
- package/dist/Notification/Notification.es.js +74 -0
- package/dist/Notification/NotificationInstance.cjs.js +244 -0
- package/dist/Notification/NotificationInstance.d.ts +8 -0
- package/dist/Notification/NotificationInstance.es.js +244 -0
- package/dist/Notification/NotificationsStore.cjs.js +30 -0
- package/dist/Notification/NotificationsStore.d.ts +13 -0
- package/dist/Notification/NotificationsStore.es.js +31 -0
- package/dist/Notification/index.d.ts +3 -0
- package/dist/Notification/styles.cjs.js +90 -0
- package/dist/Notification/styles.d.ts +8 -0
- package/dist/Notification/styles.es.js +90 -0
- package/dist/Notification/types.cjs.js +9 -0
- package/dist/Notification/types.d.ts +41 -0
- package/dist/Notification/types.es.js +9 -0
- package/dist/Progress/Progress.cjs.js +43 -0
- package/dist/Progress/Progress.d.ts +4 -0
- package/dist/Progress/Progress.es.js +44 -0
- package/dist/Progress/index.d.ts +2 -0
- package/dist/Progress/styles.cjs.js +82 -0
- package/dist/Progress/styles.d.ts +13 -0
- package/dist/Progress/styles.es.js +82 -0
- package/dist/Progress/types.d.ts +20 -0
- package/dist/RadioButton/RadioButton.cjs.js +45 -0
- package/dist/RadioButton/RadioButton.d.ts +4 -0
- package/dist/RadioButton/RadioButton.es.js +46 -0
- package/dist/RadioButton/RadioButtonGroup.cjs.js +68 -0
- package/dist/RadioButton/RadioButtonGroup.d.ts +4 -0
- package/dist/RadioButton/RadioButtonGroup.es.js +69 -0
- package/dist/RadioButton/helpers.cjs.js +14 -0
- package/dist/RadioButton/helpers.d.ts +18 -0
- package/dist/RadioButton/helpers.es.js +14 -0
- package/dist/RadioButton/index.cjs.js +7 -0
- package/dist/RadioButton/index.d.ts +8 -0
- package/dist/RadioButton/index.es.js +7 -0
- package/dist/RadioButton/styles.cjs.js +84 -0
- package/dist/RadioButton/styles.d.ts +12 -0
- package/dist/RadioButton/styles.es.js +84 -0
- package/dist/RadioButton/types.d.ts +65 -0
- package/dist/Select/Select.cjs.js +114 -0
- package/dist/Select/Select.d.ts +4 -0
- package/dist/Select/Select.es.js +115 -0
- package/dist/Select/helpers.cjs.js +16 -0
- package/dist/Select/helpers.d.ts +138 -0
- package/dist/Select/helpers.es.js +16 -0
- package/dist/Select/index.d.ts +2 -0
- package/dist/Select/styles.cjs.js +415 -0
- package/dist/Select/styles.d.ts +9 -0
- package/dist/Select/styles.es.js +415 -0
- package/dist/Select/types.d.ts +116 -0
- package/dist/Select/useSelect.cjs.js +72 -0
- package/dist/Select/useSelect.d.ts +150 -0
- package/dist/Select/useSelect.es.js +72 -0
- package/dist/Switch/Switch.cjs.js +53 -0
- package/dist/Switch/Switch.d.ts +4 -0
- package/dist/Switch/Switch.es.js +54 -0
- package/dist/Switch/index.d.ts +2 -0
- package/dist/Switch/styles.cjs.js +78 -0
- package/dist/Switch/styles.d.ts +7 -0
- package/dist/Switch/styles.es.js +78 -0
- package/dist/Switch/types.d.ts +25 -0
- package/dist/Tabs/Tab.cjs.js +42 -0
- package/dist/Tabs/Tab.d.ts +4 -0
- package/dist/Tabs/Tab.es.js +43 -0
- package/dist/Tabs/TabPanel.cjs.js +14 -0
- package/dist/Tabs/TabPanel.d.ts +4 -0
- package/dist/Tabs/TabPanel.es.js +15 -0
- package/dist/Tabs/Tabs.cjs.js +21 -0
- package/dist/Tabs/Tabs.d.ts +5 -0
- package/dist/Tabs/Tabs.es.js +21 -0
- package/dist/Tabs/TabsList.cjs.js +12 -0
- package/dist/Tabs/TabsList.d.ts +4 -0
- package/dist/Tabs/TabsList.es.js +13 -0
- package/dist/Tabs/index.cjs.js +10 -0
- package/dist/Tabs/index.d.ts +12 -0
- package/dist/Tabs/index.es.js +11 -0
- package/dist/Tabs/styles.cjs.js +74 -0
- package/dist/Tabs/styles.d.ts +9 -0
- package/dist/Tabs/styles.es.js +74 -0
- package/dist/Tabs/types.d.ts +51 -0
- package/dist/Tag/Tag.cjs.js +39 -0
- package/dist/Tag/Tag.d.ts +4 -0
- package/dist/Tag/Tag.es.js +40 -0
- package/dist/Tag/index.d.ts +2 -0
- package/dist/Tag/styles.cjs.js +51 -0
- package/dist/Tag/styles.d.ts +6 -0
- package/dist/Tag/styles.es.js +51 -0
- package/dist/Tag/types.d.ts +18 -0
- package/dist/TextField/TextField.cjs.js +100 -0
- package/dist/TextField/TextField.d.ts +4 -0
- package/dist/TextField/TextField.es.js +101 -0
- package/dist/TextField/index.d.ts +2 -0
- package/dist/TextField/styles.cjs.js +65 -0
- package/dist/TextField/styles.d.ts +9 -0
- package/dist/TextField/styles.es.js +65 -0
- package/dist/TextField/types.d.ts +41 -0
- package/dist/Textarea/Textarea.cjs.js +103 -0
- package/dist/Textarea/Textarea.d.ts +4 -0
- package/dist/Textarea/Textarea.es.js +104 -0
- package/dist/Textarea/index.d.ts +2 -0
- package/dist/Textarea/styles.cjs.js +80 -0
- package/dist/Textarea/styles.d.ts +9 -0
- package/dist/Textarea/styles.es.js +80 -0
- package/dist/Textarea/types.d.ts +47 -0
- package/dist/Tooltip/Tooltip.cjs.js +69 -0
- package/dist/Tooltip/Tooltip.d.ts +4 -0
- package/dist/Tooltip/Tooltip.es.js +70 -0
- package/dist/Tooltip/index.d.ts +2 -0
- package/dist/Tooltip/styles.cjs.js +232 -0
- package/dist/Tooltip/styles.d.ts +13 -0
- package/dist/Tooltip/styles.es.js +232 -0
- package/dist/Tooltip/types.d.ts +22 -0
- package/dist/assets/icon-arrow-bottom.svg.cjs.js +21 -0
- package/dist/assets/icon-arrow-bottom.svg.es.js +5 -0
- package/dist/assets/icon-close.svg.cjs.js +21 -0
- package/dist/assets/icon-close.svg.es.js +5 -0
- package/dist/assets/icon-error.svg.cjs.js +21 -0
- package/dist/assets/icon-error.svg.es.js +5 -0
- package/dist/assets/icon-info.svg.cjs.js +21 -0
- package/dist/assets/icon-info.svg.es.js +5 -0
- package/dist/assets/icon-lines.svg.cjs.js +21 -0
- package/dist/assets/icon-lines.svg.es.js +5 -0
- package/dist/assets/icon-success.svg.cjs.js +21 -0
- package/dist/assets/icon-success.svg.es.js +5 -0
- package/dist/assets/icon-warning.svg.cjs.js +21 -0
- package/dist/assets/icon-warning.svg.es.js +5 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/index.cjs.js +63 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.es.js +63 -0
- package/dist/types/propsWithAttributes.d.ts +2 -0
- package/dist/types/size.d.ts +2 -0
- package/dist/typography/Text/Text.cjs.js +31 -0
- package/dist/typography/Text/Text.d.ts +4 -0
- package/dist/typography/Text/Text.es.js +32 -0
- package/dist/typography/Text/__stories__/Text.stories.d.ts +9 -0
- package/dist/typography/Text/index.d.ts +2 -0
- package/dist/typography/Text/styles.cjs.js +69 -0
- package/dist/typography/Text/styles.d.ts +2 -0
- package/dist/typography/Text/styles.es.js +69 -0
- package/dist/typography/Text/types.d.ts +22 -0
- package/dist/typography/Title/Title.cjs.js +26 -0
- package/dist/typography/Title/Title.d.ts +4 -0
- package/dist/typography/Title/Title.es.js +27 -0
- package/dist/typography/Title/__stories__/Title.stories.d.ts +9 -0
- package/dist/typography/Title/index.d.ts +2 -0
- package/dist/typography/Title/styles.cjs.js +75 -0
- package/dist/typography/Title/styles.d.ts +2 -0
- package/dist/typography/Title/styles.es.js +75 -0
- package/dist/typography/Title/types.d.ts +22 -0
- package/package.json +71 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const helpers = require("./helpers.cjs.js");
|
|
5
|
+
const styles = require("./styles.cjs.js");
|
|
6
|
+
const DropdownPortal = ({
|
|
7
|
+
direction,
|
|
8
|
+
anchorRect,
|
|
9
|
+
height,
|
|
10
|
+
transitionStatus,
|
|
11
|
+
...props
|
|
12
|
+
}) => {
|
|
13
|
+
const [dropdownRect, setDropdownRect] = React.useState(helpers.DEFAULT_RECT_ELEMENT);
|
|
14
|
+
const maxHeight = React.useMemo(
|
|
15
|
+
() => document.documentElement.scrollHeight - anchorRect.height - anchorRect.y - 8,
|
|
16
|
+
[anchorRect]
|
|
17
|
+
);
|
|
18
|
+
const dropdownRef = React.useRef(null);
|
|
19
|
+
const portalDirection = React.useMemo(
|
|
20
|
+
() => helpers.getDirection({ anchorRect, direction, dropdownRect, offset: 8 }),
|
|
21
|
+
[dropdownRect, direction]
|
|
22
|
+
);
|
|
23
|
+
React.useLayoutEffect(() => {
|
|
24
|
+
setDropdownRect(helpers.calculateRectElement(dropdownRef.current));
|
|
25
|
+
}, []);
|
|
26
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
27
|
+
styles.DropdownListStyled,
|
|
28
|
+
{
|
|
29
|
+
transitionStatus,
|
|
30
|
+
direction: portalDirection,
|
|
31
|
+
anchorRect,
|
|
32
|
+
dropdownRect,
|
|
33
|
+
maxHeight,
|
|
34
|
+
ref: dropdownRef,
|
|
35
|
+
height,
|
|
36
|
+
minWidth: anchorRect.width,
|
|
37
|
+
...props
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
module.exports = DropdownPortal;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TDropdownPortalProps } from './types';
|
|
3
|
+
declare const DropdownPortal: <ITEM>({ direction, anchorRect, height, transitionStatus, ...props }: TDropdownPortalProps<ITEM>) => React.ReactElement;
|
|
4
|
+
export default DropdownPortal;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useMemo, useRef, useLayoutEffect } from "react";
|
|
3
|
+
import { DEFAULT_RECT_ELEMENT, getDirection, calculateRectElement } from "./helpers.es.js";
|
|
4
|
+
import { DropdownListStyled } from "./styles.es.js";
|
|
5
|
+
const DropdownPortal = ({
|
|
6
|
+
direction,
|
|
7
|
+
anchorRect,
|
|
8
|
+
height,
|
|
9
|
+
transitionStatus,
|
|
10
|
+
...props
|
|
11
|
+
}) => {
|
|
12
|
+
const [dropdownRect, setDropdownRect] = useState(DEFAULT_RECT_ELEMENT);
|
|
13
|
+
const maxHeight = useMemo(
|
|
14
|
+
() => document.documentElement.scrollHeight - anchorRect.height - anchorRect.y - 8,
|
|
15
|
+
[anchorRect]
|
|
16
|
+
);
|
|
17
|
+
const dropdownRef = useRef(null);
|
|
18
|
+
const portalDirection = useMemo(
|
|
19
|
+
() => getDirection({ anchorRect, direction, dropdownRect, offset: 8 }),
|
|
20
|
+
[dropdownRect, direction]
|
|
21
|
+
);
|
|
22
|
+
useLayoutEffect(() => {
|
|
23
|
+
setDropdownRect(calculateRectElement(dropdownRef.current));
|
|
24
|
+
}, []);
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
DropdownListStyled,
|
|
27
|
+
{
|
|
28
|
+
transitionStatus,
|
|
29
|
+
direction: portalDirection,
|
|
30
|
+
anchorRect,
|
|
31
|
+
dropdownRect,
|
|
32
|
+
maxHeight,
|
|
33
|
+
ref: dropdownRef,
|
|
34
|
+
height,
|
|
35
|
+
minWidth: anchorRect.width,
|
|
36
|
+
...props
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
DropdownPortal as default
|
|
42
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const DEFAULT_RECT_ELEMENT = {
|
|
4
|
+
width: 0,
|
|
5
|
+
height: 0,
|
|
6
|
+
top: 0,
|
|
7
|
+
right: 0,
|
|
8
|
+
bottom: 0,
|
|
9
|
+
left: 0,
|
|
10
|
+
x: 0,
|
|
11
|
+
y: 0,
|
|
12
|
+
toJSON: () => {
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const defaultGetItemKey = (item) => item.key || item.label;
|
|
16
|
+
const defaultGetItemLeadContent = (item) => item.leftContent;
|
|
17
|
+
const defaultGetItemDisabled = (item) => item.disabled;
|
|
18
|
+
const defaultGetItemLabel = (item) => item.label;
|
|
19
|
+
const defaultGetItemOnClick = (item) => item.onClick;
|
|
20
|
+
const defaultGetItemGroupId = (item) => item == null ? void 0 : item.groupId;
|
|
21
|
+
function withDefaultGetters(props) {
|
|
22
|
+
return {
|
|
23
|
+
...props,
|
|
24
|
+
getItemKey: props.getItemKey || defaultGetItemKey,
|
|
25
|
+
getItemLabel: props.getItemLabel || defaultGetItemLabel,
|
|
26
|
+
getItemLeftContent: props.getItemLeftContent || defaultGetItemLeadContent,
|
|
27
|
+
getItemDisabled: props.getItemDisabled || defaultGetItemDisabled,
|
|
28
|
+
getItemOnClick: props.getItemOnClick || defaultGetItemOnClick,
|
|
29
|
+
getItemGroupId: props.getItemGroupId || defaultGetItemGroupId
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const getDirection = ({
|
|
33
|
+
anchorRect,
|
|
34
|
+
direction,
|
|
35
|
+
dropdownRect,
|
|
36
|
+
offset
|
|
37
|
+
}) => {
|
|
38
|
+
const viewerSize = {
|
|
39
|
+
width: document.documentElement.clientWidth,
|
|
40
|
+
height: document.documentElement.clientHeight
|
|
41
|
+
};
|
|
42
|
+
const isTop = anchorRect.y - dropdownRect.height - offset >= 0;
|
|
43
|
+
const isBottom = anchorRect.y + anchorRect.height + dropdownRect.height + offset <= viewerSize.height;
|
|
44
|
+
const isRight = anchorRect.right + anchorRect.width + dropdownRect.width + offset <= viewerSize.width;
|
|
45
|
+
const isLeft = anchorRect.x - dropdownRect.width - offset >= 0;
|
|
46
|
+
switch (direction) {
|
|
47
|
+
case "left":
|
|
48
|
+
if (isLeft) {
|
|
49
|
+
return "left";
|
|
50
|
+
}
|
|
51
|
+
return "right";
|
|
52
|
+
case "right":
|
|
53
|
+
if (isRight) {
|
|
54
|
+
return "right";
|
|
55
|
+
}
|
|
56
|
+
return "left";
|
|
57
|
+
case "top":
|
|
58
|
+
if (isTop) {
|
|
59
|
+
return "top";
|
|
60
|
+
}
|
|
61
|
+
return "bottom";
|
|
62
|
+
case "topRight":
|
|
63
|
+
if (isTop) {
|
|
64
|
+
return "topRight";
|
|
65
|
+
}
|
|
66
|
+
return "bottomRight";
|
|
67
|
+
case "topLeft":
|
|
68
|
+
if (isTop) {
|
|
69
|
+
return "topLeft";
|
|
70
|
+
}
|
|
71
|
+
return "bottomLeft";
|
|
72
|
+
case "bottom":
|
|
73
|
+
if (isBottom) {
|
|
74
|
+
return "bottom";
|
|
75
|
+
}
|
|
76
|
+
return "top";
|
|
77
|
+
case "bottomLeft":
|
|
78
|
+
if (isBottom) {
|
|
79
|
+
return "bottomLeft";
|
|
80
|
+
}
|
|
81
|
+
return "topLeft";
|
|
82
|
+
case "bottomRight":
|
|
83
|
+
if (isBottom) {
|
|
84
|
+
return "bottomRight";
|
|
85
|
+
}
|
|
86
|
+
return "topRight";
|
|
87
|
+
default:
|
|
88
|
+
return direction;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const calculateRectElement = (el) => {
|
|
92
|
+
if (el) {
|
|
93
|
+
const { width, height, top, left, bottom, right, x, y } = el.getBoundingClientRect();
|
|
94
|
+
return {
|
|
95
|
+
width,
|
|
96
|
+
height,
|
|
97
|
+
top,
|
|
98
|
+
left,
|
|
99
|
+
bottom,
|
|
100
|
+
right,
|
|
101
|
+
x,
|
|
102
|
+
y,
|
|
103
|
+
toJSON() {
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return DEFAULT_RECT_ELEMENT;
|
|
108
|
+
};
|
|
109
|
+
exports.DEFAULT_RECT_ELEMENT = DEFAULT_RECT_ELEMENT;
|
|
110
|
+
exports.calculateRectElement = calculateRectElement;
|
|
111
|
+
exports.getDirection = getDirection;
|
|
112
|
+
exports.withDefaultGetters = withDefaultGetters;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IDropdownDefaultItem, TDropdownListProps, TDropdownGetItemKey, TDropdownGetItemLeftContent, TDropdownGetItemLabel, TDropdownGetItemDisabled, TDropdownGetItemOnClick, TDropdownGetItemGroupId, TDropdownDirection } from './types';
|
|
2
|
+
export declare const DEFAULT_RECT_ELEMENT: DOMRect;
|
|
3
|
+
export declare function withDefaultGetters<Item = IDropdownDefaultItem>(props: TDropdownListProps<Item>): {
|
|
4
|
+
getItemKey: TDropdownGetItemKey<Item>;
|
|
5
|
+
getItemLabel: TDropdownGetItemLabel<Item>;
|
|
6
|
+
getItemLeftContent: TDropdownGetItemLeftContent<Item>;
|
|
7
|
+
getItemDisabled: TDropdownGetItemDisabled<Item>;
|
|
8
|
+
getItemOnClick: TDropdownGetItemOnClick<Item>;
|
|
9
|
+
getItemGroupId: TDropdownGetItemGroupId<Item>;
|
|
10
|
+
disabled?: boolean | undefined;
|
|
11
|
+
size?: import('..').TQuenSize | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
content?: React.ReactElement | undefined;
|
|
14
|
+
open?: boolean | undefined;
|
|
15
|
+
width?: string | undefined;
|
|
16
|
+
direction?: TDropdownDirection | undefined;
|
|
17
|
+
items?: Item[] | undefined;
|
|
18
|
+
onItemClick?: import('./types').TDropdownOnClick<Item> | undefined;
|
|
19
|
+
onClickOutside?: (() => void) | undefined;
|
|
20
|
+
sortGroup?: import('./types').TDropdownSortGroup | undefined;
|
|
21
|
+
onClickClose?: (() => void) | undefined;
|
|
22
|
+
notCloseOutside?: boolean | undefined;
|
|
23
|
+
anchorRef: import('react').RefObject<HTMLElement | null>;
|
|
24
|
+
top?: number;
|
|
25
|
+
left?: number;
|
|
26
|
+
};
|
|
27
|
+
interface IGetDirectionParams {
|
|
28
|
+
anchorRect: DOMRect;
|
|
29
|
+
dropdownRect: DOMRect;
|
|
30
|
+
direction: TDropdownDirection;
|
|
31
|
+
offset: number;
|
|
32
|
+
}
|
|
33
|
+
export declare const getDirection: ({ anchorRect, direction, dropdownRect, offset }: IGetDirectionParams) => TDropdownDirection;
|
|
34
|
+
export declare const calculateRectElement: (el: Element | null) => DOMRect;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const DEFAULT_RECT_ELEMENT = {
|
|
2
|
+
width: 0,
|
|
3
|
+
height: 0,
|
|
4
|
+
top: 0,
|
|
5
|
+
right: 0,
|
|
6
|
+
bottom: 0,
|
|
7
|
+
left: 0,
|
|
8
|
+
x: 0,
|
|
9
|
+
y: 0,
|
|
10
|
+
toJSON: () => {
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const defaultGetItemKey = (item) => item.key || item.label;
|
|
14
|
+
const defaultGetItemLeadContent = (item) => item.leftContent;
|
|
15
|
+
const defaultGetItemDisabled = (item) => item.disabled;
|
|
16
|
+
const defaultGetItemLabel = (item) => item.label;
|
|
17
|
+
const defaultGetItemOnClick = (item) => item.onClick;
|
|
18
|
+
const defaultGetItemGroupId = (item) => item == null ? void 0 : item.groupId;
|
|
19
|
+
function withDefaultGetters(props) {
|
|
20
|
+
return {
|
|
21
|
+
...props,
|
|
22
|
+
getItemKey: props.getItemKey || defaultGetItemKey,
|
|
23
|
+
getItemLabel: props.getItemLabel || defaultGetItemLabel,
|
|
24
|
+
getItemLeftContent: props.getItemLeftContent || defaultGetItemLeadContent,
|
|
25
|
+
getItemDisabled: props.getItemDisabled || defaultGetItemDisabled,
|
|
26
|
+
getItemOnClick: props.getItemOnClick || defaultGetItemOnClick,
|
|
27
|
+
getItemGroupId: props.getItemGroupId || defaultGetItemGroupId
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const getDirection = ({
|
|
31
|
+
anchorRect,
|
|
32
|
+
direction,
|
|
33
|
+
dropdownRect,
|
|
34
|
+
offset
|
|
35
|
+
}) => {
|
|
36
|
+
const viewerSize = {
|
|
37
|
+
width: document.documentElement.clientWidth,
|
|
38
|
+
height: document.documentElement.clientHeight
|
|
39
|
+
};
|
|
40
|
+
const isTop = anchorRect.y - dropdownRect.height - offset >= 0;
|
|
41
|
+
const isBottom = anchorRect.y + anchorRect.height + dropdownRect.height + offset <= viewerSize.height;
|
|
42
|
+
const isRight = anchorRect.right + anchorRect.width + dropdownRect.width + offset <= viewerSize.width;
|
|
43
|
+
const isLeft = anchorRect.x - dropdownRect.width - offset >= 0;
|
|
44
|
+
switch (direction) {
|
|
45
|
+
case "left":
|
|
46
|
+
if (isLeft) {
|
|
47
|
+
return "left";
|
|
48
|
+
}
|
|
49
|
+
return "right";
|
|
50
|
+
case "right":
|
|
51
|
+
if (isRight) {
|
|
52
|
+
return "right";
|
|
53
|
+
}
|
|
54
|
+
return "left";
|
|
55
|
+
case "top":
|
|
56
|
+
if (isTop) {
|
|
57
|
+
return "top";
|
|
58
|
+
}
|
|
59
|
+
return "bottom";
|
|
60
|
+
case "topRight":
|
|
61
|
+
if (isTop) {
|
|
62
|
+
return "topRight";
|
|
63
|
+
}
|
|
64
|
+
return "bottomRight";
|
|
65
|
+
case "topLeft":
|
|
66
|
+
if (isTop) {
|
|
67
|
+
return "topLeft";
|
|
68
|
+
}
|
|
69
|
+
return "bottomLeft";
|
|
70
|
+
case "bottom":
|
|
71
|
+
if (isBottom) {
|
|
72
|
+
return "bottom";
|
|
73
|
+
}
|
|
74
|
+
return "top";
|
|
75
|
+
case "bottomLeft":
|
|
76
|
+
if (isBottom) {
|
|
77
|
+
return "bottomLeft";
|
|
78
|
+
}
|
|
79
|
+
return "topLeft";
|
|
80
|
+
case "bottomRight":
|
|
81
|
+
if (isBottom) {
|
|
82
|
+
return "bottomRight";
|
|
83
|
+
}
|
|
84
|
+
return "topRight";
|
|
85
|
+
default:
|
|
86
|
+
return direction;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const calculateRectElement = (el) => {
|
|
90
|
+
if (el) {
|
|
91
|
+
const { width, height, top, left, bottom, right, x, y } = el.getBoundingClientRect();
|
|
92
|
+
return {
|
|
93
|
+
width,
|
|
94
|
+
height,
|
|
95
|
+
top,
|
|
96
|
+
left,
|
|
97
|
+
bottom,
|
|
98
|
+
right,
|
|
99
|
+
x,
|
|
100
|
+
y,
|
|
101
|
+
toJSON() {
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return DEFAULT_RECT_ELEMENT;
|
|
106
|
+
};
|
|
107
|
+
export {
|
|
108
|
+
DEFAULT_RECT_ELEMENT,
|
|
109
|
+
calculateRectElement,
|
|
110
|
+
getDirection,
|
|
111
|
+
withDefaultGetters
|
|
112
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { default as Dropdown } from './Dropdown';
|
|
2
|
+
export type { IDropdownProps, TDropdownListProps, TDropdownItemProps, IDropdownMappersItem, IDropdownDefaultItem, TDropdownGetItemDisabled, TDropdownGetItemOnClick, TDropdownGetItemGroupId, TDropdownDirection, TDropdownGetItemKey, TDropdownGetItemLeftContent, TDropdownGetItemLabel, TDropdownOnClick, TDropdownPortalProps, TDropdownSortGroup } from './types';
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const styled = require("styled-components");
|
|
4
|
+
const DropdownList = require("./DropdownList.cjs.js");
|
|
5
|
+
const Text = require("../typography/Text/Text.cjs.js");
|
|
6
|
+
const MARGIN = 8;
|
|
7
|
+
const getDirectionStyles = ({
|
|
8
|
+
direction,
|
|
9
|
+
anchorRect,
|
|
10
|
+
dropdownRect
|
|
11
|
+
}) => {
|
|
12
|
+
switch (direction) {
|
|
13
|
+
case "top":
|
|
14
|
+
return styled.css`
|
|
15
|
+
left: ${anchorRect.left + anchorRect.width / 2 - dropdownRect.width / 2}px;
|
|
16
|
+
top: ${anchorRect.top - MARGIN - dropdownRect.height}px;
|
|
17
|
+
`;
|
|
18
|
+
case "bottom":
|
|
19
|
+
return styled.css`
|
|
20
|
+
top: ${anchorRect.bottom + MARGIN}px;
|
|
21
|
+
left: ${anchorRect.left + anchorRect.width / 2 - dropdownRect.width / 2}px;
|
|
22
|
+
`;
|
|
23
|
+
case "bottomRight":
|
|
24
|
+
return styled.css`
|
|
25
|
+
top: ${anchorRect.bottom + MARGIN}px;
|
|
26
|
+
left: ${anchorRect.right - dropdownRect.width}px;
|
|
27
|
+
`;
|
|
28
|
+
case "bottomLeft":
|
|
29
|
+
return styled.css`
|
|
30
|
+
top: ${anchorRect.bottom + MARGIN}px;
|
|
31
|
+
left: ${anchorRect.left}px;
|
|
32
|
+
`;
|
|
33
|
+
case "topLeft":
|
|
34
|
+
return styled.css`
|
|
35
|
+
top: ${anchorRect.top - MARGIN - dropdownRect.height}px;
|
|
36
|
+
left: ${anchorRect.left}px;
|
|
37
|
+
`;
|
|
38
|
+
case "topRight":
|
|
39
|
+
return styled.css`
|
|
40
|
+
top: ${anchorRect.top - MARGIN - dropdownRect.height}px;
|
|
41
|
+
left: ${anchorRect.right - dropdownRect.width}px;
|
|
42
|
+
`;
|
|
43
|
+
case "right":
|
|
44
|
+
return styled.css`
|
|
45
|
+
top: ${anchorRect.height / 2 - dropdownRect.height / 2 + anchorRect.top}px;
|
|
46
|
+
left: ${anchorRect.left + MARGIN + anchorRect.width}px;
|
|
47
|
+
`;
|
|
48
|
+
case "left":
|
|
49
|
+
return styled.css`
|
|
50
|
+
left: ${anchorRect.left - MARGIN - dropdownRect.width}px;
|
|
51
|
+
top: ${anchorRect.height / 2 - dropdownRect.height / 2 + anchorRect.top}px;
|
|
52
|
+
`;
|
|
53
|
+
default:
|
|
54
|
+
return styled.css``;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const getBorderRadius = (direction) => {
|
|
58
|
+
switch (direction) {
|
|
59
|
+
case "bottomLeft":
|
|
60
|
+
return "0 0.5rem 0.5rem 0.5rem";
|
|
61
|
+
case "bottomRight":
|
|
62
|
+
return "0.5rem 0 0.5rem 0.5rem";
|
|
63
|
+
case "topLeft":
|
|
64
|
+
return "0.5rem 0.5rem 0.5rem 0";
|
|
65
|
+
case "topRight":
|
|
66
|
+
return "0.5rem 0.5rem 0 0.5rem";
|
|
67
|
+
default:
|
|
68
|
+
return "0.5rem";
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const DropdownWrapper = styled.div`
|
|
72
|
+
display: inline-block;
|
|
73
|
+
position: relative;
|
|
74
|
+
height: max-content;
|
|
75
|
+
`;
|
|
76
|
+
const DropdownListWrapper = styled.div.withConfig({
|
|
77
|
+
shouldForwardProp: (prop) => !["anchorRef", "width", "height", "direction"].includes(prop)
|
|
78
|
+
})`
|
|
79
|
+
${({ theme, direction }) => styled.css`
|
|
80
|
+
background: ${theme.colors.grayViolet[3]};
|
|
81
|
+
padding-top: 0.5rem;
|
|
82
|
+
padding-bottom: 0.5rem;
|
|
83
|
+
border-radius: ${getBorderRadius(direction)};
|
|
84
|
+
border: 1px solid ${theme.colors.grayViolet[9]};
|
|
85
|
+
`};
|
|
86
|
+
${({ width }) => width && styled.css`
|
|
87
|
+
width: ${width};
|
|
88
|
+
`};
|
|
89
|
+
|
|
90
|
+
${({ top, left }) => top && left && styled.css`
|
|
91
|
+
left: ${left}px;
|
|
92
|
+
top: ${top}px;
|
|
93
|
+
position: absolute;
|
|
94
|
+
z-index: 1000;
|
|
95
|
+
`};
|
|
96
|
+
`;
|
|
97
|
+
const DropdownListStyled = styled(DropdownList).withConfig({
|
|
98
|
+
shouldForwardProp: (prop) => ![
|
|
99
|
+
"direction",
|
|
100
|
+
"transitionStatus",
|
|
101
|
+
"anchorRect",
|
|
102
|
+
"dropdownRect",
|
|
103
|
+
"maxHeight",
|
|
104
|
+
"minWidth"
|
|
105
|
+
].includes(prop)
|
|
106
|
+
})`
|
|
107
|
+
position: absolute;
|
|
108
|
+
overflow-y: auto;
|
|
109
|
+
max-height: ${({ maxHeight }) => maxHeight}px;
|
|
110
|
+
height: ${({ height }) => height || "max-content"};
|
|
111
|
+
width: ${({ width }) => width || "max-content"};
|
|
112
|
+
min-width: ${({ minWidth }) => `${minWidth}px`};
|
|
113
|
+
|
|
114
|
+
${({ transitionStatus }) => (transitionStatus === "preEnter" || transitionStatus === "exiting") && styled.css`
|
|
115
|
+
opacity: 0;
|
|
116
|
+
transform: scale(0.9);
|
|
117
|
+
`};
|
|
118
|
+
|
|
119
|
+
z-index: 1000;
|
|
120
|
+
${getDirectionStyles};
|
|
121
|
+
`;
|
|
122
|
+
const DropdownItemsWrapper = styled.div`
|
|
123
|
+
display: flex;
|
|
124
|
+
flex-direction: column;
|
|
125
|
+
gap: 0.5rem;
|
|
126
|
+
`;
|
|
127
|
+
const DropdownItemStyled = styled(Text)`
|
|
128
|
+
justify-content: flex-start;
|
|
129
|
+
cursor: ${({ isDisabled }) => isDisabled ? "not-allowed" : "pointer"};
|
|
130
|
+
padding: 0.25rem;
|
|
131
|
+
display: flex;
|
|
132
|
+
gap: 0.25rem;
|
|
133
|
+
|
|
134
|
+
${({ disabled }) => disabled ? styled.css`
|
|
135
|
+
background: ${({ theme }) => theme.colors.gray[3]};
|
|
136
|
+
color: ${({ theme }) => theme.colors.grayViolet[1]};
|
|
137
|
+
` : styled.css`
|
|
138
|
+
&:hover {
|
|
139
|
+
padding-left: calc(0.25rem - 2px);
|
|
140
|
+
background: ${({ theme }) => theme.colors.grayViolet[5]};
|
|
141
|
+
border-left: 2px solid
|
|
142
|
+
${({ theme }) => theme.colors.violet[9]};
|
|
143
|
+
}
|
|
144
|
+
`}
|
|
145
|
+
`;
|
|
146
|
+
exports.DropdownItemStyled = DropdownItemStyled;
|
|
147
|
+
exports.DropdownItemsWrapper = DropdownItemsWrapper;
|
|
148
|
+
exports.DropdownListStyled = DropdownListStyled;
|
|
149
|
+
exports.DropdownListWrapper = DropdownListWrapper;
|
|
150
|
+
exports.DropdownWrapper = DropdownWrapper;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TransitionStatus } from 'react-transition-state';
|
|
2
|
+
import { TDropdownDirection, IDropdownProps, TDropdownListProps } from './types';
|
|
3
|
+
import { TQuenSize } from '../types/size';
|
|
4
|
+
type IDropdownItemStyledProps = {
|
|
5
|
+
size: TQuenSize;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type TDropdownListStyledProps<ITEM> = TDropdownListProps<ITEM> & {
|
|
9
|
+
direction: TDropdownDirection;
|
|
10
|
+
anchorRect: DOMRect;
|
|
11
|
+
dropdownRect: DOMRect;
|
|
12
|
+
maxHeight: number;
|
|
13
|
+
height?: string;
|
|
14
|
+
transitionStatus: TransitionStatus;
|
|
15
|
+
minWidth: number;
|
|
16
|
+
};
|
|
17
|
+
type TDropdownStyledProps = Required<Pick<IDropdownProps, "direction">> & {
|
|
18
|
+
top?: number;
|
|
19
|
+
left?: number;
|
|
20
|
+
width?: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const DropdownWrapper: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
23
|
+
export declare const DropdownListWrapper: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, TDropdownStyledProps>> & string;
|
|
24
|
+
export declare const DropdownListStyled: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<Omit<IDropdownProps<unknown>, "children" | "height"> & {
|
|
25
|
+
top?: number;
|
|
26
|
+
left?: number;
|
|
27
|
+
} & import('react').RefAttributes<HTMLDivElement>, TDropdownListStyledProps<any>>> & string & Omit<import('react').ForwardRefExoticComponent<Omit<IDropdownProps<unknown>, "children" | "height"> & {
|
|
28
|
+
top?: number;
|
|
29
|
+
left?: number;
|
|
30
|
+
} & import('react').RefAttributes<HTMLDivElement>>, keyof import('react').Component<any, {}, any>>;
|
|
31
|
+
export declare const DropdownItemsWrapper: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
32
|
+
export declare const DropdownItemStyled: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('..').ITextProps, IDropdownItemStyledProps>> & string & Omit<import('react').FC<import('..').ITextProps>, keyof import('react').Component<any, {}, any>>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import DropdownList from "./DropdownList.es.js";
|
|
3
|
+
import Text from "../typography/Text/Text.es.js";
|
|
4
|
+
const MARGIN = 8;
|
|
5
|
+
const getDirectionStyles = ({
|
|
6
|
+
direction,
|
|
7
|
+
anchorRect,
|
|
8
|
+
dropdownRect
|
|
9
|
+
}) => {
|
|
10
|
+
switch (direction) {
|
|
11
|
+
case "top":
|
|
12
|
+
return css`
|
|
13
|
+
left: ${anchorRect.left + anchorRect.width / 2 - dropdownRect.width / 2}px;
|
|
14
|
+
top: ${anchorRect.top - MARGIN - dropdownRect.height}px;
|
|
15
|
+
`;
|
|
16
|
+
case "bottom":
|
|
17
|
+
return css`
|
|
18
|
+
top: ${anchorRect.bottom + MARGIN}px;
|
|
19
|
+
left: ${anchorRect.left + anchorRect.width / 2 - dropdownRect.width / 2}px;
|
|
20
|
+
`;
|
|
21
|
+
case "bottomRight":
|
|
22
|
+
return css`
|
|
23
|
+
top: ${anchorRect.bottom + MARGIN}px;
|
|
24
|
+
left: ${anchorRect.right - dropdownRect.width}px;
|
|
25
|
+
`;
|
|
26
|
+
case "bottomLeft":
|
|
27
|
+
return css`
|
|
28
|
+
top: ${anchorRect.bottom + MARGIN}px;
|
|
29
|
+
left: ${anchorRect.left}px;
|
|
30
|
+
`;
|
|
31
|
+
case "topLeft":
|
|
32
|
+
return css`
|
|
33
|
+
top: ${anchorRect.top - MARGIN - dropdownRect.height}px;
|
|
34
|
+
left: ${anchorRect.left}px;
|
|
35
|
+
`;
|
|
36
|
+
case "topRight":
|
|
37
|
+
return css`
|
|
38
|
+
top: ${anchorRect.top - MARGIN - dropdownRect.height}px;
|
|
39
|
+
left: ${anchorRect.right - dropdownRect.width}px;
|
|
40
|
+
`;
|
|
41
|
+
case "right":
|
|
42
|
+
return css`
|
|
43
|
+
top: ${anchorRect.height / 2 - dropdownRect.height / 2 + anchorRect.top}px;
|
|
44
|
+
left: ${anchorRect.left + MARGIN + anchorRect.width}px;
|
|
45
|
+
`;
|
|
46
|
+
case "left":
|
|
47
|
+
return css`
|
|
48
|
+
left: ${anchorRect.left - MARGIN - dropdownRect.width}px;
|
|
49
|
+
top: ${anchorRect.height / 2 - dropdownRect.height / 2 + anchorRect.top}px;
|
|
50
|
+
`;
|
|
51
|
+
default:
|
|
52
|
+
return css``;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const getBorderRadius = (direction) => {
|
|
56
|
+
switch (direction) {
|
|
57
|
+
case "bottomLeft":
|
|
58
|
+
return "0 0.5rem 0.5rem 0.5rem";
|
|
59
|
+
case "bottomRight":
|
|
60
|
+
return "0.5rem 0 0.5rem 0.5rem";
|
|
61
|
+
case "topLeft":
|
|
62
|
+
return "0.5rem 0.5rem 0.5rem 0";
|
|
63
|
+
case "topRight":
|
|
64
|
+
return "0.5rem 0.5rem 0 0.5rem";
|
|
65
|
+
default:
|
|
66
|
+
return "0.5rem";
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const DropdownWrapper = styled.div`
|
|
70
|
+
display: inline-block;
|
|
71
|
+
position: relative;
|
|
72
|
+
height: max-content;
|
|
73
|
+
`;
|
|
74
|
+
const DropdownListWrapper = styled.div.withConfig({
|
|
75
|
+
shouldForwardProp: (prop) => !["anchorRef", "width", "height", "direction"].includes(prop)
|
|
76
|
+
})`
|
|
77
|
+
${({ theme, direction }) => css`
|
|
78
|
+
background: ${theme.colors.grayViolet[3]};
|
|
79
|
+
padding-top: 0.5rem;
|
|
80
|
+
padding-bottom: 0.5rem;
|
|
81
|
+
border-radius: ${getBorderRadius(direction)};
|
|
82
|
+
border: 1px solid ${theme.colors.grayViolet[9]};
|
|
83
|
+
`};
|
|
84
|
+
${({ width }) => width && css`
|
|
85
|
+
width: ${width};
|
|
86
|
+
`};
|
|
87
|
+
|
|
88
|
+
${({ top, left }) => top && left && css`
|
|
89
|
+
left: ${left}px;
|
|
90
|
+
top: ${top}px;
|
|
91
|
+
position: absolute;
|
|
92
|
+
z-index: 1000;
|
|
93
|
+
`};
|
|
94
|
+
`;
|
|
95
|
+
const DropdownListStyled = styled(DropdownList).withConfig({
|
|
96
|
+
shouldForwardProp: (prop) => ![
|
|
97
|
+
"direction",
|
|
98
|
+
"transitionStatus",
|
|
99
|
+
"anchorRect",
|
|
100
|
+
"dropdownRect",
|
|
101
|
+
"maxHeight",
|
|
102
|
+
"minWidth"
|
|
103
|
+
].includes(prop)
|
|
104
|
+
})`
|
|
105
|
+
position: absolute;
|
|
106
|
+
overflow-y: auto;
|
|
107
|
+
max-height: ${({ maxHeight }) => maxHeight}px;
|
|
108
|
+
height: ${({ height }) => height || "max-content"};
|
|
109
|
+
width: ${({ width }) => width || "max-content"};
|
|
110
|
+
min-width: ${({ minWidth }) => `${minWidth}px`};
|
|
111
|
+
|
|
112
|
+
${({ transitionStatus }) => (transitionStatus === "preEnter" || transitionStatus === "exiting") && css`
|
|
113
|
+
opacity: 0;
|
|
114
|
+
transform: scale(0.9);
|
|
115
|
+
`};
|
|
116
|
+
|
|
117
|
+
z-index: 1000;
|
|
118
|
+
${getDirectionStyles};
|
|
119
|
+
`;
|
|
120
|
+
const DropdownItemsWrapper = styled.div`
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
gap: 0.5rem;
|
|
124
|
+
`;
|
|
125
|
+
const DropdownItemStyled = styled(Text)`
|
|
126
|
+
justify-content: flex-start;
|
|
127
|
+
cursor: ${({ isDisabled }) => isDisabled ? "not-allowed" : "pointer"};
|
|
128
|
+
padding: 0.25rem;
|
|
129
|
+
display: flex;
|
|
130
|
+
gap: 0.25rem;
|
|
131
|
+
|
|
132
|
+
${({ disabled }) => disabled ? css`
|
|
133
|
+
background: ${({ theme }) => theme.colors.gray[3]};
|
|
134
|
+
color: ${({ theme }) => theme.colors.grayViolet[1]};
|
|
135
|
+
` : css`
|
|
136
|
+
&:hover {
|
|
137
|
+
padding-left: calc(0.25rem - 2px);
|
|
138
|
+
background: ${({ theme }) => theme.colors.grayViolet[5]};
|
|
139
|
+
border-left: 2px solid
|
|
140
|
+
${({ theme }) => theme.colors.violet[9]};
|
|
141
|
+
}
|
|
142
|
+
`}
|
|
143
|
+
`;
|
|
144
|
+
export {
|
|
145
|
+
DropdownItemStyled,
|
|
146
|
+
DropdownItemsWrapper,
|
|
147
|
+
DropdownListStyled,
|
|
148
|
+
DropdownListWrapper,
|
|
149
|
+
DropdownWrapper
|
|
150
|
+
};
|