@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,57 @@
|
|
|
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
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
26
|
+
|
|
27
|
+
class RemoveThemesPlugin {
|
|
28
|
+
apply (compiler) {
|
|
29
|
+
compiler.hooks.compilation.tap('RemoveThemesPlugin', (compilation) => {
|
|
30
|
+
|
|
31
|
+
HtmlWebpackPlugin.getHooks(compilation).beforeAssetTagGeneration.tapAsync(
|
|
32
|
+
'RemoveThemesPlugin',
|
|
33
|
+
(data, cb) => {
|
|
34
|
+
|
|
35
|
+
// remove generated style-loader bundles from the page
|
|
36
|
+
// there should be a better way, which does not generate the bundles at all
|
|
37
|
+
// but for now it works
|
|
38
|
+
if (data.assets.js) {
|
|
39
|
+
data.assets.js = data.assets.js.filter(bundle => !bundle.startsWith("ui-theme-"))
|
|
40
|
+
.filter(bundle => !bundle.startsWith("runtime~ui-theme-"))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// remove css links to avoid conflicts with the themes
|
|
44
|
+
// so we remove all and add our own via preview-head.html
|
|
45
|
+
if (data.assets.css) {
|
|
46
|
+
data.assets.css = data.assets.css.filter(css => !css.startsWith("ui-theme-"))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Tell webpack to move on
|
|
50
|
+
cb(null, data)
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = RemoveThemesPlugin
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
const path = require("path");
|
|
26
|
+
const fs = require("fs");
|
|
27
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
28
|
+
const RemoveThemesPlugin = require("./RemoveThemesPlugin");
|
|
29
|
+
const ReactDOM = require("react-dom");
|
|
30
|
+
|
|
31
|
+
const root = path.resolve("..");
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const themedir = path.join(root, "ui-styles", "src");
|
|
35
|
+
|
|
36
|
+
ReactDOM.createPortal = (node) => node;
|
|
37
|
+
|
|
38
|
+
const themes = fs
|
|
39
|
+
.readdirSync(themedir)
|
|
40
|
+
.map((filename) => path.parse(filename))
|
|
41
|
+
.filter((p) => p.ext === ".scss")
|
|
42
|
+
.reduce((entries, current) => ({ ...entries, [`ui-theme-${current.name}`]: path.join(themedir, current.base) }), {});
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
typescript: { reactDocgen: false },
|
|
46
|
+
core: {
|
|
47
|
+
builder: "webpack5",
|
|
48
|
+
},
|
|
49
|
+
stories: ["../docs/**/*.stories.mdx", "../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
|
|
50
|
+
addons: [
|
|
51
|
+
"storybook-addon-i18next",
|
|
52
|
+
"storybook-addon-themes",
|
|
53
|
+
"@storybook/addon-links",
|
|
54
|
+
"@storybook/addon-essentials",
|
|
55
|
+
"@storybook/addon-interactions",
|
|
56
|
+
"@storybook/addon-a11y",
|
|
57
|
+
"storybook-addon-pseudo-states"
|
|
58
|
+
],
|
|
59
|
+
framework: "@storybook/react",
|
|
60
|
+
webpackFinal: async (config) => {
|
|
61
|
+
// add our themes to webpack entry points
|
|
62
|
+
config.entry = {
|
|
63
|
+
main: config.entry,
|
|
64
|
+
...themes,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// create separate css files for our themes
|
|
68
|
+
config.plugins.push(
|
|
69
|
+
new MiniCssExtractPlugin({
|
|
70
|
+
filename: "[name].css",
|
|
71
|
+
ignoreOrder: false,
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
config.module.rules.push({
|
|
76
|
+
test: /\.scss$/,
|
|
77
|
+
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// the html-webpack-plugin adds the generated css and js files to the iframe,
|
|
81
|
+
// which overrides our manually loaded css files.
|
|
82
|
+
// So we use a custom plugin which uses a hook of html-webpack-plugin
|
|
83
|
+
// to filter our themes from the output.
|
|
84
|
+
config.plugins.push(new RemoveThemesPlugin());
|
|
85
|
+
|
|
86
|
+
// force cjs instead of esm
|
|
87
|
+
// https://github.com/tannerlinsley/react-query/issues/3513
|
|
88
|
+
config.resolve.alias["react-query/devtools"] = require.resolve("react-query/devtools");
|
|
89
|
+
|
|
90
|
+
return config;
|
|
91
|
+
},
|
|
92
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
<link id="ui-theme" data-theme="light" rel="stylesheet" type="text/css" href="/ui-theme-light.css">
|
|
@@ -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 i18next from "i18next";
|
|
26
|
+
import { initReactI18next } from "react-i18next";
|
|
27
|
+
import { withI18next } from "storybook-addon-i18next";
|
|
28
|
+
import React, {useEffect} from "react";
|
|
29
|
+
import withApiProvider from "./withApiProvider";
|
|
30
|
+
import { withThemes } from 'storybook-addon-themes/react';
|
|
31
|
+
|
|
32
|
+
let i18n = i18next;
|
|
33
|
+
|
|
34
|
+
// only use fetch backend for storybook
|
|
35
|
+
// and not for storyshots
|
|
36
|
+
if (!process.env.JEST_WORKER_ID) {
|
|
37
|
+
const Backend = require("i18next-fetch-backend");
|
|
38
|
+
i18n = i18n.use(Backend.default);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
i18n.use(initReactI18next).init({
|
|
42
|
+
whitelist: ["en", "de", "es"],
|
|
43
|
+
lng: "en",
|
|
44
|
+
fallbackLng: "en",
|
|
45
|
+
interpolation: {
|
|
46
|
+
escapeValue: false,
|
|
47
|
+
},
|
|
48
|
+
react: {
|
|
49
|
+
useSuspense: false,
|
|
50
|
+
},
|
|
51
|
+
backend: {
|
|
52
|
+
loadPath: "/locales/{{lng}}/{{ns}}.json",
|
|
53
|
+
init: {
|
|
54
|
+
credentials: "same-origin",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export const decorators = [
|
|
60
|
+
withI18next({
|
|
61
|
+
i18n,
|
|
62
|
+
languages: {
|
|
63
|
+
en: "English",
|
|
64
|
+
de: "Deutsch",
|
|
65
|
+
es: "Spanisch",
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
withApiProvider,
|
|
69
|
+
withThemes
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
const Decorator = ({children, themeName}) => {
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
const link = document.querySelector("#ui-theme");
|
|
75
|
+
if (link && link["data-theme"] !== themeName) {
|
|
76
|
+
link.href = `ui-theme-${themeName}.css`;
|
|
77
|
+
link["data-theme"] = themeName;
|
|
78
|
+
}
|
|
79
|
+
}, [themeName]);
|
|
80
|
+
return <>{children}</>
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const parameters = {
|
|
84
|
+
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
85
|
+
themes: {
|
|
86
|
+
Decorator,
|
|
87
|
+
clearable: false,
|
|
88
|
+
default: "light",
|
|
89
|
+
list: [
|
|
90
|
+
{ name: "light", color: "#fff" },
|
|
91
|
+
{ name: "highcontrast", color: "#050514" },
|
|
92
|
+
{ name: "dark", color: "#121212" },
|
|
93
|
+
],
|
|
94
|
+
}
|
|
95
|
+
};
|
|
@@ -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 * as React from "react";
|
|
26
|
+
import { ApiProvider } from "@scm-manager/ui-api";
|
|
27
|
+
|
|
28
|
+
const withApiProvider = (storyFn) => {
|
|
29
|
+
return React.createElement(ApiProvider, {
|
|
30
|
+
index: {
|
|
31
|
+
version: "x.y.z",
|
|
32
|
+
_links: {}
|
|
33
|
+
},
|
|
34
|
+
me: {
|
|
35
|
+
name: "trillian",
|
|
36
|
+
displayName: "Trillian McMillan",
|
|
37
|
+
mail: "trillian@hitchhiker.com",
|
|
38
|
+
groups: [],
|
|
39
|
+
_links: {}
|
|
40
|
+
},
|
|
41
|
+
devtools: false,
|
|
42
|
+
children: storyFn()
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default withApiProvider;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs";
|
|
2
|
+
import { Button } from "../src";
|
|
3
|
+
|
|
4
|
+
<Meta title="Introduction"/>
|
|
5
|
+
|
|
6
|
+
# Buttons
|
|
7
|
+
|
|
8
|
+
The `@scm-manager/ui-buttons` library provides [atoms](https://atomicdesign.bradfrost.com/chapter-2/#atoms) implemented
|
|
9
|
+
as minimal wrappers around native html elements styled to match the general SCM-Manager aesthetic.
|
|
10
|
+
|
|
11
|
+
## Components
|
|
12
|
+
|
|
13
|
+
There are three actionable components available. Styling is consistent amongst them and all have the required `variant` property.
|
|
14
|
+
|
|
15
|
+
1. [Button](?path=/story/components--button)
|
|
16
|
+
2. [Link Button](?path=/story/components--link-button)
|
|
17
|
+
3. [External Link Button](?path=/story/components--external-link-button)
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Actionable components serve a dedicated purpose. It is therefore important to know when and how to use them.
|
|
22
|
+
|
|
23
|
+
### Variants
|
|
24
|
+
|
|
25
|
+
There are four variants available to each of the three button types, varying in importance.
|
|
26
|
+
|
|
27
|
+
<table>
|
|
28
|
+
<thead>
|
|
29
|
+
<tr>
|
|
30
|
+
<th>Emphasis</th>
|
|
31
|
+
<th>Button Variant</th>
|
|
32
|
+
<th>Usage Examples</th>
|
|
33
|
+
</tr>
|
|
34
|
+
</thead>
|
|
35
|
+
<tbody>
|
|
36
|
+
<tr>
|
|
37
|
+
<td>Very High</td>
|
|
38
|
+
<td><Button variant="signal">Signal</Button></td>
|
|
39
|
+
<td>Destructive actions</td>
|
|
40
|
+
</tr>
|
|
41
|
+
<tr>
|
|
42
|
+
<td>High</td>
|
|
43
|
+
<td><Button variant="primary">Primary</Button></td>
|
|
44
|
+
<td>Form submit</td>
|
|
45
|
+
</tr>
|
|
46
|
+
<tr>
|
|
47
|
+
<td>Normal</td>
|
|
48
|
+
<td><Button variant="secondary">Secondary</Button></td>
|
|
49
|
+
<td>Cancel action in dialog</td>
|
|
50
|
+
</tr>
|
|
51
|
+
<tr>
|
|
52
|
+
<td>Low</td>
|
|
53
|
+
<td><Button variant="tertiary">Tertiary</Button></td>
|
|
54
|
+
<td>Circumstantially relevant action on page with many actionable elements</td>
|
|
55
|
+
</tr>
|
|
56
|
+
</tbody>
|
|
57
|
+
</table>
|
|
58
|
+
|
|
59
|
+
## Content
|
|
60
|
+
|
|
61
|
+
Buttons exclusively contain text and no icons. Icons tend to be ambiguous and not always applicable which leads to inconsistent
|
|
62
|
+
and cluttered layouts.
|
|
63
|
+
|
|
64
|
+
Button text should be short, concise and describe the action performed.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Meta, Story } from "@storybook/addon-docs";
|
|
2
|
+
import { Button } from "../src";
|
|
3
|
+
|
|
4
|
+
<Meta title="Usage" parameters={{
|
|
5
|
+
storyshots: { disable: true }
|
|
6
|
+
}} />
|
|
7
|
+
|
|
8
|
+
In confirmation dialogs, there are two actions.<br/>
|
|
9
|
+
One to cancel the current process and one to confirm it.<br/>
|
|
10
|
+
Aborting is always the secondary action, confirmation always the primary.
|
|
11
|
+
Focus is always on the cancelling action.
|
|
12
|
+
|
|
13
|
+
<Story name="Confirmation Dialog">
|
|
14
|
+
<div>
|
|
15
|
+
<h4>Delete User</h4>
|
|
16
|
+
<p>Do you really want to delete this user ?</p>
|
|
17
|
+
<div>
|
|
18
|
+
<Button variant="secondary">Cancel</Button>
|
|
19
|
+
<Button variant="primary">Delete</Button>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</Story>
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scm-manager/ui-core",
|
|
3
|
+
"version": "3.0.0-20240024-101702",
|
|
4
|
+
"main": "./src/index.ts",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"storybook": "start-storybook -p 6006",
|
|
8
|
+
"build-storybook": "build-storybook"
|
|
9
|
+
},
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"react": "^17.0.1",
|
|
12
|
+
"react-dom": "^17.0.1",
|
|
13
|
+
"react-router-dom": "^5.3.1",
|
|
14
|
+
"classnames": "^2.3.1",
|
|
15
|
+
"react-hook-form": "7",
|
|
16
|
+
"react-i18next": "11",
|
|
17
|
+
"react-query": "3",
|
|
18
|
+
"styled-components": "5"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@headlessui/react": "^1.7.15",
|
|
22
|
+
"@radix-ui/react-radio-group": "^1.1.3",
|
|
23
|
+
"@radix-ui/react-slot": "^1.0.1",
|
|
24
|
+
"@radix-ui/react-visually-hidden": "^1.0.3",
|
|
25
|
+
"@radix-ui/react-dialog": "1.0.4",
|
|
26
|
+
"@radix-ui/react-dropdown-menu": "2.0.5",
|
|
27
|
+
"@radix-ui/react-popover": "1.0.6",
|
|
28
|
+
"@radix-ui/react-tooltip": "1.0.2",
|
|
29
|
+
"@radix-ui/react-tabs": "^1.0.4",
|
|
30
|
+
"@radix-ui/react-collapsible": "^1.0.3",
|
|
31
|
+
"mousetrap": "1.6.5"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@scm-manager/prettier-config": "^2.11.1",
|
|
35
|
+
"@scm-manager/eslint-config": "^2.17.0",
|
|
36
|
+
"@scm-manager/tsconfig": "^2.12.0",
|
|
37
|
+
"@scm-manager/babel-preset": "^2.13.1",
|
|
38
|
+
"@types/mousetrap": "1.6.5",
|
|
39
|
+
"@testing-library/react-hooks": "8.0.1",
|
|
40
|
+
"@testing-library/react": "12.1.5",
|
|
41
|
+
"@storybook/addon-actions": "^6.5.10",
|
|
42
|
+
"@storybook/addon-docs": "^6.5.14",
|
|
43
|
+
"@storybook/addon-essentials": "^6.5.10",
|
|
44
|
+
"@storybook/addon-interactions": "^6.5.10",
|
|
45
|
+
"@storybook/addon-links": "^6.5.10",
|
|
46
|
+
"@storybook/addon-a11y": "^6.5.10",
|
|
47
|
+
"storybook-addon-i18next": "^1.3.0",
|
|
48
|
+
"storybook-addon-pseudo-states": "^1.15.1",
|
|
49
|
+
"@storybook/builder-webpack5": "^6.5.10",
|
|
50
|
+
"@storybook/manager-webpack5": "^6.5.10",
|
|
51
|
+
"@storybook/react": "^6.5.10",
|
|
52
|
+
"@storybook/testing-library": "^0.0.13",
|
|
53
|
+
"@storybook/addon-storyshots-puppeteer": "^6.4.20",
|
|
54
|
+
"@storybook/addon-storyshots": "^6.4.20",
|
|
55
|
+
"storybook-addon-mock": "^3.2.0",
|
|
56
|
+
"storybook-addon-themes": "^6.1.0",
|
|
57
|
+
"storybook-react-router": "^1.0.8",
|
|
58
|
+
"mini-css-extract-plugin": "^1.6.2",
|
|
59
|
+
"html-webpack-plugin": "^5.5.0",
|
|
60
|
+
"webpack": "5",
|
|
61
|
+
"@babel/core": "^7.19.0",
|
|
62
|
+
"i18next": "^19.9.2",
|
|
63
|
+
"react-i18next": "11",
|
|
64
|
+
"i18next-fetch-backend": "^2.3.1",
|
|
65
|
+
"babel-loader": "^8.2.5",
|
|
66
|
+
"depcheck": "^1.4.3",
|
|
67
|
+
"jest-extended": "3.1.0"
|
|
68
|
+
},
|
|
69
|
+
"prettier": "@scm-manager/prettier-config",
|
|
70
|
+
"eslintConfig": {
|
|
71
|
+
"extends": "@scm-manager/eslint-config"
|
|
72
|
+
},
|
|
73
|
+
"publishConfig": {
|
|
74
|
+
"access": "public"
|
|
75
|
+
},
|
|
76
|
+
"jest": {
|
|
77
|
+
"setupFilesAfterEnv": [
|
|
78
|
+
"jest-extended/all"
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
|
|
27
|
+
import {
|
|
28
|
+
Button as ButtonComponent,
|
|
29
|
+
ButtonVariantList,
|
|
30
|
+
ButtonVariants,
|
|
31
|
+
ExternalLinkButton as ExternalLinkButtonComponent,
|
|
32
|
+
LinkButton as LinkButtonComponent,
|
|
33
|
+
} from "./Button";
|
|
34
|
+
import StoryRouter from "storybook-react-router";
|
|
35
|
+
import { StoryFn } from "@storybook/react";
|
|
36
|
+
|
|
37
|
+
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
38
|
+
export default {
|
|
39
|
+
title: "Components",
|
|
40
|
+
component: null,
|
|
41
|
+
subcomponents: {
|
|
42
|
+
Button: ButtonComponent,
|
|
43
|
+
LinkButton: LinkButtonComponent,
|
|
44
|
+
ExternalLinkButton: ExternalLinkButtonComponent,
|
|
45
|
+
},
|
|
46
|
+
argTypes: {
|
|
47
|
+
variant: {
|
|
48
|
+
options: ButtonVariantList,
|
|
49
|
+
control: { type: "select" },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
decorators: [StoryRouter()],
|
|
53
|
+
parameters: {
|
|
54
|
+
storyshots: { disable: true },
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
59
|
+
const ButtonTemplate: StoryFn<ComponentProps<typeof ButtonComponent>> = (args) => <ButtonComponent {...args} />;
|
|
60
|
+
const LinkButtonTemplate: StoryFn<ComponentProps<typeof LinkButtonComponent>> = (args) => (
|
|
61
|
+
<LinkButtonComponent {...args} />
|
|
62
|
+
);
|
|
63
|
+
const ExternalLinkButtonTemplate: StoryFn<ComponentProps<typeof ExternalLinkButtonComponent>> = (args) => (
|
|
64
|
+
<ExternalLinkButtonComponent {...args} />
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
export const Button = ButtonTemplate.bind({});
|
|
68
|
+
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
69
|
+
Button.args = {
|
|
70
|
+
children: "Button",
|
|
71
|
+
variant: ButtonVariants.PRIMARY,
|
|
72
|
+
disabled: false,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const LinkButton = LinkButtonTemplate.bind({});
|
|
76
|
+
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
77
|
+
LinkButton.args = {
|
|
78
|
+
children: "Link Button",
|
|
79
|
+
to: "/repos",
|
|
80
|
+
variant: ButtonVariants.PRIMARY,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const ExternalLinkButton = ExternalLinkButtonTemplate.bind({});
|
|
84
|
+
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
85
|
+
ExternalLinkButton.args = {
|
|
86
|
+
children: "External Link Button",
|
|
87
|
+
href: "https://scm-manager.org",
|
|
88
|
+
variant: ButtonVariants.PRIMARY,
|
|
89
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Meta, Story } from "@storybook/addon-docs";
|
|
2
|
+
import { Button, ButtonVariantList } from "./Button";
|
|
3
|
+
|
|
4
|
+
<Meta title="Tests"/>
|
|
5
|
+
|
|
6
|
+
<Story name="Light States" parameters={{
|
|
7
|
+
pseudo: {
|
|
8
|
+
hover: ButtonVariantList.map(variant => `#${variant}-Hover`),
|
|
9
|
+
focus: ButtonVariantList.map(variant => `#${variant}-Focus`),
|
|
10
|
+
active: ButtonVariantList.map(variant => `#${variant}-Active`),
|
|
11
|
+
},
|
|
12
|
+
themes: {
|
|
13
|
+
default: 'light',
|
|
14
|
+
},
|
|
15
|
+
}}>
|
|
16
|
+
<table>
|
|
17
|
+
<tr>
|
|
18
|
+
<th>STATE</th>
|
|
19
|
+
{ButtonVariantList.map(variant => <th>{variant.toUpperCase()}</th>)}
|
|
20
|
+
</tr>
|
|
21
|
+
{["Normal", "Hover", "Active", "Focus", "Disabled", "Loading"].map(state => <tr>
|
|
22
|
+
<td>{state}</td>
|
|
23
|
+
{ButtonVariantList.map(variant => <td><Button id={`${variant}-${state}`} disabled={state === "Disabled"}
|
|
24
|
+
isLoading={state === "Loading"}
|
|
25
|
+
variant={variant}>Button</Button></td>)}
|
|
26
|
+
</tr>)}
|
|
27
|
+
</table>
|
|
28
|
+
</Story>
|
|
29
|
+
|
|
30
|
+
<Story name="Dark States" parameters={{
|
|
31
|
+
pseudo: {
|
|
32
|
+
hover: ButtonVariantList.map(variant => `#${variant}-Hover`),
|
|
33
|
+
focus: ButtonVariantList.map(variant => `#${variant}-Focus`),
|
|
34
|
+
active: ButtonVariantList.map(variant => `#${variant}-Active`),
|
|
35
|
+
},
|
|
36
|
+
themes: {
|
|
37
|
+
default: 'dark',
|
|
38
|
+
},
|
|
39
|
+
}}>
|
|
40
|
+
<table>
|
|
41
|
+
<tr>
|
|
42
|
+
<th>STATE</th>
|
|
43
|
+
{ButtonVariantList.map(variant => <th>{variant.toUpperCase()}</th>)}
|
|
44
|
+
</tr>
|
|
45
|
+
{["Normal", "Hover", "Active", "Focus", "Disabled"].map(state => <tr>
|
|
46
|
+
<td>{state}</td>
|
|
47
|
+
{ButtonVariantList.map(variant => <td><Button id={`${variant}-${state}`} disabled={state === "Disabled"}
|
|
48
|
+
variant={variant}>Button</Button></td>)}
|
|
49
|
+
</tr>)}
|
|
50
|
+
</table>
|
|
51
|
+
</Story>
|
|
52
|
+
|
|
53
|
+
<Story name="High-Contrast States" parameters={{
|
|
54
|
+
pseudo: {
|
|
55
|
+
hover: ButtonVariantList.map(variant => `#${variant}-Hover`),
|
|
56
|
+
focus: ButtonVariantList.map(variant => `#${variant}-Focus`),
|
|
57
|
+
active: ButtonVariantList.map(variant => `#${variant}-Active`),
|
|
58
|
+
},
|
|
59
|
+
themes: {
|
|
60
|
+
default: 'highcontrast',
|
|
61
|
+
},
|
|
62
|
+
}}>
|
|
63
|
+
<table>
|
|
64
|
+
<tr>
|
|
65
|
+
<th>STATE</th>
|
|
66
|
+
{ButtonVariantList.map(variant => <th>{variant.toUpperCase()}</th>)}
|
|
67
|
+
</tr>
|
|
68
|
+
{["Normal", "Hover", "Active", "Focus", "Disabled"].map(state => <tr>
|
|
69
|
+
<td>{state}</td>
|
|
70
|
+
{ButtonVariantList.map(variant => <td><Button id={`${variant}-${state}`} disabled={state === "Disabled"}
|
|
71
|
+
variant={variant}>Button</Button></td>)}
|
|
72
|
+
</tr>)}
|
|
73
|
+
</table>
|
|
74
|
+
</Story>
|