@scm-manager/ui-core 3.0.0-20240024-101702

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/.storybook/.babelrc +3 -0
  2. package/.storybook/RemoveThemesPlugin.js +57 -0
  3. package/.storybook/main.js +92 -0
  4. package/.storybook/preview-head.html +25 -0
  5. package/.storybook/preview.js +95 -0
  6. package/.storybook/withApiProvider.js +46 -0
  7. package/docs/introduction.stories.mdx +64 -0
  8. package/docs/usage.stories.mdx +22 -0
  9. package/package.json +81 -0
  10. package/src/base/buttons/Button.stories.tsx +89 -0
  11. package/src/base/buttons/Button.test.stories.mdx +74 -0
  12. package/src/base/buttons/Button.tsx +143 -0
  13. package/src/base/buttons/Icon.tsx +58 -0
  14. package/src/base/buttons/a11y.test.ts +34 -0
  15. package/src/base/buttons/docs/introduction.stories.mdx +64 -0
  16. package/src/base/buttons/docs/usage.stories.mdx +22 -0
  17. package/src/base/buttons/image-snapshot.test.ts +33 -0
  18. package/src/base/buttons/index.ts +26 -0
  19. package/src/base/forms/AddListEntryForm.tsx +127 -0
  20. package/src/base/forms/ConfigurationForm.tsx +59 -0
  21. package/src/base/forms/Form.stories.tsx +453 -0
  22. package/src/base/forms/Form.tsx +215 -0
  23. package/src/base/forms/FormPathContext.tsx +73 -0
  24. package/src/base/forms/FormRow.tsx +37 -0
  25. package/src/base/forms/ScmFormContext.tsx +43 -0
  26. package/src/base/forms/ScmFormListContext.tsx +65 -0
  27. package/src/base/forms/base/Control.tsx +34 -0
  28. package/src/base/forms/base/Field.tsx +35 -0
  29. package/src/base/forms/base/field-message/FieldMessage.tsx +34 -0
  30. package/src/base/forms/base/help/Help.tsx +34 -0
  31. package/src/base/forms/base/label/Label.tsx +35 -0
  32. package/src/base/forms/checkbox/Checkbox.stories.mdx +26 -0
  33. package/src/base/forms/checkbox/Checkbox.tsx +118 -0
  34. package/src/base/forms/checkbox/CheckboxField.tsx +39 -0
  35. package/src/base/forms/checkbox/ControlledCheckboxField.stories.mdx +36 -0
  36. package/src/base/forms/checkbox/ControlledCheckboxField.tsx +82 -0
  37. package/src/base/forms/chip-input/ChipInputField.stories.tsx +75 -0
  38. package/src/base/forms/chip-input/ChipInputField.tsx +169 -0
  39. package/src/base/forms/chip-input/ControlledChipInputField.tsx +111 -0
  40. package/src/base/forms/combobox/Combobox.stories.tsx +125 -0
  41. package/src/base/forms/combobox/Combobox.tsx +223 -0
  42. package/src/base/forms/combobox/ComboboxField.tsx +62 -0
  43. package/src/base/forms/combobox/ControlledComboboxField.tsx +96 -0
  44. package/src/base/forms/headless-chip-input/ChipInput.tsx +237 -0
  45. package/src/base/forms/helpers.ts +74 -0
  46. package/src/base/forms/index.ts +85 -0
  47. package/src/base/forms/input/ControlledInputField.stories.mdx +36 -0
  48. package/src/base/forms/input/ControlledInputField.tsx +87 -0
  49. package/src/base/forms/input/ControlledSecretConfirmationField.stories.mdx +39 -0
  50. package/src/base/forms/input/ControlledSecretConfirmationField.tsx +138 -0
  51. package/src/base/forms/input/Input.stories.mdx +22 -0
  52. package/src/base/forms/input/Input.tsx +46 -0
  53. package/src/base/forms/input/InputField.stories.mdx +22 -0
  54. package/src/base/forms/input/InputField.tsx +61 -0
  55. package/src/base/forms/input/Textarea.stories.mdx +28 -0
  56. package/src/base/forms/input/Textarea.tsx +46 -0
  57. package/src/base/forms/list/ControlledList.tsx +88 -0
  58. package/src/base/forms/radio-button/ControlledRadioGroupField.tsx +94 -0
  59. package/src/base/forms/radio-button/RadioButton.stories.tsx +226 -0
  60. package/src/base/forms/radio-button/RadioButton.tsx +116 -0
  61. package/src/base/forms/radio-button/RadioButtonContext.tsx +42 -0
  62. package/src/base/forms/radio-button/RadioGroup.tsx +49 -0
  63. package/src/base/forms/radio-button/RadioGroupField.tsx +58 -0
  64. package/src/base/forms/resourceHooks.ts +164 -0
  65. package/src/base/forms/select/ControlledSelectField.tsx +87 -0
  66. package/src/base/forms/select/Select.tsx +57 -0
  67. package/src/base/forms/select/SelectField.tsx +63 -0
  68. package/src/base/forms/table/ControlledColumn.tsx +49 -0
  69. package/src/base/forms/table/ControlledTable.tsx +99 -0
  70. package/src/base/forms/variants.ts +27 -0
  71. package/src/base/helpers/devbuild.ts +44 -0
  72. package/src/base/helpers/index.ts +26 -0
  73. package/src/base/helpers/useAriaId.tsx +31 -0
  74. package/src/base/index.ts +34 -0
  75. package/src/base/layout/_helpers/with-classes.tsx +52 -0
  76. package/src/base/layout/card/Card.stories.tsx +113 -0
  77. package/src/base/layout/card/Card.tsx +76 -0
  78. package/src/base/layout/card/CardDetail.tsx +196 -0
  79. package/src/base/layout/card/CardRow.tsx +46 -0
  80. package/src/base/layout/card/CardTitle.tsx +59 -0
  81. package/src/base/layout/card-list/CardList.stories.tsx +201 -0
  82. package/src/base/layout/card-list/CardList.tsx +76 -0
  83. package/src/base/layout/collapsible/Collapsible.stories.tsx +45 -0
  84. package/src/base/layout/collapsible/Collapsible.tsx +87 -0
  85. package/src/base/layout/index.ts +93 -0
  86. package/src/base/layout/tabs/TabTrigger.tsx +46 -0
  87. package/src/base/layout/tabs/Tabs.stories.tsx +48 -0
  88. package/src/base/layout/tabs/Tabs.tsx +52 -0
  89. package/src/base/layout/tabs/TabsContent.tsx +33 -0
  90. package/src/base/layout/tabs/TabsList.tsx +41 -0
  91. package/src/base/layout/templates/data-page/DataPage.stories.tsx +201 -0
  92. package/src/base/layout/templates/data-page/DataPageHeader.tsx +100 -0
  93. package/src/base/misc/Image.tsx +32 -0
  94. package/src/base/misc/Level.tsx +40 -0
  95. package/src/base/misc/Loading.tsx +64 -0
  96. package/src/base/misc/SubSubtitle.tsx +36 -0
  97. package/src/base/misc/Subtitle.tsx +37 -0
  98. package/src/base/misc/Title.tsx +56 -0
  99. package/src/base/misc/index.ts +30 -0
  100. package/src/base/notifications/BackendErrorNotification.tsx +160 -0
  101. package/src/base/notifications/ErrorNotification.tsx +73 -0
  102. package/src/base/notifications/Notification.tsx +48 -0
  103. package/src/base/notifications/index.tsx +27 -0
  104. package/src/base/overlays/dialog/Dialog.stories.tsx +64 -0
  105. package/src/base/overlays/dialog/Dialog.tsx +85 -0
  106. package/src/base/overlays/index.ts +44 -0
  107. package/src/base/overlays/menu/Menu.stories.tsx +78 -0
  108. package/src/base/overlays/menu/Menu.tsx +213 -0
  109. package/src/base/overlays/menu/MenuTrigger.tsx +63 -0
  110. package/src/base/overlays/popover/Popover.stories.tsx +69 -0
  111. package/src/base/overlays/popover/Popover.tsx +95 -0
  112. package/src/base/overlays/tooltip/Tooltip.examples.js +41 -0
  113. package/src/base/overlays/tooltip/Tooltip.stories.mdx +52 -0
  114. package/src/base/overlays/tooltip/Tooltip.tsx +96 -0
  115. package/src/base/shortcuts/index.ts +28 -0
  116. package/src/base/shortcuts/iterator/callbackIterator.ts +220 -0
  117. package/src/base/shortcuts/iterator/keyboardIterator.test.tsx +431 -0
  118. package/src/base/shortcuts/iterator/keyboardIterator.tsx +141 -0
  119. package/src/base/shortcuts/usePauseShortcuts.ts +44 -0
  120. package/src/base/shortcuts/useShortcut.ts +110 -0
  121. package/src/base/shortcuts/useShortcutDocs.tsx +54 -0
  122. package/src/base/text/SplitAndReplace.stories.tsx +83 -0
  123. package/src/base/text/SplitAndReplace.tsx +65 -0
  124. package/src/base/text/index.ts +25 -0
  125. package/src/base/text/textSplitAndReplace.test.ts +134 -0
  126. package/src/base/text/textSplitAndReplace.ts +86 -0
  127. package/src/index.ts +25 -0
  128. package/tsconfig.json +6 -0
