@scm-manager/ui-layout 2.43.2-20230501-105257

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.
@@ -0,0 +1,4 @@
1
+ {
2
+ "presets": ["@scm-manager/babel-preset"],
3
+ "plugins": ["@babel/plugin-syntax-dynamic-import"]
4
+ }
@@ -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,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
+ const path = require("path");
26
+ const fs = require("fs");
27
+ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
28
+ const RemoveThemesPlugin = require("./RemoveThemesPlugin");
29
+
30
+ const root = path.resolve("..");
31
+
32
+ const themedir = path.join(root, "ui-styles", "src");
33
+
34
+ const themes = fs
35
+ .readdirSync(themedir)
36
+ .map((filename) => path.parse(filename))
37
+ .filter((p) => p.ext === ".scss")
38
+ .reduce((entries, current) => ({ ...entries, [`ui-theme-${current.name}`]: path.join(themedir, current.base) }), {});
39
+
40
+ module.exports = {
41
+ typescript: { reactDocgen: false },
42
+ core: {
43
+ builder: "webpack5",
44
+ },
45
+ stories: ["../src/**/*.stories.@(js|jsx|ts|tsx|mdx)"],
46
+ addons: [
47
+ "storybook-addon-i18next",
48
+ "storybook-addon-themes",
49
+ "@storybook/addon-links",
50
+ "@storybook/addon-essentials",
51
+ "@storybook/addon-interactions",
52
+ "@storybook/addon-a11y",
53
+ "storybook-addon-pseudo-states",
54
+ "storybook-addon-mock",
55
+ ],
56
+ framework: "@storybook/react",
57
+ webpackFinal: async (config) => {
58
+ // add our themes to webpack entry points
59
+ config.entry = {
60
+ main: config.entry,
61
+ ...themes,
62
+ };
63
+
64
+ // create separate css files for our themes
65
+ config.plugins.push(
66
+ new MiniCssExtractPlugin({
67
+ filename: "[name].css",
68
+ ignoreOrder: false,
69
+ })
70
+ );
71
+
72
+ config.module.rules.push({
73
+ test: /\.scss$/,
74
+ use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
75
+ });
76
+
77
+ // the html-webpack-plugin adds the generated css and js files to the iframe,
78
+ // which overrides our manually loaded css files.
79
+ // So we use a custom plugin which uses a hook of html-webpack-plugin
80
+ // to filter our themes from the output.
81
+ config.plugins.push(new RemoveThemesPlugin());
82
+
83
+ // force cjs instead of esm
84
+ // https://github.com/tannerlinsley/react-query/issues/3513
85
+ config.resolve.alias["react-query/devtools"] = require.resolve("react-query/devtools");
86
+
87
+ return config;
88
+ },
89
+ };
@@ -0,0 +1,26 @@
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">
26
+
@@ -0,0 +1,67 @@
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, { useEffect } from "react";
26
+ import { initReactI18next } from "react-i18next";
27
+ import i18n from "i18next";
28
+ import { withThemes } from "storybook-addon-themes";
29
+
30
+ i18n.use(initReactI18next).init({
31
+ whitelist: ["en", "de"],
32
+ lng: "en",
33
+ fallbackLng: "en",
34
+ interpolation: {
35
+ escapeValue: false,
36
+ },
37
+ react: {
38
+ useSuspense: false,
39
+ },
40
+ });
41
+
42
+ const Decorator = ({ children, themeName }) => {
43
+ useEffect(() => {
44
+ const link = document.querySelector("#ui-theme");
45
+ if (link && link["data-theme"] !== themeName) {
46
+ link.href = `ui-theme-${themeName}.css`;
47
+ link["data-theme"] = themeName;
48
+ }
49
+ }, [themeName]);
50
+ return <>{children}</>;
51
+ };
52
+
53
+ export const decorators = [withThemes];
54
+
55
+ export const parameters = {
56
+ actions: { argTypesRegex: "^on[A-Z].*" },
57
+ themes: {
58
+ Decorator,
59
+ clearable: false,
60
+ default: "light",
61
+ list: [
62
+ { name: "light", color: "#fff" },
63
+ { name: "highcontrast", color: "#050514" },
64
+ { name: "dark", color: "#121212" },
65
+ ],
66
+ },
67
+ };
@@ -0,0 +1,15 @@
1
+ @scm-manager/ui-layout:build: cache hit, replaying output 353a44f40eb02689
2
+ @scm-manager/ui-layout:build: $ tsup ./src/index.ts -d build --format esm,cjs --dts
3
+ @scm-manager/ui-layout:build: CLI Building entry: ./src/index.ts
4
+ @scm-manager/ui-layout:build: CLI Using tsconfig: tsconfig.json
5
+ @scm-manager/ui-layout:build: CLI tsup v6.2.3
6
+ @scm-manager/ui-layout:build: CLI Target: node14
7
+ @scm-manager/ui-layout:build: ESM Build start
8
+ @scm-manager/ui-layout:build: CJS Build start
9
+ @scm-manager/ui-layout:build: ESM build/index.mjs 3.11 KB
10
+ @scm-manager/ui-layout:build: ESM ⚡️ Build success in 59ms
11
+ @scm-manager/ui-layout:build: CJS build/index.js 5.07 KB
12
+ @scm-manager/ui-layout:build: CJS ⚡️ Build success in 41ms
13
+ @scm-manager/ui-layout:build: DTS Build start
14
+ @scm-manager/ui-layout:build: DTS ⚡️ Build success in 6352ms
15
+ @scm-manager/ui-layout:build: DTS build/index.d.ts 1.31 KB
@@ -0,0 +1,20 @@
1
+ import * as react from 'react';
2
+
3
+ declare const CardList: react.ForwardRefExoticComponent<react.HTMLAttributes<HTMLUListElement> & react.RefAttributes<HTMLUListElement>> & {
4
+ Card: react.ForwardRefExoticComponent<react.LiHTMLAttributes<HTMLLIElement> & {
5
+ action?: react.ReactElement<any, string | react.JSXElementConstructor<any>> | undefined;
6
+ } & react.RefAttributes<HTMLLIElement>> & {
7
+ Row: react.ForwardRefExoticComponent<react.HTMLAttributes<HTMLDivElement> & react.RefAttributes<HTMLDivElement>>;
8
+ Title: react.ForwardRefExoticComponent<react.HTMLAttributes<HTMLHeadingElement> & react.RefAttributes<HTMLHeadingElement>>;
9
+ };
10
+ };
11
+ declare const CardListBox: react.ForwardRefExoticComponent<react.HTMLAttributes<HTMLUListElement> & react.RefAttributes<HTMLUListElement>> & {
12
+ Card: react.ForwardRefExoticComponent<react.LiHTMLAttributes<HTMLLIElement> & {
13
+ action?: react.ReactElement<any, string | react.JSXElementConstructor<any>> | undefined;
14
+ } & react.RefAttributes<HTMLLIElement>> & {
15
+ Row: react.ForwardRefExoticComponent<react.HTMLAttributes<HTMLDivElement> & react.RefAttributes<HTMLDivElement>>;
16
+ Title: react.ForwardRefExoticComponent<react.HTMLAttributes<HTMLHeadingElement> & react.RefAttributes<HTMLHeadingElement>>;
17
+ };
18
+ };
19
+
20
+ export { CardList, CardListBox };
package/build/index.js ADDED
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+
26
+ // src/index.ts
27
+ var src_exports = {};
28
+ __export(src_exports, {
29
+ CardList: () => CardList2,
30
+ CardListBox: () => CardListBox2
31
+ });
32
+ module.exports = __toCommonJS(src_exports);
33
+
34
+ // src/card-list/CardList.tsx
35
+ var import_react = __toESM(require("react"));
36
+ var import_classnames = __toESM(require("classnames"));
37
+ var import_styled_components = __toESM(require("styled-components"));
38
+ var CardListElement = import_styled_components.default.ul`
39
+ > * + * {
40
+ border-top: var(--scm-border);
41
+ margin-top: 0.5rem;
42
+ padding-top: 1rem !important;
43
+
44
+ *:is(h1, h2, h3, h4, h5, h6) a::after {
45
+ top: 0.5rem !important;
46
+ }
47
+ }
48
+ `;
49
+ var CardList = import_react.default.forwardRef(({ children, className, ...props }, ref) => /* @__PURE__ */ import_react.default.createElement(CardListElement, {
50
+ ref,
51
+ ...props,
52
+ className: (0, import_classnames.default)(className, "is-flex", "is-flex-direction-column")
53
+ }, children));
54
+ var CardListBox = import_react.default.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ import_react.default.createElement(CardList, {
55
+ className: (0, import_classnames.default)(className, "p-2 box"),
56
+ ref,
57
+ ...props
58
+ }, children));
59
+ var CardList_default = CardList;
60
+
61
+ // src/card-list/CardRow.tsx
62
+ var import_react2 = __toESM(require("react"));
63
+ var import_styled_components2 = __toESM(require("styled-components"));
64
+ var import_classnames2 = __toESM(require("classnames"));
65
+ var CardRowElement = import_styled_components2.default.div`
66
+ grid-column: 1 / 2;
67
+ `;
68
+ var CardRow = import_react2.default.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ import_react2.default.createElement(CardRowElement, {
69
+ className: (0, import_classnames2.default)(className),
70
+ ref,
71
+ ...props
72
+ }, children));
73
+ var CardRow_default = CardRow;
74
+
75
+ // src/card-list/Card.tsx
76
+ var import_react3 = __toESM(require("react"));
77
+ var import_styled_components3 = __toESM(require("styled-components"));
78
+ var import_classnames3 = __toESM(require("classnames"));
79
+ var CardElement = import_styled_components3.default.li`
80
+ display: grid;
81
+ grid-template-columns: minmax(0, 1fr) min-content;
82
+ grid-template-rows: auto;
83
+ `;
84
+ var CardActionContainer = import_styled_components3.default.span`
85
+ grid-column: -1;
86
+ grid-row: 1;
87
+ margin-top: -0.5rem;
88
+ margin-right: -0.5rem;
89
+ `;
90
+ var Card = import_react3.default.forwardRef(({ className, children, action, ...props }, ref) => /* @__PURE__ */ import_react3.default.createElement(CardElement, {
91
+ className: (0, import_classnames3.default)(className, "is-relative", "p-2"),
92
+ ref,
93
+ ...props
94
+ }, children, action ? /* @__PURE__ */ import_react3.default.createElement(CardActionContainer, null, action) : null));
95
+ var Card_default = Card;
96
+
97
+ // src/card-list/CardTitle.tsx
98
+ var import_react4 = __toESM(require("react"));
99
+ var import_styled_components4 = __toESM(require("styled-components"));
100
+ var import_classnames4 = __toESM(require("classnames"));
101
+ var CardTitleElement = import_styled_components4.default.h3`
102
+ a {
103
+ color: var(--scm-secondary-text);
104
+
105
+ &:focus {
106
+ outline: none;
107
+ &::after {
108
+ outline: #af3ee7 3px solid;
109
+ outline-offset: 0px;
110
+ }
111
+ }
112
+
113
+ &:hover::after {
114
+ background-color: var(--scm-hover-color-blue);
115
+ }
116
+
117
+ &::after {
118
+ content: "";
119
+ position: absolute;
120
+ top: 0;
121
+ left: 0;
122
+ bottom: 0;
123
+ right: 0;
124
+ border-radius: 4px;
125
+ }
126
+ }
127
+ `;
128
+ var CardTitle = import_react4.default.forwardRef(({ children, className, ...props }, ref) => /* @__PURE__ */ import_react4.default.createElement(CardTitleElement, {
129
+ className: (0, import_classnames4.default)(className, "is-ellipsis-overflow"),
130
+ ref,
131
+ ...props
132
+ }, children));
133
+ var CardTitle_default = CardTitle;
134
+
135
+ // src/index.ts
136
+ var CardListExport = {
137
+ Card: Object.assign(Card_default, {
138
+ Row: CardRow_default,
139
+ Title: CardTitle_default
140
+ })
141
+ };
142
+ var CardList2 = Object.assign(CardList_default, CardListExport);
143
+ var CardListBox2 = Object.assign(CardListBox, CardListExport);
144
+ // Annotate the CommonJS export names for ESM import in node:
145
+ 0 && (module.exports = {
146
+ CardList,
147
+ CardListBox
148
+ });
@@ -0,0 +1,114 @@
1
+ // src/card-list/CardList.tsx
2
+ import React from "react";
3
+ import classNames from "classnames";
4
+ import styled from "styled-components";
5
+ var CardListElement = styled.ul`
6
+ > * + * {
7
+ border-top: var(--scm-border);
8
+ margin-top: 0.5rem;
9
+ padding-top: 1rem !important;
10
+
11
+ *:is(h1, h2, h3, h4, h5, h6) a::after {
12
+ top: 0.5rem !important;
13
+ }
14
+ }
15
+ `;
16
+ var CardList = React.forwardRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React.createElement(CardListElement, {
17
+ ref,
18
+ ...props,
19
+ className: classNames(className, "is-flex", "is-flex-direction-column")
20
+ }, children));
21
+ var CardListBox = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React.createElement(CardList, {
22
+ className: classNames(className, "p-2 box"),
23
+ ref,
24
+ ...props
25
+ }, children));
26
+ var CardList_default = CardList;
27
+
28
+ // src/card-list/CardRow.tsx
29
+ import React2 from "react";
30
+ import styled2 from "styled-components";
31
+ import classNames2 from "classnames";
32
+ var CardRowElement = styled2.div`
33
+ grid-column: 1 / 2;
34
+ `;
35
+ var CardRow = React2.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React2.createElement(CardRowElement, {
36
+ className: classNames2(className),
37
+ ref,
38
+ ...props
39
+ }, children));
40
+ var CardRow_default = CardRow;
41
+
42
+ // src/card-list/Card.tsx
43
+ import React3 from "react";
44
+ import styled3 from "styled-components";
45
+ import classNames3 from "classnames";
46
+ var CardElement = styled3.li`
47
+ display: grid;
48
+ grid-template-columns: minmax(0, 1fr) min-content;
49
+ grid-template-rows: auto;
50
+ `;
51
+ var CardActionContainer = styled3.span`
52
+ grid-column: -1;
53
+ grid-row: 1;
54
+ margin-top: -0.5rem;
55
+ margin-right: -0.5rem;
56
+ `;
57
+ var Card = React3.forwardRef(({ className, children, action, ...props }, ref) => /* @__PURE__ */ React3.createElement(CardElement, {
58
+ className: classNames3(className, "is-relative", "p-2"),
59
+ ref,
60
+ ...props
61
+ }, children, action ? /* @__PURE__ */ React3.createElement(CardActionContainer, null, action) : null));
62
+ var Card_default = Card;
63
+
64
+ // src/card-list/CardTitle.tsx
65
+ import React4 from "react";
66
+ import styled4 from "styled-components";
67
+ import classNames4 from "classnames";
68
+ var CardTitleElement = styled4.h3`
69
+ a {
70
+ color: var(--scm-secondary-text);
71
+
72
+ &:focus {
73
+ outline: none;
74
+ &::after {
75
+ outline: #af3ee7 3px solid;
76
+ outline-offset: 0px;
77
+ }
78
+ }
79
+
80
+ &:hover::after {
81
+ background-color: var(--scm-hover-color-blue);
82
+ }
83
+
84
+ &::after {
85
+ content: "";
86
+ position: absolute;
87
+ top: 0;
88
+ left: 0;
89
+ bottom: 0;
90
+ right: 0;
91
+ border-radius: 4px;
92
+ }
93
+ }
94
+ `;
95
+ var CardTitle = React4.forwardRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React4.createElement(CardTitleElement, {
96
+ className: classNames4(className, "is-ellipsis-overflow"),
97
+ ref,
98
+ ...props
99
+ }, children));
100
+ var CardTitle_default = CardTitle;
101
+
102
+ // src/index.ts
103
+ var CardListExport = {
104
+ Card: Object.assign(Card_default, {
105
+ Row: CardRow_default,
106
+ Title: CardTitle_default
107
+ })
108
+ };
109
+ var CardList2 = Object.assign(CardList_default, CardListExport);
110
+ var CardListBox2 = Object.assign(CardListBox, CardListExport);
111
+ export {
112
+ CardList2 as CardList,
113
+ CardListBox2 as CardListBox
114
+ };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@scm-manager/ui-layout",
3
+ "private": false,
4
+ "version": "2.43.2-20230501-105257",
5
+ "main": "build/index.js",
6
+ "types": "build/index.d.ts",
7
+ "module": "build/index.mjs",
8
+ "license": "MIT",
9
+ "scripts": {
10
+ "build": "tsup ./src/index.ts -d build --format esm,cjs --dts",
11
+ "storybook": "start-storybook -p 6006",
12
+ "build-storybook": "build-storybook"
13
+ },
14
+ "devDependencies": {
15
+ "@babel/core": "^7.19.0",
16
+ "@scm-manager/eslint-config": "^2.16.0",
17
+ "@scm-manager/prettier-config": "^2.10.1",
18
+ "@scm-manager/tsconfig": "^2.13.0",
19
+ "@scm-manager/ui-styles": "2.43.2-20230501-105257",
20
+ "@scm-manager/ui-overlays": "2.43.2-20230501-105257",
21
+ "@scm-manager/ui-buttons": "2.43.2-20230501-105257",
22
+ "@storybook/addon-actions": "^6.5.10",
23
+ "@storybook/addon-essentials": "^6.5.10",
24
+ "@storybook/addon-interactions": "^6.5.10",
25
+ "@storybook/addon-links": "^6.5.10",
26
+ "@storybook/builder-webpack5": "^6.5.10",
27
+ "@storybook/manager-webpack5": "^6.5.10",
28
+ "@storybook/react": "^6.5.10",
29
+ "@storybook/testing-library": "^0.0.13",
30
+ "@storybook/addon-docs": "^6.5.14",
31
+ "babel-loader": "^8.2.5",
32
+ "storybook-addon-mock": "^3.2.0",
33
+ "storybook-addon-themes": "^6.1.0",
34
+ "tsup": "^6.2.3"
35
+ },
36
+ "peerDependencies": {
37
+ "react": "17",
38
+ "react-dom": "17",
39
+ "classnames": "2",
40
+ "styled-components": "5"
41
+ },
42
+ "prettier": "@scm-manager/prettier-config",
43
+ "eslintConfig": {
44
+ "extends": "@scm-manager/eslint-config"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ }
49
+ }
@@ -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
+ import React, { LiHTMLAttributes } from "react";
26
+ import styled from "styled-components";
27
+ import classNames from "classnames";
28
+
29
+ const CardElement = styled.li`
30
+ display: grid;
31
+ grid-template-columns: minmax(0, 1fr) min-content;
32
+ grid-template-rows: auto;
33
+ `;
34
+
35
+ const CardActionContainer = styled.span`
36
+ grid-column: -1;
37
+ grid-row: 1;
38
+ margin-top: -0.5rem;
39
+ margin-right: -0.5rem;
40
+ `;
41
+
42
+ type Props = LiHTMLAttributes<HTMLLIElement> & {
43
+ action?: React.ReactElement;
44
+ };
45
+
46
+ /**
47
+ * @beta
48
+ * @since 2.44.0
49
+ */
50
+ const Card = React.forwardRef<HTMLLIElement, Props>(({ className, children, action, ...props }, ref) => (
51
+ <CardElement className={classNames(className, "is-relative", "p-2")} ref={ref} {...props}>
52
+ {children}
53
+ {action ? <CardActionContainer>{action}</CardActionContainer> : null}
54
+ </CardElement>
55
+ ));
56
+
57
+ export default Card;
@@ -0,0 +1,117 @@
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 { ExtractProps } from "@scm-manager/ui-extensions";
29
+ import { Link } from "react-router-dom";
30
+ import CardList, { CardListBox } from "./CardList";
31
+ import Card from "./Card";
32
+ import CardTitle from "./CardTitle";
33
+ import { Menu } from "@scm-manager/ui-overlays";
34
+ import { Icon } from "@scm-manager/ui-buttons";
35
+ import CardRow from "./CardRow";
36
+
37
+ export default {
38
+ title: "CardList",
39
+ component: CardList,
40
+ decorators: [StoryRouter()],
41
+ } as ComponentMeta<typeof CardList>;
42
+
43
+ const Template: StoryFn<ExtractProps<typeof CardListBox>> = (args) => <CardListBox {...args} />;
44
+
45
+ export const Default = Template.bind({});
46
+ // More on args: https://storybook.js.org/docs/react/writing-stories/args
47
+ Default.args = {
48
+ children: [
49
+ // eslint-disable-next-line no-console
50
+ <Card>
51
+ <CardRow>
52
+ <CardTitle>My favorite repository</CardTitle>
53
+ </CardRow>
54
+ </Card>,
55
+ <Card>
56
+ <CardRow>
57
+ <CardTitle>
58
+ <Link aria-label="Edit My least liked repo" to="/cards/1">
59
+ My least liked repo
60
+ </Link>
61
+ </CardTitle>
62
+ </CardRow>
63
+ </Card>,
64
+ <Card
65
+ action={
66
+ <Menu>
67
+ <Menu.Button>
68
+ <Icon>trash</Icon>
69
+ Delete
70
+ </Menu.Button>
71
+ </Menu>
72
+ }
73
+ >
74
+ <CardRow className="is-flex is-justify-content-space-between">
75
+ <CardTitle>
76
+ <Link aria-label="Edit My other favorite repository" to="/cards/1">
77
+ My other favorite repository
78
+ </Link>
79
+ </CardTitle>
80
+ (TAG)
81
+ </CardRow>
82
+ <CardRow className="is-size-6">
83
+ This is a card description in the second row. Highlighting how the layout flows if there are multiple rows in
84
+ one card while the card also has an action.
85
+ </CardRow>
86
+ <CardRow className="is-size-6 is-flex is-justify-content-space-between">
87
+ <span>This is a third row, lets see how this works out.</span>(MERGED)
88
+ </CardRow>
89
+ </Card>,
90
+ <Card>
91
+ <CardRow className="is-flex is-align-items-center">
92
+ <CardTitle>
93
+ <Link
94
+ aria-label="Edit Enhance descriptions to differentiate between dumps with and without metadata."
95
+ to="/cards/1"
96
+ >
97
+ Enhance descriptions to differentiate between dumps with and without metadata.
98
+ </Link>
99
+ </CardTitle>
100
+ <small>#13456</small>
101
+ </CardRow>
102
+ <CardRow className="is-size-6">
103
+ Another Name requested to merge <strong>feature/asdkjertg</strong> into <strong>develop</strong> about 3 months
104
+ ago.
105
+ </CardRow>
106
+ <CardRow className="is-size-6 is-flex is-justify-content-space-between">
107
+ <div>
108
+ <span>Tasks (3/3)</span>
109
+ <span>Reviewers (1)</span>
110
+ <span>Analyses (✓)</span>
111
+ <span>Workflow (✓)</span>
112
+ </div>
113
+ <span>(OPEN)</span>
114
+ </CardRow>
115
+ </Card>,
116
+ ],
117
+ } as ComponentProps<typeof CardListBox>;
@@ -0,0 +1,67 @@
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, { HTMLAttributes } from "react";
26
+ import classNames from "classnames";
27
+ import styled from "styled-components";
28
+
29
+ const CardListElement = styled.ul`
30
+ > * + * {
31
+ border-top: var(--scm-border);
32
+ margin-top: 0.5rem;
33
+ padding-top: 1rem !important;
34
+
35
+ *:is(h1, h2, h3, h4, h5, h6) a::after {
36
+ top: 0.5rem !important;
37
+ }
38
+ }
39
+ `;
40
+
41
+ type Props = HTMLAttributes<HTMLUListElement>;
42
+
43
+ /**
44
+ * The {@link CardList.Card.Title} is currently represented as a `h3`, which means the list can only be used on the top level of the page without breaking accessibility.
45
+ *
46
+ * @beta
47
+ * @since 2.44.0
48
+ */
49
+ const CardList = React.forwardRef<HTMLUListElement, Props>(({ children, className, ...props }, ref) => (
50
+ <CardListElement ref={ref} {...props} className={classNames(className, "is-flex", "is-flex-direction-column")}>
51
+ {children}
52
+ </CardListElement>
53
+ ));
54
+
55
+ /**
56
+ * The {@link CardList.Card.Title} is currently represented as a `h3`, which means the list can only be used on the top level of the page without breaking accessibility.
57
+ *
58
+ * @beta
59
+ * @since 2.44.0
60
+ */
61
+ export const CardListBox = React.forwardRef<HTMLUListElement, Props>(({ className, children, ...props }, ref) => (
62
+ <CardList className={classNames(className, "p-2 box")} ref={ref} {...props}>
63
+ {children}
64
+ </CardList>
65
+ ));
66
+
67
+ 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 React, { HTMLAttributes } from "react";
26
+ import styled from "styled-components";
27
+ import classNames from "classnames";
28
+
29
+ const CardRowElement = styled.div`
30
+ grid-column: 1 / 2;
31
+ `;
32
+
33
+ type Props = HTMLAttributes<HTMLDivElement>;
34
+
35
+ /**
36
+ * @beta
37
+ * @since 2.44.0
38
+ */
39
+ const CardRow = React.forwardRef<HTMLDivElement, Props>(({ className, children, ...props }, ref) => (
40
+ <CardRowElement className={classNames(className)} ref={ref} {...props}>
41
+ {children}
42
+ </CardRowElement>
43
+ ));
44
+
45
+ export default CardRow;
@@ -0,0 +1,79 @@
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, { HTMLAttributes } from "react";
26
+ import styled from "styled-components";
27
+ import classNames from "classnames";
28
+
29
+ const CardTitleElement = styled.h3`
30
+ a {
31
+ color: var(--scm-secondary-text);
32
+
33
+ &:focus {
34
+ outline: none;
35
+ &::after {
36
+ outline: #af3ee7 3px solid;
37
+ outline-offset: 0px;
38
+ }
39
+ }
40
+
41
+ &:hover::after {
42
+ background-color: var(--scm-hover-color-blue);
43
+ }
44
+
45
+ &::after {
46
+ content: "";
47
+ position: absolute;
48
+ top: 0;
49
+ left: 0;
50
+ bottom: 0;
51
+ right: 0;
52
+ border-radius: 4px;
53
+ }
54
+ }
55
+ `;
56
+
57
+ type Props = HTMLAttributes<HTMLHeadingElement>;
58
+
59
+ /**
60
+ * A card title may contain a link as its only child which will be automatically stretched to cover the whole card area.
61
+ *
62
+ * If a card title has a link, individual card elements which should be interactive have to get the `is-relative` class.
63
+ *
64
+ * The card title (or enclosed link) content must be an accessible text and must not contain any other interactive elements.
65
+ *
66
+ * You can wrap the title in a {@link CardList.Card.Row} to introduce other elements next to the title.
67
+ *
68
+ * The title (or its enclosing row) must be the first element in a {@link CardList.Card}.
69
+ *
70
+ * @beta
71
+ * @since 2.44.0
72
+ */
73
+ const CardTitle = React.forwardRef<HTMLHeadingElement, Props>(({ children, className, ...props }, ref) => (
74
+ <CardTitleElement className={classNames(className, "is-ellipsis-overflow")} ref={ref} {...props}>
75
+ {children}
76
+ </CardTitleElement>
77
+ ));
78
+
79
+ export default CardTitle;
package/src/index.ts ADDED
@@ -0,0 +1,38 @@
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 } from "./card-list/CardList";
26
+ import CardRow from "./card-list/CardRow";
27
+ import Card from "./card-list/Card";
28
+ import CardTitle from "./card-list/CardTitle";
29
+
30
+ const CardListExport = {
31
+ Card: Object.assign(Card, {
32
+ Row: CardRow,
33
+ Title: CardTitle,
34
+ }),
35
+ };
36
+
37
+ export const CardList = Object.assign(CardListComponent, CardListExport);
38
+ export const CardListBox = Object.assign(CardListBoxComponent, CardListExport);
package/tsconfig.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "@scm-manager/tsconfig"
3
+ }