@fluid-topics/ftds-chip 2.1.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/README.md +19 -0
- package/build/define.d.ts +1 -0
- package/build/define.js +3 -0
- package/build/definitions.d.ts +5 -0
- package/build/definitions.js +4 -0
- package/build/ftds-chip.d.ts +27 -0
- package/build/ftds-chip.js +136 -0
- package/build/ftds-chip.light.js +1716 -0
- package/build/ftds-chip.min.js +1832 -0
- package/build/ftds-chip.properties.d.ts +8 -0
- package/build/ftds-chip.properties.js +1 -0
- package/build/ftds-chip.styles.d.ts +1 -0
- package/build/ftds-chip.styles.js +176 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +4 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
The design system chip component
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm install @fluid-topics/ftds-chip
|
|
7
|
+
yarn add @fluid-topics/ftds-chip
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { html } from "lit"
|
|
14
|
+
import "@fluid-topics/ftds-chip"
|
|
15
|
+
|
|
16
|
+
function render() {
|
|
17
|
+
return html` <ftds-chip foo="bar"></ftds-chip> `
|
|
18
|
+
}
|
|
19
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/define.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ElementDefinitionsMap, FtdsBase } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { FtdsIcons, FtdsIconVariants } from "@fluid-topics/ftds-icon";
|
|
3
|
+
import { FtdsChipProperties } from "./ftds-chip.properties";
|
|
4
|
+
export declare class RemoveEvent extends CustomEvent<void> {
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare class FtdsChip extends FtdsBase implements FtdsChipProperties {
|
|
8
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
9
|
+
withAction: boolean;
|
|
10
|
+
removable: boolean;
|
|
11
|
+
multiLine: boolean;
|
|
12
|
+
removeButtonLabel: string;
|
|
13
|
+
label: string;
|
|
14
|
+
icon?: FtdsIcons;
|
|
15
|
+
iconVariant?: FtdsIconVariants;
|
|
16
|
+
private slottedContent?;
|
|
17
|
+
static styles: import("lit").CSSResult[];
|
|
18
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
19
|
+
private renderIcon;
|
|
20
|
+
private renderAction;
|
|
21
|
+
private resolveButtonSize;
|
|
22
|
+
private getLabel;
|
|
23
|
+
getTextContent(): string;
|
|
24
|
+
private onSlotchange;
|
|
25
|
+
private dispatchRemoveEvent;
|
|
26
|
+
private typographyVariant;
|
|
27
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, nothing, } from "lit";
|
|
8
|
+
import { property, query, } from "lit/decorators.js";
|
|
9
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
10
|
+
import { DesignSystemFamily, FtdsBase, } from "@fluid-topics/ft-wc-utils";
|
|
11
|
+
import { FtdsTypography, FtdsTypographyVariants, } from "@fluid-topics/ftds-typography";
|
|
12
|
+
import { FtdsIcon, FtdsIcons, FtdsIconVariants, } from "@fluid-topics/ftds-icon";
|
|
13
|
+
import { designSystemStyle } from "./ftds-chip.styles";
|
|
14
|
+
import { DesignSystemSize } from "@fluid-topics/design-system-variables";
|
|
15
|
+
import { FtdsButton } from "@fluid-topics/ftds-button";
|
|
16
|
+
export class RemoveEvent extends CustomEvent {
|
|
17
|
+
constructor() {
|
|
18
|
+
super("remove");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class FtdsChip extends FtdsBase {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.withAction = false;
|
|
25
|
+
this.removable = false;
|
|
26
|
+
this.multiLine = false;
|
|
27
|
+
this.removeButtonLabel = "Remove";
|
|
28
|
+
this.label = "";
|
|
29
|
+
}
|
|
30
|
+
render() {
|
|
31
|
+
const classes = {
|
|
32
|
+
"ftds-chip": true,
|
|
33
|
+
"ftds-chip--with-action": this.removable || this.withAction,
|
|
34
|
+
"ftds-chip--with-icon": !!this.icon,
|
|
35
|
+
"ftds-chip--multi-line": this.multiLine,
|
|
36
|
+
...this.getDesignSystemBaseClasses(),
|
|
37
|
+
};
|
|
38
|
+
return html `
|
|
39
|
+
<div class="${classMap(classes)}"
|
|
40
|
+
aria-label="${this.getLabel()}"
|
|
41
|
+
part="chip">
|
|
42
|
+
${this.renderIcon()}
|
|
43
|
+
<ftds-typography variant="${this.typographyVariant()}" element="span" class="ftds-chip--label" part="label">
|
|
44
|
+
<slot @slotchange=${this.onSlotchange}></slot>
|
|
45
|
+
</ftds-typography>
|
|
46
|
+
${this.renderAction()}
|
|
47
|
+
</div>
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
renderIcon() {
|
|
51
|
+
return this.icon
|
|
52
|
+
? html `
|
|
53
|
+
<div class="ftds-chip--icon-container" part="icon-container">
|
|
54
|
+
<ftds-icon .variant=${this.iconVariant} .icon=${this.icon} part="icon"></ftds-icon>
|
|
55
|
+
</div>
|
|
56
|
+
` : nothing;
|
|
57
|
+
}
|
|
58
|
+
renderAction() {
|
|
59
|
+
if (this.removable) {
|
|
60
|
+
return html `
|
|
61
|
+
<ftds-button round
|
|
62
|
+
class="ftds-chip--remove-button"
|
|
63
|
+
@click=${this.dispatchRemoveEvent}
|
|
64
|
+
icon="${FtdsIcons.XMARK}"
|
|
65
|
+
iconVariant="${FtdsIconVariants.regular}"
|
|
66
|
+
label="${this.removeButtonLabel}"
|
|
67
|
+
family="${DesignSystemFamily.neutral}"
|
|
68
|
+
size="${this.resolveButtonSize()}"
|
|
69
|
+
part="icon-button"
|
|
70
|
+
></ftds-button>
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
return this.withAction ? html `
|
|
74
|
+
<slot name="action"></slot>
|
|
75
|
+
` : nothing;
|
|
76
|
+
}
|
|
77
|
+
resolveButtonSize() {
|
|
78
|
+
switch (this.size) {
|
|
79
|
+
case DesignSystemSize.large:
|
|
80
|
+
return DesignSystemSize.medium;
|
|
81
|
+
default:
|
|
82
|
+
return DesignSystemSize.small;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
getLabel() {
|
|
86
|
+
return this.label || this.getTextContent();
|
|
87
|
+
}
|
|
88
|
+
getTextContent() {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
return (_b = (_a = this.slottedContent) === null || _a === void 0 ? void 0 : _a.assignedNodes().map((n) => n.textContent).join("").trim()) !== null && _b !== void 0 ? _b : "";
|
|
91
|
+
}
|
|
92
|
+
onSlotchange() {
|
|
93
|
+
this.requestUpdate();
|
|
94
|
+
}
|
|
95
|
+
dispatchRemoveEvent() {
|
|
96
|
+
this.dispatchEvent(new RemoveEvent());
|
|
97
|
+
}
|
|
98
|
+
typographyVariant() {
|
|
99
|
+
switch (this.size) {
|
|
100
|
+
case DesignSystemSize.large:
|
|
101
|
+
return FtdsTypographyVariants.body2medium;
|
|
102
|
+
default:
|
|
103
|
+
return FtdsTypographyVariants.caption1medium;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
FtdsChip.elementDefinitions = {
|
|
108
|
+
"ftds-typography": FtdsTypography,
|
|
109
|
+
"ftds-icon": FtdsIcon,
|
|
110
|
+
"ftds-button": FtdsButton,
|
|
111
|
+
};
|
|
112
|
+
FtdsChip.styles = designSystemStyle;
|
|
113
|
+
__decorate([
|
|
114
|
+
property({ type: Boolean })
|
|
115
|
+
], FtdsChip.prototype, "withAction", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
property({ type: Boolean })
|
|
118
|
+
], FtdsChip.prototype, "removable", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
property({ type: Boolean })
|
|
121
|
+
], FtdsChip.prototype, "multiLine", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
property()
|
|
124
|
+
], FtdsChip.prototype, "removeButtonLabel", void 0);
|
|
125
|
+
__decorate([
|
|
126
|
+
property()
|
|
127
|
+
], FtdsChip.prototype, "label", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
property()
|
|
130
|
+
], FtdsChip.prototype, "icon", void 0);
|
|
131
|
+
__decorate([
|
|
132
|
+
property()
|
|
133
|
+
], FtdsChip.prototype, "iconVariant", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
query("ftds-typography slot")
|
|
136
|
+
], FtdsChip.prototype, "slottedContent", void 0);
|