@justeattakeaway/pie-select 0.7.0 → 0.7.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/dist/index.js +30 -28
- package/package.json +1 -1
- package/src/index.ts +5 -2
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const h = class h extends b {
|
|
|
11
11
|
this.getAttribute("v") || this.setAttribute("v", h.v);
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
h.v = "0.7.
|
|
14
|
+
h.v = "0.7.1";
|
|
15
15
|
let g = h;
|
|
16
16
|
const T = "*,*: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}", O = ["small", "medium", "large"], A = ["default", "error"], c = {
|
|
17
17
|
size: "medium",
|
|
@@ -20,17 +20,19 @@ const T = "*,*:after,*:before{box-sizing:inherit}:host{display:block}.c-select{-
|
|
|
20
20
|
options: [],
|
|
21
21
|
value: ""
|
|
22
22
|
};
|
|
23
|
-
var F = Object.defineProperty, P = Object.getOwnPropertyDescriptor,
|
|
24
|
-
for (var s =
|
|
25
|
-
(d = t[a]) && (s = (
|
|
26
|
-
return
|
|
23
|
+
var F = Object.defineProperty, P = Object.getOwnPropertyDescriptor, o = (t, e, r, i) => {
|
|
24
|
+
for (var s = i > 1 ? void 0 : i ? P(e, r) : e, a = t.length - 1, d; a >= 0; a--)
|
|
25
|
+
(d = t[a]) && (s = (i ? d(e, r, s) : d(s)) || s);
|
|
26
|
+
return i && s && F(e, r, s), s;
|
|
27
27
|
};
|
|
28
28
|
const x = "pie-select", v = "assistive-text";
|
|
29
29
|
let l = class extends I(w(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 r = z(t);
|
|
35
|
+
this.dispatchEvent(r);
|
|
34
36
|
};
|
|
35
37
|
}
|
|
36
38
|
firstUpdated() {
|
|
@@ -64,8 +66,8 @@ 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 : "",
|
|
68
|
-
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 : "", r = t.find((s) => s.selected === !0), i = r ? r.value : e;
|
|
70
|
+
this._select.value = i || "", this._internals.setFormValue(i || null), this._value = i || "", this.requestUpdate();
|
|
69
71
|
}
|
|
70
72
|
_handleLeadingIconSlotchange() {
|
|
71
73
|
this._hasLeadingIcon = !!this._leadingIconSlot.length;
|
|
@@ -86,12 +88,12 @@ let l = class extends I(w(g)) {
|
|
|
86
88
|
${this.renderChildren(e.options)}
|
|
87
89
|
</optgroup>
|
|
88
90
|
`;
|
|
89
|
-
const
|
|
91
|
+
const i = this._value !== "" ? this._value === e.value : e.selected;
|
|
90
92
|
return p`
|
|
91
93
|
<option
|
|
92
94
|
.value="${L(e.value || "")}"
|
|
93
95
|
?disabled="${e.disabled}"
|
|
94
|
-
?selected="${
|
|
96
|
+
?selected="${i}">
|
|
95
97
|
${e.text}
|
|
96
98
|
</option>
|
|
97
99
|
`;
|
|
@@ -116,15 +118,15 @@ let l = class extends I(w(g)) {
|
|
|
116
118
|
const {
|
|
117
119
|
assistiveText: t,
|
|
118
120
|
disabled: e,
|
|
119
|
-
status:
|
|
120
|
-
size:
|
|
121
|
+
status: r,
|
|
122
|
+
size: i,
|
|
121
123
|
name: s,
|
|
122
124
|
options: a,
|
|
123
125
|
_hasLeadingIcon: d
|
|
124
126
|
} = this, y = {
|
|
125
127
|
"c-select": !0,
|
|
128
|
+
[`c-select--${i}`]: !0,
|
|
126
129
|
[`c-select--${r}`]: !0,
|
|
127
|
-
[`c-select--${o}`]: !0,
|
|
128
130
|
"c-select--withLeadingIcon": d,
|
|
129
131
|
"is-disabled": e
|
|
130
132
|
};
|
|
@@ -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="${r === "error" ? "true" : "false"}"
|
|
144
|
+
aria-errormessage="${u(r === "error" ? v : void 0)}"
|
|
143
145
|
@change=${this._handleChange}>
|
|
144
146
|
${this.renderChildren(a)}
|
|
145
147
|
</select>
|
|
@@ -151,42 +153,42 @@ let l = class extends I(w(g)) {
|
|
|
151
153
|
};
|
|
152
154
|
l.shadowRootOptions = { ...b.shadowRootOptions, delegatesFocus: !0 };
|
|
153
155
|
l.styles = $(T);
|
|
154
|
-
|
|
156
|
+
o([
|
|
155
157
|
n({ type: String }),
|
|
156
158
|
f(x, O, c.size)
|
|
157
159
|
], l.prototype, "size", 2);
|
|
158
|
-
|
|
160
|
+
o([
|
|
159
161
|
n({ type: Boolean })
|
|
160
162
|
], l.prototype, "disabled", 2);
|
|
161
|
-
|
|
163
|
+
o([
|
|
162
164
|
n({ type: String }),
|
|
163
165
|
f(x, A, c.status)
|
|
164
166
|
], l.prototype, "status", 2);
|
|
165
|
-
|
|
167
|
+
o([
|
|
166
168
|
n({ type: String })
|
|
167
169
|
], l.prototype, "assistiveText", 2);
|
|
168
|
-
|
|
170
|
+
o([
|
|
169
171
|
n({ type: String, reflect: !0 })
|
|
170
172
|
], l.prototype, "name", 2);
|
|
171
|
-
|
|
173
|
+
o([
|
|
172
174
|
n({ type: Array })
|
|
173
175
|
], l.prototype, "options", 2);
|
|
174
|
-
|
|
176
|
+
o([
|
|
175
177
|
m("select")
|
|
176
178
|
], l.prototype, "focusTarget", 2);
|
|
177
|
-
|
|
179
|
+
o([
|
|
178
180
|
m("select")
|
|
179
181
|
], l.prototype, "_select", 2);
|
|
180
|
-
|
|
182
|
+
o([
|
|
181
183
|
S({ slot: "leadingIcon", flatten: !0 })
|
|
182
184
|
], l.prototype, "_leadingIconSlot", 2);
|
|
183
|
-
|
|
185
|
+
o([
|
|
184
186
|
C()
|
|
185
187
|
], l.prototype, "_hasLeadingIcon", 2);
|
|
186
|
-
|
|
188
|
+
o([
|
|
187
189
|
n()
|
|
188
190
|
], l.prototype, "value", 1);
|
|
189
|
-
l =
|
|
191
|
+
l = o([
|
|
190
192
|
k("pie-select")
|
|
191
193
|
], l);
|
|
192
194
|
export {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -159,6 +159,11 @@ export class PieSelect extends FormControlMixin(RtlMixin(PieElement)) implements
|
|
|
159
159
|
* @param event - The change event.
|
|
160
160
|
*/
|
|
161
161
|
private _handleChange = (event: Event) => {
|
|
162
|
+
// Update value state
|
|
163
|
+
const { value } = this._select;
|
|
164
|
+
this._value = value;
|
|
165
|
+
this._internals.setFormValue(value);
|
|
166
|
+
|
|
162
167
|
// We have to create our own change event because the native one
|
|
163
168
|
// does not penetrate the shadow boundary.
|
|
164
169
|
|
|
@@ -166,8 +171,6 @@ export class PieSelect extends FormControlMixin(RtlMixin(PieElement)) implements
|
|
|
166
171
|
// Reference: https://javascript.info/shadow-dom-events#event-composed
|
|
167
172
|
const customChangeEvent = wrapNativeEvent(event);
|
|
168
173
|
this.dispatchEvent(customChangeEvent);
|
|
169
|
-
|
|
170
|
-
this._internals.setFormValue(this._select.value);
|
|
171
174
|
};
|
|
172
175
|
|
|
173
176
|
private _handleLeadingIconSlotchange () {
|