@justeattakeaway/pie-assistive-text 0.11.35 → 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/README.md CHANGED
@@ -34,14 +34,11 @@ Ideally, you should install the component using the **`@justeattakeaway/pie-webc
34
34
  | Prop | Options | Description | Default |
35
35
  |-------------------|------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|
36
36
  | `variant` | `"default"`, `"error"`, `"success"` | Sets the type of message displayed to one of three potential options: `error`, `success` or `default`. `error` and `success` include an icon and are used for validation messages. `default` provides users with extra context and guidance. | `default` |
37
+ | `message` | `string` | The assistive message text content. | `""` |
37
38
  | `isVisuallyHidden`| `true`, `false` | If true, hides the component visually but leaves it accessible for screen readers. | `false` |
38
39
 
39
-
40
40
  ### Slots
41
-
42
- | Slot | Description |
43
- |----------|--------------------------------------------------------------|
44
- | `default`| The default, unnamed slot is used to pass in text to the component. |
41
+ This component does not have any slots. All content is controlled through properties.
45
42
 
46
43
  ### CSS Variables
47
44
  This component does not expose any CSS variables for style overrides.
@@ -60,8 +57,9 @@ import '@justeattakeaway/pie-webc/components/assistive-text.js'
60
57
  ```
61
58
 
62
59
  ```html
63
- <pie-assistive-text variant="success">
64
- Your request has been submitted.
60
+ <pie-assistive-text
61
+ variant="success"
62
+ message="Your request has been submitted.">
65
63
  </pie-assistive-text>
66
64
 
67
65
  <script type="module" src="/main.js"></script>
@@ -75,8 +73,9 @@ import '@justeattakeaway/pie-webc/components/assistive-text.js';
75
73
  ```
76
74
 
77
75
  ```html
78
- <pie-assistive-text variant="success">
79
- Your request has been submitted.
76
+ <pie-assistive-text
77
+ variant="success"
78
+ message="Your request has been submitted.">
80
79
  </pie-assistive-text>
81
80
  ```
82
81
 
@@ -85,9 +84,10 @@ import '@justeattakeaway/pie-webc/components/assistive-text.js';
85
84
  ```jsx
86
85
  import { PieAssistiveText } from '@justeattakeaway/pie-webc/react/assistive-text.js';
87
86
 
88
- <PieAssistiveText variant="success">
89
- Your request has been submitted.
90
- </PieAssistiveText>
87
+ <PieAssistiveText
88
+ variant="success"
89
+ message="Your request has been submitted."
90
+ />
91
91
  ```
92
92
 
93
93
  ## Questions and Support
@@ -26,7 +26,7 @@
26
26
  "type": {
27
27
  "text": "DefaultProps"
28
28
  },
29
- "default": "{ variant: 'default', isVisuallyHidden: false, }"
29
+ "default": "{ variant: 'default', message: '', isVisuallyHidden: false, }"
30
30
  }
31
31
  ],
