@fluid-topics/ftds-input-helper-text 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-input-helper-text.d.ts +13 -0
- package/build/ftds-input-helper-text.js +74 -0
- package/build/ftds-input-helper-text.light.js +674 -0
- package/build/ftds-input-helper-text.min.js +808 -0
- package/build/ftds-input-helper-text.properties.d.ts +5 -0
- package/build/ftds-input-helper-text.properties.js +1 -0
- package/build/ftds-input-helper-text.styles.d.ts +8 -0
- package/build/ftds-input-helper-text.styles.js +48 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +4 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
The design system input helper text component
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm install @fluid-topics/ftds-input-helper-text
|
|
7
|
+
yarn add @fluid-topics/ftds-input-helper-text
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { html } from "lit"
|
|
14
|
+
import "@fluid-topics/ftds-input-helper-text"
|
|
15
|
+
|
|
16
|
+
function render() {
|
|
17
|
+
return html` <ftds-input-helper-text foo="bar"></ftds-input-helper-text> `
|
|
18
|
+
}
|
|
19
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/define.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ElementDefinitionsMap, FtLitElement, Status } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { FtdsInputHelperTextProperties } from "./ftds-input-helper-text.properties";
|
|
3
|
+
export declare class FtdsInputHelperText extends FtLitElement implements FtdsInputHelperTextProperties {
|
|
4
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
5
|
+
static styles: import("lit").CSSResult;
|
|
6
|
+
helperText?: string;
|
|
7
|
+
errorMessages: string[];
|
|
8
|
+
warningMessages: string[];
|
|
9
|
+
ariaHidden: string;
|
|
10
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
protected renderMessage(text: string, status: Status): import("lit-html").TemplateResult<1>;
|
|
12
|
+
private toIconIdentifier;
|
|
13
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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 } from "lit";
|
|
8
|
+
import { property } from "lit/decorators.js";
|
|
9
|
+
import { FtLitElement, Status, } from "@fluid-topics/ft-wc-utils";
|
|
10
|
+
import { styles } from "./ftds-input-helper-text.styles";
|
|
11
|
+
import { repeat } from "lit/directives/repeat.js";
|
|
12
|
+
import { when } from "lit/directives/when.js";
|
|
13
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
14
|
+
import { FtdsTypography, FtdsTypographyVariants, } from "@fluid-topics/ftds-typography";
|
|
15
|
+
import { FtdsIcon, FtdsIcons, FtdsIconVariants, } from "@fluid-topics/ftds-icon";
|
|
16
|
+
export class FtdsInputHelperText extends FtLitElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.errorMessages = [];
|
|
20
|
+
this.warningMessages = [];
|
|
21
|
+
this.ariaHidden = "true";
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
return html `
|
|
25
|
+
<ul class="ftds-input-helper-text">
|
|
26
|
+
${repeat(this.errorMessages, (v) => this.renderMessage(v, Status.error))}
|
|
27
|
+
${repeat(this.warningMessages, (v) => this.renderMessage(v, Status.warning))}
|
|
28
|
+
${when((!this.errorMessages.length && !this.warningMessages.length && this.helperText), () => this.renderMessage(this.helperText, Status.default))}
|
|
29
|
+
</ul>
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
renderMessage(text, status) {
|
|
33
|
+
const optIcon = this.toIconIdentifier(status);
|
|
34
|
+
const classes = {
|
|
35
|
+
"ftds-input-helper-text--list-item": true,
|
|
36
|
+
"hasIcon": Boolean(optIcon),
|
|
37
|
+
[status]: true,
|
|
38
|
+
};
|
|
39
|
+
return html `
|
|
40
|
+
<li class="${classMap(classes)}">
|
|
41
|
+
${when(optIcon, () => html `
|
|
42
|
+
<ftds-icon class="icon" icon="${optIcon}" variant="${FtdsIconVariants.solid}" part="icon"></ftds-icon>`)}
|
|
43
|
+
<ftds-typography part="text" variant="${FtdsTypographyVariants.caption1medium}">${text}</ftds-typography>
|
|
44
|
+
</li>
|
|
45
|
+
`;
|
|
46
|
+
}
|
|
47
|
+
toIconIdentifier(status) {
|
|
48
|
+
switch (status) {
|
|
49
|
+
case Status.error:
|
|
50
|
+
return FtdsIcons.OCTAGON_XMARK;
|
|
51
|
+
case Status.warning:
|
|
52
|
+
return FtdsIcons.TRIANGLE_EXCLAMATION;
|
|
53
|
+
case Status.default:
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
FtdsInputHelperText.elementDefinitions = {
|
|
59
|
+
"ftds-typography": FtdsTypography,
|
|
60
|
+
"ftds-icon": FtdsIcon,
|
|
61
|
+
};
|
|
62
|
+
FtdsInputHelperText.styles = styles;
|
|
63
|
+
__decorate([
|
|
64
|
+
property()
|
|
65
|
+
], FtdsInputHelperText.prototype, "helperText", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
property({ type: Array })
|
|
68
|
+
], FtdsInputHelperText.prototype, "errorMessages", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
property({ type: Array })
|
|
71
|
+
], FtdsInputHelperText.prototype, "warningMessages", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
property({ reflect: true, attribute: "aria-hidden" })
|
|
74
|
+
], FtdsInputHelperText.prototype, "ariaHidden", void 0);
|