@m3e/tooltip 1.0.0-rc.1
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/LICENSE +22 -0
- package/README.md +115 -0
- package/cem.config.mjs +16 -0
- package/demo/index.html +71 -0
- package/dist/css-custom-data.json +67 -0
- package/dist/custom-elements.json +400 -0
- package/dist/html-custom-data.json +43 -0
- package/dist/index.js +436 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +117 -0
- package/dist/index.min.js.map +1 -0
- package/dist/src/TooltipElement.d.ts +104 -0
- package/dist/src/TooltipElement.d.ts.map +1 -0
- package/dist/src/TooltipPosition.d.ts +3 -0
- package/dist/src/TooltipPosition.d.ts.map +1 -0
- package/dist/src/TooltipTouchGestures.d.ts +3 -0
- package/dist/src/TooltipTouchGestures.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/eslint.config.mjs +13 -0
- package/package.json +51 -0
- package/rollup.config.js +32 -0
- package/src/TooltipElement.ts +374 -0
- package/src/TooltipPosition.ts +2 -0
- package/src/TooltipTouchGestures.ts +2 -0
- package/src/index.ts +3 -0
- package/tsconfig.json +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 matraic
|
|
4
|
+
Contact: matraic@yahoo.com
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# @m3e/tooltip
|
|
2
|
+
|
|
3
|
+
The `m3e-tooltip` component provides contextual information in response to user interaction, enhancing comprehension and reducing ambiguity. Tooltips are positioned relative to a target element and support configurable delays for show and hide behavior. Use the `for` attribute to designate the element for which to provide a tooltip.
|
|
4
|
+
|
|
5
|
+
> **Part of the [M3E](../../README.md) monorepo**
|
|
6
|
+
> This package is maintained within the unified M3E repository, which provides a suite of Material 3 web components.
|
|
7
|
+
|
|
8
|
+
## ๐ฆ Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @m3e/tooltip
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## ๐ป Editor Integration
|
|
15
|
+
|
|
16
|
+
This package includes a [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) to support enhanced editor tooling and developer experience.
|
|
17
|
+
|
|
18
|
+
### Visual Studio Code
|
|
19
|
+
|
|
20
|
+
To enable autocomplete and hover documentation for `@m3e/tooltip`, install the [Custom Elements Manifest Language Server](https://marketplace.visualstudio.com/items?itemName=pwrs.cem-language-server-vscode) extension. It will automatically detect the manifest bundled with this package and surface tag names, attributes, slots, and events in supported files.
|
|
21
|
+
|
|
22
|
+
Alternately, you can explicitly reference the `html-custom-data.json` and `css-custom-data.json` in your workspace settings:
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"html.customData": ["./node_modules/@m3e/tooltip/dist/html-custom-data.json"],
|
|
27
|
+
"css.customData": ["./node_modules/@m3e/tooltip/dist/css-custom-data.json"]
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## ๐ Browser Usage
|
|
32
|
+
|
|
33
|
+
This package uses [JavaScript Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#module_specifiers). To use it directly in a browser without a bundler, use a module script similar to the following.
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<script type="module" src="/node_modules/@m3e/toolbar/dist/index.js"></script>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
In addition, you must use an [import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap) to include dependencies.
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<script type="importmap">
|
|
43
|
+
{
|
|
44
|
+
"imports": {
|
|
45
|
+
"lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
|
|
46
|
+
"@m3e/core": "/node_modules/@m3e/core/dist/index.js",
|
|
47
|
+
"@m3e/core/a11y": "/node_modules/@m3e/core/dist/a11y.js",
|
|
48
|
+
"@m3e/core/anchoring": "/node_modules/@m3e/core/dist/anchoring.js",
|
|
49
|
+
"@m3e/core/platform": "/node_modules/@m3e/core/dist/platform.js"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
</script>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
> For production, use index.min.js, a11y.min.js, anchoring.min.js, and platform.min.js for faster load times.
|
|
56
|
+
|
|
57
|
+
## ๐๏ธ Elements
|
|
58
|
+
|
|
59
|
+
- `m3e-tooltip` โ Adds additional context to a button or other UI element.
|
|
60
|
+
|
|
61
|
+
## ๐งช Examples
|
|
62
|
+
|
|
63
|
+
The following example illustrates connecting a tooltip to a button using the `for` attribute.
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<m3e-icon-button id="button" aria-label="Back">
|
|
67
|
+
<m3e-icon name="arrow_back"></m3e-icon>
|
|
68
|
+
</m3e-icon-button>
|
|
69
|
+
<m3e-tooltip for="button">Go Back</m3e-tooltip>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## ๐ API Reference
|
|
73
|
+
|
|
74
|
+
This section details the attributes, slots and CSS custom properties available for the `m3e-tooltip` component.
|
|
75
|
+
|
|
76
|
+
### โ๏ธ Attributes
|
|
77
|
+
|
|
78
|
+
| Attribute | Type | Default | Description |
|
|
79
|
+
| ------------ | --------- | ------- | ----------------------------------------------------------------------- |
|
|
80
|
+
| `disabled` | `boolean` | `false` | Whether the element is disabled. |
|
|
81
|
+
| `for` | `string` | | The query selector used to specify the element related to this element. |
|
|
82
|
+
| `hide-delay` | `number` | `200` | The amount of time, in milliseconds, before hiding the tooltip. |
|
|
83
|
+
| `position` | `string` | `"top"` | The position of the tooltip. |
|
|
84
|
+
| `show-delay` | `number` | `0` | The amount of time, in milliseconds, before showing the tooltip. |
|
|
85
|
+
|
|
86
|
+
### ๐งฉ Slots
|
|
87
|
+
|
|
88
|
+
| Slot | Description |
|
|
89
|
+
| ----------- | ----------------------------------- |
|
|
90
|
+
| _(default)_ | Renders the content of the tooltip. |
|
|
91
|
+
|
|
92
|
+
### ๐๏ธ CSS Custom Properties
|
|
93
|
+
|
|
94
|
+
| Property | Description |
|
|
95
|
+
| ------------------------------------------- | ------------------------------------------ |
|
|
96
|
+
| `--m3e-tooltip-padding` | Internal spacing of the tooltip container. |
|
|
97
|
+
| `--m3e-tooltip-min-width` | Minimum width of the tooltip. |
|
|
98
|
+
| `--m3e-tooltip-max-width` | Maximum width of the tooltip. |
|
|
99
|
+
| `--m3e-tooltip-min-height` | Minimum height of the tooltip container. |
|
|
100
|
+
| `--m3e-tooltip-max-height` | Maximum height of the tooltip. |
|
|
101
|
+
| `--m3e-tooltip-shape` | Border radius of the tooltip container. |
|
|
102
|
+
| `--m3e-tooltip-container-color` | Background color of the tooltip. |
|
|
103
|
+
| `--m3e-tooltip-supporting-text-color` | Text color of supporting text. |
|
|
104
|
+
| `--m3e-tooltip-supporting-text-font-size` | Font size of supporting text. |
|
|
105
|
+
| `--m3e-tooltip-supporting-text-font-weight` | Font weight of supporting text. |
|
|
106
|
+
| `--m3e-tooltip-supporting-text-line-height` | Line height of supporting text. |
|
|
107
|
+
| `--m3e-tooltip-supporting-text-tracking` | Letter spacing of supporting text. |
|
|
108
|
+
|
|
109
|
+
## ๐ค Contributing
|
|
110
|
+
|
|
111
|
+
See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.
|
|
112
|
+
|
|
113
|
+
## ๐ License
|
|
114
|
+
|
|
115
|
+
This package is licensed under the MIT License.
|
package/cem.config.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { customElementVsCodePlugin } from "custom-element-vs-code-integration";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
globs: ["src/**/*.ts"],
|
|
5
|
+
exclude: ["src/**/*.spec.ts"],
|
|
6
|
+
packagejson: true,
|
|
7
|
+
outdir: "dist",
|
|
8
|
+
litelement: true,
|
|
9
|
+
plugins: [
|
|
10
|
+
customElementVsCodePlugin({
|
|
11
|
+
outdir: "dist",
|
|
12
|
+
htmlFileName: "html-custom-data.json",
|
|
13
|
+
cssFileName: "css-custom-data.json",
|
|
14
|
+
}),
|
|
15
|
+
],
|
|
16
|
+
};
|
package/demo/index.html
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" style="overflow-y: auto">
|
|
3
|
+
<head>
|
|
4
|
+
<title>Tooltip for M3E</title>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<meta name="description" content="Tooltip for M3E" />
|
|
8
|
+
<base href="./" />
|
|
9
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
10
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
11
|
+
<link
|
|
12
|
+
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap"
|
|
13
|
+
rel="stylesheet"
|
|
14
|
+
/>
|
|
15
|
+
<link
|
|
16
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0..1,0"
|
|
17
|
+
rel="stylesheet"
|
|
18
|
+
/>
|
|
19
|
+
<script type="importmap">
|
|
20
|
+
{
|
|
21
|
+
"imports": {
|
|
22
|
+
"lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
|
|
23
|
+
"@m3e/core": "../../core/dist/index.min.js",
|
|
24
|
+
"@m3e/core/a11y": "../../core/dist/a11y.min.js",
|
|
25
|
+
"@m3e/core/anchoring": "../../core/dist/anchoring.min.js",
|
|
26
|
+
"@m3e/core/platform": "../../core/dist/platform.min.js"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
<script type="module" src="../../button/dist/index.min.js"></script>
|
|
31
|
+
<script type="module" src="../../icon/dist/index.min.js"></script>
|
|
32
|
+
<script type="module" src="../../icon-button/dist/index.min.js"></script>
|
|
33
|
+
<script type="module" src="../../theme/dist/index.min.js"></script>
|
|
34
|
+
<script type="module" src="../../toolbar/dist/index.min.js"></script>
|
|
35
|
+
<script type="module" src="../dist/index.min.js"></script>
|
|
36
|
+
<style>
|
|
37
|
+
body {
|
|
38
|
+
font-family: "Roboto";
|
|
39
|
+
}
|
|
40
|
+
*:not(:defined) {
|
|
41
|
+
display: none;
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
<m3e-theme strong-focus>
|
|
47
|
+
<m3e-toolbar variant="vibrant" shape="rounded">
|
|
48
|
+
<m3e-icon-button id="btnBack">
|
|
49
|
+
<m3e-icon name="arrow_back"></m3e-icon>
|
|
50
|
+
</m3e-icon-button>
|
|
51
|
+
<m3e-tooltip for="btnBack">Go back</m3e-tooltip>
|
|
52
|
+
<m3e-icon-button id="btnForward">
|
|
53
|
+
<m3e-icon name="arrow_forward"></m3e-icon>
|
|
54
|
+
</m3e-icon-button>
|
|
55
|
+
<m3e-tooltip for="btnForward">Go forward</m3e-tooltip>
|
|
56
|
+
<m3e-icon-button id="btnAdd" width="wide" variant="filled">
|
|
57
|
+
<m3e-icon name="add"></m3e-icon>
|
|
58
|
+
</m3e-icon-button>
|
|
59
|
+
<m3e-tooltip for="btnAdd">Create video</m3e-tooltip>
|
|
60
|
+
<m3e-icon-button id="btnPip">
|
|
61
|
+
<m3e-icon name="picture_in_picture"></m3e-icon>
|
|
62
|
+
</m3e-icon-button>
|
|
63
|
+
<m3e-tooltip for="btnPip">Pop out video</m3e-tooltip>
|
|
64
|
+
<m3e-icon-button id="btnMore">
|
|
65
|
+
<m3e-icon name="more_vert"></m3e-icon>
|
|
66
|
+
</m3e-icon-button>
|
|
67
|
+
<m3e-tooltip for="btnMore">Show more</m3e-tooltip>
|
|
68
|
+
</m3e-toolbar>
|
|
69
|
+
</m3e-theme>
|
|
70
|
+
</body>
|
|
71
|
+
</html>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/microsoft/vscode-css-languageservice/main/docs/customData.schema.json",
|
|
3
|
+
"version": 1.1,
|
|
4
|
+
"properties": [
|
|
5
|
+
{
|
|
6
|
+
"name": "--m3e-tooltip-padding",
|
|
7
|
+
"description": "Internal spacing of the tooltip container.",
|
|
8
|
+
"values": []
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "--m3e-tooltip-min-width",
|
|
12
|
+
"description": "Minimum width of the tooltip.",
|
|
13
|
+
"values": []
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "--m3e-tooltip-max-width",
|
|
17
|
+
"description": "Maximum width of the tooltip.",
|
|
18
|
+
"values": []
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "--m3e-tooltip-min-height",
|
|
22
|
+
"description": "Minimum height of the tooltip container.",
|
|
23
|
+
"values": []
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "--m3e-tooltip-max-height",
|
|
27
|
+
"description": "Maximum height of the tooltip.",
|
|
28
|
+
"values": []
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "--m3e-tooltip-shape",
|
|
32
|
+
"description": "Border radius of the tooltip container.",
|
|
33
|
+
"values": []
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "--m3e-tooltip-container-color",
|
|
37
|
+
"description": "Background color of the tooltip.",
|
|
38
|
+
"values": []
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "--m3e-tooltip-supporting-text-color",
|
|
42
|
+
"description": "Text color of supporting text.",
|
|
43
|
+
"values": []
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "--m3e-tooltip-supporting-text-font-size",
|
|
47
|
+
"description": "Font size of supporting text.",
|
|
48
|
+
"values": []
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "--m3e-tooltip-supporting-text-font-weight",
|
|
52
|
+
"description": "Font weight of supporting text.",
|
|
53
|
+
"values": []
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "--m3e-tooltip-supporting-text-line-height",
|
|
57
|
+
"description": "Line height of supporting text.",
|
|
58
|
+
"values": []
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "--m3e-tooltip-supporting-text-tracking",
|
|
62
|
+
"description": "Letter spacing of supporting text.",
|
|
63
|
+
"values": []
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"pseudoElements": []
|
|
67
|
+
}
|