@justeattakeaway/pie-select 0.7.0 → 0.8.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/custom-elements.json +4 -9
- package/dist/index.d.ts +0 -6
- package/dist/index.js +48 -47
- package/dist/react.d.ts +0 -6
- package/package.json +4 -4
- package/src/index.ts +7 -6
package/custom-elements.json
CHANGED
|
@@ -73,15 +73,6 @@
|
|
|
73
73
|
"description": "",
|
|
74
74
|
"name": "PieSelect",
|
|
75
75
|
"members": [
|
|
76
|
-
{
|
|
77
|
-
"kind": "field",
|
|
78
|
-
"name": "shadowRootOptions",
|
|
79
|
-
"type": {
|
|
80
|
-
"text": "object"
|
|
81
|
-
},
|
|
82
|
-
"static": true,
|
|
83
|
-
"default": "{ ...LitElement.shadowRootOptions, delegatesFocus: true }"
|
|
84
|
-
},
|
|
85
76
|
{
|
|
86
77
|
"kind": "field",
|
|
87
78
|
"name": "size",
|
|
@@ -277,6 +268,10 @@
|
|
|
277
268
|
{
|
|
278
269
|
"name": "RtlMixin",
|
|
279
270
|
"package": "@justeattakeaway/pie-webc-core"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"name": "DelegatesFocusMixin",
|
|
274
|
+
"package": "@justeattakeaway/pie-webc-core"
|
|
280
275
|
}
|
|
281
276
|
],
|
|
282
277
|
"superclass": {
|
package/dist/index.d.ts
CHANGED
|
@@ -15,12 +15,6 @@ export declare const defaultProps: DefaultProps;
|
|
|
15
15
|
* @event {CustomEvent} change - when the selected option is changed.
|
|
16
16
|
*/
|
|
17
17
|
export declare class PieSelect extends PieSelect_base implements SelectProps {
|
|
18
|
-
static shadowRootOptions: {
|
|
19
|
-
delegatesFocus: boolean;
|
|
20
|
-
mode: ShadowRootMode;
|
|
21
|
-
serializable?: boolean;
|
|
22
|
-
slotAssignment?: SlotAssignmentMode;
|
|
23
|
-
};
|
|
24
18
|
size: "small" | "medium" | "large";
|
|
25
19
|
disabled: boolean;
|
|
26
20
|
status: "default" | "error";
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { FormControlMixin as I, RtlMixin as w,
|
|
3
|
-
import { property as n, query as
|
|
1
|
+
import { LitElement as y, html as p, nothing as _, unsafeCSS as $ } from "lit";
|
|
2
|
+
import { FormControlMixin as I, RtlMixin as w, DelegatesFocusMixin as z, wrapNativeEvent as k, validPropertyValues as b, safeCustomElement as S } from "@justeattakeaway/pie-webc-core";
|
|
3
|
+
import { property as n, query as f, queryAssignedElements as C, state as V } from "lit/decorators.js";
|
|
4
4
|
import { ifDefined as u } from "lit/directives/if-defined.js";
|
|
5
|
-
import { classMap as
|
|
6
|
-
import { live as
|
|
5
|
+
import { classMap as L } from "lit/directives/class-map.js";
|
|
6
|
+
import { live as T } from "lit/directives/live.js";
|
|
7
7
|
import "@justeattakeaway/pie-icons-webc/dist/IconChevronDown.js";
|
|
8
8
|
import "@justeattakeaway/pie-assistive-text";
|
|
9
|
-
const h = class h extends
|
|
9
|
+
const h = class h extends y {
|
|
10
10
|
willUpdate() {
|
|
11
11
|
this.getAttribute("v") || this.setAttribute("v", h.v);
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
h.v = "0.
|
|
14
|
+
h.v = "0.8.0";
|
|
15
15
|
let g = h;
|
|
16
|
-
const
|
|
16
|
+
const A = "*,*:after,*:before{box-sizing:inherit}:host{display:block}.c-select{--select-padding-block: var(--dt-spacing-c);--select-padding-inline-start: var(--dt-spacing-d);--select-padding-inline-end: 52px;--select-background-color: var(--dt-color-container-default);--select-text-color: var(--dt-color-content-default);--select-border-color: var(--dt-color-border-form);--select-font-size: calc(var(--dt-font-body-l-size) * 1px);--select-line-height: calc(var(--dt-font-body-l-line-height) * 1px);--select-height: 48px;--select-cursor: pointer;position:relative;color:var(--select-text-color);font-size:var(--select-font-size);line-height:var(--select-line-height)}.c-select select{height:var(--select-height);width:100%;border:1px solid var(--select-border-color);border-radius:var(--dt-radius-rounded-c);padding-inline-start:var(--select-padding-inline-start);padding-inline-end:var(--select-padding-inline-end);padding-block-start:var(--select-padding-block);padding-block-end:var(--select-padding-block);background-color:var(--select-background-color);font-family:inherit;font-size:inherit;line-height:inherit;color:inherit;outline:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:var(--select-cursor);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.c-select select:focus-within{box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}.c-select.c-select--small{--select-padding-block: var(--dt-spacing-b);--select-height: 40px}.c-select.c-select--large{--select-padding-block: var(--dt-spacing-d);--select-height: 56px}.c-select.c-select--error{--select-border-color: var(--dt-color-support-error)}.c-select.c-select--withLeadingIcon{--select-padding-inline-start: calc(var(--dt-spacing-h) - var(--dt-spacing-a))}.c-select ::slotted([slot=leadingIcon]),.c-select .c-select-trailingIcon{position:absolute;top:50%;transform:translateY(-50%);pointer-events:none}.c-select:not(.is-disabled) ::slotted([slot=leadingIcon]),.c-select:not(.is-disabled) .c-select-trailingIcon{color:var(--dt-color-content-subdued)}.c-select ::slotted([slot=leadingIcon]){--icon-display-override: block;--icon-size-override: 24px;inset-inline-start:var(--dt-spacing-d)}.c-select .c-select-trailingIcon{inset-inline-end:var(--dt-spacing-d)}@media (hover: hover){.c-select:hover{--select-background-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + calc(-1 * var(--dt-color-hover-01))))}@supports (background-color: color-mix(in srgb,black,white)){.c-select:hover{--select-background-color: color-mix(in srgb, var(--dt-color-hover-01-bg) var(--dt-color-hover-01), var(--dt-color-container-default))}}}.c-select.is-disabled{--select-background-color: var(--dt-color-disabled-01);--select-border-color: var(--dt-color-disabled-01);--select-text-color: var(--dt-color-content-disabled);--select-cursor: auto}", F = ["small", "medium", "large"], D = ["default", "error"], c = {
|
|
17
17
|
size: "medium",
|
|
18
18
|
status: "default",
|
|
19
19
|
disabled: !1,
|
|
20
20
|
options: [],
|
|
21
21
|
value: ""
|
|
22
22
|
};
|
|
23
|
-
var
|
|
24
|
-
for (var s = r > 1 ? void 0 : r ? P(e,
|
|
25
|
-
(d = t[a]) && (s = (r ? d(e,
|
|
26
|
-
return r && s &&
|
|
23
|
+
var O = Object.defineProperty, P = Object.getOwnPropertyDescriptor, o = (t, e, i, r) => {
|
|
24
|
+
for (var s = r > 1 ? void 0 : r ? P(e, i) : e, a = t.length - 1, d; a >= 0; a--)
|
|
25
|
+
(d = t[a]) && (s = (r ? d(e, i, s) : d(s)) || s);
|
|
26
|
+
return r && s && O(e, i, s), s;
|
|
27
27
|
};
|
|
28
|
-
const
|
|
29
|
-
let l = class extends I(w(g)) {
|
|
28
|
+
const m = "pie-select", v = "assistive-text";
|
|
29
|
+
let l = class extends I(w(z(g))) {
|
|
30
30
|
constructor() {
|
|
31
31
|
super(...arguments), this.size = c.size, this.disabled = c.disabled, this.status = c.status, this.options = c.options, this._value = c.value, this._hasLeadingIcon = !1, this._handleChange = (t) => {
|
|
32
|
-
const e =
|
|
33
|
-
this.
|
|
32
|
+
const { value: e } = this._select;
|
|
33
|
+
this._value = e, this._internals.setFormValue(e);
|
|
34
|
+
const i = k(t);
|
|
35
|
+
this.dispatchEvent(i);
|
|
34
36
|
};
|
|
35
37
|
}
|
|
36
38
|
firstUpdated() {
|
|
@@ -64,7 +66,7 @@ let l = class extends I(w(g)) {
|
|
|
64
66
|
* Resets the value to the default select value.
|
|
65
67
|
*/
|
|
66
68
|
formResetCallback() {
|
|
67
|
-
const t = this.options.reduce((s, a) => a.tag === "optgroup" ? s.concat(a.options) : (s.push(a), s), []), e = t.length > 0 ? t[0].value : "",
|
|
69
|
+
const t = this.options.reduce((s, a) => a.tag === "optgroup" ? s.concat(a.options) : (s.push(a), s), []), e = t.length > 0 ? t[0].value : "", i = t.find((s) => s.selected === !0), r = i ? i.value : e;
|
|
68
70
|
this._select.value = r || "", this._internals.setFormValue(r || null), this._value = r || "", this.requestUpdate();
|
|
69
71
|
}
|
|
70
72
|
_handleLeadingIconSlotchange() {
|
|
@@ -89,7 +91,7 @@ let l = class extends I(w(g)) {
|
|
|
89
91
|
const r = this._value !== "" ? this._value === e.value : e.selected;
|
|
90
92
|
return p`
|
|
91
93
|
<option
|
|
92
|
-
.value="${
|
|
94
|
+
.value="${T(e.value || "")}"
|
|
93
95
|
?disabled="${e.disabled}"
|
|
94
96
|
?selected="${r}">
|
|
95
97
|
${e.text}
|
|
@@ -116,21 +118,21 @@ let l = class extends I(w(g)) {
|
|
|
116
118
|
const {
|
|
117
119
|
assistiveText: t,
|
|
118
120
|
disabled: e,
|
|
119
|
-
status:
|
|
121
|
+
status: i,
|
|
120
122
|
size: r,
|
|
121
123
|
name: s,
|
|
122
124
|
options: a,
|
|
123
125
|
_hasLeadingIcon: d
|
|
124
|
-
} = this,
|
|
126
|
+
} = this, x = {
|
|
125
127
|
"c-select": !0,
|
|
126
128
|
[`c-select--${r}`]: !0,
|
|
127
|
-
[`c-select--${
|
|
129
|
+
[`c-select--${i}`]: !0,
|
|
128
130
|
"c-select--withLeadingIcon": d,
|
|
129
131
|
"is-disabled": e
|
|
130
132
|
};
|
|
131
133
|
return p`
|
|
132
134
|
<div
|
|
133
|
-
class="${
|
|
135
|
+
class="${L(x)}"
|
|
134
136
|
data-test-id="pie-select-shell">
|
|
135
137
|
<slot name="leadingIcon" @slotchange=${this._handleLeadingIconSlotchange}></slot>
|
|
136
138
|
<select
|
|
@@ -138,8 +140,8 @@ let l = class extends I(w(g)) {
|
|
|
138
140
|
name="${u(s)}"
|
|
139
141
|
?disabled="${e}"
|
|
140
142
|
aria-describedby="${u(t ? v : void 0)}"
|
|
141
|
-
aria-invalid="${
|
|
142
|
-
aria-errormessage="${u(
|
|
143
|
+
aria-invalid="${i === "error" ? "true" : "false"}"
|
|
144
|
+
aria-errormessage="${u(i === "error" ? v : void 0)}"
|
|
143
145
|
@change=${this._handleChange}>
|
|
144
146
|
${this.renderChildren(a)}
|
|
145
147
|
</select>
|
|
@@ -149,49 +151,48 @@ let l = class extends I(w(g)) {
|
|
|
149
151
|
`;
|
|
150
152
|
}
|
|
151
153
|
};
|
|
152
|
-
l.
|
|
153
|
-
|
|
154
|
-
i([
|
|
154
|
+
l.styles = $(A);
|
|
155
|
+
o([
|
|
155
156
|
n({ type: String }),
|
|
156
|
-
|
|
157
|
+
b(m, F, c.size)
|
|
157
158
|
], l.prototype, "size", 2);
|
|
158
|
-
|
|
159
|
+
o([
|
|
159
160
|
n({ type: Boolean })
|
|
160
161
|
], l.prototype, "disabled", 2);
|
|
161
|
-
|
|
162
|
+
o([
|
|
162
163
|
n({ type: String }),
|
|
163
|
-
|
|
164
|
+
b(m, D, c.status)
|
|
164
165
|
], l.prototype, "status", 2);
|
|
165
|
-
|
|
166
|
+
o([
|
|
166
167
|
n({ type: String })
|
|
167
168
|
], l.prototype, "assistiveText", 2);
|
|
168
|
-
|
|
169
|
+
o([
|
|
169
170
|
n({ type: String, reflect: !0 })
|
|
170
171
|
], l.prototype, "name", 2);
|
|
171
|
-
|
|
172
|
+
o([
|
|
172
173
|
n({ type: Array })
|
|
173
174
|
], l.prototype, "options", 2);
|
|
174
|
-
|
|
175
|
-
|
|
175
|
+
o([
|
|
176
|
+
f("select")
|
|
176
177
|
], l.prototype, "focusTarget", 2);
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
o([
|
|
179
|
+
f("select")
|
|
179
180
|
], l.prototype, "_select", 2);
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
o([
|
|
182
|
+
C({ slot: "leadingIcon", flatten: !0 })
|
|
182
183
|
], l.prototype, "_leadingIconSlot", 2);
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
o([
|
|
185
|
+
V()
|
|
185
186
|
], l.prototype, "_hasLeadingIcon", 2);
|
|
186
|
-
|
|
187
|
+
o([
|
|
187
188
|
n()
|
|
188
189
|
], l.prototype, "value", 1);
|
|
189
|
-
l =
|
|
190
|
-
|
|
190
|
+
l = o([
|
|
191
|
+
S("pie-select")
|
|
191
192
|
], l);
|
|
192
193
|
export {
|
|
193
194
|
l as PieSelect,
|
|
194
195
|
c as defaultProps,
|
|
195
|
-
|
|
196
|
-
|
|
196
|
+
F as sizes,
|
|
197
|
+
D as statusTypes
|
|
197
198
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -18,12 +18,6 @@ export declare const PieSelect: React_2.ForwardRefExoticComponent<React_2.PropsW
|
|
|
18
18
|
* @event {CustomEvent} change - when the selected option is changed.
|
|
19
19
|
*/
|
|
20
20
|
declare class PieSelect_2 extends PieSelect_base implements SelectProps {
|
|
21
|
-
static shadowRootOptions: {
|
|
22
|
-
delegatesFocus: boolean;
|
|
23
|
-
mode: ShadowRootMode;
|
|
24
|
-
serializable?: boolean;
|
|
25
|
-
slotAssignment?: SlotAssignmentMode;
|
|
26
|
-
};
|
|
27
21
|
size: "small" | "medium" | "large";
|
|
28
22
|
disabled: boolean;
|
|
29
23
|
status: "default" | "error";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-select",
|
|
3
3
|
"description": "PIE Design System Select built using Web Components",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/justeattakeaway/pie",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
42
42
|
"@justeattakeaway/pie-components-config": "0.21.0",
|
|
43
|
-
"@justeattakeaway/pie-css": "0.
|
|
43
|
+
"@justeattakeaway/pie-css": "0.22.0",
|
|
44
44
|
"@justeattakeaway/pie-monorepo-utils": "0.7.0",
|
|
45
45
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@justeattakeaway/pie-assistive-text": "0.
|
|
49
|
-
"@justeattakeaway/pie-webc-core": "
|
|
48
|
+
"@justeattakeaway/pie-assistive-text": "0.11.0",
|
|
49
|
+
"@justeattakeaway/pie-webc-core": "2.0.0"
|
|
50
50
|
},
|
|
51
51
|
"volta": {
|
|
52
52
|
"extends": "../../../package.json"
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LitElement,
|
|
3
2
|
html,
|
|
4
3
|
nothing,
|
|
5
4
|
unsafeCSS,
|
|
@@ -9,6 +8,7 @@ import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElem
|
|
|
9
8
|
import {
|
|
10
9
|
FormControlMixin,
|
|
11
10
|
RtlMixin,
|
|
11
|
+
DelegatesFocusMixin,
|
|
12
12
|
safeCustomElement,
|
|
13
13
|
validPropertyValues,
|
|
14
14
|
wrapNativeEvent,
|
|
@@ -45,9 +45,7 @@ const assistiveTextIdValue = 'assistive-text';
|
|
|
45
45
|
* @event {CustomEvent} change - when the selected option is changed.
|
|
46
46
|
*/
|
|
47
47
|
@safeCustomElement('pie-select')
|
|
48
|
-
export class PieSelect extends FormControlMixin(RtlMixin(PieElement)) implements SelectProps {
|
|
49
|
-
static shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
|
|
50
|
-
|
|
48
|
+
export class PieSelect extends FormControlMixin(RtlMixin(DelegatesFocusMixin(PieElement))) implements SelectProps {
|
|
51
49
|
@property({ type: String })
|
|
52
50
|
@validPropertyValues(componentSelector, sizes, defaultProps.size)
|
|
53
51
|
public size = defaultProps.size;
|
|
@@ -159,6 +157,11 @@ export class PieSelect extends FormControlMixin(RtlMixin(PieElement)) implements
|
|
|
159
157
|
* @param event - The change event.
|
|
160
158
|
*/
|
|
161
159
|
private _handleChange = (event: Event) => {
|
|
160
|
+
// Update value state
|
|
161
|
+
const { value } = this._select;
|
|
162
|
+
this._value = value;
|
|
163
|
+
this._internals.setFormValue(value);
|
|
164
|
+
|
|
162
165
|
// We have to create our own change event because the native one
|
|
163
166
|
// does not penetrate the shadow boundary.
|
|
164
167
|
|
|
@@ -166,8 +169,6 @@ export class PieSelect extends FormControlMixin(RtlMixin(PieElement)) implements
|
|
|
166
169
|
// Reference: https://javascript.info/shadow-dom-events#event-composed
|
|
167
170
|
const customChangeEvent = wrapNativeEvent(event);
|
|
168
171
|
this.dispatchEvent(customChangeEvent);
|
|
169
|
-
|
|
170
|
-
this._internals.setFormValue(this._select.value);
|
|
171
172
|
};
|
|
172
173
|
|
|
173
174
|
private _handleLeadingIconSlotchange () {
|