@fluid-topics/ftds-notice 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 ADDED
@@ -0,0 +1,19 @@
1
+ The design system notice component
2
+
3
+ ## Install
4
+
5
+ ```shell
6
+ npm install @fluid-topics/ftds-notice
7
+ yarn add @fluid-topics/ftds-notice
8
+ ```
9
+
10
+ ## Usage
11
+
12
+ ```typescript
13
+ import { html } from "lit"
14
+ import "@fluid-topics/ftds-notice"
15
+
16
+ function render() {
17
+ return html` <ftds-notice foo="bar"></ftds-notice> `
18
+ }
19
+ ```
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { customElements } from "@fluid-topics/ft-wc-utils";
2
+ import definitions from "./definitions";
3
+ customElements(definitions);
@@ -0,0 +1,5 @@
1
+ import { FtdsNotice } from "./ftds-notice";
2
+ declare const _default: {
3
+ "ftds-notice": typeof FtdsNotice;
4
+ };
5
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { FtdsNotice } from "./ftds-notice";
2
+ export default {
3
+ "ftds-notice": FtdsNotice,
4
+ };
@@ -0,0 +1,20 @@
1
+ import { FtdsTypographyVariants } from "@fluid-topics/ftds-typography";
2
+ import { FtdsNoticeProperties, FtdsNoticeVariant } from "./ftds-notice.properties";
3
+ import { PropertyValues } from "lit";
4
+ import { FtdsIcons, FtdsIconVariants } from "@fluid-topics/ftds-icon";
5
+ import { DesignSystemFamily, ElementDefinitionsMap, FtdsBase } from "@fluid-topics/ft-wc-utils";
6
+ export declare class FtdsNotice extends FtdsBase implements FtdsNoticeProperties {
7
+ static elementDefinitions: ElementDefinitionsMap;
8
+ static styles: import("lit").CSSResult;
9
+ collapsible: boolean;
10
+ dense: boolean;
11
+ icon?: FtdsIcons;
12
+ iconVariant?: FtdsIconVariants;
13
+ family: DesignSystemFamily;
14
+ variant?: FtdsNoticeVariant;
15
+ private iconByFamily;
16
+ private iconVariantByFamily;
17
+ protected willUpdate(props: PropertyValues): void;
18
+ protected render(): import("lit-html").TemplateResult<1>;
19
+ get typographyVariant(): FtdsTypographyVariants;
20
+ }
@@ -0,0 +1,98 @@
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 { FtdsTypography, FtdsTypographyVariants, } from "@fluid-topics/ftds-typography";
8
+ import { FtdsNoticeVariant, } from "./ftds-notice.properties";
9
+ import { styles } from "./ftds-notice.styles";
10
+ import { property } from "lit/decorators.js";
11
+ import { html, } from "lit";
12
+ import { FtdsIcon, FtdsIcons, FtdsIconVariants, } from "@fluid-topics/ftds-icon";
13
+ import { classMap } from "lit/directives/class-map.js";
14
+ import { DesignSystemFamily, FtdsBase, } from "@fluid-topics/ft-wc-utils";
15
+ export class FtdsNotice extends FtdsBase {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.collapsible = false;
19
+ this.dense = false;
20
+ // Override default value
21
+ this.family = DesignSystemFamily.info;
22
+ this.iconByFamily = {
23
+ [DesignSystemFamily.error]: FtdsIcons.XMARK,
24
+ [DesignSystemFamily.info]: FtdsIcons.CIRCLE_INFO,
25
+ [DesignSystemFamily.success]: FtdsIcons.CIRCLE_CHECK,
26
+ [DesignSystemFamily.warning]: FtdsIcons.TRIANGLE_EXCLAMATION,
27
+ };
28
+ this.iconVariantByFamily = {
29
+ [DesignSystemFamily.error]: FtdsIconVariants.regular,
30
+ [DesignSystemFamily.info]: FtdsIconVariants.regular,
31
+ [DesignSystemFamily.success]: FtdsIconVariants.solid,
32
+ [DesignSystemFamily.warning]: FtdsIconVariants.solid,
33
+ };
34
+ }
35
+ willUpdate(props) {
36
+ super.willUpdate(props);
37
+ if (props.has("variant") && this.variant) {
38
+ switch (this.variant) {
39
+ case FtdsNoticeVariant.info:
40
+ this.family = DesignSystemFamily.info;
41
+ break;
42
+ case FtdsNoticeVariant.success:
43
+ this.family = DesignSystemFamily.success;
44
+ break;
45
+ case FtdsNoticeVariant.warning:
46
+ this.family = DesignSystemFamily.warning;
47
+ break;
48
+ case FtdsNoticeVariant.error:
49
+ this.family = DesignSystemFamily.error;
50
+ break;
51
+ }
52
+ }
53
+ }
54
+ render() {
55
+ const classes = {
56
+ "ftds-notice--collapsible": this.collapsible,
57
+ "ftds-notice--dense": this.dense,
58
+ ...this.getDesignSystemBaseClasses(),
59
+ };
60
+ return html `
61
+ <div class="${classMap(classes)}" part="container">
62
+ <div part="icon">
63
+ <ftds-icon icon="${this.icon || this.iconByFamily[this.family]}"
64
+ variant="${this.iconVariantByFamily || this.iconVariantByFamily[this.family]}"></ftds-icon>
65
+ </div>
66
+ <ftds-typography part="label" variant="${this.typographyVariant}">
67
+ <slot></slot>
68
+ </ftds-typography>
69
+ </div>
70
+ `;
71
+ }
72
+ get typographyVariant() {
73
+ return this.dense ? FtdsTypographyVariants.caption1medium : FtdsTypographyVariants.body2regular;
74
+ }
75
+ }
76
+ FtdsNotice.elementDefinitions = {
77
+ "ftds-icon": FtdsIcon,
78
+ "ftds-typography": FtdsTypography,
79
+ };
80
+ FtdsNotice.styles = styles;
81
+ __decorate([
82
+ property({ type: Boolean })
83
+ ], FtdsNotice.prototype, "collapsible", void 0);
84
+ __decorate([
85
+ property({ type: Boolean })
86
+ ], FtdsNotice.prototype, "dense", void 0);
87
+ __decorate([
88
+ property({ type: String })
89
+ ], FtdsNotice.prototype, "icon", void 0);
90
+ __decorate([
91
+ property({ type: String })
92
+ ], FtdsNotice.prototype, "iconVariant", void 0);
93
+ __decorate([
94
+ property()
95
+ ], FtdsNotice.prototype, "family", void 0);
96
+ __decorate([
97
+ property()
98
+ ], FtdsNotice.prototype, "variant", void 0);