@justeattakeaway/pie-assistive-text 0.5.0 → 0.6.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 CHANGED
@@ -12,11 +12,9 @@
12
12
 
13
13
  1. [Introduction](#pie-assistive-text)
14
14
  2. [Installation](#installation)
15
- 3. [Importing the component](#importing-the-component)
16
- 4. [Peer Dependencies](#peer-dependencies)
17
- 5. [Props](#props)
18
- 6. [Slots](#slots)
19
- 6. [Contributing](#contributing)
15
+ 3. [Documentation](#documentation)
16
+ 4. [Questions](#questions)
17
+ 5. [Contributing](#contributing)
20
18
 
21
19
  ## pie-assistive-text
22
20
 
@@ -26,7 +26,7 @@
26
26
  "type": {
27
27
  "text": "DefaultProps"
28
28
  },
29
- "default": "{\n variant: 'default',\n}"
29
+ "default": "{\n variant: 'default',\n isVisuallyHidden: false,\n}"
30
30
  }
31
31
  ],
32
32
  "exports": [
@@ -66,12 +66,15 @@
66
66
  {
67
67
  "kind": "field",
68
68
  "name": "variant",
69
- "type": {
70
- "text": "AssistiveTextProps['variant'] | undefined"
71
- },
72
69
  "privacy": "public",
73
70
  "attribute": "variant"
74
71
  },
72
+ {
73
+ "kind": "field",
74
+ "name": "isVisuallyHidden",
75
+ "privacy": "public",
76
+ "attribute": "isVisuallyHidden"
77
+ },
75
78
  {
76
79
  "kind": "method",
77
80
  "name": "renderIcon",
@@ -87,10 +90,11 @@
87
90
  "attributes": [
88
91
  {
89
92
  "name": "variant",
90
- "type": {
91
- "text": "AssistiveTextProps['variant'] | undefined"
92
- },
93
93
  "fieldName": "variant"
94
+ },
95
+ {
96
+ "name": "isVisuallyHidden",
97
+ "fieldName": "isVisuallyHidden"
94
98
  }
95
99
  ],
96
100
  "superclass": {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
1
+ import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
2
2
  import type { CSSResult } from 'lit';
3
3
  import type { LitElement } from 'lit';
4
4
  import type { TemplateResult } from 'lit';
@@ -8,9 +8,13 @@ export declare interface AssistiveTextProps {
8
8
  * What variant the assistive text should be such as default, error or success.
9
9
  */
10
10
  variant?: typeof variants[number];
11
+ /**
12
+ * If true, hides the component visually but leaves it accessible for a11y technologies.
13
+ */
14
+ isVisuallyHidden?: boolean;
11
15
  }
12
16
 
13
- export declare type DefaultProps = ComponentDefaultPropsGeneric<AssistiveTextProps, 'variant'>;
17
+ export declare type DefaultProps = ComponentDefaultProps<AssistiveTextProps>;
14
18
 
15
19
  export declare const defaultProps: DefaultProps;
16
20
 
@@ -19,7 +23,8 @@ export declare const defaultProps: DefaultProps;
19
23
  * @slot - Default slot
20
24
  */
21
25
  export declare class PieAssistiveText extends LitElement implements AssistiveTextProps {
22
- variant?: AssistiveTextProps['variant'];
26
+ variant: "default" | "error" | "success";
27
+ isVisuallyHidden: boolean;
23
28
  /**
24
29
  * Renders the assistive-text icon content.
25
30
  * @private
package/dist/index.js CHANGED
@@ -1,55 +1,63 @@
1
- import { unsafeCSS as f, LitElement as d, html as i, nothing as l } from "lit";
2
- import { property as x } from "lit/decorators.js";
3
- import { validPropertyValues as m, defineCustomElement as u } from "@justeattakeaway/pie-webc-core";
4
- import { ifDefined as h } from "lit/directives/if-defined.js";
1
+ import { unsafeCSS as x, LitElement as u, html as r, nothing as d } from "lit";
2
+ import { property as v } from "lit/decorators.js";
3
+ import { validPropertyValues as y, defineCustomElement as h } from "@justeattakeaway/pie-webc-core";
4
+ import { classMap as m } from "lit/directives/class-map.js";
5
5
  import "@justeattakeaway/pie-icons-webc/dist/IconAlertCircle.js";
6
6
  import "@justeattakeaway/pie-icons-webc/dist/IconCheckCircle.js";
7
- const y = `*,*:after,*:before{box-sizing:inherit}.c-assistiveText{--assistive-text-color: var(--dt-color-content-subdued);margin:0;padding-block-start:var(--dt-spacing-a);color:var(--assistive-text-color);font-family:var(--dt-font-body-s-family);font-weight:var(--dt-font-body-s-weight);font-size:calc(var(--dt-font-body-s-size) * 1px);line-height:calc(var(--dt-font-body-s-line-height) * 1px);gap:var(--dt-spacing-b);display:flex;align-items:flex-start;overflow-wrap:anywhere}.c-assistiveText[variant=success]{--assistive-text-color: var(--dt-color-content-positive)}.c-assistiveText[variant=error]{--assistive-text-color: var(--dt-color-content-error)}.c-assistiveText .c-assistiveText-icon{display:inline-flex}
8
- `, g = ["default", "error", "success"], v = {
9
- variant: "default"
7
+ const g = `*,*:after,*:before{box-sizing:inherit}.c-assistiveText{--assistive-text-color: var(--dt-color-content-subdued);margin:0;padding-block-start:var(--dt-spacing-a);color:var(--assistive-text-color);font-family:var(--dt-font-body-s-family);font-weight:var(--dt-font-body-s-weight);font-size:calc(var(--dt-font-body-s-size) * 1px);line-height:calc(var(--dt-font-body-s-line-height) * 1px);gap:var(--dt-spacing-b);display:flex;align-items:flex-start;overflow-wrap:anywhere}.c-assistiveText[variant=success]{--assistive-text-color: var(--dt-color-content-positive)}.c-assistiveText[variant=error]{--assistive-text-color: var(--dt-color-content-error)}.c-assistiveText .c-assistiveText-icon{display:inline-flex}.c-assistiveText--isVisuallyHidden{position:absolute;display:block;height:1px;width:1px;overflow:hidden;padding:1px;white-space:nowrap}
8
+ `, b = ["default", "error", "success"], l = {
9
+ variant: "default",
10
+ isVisuallyHidden: !1
10
11
  };
11
- var b = Object.defineProperty, T = Object.getOwnPropertyDescriptor, w = (r, t, o, s) => {
12
- for (var e = s > 1 ? void 0 : s ? T(t, o) : t, a = r.length - 1, n; a >= 0; a--)
13
- (n = r[a]) && (e = (s ? n(t, o, e) : n(e)) || e);
14
- return s && e && b(t, o, e), e;
12
+ var w = Object.defineProperty, T = Object.getOwnPropertyDescriptor, p = (o, s, e, i) => {
13
+ for (var t = i > 1 ? void 0 : i ? T(s, e) : s, n = o.length - 1, c; n >= 0; n--)
14
+ (c = o[n]) && (t = (i ? c(s, e, t) : c(t)) || t);
15
+ return i && t && w(s, e, t), t;
15
16
  };
16
- const p = "pie-assistive-text";
17
- class c extends d {
17
+ const f = "pie-assistive-text";
18
+ class a extends u {
18
19
  constructor() {
19
- super(...arguments), this.variant = v.variant;
20
+ super(...arguments), this.variant = l.variant, this.isVisuallyHidden = l.isVisuallyHidden;
20
21
  }
21
22
  /**
22
- * Renders the assistive-text icon content.
23
- * @private
24
- */
23
+ * Renders the assistive-text icon content.
24
+ * @private
25
+ */
25
26
  renderIcon() {
26
- const { variant: t } = this;
27
- return i`
28
- ${t === "success" ? i`<icon-check-circle class="c-assistiveText-icon" size="s" ></icon-check-circle>` : l}
29
- ${t === "error" ? i`<icon-alert-circle class="c-assistiveText-icon" size="s"></icon-alert-circle>` : l}`;
27
+ const { variant: s } = this;
28
+ return r`
29
+ ${s === "success" ? r`<icon-check-circle class="c-assistiveText-icon" size="s" ></icon-check-circle>` : d}
30
+ ${s === "error" ? r`<icon-alert-circle class="c-assistiveText-icon" size="s"></icon-alert-circle>` : d}`;
30
31
  }
31
32
  render() {
32
33
  const {
33
- variant: t
34
+ variant: s,
35
+ isVisuallyHidden: e
34
36
  } = this;
35
- return i`
37
+ return r`
36
38
  <p
37
- class="c-assistiveText"
39
+ class="${m({
40
+ "c-assistiveText": !0,
41
+ "c-assistiveText--isVisuallyHidden": e
42
+ })}"
38
43
  data-test-id="pie-assistive-text"
39
- variant=${h(t)}>
44
+ variant=${s}>
40
45
  ${this.renderIcon()}
41
46
  <slot></slot>
42
47
  </p>`;
43
48
  }
44
49
  }
45
- c.styles = f(y);
46
- w([
47
- x({ type: String }),
48
- m(p, g, v.variant)
49
- ], c.prototype, "variant", 2);
50
- u(p, c);
50
+ a.styles = x(g);
51
+ p([
52
+ v({ type: String }),
53
+ y(f, b, l.variant)
54
+ ], a.prototype, "variant", 2);
55
+ p([
56
+ v({ type: Boolean })
57
+ ], a.prototype, "isVisuallyHidden", 2);
58
+ h(f, a);
51
59
  export {
52
- c as PieAssistiveText,
53
- v as defaultProps,
54
- g as variants
60
+ a as PieAssistiveText,
61
+ l as defaultProps,
62
+ b as variants
55
63
  };
package/dist/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
1
+ import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
2
2
  import type { CSSResult } from 'lit';
3
3
  import type { LitElement } from 'lit';
4
4
  import * as React_2 from 'react';
@@ -9,9 +9,13 @@ export declare interface AssistiveTextProps {
9
9
  * What variant the assistive text should be such as default, error or success.
10
10
  */
11
11
  variant?: typeof variants[number];
12
+ /**
13
+ * If true, hides the component visually but leaves it accessible for a11y technologies.
14
+ */
15
+ isVisuallyHidden?: boolean;
12
16
  }
13
17
 
14
- export declare type DefaultProps = ComponentDefaultPropsGeneric<AssistiveTextProps, 'variant'>;
18
+ export declare type DefaultProps = ComponentDefaultProps<AssistiveTextProps>;
15
19
 
16
20
  export declare const defaultProps: DefaultProps;
17
21
 
@@ -22,7 +26,8 @@ export declare const PieAssistiveText: React_2.ForwardRefExoticComponent<Assisti
22
26
  * @slot - Default slot
23
27
  */
24
28
  declare class PieAssistiveText_2 extends LitElement implements AssistiveTextProps {
25
- variant?: AssistiveTextProps['variant'];
29
+ variant: "default" | "error" | "success";
30
+ isVisuallyHidden: boolean;
26
31
  /**
27
32
  * Renders the assistive-text icon content.
28
33
  * @private
package/dist/react.js CHANGED
@@ -5,7 +5,7 @@ import { defaultProps as A, variants as T } from "./index.js";
5
5
  import "lit";
6
6
  import "lit/decorators.js";
7
7
  import "@justeattakeaway/pie-webc-core";
8
- import "lit/directives/if-defined.js";
8
+ import "lit/directives/class-map.js";
9
9
  import "@justeattakeaway/pie-icons-webc/dist/IconAlertCircle.js";
10
10
  import "@justeattakeaway/pie-icons-webc/dist/IconCheckCircle.js";
11
11
  const s = e({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-assistive-text",
3
3
  "description": "PIE Design System Assistive Text built using Web Components",
4
- "version": "0.5.0",
4
+ "version": "0.6.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -40,8 +40,8 @@
40
40
  "cem-plugin-module-file-extensions": "0.0.5"
41
41
  },
42
42
  "dependencies": {
43
- "@justeattakeaway/pie-icons-webc": "0.24.1",
44
- "@justeattakeaway/pie-webc-core": "0.23.0"
43
+ "@justeattakeaway/pie-icons-webc": "0.24.2",
44
+ "@justeattakeaway/pie-webc-core": "0.24.0"
45
45
  },
46
46
  "volta": {
47
47
  "extends": "../../../package.json"
@@ -27,3 +27,7 @@
27
27
  display: inline-flex;
28
28
  }
29
29
  }
30
+
31
+ .c-assistiveText--isVisuallyHidden {
32
+ @include p.visually-hidden;
33
+ }
package/src/defs.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
1
+ import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
2
2
 
3
3
  export const variants = ['default', 'error', 'success'] as const;
4
4
 
@@ -7,10 +7,16 @@ export interface AssistiveTextProps {
7
7
  * What variant the assistive text should be such as default, error or success.
8
8
  */
9
9
  variant?: typeof variants[number];
10
+
11
+ /**
12
+ * If true, hides the component visually but leaves it accessible for a11y technologies.
13
+ */
14
+ isVisuallyHidden?: boolean;
10
15
  }
11
16
 
12
- export type DefaultProps = ComponentDefaultPropsGeneric<AssistiveTextProps, 'variant'>;
17
+ export type DefaultProps = ComponentDefaultProps<AssistiveTextProps>;
13
18
 
14
19
  export const defaultProps: DefaultProps = {
15
20
  variant: 'default',
21
+ isVisuallyHidden: false,
16
22
  };
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
 
5
5
  import { property } from 'lit/decorators.js';
6
6
  import { validPropertyValues, defineCustomElement } from '@justeattakeaway/pie-webc-core';
7
- import { ifDefined } from 'lit/directives/if-defined.js';
7
+ import { classMap } from 'lit/directives/class-map.js';
8
8
  import '@justeattakeaway/pie-icons-webc/dist/IconAlertCircle.js';
9
9
  import '@justeattakeaway/pie-icons-webc/dist/IconCheckCircle.js';
10
10
 
@@ -23,12 +23,15 @@ const componentSelector = 'pie-assistive-text';
23
23
  export class PieAssistiveText extends LitElement implements AssistiveTextProps {
24
24
  @property({ type: String })
25
25
  @validPropertyValues(componentSelector, variants, defaultProps.variant)
26
- public variant?: AssistiveTextProps['variant'] = defaultProps.variant;
26
+ public variant = defaultProps.variant;
27
+
28
+ @property({ type: Boolean })
29
+ public isVisuallyHidden = defaultProps.isVisuallyHidden;
27
30
 
28
31
  /**
29
- * Renders the assistive-text icon content.
30
- * @private
31
- */
32
+ * Renders the assistive-text icon content.
33
+ * @private
34
+ */
32
35
  private renderIcon (): TemplateResult {
33
36
  const { variant } = this;
34
37
  return html`
@@ -39,13 +42,19 @@ export class PieAssistiveText extends LitElement implements AssistiveTextProps {
39
42
  render () {
40
43
  const {
41
44
  variant,
45
+ isVisuallyHidden,
42
46
  } = this;
43
47
 
48
+ const classes = {
49
+ 'c-assistiveText': true,
50
+ 'c-assistiveText--isVisuallyHidden': isVisuallyHidden,
51
+ };
52
+
44
53
  return html`
45
54
  <p
46
- class="c-assistiveText"
55
+ class="${classMap(classes)}"
47
56
  data-test-id="pie-assistive-text"
48
- variant=${ifDefined(variant)}>
57
+ variant=${variant}>
49
58
  ${this.renderIcon()}
50
59
  <slot></slot>
51
60
  </p>`;