@@ -0,0 +1,213 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2020-present Cloudogu GmbH and Contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React, {
26
+ AnchorHTMLAttributes,
27
+ ButtonHTMLAttributes,
28
+ ComponentProps,
29
+ createContext,
30
+ FC,
31
+ ReactNode,
32
+ useCallback,
33
+ useContext,
34
+ useMemo,
35
+ useState,
36
+ } from "react";
37
+ import * as RadixMenu from "@radix-ui/react-dropdown-menu";
38
+ import styled from "styled-components";
39
+ import { DefaultMenuTrigger } from "./MenuTrigger";
40
+ import classNames from "classnames";
41
+ import { Link as ReactRouterLink, LinkProps as ReactRouterLinkProps } from "react-router-dom";
42
+ import Dialog from "../dialog/Dialog";
43
+
44
+ const MenuContent = styled(RadixMenu.Content)`
45
+ border: var(--scm-border);
46
+ background-color: var(--scm-secondary-background);
47
+ position: relative;
48
+ `;
49
+
50
+ const MenuItem = styled(RadixMenu.Item).attrs({
51
+ className:
52
+ "is-flex is-align-items-center px-3 py-2 has-text-inherit is-clickable is-size-6 has-hover-color-blue is-borderless has-background-transparent has-rounded-border",
53
+ })`
54
+ line-height: inherit;
55
+ :focus {
56
+ outline: #af3ee7 3px solid;
57
+ outline-offset: 0px;
58
+ }
59
+ &[data-disabled] {
60
+ color: unset !important;
61
+ opacity: 40%;
62
+ cursor: unset !important;
63
+ }
64
+ `;
65
+
66
+ type MenuLinkProps = Omit<ReactRouterLinkProps, "onSelect"> & Pick<RadixMenu.MenuItemProps, "disabled">;
67
+
68
+ /**
69
+ * @beta
70
+ * @since 2.44.0
71
+ */
72
+ export const MenuLink = React.forwardRef<HTMLAnchorElement, MenuLinkProps>(({ children, disabled, ...props }, ref) => (
73
+ <MenuItem asChild disabled={disabled}>
74
+ <ReactRouterLink ref={ref} {...props}>
75
+ {children}
76
+ </ReactRouterLink>
77
+ </MenuItem>
78
+ ));
79
+
80
+ type MenuExternalLinkProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "onSelect"> &
81
+ Pick<RadixMenu.MenuItemProps, "disabled">;
82
+
83
+ /**
84
+ * External links open in a new browser tab with rel flags "noopener" and "noreferrer" set by default.
85
+ *
86
+ * @beta
87
+ * @since 2.44.0
88
+ */
89
+ export const MenuExternalLink = React.forwardRef<HTMLAnchorElement, MenuExternalLinkProps>(
90
+ ({ children, disabled, ...props }, ref) => (
91
+ <MenuItem asChild disabled={disabled}>
92
+ <a ref={ref} target="_blank" rel="noopener noreferrer" {...props}>
93
+ {children}
94
+ </a>
95
+ </MenuItem>
96
+ )
97
+ );
98
+
99
+ type MenuButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onClick" | "onSelect"> &
100
+ Pick<RadixMenu.MenuItemProps, "onSelect">;
101
+
102
+ /**
103
+ * Use {@link MenuButtonProps#onSelect} to handle menu item selection.
104
+ * The menu will close by default. This behavior can be overwritten by calling {@link Event.preventDefault} on the event.
105
+ *
106
+ * @beta
107
+ * @since 2.44.0
108
+ */
109
+ export const MenuButton = React.forwardRef<HTMLButtonElement, MenuButtonProps>(
110
+ ({ children, onSelect, disabled, ...props }, ref) => (
111
+ <MenuItem asChild disabled={disabled} onSelect={onSelect}>
112
+ <button ref={ref} {...props}>
113
+ {children}
114
+ </button>
115
+ </MenuItem>
116
+ )
117
+ );
118
+
119
+ type MenuContextType = {
120
+ handleDialogItemOpenChange: (open: boolean) => void;
121
+ };
122
+ const MenuContext = createContext<MenuContextType>(null as unknown as MenuContextType);
123
+
124
+ type MenuDialogProps = Omit<MenuButtonProps, "onSelect"> &
125
+ Omit<ComponentProps<typeof Dialog>, "trigger"> & {
126
+ dialogContent?: ReactNode;
127
+ };
128
+
129
+ /**
130
+ * @beta
131
+ * @since 2.46.0
132
+ * @see {@link Dialog}
133
+ */
134
+ export const MenuDialog = React.forwardRef<HTMLButtonElement, MenuDialogProps>(
135
+ ({ children, dialogContent, title, description, footer }, ref) => {
136
+ const { handleDialogItemOpenChange } = useContext(MenuContext);
137
+ const [open, setOpen] = useState(false);
138
+ const handleSelect = useCallback((event: Event) => event.preventDefault(), []);
139
+ const changeOpen = useCallback(
140
+ (newValue: boolean) => {
141
+ setOpen(newValue);
142
+ handleDialogItemOpenChange(newValue);
143
+ },
144
+ [handleDialogItemOpenChange]
145
+ );
146
+
147
+ return (
148
+ <Dialog
149
+ trigger={
150
+ <MenuButton ref={ref} onSelect={handleSelect}>
151
+ {children}
152
+ </MenuButton>
153
+ }
154
+ title={title}
155
+ description={description}
156
+ footer={footer}
157
+ onOpenChange={changeOpen}
158
+ open={open}
159
+ >
160
+ {dialogContent}
161
+ </Dialog>
162
+ );
163
+ }
164
+ );
165
+
166
+ type Props = {
167
+ className?: string;
168
+ trigger?: React.ReactElement;
169
+ } & Pick<RadixMenu.DropdownMenuContentProps, "side">;
170
+
171
+ /**
172
+ * A menu consists of a trigger button (vertical ellipsis icon button by default)
173
+ * and a dropdown container containing individual menu items.
174
+ *
175
+ * @beta
176
+ * @since 2.44.0
177
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/menubar/
178
+ */
179
+ const Menu: FC<Props> = ({ children, side, className, trigger = <DefaultMenuTrigger /> }) => {
180
+ const [dropdownOpen, setDropdownOpen] = useState(false);
181
+ const [hasOpenDialog, setHasOpenDialog] = useState(false);
182
+ const handleDialogItemOpenChange = useCallback((open: boolean) => {
183
+ setHasOpenDialog(open);
184
+ if (!open) {
185
+ setDropdownOpen(false);
186
+ }
187
+ }, []);
188
+ const menuContextValue = useMemo<MenuContextType>(
189
+ () => ({
190
+ handleDialogItemOpenChange,
191
+ }),
192
+ [handleDialogItemOpenChange]
193
+ );
194
+
195
+ return (
196
+ <RadixMenu.Root open={dropdownOpen} onOpenChange={setDropdownOpen} modal={false}>
197
+ {trigger}
198
+ <RadixMenu.Portal>
199
+ <MenuContent
200
+ className={classNames(className, "is-flex is-flex-direction-column has-rounded-border has-box-shadow")}
201
+ side={side}
202
+ sideOffset={4}
203
+ collisionPadding={4}
204
+ hidden={hasOpenDialog}
205
+ >
206
+ <MenuContext.Provider value={menuContextValue}>{children}</MenuContext.Provider>
207
+ </MenuContent>
208
+ </RadixMenu.Portal>
209
+ </RadixMenu.Root>
210
+ );
211
+ };
212
+
213
+ export default Menu;
@@ -0,0 +1,63 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2020-present Cloudogu GmbH and Contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React, { ComponentProps } from "react";
26
+ import { Button, Icon } from "../../buttons";
27
+ import * as RadixMenu from "@radix-ui/react-dropdown-menu";
28
+ import { useTranslation } from "react-i18next";
29
+ import classNames from "classnames";
30
+
31
+ type Props = ComponentProps<typeof Button>;
32
+
33
+ /**
34
+ * @beta
35
+ * @since 2.44.0
36
+ */
37
+ const MenuTrigger = React.forwardRef<HTMLButtonElement, Props>(({ children, ...props }, ref) => (
38
+ <RadixMenu.Trigger asChild>
39
+ <Button ref={ref} {...props}>
40
+ {children}
41
+ </Button>
42
+ </RadixMenu.Trigger>
43
+ ));
44
+
45
+ /**
46
+ * @beta
47
+ * @since 2.44.0
48
+ */
49
+ export const DefaultMenuTrigger = React.forwardRef<HTMLButtonElement, Props>(({ className, ...props }, ref) => {
50
+ const [t] = useTranslation("commons");
51
+ return (
52
+ <MenuTrigger
53
+ aria-label={t("menu.defaultTriggerLabel")}
54
+ className={classNames(className, "is-borderless has-background-transparent has-hover-color-blue px-2")}
55
+ ref={ref}
56
+ {...props}
57
+ >
58
+ <Icon>ellipsis-v</Icon>
59
+ </MenuTrigger>
60
+ );
61
+ });
62
+
63
+ export default MenuTrigger;
@@ -0,0 +1,69 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2020-present Cloudogu GmbH and Contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import Popover from "./Popover";
26
+ import { ComponentMeta, ComponentStory } from "@storybook/react";
27
+ import React from "react";
28
+
29
+ export default {
30
+ title: "Popover",
31
+ component: Popover,
32
+ } as ComponentMeta<typeof Popover>;
33
+
34
+ const Template: ComponentStory<typeof Popover> = (args) => <Popover {...args} />;
35
+
36
+ export const WithShortBody = Template.bind({});
37
+ WithShortBody.args = {
38
+ trigger: <button>a button</button>,
39
+ title: <h1>A title longer than the body</h1>,
40
+ children: <div>very short body</div>,
41
+ };
42
+
43
+ export const CiStatus = Template.bind({});
44
+ CiStatus.args = {
45
+ trigger: (
46
+ <button className={"is-borderless has-background-transparent"}>
47
+ <i className={"fas fa-1x has-text-secondary fa-circle-notch"}></i>
48
+ </button>
49
+ ),
50
+ title: <h1>Analyses: 0 error found</h1>,
51
+ children: (
52
+ <>
53
+ <hr className={"my-2"} />
54
+ <a className={"has-hover-background-blue is-flex is-flex-direction-row px-2 py-2 is-align-items-center"}>
55
+ <i className={"fas fa-1x has-text-secondary fa-circle-notch mr-2"}></i>
56
+ <span className="has-text-default">
57
+ <strong>jenkins:</strong> scm-manager » scm-manager » develop
58
+ </span>
59
+ </a>
60
+ <hr className={"my-2"} />
61
+ <a className={"has-hover-background-blue is-flex is-flex-direction-row px-2 py-2 is-align-items-center"}>
62
+ <i className={"fas fa-1x has-text-secondary fa-circle-notch mr-2"}></i>
63
+ <span className={"has-text-default"}>
64
+ <strong>Sonar:</strong> Sonar
65
+ </span>
66
+ </a>
67
+ </>
68
+ ),
69
+ };
@@ -0,0 +1,95 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2020-present Cloudogu GmbH and Contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React, { ReactElement, ReactNode } from "react";
26
+ import * as RadixPopover from "@radix-ui/react-popover";
27
+ import styled from "styled-components";
28
+ import classNames from "classnames";
29
+ import { useTranslation } from "react-i18next";
30
+
31
+ const StyledContent = styled(RadixPopover.Content)`
32
+ z-index: 1020;
33
+ `;
34
+
35
+ const StyledArrow = styled(RadixPopover.Arrow)`
36
+ fill: var(--scm-popover-border-color);
37
+ z-index: 1020;
38
+ `;
39
+
40
+ const TitleContainer = styled("div")`
41
+ flex: 1;
42
+ `;
43
+
44
+ type Props = {
45
+ /**
46
+ * Element to trigger the popover
47
+ */
48
+ trigger: ReactElement;
49
+
50
+ /**
51
+ * Element for the content of the popover
52
+ */
53
+ children: ReactElement;
54
+
55
+ /**
56
+ * Element for the title row of the popover
57
+ */
58
+ title: ReactNode;
59
+
60
+ /**
61
+ * Classnames for the content of the popover
62
+ */
63
+ className?: string;
64
+ };
65
+
66
+ /**
67
+ * @beta
68
+ * @since 2.46.0
69
+ */
70
+ const Popover = React.forwardRef<HTMLDivElement, Props>(({ title, className, trigger, children }, ref) => {
71
+ const [t] = useTranslation("commons");
72
+
73
+ return (
74
+ <RadixPopover.Root>
75
+ <RadixPopover.Trigger asChild>{trigger}</RadixPopover.Trigger>
76
+ <RadixPopover.Portal>
77
+ <StyledContent
78
+ ref={ref}
79
+ className={classNames("has-rounded-border", "p-2", "popover-content", "box", "popover", className)}
80
+ >
81
+ <div className="is-flex is-align-items-center">
82
+ <TitleContainer className="mr-4">{title}</TitleContainer>
83
+ <RadixPopover.Close asChild>
84
+ <button className="delete popover-close" aria-label={t("popover.closeButton.ariaLabel")} />
85
+ </RadixPopover.Close>
86
+ </div>
87
+ {children}
88
+ <StyledArrow className="popover-arrow" />
89
+ </StyledContent>
90
+ </RadixPopover.Portal>
91
+ </RadixPopover.Root>
92
+ );
93
+ });
94
+
95
+ export default Popover;
@@ -0,0 +1,41 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2020-present Cloudogu GmbH and Contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ export const LongText =
26
+ "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
27
+
28
+ export const ShortList = ` * a
29
+ * b
30
+ * c
31
+ `;
32
+
33
+ export const List = ` Characters:
34
+
35
+ - Arthur Dent
36
+ - Ford Prefect
37
+ - Zaphod Beeblebrox
38
+ - Marvin the Paranoid Android
39
+ - Trillian
40
+ - Slartibartfast
41
+ `;
@@ -0,0 +1,52 @@
1
+ import { Meta, Story } from "@storybook/addon-docs";
2
+ import Tooltip from "./Tooltip"
3
+ import { List, LongText, ShortList } from "./Tooltip.examples";
4
+
5
+ <Meta title="Tooltip"/>
6
+
7
+ Here will be some documentation for the Tooltip component.
8
+
9
+ <Story name="Default">
10
+ <Tooltip message="I am a tooltip!">
11
+ <button>Hover me</button>
12
+ </Tooltip>
13
+ </Story>
14
+
15
+ <Story name="With Styling">
16
+ <Tooltip message="I am a tooltip!" className="has-text-warning">
17
+ <button>Hover me</button>
18
+ </Tooltip>
19
+ </Story>
20
+
21
+ <Story name="Long Text">
22
+ <Tooltip
23
+ message={LongText}>
24
+ <button>Hover me</button>
25
+ </Tooltip>
26
+ </Story>
27
+
28
+ <Story name="List">
29
+ <Tooltip message={List}>
30
+ <button>Hover me</button>
31
+ </Tooltip>
32
+ </Story>
33
+
34
+ <Story name="Short List">
35
+ <Tooltip message={ShortList}>
36
+ <button>Hover me</button>
37
+ </Tooltip>
38
+ </Story>
39
+
40
+ <Story name="With Link">
41
+ <Tooltip message={<p>
42
+ For more information look up the documentation on the <a href="https://scm-manager.org">SCM-Manager</a> Website.
43
+ </p>}>
44
+ <button>Hover me</button>
45
+ </Tooltip>
46
+ </Story>
47
+
48
+ <Story name="Adjust Position">
49
+ <Tooltip message="I should show where there is space" side="left">
50
+ <button>Hover me</button>
51
+ </Tooltip>
52
+ </Story>
@@ -0,0 +1,96 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2020-present Cloudogu GmbH and Contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React, { ReactElement, ReactNode } from "react";
26
+ import * as RadixTooltip from "@radix-ui/react-tooltip";
27
+ import classNames from "classnames";
28
+ import styled from "styled-components";
29
+
30
+ const StyledContent = styled(RadixTooltip.Content)`
31
+ overflow: hidden;
32
+ hyphens: auto;
33
+ text-overflow: clip;
34
+ white-space: pre-wrap;
35
+ max-width: 15rem;
36
+ word-break: keep-all;
37
+ z-index: 1020;
38
+ `;
39
+
40
+ const StyledArrow = styled(RadixTooltip.Arrow)`
41
+ z-index: 1020;
42
+ `;
43
+
44
+ type Props = {
45
+ /**
46
+ * The message to be displayed in the overlay.
47
+ */
48
+ message: ReactNode;
49
+
50
+ /**
51
+ * It is required to provide a {@link ReactElement} as the single child because listeners and metadata is going to be
52
+ * attached to it automatically.
53
+ */
54
+ children: ReactElement;
55
+
56
+ /**
57
+ * Class to be applied to the content container.
58
+ */
59
+ className?: string;
60
+ } & Pick<RadixTooltip.TooltipContentProps, "side">;
61
+
62
+ /**
63
+ * Displays the given {@link Props#message} whenever the provided {@link Props#children} is hovered or focused.
64
+ *
65
+ * @since 2.41.0
66
+ * @beta
67
+ */
68
+ const Tooltip = React.forwardRef<HTMLDivElement, Props>(({ children, className, message, side }, ref) => (
69
+ <RadixTooltip.Provider>
70
+ <RadixTooltip.Root>
71
+ <RadixTooltip.Trigger asChild>{children}</RadixTooltip.Trigger>
72
+ <RadixTooltip.Portal>
73
+ <StyledContent
74
+ className={classNames(
75
+ "is-size-7",
76
+ "is-family-primary",
77
+ "has-rounded-border",
78
+ "has-text-white",
79
+ "has-background-grey-dark",
80
+ "has-text-weight-semibold",
81
+ "p-2",
82
+ className
83
+ )}
84
+ side={side}
85
+ sideOffset={4}
86
+ collisionPadding={4}
87
+ ref={ref}
88
+ >
89
+ {message}
90
+ <StyledArrow className="tooltip-arrow-fill-color" />
91
+ </StyledContent>
92
+ </RadixTooltip.Portal>
93
+ </RadixTooltip.Root>
94
+ </RadixTooltip.Provider>
95
+ ));
96
+ export default Tooltip;
@@ -0,0 +1,28 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2020-present Cloudogu GmbH and Contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ export { default as useShortcut } from "./useShortcut";
26
+ export { default as useShortcutDocs, ShortcutDocsContextProvider } from "./useShortcutDocs";
27
+ export { default as usePauseShortcuts } from "./usePauseShortcuts";
28
+ export { useKeyboardIteratorTarget, KeyboardIterator, KeyboardSubIterator } from "./iterator/keyboardIterator";