@justeattakeaway/pie-textarea 0.2.0 → 0.3.1

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
@@ -72,9 +72,10 @@ import { PieTextarea } from '@justeattakeaway/pie-textarea/dist/react';
72
72
 
73
73
  ## Props
74
74
 
75
- | Property | Type | Default | Description |
76
- |--|--|--|----------------------------------------------------|
77
- | `disabled` | `boolean` | `false` | Indicates whether or not the textarea is disabled. |
75
+ | Property | Type | Default | Description |
76
+ |------------|----------------------------|----------|----------------------------------------------------|
77
+ | `disabled` | `boolean` | `false` | Indicates whether or not the textarea is disabled. |
78
+ | `size` | `small`, `medium`, `large` | `medium` | The size of the textarea field. |
78
79
 
79
80
  In your markup or JSX, you can then use these to set the properties for the `pie-textarea` component:
80
81
 
@@ -11,8 +11,43 @@
11
11
  {
12
12
  "kind": "javascript-module",
13
13
  "path": "src/defs.js",
14
- "declarations": [],
15
- "exports": []
14
+ "declarations": [
15
+ {
16
+ "kind": "variable",
17
+ "name": "sizes",
18
+ "type": {
19
+ "text": "['small', 'medium', 'large']"
20
+ },
21
+ "default": "['small', 'medium', 'large']"
22
+ },
23
+ {
24
+ "kind": "variable",
25
+ "name": "defaultProps",
26
+ "type": {
27
+ "text": "DefaultProps"
28
+ },
29
+ "default": "{\n disabled: false,\n size: 'medium',\n}",
30
+ "description": "Default values for optional properties that have default fallback values in the component."
31
+ }
32
+ ],
33
+ "exports": [
34
+ {
35
+ "kind": "js",
36
+ "name": "sizes",
37
+ "declaration": {
38
+ "name": "sizes",
39
+ "module": "src/defs.js"
40
+ }
41
+ },
42
+ {
43
+ "kind": "js",
44
+ "name": "defaultProps",
45
+ "declaration": {
46
+ "name": "defaultProps",
47
+ "module": "src/defs.js"
48
+ }
49
+ }
50
+ ]
16
51
  },
17
52
  {
18
53
  "kind": "javascript-module",
@@ -41,6 +76,15 @@
41
76
  "privacy": "public",
42
77
  "attribute": "disabled",
43
78
  "reflects": true
79
+ },
80
+ {
81
+ "kind": "field",
82
+ "name": "size",
83
+ "type": {
84
+ "text": "TextareaProps['size'] | undefined"
85
+ },
86
+ "privacy": "public",
87
+ "attribute": "size"
44
88
  }
45
89
  ],
46
90
  "attributes": [
@@ -50,6 +94,13 @@
50
94
  "text": "TextareaProps['disabled'] | undefined"
51
95
  },
52
96
  "fieldName": "disabled"
97
+ },
98
+ {
99
+ "name": "size",
100
+ "type": {
101
+ "text": "TextareaProps['size'] | undefined"
102
+ },
103
+ "fieldName": "size"
53
104
  }
54
105
  ],
55
106
  "mixins": [
package/dist/index.d.ts CHANGED
@@ -1,9 +1,20 @@
1
+ import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
1
2
  import type { CSSResult } from 'lit';
2
3
  import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
3
4
  import type { LitElement } from 'lit';
4
5
  import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
5
6
  import type { TemplateResult } from 'lit-html';
6
7
 
8
+ /**
9
+ * The default values for the `TextareaProps` that are required (i.e. they have a fallback value in the component).
10
+ */
11
+ declare type DefaultProps = ComponentDefaultProps<TextareaProps>;
12
+
13
+ /**
14
+ * Default values for optional properties that have default fallback values in the component.
15
+ */
16
+ export declare const defaultProps: DefaultProps;
17
+
7
18
  /**
8
19
  * @tagname pie-textarea
9
20
  */
@@ -14,17 +25,24 @@ export declare class PieTextarea extends PieTextarea_base implements TextareaPro
14
25
  slotAssignment?: SlotAssignmentMode | undefined;
15
26
  };
