@justeattakeaway/pie-textarea 0.1.0 → 0.3.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 +5 -4
- package/custom-elements.json +83 -3
- package/dist/index.d.ts +28 -0
- package/dist/index.js +45 -9
- package/dist/react.d.ts +29 -1
- package/dist/react.js +11 -6
- package/package.json +1 -1
- package/src/defs-react.ts +2 -7
- package/src/defs.ts +27 -3
- package/src/index.ts +29 -3
- package/src/react.ts +1 -1
- package/src/textarea.scss +21 -0
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
|
|
76
|
-
|
|
77
|
-
|
|
|
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
|
|
|
@@ -88,4 +89,4 @@ In your markup or JSX, you can then use these to set the properties for the `pie
|
|
|
88
89
|
|
|
89
90
|
## Contributing
|
|
90
91
|
|
|
91
|
-
Check out our [contributing guide](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide) for more information on [local development](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#local-development) and how to run specific [component tests](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#testing).
|
|
92
|
+
Check out our [contributing guide](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide) for more information on [local development](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#local-development) and how to run specific [component tests](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#testing).
|
package/custom-elements.json
CHANGED
|
@@ -11,8 +11,43 @@
|
|
|
11
11
|
{
|
|
12
12
|
"kind": "javascript-module",
|
|
13
13
|
"path": "src/defs.js",
|
|
14
|
-
"declarations": [
|
|
15
|
-
|
|
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 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",
|
|
@@ -22,7 +57,52 @@
|
|
|
22
57
|
"kind": "class",
|
|
23
58
|
"description": "",
|
|
24
59
|
"name": "PieTextarea",
|
|
25
|
-
"members": [
|
|
60
|
+
"members": [
|
|
61
|
+
{
|
|
62
|
+
"kind": "field",
|
|
63
|
+
"name": "shadowRootOptions",
|
|
64
|
+
"type": {
|
|
65
|
+
"text": "object"
|
|
66
|
+
},
|
|
67
|
+
"static": true,
|
|
68
|
+
"default": "{ ...LitElement.shadowRootOptions, delegatesFocus: true }"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"kind": "field",
|
|
72
|
+
"name": "disabled",
|
|
73
|
+
"type": {
|
|
74
|
+
"text": "TextareaProps['disabled'] | undefined"
|
|
75
|
+
},
|
|
76
|
+
"privacy": "public",
|
|
77
|
+
"attribute": "disabled",
|
|
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"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"attributes": [
|
|
91
|
+
{
|
|
92
|
+
"name": "disabled",
|
|
93
|
+
"type": {
|
|
94
|
+
"text": "TextareaProps['disabled'] | undefined"
|
|
95
|
+
},
|
|
96
|
+
"fieldName": "disabled"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "size",
|
|
100
|
+
"type": {
|
|
101
|
+
"text": "TextareaProps['size'] | undefined"
|
|
102
|
+
},
|
|
103
|
+
"fieldName": "size"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
26
106
|
"mixins": [
|
|
27
107
|
{
|
|
28
108
|
"name": "RtlMixin",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,48 @@
|
|
|
1
|
+
import { ComponentDefaultPropsGeneric } 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 = ComponentDefaultPropsGeneric<TextareaProps, 'size'>;
|
|
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
|
*/
|
|
10
21
|
export declare class PieTextarea extends PieTextarea_base implements TextareaProps {
|
|
22
|
+
static shadowRootOptions: {
|
|
23
|
+
delegatesFocus: boolean;
|
|
24
|
+
mode: ShadowRootMode;
|
|
25
|
+
slotAssignment?: SlotAssignmentMode | undefined;
|
|
26
|
+
};
|
|
27
|
+
disabled?: TextareaProps['disabled'];
|
|
28
|
+
size?: TextareaProps['size'];
|
|
11
29
|
render(): TemplateResult<1>;
|
|
12
30
|
static styles: CSSResult;
|
|
13
31
|
}
|
|
14
32
|
|
|
15
33
|
declare const PieTextarea_base: GenericConstructor<RTLInterface> & typeof LitElement;
|
|
16
34
|
|
|
35
|
+
export declare const sizes: readonly ["small", "medium", "large"];
|
|
36
|
+
|
|
17
37
|
export declare interface TextareaProps {
|
|
38
|
+
/**
|
|
39
|
+
* Same as the HTML disabled attribute - indicates whether the textarea is disabled.
|
|
40
|
+
*/
|
|
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];
|
|
18
46
|
}
|
|
19
47
|
|
|
20
48
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,50 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { LitElement as l, html as c, unsafeCSS as m } from "lit";
|
|
2
|
+
import { property as n } from "lit/decorators.js";
|
|
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
|
+
`, y = ["small", "medium", "large"], d = {
|
|
7
|
+
size: "medium"
|
|
8
|
+
};
|
|
9
|
+
var b = Object.defineProperty, P = Object.getOwnPropertyDescriptor, x = (s, t, a, i) => {
|
|
10
|
+
for (var e = i > 1 ? void 0 : i ? P(t, a) : t, o = s.length - 1, p; o >= 0; o--)
|
|
11
|
+
(p = s[o]) && (e = (i ? p(t, a, e) : p(e)) || e);
|
|
12
|
+
return i && e && b(t, a, e), e;
|
|
13
|
+
};
|
|
14
|
+
const h = "pie-textarea";
|
|
15
|
+
class r extends u(l) {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments), this.size = d.size;
|
|
18
|
+
}
|
|
6
19
|
render() {
|
|
7
|
-
|
|
20
|
+
const {
|
|
21
|
+
disabled: t,
|
|
22
|
+
size: a
|
|
23
|
+
} = this;
|
|
24
|
+
return c`
|
|
25
|
+
<div
|
|
26
|
+
class="c-textarea"
|
|
27
|
+
data-test-id="pie-textarea-shell"
|
|
28
|
+
data-pie-size=${f(a)}>
|
|
29
|
+
<textarea
|
|
30
|
+
data-test-id="pie-textarea"
|
|
31
|
+
?disabled=${t}
|
|
32
|
+
></textarea>
|
|
33
|
+
</div>`;
|
|
8
34
|
}
|
|
9
35
|
}
|
|
10
|
-
|
|
11
|
-
|
|
36
|
+
r.shadowRootOptions = { ...l.shadowRootOptions, delegatesFocus: !0 };
|
|
37
|
+
r.styles = m(v);
|
|
38
|
+
x([
|
|
39
|
+
n({ type: Boolean, reflect: !0 })
|
|
40
|
+
], r.prototype, "disabled", 2);
|
|
41
|
+
x([
|
|
42
|
+
n({ type: String }),
|
|
43
|
+
g(h, y, d.size)
|
|
44
|
+
], r.prototype, "size", 2);
|
|
45
|
+
z(h, r);
|
|
12
46
|
export {
|
|
13
|
-
|
|
47
|
+
r as PieTextarea,
|
|
48
|
+
d as defaultProps,
|
|
49
|
+
y as sizes
|
|
14
50
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ComponentDefaultPropsGeneric } 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,21 +6,48 @@ 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 = ComponentDefaultPropsGeneric<TextareaProps, 'size'>;
|
|
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
|
/**
|
|
11
22
|
* @tagname pie-textarea
|
|
12
23
|
*/
|
|
13
24
|
declare class PieTextarea_2 extends PieTextarea_base implements TextareaProps {
|
|
25
|
+
static shadowRootOptions: {
|
|
26
|
+
delegatesFocus: boolean;
|
|
27
|
+
mode: ShadowRootMode;
|
|
28
|
+
slotAssignment?: SlotAssignmentMode | undefined;
|
|
29
|
+
};
|
|
30
|
+
disabled?: TextareaProps['disabled'];
|
|
31
|
+
size?: TextareaProps['size'];
|
|
14
32
|
render(): TemplateResult<1>;
|
|
15
33
|
static styles: CSSResult;
|
|
16
34
|
}
|
|
17
35
|
|
|
18
36
|
declare const PieTextarea_base: GenericConstructor<RTLInterface> & typeof LitElement;
|
|
19
37
|
|
|
20
|
-
declare type ReactBaseType = React_2.HTMLAttributes<
|
|
38
|
+
declare type ReactBaseType = React_2.HTMLAttributes<HTMLTextAreaElement>;
|
|
39
|
+
|
|
40
|
+
export declare const sizes: readonly ["small", "medium", "large"];
|
|
21
41
|
|
|
22
42
|
export declare interface TextareaProps {
|
|
43
|
+
/**
|
|
44
|
+
* Same as the HTML disabled attribute - indicates whether the textarea is disabled.
|
|
45
|
+
*/
|
|
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];
|
|
23
51
|
}
|
|
24
52
|
|
|
25
53
|
export { }
|
package/dist/react.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
|
-
import { createComponent as
|
|
3
|
-
import { PieTextarea as
|
|
2
|
+
import { createComponent as t } from "@lit/react";
|
|
3
|
+
import { PieTextarea as a } from "./index.js";
|
|
4
|
+
import { defaultProps as f, sizes as T } from "./index.js";
|
|
4
5
|
import "lit";
|
|
6
|
+
import "lit/decorators.js";
|
|
7
|
+
import "lit/directives/if-defined.js";
|
|
5
8
|
import "@justeattakeaway/pie-webc-core";
|
|
6
|
-
const r =
|
|
9
|
+
const r = t({
|
|
7
10
|
displayName: "PieTextarea",
|
|
8
|
-
elementClass:
|
|
11
|
+
elementClass: a,
|
|
9
12
|
react: e,
|
|
10
13
|
tagName: "pie-textarea",
|
|
11
14
|
events: {}
|
|
12
|
-
}),
|
|
15
|
+
}), c = r;
|
|
13
16
|
export {
|
|
14
|
-
|
|
17
|
+
c as PieTextarea,
|
|
18
|
+
f as defaultProps,
|
|
19
|
+
T as sizes
|
|
15
20
|
};
|
package/package.json
CHANGED
package/src/defs-react.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Use the React IntrinsicElements interface to find how to map standard HTML elements to existing React Interfaces
|
|
5
|
-
* Example: an HTML button maps to `React.ButtonHTMLAttributes<HTMLButtonElement>`
|
|
6
|
-
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0bb210867d16170c4a08d9ce5d132817651a0f80/types/react/index.d.ts#L2829
|
|
7
|
-
*/
|
|
8
|
-
export type ReactBaseType = React.HTMLAttributes<HTMLElement>
|
|
2
|
+
|
|
3
|
+
export type ReactBaseType = React.HTMLAttributes<HTMLTextAreaElement>
|
package/src/defs.ts
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
|
|
2
|
+
|
|
3
|
+
export const sizes = ['small', 'medium', 'large'] as const;
|
|
4
|
+
|
|
5
|
+
export interface TextareaProps {
|
|
6
|
+
/**
|
|
7
|
+
* Same as the HTML disabled attribute - indicates whether the textarea is disabled.
|
|
8
|
+
*/
|
|
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];
|
|
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 = ComponentDefaultPropsGeneric<TextareaProps, 'size'>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Default values for optional properties that have default fallback values in the component.
|
|
24
|
+
*/
|
|
25
|
+
export const defaultProps: DefaultProps = {
|
|
26
|
+
size: 'medium',
|
|
27
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { LitElement, html, unsafeCSS } from 'lit';
|
|
2
|
-
import {
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
|
+
|
|
5
|
+
import { validPropertyValues, RtlMixin, defineCustomElement } from '@justeattakeaway/pie-webc-core';
|
|
3
6
|
|
|
4
7
|
import styles from './textarea.scss?inline';
|
|
5
|
-
import { TextareaProps } from './defs';
|
|
8
|
+
import { TextareaProps, defaultProps, sizes } from './defs';
|
|
6
9
|
|
|
7
10
|
// Valid values available to consumers
|
|
8
11
|
export * from './defs';
|
|
@@ -13,8 +16,31 @@ const componentSelector = 'pie-textarea';
|
|
|
13
16
|
* @tagname pie-textarea
|
|
14
17
|
*/
|
|
15
18
|
export class PieTextarea extends RtlMixin(LitElement) implements TextareaProps {
|
|
19
|
+
static shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
|
|
20
|
+
|
|
21
|
+
@property({ type: Boolean, reflect: true })
|
|
22
|
+
public disabled?: TextareaProps['disabled'];
|
|
23
|
+
|
|
24
|
+
@property({ type: String })
|
|
25
|
+
@validPropertyValues(componentSelector, sizes, defaultProps.size)
|
|
26
|
+
public size?: TextareaProps['size'] = defaultProps.size;
|
|
27
|
+
|
|
16
28
|
render () {
|
|
17
|
-
|
|
29
|
+
const {
|
|
30
|
+
disabled,
|
|
31
|
+
size,
|
|
32
|
+
} = this;
|
|
33
|
+
|
|
34
|
+
return html`
|
|
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>`;
|
|
18
44
|
}
|
|
19
45
|
|
|
20
46
|
// Renders a `CSSResult` generated from SCSS by Vite
|
package/src/react.ts
CHANGED
|
@@ -13,7 +13,7 @@ const PieTextareaReact = createComponent({
|
|
|
13
13
|
events: {},
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
type ReactBaseType = React.HTMLAttributes<
|
|
16
|
+
type ReactBaseType = React.HTMLAttributes<HTMLTextAreaElement>
|
|
17
17
|
|
|
18
18
|
export const PieTextarea = PieTextareaReact as React.ForwardRefExoticComponent<React.PropsWithoutRef<TextareaProps>
|
|
19
19
|
& React.RefAttributes<PieTextareaLit> & ReactBaseType>;
|
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
|
+
|