67 lines
1.8 KiB
JavaScript
67 lines
1.8 KiB
JavaScript
import { _ as i, n as l } from "./class-map-CwiboTfb.mjs";
|
|
import { i as a } from "./element-internals-3IY9gE4L.mjs";
|
|
/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
const o = Symbol("getFormValue"), n = Symbol("getFormState");
|
|
function h(u) {
|
|
class r extends u {
|
|
get form() {
|
|
return this[a].form;
|
|
}
|
|
get labels() {
|
|
return this[a].labels;
|
|
}
|
|
// Use @property for the `name` and `disabled` properties to add them to the
|
|
// `observedAttributes` array and trigger `attributeChangedCallback()`.
|
|
//
|
|
// We don't use Lit's default getter/setter (`noAccessor: true`) because
|
|
// the attributes need to be updated synchronously to work with synchronous
|
|
// form APIs, and Lit updates attributes async by default.
|
|
get name() {
|
|
return this.getAttribute("name") ?? "";
|
|
}
|
|
set name(t) {
|
|
this.setAttribute("name", t);
|
|
}
|
|
get disabled() {
|
|
return this.hasAttribute("disabled");
|
|
}
|
|
set disabled(t) {
|
|
this.toggleAttribute("disabled", t);
|
|
}
|
|
attributeChangedCallback(t, e, s) {
|
|
if (t === "name" || t === "disabled") {
|
|
const d = t === "disabled" ? e !== null : e;
|
|
this.requestUpdate(t, d);
|
|
return;
|
|
}
|
|
super.attributeChangedCallback(t, e, s);
|
|
}
|
|
requestUpdate(t, e, s) {
|
|
super.requestUpdate(t, e, s), this[a].setFormValue(this[o](), this[n]());
|
|
}
|
|
[o]() {
|
|
throw new Error("Implement [getFormValue]");
|
|
}
|
|
[n]() {
|
|
return this[o]();
|
|
}
|
|
formDisabledCallback(t) {
|
|
this.disabled = t;
|
|
}
|
|
}
|
|
return r.formAssociated = !0, i([
|
|
l({ noAccessor: !0 })
|
|
], r.prototype, "name", null), i([
|
|
l({ type: Boolean, noAccessor: !0 })
|
|
], r.prototype, "disabled", null), r;
|
|
}
|
|
export {
|
|
n as a,
|
|
o as g,
|
|
h as m
|
|
};
|