@justeattakeaway/pie-select 0.7.1 → 0.8.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 +4 -9
- package/dist/index.d.ts +0 -6
- package/dist/index.js +38 -39
- package/dist/react.d.ts +0 -6
- package/package.json +10 -5
- package/src/index.ts +2 -4
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,38 +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.1";
|
|
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 =
|
|
25
|
-
(d = t[a]) && (s = (
|
|
26
|
-
return
|
|
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
32
|
const { value: e } = this._select;
|
|
33
33
|
this._value = e, this._internals.setFormValue(e);
|
|
34
|
-
const
|
|
35
|
-
this.dispatchEvent(
|
|
34
|
+
const i = k(t);
|
|
35
|
+
this.dispatchEvent(i);
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
firstUpdated() {
|
|
@@ -66,8 +66,8 @@ let l = class extends I(w(g)) {
|
|
|
66
66
|
* Resets the value to the default select value.
|
|
67
67
|
*/
|
|
68
68
|
formResetCallback() {
|
|
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 : "",
|
|
70
|
-
this._select.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;
|
|
70
|
+
this._select.value = r || "", this._internals.setFormValue(r || null), this._value = r || "", this.requestUpdate();
|
|
71
71
|
}
|
|
72
72
|
_handleLeadingIconSlotchange() {
|
|
73
73
|
this._hasLeadingIcon = !!this._leadingIconSlot.length;
|
|
@@ -88,12 +88,12 @@ let l = class extends I(w(g)) {
|
|
|
88
88
|
${this.renderChildren(e.options)}
|
|
89
89
|
</optgroup>
|
|
90
90
|
`;
|
|
91
|
-
const
|
|
91
|
+
const r = this._value !== "" ? this._value === e.value : e.selected;
|
|
92
92
|
return p`
|
|
93
93
|
<option
|
|
94
|
-
.value="${
|
|
94
|
+
.value="${T(e.value || "")}"
|
|
95
95
|
?disabled="${e.disabled}"
|
|
96
|
-
?selected="${
|
|
96
|
+
?selected="${r}">
|
|
97
97
|
${e.text}
|
|
98
98
|
</option>
|
|
99
99
|
`;
|
|
@@ -118,21 +118,21 @@ let l = class extends I(w(g)) {
|
|
|
118
118
|
const {
|
|
119
119
|
assistiveText: t,
|
|
120
120
|
disabled: e,
|
|
121
|
-
status:
|
|
122
|
-
size:
|
|
121
|
+
status: i,
|
|
122
|
+
size: r,
|
|
123
123
|
name: s,
|
|
124
124
|
options: a,
|
|
125
125
|
_hasLeadingIcon: d
|
|
126
|
-
} = this,
|
|
126
|
+
} = this, x = {
|
|
127
127
|
"c-select": !0,
|
|
128
|
-
[`c-select--${i}`]: !0,
|
|
129
128
|
[`c-select--${r}`]: !0,
|
|
129
|
+
[`c-select--${i}`]: !0,
|
|
130
130
|
"c-select--withLeadingIcon": d,
|
|
131
131
|
"is-disabled": e
|
|
132
132
|
};
|
|
133
133
|
return p`
|
|
134
134
|
<div
|
|
135
|
-
class="${
|
|
135
|
+
class="${L(x)}"
|
|
136
136
|
data-test-id="pie-select-shell">
|
|
137
137
|
<slot name="leadingIcon" @slotchange=${this._handleLeadingIconSlotchange}></slot>
|
|
138
138
|
<select
|
|
@@ -140,8 +140,8 @@ let l = class extends I(w(g)) {
|
|
|
140
140
|
name="${u(s)}"
|
|
141
141
|
?disabled="${e}"
|
|
142
142
|
aria-describedby="${u(t ? v : void 0)}"
|
|
143
|
-
aria-invalid="${
|
|
144
|
-
aria-errormessage="${u(
|
|
143
|
+
aria-invalid="${i === "error" ? "true" : "false"}"
|
|
144
|
+
aria-errormessage="${u(i === "error" ? v : void 0)}"
|
|
145
145
|
@change=${this._handleChange}>
|
|
146
146
|
${this.renderChildren(a)}
|
|
147
147
|
</select>
|
|
@@ -151,18 +151,17 @@ let l = class extends I(w(g)) {
|
|
|
151
151
|
`;
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
|
-
l.
|
|
155
|
-
l.styles = $(T);
|
|
154
|
+
l.styles = $(A);
|
|
156
155
|
o([
|
|
157
156
|
n({ type: String }),
|
|
158
|
-
|
|
157
|
+
b(m, F, c.size)
|
|
159
158
|
], l.prototype, "size", 2);
|
|
160
159
|
o([
|
|
161
160
|
n({ type: Boolean })
|
|
162
161
|
], l.prototype, "disabled", 2);
|
|
163
162
|
o([
|
|
164
163
|
n({ type: String }),
|
|
165
|
-
|
|
164
|
+
b(m, D, c.status)
|
|
166
165
|
], l.prototype, "status", 2);
|
|
167
166
|
o([
|
|
168
167
|
n({ type: String })
|
|
@@ -174,26 +173,26 @@ o([
|
|
|
174
173
|
n({ type: Array })
|
|
175
174
|
], l.prototype, "options", 2);
|
|
176
175
|
o([
|
|
177
|
-
|
|
176
|
+
f("select")
|
|
178
177
|
], l.prototype, "focusTarget", 2);
|
|
179
178
|
o([
|
|
180
|
-
|
|
179
|
+
f("select")
|
|
181
180
|
], l.prototype, "_select", 2);
|
|
182
181
|
o([
|
|
183
|
-
|
|
182
|
+
C({ slot: "leadingIcon", flatten: !0 })
|
|
184
183
|
], l.prototype, "_leadingIconSlot", 2);
|
|
185
184
|
o([
|
|
186
|
-
|
|
185
|
+
V()
|
|
187
186
|
], l.prototype, "_hasLeadingIcon", 2);
|
|
188
187
|
o([
|
|
189
188
|
n()
|
|
190
189
|
], l.prototype, "value", 1);
|
|
191
190
|
l = o([
|
|
192
|
-
|
|
191
|
+
S("pie-select")
|
|
193
192
|
], l);
|
|
194
193
|
export {
|
|
195
194
|
l as PieSelect,
|
|
196
195
|
c as defaultProps,
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
F as sizes,
|
|
197
|
+
D as statusTypes
|
|
199
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.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/justeattakeaway/pie",
|
|
@@ -19,7 +19,12 @@
|
|
|
19
19
|
"**/*.d.ts"
|
|
20
20
|
],
|
|
21
21
|
"pieMetadata": {
|
|
22
|
-
"componentStatus": "beta"
|
|
22
|
+
"componentStatus": "beta",
|
|
23
|
+
"replaces": {
|
|
24
|
+
"snacks": [
|
|
25
|
+
"Select"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
23
28
|
},
|
|
24
29
|
"scripts": {
|
|
25
30
|
"build": "run -T vite build",
|
|
@@ -40,13 +45,13 @@
|
|
|
40
45
|
"devDependencies": {
|
|
41
46
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
42
47
|
"@justeattakeaway/pie-components-config": "0.21.0",
|
|
43
|
-
"@justeattakeaway/pie-css": "0.
|
|
48
|
+
"@justeattakeaway/pie-css": "0.23.0",
|
|
44
49
|
"@justeattakeaway/pie-monorepo-utils": "0.7.0",
|
|
45
50
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
46
51
|
},
|
|
47
52
|
"dependencies": {
|
|
48
|
-
"@justeattakeaway/pie-assistive-text": "0.
|
|
49
|
-
"@justeattakeaway/pie-webc-core": "
|
|
53
|
+
"@justeattakeaway/pie-assistive-text": "0.11.1",
|
|
54
|
+
"@justeattakeaway/pie-webc-core": "3.0.0"
|
|
50
55
|
},
|
|
51
56
|
"volta": {
|
|
52
57
|
"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;
|