32
32
  "exports": [
@@ -56,12 +56,6 @@
56
56
  "kind": "class",
57
57
  "description": "",
58
58
  "name": "PieAssistiveText",
59
- "slots": [
60
- {
61
- "description": "Default slot",
62
- "name": ""
63
- }
64
- ],
65
59
  "members": [
66
60
  {
67
61
  "kind": "field",
@@ -69,6 +63,12 @@
69
63
  "privacy": "public",
70
64
  "attribute": "variant"
71
65
  },
66
+ {
67
+ "kind": "field",
68
+ "name": "message",
69
+ "privacy": "public",
70
+ "attribute": "message"
71
+ },
72
72
  {
73
73
  "kind": "field",
74
74
  "name": "isVisuallyHidden",
@@ -92,6 +92,10 @@
92
92
  "name": "variant",
93
93
  "fieldName": "variant"
94
94
  },
95
+ {
96
+ "name": "message",
97
+ "fieldName": "message"
98
+ },
95
99
  {
96
100
  "name": "isVisuallyHidden",
97
101
  "fieldName": "isVisuallyHidden"
package/dist/index.d.ts CHANGED
@@ -8,6 +8,10 @@ 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
+ * The assistive message text.
13
+ */
14
+ message?: string;
11
15
  /**
12
16
  * If true, hides the component visually but leaves it accessible for screen readers.
13
17
  */
@@ -20,10 +24,10 @@ export declare const defaultProps: DefaultProps;
20
24
 
21
25
  /**
22
26
  * @tagname pie-assistive-text
23
- * @slot - Default slot
24
27
  */
25
28
  export declare class PieAssistiveText extends PieElement implements AssistiveTextProps {
26
29
  variant: "default" | "error" | "success";
30
+ message: string;
27
31
  isVisuallyHidden: boolean;
28
32
  /**
29
33
  * Renders the assistive-text icon content.
package/dist/index.js CHANGED
@@ -1,29 +1,30 @@
1
- import { LitElement as x, unsafeCSS as h, nothing as f, html as a } from "lit";
2
- import { property as u } from "lit/decorators.js";
1
+ import { LitElement as h, unsafeCSS as x, nothing as u, html as o } from "lit";
2
+ import { property as f } from "lit/decorators.js";
3
3
  import { validPropertyValues as y, safeCustomElement as m } from "@justeattakeaway/pie-webc-core";
4
4
  import { classMap as g } 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 c = class c extends x {
7
+ const n = class n extends h {
8
8
  willUpdate() {
9
- this.getAttribute("v") || this.setAttribute("v", c.v);
9
+ this.getAttribute("v") || this.setAttribute("v", n.v);
10
10
  }
11
11
  };
12
- c.v = "0.11.35";
13
- let d = c;
14
- const b = "*,*:after,*:before{box-sizing:inherit}:host{display:block}.c-assistiveText{--assistive-text-color: var(--dt-color-content-subdued-solid);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 .c-assistiveText-icon{display:inline-flex}.c-assistiveText--success{--assistive-text-color: var(--dt-color-content-positive-solid)}.c-assistiveText--error{--assistive-text-color: var(--dt-color-content-error-solid)}.is-visuallyHidden{position:absolute;display:block;height:1px;width:1px;overflow:hidden;padding:1px;white-space:nowrap}", w = ["default", "error", "success"], v = {
12
+ n.v = "1.0.0";
13
+ let v = n;
14
+ const b = "*,*:after,*:before{box-sizing:inherit}:host{display:block}.c-assistiveText{--assistive-text-color: var(--dt-color-content-subdued-solid);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 .c-assistiveText-icon{display:inline-flex}.c-assistiveText--success{--assistive-text-color: var(--dt-color-content-positive-solid)}.c-assistiveText--error{--assistive-text-color: var(--dt-color-content-error-solid)}.is-visuallyHidden{position:absolute;display:block;height:1px;width:1px;border:0;padding:0;margin:-1px;overflow:hidden;white-space:nowrap;clip:rect(0,0,0,0);clip-path:inset(50%)}.is-visuallyHidden *{overflow:hidden}", w = ["default", "error", "success"], l = {
15
15
  variant: "default",
16
+ message: "",
16
17
  isVisuallyHidden: !1
17
18
  };
18
- var T = Object.defineProperty, H = Object.getOwnPropertyDescriptor, p = (t, e, i, o) => {
19
- for (var s = o > 1 ? void 0 : o ? H(e, i) : e, l = t.length - 1, n; l >= 0; l--)
20
- (n = t[l]) && (s = (o ? n(e, i, s) : n(s)) || s);
21
- return o && s && T(e, i, s), s;
19
+ var T = Object.defineProperty, H = Object.getOwnPropertyDescriptor, c = (t, i, a, e) => {
20
+ for (var s = e > 1 ? void 0 : e ? H(i, a) : i, d = t.length - 1, p; d >= 0; d--)
21
+ (p = t[d]) && (s = (e ? p(i, a, s) : p(s)) || s);
22
+ return e && s && T(i, a, s), s;
22
23
  };
23
- const V = "pie-assistive-text";
24
- let r = class extends d {
24
+ const $ = "pie-assistive-text";
25
+ let r = class extends v {
25
26
  constructor() {
26
- super(...arguments), this.variant = v.variant, this.isVisuallyHidden = v.isVisuallyHidden;
27
+ super(...arguments), this.variant = l.variant, this.message = l.message, this.isVisuallyHidden = l.isVisuallyHidden;
27
28
  }
28
29
  /**
29
30
  * Renders the assistive-text icon content.
@@ -31,41 +32,48 @@ let r = class extends d {
31
32
  */
32
33
  renderIcon() {
33
34
  const { variant: t } = this;
34
- return a`
35
- ${t === "success" ? a`<icon-check-circle class="c-assistiveText-icon" size="s" ></icon-check-circle>` : f}
36
- ${t === "error" ? a`<icon-alert-circle class="c-assistiveText-icon" size="s"></icon-alert-circle>` : f}`;
35
+ return o`
36
+ ${t === "success" ? o`<icon-check-circle class="c-assistiveText-icon" size="s" ></icon-check-circle>` : u}
37
+ ${t === "error" ? o`<icon-alert-circle class="c-assistiveText-icon" size="s"></icon-alert-circle>` : u}`;
37
38
  }
38
39
  render() {
39
40
  const {
40
41
  variant: t,
41
- isVisuallyHidden: e
42
- } = this, i = {
42
+ message: i,
43
+ isVisuallyHidden: a
44
+ } = this, e = t === "error", s = {
43
45
  "c-assistiveText": !0,
44
- "is-visuallyHidden": e,
46
+ "is-visuallyHidden": a,
45
47
  [`c-assistiveText--${t}`]: !0
46
48
  };
47
- return a`
49
+ return o`
48
50
  <p
49
- class="${g(i)}"
51
+ class="${g(s)}"
52
+ role="${e ? "alert" : "status"}"
53
+ aria-live="${e ? "assertive" : "polite"}"
54
+ aria-atomic="true"
50
55
  data-test-id="pie-assistive-text">
51
56
  ${this.renderIcon()}
52
- <slot></slot>
57
+ ${i}
53
58
  </p>`;
54
59
  }
55
60
  };
56
- r.styles = h(b);
57
- p([
58
- u({ type: String }),
59
- y(V, w, v.variant)
61
+ r.styles = x(b);
62
+ c([
63
+ f({ type: String }),
64
+ y($, w, l.variant)
60
65
  ], r.prototype, "variant", 2);
61
- p([
62
- u({ type: Boolean })
66
+ c([
67
+ f({ type: String })
68
+ ], r.prototype, "message", 2);
69
+ c([
70
+ f({ type: Boolean })
63
71
  ], r.prototype, "isVisuallyHidden", 2);
64
- r = p([
72
+ r = c([
65
73
  m("pie-assistive-text")
66
74
  ], r);
67
75
  export {
68
76
  r as PieAssistiveText,
69
- v as defaultProps,
77
+ l as defaultProps,
70
78
  w as variants
71
79
  };
package/dist/react.d.ts CHANGED
@@ -9,6 +9,10 @@ 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
+ * The assistive message text.
14
+ */
15
+ message?: string;
12
16
  /**
13
17
  * If true, hides the component visually but leaves it accessible for screen readers.
14
18
  */
@@ -23,10 +27,10 @@ export declare const PieAssistiveText: React_2.ForwardRefExoticComponent<React_2
23
27
 
24
28
  /**
25
29
  * @tagname pie-assistive-text
26
- * @slot - Default slot
27
30
  */
28
31
  declare class PieAssistiveText_2 extends PieElement implements AssistiveTextProps {
29
32
  variant: "default" | "error" | "success";
33
+ message: string;
30
34
  isVisuallyHidden: boolean;
31
35
  /**
32
36
  * Renders the assistive-text icon content.
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.11.35",
4
+ "version": "1.0.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/justeattakeaway/pie",
@@ -19,7 +19,7 @@
19
19
  "**/*.d.ts"
20
20
  ],
21
21
  "pieMetadata": {
22
- "componentStatus": "beta",
22
+ "componentStatus": "stable",
23
23
  "replaces": {
24
24
  "snacks": [
25
25
  "ErrorMessage"
@@ -44,12 +44,12 @@
44
44
  "license": "Apache-2.0",
45
45
  "devDependencies": {
46
46
  "@justeattakeaway/pie-components-config": "0.21.3",
47
- "@justeattakeaway/pie-css": "1.1.2",
48
- "@justeattakeaway/pie-monorepo-utils": "0.9.4"
47
+ "@justeattakeaway/pie-css": "1.2.0",
48
+ "@justeattakeaway/pie-monorepo-utils": "0.9.5"
49
49
  },
50
50
  "dependencies": {
51
- "@justeattakeaway/pie-icons-webc": "1.25.0",
52
- "@justeattakeaway/pie-webc-core": "14.0.2"
51
+ "@justeattakeaway/pie-icons-webc": "1.25.1",
52
+ "@justeattakeaway/pie-webc-core": "15.0.0"
53
53
  },
54
54
  "customElements": "custom-elements.json",
55
55
  "sideEffects": [
package/src/defs.ts CHANGED
@@ -8,6 +8,11 @@ export interface AssistiveTextProps {
8
8
  */
9
9
  variant?: typeof variants[number];
10
10
 
11
+ /**
12
+ * The assistive message text.
13
+ */
14
+ message?: string;
15
+
11
16
  /**
12
17
  * If true, hides the component visually but leaves it accessible for screen readers.
13
18
  */
@@ -18,5 +23,6 @@ export type DefaultProps = ComponentDefaultProps<AssistiveTextProps>;
18
23
 
19
24
  export const defaultProps: DefaultProps = {
20
25
  variant: 'default',
26
+ message: '',
21
27
  isVisuallyHidden: false,
22
28
  };
package/src/index.ts CHANGED
@@ -18,7 +18,6 @@ const componentSelector = 'pie-assistive-text';
18
18
 
19
19
  /**
20
20
  * @tagname pie-assistive-text
21
- * @slot - Default slot
22
21
  */
23
22
  @safeCustomElement('pie-assistive-text')
24
23
  export class PieAssistiveText extends PieElement implements AssistiveTextProps {
@@ -26,6 +25,9 @@ export class PieAssistiveText extends PieElement implements AssistiveTextProps {
26
25
  @validPropertyValues(componentSelector, variants, defaultProps.variant)
27
26
  public variant = defaultProps.variant;
28
27
 
28
+ @property({ type: String })
29
+ public message = defaultProps.message;
30
+
29
31
  @property({ type: Boolean })
30
32
  public isVisuallyHidden = defaultProps.isVisuallyHidden;
31
33
 
@@ -43,8 +45,10 @@ export class PieAssistiveText extends PieElement implements AssistiveTextProps {
43
45
  render () {
44
46
  const {
45
47
  variant,
48
+ message,
46
49
  isVisuallyHidden,
47
50
  } = this;
51
+ const isError = variant === 'error';
48
52
 
49
53
  const classes = {
50
54
  'c-assistiveText': true,
@@ -55,9 +59,12 @@ export class PieAssistiveText extends PieElement implements AssistiveTextProps {
55
59
  return html`
56
60
  <p
57
61
  class="${classMap(classes)}"
62
+ role="${isError ? 'alert' : 'status'}"
63
+ aria-live="${isError ? 'assertive' : 'polite'}"
64
+ aria-atomic="true"
58
65
  data-test-id="pie-assistive-text">
59
66
  ${this.renderIcon()}
60
- <slot></slot>
67
+ ${message}
61
68
  </p>`;
62
69
  }
63
70