@scm-manager/ui-overlays 2.40.2-20230016-130104
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/RemoveThemesPlugin.js +57 -0
- package/.storybook/main.js +89 -0
- package/.storybook/preview-head.html +26 -0
- package/.storybook/preview.js +72 -0
- package/.turbo/turbo-build.log +15 -0
- package/build/index.d.ts +26 -0
- package/build/index.js +73 -0
- package/build/index.mjs +40 -0
- package/package.json +49 -0
- package/src/index.ts +25 -0
- package/src/tooltip/Tooltip.examples.js +41 -0
- package/src/tooltip/Tooltip.stories.mdx +52 -0
- package/src/tooltip/Tooltip.tsx +95 -0
- package/tsconfig.json +3 -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,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,72 @@
|
|
|
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 { I18nextProvider, initReactI18next } from "react-i18next";
|
|
27
|
+
import i18n from "i18next";
|
|
28
|
+
|
|
29
|
+
i18n.use(initReactI18next).init({
|
|
30
|
+
whitelist: ["en", "de"],
|
|
31
|
+
lng: "en",
|
|
32
|
+
fallbackLng: "en",
|
|
33
|
+
interpolation: {
|
|
34
|
+
escapeValue: false,
|
|
35
|
+
},
|
|
36
|
+
react: {
|
|
37
|
+
useSuspense: false,
|
|
38
|
+
},
|
|
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 parameters = {
|
|
54
|
+
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
55
|
+
decorators: [
|
|
56
|
+
(Story) => (
|
|
57
|
+
<I18nextProvider i18n={i18n}>
|
|
58
|
+
<Story />
|
|
59
|
+
</I18nextProvider>
|
|
60
|
+
),
|
|
61
|
+
],
|
|
62
|
+
themes: {
|
|
63
|
+
Decorator,
|
|
64
|
+
clearable: false,
|
|
65
|
+
default: "light",
|
|
66
|
+
list: [
|
|
67
|
+
{ name: "light", color: "#fff" },
|
|
68
|
+
{ name: "highcontrast", color: "#050514" },
|
|
69
|
+
{ name: "dark", color: "#121212" },
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@scm-manager/ui-overlays:build: cache hit, replaying output 5ab67f515d27c6b4
|
|
2
|
+
@scm-manager/ui-overlays:build: $ tsup ./src/index.ts -d build --format esm,cjs --dts
|
|
3
|
+
@scm-manager/ui-overlays:build: CLI Building entry: ./src/index.ts
|
|
4
|
+
@scm-manager/ui-overlays:build: CLI Using tsconfig: tsconfig.json
|
|
5
|
+
@scm-manager/ui-overlays:build: CLI tsup v6.2.3
|
|
6
|
+
@scm-manager/ui-overlays:build: CLI Target: node14
|
|
7
|
+
@scm-manager/ui-overlays:build: ESM Build start
|
|
8
|
+
@scm-manager/ui-overlays:build: CJS Build start
|
|
9
|
+
@scm-manager/ui-overlays:build: ESM build/index.mjs 1.26 KB
|
|
10
|
+
@scm-manager/ui-overlays:build: ESM ⚡️ Build success in 115ms
|
|
11
|
+
@scm-manager/ui-overlays:build: CJS build/index.js 2.80 KB
|
|
12
|
+
@scm-manager/ui-overlays:build: CJS ⚡️ Build success in 86ms
|
|
13
|
+
@scm-manager/ui-overlays:build: DTS Build start
|
|
14
|
+
@scm-manager/ui-overlays:build: DTS ⚡️ Build success in 8242ms
|
|
15
|
+
@scm-manager/ui-overlays:build: DTS build/index.d.ts 831.00 B
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { ReactNode, ReactElement } from 'react';
|
|
2
|
+
import * as RadixTooltip from '@radix-ui/react-tooltip';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Displays the given {@link Props#message} whenever the provided {@link Props#children} is hovered or focused.
|
|
6
|
+
*
|
|
7
|
+
* @since 2.41.0
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
declare const Tooltip: React.ForwardRefExoticComponent<{
|
|
11
|
+
/**
|
|
12
|
+
* The message to be displayed in the overlay.
|
|
13
|
+
*/
|
|
14
|
+
message: ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* It is required to provide a {@link ReactElement} as the single child because listeners and metadata is going to be
|
|
17
|
+
* attached to it automatically.
|
|
18
|
+
*/
|
|
19
|
+
children: ReactElement;
|
|
20
|
+
/**
|
|
21
|
+
* Class to be applied to the content container.
|
|
22
|
+
*/
|
|
23
|
+
className?: string | undefined;
|
|
24
|
+
} & Pick<RadixTooltip.TooltipContentProps, "side"> & React.RefAttributes<HTMLDivElement>>;
|
|
25
|
+
|
|
26
|
+
export { Tooltip };
|
package/build/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
Tooltip: () => Tooltip_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(src_exports);
|
|
32
|
+
|
|
33
|
+
// src/tooltip/Tooltip.tsx
|
|
34
|
+
var import_react = __toESM(require("react"));
|
|
35
|
+
var RadixTooltip = __toESM(require("@radix-ui/react-tooltip"));
|
|
36
|
+
var import_classnames = __toESM(require("classnames"));
|
|
37
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
38
|
+
var StyledContent = (0, import_styled_components.default)(RadixTooltip.Content)`
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
hyphens: auto;
|
|
41
|
+
text-overflow: clip;
|
|
42
|
+
white-space: pre-wrap;
|
|
43
|
+
max-width: 15rem;
|
|
44
|
+
word-break: keep-all;
|
|
45
|
+
z-index: 1020;
|
|
46
|
+
`;
|
|
47
|
+
var StyledArrow = (0, import_styled_components.default)(RadixTooltip.Arrow)`
|
|
48
|
+
z-index: 1020;
|
|
49
|
+
`;
|
|
50
|
+
var Tooltip = import_react.default.forwardRef(({ children, className, message, side }, ref) => /* @__PURE__ */ import_react.default.createElement(RadixTooltip.Provider, null, /* @__PURE__ */ import_react.default.createElement(RadixTooltip.Root, null, /* @__PURE__ */ import_react.default.createElement(RadixTooltip.Trigger, {
|
|
51
|
+
asChild: true
|
|
52
|
+
}, children), /* @__PURE__ */ import_react.default.createElement(RadixTooltip.Portal, null, /* @__PURE__ */ import_react.default.createElement(StyledContent, {
|
|
53
|
+
className: (0, import_classnames.default)(
|
|
54
|
+
"is-size-7",
|
|
55
|
+
"is-family-primary",
|
|
56
|
+
"has-rounded-border",
|
|
57
|
+
"has-text-white",
|
|
58
|
+
"has-background-grey-dark",
|
|
59
|
+
"has-text-weight-semibold",
|
|
60
|
+
"p-2",
|
|
61
|
+
className
|
|
62
|
+
),
|
|
63
|
+
side,
|
|
64
|
+
sideOffset: 5,
|
|
65
|
+
ref
|
|
66
|
+
}, message, /* @__PURE__ */ import_react.default.createElement(StyledArrow, {
|
|
67
|
+
className: "tooltip-arrow-fill-color"
|
|
68
|
+
}))))));
|
|
69
|
+
var Tooltip_default = Tooltip;
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
Tooltip
|
|
73
|
+
});
|
package/build/index.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/tooltip/Tooltip.tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
import * as RadixTooltip from "@radix-ui/react-tooltip";
|
|
4
|
+
import classNames from "classnames";
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
var StyledContent = styled(RadixTooltip.Content)`
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
hyphens: auto;
|
|
9
|
+
text-overflow: clip;
|
|
10
|
+
white-space: pre-wrap;
|
|
11
|
+
max-width: 15rem;
|
|
12
|
+
word-break: keep-all;
|
|
13
|
+
z-index: 1020;
|
|
14
|
+
`;
|
|
15
|
+
var StyledArrow = styled(RadixTooltip.Arrow)`
|
|
16
|
+
z-index: 1020;
|
|
17
|
+
`;
|
|
18
|
+
var Tooltip = React.forwardRef(({ children, className, message, side }, ref) => /* @__PURE__ */ React.createElement(RadixTooltip.Provider, null, /* @__PURE__ */ React.createElement(RadixTooltip.Root, null, /* @__PURE__ */ React.createElement(RadixTooltip.Trigger, {
|
|
19
|
+
asChild: true
|
|
20
|
+
}, children), /* @__PURE__ */ React.createElement(RadixTooltip.Portal, null, /* @__PURE__ */ React.createElement(StyledContent, {
|
|
21
|
+
className: classNames(
|
|
22
|
+
"is-size-7",
|
|
23
|
+
"is-family-primary",
|
|
24
|
+
"has-rounded-border",
|
|
25
|
+
"has-text-white",
|
|
26
|
+
"has-background-grey-dark",
|
|
27
|
+
"has-text-weight-semibold",
|
|
28
|
+
"p-2",
|
|
29
|
+
className
|
|
30
|
+
),
|
|
31
|
+
side,
|
|
32
|
+
sideOffset: 5,
|
|
33
|
+
ref
|
|
34
|
+
}, message, /* @__PURE__ */ React.createElement(StyledArrow, {
|
|
35
|
+
className: "tooltip-arrow-fill-color"
|
|
36
|
+
}))))));
|
|
37
|
+
var Tooltip_default = Tooltip;
|
|
38
|
+
export {
|
|
39
|
+
Tooltip_default as Tooltip
|
|
40
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scm-manager/ui-overlays",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "2.40.2-20230016-130104",
|
|
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.40.2-20230016-130104",
|
|
20
|
+
"@storybook/addon-actions": "^6.5.10",
|
|
21
|
+
"@storybook/addon-essentials": "^6.5.10",
|
|
22
|
+
"@storybook/addon-interactions": "^6.5.10",
|
|
23
|
+
"@storybook/addon-links": "^6.5.10",
|
|
24
|
+
"@storybook/builder-webpack5": "^6.5.10",
|
|
25
|
+
"@storybook/manager-webpack5": "^6.5.10",
|
|
26
|
+
"@storybook/react": "^6.5.10",
|
|
27
|
+
"@storybook/testing-library": "^0.0.13",
|
|
28
|
+
"@storybook/addon-docs": "^6.5.14",
|
|
29
|
+
"babel-loader": "^8.2.5",
|
|
30
|
+
"storybook-addon-mock": "^3.2.0",
|
|
31
|
+
"storybook-addon-themes": "^6.1.0",
|
|
32
|
+
"tsup": "^6.2.3"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"classnames": "^2.3.1",
|
|
36
|
+
"react": "17",
|
|
37
|
+
"styled-components": "^5.3.6"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@radix-ui/react-tooltip": "1.0.2"
|
|
41
|
+
},
|
|
42
|
+
"prettier": "@scm-manager/prettier-config",
|
|
43
|
+
"eslintConfig": {
|
|
44
|
+
"extends": "@scm-manager/eslint-config"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/index.ts
ADDED
|
@@ -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
|
+
export { default as Tooltip } from "./tooltip/Tooltip";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export const LongText =
|
|
26
|
+
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
|
|
27
|
+
|
|
28
|
+
export const ShortList = ` * a
|
|
29
|
+
* b
|
|
30
|
+
* c
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
export const List = ` Characters:
|
|
34
|
+
|
|
35
|
+
- Arthur Dent
|
|
36
|
+
- Ford Prefect
|
|
37
|
+
- Zaphod Beeblebrox
|
|
38
|
+
- Marvin the Paranoid Android
|
|
39
|
+
- Trillian
|
|
40
|
+
- Slartibartfast
|
|
41
|
+
`;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Meta, Story } from "@storybook/addon-docs";
|
|
2
|
+
import Tooltip from "./Tooltip"
|
|
3
|
+
import { List, LongText, ShortList } from "./Tooltip.examples";
|
|
4
|
+
|
|
5
|
+
<Meta title="Tooltip"/>
|
|
6
|
+
|
|
7
|
+
Here will be some documentation for the Tooltip component.
|
|
8
|
+
|
|
9
|
+
<Story name="Default">
|
|
10
|
+
<Tooltip message="I am a tooltip!">
|
|
11
|
+
<button>Hover me</button>
|
|
12
|
+
</Tooltip>
|
|
13
|
+
</Story>
|
|
14
|
+
|
|
15
|
+
<Story name="With Styling">
|
|
16
|
+
<Tooltip message="I am a tooltip!" className="has-text-warning">
|
|
17
|
+
<button>Hover me</button>
|
|
18
|
+
</Tooltip>
|
|
19
|
+
</Story>
|
|
20
|
+
|
|
21
|
+
<Story name="Long Text">
|
|
22
|
+
<Tooltip
|
|
23
|
+
message={LongText}>
|
|
24
|
+
<button>Hover me</button>
|
|
25
|
+
</Tooltip>
|
|
26
|
+
</Story>
|
|
27
|
+
|
|
28
|
+
<Story name="List">
|
|
29
|
+
<Tooltip message={List}>
|
|
30
|
+
<button>Hover me</button>
|
|
31
|
+
</Tooltip>
|
|
32
|
+
</Story>
|
|
33
|
+
|
|
34
|
+
<Story name="Short List">
|
|
35
|
+
<Tooltip message={ShortList}>
|
|
36
|
+
<button>Hover me</button>
|
|
37
|
+
</Tooltip>
|
|
38
|
+
</Story>
|
|
39
|
+
|
|
40
|
+
<Story name="With Link">
|
|
41
|
+
<Tooltip message={<p>
|
|
42
|
+
For more information look up the documentation on the <a href="https://scm-manager.org">SCM-Manager</a> Website.
|
|
43
|
+
</p>}>
|
|
44
|
+
<button>Hover me</button>
|
|
45
|
+
</Tooltip>
|
|
46
|
+
</Story>
|
|
47
|
+
|
|
48
|
+
<Story name="Adjust Position">
|
|
49
|
+
<Tooltip message="I should show where there is space" side="left">
|
|
50
|
+
<button>Hover me</button>
|
|
51
|
+
</Tooltip>
|
|
52
|
+
</Story>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import React, { ReactElement, ReactNode } from "react";
|
|
26
|
+
import * as RadixTooltip from "@radix-ui/react-tooltip";
|
|
27
|
+
import classNames from "classnames";
|
|
28
|
+
import styled from "styled-components";
|
|
29
|
+
|
|
30
|
+
const StyledContent = styled(RadixTooltip.Content)`
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
hyphens: auto;
|
|
33
|
+
text-overflow: clip;
|
|
34
|
+
white-space: pre-wrap;
|
|
35
|
+
max-width: 15rem;
|
|
36
|
+
word-break: keep-all;
|
|
37
|
+
z-index: 1020;
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const StyledArrow = styled(RadixTooltip.Arrow)`
|
|
41
|
+
z-index: 1020;
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
type Props = {
|
|
45
|
+
/**
|
|
46
|
+
* The message to be displayed in the overlay.
|
|
47
|
+
*/
|
|
48
|
+
message: ReactNode;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* It is required to provide a {@link ReactElement} as the single child because listeners and metadata is going to be
|
|
52
|
+
* attached to it automatically.
|
|
53
|
+
*/
|
|
54
|
+
children: ReactElement;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Class to be applied to the content container.
|
|
58
|
+
*/
|
|
59
|
+
className?: string;
|
|
60
|
+
} & Pick<RadixTooltip.TooltipContentProps, "side">;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Displays the given {@link Props#message} whenever the provided {@link Props#children} is hovered or focused.
|
|
64
|
+
*
|
|
65
|
+
* @since 2.41.0
|
|
66
|
+
* @beta
|
|
67
|
+
*/
|
|
68
|
+
const Tooltip = React.forwardRef<HTMLDivElement, Props>(({ children, className, message, side }, ref) => (
|
|
69
|
+
<RadixTooltip.Provider>
|
|
70
|
+
<RadixTooltip.Root>
|
|
71
|
+
<RadixTooltip.Trigger asChild>{children}</RadixTooltip.Trigger>
|
|
72
|
+
<RadixTooltip.Portal>
|
|
73
|
+
<StyledContent
|
|
74
|
+
className={classNames(
|
|
75
|
+
"is-size-7",
|
|
76
|
+
"is-family-primary",
|
|
77
|
+
"has-rounded-border",
|
|
78
|
+
"has-text-white",
|
|
79
|
+
"has-background-grey-dark",
|
|
80
|
+
"has-text-weight-semibold",
|
|
81
|
+
"p-2",
|
|
82
|
+
className
|
|
83
|
+
)}
|
|
84
|
+
side={side}
|
|
85
|
+
sideOffset={5}
|
|
86
|
+
ref={ref}
|
|
87
|
+
>
|
|
88
|
+
{message}
|
|
89
|
+
<StyledArrow className="tooltip-arrow-fill-color" />
|
|
90
|
+
</StyledContent>
|
|
91
|
+
</RadixTooltip.Portal>
|
|
92
|
+
</RadixTooltip.Root>
|
|
93
|
+
</RadixTooltip.Provider>
|
|
94
|
+
));
|
|
95
|
+
export default Tooltip;
|
package/tsconfig.json
ADDED