@vectara/vectara-ui 0.0.2
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/.github/workflows/deploy-pages-site.yml +26 -0
- package/.github/workflows/deploy-pr-preview.yml +25 -0
- package/CHANGELOG.md +13 -0
- package/NO_LICENSE +3 -0
- package/lib/components/accordion/Accordion.d.ts +8 -0
- package/lib/components/accordion/Accordion.js +27 -0
- package/lib/components/accordion/_index.scss +23 -0
- package/lib/components/accountMenu/AccountMenu.d.ts +13 -0
- package/lib/components/accountMenu/AccountMenu.js +7 -0
- package/lib/components/accountMenu/_index.scss +20 -0
- package/lib/components/app/AppContent.d.ts +9 -0
- package/lib/components/app/AppContent.js +28 -0
- package/lib/components/app/AppHeader.d.ts +7 -0
- package/lib/components/app/AppHeader.js +18 -0
- package/lib/components/app/AppLayout.d.ts +9 -0
- package/lib/components/app/AppLayout.js +10 -0
- package/lib/components/app/_index.scss +4 -0
- package/lib/components/app/appContent.scss +26 -0
- package/lib/components/app/appHeader.scss +15 -0
- package/lib/components/app/appLayout.scss +23 -0
- package/lib/components/app/appSideNav/AppSideNav.d.ts +7 -0
- package/lib/components/app/appSideNav/AppSideNav.js +46 -0
- package/lib/components/app/appSideNav/AppSideNavLink.d.ts +4 -0
- package/lib/components/app/appSideNav/AppSideNavLink.js +26 -0
- package/lib/components/app/appSideNav/AppSideNavSections.d.ts +2 -0
- package/lib/components/app/appSideNav/AppSideNavSections.js +11 -0
- package/lib/components/app/appSideNav/AppSideNavTree.d.ts +2 -0
- package/lib/components/app/appSideNav/AppSideNavTree.js +38 -0
- package/lib/components/app/appSideNav/_index.scss +17 -0
- package/lib/components/app/appSideNav/appSideNav.scss +75 -0
- package/lib/components/app/appSideNav/appSideNavSections.scss +33 -0
- package/lib/components/app/appSideNav/appSideNavTree.scss +25 -0
- package/lib/components/app/types.d.ts +21 -0
- package/lib/components/app/types.js +1 -0
- package/lib/components/badge/Badge.d.ts +14 -0
- package/lib/components/badge/Badge.js +33 -0
- package/lib/components/badge/_index.scss +64 -0
- package/lib/components/button/BaseButton.d.ts +28 -0
- package/lib/components/button/BaseButton.js +65 -0
- package/lib/components/button/ButtonPrimary.d.ts +8 -0
- package/lib/components/button/ButtonPrimary.js +42 -0
- package/lib/components/button/ButtonSecondary.d.ts +10 -0
- package/lib/components/button/ButtonSecondary.js +43 -0
- package/lib/components/button/ButtonTertiary.d.ts +10 -0
- package/lib/components/button/ButtonTertiary.js +43 -0
- package/lib/components/button/IconButton.d.ts +16 -0
- package/lib/components/button/IconButton.js +29 -0
- package/lib/components/button/_index.scss +5 -0
- package/lib/components/button/baseButton.scss +94 -0
- package/lib/components/button/buttonPrimary.scss +51 -0
- package/lib/components/button/buttonSecondary.scss +54 -0
- package/lib/components/button/buttonTertiary.scss +56 -0
- package/lib/components/button/createButtonIcon.d.ts +3 -0
- package/lib/components/button/createButtonIcon.js +24 -0
- package/lib/components/button/iconButton.scss +44 -0
- package/lib/components/button/types.d.ts +3 -0
- package/lib/components/button/types.js +2 -0
- package/lib/components/callout/Callout.d.ts +13 -0
- package/lib/components/callout/Callout.js +40 -0
- package/lib/components/callout/_index.scss +49 -0
- package/lib/components/callout/types.d.ts +3 -0
- package/lib/components/callout/types.js +2 -0
- package/lib/components/card/Card.d.ts +14 -0
- package/lib/components/card/Card.js +29 -0
- package/lib/components/card/_index.scss +114 -0
- package/lib/components/chat/Chat.d.ts +17 -0
- package/lib/components/chat/Chat.js +130 -0
- package/lib/components/chat/ChatInspector.d.ts +7 -0
- package/lib/components/chat/ChatInspector.js +12 -0
- package/lib/components/chat/ChatPanel.d.ts +7 -0
- package/lib/components/chat/ChatPanel.js +11 -0
- package/lib/components/chat/ChatSearchResult.d.ts +16 -0
- package/lib/components/chat/ChatSearchResult.js +26 -0
- package/lib/components/chat/ChatTurn.d.ts +9 -0
- package/lib/components/chat/ChatTurn.js +19 -0
- package/lib/components/chat/_index.scss +150 -0
- package/lib/components/chat/chatTurn.scss +38 -0
- package/lib/components/chat/types.d.ts +17 -0
- package/lib/components/chat/types.js +19 -0
- package/lib/components/code/Code.d.ts +17 -0
- package/lib/components/code/Code.js +44 -0
- package/lib/components/code/_index.scss +33 -0
- package/lib/components/code/types.d.ts +1 -0
- package/lib/components/code/types.js +1 -0
- package/lib/components/context/Context.d.ts +18 -0
- package/lib/components/context/Context.js +34 -0
- package/lib/components/context/Context.test.util.d.ts +2 -0
- package/lib/components/context/Context.test.util.js +22 -0
- package/lib/components/copyButton/CopyButton.d.ts +10 -0
- package/lib/components/copyButton/CopyButton.js +50 -0
- package/lib/components/drawer/Drawer.d.ts +13 -0
- package/lib/components/drawer/Drawer.js +53 -0
- package/lib/components/drawer/_index.scss +73 -0
- package/lib/components/flex/FlexContainer.d.ts +36 -0
- package/lib/components/flex/FlexContainer.js +53 -0
- package/lib/components/flex/FlexItem.d.ts +22 -0
- package/lib/components/flex/FlexItem.js +36 -0
- package/lib/components/flex/_flexContainer.scss +79 -0
- package/lib/components/flex/_flexItem.scss +64 -0
- package/lib/components/flex/_index.scss +2 -0
- package/lib/components/flex/types.d.ts +2 -0
- package/lib/components/flex/types.js +1 -0
- package/lib/components/form/_index.scss +7 -0
- package/lib/components/form/checkbox/Checkbox.d.ts +8 -0
- package/lib/components/form/checkbox/Checkbox.js +24 -0
- package/lib/components/form/checkbox/_index.scss +3 -0
- package/lib/components/form/index.d.ts +10 -0
- package/lib/components/form/index.js +9 -0
- package/lib/components/form/input/BasicInput.d.ts +15 -0
- package/lib/components/form/input/BasicInput.js +30 -0
- package/lib/components/form/input/NumberInput.d.ts +8 -0
- package/lib/components/form/input/NumberInput.js +61 -0
- package/lib/components/form/input/PasswordInput.d.ts +7 -0
- package/lib/components/form/input/PasswordInput.js +21 -0
- package/lib/components/form/input/TextInput.d.ts +6 -0
- package/lib/components/form/input/TextInput.js +21 -0
- package/lib/components/form/input/_index.scss +24 -0
- package/lib/components/form/label/Label.d.ts +7 -0
- package/lib/components/form/label/Label.js +18 -0
- package/lib/components/form/label/_index.scss +5 -0
- package/lib/components/form/radioButton/RadioButton.d.ts +9 -0
- package/lib/components/form/radioButton/RadioButton.js +24 -0
- package/lib/components/form/radioButton/_index.scss +3 -0
- package/lib/components/form/select/Select.d.ts +17 -0
- package/lib/components/form/select/Select.js +34 -0
- package/lib/components/form/select/_index.scss +56 -0
- package/lib/components/form/superRadioGroup/SuperRadioButton.d.ts +7 -0
- package/lib/components/form/superRadioGroup/SuperRadioButton.js +22 -0
- package/lib/components/form/superRadioGroup/SuperRadioGroup.d.ts +8 -0
- package/lib/components/form/superRadioGroup/SuperRadioGroup.js +6 -0
- package/lib/components/form/superRadioGroup/_index.scss +31 -0
- package/lib/components/form/superRadioGroup/types.d.ts +8 -0
- package/lib/components/form/superRadioGroup/types.js +1 -0
- package/lib/components/form/textArea/TextArea.d.ts +12 -0
- package/lib/components/form/textArea/TextArea.js +21 -0
- package/lib/components/form/textArea/_index.scss +14 -0
- package/lib/components/formGroup/FormGroup.d.ts +10 -0
- package/lib/components/formGroup/FormGroup.js +27 -0
- package/lib/components/grid/Grid.d.ts +12 -0
- package/lib/components/grid/Grid.js +20 -0
- package/lib/components/grid/_index.scss +51 -0
- package/lib/components/horizontalRule/HorizontalRule.d.ts +6 -0
- package/lib/components/horizontalRule/HorizontalRule.js +4 -0
- package/lib/components/horizontalRule/_index.scss +40 -0
- package/lib/components/icon/Icon.d.ts +11 -0
- package/lib/components/icon/Icon.js +37 -0
- package/lib/components/icon/_index.scss +25 -0
- package/lib/components/icon/types.d.ts +2 -0
- package/lib/components/icon/types.js +12 -0
- package/lib/components/index.d.ts +75 -0
- package/lib/components/index.js +67 -0
- package/lib/components/infoTable/InfoTable.d.ts +24 -0
- package/lib/components/infoTable/InfoTable.js +24 -0
- package/lib/components/infoTable/_index.scss +53 -0
- package/lib/components/link/Link.d.ts +3 -0
- package/lib/components/link/Link.js +36 -0
- package/lib/components/link/Link.test.d.ts +1 -0
- package/lib/components/link/Link.test.js +40 -0
- package/lib/components/link/_index.scss +17 -0
- package/lib/components/link/types.d.ts +15 -0
- package/lib/components/link/types.js +1 -0
- package/lib/components/list/List.d.ts +12 -0
- package/lib/components/list/List.js +15 -0
- package/lib/components/list/_index.scss +29 -0
- package/lib/components/menu/Menu.d.ts +7 -0
- package/lib/components/menu/Menu.js +6 -0
- package/lib/components/menu/MenuItem.d.ts +10 -0
- package/lib/components/menu/MenuItem.js +31 -0
- package/lib/components/menu/_index.scss +75 -0
- package/lib/components/modal/Modal.d.ts +13 -0
- package/lib/components/modal/Modal.js +53 -0
- package/lib/components/modal/_index.scss +85 -0
- package/lib/components/notification/Notification.d.ts +12 -0
- package/lib/components/notification/Notification.js +23 -0
- package/lib/components/notification/Notifications.d.ts +10 -0
- package/lib/components/notification/Notifications.js +35 -0
- package/lib/components/notification/_index.scss +99 -0
- package/lib/components/optionsButton/OptionsButton.d.ts +7 -0
- package/lib/components/optionsButton/OptionsButton.js +25 -0
- package/lib/components/optionsButton/_index.scss +42 -0
- package/lib/components/optionsList/OptionsList.d.ts +13 -0
- package/lib/components/optionsList/OptionsList.js +31 -0
- package/lib/components/optionsList/OptionsListItem.d.ts +10 -0
- package/lib/components/optionsList/OptionsListItem.js +41 -0
- package/lib/components/optionsList/_index.scss +84 -0
- package/lib/components/optionsList/types.d.ts +13 -0
- package/lib/components/optionsList/types.js +1 -0
- package/lib/components/popover/Popover.d.ts +11 -0
- package/lib/components/popover/Popover.js +91 -0
- package/lib/components/popover/_index.scss +29 -0
- package/lib/components/portal/Portal.d.ts +6 -0
- package/lib/components/portal/Portal.js +16 -0
- package/lib/components/progressBar/ProgressBar.d.ts +9 -0
- package/lib/components/progressBar/ProgressBar.js +26 -0
- package/lib/components/progressBar/_index.scss +63 -0
- package/lib/components/prompt/Prompt.d.ts +20 -0
- package/lib/components/prompt/Prompt.js +19 -0
- package/lib/components/prompt/_index.scss +70 -0
- package/lib/components/screenBlock/ScreenBlock.d.ts +6 -0
- package/lib/components/screenBlock/ScreenBlock.js +4 -0
- package/lib/components/screenBlock/_index.scss +17 -0
- package/lib/components/searchInput/SearchInput.d.ts +13 -0
- package/lib/components/searchInput/SearchInput.js +19 -0
- package/lib/components/searchInput/_index.scss +49 -0
- package/lib/components/searchResult/SearchResult.d.ts +21 -0
- package/lib/components/searchResult/SearchResult.js +33 -0
- package/lib/components/searchResult/SearchResult.test.d.ts +1 -0
- package/lib/components/searchResult/SearchResult.test.js +280 -0
- package/lib/components/searchResult/_index.scss +29 -0
- package/lib/components/searchSelect/SearchSelect.d.ts +11 -0
- package/lib/components/searchSelect/SearchSelect.js +78 -0
- package/lib/components/searchSelect/_index.scss +13 -0
- package/lib/components/setting/Setting.d.ts +12 -0
- package/lib/components/setting/Setting.js +24 -0
- package/lib/components/spacer/Spacer.d.ts +6 -0
- package/lib/components/spacer/Spacer.js +6 -0
- package/lib/components/spacer/_index.scss +20 -0
- package/lib/components/spacer/types.d.ts +1 -0
- package/lib/components/spacer/types.js +1 -0
- package/lib/components/spinner/Spinner.d.ts +7 -0
- package/lib/components/spinner/Spinner.js +15 -0
- package/lib/components/spinner/_index.scss +52 -0
- package/lib/components/spinner/types.d.ts +3 -0
- package/lib/components/spinner/types.js +2 -0
- package/lib/components/statList/StatList.d.ts +9 -0
- package/lib/components/statList/StatList.js +15 -0
- package/lib/components/statList/_index.scss +3 -0
- package/lib/components/status/Status.d.ts +6 -0
- package/lib/components/status/Status.js +24 -0
- package/lib/components/summary/Summary.d.ts +7 -0
- package/lib/components/summary/Summary.js +43 -0
- package/lib/components/summary/Summary.test.d.ts +1 -0
- package/lib/components/summary/Summary.test.js +544 -0
- package/lib/components/summary/SummaryCitation.d.ts +8 -0
- package/lib/components/summary/SummaryCitation.js +20 -0
- package/lib/components/summary/_index.scss +29 -0
- package/lib/components/table/Table.d.ts +44 -0
- package/lib/components/table/Table.js +117 -0
- package/lib/components/table/TableBulkActions.d.ts +7 -0
- package/lib/components/table/TableBulkActions.js +34 -0
- package/lib/components/table/TableCell.d.ts +5 -0
- package/lib/components/table/TableCell.js +4 -0
- package/lib/components/table/TableContent.d.ts +6 -0
- package/lib/components/table/TableContent.js +6 -0
- package/lib/components/table/TableHeaderCell.d.ts +9 -0
- package/lib/components/table/TableHeaderCell.js +8 -0
- package/lib/components/table/TablePager.d.ts +9 -0
- package/lib/components/table/TablePager.js +9 -0
- package/lib/components/table/TablePagination.d.ts +10 -0
- package/lib/components/table/TablePagination.js +18 -0
- package/lib/components/table/TableRowActions.d.ts +15 -0
- package/lib/components/table/TableRowActions.js +29 -0
- package/lib/components/table/_index.scss +70 -0
- package/lib/components/table/createPagination.d.ts +4 -0
- package/lib/components/table/createPagination.js +44 -0
- package/lib/components/table/createPagination.test.d.ts +1 -0
- package/lib/components/table/createPagination.test.js +32 -0
- package/lib/components/table/types.d.ts +1 -0
- package/lib/components/table/types.js +1 -0
- package/lib/components/tabs/Tab.d.ts +9 -0
- package/lib/components/tabs/Tab.js +27 -0
- package/lib/components/tabs/TabbedRoutes.d.ts +15 -0
- package/lib/components/tabs/TabbedRoutes.js +15 -0
- package/lib/components/tabs/Tabs.d.ts +10 -0
- package/lib/components/tabs/Tabs.js +8 -0
- package/lib/components/tabs/_index.scss +103 -0
- package/lib/components/tabs/types.d.ts +2 -0
- package/lib/components/tabs/types.js +1 -0
- package/lib/components/toggle/Toggle.d.ts +8 -0
- package/lib/components/toggle/Toggle.js +25 -0
- package/lib/components/toggle/_index.scss +55 -0
- package/lib/components/topicButton/TopicButton.d.ts +10 -0
- package/lib/components/topicButton/TopicButton.js +30 -0
- package/lib/components/topicButton/_index.scss +21 -0
- package/lib/components/typography/Text.d.ts +13 -0
- package/lib/components/typography/Text.js +24 -0
- package/lib/components/typography/TextColor.d.ts +9 -0
- package/lib/components/typography/TextColor.js +6 -0
- package/lib/components/typography/Title.d.ts +11 -0
- package/lib/components/typography/Title.js +20 -0
- package/lib/components/typography/_index.scss +3 -0
- package/lib/components/typography/_text.scss +150 -0
- package/lib/components/typography/_textColor.scss +15 -0
- package/lib/components/typography/_title.scss +68 -0
- package/lib/components/typography/types.d.ts +4 -0
- package/lib/components/typography/types.js +3 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/sassUtils/_animation.scss +1 -0
- package/lib/sassUtils/_app.scss +1 -0
- package/lib/sassUtils/_borders.scss +2 -0
- package/lib/sassUtils/_colors.scss +24 -0
- package/lib/sassUtils/_depth.scss +8 -0
- package/lib/sassUtils/_mixins.scss +11 -0
- package/lib/sassUtils/_shadows.scss +5 -0
- package/lib/sassUtils/_sizes.scss +10 -0
- package/lib/sassUtils/_typography.scss +20 -0
- package/lib/sassUtils/index.scss +10 -0
- package/lib/styles/index.css +3229 -0
- package/lib/utils/citations/applyCitationOrder.d.ts +1 -0
- package/lib/utils/citations/applyCitationOrder.js +19 -0
- package/lib/utils/citations/applyCitationOrder.test.d.ts +1 -0
- package/lib/utils/citations/applyCitationOrder.test.js +65 -0
- package/lib/utils/citations/extractCitations.d.ts +4 -0
- package/lib/utils/citations/extractCitations.js +26 -0
- package/lib/utils/citations/extractCitations.test.d.ts +1 -0
- package/lib/utils/citations/extractCitations.test.js +40 -0
- package/lib/utils/citations/index.d.ts +5 -0
- package/lib/utils/citations/index.js +5 -0
- package/lib/utils/citations/removeCitations.d.ts +1 -0
- package/lib/utils/citations/removeCitations.js +2 -0
- package/lib/utils/citations/removeCitations.test.d.ts +1 -0
- package/lib/utils/citations/removeCitations.test.js +11 -0
- package/lib/utils/citations/reorderCitations.d.ts +1 -0
- package/lib/utils/citations/reorderCitations.js +9 -0
- package/lib/utils/citations/reorderCitations.test.d.ts +1 -0
- package/lib/utils/citations/reorderCitations.test.js +6 -0
- package/lib/utils/citations/sanitizeCitations.d.ts +1 -0
- package/lib/utils/citations/sanitizeCitations.js +30 -0
- package/lib/utils/citations/sanitizeCitations.test.d.ts +1 -0
- package/lib/utils/citations/sanitizeCitations.test.js +11 -0
- package/lib/utils/createId.d.ts +1 -0
- package/lib/utils/createId.js +10 -0
- package/lib/utils/getTrackingProps.d.ts +7 -0
- package/lib/utils/getTrackingProps.js +18 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/utils/truncateString.d.ts +2 -0
- package/lib/utils/truncateString.js +20 -0
- package/lib/utils/truncateString.test.d.ts +1 -0
- package/lib/utils/truncateString.test.js +59 -0
- package/licenses.txt +9035 -0
- package/package.json +100 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { BiX } from "react-icons/bi";
|
|
4
|
+
import { VuiText } from "../typography/Text";
|
|
5
|
+
import { VuiTextColor } from "../typography/TextColor";
|
|
6
|
+
import { VuiFlexContainer } from "../flex/FlexContainer";
|
|
7
|
+
import { VuiFlexItem } from "../flex/FlexItem";
|
|
8
|
+
import { VuiIconButton } from "../button/IconButton";
|
|
9
|
+
import { VuiIcon } from "../icon/Icon";
|
|
10
|
+
import { VuiSpacer } from "../spacer/Spacer";
|
|
11
|
+
import { VuiHorizontalRule } from "../horizontalRule/HorizontalRule";
|
|
12
|
+
export const VuiNotification = ({ notification, onDismiss, notificationsCount, children }) => {
|
|
13
|
+
const { color, message } = notification;
|
|
14
|
+
const classes = classNames("vuiNotification", `vuiNotification--${color}`);
|
|
15
|
+
const hasManyNotifications = notificationsCount > 1;
|
|
16
|
+
const placeholder1Classes = classNames("vuiNotification", "vuiNotificationPlaceholder", {
|
|
17
|
+
"vuiNotificationPlaceholder1-isVisible": notificationsCount > 1
|
|
18
|
+
});
|
|
19
|
+
const placeholder2Classes = classNames("vuiNotification", "vuiNotificationPlaceholder", {
|
|
20
|
+
"vuiNotificationPlaceholder2-isVisible": notificationsCount > 2
|
|
21
|
+
});
|
|
22
|
+
return (_jsxs("div", Object.assign({ className: "vuiNotificationContainer" }, { children: [_jsxs("div", Object.assign({ className: classes }, { children: [_jsxs(VuiFlexContainer, Object.assign({ alignItems: "start", spacing: "s" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx(VuiIconButton, { size: "xs", color: "neutral", icon: _jsx(VuiIcon, { children: _jsx(BiX, {}) }), onClick: () => onDismiss(notification) }) })), _jsxs(VuiFlexItem, Object.assign({ grow: 1 }, { children: [_jsx(VuiText, { children: _jsx(VuiTextColor, Object.assign({ color: color }, { children: message })) }), hasManyNotifications && (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "xxs" }), _jsx(VuiText, Object.assign({ size: "xs" }, { children: _jsxs(VuiTextColor, Object.assign({ color: "subdued" }, { children: ["+", notificationsCount - 1, " more"] })) }))] }))] }))] })), children && (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "s" }), _jsx(VuiHorizontalRule, {}), _jsx(VuiSpacer, { size: "xxs" }), children] }))] })), _jsx("div", { className: placeholder2Classes }), _jsx("div", { className: placeholder1Classes })] })));
|
|
23
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Notification } from "./Notification";
|
|
2
|
+
type Props = {
|
|
3
|
+
notifications: Notification[];
|
|
4
|
+
onShowAll: () => void;
|
|
5
|
+
onDismiss: (notification: Notification) => void;
|
|
6
|
+
onDismissAll: () => void;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const VuiNotifications: ({ notifications, onShowAll, onDismiss, onDismissAll, onClose }: Props) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { VuiButtonSecondary } from "../button/ButtonSecondary";
|
|
4
|
+
import { VuiFlexContainer } from "../flex/FlexContainer";
|
|
5
|
+
import { VuiFlexItem } from "../flex/FlexItem";
|
|
6
|
+
import { VuiSpacer } from "../spacer/Spacer";
|
|
7
|
+
import { VuiNotification } from "./Notification";
|
|
8
|
+
import { useEffect, useRef } from "react";
|
|
9
|
+
import { VuiButtonTertiary } from "../button/ButtonTertiary";
|
|
10
|
+
export const VuiNotifications = ({ notifications, onShowAll, onDismiss, onDismissAll, onClose }) => {
|
|
11
|
+
const timeoutRef = useRef();
|
|
12
|
+
const startTimeout = () => {
|
|
13
|
+
clearTimeout(timeoutRef.current);
|
|
14
|
+
timeoutRef.current = setTimeout(() => {
|
|
15
|
+
onClose();
|
|
16
|
+
}, 8000);
|
|
17
|
+
return timeoutRef.current;
|
|
18
|
+
};
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
startTimeout();
|
|
21
|
+
return () => clearTimeout(timeoutRef.current);
|
|
22
|
+
}, [notifications]);
|
|
23
|
+
const onMouseEnter = () => {
|
|
24
|
+
clearTimeout(timeoutRef.current);
|
|
25
|
+
};
|
|
26
|
+
const onMouseLeave = () => {
|
|
27
|
+
startTimeout();
|
|
28
|
+
};
|
|
29
|
+
if (!notifications.length)
|
|
30
|
+
return null;
|
|
31
|
+
const classes = classNames("vuiNotificationList", {
|
|
32
|
+
"vuiNotificationList--hasMany": notifications.length > 1
|
|
33
|
+
});
|
|
34
|
+
return (_jsx("div", Object.assign({ className: classes, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, { children: _jsx("div", Object.assign({ className: "vuiNotificationList__notifications" }, { children: _jsx(VuiNotification, Object.assign({ notification: notifications[notifications.length - 1], onDismiss: onDismiss, notificationsCount: notifications.length }, { children: notifications.length > 1 && (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "xs" }), _jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", justifyContent: "spaceBetween" }, { children: [_jsx(VuiFlexItem, { children: _jsx(VuiButtonTertiary, Object.assign({ size: "s", color: "primary", onClick: onDismissAll }, { children: "Dismiss all" })) }), _jsx(VuiFlexItem, { children: _jsx(VuiButtonSecondary, Object.assign({ size: "s", color: "primary", onClick: onShowAll }, { children: "See all" })) })] }))] })) })) })) })));
|
|
35
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
.vuiNotificationList {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
right: 0;
|
|
5
|
+
z-index: $notificationsZIndex;
|
|
6
|
+
animation: popTop 0.4s cubic-bezier(0.5, 0, 0.5, 1) 1;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.vuiNotificationList__notifications {
|
|
10
|
+
padding: $sizeXxs;
|
|
11
|
+
border-bottom-left-radius: $sizeM;
|
|
12
|
+
transition: all $transitionSpeed;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.vuiNotificationList--hasMany {
|
|
16
|
+
.vuiNotificationList__notifications {
|
|
17
|
+
border-bottom-left-radius: $sizeXs;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.vuiNotificationContainer {
|
|
22
|
+
position: relative;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.vuiNotification {
|
|
26
|
+
position: relative;
|
|
27
|
+
z-index: 1;
|
|
28
|
+
border-radius: $sizeS;
|
|
29
|
+
padding: $sizeS;
|
|
30
|
+
font-size: $fontSizeStandard;
|
|
31
|
+
color: $colorText;
|
|
32
|
+
width: 420px;
|
|
33
|
+
box-shadow: $shadowLargeStart;
|
|
34
|
+
background-color: $colorEmptyShade;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.vuiNotificationPlaceholder {
|
|
38
|
+
position: absolute;
|
|
39
|
+
z-index: 0;
|
|
40
|
+
bottom: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.vuiNotificationPlaceholder1-isVisible {
|
|
44
|
+
bottom: -$sizeXxs;
|
|
45
|
+
animation: popBottom1 0.2s cubic-bezier(0.5, 0, 0.5, 1) 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.vuiNotificationPlaceholder2-isVisible {
|
|
49
|
+
bottom: -$sizeXxs * 1.75;
|
|
50
|
+
animation: popBottom2 0.2s cubic-bezier(0.5, 0, 0.5, 1) 1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@keyframes popTop {
|
|
54
|
+
0% {
|
|
55
|
+
transform: translateY(-100%);
|
|
56
|
+
opacity: 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
50% {
|
|
60
|
+
transform: translateY(10px);
|
|
61
|
+
opacity: 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
100% {
|
|
65
|
+
transform: translateX(0);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@keyframes popBottom1 {
|
|
70
|
+
0% {
|
|
71
|
+
transform: translateY(0);
|
|
72
|
+
opacity: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
50% {
|
|
76
|
+
transform: translateY(2px);
|
|
77
|
+
opacity: 1;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
100% {
|
|
81
|
+
transform: translateY(0);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@keyframes popBottom2 {
|
|
86
|
+
0% {
|
|
87
|
+
transform: translateY(0);
|
|
88
|
+
opacity: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
50% {
|
|
92
|
+
transform: translateY(8x);
|
|
93
|
+
opacity: 1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
100% {
|
|
97
|
+
transform: translateY(0);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Props as ButtonPrimaryProps } from "../button/ButtonPrimary";
|
|
2
|
+
import { Props as OptionsListProps } from "../optionsList/OptionsList";
|
|
3
|
+
import { Props as PopoverProps } from "../popover/Popover";
|
|
4
|
+
export type Props = Pick<PopoverProps, "isOpen" | "setIsOpen"> & Pick<OptionsListProps<any>, "options" | "onSelectOption"> & Pick<ButtonPrimaryProps, "children" | "icon" | "color" | "size" | "className" | "fullWidth" | "onClick"> & {
|
|
5
|
+
type?: "primary" | "secondary";
|
|
6
|
+
};
|
|
7
|
+
export declare const VuiOptionsButton: ({ type, isOpen, setIsOpen, children, icon, color, size, className, fullWidth, onSelectOption, options, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { BiCaretDown } from "react-icons/bi";
|
|
14
|
+
import { VuiButtonPrimary } from "../button/ButtonPrimary";
|
|
15
|
+
import { VuiFlexContainer } from "../flex/FlexContainer";
|
|
16
|
+
import { VuiFlexItem } from "../flex/FlexItem";
|
|
17
|
+
import { VuiOptionsList } from "../optionsList/OptionsList";
|
|
18
|
+
import { VuiIcon } from "../icon/Icon";
|
|
19
|
+
import { VuiPopover } from "../popover/Popover";
|
|
20
|
+
import { VuiButtonSecondary } from "../button/ButtonSecondary";
|
|
21
|
+
export const VuiOptionsButton = (_a) => {
|
|
22
|
+
var { type = "primary", isOpen, setIsOpen, children, icon, color, size, className, fullWidth, onSelectOption, options } = _a, rest = __rest(_a, ["type", "isOpen", "setIsOpen", "children", "icon", "color", "size", "className", "fullWidth", "onSelectOption", "options"]);
|
|
23
|
+
const Button = type === "primary" ? VuiButtonPrimary : VuiButtonSecondary;
|
|
24
|
+
return (_jsxs(VuiFlexContainer, Object.assign({ spacing: "none", alignItems: "center", className: className }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx(Button, Object.assign({ icon: icon, color: color, size: size, className: "vuiOptionsButtonLeft", fullWidth: fullWidth }, rest, { children: children })) })), _jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx(VuiPopover, Object.assign({ isOpen: isOpen, setIsOpen: () => setIsOpen(!isOpen), button: _jsx(Button, { color: color, size: size, className: `vuiOptionsButtonRight vuiOptionsButtonRight--${color}`, isSelected: isOpen, icon: _jsx(VuiIcon, { children: _jsx(BiCaretDown, {}) }) }) }, { children: _jsx(VuiOptionsList, { onSelectOption: onSelectOption, options: options }) })) }))] })));
|
|
25
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.vuiOptionsButtonLeft {
|
|
2
|
+
border-top-right-radius: 0;
|
|
3
|
+
border-bottom-right-radius: 0;
|
|
4
|
+
border-right: none;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.vuiOptionsButtonRight {
|
|
8
|
+
border-top-left-radius: 0;
|
|
9
|
+
border-bottom-left-radius: 0;
|
|
10
|
+
border-left: 1px solid;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Color
|
|
14
|
+
$colorPrimaryButton: (
|
|
15
|
+
accent: transparentize($colorEmptyShade, 0.5),
|
|
16
|
+
primary: transparentize($colorEmptyShade, 0.5),
|
|
17
|
+
success: transparentize($colorEmptyShade, 0.5),
|
|
18
|
+
danger: transparentize($colorEmptyShade, 0.5),
|
|
19
|
+
warning: transparentize($colorEmptyShade, 0.5),
|
|
20
|
+
neutral: transparentize($colorText, 0.8)
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
@each $colorName, $colorValue in $colorPrimaryButton {
|
|
24
|
+
.vuiButtonPrimary.vuiOptionsButtonRight--#{$colorName} {
|
|
25
|
+
border-left-color: $colorValue;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
$coloSecondaryButton: (
|
|
30
|
+
accent: transparentize($colorAccent, 0.7),
|
|
31
|
+
primary: transparentize($colorPrimary, 0.7),
|
|
32
|
+
success: transparentize($colorSuccess, 0.7),
|
|
33
|
+
danger: transparentize($colorDanger, 0.7),
|
|
34
|
+
warning: transparentize($colorWarning, 0.7),
|
|
35
|
+
neutral: transparentize($colorText, 0.8)
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
@each $colorName, $colorValue in $coloSecondaryButton {
|
|
39
|
+
.vuiButtonSecondary.vuiOptionsButtonRight--#{$colorName} {
|
|
40
|
+
border-left-color: $colorValue;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OptionListItem } from "./types";
|
|
2
|
+
declare const SIZE: readonly ["s", "m", "l"];
|
|
3
|
+
export type Props<T> = {
|
|
4
|
+
className?: string;
|
|
5
|
+
options: OptionListItem<T>[];
|
|
6
|
+
onSelectOption?: (value: T) => void;
|
|
7
|
+
selected?: T | T[];
|
|
8
|
+
isSelectable?: boolean;
|
|
9
|
+
isScrollable?: boolean;
|
|
10
|
+
size?: (typeof SIZE)[number];
|
|
11
|
+
};
|
|
12
|
+
export declare const VuiOptionsList: <T extends unknown = unknown>({ className, options, onSelectOption, selected, isSelectable, isScrollable, size, ...rest }: Props<T>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import classNames from "classnames";
|
|
14
|
+
import { VuiOptionsListItem } from "./OptionsListItem";
|
|
15
|
+
const SIZE = ["s", "m", "l"];
|
|
16
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/4062
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
18
|
+
export const VuiOptionsList = (_a) => {
|
|
19
|
+
var { className, options, onSelectOption, selected, isSelectable = false, isScrollable = false, size = "s" } = _a, rest = __rest(_a, ["className", "options", "onSelectOption", "selected", "isSelectable", "isScrollable", "size"]);
|
|
20
|
+
const classes = classNames("vuiOptionsList", `vuiOptionsList--${size}`, {
|
|
21
|
+
"vuiOptionsList--scrollable": isScrollable
|
|
22
|
+
}, className);
|
|
23
|
+
return (_jsx("div", Object.assign({ className: classes }, rest, { children: options.map((_a) => {
|
|
24
|
+
var { value, label, onClick } = _a, rest = __rest(_a, ["value", "label", "onClick"]);
|
|
25
|
+
const isSelected = Array.isArray(selected) ? selected.includes(value) : value === selected;
|
|
26
|
+
return (_jsx(VuiOptionsListItem, Object.assign({ value: value, label: label, onClick: () => {
|
|
27
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(value);
|
|
28
|
+
onSelectOption === null || onSelectOption === void 0 ? void 0 : onSelectOption(value);
|
|
29
|
+
}, isSelectable: isSelectable, isSelected: isSelected }, rest), label));
|
|
30
|
+
}) })));
|
|
31
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OptionListItem } from "./types";
|
|
2
|
+
import { LinkProps } from "../link/types";
|
|
3
|
+
export declare const colorIcon: (icon: OptionListItem<string>["icon"], color: OptionListItem<string>["color"]) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
|
|
4
|
+
type Props<T> = OptionListItem<T> & {
|
|
5
|
+
isSelectable?: boolean;
|
|
6
|
+
isSelected?: boolean;
|
|
7
|
+
target?: LinkProps["target"];
|
|
8
|
+
};
|
|
9
|
+
export declare const VuiOptionsListItem: <T extends unknown = unknown>({ value, label, icon, color, href, target, onClick, isSelectable, isSelected, testId, ...rest }: Props<T>) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { cloneElement } from "react";
|
|
14
|
+
import { BiCheck } from "react-icons/bi";
|
|
15
|
+
import classNames from "classnames";
|
|
16
|
+
import { VuiFlexContainer } from "../flex/FlexContainer";
|
|
17
|
+
import { VuiFlexItem } from "../flex/FlexItem";
|
|
18
|
+
import { VuiIcon } from "../icon/Icon";
|
|
19
|
+
import { useVuiContext } from "../context/Context";
|
|
20
|
+
export const colorIcon = (icon, color) => {
|
|
21
|
+
return icon
|
|
22
|
+
? cloneElement(icon, {
|
|
23
|
+
color,
|
|
24
|
+
size: "s"
|
|
25
|
+
})
|
|
26
|
+
: null;
|
|
27
|
+
};
|
|
28
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/4062
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
30
|
+
export const VuiOptionsListItem = (_a) => {
|
|
31
|
+
var { value, label, icon, color = "neutral", href, target, onClick, isSelectable, isSelected, testId } = _a, rest = __rest(_a, ["value", "label", "icon", "color", "href", "target", "onClick", "isSelectable", "isSelected", "testId"]);
|
|
32
|
+
const { createLink } = useVuiContext();
|
|
33
|
+
const labelContent = icon ? (_jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xs" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: colorIcon(icon, color) })), _jsx(VuiFlexItem, Object.assign({ grow: 1 }, { children: label }))] }))) : (label);
|
|
34
|
+
const content = (_jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xs" }, { children: [isSelectable && (_jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx(VuiIcon, Object.assign({ className: isSelected ? "" : "vuiOptionsListItem__selected--unselected", color: "accent", size: "s" }, { children: _jsx(BiCheck, {}) })) }))), _jsx(VuiFlexItem, Object.assign({ grow: false }, { children: labelContent }))] })));
|
|
35
|
+
const classes = classNames("vuiOptionsListItem", `vuiOptionsListItem--${color}`);
|
|
36
|
+
if (href) {
|
|
37
|
+
return createLink(Object.assign({ className: classes, href,
|
|
38
|
+
target, onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(value), "data-testid": testId, children: content }, rest));
|
|
39
|
+
}
|
|
40
|
+
return (_jsx("button", Object.assign({ className: classes, onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(value), "data-testid": testId }, rest, { children: content })));
|
|
41
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
@use "sass:map";
|
|
2
|
+
|
|
3
|
+
.vuiOptionsList {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
font-size: $fontSizeStandard;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.vuiOptionsList--scrollable {
|
|
10
|
+
max-height: 220px;
|
|
11
|
+
overflow-y: auto;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.vuiOptionsList--s {
|
|
15
|
+
.vuiOptionsListItem {
|
|
16
|
+
padding: ($sizeXxs + 1px) $sizeXs;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.vuiOptionsList--m {
|
|
21
|
+
.vuiOptionsListItem {
|
|
22
|
+
padding: ($sizeXxs + 1px) $sizeS;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.vuiOptionsList--l {
|
|
27
|
+
.vuiOptionsListItem {
|
|
28
|
+
padding: $sizeXs $sizeS;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.vuiOptionsListItem {
|
|
33
|
+
background-color: $colorEmptyShade;
|
|
34
|
+
text-decoration: none;
|
|
35
|
+
|
|
36
|
+
&:hover {
|
|
37
|
+
text-decoration: underline;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Color
|
|
42
|
+
$color: (
|
|
43
|
+
accent: (
|
|
44
|
+
"color": $colorAccent,
|
|
45
|
+
"hover-color": $colorAccent,
|
|
46
|
+
"selected-color": $colorAccentLightShade
|
|
47
|
+
),
|
|
48
|
+
primary: (
|
|
49
|
+
"color": $colorPrimary,
|
|
50
|
+
"hover-color": $colorPrimary,
|
|
51
|
+
"selected-color": $colorPrimaryLighterShade
|
|
52
|
+
),
|
|
53
|
+
success: (
|
|
54
|
+
"color": $colorSuccess,
|
|
55
|
+
"hover-color": $colorSuccess,
|
|
56
|
+
"selected-color": $colorSuccessLightShade
|
|
57
|
+
),
|
|
58
|
+
danger: (
|
|
59
|
+
"color": $colorDanger,
|
|
60
|
+
"hover-color": $colorDanger,
|
|
61
|
+
"selected-color": $colorDangerLightShade
|
|
62
|
+
),
|
|
63
|
+
warning: (
|
|
64
|
+
"color": $colorWarning,
|
|
65
|
+
"hover-color": $colorWarning,
|
|
66
|
+
"selected-color": $colorWarningLightShade
|
|
67
|
+
),
|
|
68
|
+
neutral: (
|
|
69
|
+
"color": $colorText,
|
|
70
|
+
"hover-color": $colorPrimary,
|
|
71
|
+
"selected-color": $colorPrimaryLighterShade
|
|
72
|
+
)
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
@each $colorName, $colorValue in $color {
|
|
76
|
+
.vuiOptionsListItem--#{$colorName} {
|
|
77
|
+
color: #{map.get($colorValue, "color")};
|
|
78
|
+
|
|
79
|
+
&:hover {
|
|
80
|
+
color: #{map.get($colorValue, "hover-color")};
|
|
81
|
+
background-color: #{map.get($colorValue, "selected-color")};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import { TextColor } from "../typography/types";
|
|
3
|
+
import { LinkProps } from "../link/types";
|
|
4
|
+
export type OptionListItem<T> = {
|
|
5
|
+
value: T;
|
|
6
|
+
label: string;
|
|
7
|
+
icon?: ReactElement | null;
|
|
8
|
+
href?: string;
|
|
9
|
+
target?: LinkProps["target"];
|
|
10
|
+
onClick?: (value: T) => void;
|
|
11
|
+
color?: TextColor;
|
|
12
|
+
testId?: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type Props = {
|
|
3
|
+
button: React.ReactElement;
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
header?: React.ReactNode;
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
setIsOpen: (isOpen: boolean) => void;
|
|
9
|
+
padding?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const VuiPopover: ({ button: originalButton, children, className, header, isOpen, setIsOpen, padding, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { cloneElement, useEffect, useRef, useState } from "react";
|
|
14
|
+
import classNames from "classnames";
|
|
15
|
+
import { VuiPortal } from "../portal/Portal";
|
|
16
|
+
import { FocusOn } from "react-focus-on";
|
|
17
|
+
const getPosition = (button) => {
|
|
18
|
+
if (!button)
|
|
19
|
+
return undefined;
|
|
20
|
+
const { bottom, right } = button.getBoundingClientRect();
|
|
21
|
+
return {
|
|
22
|
+
top: bottom + 2 + document.documentElement.scrollTop,
|
|
23
|
+
right: window.innerWidth - right
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export const VuiPopover = (_a) => {
|
|
27
|
+
var { button: originalButton, children, className, header, isOpen, setIsOpen, padding } = _a, rest = __rest(_a, ["button", "children", "className", "header", "isOpen", "setIsOpen", "padding"]);
|
|
28
|
+
const returnFocusElRef = useRef(null);
|
|
29
|
+
const buttonRef = useRef(null);
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
31
|
+
const [positionMarker, setPositionMarker] = useState(0);
|
|
32
|
+
const button = cloneElement(originalButton, {
|
|
33
|
+
isSelected: isOpen,
|
|
34
|
+
onClick: () => {
|
|
35
|
+
setIsOpen(!isOpen);
|
|
36
|
+
},
|
|
37
|
+
ref: (node) => {
|
|
38
|
+
buttonRef.current = node;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const updatePosition = () => {
|
|
43
|
+
// Force a re-render when the window resizes.
|
|
44
|
+
setPositionMarker(Date.now());
|
|
45
|
+
};
|
|
46
|
+
window.removeEventListener("resize", updatePosition);
|
|
47
|
+
// Mostly defensive to prevent weird bugs where the popover ends
|
|
48
|
+
// up being rendered partially off-screen.
|
|
49
|
+
window.removeEventListener("scroll", updatePosition);
|
|
50
|
+
return () => {
|
|
51
|
+
window.removeEventListener("resize", updatePosition);
|
|
52
|
+
window.removeEventListener("scroll", updatePosition);
|
|
53
|
+
};
|
|
54
|
+
}, []);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
var _a;
|
|
57
|
+
if (isOpen) {
|
|
58
|
+
returnFocusElRef.current = document.activeElement;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
(_a = returnFocusElRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
62
|
+
returnFocusElRef.current = null;
|
|
63
|
+
}
|
|
64
|
+
}, [isOpen]);
|
|
65
|
+
// Allow contents to respond to blur events before unmounting, and also
|
|
66
|
+
// enable focus to properly return to the button when the user clicks
|
|
67
|
+
// outside of the popover.
|
|
68
|
+
const onCloseDelayed = () => {
|
|
69
|
+
window.setTimeout(() => {
|
|
70
|
+
setIsOpen(false);
|
|
71
|
+
}, 0);
|
|
72
|
+
};
|
|
73
|
+
// Always keep menu position up to date. If we tried to cache this inside
|
|
74
|
+
// a useEffect based on isOpen then there'd be a flicker if the width
|
|
75
|
+
// of the button changes.
|
|
76
|
+
const position = getPosition(buttonRef.current);
|
|
77
|
+
const classes = classNames("vuiPopover", className);
|
|
78
|
+
const contentClasses = classNames("vuiPopoverContent", {
|
|
79
|
+
"vuiPopoverContent--padding": padding
|
|
80
|
+
});
|
|
81
|
+
return (_jsxs(_Fragment, { children: [button, _jsx(VuiPortal, { children: isOpen && position && (_jsx(FocusOn, Object.assign({ onEscapeKey: onCloseDelayed, onClickOutside: onCloseDelayed,
|
|
82
|
+
// Enable manual focus return to work.
|
|
83
|
+
returnFocus: false,
|
|
84
|
+
// Enable focus on contents when it's open,
|
|
85
|
+
// but enable manual focus return to work when it's closed.
|
|
86
|
+
autoFocus: isOpen,
|
|
87
|
+
// Enable scrolling of the page.
|
|
88
|
+
scrollLock: false,
|
|
89
|
+
// Enable scrolling of the page.
|
|
90
|
+
preventScrollOnFocus: false }, { children: _jsxs("div", Object.assign({ className: classes, style: { top: `${position.top}px`, right: `${position.right}px` } }, rest, { children: [header && typeof header === "string" ? _jsx("div", Object.assign({ className: "vuiPopoverTitle" }, { children: header })) : header, children && _jsx("div", Object.assign({ className: contentClasses }, { children: children }))] })) }))) })] }));
|
|
91
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.vuiPopover {
|
|
2
|
+
position: absolute;
|
|
3
|
+
background-color: $colorEmptyShade;
|
|
4
|
+
border: 1px solid $borderColor;
|
|
5
|
+
z-index: $popoverZIndex;
|
|
6
|
+
box-shadow: $shadowLargeEnd;
|
|
7
|
+
border-radius: $sizeXxs;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.vuiOptionsListItem__selected--unselected {
|
|
12
|
+
visibility: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.vuiPopoverTitle {
|
|
16
|
+
padding: $sizeXs $sizeS;
|
|
17
|
+
border-bottom: 1px solid $borderColor;
|
|
18
|
+
font-weight: $fontWeightBold;
|
|
19
|
+
font-size: $fontSizeStandard;
|
|
20
|
+
color: $colorDarkerShade;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.vuiPopoverContent {
|
|
24
|
+
padding: $sizeXxs 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.vuiPopoverContent--padding {
|
|
28
|
+
padding: $sizeS;
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
export const VuiPortal = ({ children }) => {
|
|
4
|
+
const portalRef = useRef(null);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
portalRef.current = document.createElement("div");
|
|
7
|
+
document.body.appendChild(portalRef.current);
|
|
8
|
+
return () => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
(_b = (_a = portalRef.current) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(portalRef.current);
|
|
11
|
+
};
|
|
12
|
+
}, []);
|
|
13
|
+
if (!portalRef.current)
|
|
14
|
+
return null;
|
|
15
|
+
return createPortal(children, portalRef.current);
|
|
16
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const PROGRESS_BAR_COLOR: readonly ["accent", "primary", "danger", "warning", "success", "neutral"];
|
|
2
|
+
type Props = {
|
|
3
|
+
color: (typeof PROGRESS_BAR_COLOR)[number];
|
|
4
|
+
percentage: number;
|
|
5
|
+
className?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const VuiProgressBar: ({ color, percentage, className, value, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import classNames from "classnames";
|
|
14
|
+
import { VuiFlexContainer } from "../flex/FlexContainer";
|
|
15
|
+
import { VuiFlexItem } from "../flex/FlexItem";
|
|
16
|
+
import { VuiText } from "../typography/Text";
|
|
17
|
+
export const PROGRESS_BAR_COLOR = ["accent", "primary", "danger", "warning", "success", "neutral"];
|
|
18
|
+
export const VuiProgressBar = (_a) => {
|
|
19
|
+
var { color, percentage, className, value } = _a, rest = __rest(_a, ["color", "percentage", "className", "value"]);
|
|
20
|
+
const classes = classNames(className, "vuiProgressBar", `vuiProgressBar--${color}`);
|
|
21
|
+
const bar = (_jsxs("div", Object.assign({ className: classes }, rest, { children: [_jsx("div", { className: "vuiProgressBar__empty" }), _jsx("div", { className: "vuiProgressBar__bar", style: { width: `${percentage}%` } }), _jsx("div", { className: "vuiProgressBar__outline" })] })));
|
|
22
|
+
if (value) {
|
|
23
|
+
return (_jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xs" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiText, { children: _jsx("p", { children: value }) }) })), _jsx(VuiFlexItem, Object.assign({ grow: 1 }, { children: bar }))] })));
|
|
24
|
+
}
|
|
25
|
+
return bar;
|
|
26
|
+
};
|