@polarityio/pi-external-link 1.0.0
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 +21 -0
- package/README.md +71 -0
- package/dist/component-registry.json +7 -0
- package/dist/external-link.d.ts +31 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +118 -0
- package/dist/styles/external-link.d.ts +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ThreatConnect, Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Polarity Integration Component Library
|
|
2
|
+
|
|
3
|
+
## External Link Component
|
|
4
|
+
|
|
5
|
+
A styled link that opens in a new tab with an external link icon and customizable hover tooltip.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @polarityio/pi-external-link
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Peer Dependencies
|
|
14
|
+
|
|
15
|
+
- [lit](https://lit.dev/) ^3.0.0
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
import '@polarityio/pi-external-link';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<!-- Basic link (displays the URL as text) -->
|
|
25
|
+
<pi-external-link href="https://example.com"></pi-external-link>
|
|
26
|
+
|
|
27
|
+
<!-- Link with custom display text -->
|
|
28
|
+
<pi-external-link href="https://example.com" text="Visit Example"></pi-external-link>
|
|
29
|
+
|
|
30
|
+
<!-- Link without icon -->
|
|
31
|
+
<pi-external-link href="https://example.com" text="Example" no-icon></pi-external-link>
|
|
32
|
+
|
|
33
|
+
<!-- Link with custom tooltip -->
|
|
34
|
+
<pi-external-link href="https://example.com" text="Example" tooltip-text="Opens in a new tab"></pi-external-link>
|
|
35
|
+
|
|
36
|
+
<!-- Link without tooltip -->
|
|
37
|
+
<pi-external-link href="https://example.com" text="Example" no-tooltip></pi-external-link>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## API Reference
|
|
41
|
+
|
|
42
|
+
### Properties
|
|
43
|
+
|
|
44
|
+
| Property | Type | Default | Description |
|
|
45
|
+
| --- | --- | --- | --- |
|
|
46
|
+
| `href` | `string` | `''` | The destination URL. Component renders nothing when empty. |
|
|
47
|
+
| `text` | `string` | `''` | Display text for the link. Falls back to `href` if empty. |
|
|
48
|
+
| `noIcon` | `boolean` | `false` | Hides the external-link icon when `true` |
|
|
49
|
+
| `tooltipText` | `string` | `''` | Custom tooltip text. Defaults to showing the `href` when empty. |
|
|
50
|
+
| `noTooltip` | `boolean` | `false` | Hides the tooltip entirely when `true` |
|
|
51
|
+
|
|
52
|
+
### Slots
|
|
53
|
+
|
|
54
|
+
| Slot Name | Description |
|
|
55
|
+
| --- | --- |
|
|
56
|
+
| `tooltip` | Custom tooltip content. Overrides both `tooltipText` and the default href tooltip. |
|
|
57
|
+
|
|
58
|
+
### CSS Custom Properties
|
|
59
|
+
|
|
60
|
+
| Property | Default | Description |
|
|
61
|
+
| --- | --- | --- |
|
|
62
|
+
| `--pi-external-link-icon-size` | `0.85em` | Size of the external-link icon |
|
|
63
|
+
| `--pi-external-link-icon-color` | `currentColor` | Color of the external-link icon |
|
|
64
|
+
|
|
65
|
+
## Theming
|
|
66
|
+
|
|
67
|
+
Customize the appearance using CSS custom properties. This component uses design tokens from `@polarityio/pi-shared` for consistent theming across the component library.
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
MIT
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { LitElement, nothing } from 'lit';
|
|
2
|
+
export declare const CUSTOM_ELEMENT_NAME: string;
|
|
3
|
+
export interface PiExternalLinkProps {
|
|
4
|
+
href: string;
|
|
5
|
+
text: string;
|
|
6
|
+
noIcon: boolean;
|
|
7
|
+
tooltipText: string;
|
|
8
|
+
noTooltip: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A styled link that opens in a new tab with an external link icon and hover tooltip.
|
|
12
|
+
*
|
|
13
|
+
* @element pi-external-link
|
|
14
|
+
* @slot tooltip - Custom tooltip content (overrides default tooltip)
|
|
15
|
+
* @cssproperty [--pi-external-link-icon-size=0.85em] - Override the link icon size
|
|
16
|
+
* @cssproperty [--pi-external-link-icon-color=currentColor] - Override the link icon color
|
|
17
|
+
*/
|
|
18
|
+
export declare class PiExternalLink extends LitElement {
|
|
19
|
+
href: string;
|
|
20
|
+
text: string;
|
|
21
|
+
/** Hide the external-link icon */
|
|
22
|
+
noIcon: boolean;
|
|
23
|
+
/** Custom tooltip text (defaults to href) */
|
|
24
|
+
tooltipText: string;
|
|
25
|
+
/** Hide the tooltip entirely */
|
|
26
|
+
noTooltip: boolean;
|
|
27
|
+
static styles: import('lit').CSSResult;
|
|
28
|
+
private _renderIcon;
|
|
29
|
+
private _renderTooltip;
|
|
30
|
+
render(): typeof nothing | import('lit').TemplateResult<1>;
|
|
31
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { css, LitElement, nothing, html as html$1 } from "lit";
|
|
2
|
+
import { property } from "lit/decorators.js";
|
|
3
|
+
import { unsafeStatic, html } from "lit/static-html.js";
|
|
4
|
+
import { faUpRightFromSquare } from "@fortawesome/free-solid-svg-icons";
|
|
5
|
+
import { defineCustomElementOnce, libraryCustomElementName } from "@polarityio/pi-shared";
|
|
6
|
+
import { CUSTOM_ELEMENT_NAME as CUSTOM_ELEMENT_NAME$1, PiIcon } from "@polarityio/pi-icon";
|
|
7
|
+
import { CUSTOM_ELEMENT_NAME as CUSTOM_ELEMENT_NAME$2, PiTooltip } from "@polarityio/pi-tooltip";
|
|
8
|
+
const version = "1.0.0";
|
|
9
|
+
const packageJson = {
|
|
10
|
+
version
|
|
11
|
+
};
|
|
12
|
+
const externalLinkStyles = css`
|
|
13
|
+
:host {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
font-family: var(--pi-font-family-base, 'NotoSans', sans-serif);
|
|
17
|
+
font-size: var(--pi-size-font-base, 0.8125rem);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:host([hidden]) {
|
|
21
|
+
display: none !important;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
a {
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
gap: var(--pi-size-spacing-xs, 0.25rem);
|
|
28
|
+
color: var(--pi-color-font-info, #5ba4cf);
|
|
29
|
+
text-decoration: none;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
line-height: 1.4;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
a:hover {
|
|
35
|
+
text-decoration: underline;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
a:focus-visible {
|
|
39
|
+
outline: 2px solid var(--pi-color-border-focus, var(--pi-color-background-primary));
|
|
40
|
+
outline-offset: 2px;
|
|
41
|
+
border-radius: var(--pi-size-radius-sm, 2px);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.link-icon {
|
|
45
|
+
display: inline-flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
flex-shrink: 0;
|
|
48
|
+
line-height: 0;
|
|
49
|
+
margin-bottom: 2px;
|
|
50
|
+
--pi-icon-size: var(--pi-external-link-icon-size, 0.85em);
|
|
51
|
+
--pi-icon-color: var(--pi-external-link-icon-color, currentColor);
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
var __defProp = Object.defineProperty;
|
|
55
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
56
|
+
var result = void 0;
|
|
57
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
58
|
+
if (decorator = decorators[i])
|
|
59
|
+
result = decorator(target, key, result) || result;
|
|
60
|
+
if (result) __defProp(target, key, result);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
defineCustomElementOnce(CUSTOM_ELEMENT_NAME$1, PiIcon);
|
|
64
|
+
defineCustomElementOnce(CUSTOM_ELEMENT_NAME$2, PiTooltip);
|
|
65
|
+
const CUSTOM_ELEMENT_NAME = libraryCustomElementName("external-link", packageJson.version);
|
|
66
|
+
const iconTag = unsafeStatic(CUSTOM_ELEMENT_NAME$1);
|
|
67
|
+
const tooltipTag = unsafeStatic(CUSTOM_ELEMENT_NAME$2);
|
|
68
|
+
const _PiExternalLink = class _PiExternalLink extends LitElement {
|
|
69
|
+
constructor() {
|
|
70
|
+
super(...arguments);
|
|
71
|
+
this.href = "";
|
|
72
|
+
this.text = "";
|
|
73
|
+
this.noIcon = false;
|
|
74
|
+
this.tooltipText = "";
|
|
75
|
+
this.noTooltip = false;
|
|
76
|
+
}
|
|
77
|
+
_renderIcon() {
|
|
78
|
+
if (this.noIcon) return nothing;
|
|
79
|
+
return html`<${iconTag} class="link-icon" .icon=${faUpRightFromSquare}></${iconTag}>`;
|
|
80
|
+
}
|
|
81
|
+
_renderTooltip() {
|
|
82
|
+
if (this.noTooltip) return nothing;
|
|
83
|
+
const defaultText = this.tooltipText || this.href;
|
|
84
|
+
return html`<${tooltipTag} placement="top" open-delay="500"><slot name="tooltip">${defaultText}</slot></${tooltipTag}>`;
|
|
85
|
+
}
|
|
86
|
+
render() {
|
|
87
|
+
if (!this.href) return nothing;
|
|
88
|
+
const displayText = this.text || this.href;
|
|
89
|
+
return html$1`
|
|
90
|
+
<a href=${this.href} target="_blank" rel="noopener noreferrer">
|
|
91
|
+
<span class="link-text">${displayText}</span>
|
|
92
|
+
${this._renderIcon()}
|
|
93
|
+
</a>
|
|
94
|
+
${this._renderTooltip()}
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
_PiExternalLink.styles = externalLinkStyles;
|
|
99
|
+
let PiExternalLink = _PiExternalLink;
|
|
100
|
+
__decorateClass([
|
|
101
|
+
property({ type: String })
|
|
102
|
+
], PiExternalLink.prototype, "href");
|
|
103
|
+
__decorateClass([
|
|
104
|
+
property({ type: String })
|
|
105
|
+
], PiExternalLink.prototype, "text");
|
|
106
|
+
__decorateClass([
|
|
107
|
+
property({ type: Boolean, attribute: "no-icon" })
|
|
108
|
+
], PiExternalLink.prototype, "noIcon");
|
|
109
|
+
__decorateClass([
|
|
110
|
+
property({ type: String, attribute: "tooltip-text" })
|
|
111
|
+
], PiExternalLink.prototype, "tooltipText");
|
|
112
|
+
__decorateClass([
|
|
113
|
+
property({ type: Boolean, attribute: "no-tooltip" })
|
|
114
|
+
], PiExternalLink.prototype, "noTooltip");
|
|
115
|
+
export {
|
|
116
|
+
CUSTOM_ELEMENT_NAME,
|
|
117
|
+
PiExternalLink
|
|
118
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const externalLinkStyles: import('lit').CSSResult;
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@polarityio/pi-external-link",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "External link component that opens in a new tab with icon and tooltip",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/polarityio/integration-component-library.git",
|
|
12
|
+
"directory": "packages/external-link"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"module": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"source": "./src/index.ts",
|
|
23
|
+
"import": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./component-registry.json": "./dist/component-registry.json"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@fortawesome/free-solid-svg-icons": "^7.0.0",
|
|
32
|
+
"@polarityio/pi-shared": "1.0.0",
|
|
33
|
+
"@polarityio/pi-tooltip": "1.0.0",
|
|
34
|
+
"@polarityio/pi-icon": "1.0.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"lit": "^3.0.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "vite build",
|
|
41
|
+
"typecheck": "tsc --noEmit"
|
|
42
|
+
}
|
|
43
|
+
}
|