@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.
- package/.storybook/.babelrc +3 -0
- package/.storybook/RemoveThemesPlugin.js +57 -0
- package/.storybook/main.js +92 -0
- package/.storybook/preview-head.html +25 -0
- package/.storybook/preview.js +95 -0
- package/.storybook/withApiProvider.js +46 -0
- package/docs/introduction.stories.mdx +64 -0
- package/docs/usage.stories.mdx +22 -0
- package/package.json +81 -0
- package/src/base/buttons/Button.stories.tsx +89 -0
- package/src/base/buttons/Button.test.stories.mdx +74 -0
- package/src/base/buttons/Button.tsx +143 -0
- package/src/base/buttons/Icon.tsx +58 -0
- package/src/base/buttons/a11y.test.ts +34 -0
- package/src/base/buttons/docs/introduction.stories.mdx +64 -0
- package/src/base/buttons/docs/usage.stories.mdx +22 -0
- package/src/base/buttons/image-snapshot.test.ts +33 -0
- package/src/base/buttons/index.ts +26 -0
- package/src/base/forms/AddListEntryForm.tsx +127 -0
- package/src/base/forms/ConfigurationForm.tsx +59 -0
- package/src/base/forms/Form.stories.tsx +453 -0
- package/src/base/forms/Form.tsx +215 -0
- package/src/base/forms/FormPathContext.tsx +73 -0
- package/src/base/forms/FormRow.tsx +37 -0
- package/src/base/forms/ScmFormContext.tsx +43 -0
- package/src/base/forms/ScmFormListContext.tsx +65 -0
- package/src/base/forms/base/Control.tsx +34 -0
- package/src/base/forms/base/Field.tsx +35 -0
- package/src/base/forms/base/field-message/FieldMessage.tsx +34 -0
- package/src/base/forms/base/help/Help.tsx +34 -0
- package/src/base/forms/base/label/Label.tsx +35 -0
- package/src/base/forms/checkbox/Checkbox.stories.mdx +26 -0
- package/src/base/forms/checkbox/Checkbox.tsx +118 -0
- package/src/base/forms/checkbox/CheckboxField.tsx +39 -0
- package/src/base/forms/checkbox/ControlledCheckboxField.stories.mdx +36 -0
- package/src/base/forms/checkbox/ControlledCheckboxField.tsx +82 -0
- package/src/base/forms/chip-input/ChipInputField.stories.tsx +75 -0
- package/src/base/forms/chip-input/ChipInputField.tsx +169 -0
- package/src/base/forms/chip-input/ControlledChipInputField.tsx +111 -0
- package/src/base/forms/combobox/Combobox.stories.tsx +125 -0
- package/src/base/forms/combobox/Combobox.tsx +223 -0
- package/src/base/forms/combobox/ComboboxField.tsx +62 -0
- package/src/base/forms/combobox/ControlledComboboxField.tsx +96 -0
- package/src/base/forms/headless-chip-input/ChipInput.tsx +237 -0
- package/src/base/forms/helpers.ts +74 -0
- package/src/base/forms/index.ts +85 -0
- package/src/base/forms/input/ControlledInputField.stories.mdx +36 -0
- package/src/base/forms/input/ControlledInputField.tsx +87 -0
- package/src/base/forms/input/ControlledSecretConfirmationField.stories.mdx +39 -0
- package/src/base/forms/input/ControlledSecretConfirmationField.tsx +138 -0
- package/src/base/forms/input/Input.stories.mdx +22 -0
- package/src/base/forms/input/Input.tsx +46 -0
- package/src/base/forms/input/InputField.stories.mdx +22 -0
- package/src/base/forms/input/InputField.tsx +61 -0
- package/src/base/forms/input/Textarea.stories.mdx +28 -0
- package/src/base/forms/input/Textarea.tsx +46 -0
- package/src/base/forms/list/ControlledList.tsx +88 -0
- package/src/base/forms/radio-button/ControlledRadioGroupField.tsx +94 -0
- package/src/base/forms/radio-button/RadioButton.stories.tsx +226 -0
- package/src/base/forms/radio-button/RadioButton.tsx +116 -0
- package/src/base/forms/radio-button/RadioButtonContext.tsx +42 -0
- package/src/base/forms/radio-button/RadioGroup.tsx +49 -0
- package/src/base/forms/radio-button/RadioGroupField.tsx +58 -0
- package/src/base/forms/resourceHooks.ts +164 -0
- package/src/base/forms/select/ControlledSelectField.tsx +87 -0
- package/src/base/forms/select/Select.tsx +57 -0
- package/src/base/forms/select/SelectField.tsx +63 -0
- package/src/base/forms/table/ControlledColumn.tsx +49 -0
- package/src/base/forms/table/ControlledTable.tsx +99 -0
- package/src/base/forms/variants.ts +27 -0
- package/src/base/helpers/devbuild.ts +44 -0
- package/src/base/helpers/index.ts +26 -0
- package/src/base/helpers/useAriaId.tsx +31 -0
- package/src/base/index.ts +34 -0
- package/src/base/layout/_helpers/with-classes.tsx +52 -0
- package/src/base/layout/card/Card.stories.tsx +113 -0
- package/src/base/layout/card/Card.tsx +76 -0
- package/src/base/layout/card/CardDetail.tsx +196 -0
- package/src/base/layout/card/CardRow.tsx +46 -0
- package/src/base/layout/card/CardTitle.tsx +59 -0
- package/src/base/layout/card-list/CardList.stories.tsx +201 -0
- package/src/base/layout/card-list/CardList.tsx +76 -0
- package/src/base/layout/collapsible/Collapsible.stories.tsx +45 -0
- package/src/base/layout/collapsible/Collapsible.tsx +87 -0
- package/src/base/layout/index.ts +93 -0
- package/src/base/layout/tabs/TabTrigger.tsx +46 -0
- package/src/base/layout/tabs/Tabs.stories.tsx +48 -0
- package/src/base/layout/tabs/Tabs.tsx +52 -0
- package/src/base/layout/tabs/TabsContent.tsx +33 -0
- package/src/base/layout/tabs/TabsList.tsx +41 -0
- package/src/base/layout/templates/data-page/DataPage.stories.tsx +201 -0
- package/src/base/layout/templates/data-page/DataPageHeader.tsx +100 -0
- package/src/base/misc/Image.tsx +32 -0
- package/src/base/misc/Level.tsx +40 -0
- package/src/base/misc/Loading.tsx +64 -0
- package/src/base/misc/SubSubtitle.tsx +36 -0
- package/src/base/misc/Subtitle.tsx +37 -0
- package/src/base/misc/Title.tsx +56 -0
- package/src/base/misc/index.ts +30 -0
- package/src/base/notifications/BackendErrorNotification.tsx +160 -0
- package/src/base/notifications/ErrorNotification.tsx +73 -0
- package/src/base/notifications/Notification.tsx +48 -0
- package/src/base/notifications/index.tsx +27 -0
- package/src/base/overlays/dialog/Dialog.stories.tsx +64 -0
- package/src/base/overlays/dialog/Dialog.tsx +85 -0
- package/src/base/overlays/index.ts +44 -0
- package/src/base/overlays/menu/Menu.stories.tsx +78 -0
- package/src/base/overlays/menu/Menu.tsx +213 -0
- package/src/base/overlays/menu/MenuTrigger.tsx +63 -0
- package/src/base/overlays/popover/Popover.stories.tsx +69 -0
- package/src/base/overlays/popover/Popover.tsx +95 -0
- package/src/base/overlays/tooltip/Tooltip.examples.js +41 -0
- package/src/base/overlays/tooltip/Tooltip.stories.mdx +52 -0
- package/src/base/overlays/tooltip/Tooltip.tsx +96 -0
- package/src/base/shortcuts/index.ts +28 -0
- package/src/base/shortcuts/iterator/callbackIterator.ts +220 -0
- package/src/base/shortcuts/iterator/keyboardIterator.test.tsx +431 -0
- package/src/base/shortcuts/iterator/keyboardIterator.tsx +141 -0
- package/src/base/shortcuts/usePauseShortcuts.ts +44 -0
- package/src/base/shortcuts/useShortcut.ts +110 -0
- package/src/base/shortcuts/useShortcutDocs.tsx +54 -0
- package/src/base/text/SplitAndReplace.stories.tsx +83 -0
- package/src/base/text/SplitAndReplace.tsx +65 -0
- package/src/base/text/index.ts +25 -0
- package/src/base/text/textSplitAndReplace.test.ts +134 -0
- package/src/base/text/textSplitAndReplace.ts +86 -0
- package/src/index.ts +25 -0
- package/tsconfig.json +6 -0
|
@@ -0,0 +1,201 @@
|
|
|
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 StoryRouter from "storybook-react-router";
|
|
26
|
+
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
|
27
|
+
import React from "react";
|
|
28
|
+
import { Link } from "react-router-dom";
|
|
29
|
+
import CardList, { CardListBox, CardListCard } from "./CardList";
|
|
30
|
+
import CardTitle from "../card/CardTitle";
|
|
31
|
+
import { Menu } from "../../overlays";
|
|
32
|
+
import { Icon } from "../../buttons";
|
|
33
|
+
import CardRow, { SecondaryRow } from "../card/CardRow";
|
|
34
|
+
import { CardDetail, CardDetailLabel, CardDetails, CardDetailTag, CardLinkDetail } from "../card/CardDetail";
|
|
35
|
+
|
|
36
|
+
export default {
|
|
37
|
+
title: "CardList",
|
|
38
|
+
component: CardList,
|
|
39
|
+
decorators: [StoryRouter()],
|
|
40
|
+
} as ComponentMeta<typeof CardList>;
|
|
41
|
+
|
|
42
|
+
export const Default: ComponentStory<typeof CardListBox> = () => (
|
|
43
|
+
<CardListBox>
|
|
44
|
+
<CardListCard
|
|
45
|
+
action={
|
|
46
|
+
<Menu>
|
|
47
|
+
<Menu.Button>
|
|
48
|
+
<Icon>trash</Icon>
|
|
49
|
+
Delete
|
|
50
|
+
</Menu.Button>
|
|
51
|
+
</Menu>
|
|
52
|
+
}
|
|
53
|
+
>
|
|
54
|
+
<CardRow>
|
|
55
|
+
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
|
|
56
|
+
dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
|
|
57
|
+
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,
|
|
58
|
+
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed
|
|
59
|
+
diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
|
|
60
|
+
takimata sanctus est Lorem ipsum dolor sit amet.
|
|
61
|
+
</CardRow>
|
|
62
|
+
</CardListCard>
|
|
63
|
+
<CardListCard>
|
|
64
|
+
<CardRow>
|
|
65
|
+
<CardTitle>My favorite repository</CardTitle>
|
|
66
|
+
</CardRow>
|
|
67
|
+
</CardListCard>
|
|
68
|
+
<CardListCard
|
|
69
|
+
action={
|
|
70
|
+
<Menu>
|
|
71
|
+
<Menu.Button>
|
|
72
|
+
<Icon>trash</Icon>
|
|
73
|
+
Delete
|
|
74
|
+
</Menu.Button>
|
|
75
|
+
</Menu>
|
|
76
|
+
}
|
|
77
|
+
>
|
|
78
|
+
<CardRow>
|
|
79
|
+
<CardTitle level={5}>
|
|
80
|
+
<Link aria-label="Edit My least liked repo" to="/cards/1">
|
|
81
|
+
My favorite repository with a very long title and some other things
|
|
82
|
+
</Link>
|
|
83
|
+
</CardTitle>
|
|
84
|
+
</CardRow>
|
|
85
|
+
</CardListCard>
|
|
86
|
+
<CardListCard>
|
|
87
|
+
<CardRow>
|
|
88
|
+
<CardTitle>
|
|
89
|
+
<Link aria-label="Edit My least liked repo" to="/cards/1">
|
|
90
|
+
My least liked repo
|
|
91
|
+
</Link>
|
|
92
|
+
</CardTitle>
|
|
93
|
+
</CardRow>
|
|
94
|
+
</CardListCard>
|
|
95
|
+
<CardListCard
|
|
96
|
+
action={
|
|
97
|
+
<Menu>
|
|
98
|
+
<Menu.Button>
|
|
99
|
+
<Icon>trash</Icon>
|
|
100
|
+
Delete
|
|
101
|
+
</Menu.Button>
|
|
102
|
+
</Menu>
|
|
103
|
+
}
|
|
104
|
+
>
|
|
105
|
+
<CardRow className="is-flex is-justify-content-space-between">
|
|
106
|
+
<CardTitle>
|
|
107
|
+
<Link aria-label="Edit My other favorite repository" to="/cards/1">
|
|
108
|
+
My other favorite repository
|
|
109
|
+
</Link>
|
|
110
|
+
</CardTitle>
|
|
111
|
+
(TAG)
|
|
112
|
+
</CardRow>
|
|
113
|
+
<CardRow className="is-size-6">
|
|
114
|
+
This is a card description in the second row. Highlighting how the layout flows if there are multiple rows in
|
|
115
|
+
one card while the card also has an action.
|
|
116
|
+
</CardRow>
|
|
117
|
+
<CardRow className="is-size-6 is-flex is-justify-content-space-between">
|
|
118
|
+
<span>This is a third row, lets see how this works out.</span>(MERGED)
|
|
119
|
+
</CardRow>
|
|
120
|
+
</CardListCard>
|
|
121
|
+
<CardListCard>
|
|
122
|
+
<CardRow className="is-flex is-align-items-center">
|
|
123
|
+
<CardTitle>
|
|
124
|
+
<Link
|
|
125
|
+
aria-label="Edit Enhance descriptions to differentiate between dumps with and without metadata."
|
|
126
|
+
to="/cards/1"
|
|
127
|
+
>
|
|
128
|
+
Enhance descriptions to differentiate between dumps with and without metadata.
|
|
129
|
+
</Link>
|
|
130
|
+
</CardTitle>
|
|
131
|
+
<small>#13456</small>
|
|
132
|
+
</CardRow>
|
|
133
|
+
<CardRow className="is-size-6">
|
|
134
|
+
Another Name requested to merge <strong>feature/asdkjertg</strong> into <strong>develop</strong> about 3 months
|
|
135
|
+
ago.
|
|
136
|
+
</CardRow>
|
|
137
|
+
<CardRow className="is-size-6 is-flex is-justify-content-space-between">
|
|
138
|
+
<div>
|
|
139
|
+
<span>Tasks (3/3)</span>
|
|
140
|
+
<span>Reviewers (1)</span>
|
|
141
|
+
<span>Analyses (✓)</span>
|
|
142
|
+
<span>Workflow (✓)</span>
|
|
143
|
+
</div>
|
|
144
|
+
<span>(OPEN)</span>
|
|
145
|
+
</CardRow>
|
|
146
|
+
</CardListCard>
|
|
147
|
+
<CardListCard>
|
|
148
|
+
<CardRow>
|
|
149
|
+
<CardTitle>
|
|
150
|
+
<Link aria-label="Edit My least liked repo" to="/cards/1">
|
|
151
|
+
My least liked repo
|
|
152
|
+
</Link>
|
|
153
|
+
</CardTitle>
|
|
154
|
+
</CardRow>
|
|
155
|
+
<CardRow>
|
|
156
|
+
<CardDetails>
|
|
157
|
+
<CardDetail>
|
|
158
|
+
<CardDetailLabel>Workers</CardDetailLabel>
|
|
159
|
+
<CardDetailTag>2/3</CardDetailTag>
|
|
160
|
+
</CardDetail>
|
|
161
|
+
<CardLinkDetail to="/my/detail">
|
|
162
|
+
<CardDetailLabel>Go to docs</CardDetailLabel>
|
|
163
|
+
</CardLinkDetail>
|
|
164
|
+
</CardDetails>
|
|
165
|
+
</CardRow>
|
|
166
|
+
</CardListCard>
|
|
167
|
+
<CardListCard avatar={<Icon>user</Icon>} action={<Icon>ellipsis-v</Icon>}>
|
|
168
|
+
<CardRow>
|
|
169
|
+
<CardTitle>
|
|
170
|
+
3c991eec687444630c0929e4e23d8a1a2565011d4bea28d4338dd1d024bb74c8
|
|
171
|
+
c076ca5eea66545ee227c8854acc8b9bf075676a6848d54fa0bc1fa291f78887
|
|
172
|
+
72d7e2ef64c9575dd8ceeed8ed6b24f185646deb6595b13fd51c5705c61a2c46
|
|
173
|
+
9127daa67e066bc49f39cca9670b92de3d576ac1fb9c916e9b44692923e12a9d
|
|
174
|
+
14d07434e8c5b3d0ba2e752bc580888a30963d4e8021be573392bb625f6150da
|
|
175
|
+
60fc6f2e7503b1ca5963afb627ef560f4e2191c0da4c9328ae4ab088e177fb41
|
|
176
|
+
749e63a6af1731d5c599e960a2f6c8cb9a15d6cf6a82493f419d417829f7b2a8
|
|
177
|
+
0ca9334aeda2e5dab101e4af13c9610839afc3b9dd2ec56ffb067d6914ce9b67
|
|
178
|
+
b708983948a1750f79fbb91875399fcce453410dad6191c5dc5059f4b28aee1d
|
|
179
|
+
0d13a4349270947bc79cfc59c7c2aa59960d847a49b40feccd3388fa9a600a68
|
|
180
|
+
</CardTitle>
|
|
181
|
+
</CardRow>
|
|
182
|
+
<SecondaryRow className="is-ellipsis-overflow">
|
|
183
|
+
7cab5486ab8cd946af71a77d37c84bac c05156ef54a1f0bfd5d4fa12f774148c 4f2964e1895470b6313e3264fef276d8
|
|
184
|
+
8c57fdf7fde5fc227ea0c59a0f359122 3bc64067ff6fb9c64f4ae5ac15e4375d 91943ad0c020859ad6cc3723fe9bd325
|
|
185
|
+
07bb6d93d9faf2df68d02949ec10e58e 0bee2b579b7ab5777683f3d5b5975960 4a3009269d971f555524374e7da745ad
|
|
186
|
+
a693ffb57da89f191249de6480c2387b
|
|
187
|
+
</SecondaryRow>
|
|
188
|
+
<CardRow>
|
|
189
|
+
<CardDetails>
|
|
190
|
+
<CardDetail>
|
|
191
|
+
<CardDetailLabel>Workers</CardDetailLabel>
|
|
192
|
+
<CardDetailTag>2/3</CardDetailTag>
|
|
193
|
+
</CardDetail>
|
|
194
|
+
<CardLinkDetail to="/to/docs">
|
|
195
|
+
<CardDetailLabel>Go to docs</CardDetailLabel>
|
|
196
|
+
</CardLinkDetail>
|
|
197
|
+
</CardDetails>
|
|
198
|
+
</CardRow>
|
|
199
|
+
</CardListCard>
|
|
200
|
+
</CardListBox>
|
|
201
|
+
);
|
|
@@ -0,0 +1,76 @@
|
|
|
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, HTMLAttributes } from "react";
|
|
26
|
+
import classNames from "classnames";
|
|
27
|
+
import styled from "styled-components";
|
|
28
|
+
import Card from "../card/Card";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @beta
|
|
32
|
+
* @since 2.44.0
|
|
33
|
+
* @see Card
|
|
34
|
+
*/
|
|
35
|
+
export const CardListCard = React.forwardRef<HTMLElement, Omit<ComponentProps<typeof Card>, "as">>((props, ref) => (
|
|
36
|
+
<Card ref={ref} {...props} as="li" />
|
|
37
|
+
));
|
|
38
|
+
|
|
39
|
+
const CardListElement = styled.ul`
|
|
40
|
+
> * + * {
|
|
41
|
+
margin-top: calc(0.5rem + 1px);
|
|
42
|
+
|
|
43
|
+
&::before {
|
|
44
|
+
content: "";
|
|
45
|
+
position: absolute;
|
|
46
|
+
width: 100%;
|
|
47
|
+
border-top: var(--scm-border);
|
|
48
|
+
left: 0;
|
|
49
|
+
top: calc(-0.25rem - 1px);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
type Props = HTMLAttributes<HTMLUListElement>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @beta
|
|
58
|
+
* @since 2.44.0
|
|
59
|
+
*/
|
|
60
|
+
const CardList = React.forwardRef<HTMLUListElement, Props>(({ children, className, ...props }, ref) => (
|
|
61
|
+
<CardListElement ref={ref} {...props} className={classNames(className, "is-flex", "is-flex-direction-column")}>
|
|
62
|
+
{children}
|
|
63
|
+
</CardListElement>
|
|
64
|
+
));
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @beta
|
|
68
|
+
* @since 2.44.0
|
|
69
|
+
*/
|
|
70
|
+
export const CardListBox = React.forwardRef<HTMLUListElement, Props>(({ className, children, ...props }, ref) => (
|
|
71
|
+
<CardList className={classNames(className, "p-2 box")} ref={ref} {...props}>
|
|
72
|
+
{children}
|
|
73
|
+
</CardList>
|
|
74
|
+
));
|
|
75
|
+
|
|
76
|
+
export default CardList;
|
|
@@ -0,0 +1,45 @@
|
|
|
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 StoryRouter from "storybook-react-router";
|
|
26
|
+
import { ComponentMeta, StoryFn } from "@storybook/react";
|
|
27
|
+
import React, { ComponentProps } from "react";
|
|
28
|
+
import Collapsible from "./Collapsible";
|
|
29
|
+
|
|
30
|
+
export default {
|
|
31
|
+
title: "Collapsible",
|
|
32
|
+
component: Collapsible,
|
|
33
|
+
decorators: [StoryRouter()],
|
|
34
|
+
} as ComponentMeta<typeof Collapsible>;
|
|
35
|
+
|
|
36
|
+
const Template: StoryFn<ComponentProps<typeof Collapsible>> = (args) => <Collapsible {...args} />;
|
|
37
|
+
|
|
38
|
+
export const Default = Template.bind({});
|
|
39
|
+
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
40
|
+
Default.args = {
|
|
41
|
+
children: [
|
|
42
|
+
"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.",
|
|
43
|
+
],
|
|
44
|
+
header: "This is a collapsible",
|
|
45
|
+
} as ComponentProps<typeof Collapsible>;
|
|
@@ -0,0 +1,87 @@
|
|
|
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, ReactNode, useEffect, useState } from "react";
|
|
26
|
+
import * as RadixCollapsible from "@radix-ui/react-collapsible";
|
|
27
|
+
import { Icon } from "../../buttons";
|
|
28
|
+
import styled from "styled-components";
|
|
29
|
+
import { useAriaId } from "../../helpers";
|
|
30
|
+
import classNames from "classnames";
|
|
31
|
+
|
|
32
|
+
const StyledTrigger = styled(RadixCollapsible.Trigger)`
|
|
33
|
+
margin-right: 0.5rem;
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
const StyledCollapsibleHeader = styled.div`
|
|
37
|
+
background-color: var(--scm-secondary-less-color);
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
type Props = {
|
|
41
|
+
header: ReactNode;
|
|
42
|
+
defaultCollapsed?: boolean;
|
|
43
|
+
collapsed?: boolean;
|
|
44
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
45
|
+
} & Pick<ComponentProps<typeof RadixCollapsible.Root>, "className" | "children">;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @beta
|
|
49
|
+
* @since 2.46.0
|
|
50
|
+
*/
|
|
51
|
+
const Collapsible = React.forwardRef<HTMLButtonElement, Props>(
|
|
52
|
+
({ children, header, className, defaultCollapsed, collapsed, onCollapsedChange }, ref) => {
|
|
53
|
+
const [isCollapsed, setCollapsed] = useState(defaultCollapsed);
|
|
54
|
+
const titleId = useAriaId();
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (collapsed !== undefined) {
|
|
57
|
+
setCollapsed(collapsed);
|
|
58
|
+
}
|
|
59
|
+
}, [collapsed]);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<RadixCollapsible.Root
|
|
63
|
+
className={classNames("card", className)}
|
|
64
|
+
open={!isCollapsed}
|
|
65
|
+
onOpenChange={(o) => {
|
|
66
|
+
setCollapsed(!o);
|
|
67
|
+
if (onCollapsedChange) {
|
|
68
|
+
onCollapsedChange(!o);
|
|
69
|
+
}
|
|
70
|
+
}}
|
|
71
|
+
defaultOpen={!defaultCollapsed}
|
|
72
|
+
>
|
|
73
|
+
<StyledCollapsibleHeader className="card-header is-flex is-justify-content-space-between is-shadowless">
|
|
74
|
+
<span id={titleId} className="card-header-title">
|
|
75
|
+
{header}
|
|
76
|
+
</span>
|
|
77
|
+
<StyledTrigger aria-labelledby={titleId} className="card-header-icon" ref={ref}>
|
|
78
|
+
<Icon>{isCollapsed ? "angle-left" : "angle-down"}</Icon>
|
|
79
|
+
</StyledTrigger>
|
|
80
|
+
</StyledCollapsibleHeader>
|
|
81
|
+
<RadixCollapsible.Content className="card-content p-2">{children}</RadixCollapsible.Content>
|
|
82
|
+
</RadixCollapsible.Root>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
export default Collapsible;
|
|
@@ -0,0 +1,93 @@
|
|
|
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 CardListComponent, { CardListBox as CardListBoxComponent, CardListCard } from "./card-list/CardList";
|
|
26
|
+
import CardTitle from "./card/CardTitle";
|
|
27
|
+
import CardRow, { SecondaryRow, TertiaryRow } from "./card/CardRow";
|
|
28
|
+
import {
|
|
29
|
+
CardButtonDetail,
|
|
30
|
+
CardDetail,
|
|
31
|
+
CardDetailLabel,
|
|
32
|
+
CardDetails,
|
|
33
|
+
CardDetailTag,
|
|
34
|
+
CardLinkDetail,
|
|
35
|
+
} from "./card/CardDetail";
|
|
36
|
+
import CardComponent from "./card/Card";
|
|
37
|
+
import {
|
|
38
|
+
DataPageHeader as DataPageHeaderComponent,
|
|
39
|
+
DataPageHeaderCreateButton,
|
|
40
|
+
DataPageHeaderSetting,
|
|
41
|
+
DataPageHeaderSettingField,
|
|
42
|
+
DataPageHeaderSettingLabel,
|
|
43
|
+
DataPageHeaderSettings,
|
|
44
|
+
} from "./templates/data-page/DataPageHeader";
|
|
45
|
+
import TabsComponent from "./tabs/Tabs";
|
|
46
|
+
import TabsContent from "./tabs/TabsContent";
|
|
47
|
+
import TabsList from "./tabs/TabsList";
|
|
48
|
+
import TabTrigger from "./tabs/TabTrigger";
|
|
49
|
+
|
|
50
|
+
export { default as Collapsible } from "./collapsible/Collapsible";
|
|
51
|
+
|
|
52
|
+
const CardDetailExports = {
|
|
53
|
+
Label: CardDetailLabel,
|
|
54
|
+
Tag: CardDetailTag,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const CardExport = {
|
|
58
|
+
Title: CardTitle,
|
|
59
|
+
Row: CardRow,
|
|
60
|
+
SecondaryRow: SecondaryRow,
|
|
61
|
+
TertiaryRow: TertiaryRow,
|
|
62
|
+
Details: Object.assign(CardDetails, {
|
|
63
|
+
Detail: Object.assign(CardDetail, CardDetailExports),
|
|
64
|
+
ButtonDetail: Object.assign(CardButtonDetail, CardDetailExports),
|
|
65
|
+
LinkDetail: Object.assign(CardLinkDetail, CardDetailExports),
|
|
66
|
+
}),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const Card = Object.assign(CardComponent, CardExport);
|
|
70
|
+
|
|
71
|
+
const CardListExport = {
|
|
72
|
+
Card: Object.assign(CardListCard, CardExport),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const CardList = Object.assign(CardListComponent, CardListExport);
|
|
76
|
+
export const CardListBox = Object.assign(CardListBoxComponent, CardListExport);
|
|
77
|
+
|
|
78
|
+
export const DataPageHeader = Object.assign(DataPageHeaderComponent, {
|
|
79
|
+
Settings: Object.assign(DataPageHeaderSettings, {
|
|
80
|
+
Setting: Object.assign(DataPageHeaderSetting, {
|
|
81
|
+
Label: DataPageHeaderSettingLabel,
|
|
82
|
+
Field: DataPageHeaderSettingField,
|
|
83
|
+
}),
|
|
84
|
+
}),
|
|
85
|
+
CreateButton: DataPageHeaderCreateButton,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export const Tabs = Object.assign(TabsComponent, {
|
|
89
|
+
List: Object.assign(TabsList, {
|
|
90
|
+
Trigger: TabTrigger,
|
|
91
|
+
}),
|
|
92
|
+
Content: TabsContent,
|
|
93
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
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 classNames from "classnames";
|
|
27
|
+
import * as HeadlessTabs from "@radix-ui/react-tabs";
|
|
28
|
+
|
|
29
|
+
type Props = ComponentProps<typeof HeadlessTabs.Trigger>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @beta
|
|
33
|
+
* @since 2.47.0
|
|
34
|
+
*/
|
|
35
|
+
const TabTrigger = React.forwardRef<HTMLButtonElement, Props>(({ children, className, ...props }, ref) => (
|
|
36
|
+
<li>
|
|
37
|
+
<HeadlessTabs.Trigger
|
|
38
|
+
className={classNames("has-background-transparent is-borderless", className)}
|
|
39
|
+
ref={ref}
|
|
40
|
+
{...props}
|
|
41
|
+
>
|
|
42
|
+
{children}
|
|
43
|
+
</HeadlessTabs.Trigger>
|
|
44
|
+
</li>
|
|
45
|
+
));
|
|
46
|
+
export default TabTrigger;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 from "react";
|
|
26
|
+
import StoryRouter from "storybook-react-router";
|
|
27
|
+
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
|
28
|
+
import Tabs from "./Tabs";
|
|
29
|
+
import TabsList from "./TabsList";
|
|
30
|
+
import TabTrigger from "./TabTrigger";
|
|
31
|
+
import TabsContent from "./TabsContent";
|
|
32
|
+
|
|
33
|
+
export default {
|
|
34
|
+
title: "Tab",
|
|
35
|
+
component: Tabs,
|
|
36
|
+
decorators: [StoryRouter()],
|
|
37
|
+
} as ComponentMeta<typeof Tabs>;
|
|
38
|
+
|
|
39
|
+
export const Default: ComponentStory<typeof Tabs> = () => (
|
|
40
|
+
<Tabs defaultValue="tab2">
|
|
41
|
+
<TabsList>
|
|
42
|
+
<TabTrigger value="tab1">Account</TabTrigger>
|
|
43
|
+
<TabTrigger value="tab2">Password</TabTrigger>
|
|
44
|
+
</TabsList>
|
|
45
|
+
<TabsContent value="tab1">Account Settings</TabsContent>
|
|
46
|
+
<TabsContent value="tab2">Password Settings</TabsContent>
|
|
47
|
+
</Tabs>
|
|
48
|
+
);
|
|
@@ -0,0 +1,52 @@
|
|
|
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, useCallback, useState } from "react";
|
|
26
|
+
import * as HeadlessTabs from "@radix-ui/react-tabs";
|
|
27
|
+
|
|
28
|
+
type Props = Omit<ComponentProps<typeof HeadlessTabs.Root>, "value">;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @beta
|
|
32
|
+
* @since 2.47.0
|
|
33
|
+
*/
|
|
34
|
+
const Tabs = React.forwardRef<HTMLDivElement, Props>(({ defaultValue, onValueChange, children, ...props }, ref) => {
|
|
35
|
+
const [value, setValue] = useState(defaultValue);
|
|
36
|
+
const handleValueChange = useCallback(
|
|
37
|
+
(newValue: string) => {
|
|
38
|
+
setValue(newValue);
|
|
39
|
+
if (onValueChange) {
|
|
40
|
+
onValueChange(newValue);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
[onValueChange]
|
|
44
|
+
);
|
|
45
|
+
return (
|
|
46
|
+
<HeadlessTabs.Root {...props} ref={ref} onValueChange={handleValueChange} value={value}>
|
|
47
|
+
{children}
|
|
48
|
+
</HeadlessTabs.Root>
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export default Tabs;
|
|
@@ -0,0 +1,33 @@
|
|
|
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 * as RadixTabs from "@radix-ui/react-tabs";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @beta
|
|
29
|
+
* @since 2.47.0
|
|
30
|
+
*/
|
|
31
|
+
const TabsContent = RadixTabs.Content;
|
|
32
|
+
|
|
33
|
+
export default TabsContent;
|