16
27
  disabled?: TextareaProps['disabled'];
28
+ size?: TextareaProps['size'];
17
29
  render(): TemplateResult<1>;
18
30
  static styles: CSSResult;
19
31
  }
20
32
 
21
33
  declare const PieTextarea_base: GenericConstructor<RTLInterface> & typeof LitElement;
22
34
 
35
+ export declare const sizes: readonly ["small", "medium", "large"];
36
+
23
37
  export declare interface TextareaProps {
24
38
  /**
25
39
  * Same as the HTML disabled attribute - indicates whether the textarea is disabled.
26
40
  */
27
41
  disabled?: boolean;
42
+ /**
43
+ * The size of the textarea field. Can be `small`, `medium` or `large`. Defaults to `medium`.
44
+ */
45
+ size?: typeof sizes[number];
28
46
  }
29
47
 
30
48
  export { }
package/dist/index.js CHANGED
@@ -1,32 +1,51 @@
1
- import { LitElement as p, html as l, unsafeCSS as f } from "lit";
1
+ import { LitElement as l, html as c, unsafeCSS as m } from "lit";
2
2
  import { property as d } from "lit/decorators.js";
3
- import { RtlMixin as m, defineCustomElement as c } from "@justeattakeaway/pie-webc-core";
4
- const u = `*,*:after,*:before{box-sizing:inherit}
5
- `;
6
- var x = Object.defineProperty, b = Object.getOwnPropertyDescriptor, h = (s, t, a, r) => {
7
- for (var e = r > 1 ? void 0 : r ? b(t, a) : t, i = s.length - 1, n; i >= 0; i--)
8
- (n = s[i]) && (e = (r ? n(t, a, e) : n(e)) || e);
9
- return r && e && x(t, a, e), e;
3
+ import { ifDefined as f } from "lit/directives/if-defined.js";
4
+ import { RtlMixin as u, validPropertyValues as g, defineCustomElement as z } from "@justeattakeaway/pie-webc-core";
5
+ const v = `*,*:after,*:before{box-sizing:inherit}.c-textarea{--textarea-height: 72px;height:var(--textarea-height)}.c-textarea[data-pie-size=large]{--textarea-height: 80px}.c-textarea[data-pie-size=small]{--textarea-height: 64px}.c-textarea textarea{width:100%;height:100%}
6
+ `, b = ["small", "medium", "large"], n = {
7
+ disabled: !1,
8
+ size: "medium"
10
9
  };
11
- const v = "pie-textarea";
12
- class o extends m(p) {
10
+ var y = Object.defineProperty, P = Object.getOwnPropertyDescriptor, x = (i, t, a, s) => {
11
+ for (var e = s > 1 ? void 0 : s ? P(t, a) : t, o = i.length - 1, p; o >= 0; o--)
12
+ (p = i[o]) && (e = (s ? p(t, a, e) : p(e)) || e);
13
+ return s && e && y(t, a, e), e;
14
+ };
15
+ const h = "pie-textarea";
16
+ class r extends u(l) {
17
+ constructor() {
18
+ super(...arguments), this.size = n.size;
19
+ }
13
20
  render() {
14
21
  const {
15
- disabled: t
22
+ disabled: t,
23
+ size: a
16
24
  } = this;
17
- return l`
18
- <textarea
19
- data-test-id="pie-textarea"
20
- ?disabled=${t}
21
- />`;
25
+ return c`
26
+ <div
27
+ class="c-textarea"
28
+ data-test-id="pie-textarea-shell"
29
+ data-pie-size=${f(a)}>
30
+ <textarea
31
+ data-test-id="pie-textarea"
32
+ ?disabled=${t}
33
+ ></textarea>
34
+ </div>`;
22
35
  }
23
36
  }
24
- o.shadowRootOptions = { ...p.shadowRootOptions, delegatesFocus: !0 };
25
- o.styles = f(u);
26
- h([
37
+ r.shadowRootOptions = { ...l.shadowRootOptions, delegatesFocus: !0 };
38
+ r.styles = m(v);
39
+ x([
27
40
  d({ type: Boolean, reflect: !0 })
28
- ], o.prototype, "disabled", 2);
29
- c(v, o);
41
+ ], r.prototype, "disabled", 2);
42
+ x([
43
+ d({ type: String }),
44
+ g(h, b, n.size)
45
+ ], r.prototype, "size", 2);
46
+ z(h, r);
30
47
  export {
31
- o as PieTextarea
48
+ r as PieTextarea,
49
+ n as defaultProps,
50
+ b as sizes
32
51
  };
package/dist/react.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
1
2
  import type { CSSResult } from 'lit';
2
3
  import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
3
4
  import type { LitElement } from 'lit';
@@ -5,6 +6,16 @@ import * as React_2 from 'react';
5
6
  import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
6
7
  import type { TemplateResult } from 'lit-html';
7
8
 
9
+ /**
10
+ * The default values for the `TextareaProps` that are required (i.e. they have a fallback value in the component).
11
+ */
12
+ declare type DefaultProps = ComponentDefaultProps<TextareaProps>;
13
+
14
+ /**
15
+ * Default values for optional properties that have default fallback values in the component.
16
+ */
17
+ export declare const defaultProps: DefaultProps;
18
+
8
19
  export declare const PieTextarea: React_2.ForwardRefExoticComponent<TextareaProps & React_2.RefAttributes<PieTextarea_2> & ReactBaseType>;
9
20
 
10
21
  /**
@@ -17,6 +28,7 @@ declare class PieTextarea_2 extends PieTextarea_base implements TextareaProps {
17
28
  slotAssignment?: SlotAssignmentMode | undefined;
18
29
  };
19
30
  disabled?: TextareaProps['disabled'];
31
+ size?: TextareaProps['size'];
20
32
  render(): TemplateResult<1>;
21
33
  static styles: CSSResult;
22
34
  }
@@ -25,11 +37,17 @@ declare const PieTextarea_base: GenericConstructor<RTLInterface> & typeof LitEle
25
37
 
26
38
  declare type ReactBaseType = React_2.HTMLAttributes<HTMLTextAreaElement>;
27
39
 
40
+ export declare const sizes: readonly ["small", "medium", "large"];
41
+
28
42
  export declare interface TextareaProps {
29
43
  /**
30
44
  * Same as the HTML disabled attribute - indicates whether the textarea is disabled.
31
45
  */
32
46
  disabled?: boolean;
47
+ /**
48
+ * The size of the textarea field. Can be `small`, `medium` or `large`. Defaults to `medium`.
49
+ */
50
+ size?: typeof sizes[number];
33
51
  }
34
52
 
35
53
  export { }
package/dist/react.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import * as e from "react";
2
2
  import { createComponent as t } from "@lit/react";
3
3
  import { PieTextarea as a } from "./index.js";
4
+ import { defaultProps as f, sizes as T } from "./index.js";
4
5
  import "lit";
5
6
  import "lit/decorators.js";
7
+ import "lit/directives/if-defined.js";
6
8
  import "@justeattakeaway/pie-webc-core";
7
9
  const r = t({
8
10
  displayName: "PieTextarea",
@@ -10,7 +12,9 @@ const r = t({
10
12
  react: e,
11
13
  tagName: "pie-textarea",
12
14
  events: {}
13
- }), x = r;
15
+ }), c = r;
14
16
  export {
15
- x as PieTextarea
17
+ c as PieTextarea,
18
+ f as defaultProps,
19
+ T as sizes
16
20
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-textarea",
3
3
  "description": "PIE Design System Textarea built using Web Components",
4
- "version": "0.2.0",
4
+ "version": "0.3.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -40,7 +40,7 @@
40
40
  "cem-plugin-module-file-extensions": "0.0.5"
41
41
  },
42
42
  "dependencies": {
43
- "@justeattakeaway/pie-webc-core": "0.23.0"
43
+ "@justeattakeaway/pie-webc-core": "0.24.0"
44
44
  },
45
45
  "volta": {
46
46
  "extends": "../../../package.json"
package/src/defs.ts CHANGED
@@ -1,6 +1,28 @@
1
+ import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
2
+
3
+ export const sizes = ['small', 'medium', 'large'] as const;
4
+
1
5
  export interface TextareaProps {
2
6
  /**
3
7
  * Same as the HTML disabled attribute - indicates whether the textarea is disabled.
4
8
  */
5
9
  disabled?: boolean;
10
+
11
+ /**
12
+ * The size of the textarea field. Can be `small`, `medium` or `large`. Defaults to `medium`.
13
+ */
14
+ size?: typeof sizes[number];
6
15
  }
16
+
17
+ /**
18
+ * The default values for the `TextareaProps` that are required (i.e. they have a fallback value in the component).
19
+ */
20
+ type DefaultProps = ComponentDefaultProps<TextareaProps>;
21
+
22
+ /**
23
+ * Default values for optional properties that have default fallback values in the component.
24
+ */
25
+ export const defaultProps: DefaultProps = {
26
+ disabled: false,
27
+ size: 'medium',
28
+ };
package/src/index.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { LitElement, html, unsafeCSS } from 'lit';
2
2
  import { property } from 'lit/decorators.js';
3
+ import { ifDefined } from 'lit/directives/if-defined.js';
3
4
 
4
- import { RtlMixin, defineCustomElement } from '@justeattakeaway/pie-webc-core';
5
+ import { validPropertyValues, RtlMixin, defineCustomElement } from '@justeattakeaway/pie-webc-core';
5
6
 
6
7
  import styles from './textarea.scss?inline';
7
- import { TextareaProps } from './defs';
8
+ import { TextareaProps, defaultProps, sizes } from './defs';
8
9
 
9
10
  // Valid values available to consumers
10
11
  export * from './defs';
@@ -20,16 +21,26 @@ export class PieTextarea extends RtlMixin(LitElement) implements TextareaProps {
20
21
  @property({ type: Boolean, reflect: true })
21
22
  public disabled?: TextareaProps['disabled'];
22
23
 
24
+ @property({ type: String })
25
+ @validPropertyValues(componentSelector, sizes, defaultProps.size)
26
+ public size?: TextareaProps['size'] = defaultProps.size;
27
+
23
28
  render () {
24
29
  const {
25
30
  disabled,
31
+ size,
26
32
  } = this;
27
33
 
28
34
  return html`
29
- <textarea
30
- data-test-id="pie-textarea"
31
- ?disabled=${disabled}
32
- />`;
35
+ <div
36
+ class="c-textarea"
37
+ data-test-id="pie-textarea-shell"
38
+ data-pie-size=${ifDefined(size)}>
39
+ <textarea
40
+ data-test-id="pie-textarea"
41
+ ?disabled=${disabled}
42
+ ></textarea>
43
+ </div>`;
33
44
  }
34
45
 
35
46
  // Renders a `CSSResult` generated from SCSS by Vite
package/src/textarea.scss CHANGED
@@ -1 +1,22 @@
1
1
  @use '@justeattakeaway/pie-css/scss' as p;
2
+
3
+ .c-textarea {
4
+ --textarea-height: 72px;
5
+
6
+ height: var(--textarea-height);
7
+
8
+ &[data-pie-size="large"] {
9
+ --textarea-height: 80px;
10
+ }
11
+
12
+ &[data-pie-size="small"] {
13
+ --textarea-height: 64px;
14
+ }
15
+
16
+ textarea {
17
+ width: 100%;
18
+ height: 100%;
19
+ }
20
+ }
21
+
22
+