@justeattakeaway/pie-text-input 0.23.6 → 0.24.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/custom-elements.json +30 -54
- package/dist/index.d.ts +22 -22
- package/dist/index.js +241 -247
- package/dist/react.d.ts +22 -22
- package/dist/react.js +9 -15
- package/package.json +5 -5
- package/src/defs-react.ts +1 -1
- package/src/defs.ts +3 -1
- package/src/index.ts +36 -36
- package/src/text-input.scss +9 -9
package/dist/react.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { TemplateResult } from 'lit-html';
|
|
|
12
12
|
/**
|
|
13
13
|
* The default values for the `TextInputProps` that are required (i.e. they have a fallback value in the component).
|
|
14
14
|
*/
|
|
15
|
-
declare type DefaultProps = ComponentDefaultProps<TextInputProps, 'type' | 'value' | 'size' | 'status'>;
|
|
15
|
+
declare type DefaultProps = ComponentDefaultProps<TextInputProps, 'type' | 'value' | 'size' | 'status' | 'disabled' | 'readonly'>;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Default values for optional properties that have default fallback values in the component.
|
|
@@ -38,27 +38,27 @@ declare class PieTextInput_2 extends PieTextInput_base implements TextInputProps
|
|
|
38
38
|
mode: ShadowRootMode;
|
|
39
39
|
slotAssignment?: SlotAssignmentMode | undefined;
|
|
40
40
|
};
|
|
41
|
-
type
|
|
41
|
+
type: "number" | "text" | "password" | "url" | "email" | "tel";
|
|
42
42
|
value: string;
|
|
43
|
-
name
|
|
44
|
-
disabled
|
|
45
|
-
pattern
|
|
46
|
-
minlength
|
|
47
|
-
maxlength
|
|
48
|
-
autocomplete
|
|
49
|
-
placeholder
|
|
50
|
-
autoFocus
|
|
51
|
-
inputmode
|
|
52
|
-
readonly
|
|
53
|
-
defaultValue
|
|
54
|
-
assistiveText
|
|
55
|
-
status
|
|
56
|
-
step
|
|
57
|
-
min
|
|
58
|
-
max
|
|
59
|
-
size
|
|
60
|
-
required
|
|
61
|
-
private input
|
|
43
|
+
name: TextInputProps['name'];
|
|
44
|
+
disabled: boolean;
|
|
45
|
+
pattern: TextInputProps['pattern'];
|
|
46
|
+
minlength: TextInputProps['minlength'];
|
|
47
|
+
maxlength: TextInputProps['maxlength'];
|
|
48
|
+
autocomplete: TextInputProps['autocomplete'];
|
|
49
|
+
placeholder: TextInputProps['placeholder'];
|
|
50
|
+
autoFocus: TextInputProps['autoFocus'];
|
|
51
|
+
inputmode: TextInputProps['inputmode'];
|
|
52
|
+
readonly: boolean;
|
|
53
|
+
defaultValue: TextInputProps['defaultValue'];
|
|
54
|
+
assistiveText: TextInputProps['assistiveText'];
|
|
55
|
+
status: "default" | "error" | "success";
|
|
56
|
+
step: TextInputProps['step'];
|
|
57
|
+
min: TextInputProps['min'];
|
|
58
|
+
max: TextInputProps['max'];
|
|
59
|
+
size: "small" | "medium" | "large";
|
|
60
|
+
required: boolean;
|
|
61
|
+
private input;
|
|
62
62
|
focusTarget: HTMLElement;
|
|
63
63
|
/**
|
|
64
64
|
* (Read-only) returns a ValidityState with the validity states that this element is in.
|
|
@@ -77,7 +77,7 @@ declare class PieTextInput_2 extends PieTextInput_base implements TextInputProps
|
|
|
77
77
|
* Resets the value to the default value.
|
|
78
78
|
*/
|
|
79
79
|
formResetCallback(): void;
|
|
80
|
-
protected firstUpdated(
|
|
80
|
+
protected firstUpdated(): void;
|
|
81
81
|
protected updated(_changedProperties: PropertyValues<this>): void;
|
|
82
82
|
/**
|
|
83
83
|
* Handles data processing in response to the input event. The native input event is left to bubble up.
|
package/dist/react.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import * as t from "react";
|
|
2
2
|
import { createComponent as e } from "@lit/react";
|
|
3
3
|
import { PieTextInput as p } from "./index.js";
|
|
4
|
-
import { defaultProps as
|
|
5
|
-
|
|
6
|
-
import "lit/decorators.js";
|
|
7
|
-
import "lit/directives/if-defined.js";
|
|
8
|
-
import "lit/directives/live.js";
|
|
9
|
-
import "@justeattakeaway/pie-webc-core";
|
|
10
|
-
import "@justeattakeaway/pie-assistive-text";
|
|
11
|
-
const o = e({
|
|
4
|
+
import { defaultProps as m, inputModes as u, sizes as x, statusTypes as c, types as I } from "./index.js";
|
|
5
|
+
const n = e({
|
|
12
6
|
displayName: "PieTextInput",
|
|
13
7
|
elementClass: p,
|
|
14
8
|
react: t,
|
|
@@ -19,12 +13,12 @@ const o = e({
|
|
|
19
13
|
onChange: "change"
|
|
20
14
|
// when the input value is changed.
|
|
21
15
|
}
|
|
22
|
-
}),
|
|
16
|
+
}), a = n;
|
|
23
17
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
a as PieTextInput,
|
|
19
|
+
m as defaultProps,
|
|
20
|
+
u as inputModes,
|
|
21
|
+
x as sizes,
|
|
22
|
+
c as statusTypes,
|
|
23
|
+
I as types
|
|
30
24
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-text-input",
|
|
3
3
|
"description": "PIE Design System Input built using Web Components",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.24.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
39
39
|
"@justeattakeaway/pie-components-config": "0.18.0",
|
|
40
|
-
"@justeattakeaway/pie-css": "0.
|
|
41
|
-
"@justeattakeaway/pie-icons-webc": "0.25.
|
|
40
|
+
"@justeattakeaway/pie-css": "0.13.0",
|
|
41
|
+
"@justeattakeaway/pie-icons-webc": "0.25.2",
|
|
42
42
|
"@justeattakeaway/pie-wrapper-react": "0.14.1",
|
|
43
43
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@justeattakeaway/pie-assistive-text": "0.7.
|
|
47
|
-
"@justeattakeaway/pie-webc-core": "0.24.
|
|
46
|
+
"@justeattakeaway/pie-assistive-text": "0.7.2",
|
|
47
|
+
"@justeattakeaway/pie-webc-core": "0.24.1",
|
|
48
48
|
"element-internals-polyfill": "1.3.11"
|
|
49
49
|
},
|
|
50
50
|
"volta": {
|
package/src/defs-react.ts
CHANGED
package/src/defs.ts
CHANGED
|
@@ -115,7 +115,7 @@ export interface TextInputProps {
|
|
|
115
115
|
/**
|
|
116
116
|
* The default values for the `TextInputProps` that are required (i.e. they have a fallback value in the component).
|
|
117
117
|
*/
|
|
118
|
-
type DefaultProps = ComponentDefaultProps<TextInputProps, 'type' | 'value' | 'size' | 'status'>;
|
|
118
|
+
type DefaultProps = ComponentDefaultProps<TextInputProps, 'type' | 'value' | 'size' | 'status' | 'disabled' | 'readonly'>;
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* Default values for optional properties that have default fallback values in the component.
|
|
@@ -125,4 +125,6 @@ export const defaultProps: DefaultProps = {
|
|
|
125
125
|
value: '',
|
|
126
126
|
size: 'medium',
|
|
127
127
|
status: 'default',
|
|
128
|
+
disabled: false,
|
|
129
|
+
readonly: false,
|
|
128
130
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LitElement, html, unsafeCSS, PropertyValues, nothing,
|
|
2
|
+
LitElement, html, unsafeCSS, type PropertyValues, nothing,
|
|
3
3
|
} from 'lit';
|
|
4
4
|
import { property, query } from 'lit/decorators.js';
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
|
+
import { classMap, type ClassInfo } from 'lit/directives/class-map.js';
|
|
6
7
|
import { live } from 'lit/directives/live.js';
|
|
7
8
|
|
|
8
9
|
import {
|
|
@@ -12,7 +13,7 @@ import '@justeattakeaway/pie-assistive-text';
|
|
|
12
13
|
|
|
13
14
|
import styles from './text-input.scss?inline';
|
|
14
15
|
import {
|
|
15
|
-
types, statusTypes,
|
|
16
|
+
type TextInputProps, types, statusTypes, defaultProps,
|
|
16
17
|
} from './defs';
|
|
17
18
|
import 'element-internals-polyfill';
|
|
18
19
|
|
|
@@ -36,68 +37,68 @@ export class PieTextInput extends FormControlMixin(RtlMixin(LitElement)) impleme
|
|
|
36
37
|
|
|
37
38
|
@property({ type: String, reflect: true })
|
|
38
39
|
@validPropertyValues(componentSelector, types, defaultProps.type)
|
|
39
|
-
public type
|
|
40
|
+
public type = defaultProps.type;
|
|
40
41
|
|
|
41
42
|
@property({ type: String })
|
|
42
43
|
public value = defaultProps.value;
|
|
43
44
|
|
|
44
45
|
@property({ type: String })
|
|
45
|
-
public name
|
|
46
|
+
public name: TextInputProps['name'];
|
|
46
47
|
|
|
47
48
|
@property({ type: Boolean, reflect: true })
|
|
48
|
-
public disabled
|
|
49
|
+
public disabled = defaultProps.disabled;
|
|
49
50
|
|
|
50
51
|
@property({ type: String })
|
|
51
|
-
public pattern
|
|
52
|
+
public pattern: TextInputProps['pattern'];
|
|
52
53
|
|
|
53
54
|
@property({ type: Number })
|
|
54
|
-
public minlength
|
|
55
|
+
public minlength: TextInputProps['minlength'];
|
|
55
56
|
|
|
56
57
|
@property({ type: Number })
|
|
57
|
-
public maxlength
|
|
58
|
+
public maxlength: TextInputProps['maxlength'];
|
|
58
59
|
|
|
59
60
|
@property({ type: String })
|
|
60
|
-
public autocomplete
|
|
61
|
+
public autocomplete: TextInputProps['autocomplete'];
|
|
61
62
|
|
|
62
63
|
@property({ type: String })
|
|
63
|
-
public placeholder
|
|
64
|
+
public placeholder: TextInputProps['placeholder'];
|
|
64
65
|
|
|
65
66
|
@property({ type: Boolean })
|
|
66
|
-
public autoFocus
|
|
67
|
+
public autoFocus: TextInputProps['autoFocus'];
|
|
67
68
|
|
|
68
69
|
@property({ type: String })
|
|
69
|
-
public inputmode
|
|
70
|
+
public inputmode: TextInputProps['inputmode'];
|
|
70
71
|
|
|
71
72
|
@property({ type: Boolean })
|
|
72
|
-
public readonly
|
|
73
|
+
public readonly = defaultProps.readonly;
|
|
73
74
|
|
|
74
75
|
@property({ type: String })
|
|
75
|
-
public defaultValue
|
|
76
|
+
public defaultValue: TextInputProps['defaultValue'];
|
|
76
77
|
|
|
77
78
|
@property({ type: String })
|
|
78
|
-
public assistiveText
|
|
79
|
+
public assistiveText: TextInputProps['assistiveText'];
|
|
79
80
|
|
|
80
81
|
@property({ type: String })
|
|
81
82
|
@validPropertyValues(componentSelector, statusTypes, defaultProps.status)
|
|
82
|
-
public status
|
|
83
|
+
public status = defaultProps.status;
|
|
83
84
|
|
|
84
85
|
@property({ type: Number })
|
|
85
|
-
public step
|
|
86
|
+
public step: TextInputProps['step'];
|
|
86
87
|
|
|
87
88
|
@property({ type: Number })
|
|
88
|
-
public min
|
|
89
|
+
public min: TextInputProps['min'];
|
|
89
90
|
|
|
90
91
|
@property({ type: Number })
|
|
91
|
-
public max
|
|
92
|
+
public max: TextInputProps['max'];
|
|
92
93
|
|
|
93
94
|
@property({ type: String })
|
|
94
|
-
public size
|
|
95
|
+
public size = defaultProps.size;
|
|
95
96
|
|
|
96
97
|
@property({ type: Boolean })
|
|
97
|
-
public required
|
|
98
|
+
public required = false;
|
|
98
99
|
|
|
99
100
|
@query('input')
|
|
100
|
-
private input
|
|
101
|
+
private input!: HTMLInputElement;
|
|
101
102
|
|
|
102
103
|
@query('input')
|
|
103
104
|
public focusTarget!: HTMLElement;
|
|
@@ -107,7 +108,7 @@ export class PieTextInput extends FormControlMixin(RtlMixin(LitElement)) impleme
|
|
|
107
108
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
|
|
108
109
|
*/
|
|
109
110
|
public get validity (): ValidityState {
|
|
110
|
-
return
|
|
111
|
+
return this.input.validity;
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
/**
|
|
@@ -129,21 +130,16 @@ export class PieTextInput extends FormControlMixin(RtlMixin(LitElement)) impleme
|
|
|
129
130
|
|
|
130
131
|
// This ensures the input value is updated when the form is reset.
|
|
131
132
|
// Otherwise there is a bug where values like 'e1212' for number inputs do not correctly reset.
|
|
132
|
-
|
|
133
|
-
this.input.value = this.value;
|
|
134
|
-
}
|
|
133
|
+
this.input.value = this.value;
|
|
135
134
|
|
|
136
135
|
this._internals.setFormValue(this.value);
|
|
137
136
|
}
|
|
138
137
|
|
|
139
|
-
protected firstUpdated (
|
|
140
|
-
super.firstUpdated(_changedProperties);
|
|
138
|
+
protected firstUpdated (): void {
|
|
141
139
|
this._internals.setFormValue(this.value);
|
|
142
140
|
}
|
|
143
141
|
|
|
144
142
|
protected updated (_changedProperties: PropertyValues<this>): void {
|
|
145
|
-
super.updated(_changedProperties);
|
|
146
|
-
|
|
147
143
|
if (_changedProperties.has('value')) {
|
|
148
144
|
this._internals.setFormValue(this.value);
|
|
149
145
|
}
|
|
@@ -195,14 +191,18 @@ export class PieTextInput extends FormControlMixin(RtlMixin(LitElement)) impleme
|
|
|
195
191
|
required,
|
|
196
192
|
} = this;
|
|
197
193
|
|
|
194
|
+
const classes : ClassInfo = {
|
|
195
|
+
'c-textInput': true,
|
|
196
|
+
[`c-textInput--${size}`]: true,
|
|
197
|
+
[`c-textInput--${status}`]: true,
|
|
198
|
+
'c-textInput--disabled': disabled,
|
|
199
|
+
'c-textInput--readonly': readonly,
|
|
200
|
+
};
|
|
201
|
+
|
|
198
202
|
return html`
|
|
199
203
|
<div
|
|
200
|
-
class="
|
|
201
|
-
data-test-id="pie-text-input-shell"
|
|
202
|
-
data-pie-size=${ifDefined(size)}
|
|
203
|
-
data-pie-status=${ifDefined(status)}
|
|
204
|
-
?data-pie-disabled=${live(disabled)}
|
|
205
|
-
?data-pie-readonly=${readonly}>
|
|
204
|
+
class="${classMap(classes)}"
|
|
205
|
+
data-test-id="pie-text-input-shell">
|
|
206
206
|
<!-- The reason for separate slots for icons and text is that we cannot programmatically be aware of the
|
|
207
207
|
HTML used inside of the slot without breaking SSR in consuming applications (icons need to use different colours than text content)
|
|
208
208
|
Therefore, we provide two slots and advise consumers do not attempt to use both leading/trailing at the same time
|
package/src/text-input.scss
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
--input-gap: var(--dt-spacing-d);
|
|
7
7
|
--input-text-color: var(--dt-color-content-default);
|
|
8
8
|
--input-text-color-leading-trailing-content: var(--dt-color-content-default);
|
|
9
|
-
--input-text-color-placeholder: var(--dt-color-content-
|
|
9
|
+
--input-text-color-placeholder: var(--dt-color-content-placeholder);
|
|
10
10
|
--input-border-color: var(--dt-color-interactive-form);
|
|
11
11
|
--input-container-color: var(--dt-color-container-default);
|
|
12
12
|
--input-radius: var(--dt-radius-rounded-c);
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
color: var(--input-text-color-leading-trailing-content); // Applies to the leadingText and trailingText slot content
|
|
35
35
|
cursor: var(--input-cursor);
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
&.c-textInput--large {
|
|
38
38
|
--input-padding-block: var(--dt-spacing-d);
|
|
39
39
|
--input-height: 56px;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
&.c-textInput--small {
|
|
43
43
|
--input-padding-block: var(--dt-spacing-b);
|
|
44
44
|
--input-height: 40px;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
&.c-textInput--error {
|
|
48
48
|
--input-border-color: var(--dt-color-support-error);
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
&:not(
|
|
76
|
-
&:not(
|
|
75
|
+
&:not(.c-textInput--disabled) ::slotted([slot="leadingIcon"]),
|
|
76
|
+
&:not(.c-textInput--disabled) ::slotted([slot="trailingIcon"]) {
|
|
77
77
|
color: var(--dt-color-content-subdued);
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -83,14 +83,14 @@
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
&.c-textInput--readonly {
|
|
87
87
|
--input-container-color: var(--dt-color-container-subtle);
|
|
88
88
|
--input-border-color: var(--dt-color-interactive-form);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// Ensure that if an input is readonly and disabled, the disabled styles take precedence
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
&.c-textInput--disabled.c-textInput--readonly,
|
|
93
|
+
&.c-textInput--disabled {
|
|
94
94
|
--input-container-color: var(--dt-color-disabled-01);
|
|
95
95
|
--input-border-color: var(--dt-color-disabled-01);
|
|
96
96
|
--input-text-color: var(--dt-color-content-disabled);
|