@bake-js/-o-id-ui
Version:
1,299 lines (1,283 loc) • 41.6 kB
JavaScript
var Rt = (t) => {
throw TypeError(t);
};
var Vt = (t, e, r) => e.has(t) || Rt("Cannot " + r);
var ht = (t, e, r) => (Vt(t, e, "read from private field"), r ? r.call(t) : e.get(t)), dt = (t, e, r) => e.has(t) ? Rt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), L = (t, e, r, i) => (Vt(t, e, "write to private field"), i ? i.call(t, r) : e.set(t, r), r);
const f = (t) => ({
/**
* Define o alvo do interceptor.
*
* @param {Object} target - O alvo do interceptor, geralmente a classe ou objeto.
* @returns {Object} Um objeto com o método `then` para adicionar lógica ao método interceptado.
*
* @example
* interceptor.in(myObject);
*/
in: (e) => ({
/**
* Adiciona a lógica a ser executada após o método original.
*
* @param {Function} substituent - A função que será executada após o método original.
*
* @example
* interceptor.then(function() {
* console.log('Lógica adicional executada.');
* });
*/
then: (r) => {
const i = e[t] ?? (() => {
});
Reflect.defineProperty(e, t, {
async value(...a) {
return await Reflect.apply(i, this, a), await Reflect.apply(r, this, a), this;
},
writable: !0
// Permite que o método seja sobrescrito
});
}
})
}), V = (t) => async function(...e) {
await this[t](...e);
}, sr = "attributeChangedCallback", or = "connectedCallback", lr = "disconnectedCallback", hr = "formAssociatedCallback", dr = "formResetCallback", zt = "observedAttributes", v = (t, ...e) => (r, i, a) => {
const n = r.constructor[zt] ?? [];
Object.assign(r.constructor, {
[zt]: [...n, t]
}), f(sr).in(r).then(function(s, u, S) {
if (s === t && u !== S) {
const M = e.reduce(
(T, W) => W(T),
S
);
a.set && (this[i] = M), a.value && this[i](M, u);
}
});
}, P = (t, e) => {
f(or).in(t).then(V(e));
}, y = (t, e) => (r) => {
customElements.get(t) ?? customElements.define(t, r, e);
}, E = (t, e) => f(lr).in(t).then(V(e)), pr = (t, e) => f(hr).in(t).then(V(e)), cr = (t, e) => f(dr).in(t).then(V(e));
var ur = Object.defineProperty, jt = (t) => {
throw TypeError(t);
}, vr = (t, e, r) => e in t ? ur(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, _r = (t, e, r) => vr(t, typeof e != "symbol" ? e + "" : e, r), mr = (t, e, r) => e.has(t) || jt("Cannot " + r), pt = (t, e, r) => (mr(t, e, "read from private field"), e.get(t)), fr = (t, e, r) => e.has(t) ? jt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r);
const Ot = "attributeChangedCallback", kt = "disconnectedCallback", Gt = "dispatchEvent", Mt = Symbol.for("echoConnectedCallback"), vt = Symbol.for("echoDisconnectedCallback"), yr = "id", qt = "observedAttributes", Dt = "on";
class $r extends HTMLElement {
/**
* Define quais atributos devem ser observados.
*
* @returns {string[]} A lista de nomes dos atributos observados.
*
* @description
* O `Source` observa o atributo definido como `on` para gerenciar a conexão e desconexão de eventos
* de acordo com o protocolo do Echo.
*/
static get [qt]() {
return [Dt];
}
/**
* Este método é chamado sempre que um dos atributos definidos em `observedAttributes` é alterado.
* Ele garante que o elemento pai esteja definido e chama os callbacks de conexão e desconexão no elemento pai,
* se eles existirem.
*
* @param {string} name - O nome do atributo que foi alterado.
* @param {string|null} oldValue - O valor antigo do atributo antes da alteração.
* @param {string|null} newValue - O novo valor do atributo após a alteração.
* @returns {Promise<Source>} Uma promessa que resolve a instância atual após a execução do callback.
*
* @description
* O `attributeChangedCallback` gerencia a resposta do elemento às mudanças nos atributos observados, como
* a desconexão e reconexão de protocolos de eventos no Echo, garantindo que o comportamento do elemento
* seja sempre consistente com as mudanças no DOM.
*/
async [Ot](e, r, i) {
var a, n, s, u;
return await customElements.whenDefined(this.parentElement.localName), (n = (a = this.parentElement) == null ? void 0 : a[vt]) == null || n.call(a, r), (u = (s = this.parentElement) == null ? void 0 : s[Mt]) == null || u.call(s, i), this;
}
}
customElements.get("o-id-echo-source") ?? customElements.define("o-id-echo-source", $r);
const gr = {
/**
* Acessa uma propriedade aninhada de um objeto com base em um caminho de string.
*
* @param {Object} object- O objeto alvo de onde a propriedade será extraída.
* @param {string} propertyPath - O caminho da propriedade no formato de string. Pode incluir notação de ponto ou colchetes.
* @returns {*} O valor da propriedade acessada ou `undefined` se o caminho não for válido.
*
* @description
* A função `prop` permite acessar propriedades aninhadas de um objeto de forma dinâmica, com base
* em um caminho de string. O caminho pode ser composto por notação de ponto (por exemplo, `address.city`)
* ou colchetes (por exemplo, `address['city']`). Caso o caminho seja inválido ou a propriedade não exista,
* `undefined` será retornado.
*
* @example
* const user = {
* name: 'Alice',
* address: {
* city: 'Wonderland',
* },
* };
*
* const cityName = filters.prop(user, 'address.city');
* console.log(cityName); // 'Wonderland'
*
* const invalidProp = filters.prop(user, 'address.country');
* console.log(invalidProp); // undefined
*/
prop: (t, e) => {
try {
return new Function(
"data",
`return data${/(^\[$)/.test(e) ? "" : "."}${e}`
)(t);
} catch {
return;
}
}
}, It = new EventTarget(), $ = (t) => {
var e, r, i;
return i = class extends t {
constructor() {
super(...arguments), fr(this, r, {});
}
/**
* Callback que é chamado quando um atributo observado é alterado.
*
* @param {string} name - Nome do atributo que foi alterado.
* @param {string|null} oldValue - O valor anterior do atributo.
* @param {string|null} newValue - O novo valor do atributo.
* @returns {this} - A instância do elemento.
*
* @description
* Este método manipula mudanças em atributos observados, especialmente o atributo `on`.
* Quando o atributo `on` é alterado, o componente se desconecta do protocolo antigo e se
* conecta ao novo protocolo.
*
* @example
* const element = document.querySelector('my-component');
* element.setAttribute('on', 'sender/message:method/handleMessage');
*/
[(e = qt, Ot)](a, n, s) {
var u;
return (u = super[Ot]) == null || u.call(this, a, n, s), a === Dt && (this[vt](n), this[Mt](s)), this;
}
/**
* Callback que é chamado quando o elemento é desconectado do DOM.
* Aborta todos os controladores de eventos registrados.
*
* @returns {this} - A instância do elemento.
*
* @description
* Este método é invocado quando o componente é removido do DOM. Ele garante que todos os
* eventos associados ao componente sejam corretamente abortados, prevenindo vazamento de
* memória ou comportamento indesejado.
*
* @example
* const element = document.querySelector('my-component');
* document.body.removeChild(element); // Dispara o disconnectedCallback.
*/
[kt]() {
var a;
return (a = super[kt]) == null || a.call(this), Object.keys(pt(this, r)).forEach(
(n) => this[vt](n)
), this;
}
/**
* Despacha um evento personalizado e notifica o Event Bus.
*
* @param {CustomEvent} event - O evento a ser despachado.
*
* @description
* Este método estende o comportamento padrão de `dispatchEvent` para incluir a notificação
* ao Event Bus, permitindo que outros componentes escutem e respondam ao evento.
*
* @example
* const event = new CustomEvent('messageSent', { detail: 'Hello World' });
* element.dispatchEvent(event);
*/
[Gt](a) {
var n;
(n = super[Gt]) == null || n.call(this, a);
const s = this.getAttribute(yr) ?? this.localName;
It.dispatchEvent(
new CustomEvent(`${s}/${a.type}`, {
detail: a.detail
})
);
}
/**
* Conecta o protocolo de eventos, registrando listeners de eventos baseados no protocolo.
*
* @param {string} protocol - O protocolo de eventos a ser conectado. O formato deve ser
* `target/event:method|attribute|setter/target-name|filter1=value1|filter2=value2`.
* @returns {this} - A instância do elemento.
*
* @description
* Este método conecta o componente ao Event Bus, registrando listeners de eventos de acordo
* com o protocolo especificado. O protocolo define como os eventos devem ser manipulados e quais
* métodos, atributos ou setters devem ser atualizados em resposta aos eventos.
*
* O protocolo é dividido em várias partes:
* - `target/event`: Identifica o evento a ser ouvido.
* - `method|attribute|setter`: Especifica como o evento deve afetar o componente.
* - `target-name`: O nome do método, atributo ou setter a ser atualizado.
* - `filter1=value1|filter2=value2`: Filtros adicionais que serão aplicados aos eventos.
*
* @example
* // Supondo que `element` seja uma instância de um componente que utiliza o Echo.
* element[echoConnectedCallback]('sender/message:method/handleMessage|filter1=value1');
*
* @example
* // Exemplo com um filtro complexo.
* element[echoConnectedCallback]('sender/event:attribute/attributeName|filter1=value1|filter2=value2');
*/
[Mt](a) {
pt(this, r)[a] = new AbortController();
const [, n, s, u, S] = a.match(
/^([a-z0-9-_]+\/[a-z0-9-_]+):([a-z]+)\/([a-z0-9-_]+)(\|.*)?$/i
) || [], M = (S || "").split("|").filter(Boolean).map((T) => {
const [W, St] = T.split("=");
return [gr[W], St];
});
return It.addEventListener(
n,
(T) => {
const W = M.reduce(
(St, [ir, nr]) => ir(St, nr),
T.detail
);
return /^method$/.test(s) && this[u](W), /^attribute$/.test(s) && this.setAttribute(u, W), /^setter$/.test(s) && (this[u] = W), this;
},
{ signal: pt(this, r)[a].signal }
), this;
}
/**
* Desconecta o protocolo de eventos, abortando os listeners registrados.
*
* @param {string} protocol - O protocolo de eventos a ser desconectado.
* @returns {this} - A instância do elemento.
*
* @description
* Este método desativa a conexão do componente ao Event Bus, removendo os listeners de
* eventos associados ao protocolo especificado. É chamado automaticamente quando o
* atributo `on` é alterado ou o componente é desconectado do DOM.
*
* @example
* element[echoDisconnectedCallback]('sender/message:method/handleMessage');
*/
[vt](a) {
var n;
return (n = pt(this, r)[a]) == null || n.abort(), this;
}
}, r = /* @__PURE__ */ new WeakMap(), /**
* Lista de atributos observados pelo Custom Element.
* Inclui o atributo `on`, necessário para o funcionamento do Event Bus.
*
* @type {string[]}
*
* @description
* A propriedade `observedAttributes` define quais atributos do elemento devem ser observados
* para alterações. O atributo `on` é incluído automaticamente para gerenciar a comunicação
* de eventos entre componentes.
*/
_r(i, e, [...t[qt] ?? [], Dt]), i;
}, _ = (t) => (e, r, i) => {
const a = i.set ?? (() => {
});
Object.assign(i, {
async set(n) {
await Reflect.apply(a, this, [n]), this.isConnected && this.dispatchEvent(
new CustomEvent(t, {
bubbles: !0,
cancelable: !0,
detail: n
})
);
}
});
}, wr = (t, e) => {
try {
return new Function(
"data",
`return data${/(^\[|^ $)/.test(t) ? "" : "."}${t}`
)(e);
} catch {
return;
}
};
var br = Object.defineProperty, Er = Object.getOwnPropertyDescriptor, te = (t) => {
throw TypeError(t);
}, ee = (t, e, r, i) => {
for (var a = i > 1 ? void 0 : i ? Er(e, r) : e, n = t.length - 1, s; n >= 0; n--)
(s = t[n]) && (a = (i ? s(e, r, a) : s(a)) || a);
return i && a && br(e, r, a), a;
}, re = (t, e, r) => e.has(t) || te("Cannot " + r), Pt = (t, e, r) => (re(t, e, "read from private field"), r ? r.call(t) : e.get(t)), Ht = (t, e, r) => e.has(t) ? te("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), At = (t, e, r, i) => (re(t, e, "write to private field"), e.set(t, r), r), z, k;
let Tt = class extends $(HTMLElement) {
constructor() {
super(...arguments), Ht(this, z), Ht(this, k);
}
get url() {
return Pt(this, k) ?? At(this, k, "");
}
set url(t) {
At(this, k, t);
}
async get(t) {
var r;
(r = Pt(this, z)) == null || r.abort(), At(this, z, new AbortController());
const e = this.url.replace(
/{{\s*(\w+)\s*}}/g,
(i, a) => wr(a, { payload: t })
);
try {
const a = await (await fetch(e, { signal: Pt(this, z).signal })).json();
this.dispatchEvent(new CustomEvent("success", { detail: a }));
} catch {
this.dispatchEvent(new CustomEvent("error"));
}
return this;
}
};
z = /* @__PURE__ */ new WeakMap();
k = /* @__PURE__ */ new WeakMap();
ee([
v("url"),
_("rerouted")
], Tt.prototype, "url", 1);
Tt = ee([
y("o-data-source")
], Tt);
const Wt = (t, ...e) => {
const r = new CSSStyleSheet(), i = String.raw({ raw: t }, ...e);
return r.replaceSync(i), [r];
}, xr = "connectedCallback", ae = Symbol("didPaintCallback"), Kt = Symbol("paintCallback"), Cr = Symbol("willPaintCallback"), Sr = (t, e) => f(ae).in(t).then(V(e)), mt = (t, ...e) => {
const r = e.map((a) => [].concat(a).join(""));
let i = String.raw({ raw: t }, ...r);
return i = i.replace(/[\n\r]+/g, "").replace(/\s+/g, " ").replace(/>\s+</g, "><").trim(), i;
}, x = (t, e = () => []) => (r) => {
f(Kt).in(r.prototype).then(async function() {
var i, a;
const n = (s) => {
requestAnimationFrame(() => {
(this.shadowRoot ?? document).adoptedStyleSheets = e(this), (this.shadowRoot ?? this).innerHTML = t(this), this.isPainted = !0, s();
});
};
await ((i = this[Cr]) == null ? void 0 : i.call(this)), await new Promise(n), await ((a = this[ae]) == null ? void 0 : a.call(this));
}), f(xr).in(r.prototype).then(V(Kt));
}, ie = "connectedCallback", ne = "disconnectedCallback", _t = Symbol("abortController"), Pr = (t, e, ...r) => (i, a) => {
f(ie).in(i).then(function() {
var n;
const s = { signal: (this[n = _t] ?? (this[n] = new AbortController())).signal }, u = (S) => {
S.target.matches(e) && this[a](
r.reduce((M, T) => T(M), S)
);
};
this.addEventListener(t, u, s);
}), f(ne).in(i).then(function() {
this[_t].abort();
});
}, ot = new Proxy(
{},
{
get: (t, e) => (r, ...i) => Pr(e, r, ...i)
}
), Ar = (t) => Object.fromEntries(new FormData(t.target, t.submitter));
function Lt(t) {
return t.preventDefault(), t;
}
function Or(t) {
return t.target.value;
}
function Mr() {
return mt`
<form class="form">
<slot></slot>
</form>
`;
}
const qr = Symbol("attached"), Dr = Symbol("removed"), Tr = Symbol("reseted"), Wr = Symbol("submitted");
function Lr() {
return Wt`
.form {
align-items: start;
display: flex;
flex-direction: column;
gap: var(--spacing-5);
padding: var(--spacing-6);
}
`;
}
var Fr = Object.defineProperty, Rr = Object.getOwnPropertyDescriptor, lt = (t, e, r, i) => {
for (var a = i > 1 ? void 0 : i ? Rr(e, r) : e, n = t.length - 1, s; n >= 0; n--)
(s = t[n]) && (a = (i ? s(e, r, a) : s(a)) || a);
return i && a && Fr(e, r, a), a;
}, se, oe, le, he;
let R = class extends $(HTMLElement) {
constructor() {
super(), this.attachShadow({ mode: "open" });
}
[he = qr]() {
return this.dispatchEvent(new CustomEvent("attached")), this;
}
[le = Dr]() {
return this.dispatchEvent(new CustomEvent("removed")), this;
}
reset() {
const t = { bubbles: !0, cancelable: !0, composed: !0 }, e = new Event("reset", t);
return this.shadowRoot.querySelector("form").dispatchEvent(e), this;
}
[oe = Tr]() {
return this.dispatchEvent(new CustomEvent("reseted")), this;
}
submit() {
const t = { bubbles: !0, cancelable: !0, composed: !0 }, e = new Event("submit", t);
return this.shadowRoot.querySelector("form").dispatchEvent(e), this;
}
[se = Wr](t) {
return this.dispatchEvent(new CustomEvent("submitted", { detail: t })), this;
}
};
lt([
P
], R.prototype, he, 1);
lt([
E
], R.prototype, le, 1);
lt([
ot.reset("form")
], R.prototype, oe, 1);
lt([
ot.submit("form", Lt, Ar)
], R.prototype, se, 1);
R = lt([
y("o-form"),
x(Mr, Lr)
], R);
const Vr = (t, ...e) => (r, i) => {
f(ie).in(r).then(function() {
var a;
const n = { signal: (this[a = _t] ?? (this[a] = new AbortController())).signal }, s = (u) => {
this[i](
e.reduce((S, M) => M(S), u)
);
};
this.parentElement.addEventListener(t, s, n);
}), f(ne).in(r).then(function() {
this[_t].abort();
});
}, h = new Proxy(
{},
{
get: (t, e) => (...r) => Vr(e, ...r)
}
), ft = (t) => t === "" ? !0 : t !== null, c = (t) => (e, r, i) => {
const a = i.set ? "set" : "value", n = i[a] ?? (() => {
});
Object.assign(i, {
async [a](...s) {
var u;
return await Reflect.apply(n, this, s), await ((u = this[t]) == null ? void 0 : u.call(this, ...s)), this;
}
});
}, A = Symbol("removed"), O = Symbol("setState"), g = Symbol("syncAttribute");
var zr = Object.defineProperty, kr = Object.getOwnPropertyDescriptor, Ft = (t, e, r, i) => {
for (var a = kr(e, r), n = t.length - 1, s; n >= 0; n--)
(s = t[n]) && (a = s(e, r, a) || a);
return a && zr(e, r, a), a;
}, it, nt, st;
class w extends HTMLElement {
constructor() {
super();
dt(this, it);
dt(this, nt);
dt(this, st);
this.attachShadow({ mode: "open" });
}
get disabled() {
return ht(this, it) ?? L(this, it, !1);
}
set disabled(r) {
L(this, it, r);
}
get message() {
return ht(this, nt) ?? L(this, nt, "");
}
set message(r) {
L(this, nt, r), this.isPainted && (this.shadowRoot.querySelector("span").innerHTML = r);
}
get value() {
return ht(this, st);
}
set value(r) {
L(this, st, r);
}
[A]() {
return this;
}
[g]() {
return this;
}
[O]() {
return this;
}
}
it = new WeakMap(), nt = new WeakMap(), st = new WeakMap();
Ft([
v("disabled", ft),
_("redisabed"),
c(g)
], w.prototype, "disabled");
Ft([
v("message"),
_("messaged")
], w.prototype, "message");
Ft([
v("value"),
_("changed"),
c(g)
], w.prototype, "value");
function q(t) {
return mt`
<span class="required">
${t.message}
</span>
`;
}
function D() {
return Wt`
.required {
color: var(--color-error-500);
display: none;
font-family: var(--font-family);
font-size: var(--font-size-sm);
font-weight: 400;
line-height: var(--line-height-sm);
}
:host(:state(invalid)) {
.required {
display: inline;
}
}
`;
}
var Gr = Object.defineProperty, Ir = Object.getOwnPropertyDescriptor, de = (t) => {
throw TypeError(t);
}, yt = (t, e, r, i) => {
for (var a = i > 1 ? void 0 : i ? Ir(e, r) : e, n = t.length - 1, s; n >= 0; n--)
(s = t[n]) && (a = (i ? s(e, r, a) : s(a)) || a);
return i && a && Gr(e, r, a), a;
}, pe = (t, e, r) => e.has(t) || de("Cannot " + r), Nt = (t, e, r) => (pe(t, e, "read from private field"), r ? r.call(t) : e.get(t)), Hr = (t, e, r) => e.has(t) ? de("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), Kr = (t, e, r, i) => (pe(t, e, "write to private field"), e.set(t, r), r), ce, ue, ve, G;
let Q = class extends $(w) {
constructor() {
super(), Hr(this, G), Kr(this, G, this.attachInternals());
}
[ve = A]() {
return this.parentElement.removeAttribute("maxlength"), this;
}
[ue = g]() {
return this.isConnected && (this.disabled ? this.parentElement.removeAttribute("maxlength") : this.parentElement.setAttribute("maxlength", this.value)), this;
}
[ce = O]() {
return this.parentElement.validity.tooLong ? Nt(this, G).states.add("invalid") : Nt(this, G).states.delete("invalid"), this;
}
};
G = /* @__PURE__ */ new WeakMap();
yt([
E
], Q.prototype, ve, 1);
yt([
P
], Q.prototype, ue, 1);
yt([
h.changed(),
h.invalidated(),
h.maxed()
], Q.prototype, ce, 1);
Q = yt([
y("o-maxlength-validator"),
x(q, D)
], Q);
var Nr = Object.defineProperty, Br = Object.getOwnPropertyDescriptor, _e = (t) => {
throw TypeError(t);
}, $t = (t, e, r, i) => {
for (var a = i > 1 ? void 0 : i ? Br(e, r) : e, n = t.length - 1, s; n >= 0; n--)
(s = t[n]) && (a = (i ? s(e, r, a) : s(a)) || a);
return i && a && Nr(e, r, a), a;
}, me = (t, e, r) => e.has(t) || _e("Cannot " + r), Bt = (t, e, r) => (me(t, e, "read from private field"), r ? r.call(t) : e.get(t)), Ur = (t, e, r) => e.has(t) ? _e("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), Zr = (t, e, r, i) => (me(t, e, "write to private field"), e.set(t, r), r), fe, ye, $e, I;
let X = class extends $(w) {
constructor() {
super(), Ur(this, I), Zr(this, I, this.attachInternals());
}
[$e = A]() {
return this.parentElement.removeAttribute("max"), this;
}
[ye = g]() {
return this.isConnected && (this.disabled ? this.parentElement.removeAttribute("max") : this.parentElement.setAttribute("max", this.value)), this;
}
[fe = O]() {
return this.parentElement.validity.rangeOverflow ? Bt(this, I).states.add("invalid") : Bt(this, I).states.delete("invalid"), this;
}
};
I = /* @__PURE__ */ new WeakMap();
$t([
E
], X.prototype, $e, 1);
$t([
P
], X.prototype, ye, 1);
$t([
h.changed(),
h.invalidated(),
h.maximised()
], X.prototype, fe, 1);
X = $t([
y("o-max-validator"),
x(q, D)
], X);
var Jr = Object.defineProperty, Qr = Object.getOwnPropertyDescriptor, ge = (t) => {
throw TypeError(t);
}, gt = (t, e, r, i) => {
for (var a = i > 1 ? void 0 : i ? Qr(e, r) : e, n = t.length - 1, s; n >= 0; n--)
(s = t[n]) && (a = (i ? s(e, r, a) : s(a)) || a);
return i && a && Jr(e, r, a), a;
}, we = (t, e, r) => e.has(t) || ge("Cannot " + r), Ut = (t, e, r) => (we(t, e, "read from private field"), r ? r.call(t) : e.get(t)), Xr = (t, e, r) => e.has(t) ? ge("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), Yr = (t, e, r, i) => (we(t, e, "write to private field"), e.set(t, r), r), be, Ee, xe, H;
let Y = class extends $(w) {
constructor() {
super(), Xr(this, H), Yr(this, H, this.attachInternals());
}
[xe = A]() {
return this.parentElement.removeAttribute("minlength"), this;
}
[Ee = g]() {
return this.isConnected && (this.disabled ? this.parentElement.removeAttribute("minlength") : this.parentElement.setAttribute("minlength", this.value)), this;
}
[be = O]() {
return this.parentElement.validity.tooShort ? Ut(this, H).states.add("invalid") : Ut(this, H).states.delete("invalid"), this;
}
};
H = /* @__PURE__ */ new WeakMap();
gt([
E
], Y.prototype, xe, 1);
gt([
P
], Y.prototype, Ee, 1);
gt([
h.changed(),
h.invalidated(),
h.mined()
], Y.prototype, be, 1);
Y = gt([
y("o-minlength-validator"),
x(q, D)
], Y);
var jr = Object.defineProperty, ta = Object.getOwnPropertyDescriptor, Ce = (t) => {
throw TypeError(t);
}, wt = (t, e, r, i) => {
for (var a = i > 1 ? void 0 : i ? ta(e, r) : e, n = t.length - 1, s; n >= 0; n--)
(s = t[n]) && (a = (i ? s(e, r, a) : s(a)) || a);
return i && a && jr(e, r, a), a;
}, Se = (t, e, r) => e.has(t) || Ce("Cannot " + r), Zt = (t, e, r) => (Se(t, e, "read from private field"), r ? r.call(t) : e.get(t)), ea = (t, e, r) => e.has(t) ? Ce("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), ra = (t, e, r, i) => (Se(t, e, "write to private field"), e.set(t, r), r), Pe, Ae, Oe, K;
let j = class extends $(w) {
constructor() {
super(), ea(this, K), ra(this, K, this.attachInternals());
}
[Oe = A]() {
return this.parentElement.removeAttribute("min"), this;
}
[Ae = g]() {
return this.isConnected && (this.disabled ? this.parentElement.removeAttribute("min") : this.parentElement.setAttribute("min", this.value)), this;
}
[Pe = O]() {
return this.parentElement.validity.rangeUnderflow ? Zt(this, K).states.add("invalid") : Zt(this, K).states.delete("invalid"), this;
}
};
K = /* @__PURE__ */ new WeakMap();
wt([
E
], j.prototype, Oe, 1);
wt([
P
], j.prototype, Ae, 1);
wt([
h.changed(),
h.invalidated(),
h.minimised()
], j.prototype, Pe, 1);
j = wt([
y("o-min-validator"),
x(q, D)
], j);
var aa = Object.defineProperty, ia = Object.getOwnPropertyDescriptor, Me = (t) => {
throw TypeError(t);
}, bt = (t, e, r, i) => {
for (var a = i > 1 ? void 0 : i ? ia(e, r) : e, n = t.length - 1, s; n >= 0; n--)
(s = t[n]) && (a = (i ? s(e, r, a) : s(a)) || a);
return i && a && aa(e, r, a), a;
}, qe = (t, e, r) => e.has(t) || Me("Cannot " + r), Jt = (t, e, r) => (qe(t, e, "read from private field"), r ? r.call(t) : e.get(t)), na = (t, e, r) => e.has(t) ? Me("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), sa = (t, e, r, i) => (qe(t, e, "write to private field"), e.set(t, r), r), De, Te, We, N;
let tt = class extends $(w) {
constructor() {
super(), na(this, N), sa(this, N, this.attachInternals());
}
[We = A]() {
return this.parentElement.removeAttribute("pattern"), this;
}
[Te = g]() {
return this.isConnected && (this.disabled ? this.parentElement.removeAttribute("pattern") : this.parentElement.setAttribute("pattern", this.value)), this;
}
[De = O]() {
return this.parentElement.validity.patternMismatch ? Jt(this, N).states.add("invalid") : Jt(this, N).states.delete("invalid"), this;
}
};
N = /* @__PURE__ */ new WeakMap();
bt([
E
], tt.prototype, We, 1);
bt([
P
], tt.prototype, Te, 1);
bt([
h.changed(),
h.invalidated(),
h.patterned()
], tt.prototype, De, 1);
tt = bt([
y("o-pattern-validator"),
x(q, D)
], tt);
var oa = Object.defineProperty, la = Object.getOwnPropertyDescriptor, Le = (t) => {
throw TypeError(t);
}, Et = (t, e, r, i) => {
for (var a = i > 1 ? void 0 : i ? la(e, r) : e, n = t.length - 1, s; n >= 0; n--)
(s = t[n]) && (a = (i ? s(e, r, a) : s(a)) || a);
return i && a && oa(e, r, a), a;
}, Fe = (t, e, r) => e.has(t) || Le("Cannot " + r), Qt = (t, e, r) => (Fe(t, e, "read from private field"), r ? r.call(t) : e.get(t)), ha = (t, e, r) => e.has(t) ? Le("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), da = (t, e, r, i) => (Fe(t, e, "write to private field"), e.set(t, r), r), Re, Ve, ze, B;
let et = class extends $(w) {
constructor() {
super(), ha(this, B), da(this, B, this.attachInternals());
}
[ze = A]() {
return this.parentElement.removeAttribute("required"), this;
}
[Ve = g]() {
return this.isConnected && (this.disabled ? this.parentElement.removeAttribute("required") : this.parentElement.setAttribute("required", !0)), this;
}
[Re = O]() {
return this.parentElement.validity.valueMissing ? Qt(this, B).states.add("invalid") : Qt(this, B).states.delete("invalid"), this;
}
};
B = /* @__PURE__ */ new WeakMap();
Et([
E
], et.prototype, ze, 1);
Et([
P
], et.prototype, Ve, 1);
Et([
h.changed(),
h.invalidated(),
h.requireded()
], et.prototype, Re, 1);
et = Et([
y("o-required-validator"),
x(q, D)
], et);
var pa = Object.defineProperty, ca = Object.getOwnPropertyDescriptor, ke = (t) => {
throw TypeError(t);
}, xt = (t, e, r, i) => {
for (var a = i > 1 ? void 0 : i ? ca(e, r) : e, n = t.length - 1, s; n >= 0; n--)
(s = t[n]) && (a = (i ? s(e, r, a) : s(a)) || a);
return i && a && pa(e, r, a), a;
}, Ge = (t, e, r) => e.has(t) || ke("Cannot " + r), Xt = (t, e, r) => (Ge(t, e, "read from private field"), r ? r.call(t) : e.get(t)), ua = (t, e, r) => e.has(t) ? ke("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), va = (t, e, r, i) => (Ge(t, e, "write to private field"), e.set(t, r), r), Ie, He, Ke, U;
let rt = class extends $(w) {
constructor() {
super(), ua(this, U), this.attachShadow({ mode: "open" }), va(this, U, this.attachInternals());
}
[Ke = A]() {
return this.parentElement.removeAttribute("step"), this;
}
[He = g]() {
return this.isConnected && (this.disabled ? this.parentElement.removeAttribute("step") : this.parentElement.setAttribute("step", this.value)), this;
}
[Ie = O]() {
return this.parentElement.validity.stepMismatch ? Xt(this, U).states.add("invalid") : Xt(this, U).states.delete("invalid"), this;
}
};
U = /* @__PURE__ */ new WeakMap();
xt([
E
], rt.prototype, Ke, 1);
xt([
P
], rt.prototype, He, 1);
xt([
h.changed(),
h.invalidated(),
h.stepped()
], rt.prototype, Ie, 1);
rt = xt([
y("o-step-validator"),
x(q, D)
], rt);
const _a = mt`
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.99992 5.33325V7.99992M7.99992 10.6666H8.00659M14.6666 7.99992C14.6666 11.6818 11.6818 14.6666 7.99992 14.6666C4.31802 14.6666 1.33325 11.6818 1.33325 7.99992C1.33325 4.31802 4.31802 1.33325 7.99992 1.33325C11.6818 1.33325 14.6666 4.31802 14.6666 7.99992Z" stroke="#F04438" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`;
function ma(t) {
return mt`
<div class="textField__container">
<label
class="textField__label"
${t.id ? `for="${t.id}"` : ""}
>
${t.label}
</label>
<div class="textField__wrapper">
<input
class="textField"
${t.id ? `id="${t.id}"` : ""}
${t.inputMode ? `inputmode="${t.inputMode}"` : ""}
${t.max ? `max="${t.max}"` : ""}
${t.maxLength ? `maxlength="${t.maxLength}"` : ""}
${t.min ? `min="${t.min}"` : ""}
${t.minLength ? `minlength="${t.minLength}"` : ""}
${t.name ? `name="${t.name}"` : ""}
${t.type ? `type="${t.type}"` : ""}
${t.value ? `value="${t.value}"` : ""}
${t.readonly ? "readonly" : ""}
${t.required ? "required" : ""}
/>
<span class="textField__alert">
${_a}
</span>
</div>
<slot></slot>
</div>
`;
}
const fa = {
from(t) {
return new Proxy(
{},
{
get(e, r) {
return t.isPainted ? t.shadowRoot.querySelector("input").getAttribute(r) : e[r];
},
set(e, r, i) {
return t.isPainted ? r === "value" ? (t.shadowRoot.querySelector("input").value = i, this) : (i ? t.shadowRoot.querySelector("input").setAttribute(r, i) : t.shadowRoot.querySelector("input").removeAttribute(r), this) : (e[r] = i, !0);
}
}
);
}
}, ya = Symbol("changed"), $a = Symbol("invalidated"), ga = Symbol("removed"), wa = Symbol("setFormValue"), b = Symbol("setValidity"), C = Symbol("setState"), ba = {
from(t) {
const e = {};
return {
get innerText() {
return t.isPainted ? t.shadowRoot.querySelector("label").innerText : e.innerText;
},
set innerText(r) {
if (t.isPainted) {
t.shadowRoot.querySelector("label").innerText = r;
return;
}
e.innerText = r;
},
get for() {
return t.isPainted ? t.shadowRoot.querySelector("label").getAttribute("for") : e.for;
},
set for(r) {
if (t.isPainted) {
t.shadowRoot.querySelector("label").setAttribute("for", r);
return;
}
e.for = r;
}
};
}
};
function Ea() {
return Wt`
*,
*::after,
*::before {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.textField__container {
align-items: start;
display: flex;
flex-direction: column;
gap: var(--spacing-2);
position: relative;
width: 320px;
}
.textField__label {
color: var(--color-gray-700);
font-family: var(--font-family);
font-size: var(--font-size-sm);
font-weight: 500;
line-height: var(--line-height-sm);
}
.textField__wrapper {
position: relative;
width: inherit;
}
.textField {
appearance: none;
background-color: white;
border: 1px solid var(--color-gray-300);
border-radius: var(--border-radius-200);
color: var(--color-gray-500);
font-family: var(--font-family);
font-size: var(--font-size-md);
font-weight: 400;
height: 44px;
line-height: var(--line-height-md);
padding: var(--spacing-2) var(--spacing-3);
width: 100%;
}
.textField[type="number"] {
-moz-appearance: textfield;
}
.textField:active,
.textField:hover {
color: var(--color-gray-900);
outline: 0;
}
.textField:focus {
border-color: var(--color-primary-300);
box-shadow: 0 0 4px 4px var(--color-primary-100);
color: var(--color-gray-900);
outline: 0;
}
.textField:read-only {
background-color: var(--color-gray-50);
border-color: var(--color-gray-300);
box-shadow: none;
color: var(--color-gray-500);
}
.textField::-webkit-autofill,
.textField::-webkit-autofill:hover,
.textField::-webkit-autofill:focus,
.textField::-webkit-autofill:active {
transition: background-color 9999999999s ease-in-out 0s
}
.textField::-webkit-outer-spin-button,
.textField::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
.textField__alert {
align-items: center;
display: none;
height: 16px;
justify-content: center;
position: absolute;
right: 14px;
top: 14px;
width: 16px;
}
:host(:state(invalid)) {
.textField__alert {
display: flex;
}
.textField {
border-color: var(--color-error-300);
padding-right: 40px;
}
.textField:focus {
box-shadow: 0 0 4px 4px var(--color-error-100);
}
}
`;
}
var xa = Object.defineProperty, Ca = Object.getOwnPropertyDescriptor, Ne = (t) => {
throw TypeError(t);
}, p = (t, e, r, i) => {
for (var a = i > 1 ? void 0 : i ? Ca(e, r) : e, n = t.length - 1, s; n >= 0; n--)
(s = t[n]) && (a = (i ? s(e, r, a) : s(a)) || a);
return i && a && xa(e, r, a), a;
}, Be = (t, e, r) => e.has(t) || Ne("Cannot " + r), o = (t, e, r) => (Be(t, e, "read from private field"), r ? r.call(t) : e.get(t)), ct = (t, e, r) => e.has(t) ? Ne("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), ut = (t, e, r, i) => (Be(t, e, "write to private field"), e.set(t, r), r), Ue, Ze, Je, Qe, Xe, Ye, Z, l, m, F;
let d = class extends $(HTMLElement) {
constructor() {
super(), ct(this, Z), ct(this, l), ct(this, m), ct(this, F), this.attachShadow({ mode: "open", delegatesFocus: !0 }), ut(this, Z, new AbortController()), ut(this, m, this.attachInternals()), ut(this, l, fa.from(this)), ut(this, F, ba.from(this));
}
get form() {
return o(this, m).form;
}
get id() {
return o(this, l).id;
}
set id(t) {
o(this, F).for = t, o(this, l).id = t;
}
get inputMode() {
return o(this, l).inputMode;
}
set inputMode(t) {
o(this, l).inputMode = t;
}
get label() {
return o(this, F).innerText;
}
set label(t) {
o(this, F).innerText = t;
}
get max() {
var t;
return (t = o(this, l)).max ?? (t.max = "");
}
set max(t) {
o(this, l).max = t;
}
get maxLength() {
var t;
return (t = o(this, l)).maxlength ?? (t.maxlength = "");
}
set maxLength(t) {
o(this, l).maxlength = t;
}
get min() {
var t;
return (t = o(this, l)).min ?? (t.min = "");
}
set min(t) {
o(this, l).min = t;
}
get minLength() {
var t;
return (t = o(this, l)).minlength ?? (t.minlength = "");
}
set minLength(t) {
o(this, l).minlength = t;
}
get name() {
var t;
return (t = o(this, l)).name ?? (t.name = "");
}
set name(t) {
o(this, l).name = t;
}
get pattern() {
return o(this, l).pattern;
}
set pattern(t) {
o(this, l).pattern = t;
}
get readonly() {
return o(this, l).readonly;
}
set readonly(t) {
o(this, l).readonly = t;
}
get required() {
return o(this, l).required;
}
set required(t) {
o(this, l).required = t;
}
get step() {
return o(this, l).step;
}
set step(t) {
o(this, l).step = t;
}
get type() {
return o(this, l).type;
}
set type(t) {
o(this, l).type = t;
}
get validationMessage() {
return o(this, m).validationMessage;
}
get validity() {
return o(this, m).validity;
}
get value() {
return o(this, l).value;
}
set value(t) {
o(this, l).value = t;
}
get willValidate() {
return o(this, m).willValidate;
}
static get formAssociated() {
return !0;
}
[Ye = ya](t) {
return this.value = t, this;
}
checkValidity() {
return o(this, m).checkValidity();
}
[Xe = $a]() {
return this.dispatchEvent(new CustomEvent("invalidated")), this;
}
[Qe = ga]() {
return o(this, Z).abort(), this;
}
reportValidity() {
return o(this, m).reportValidity();
}
reset() {
return o(this, l).value = "", o(this, m).states.delete("invalid"), this.dispatchEvent(new CustomEvent("reseted")), this;
}
[Je = wa](t) {
return t.addEventListener(
"formdata",
(e) => e.formData.set(this.name, this.value),
{ signal: o(this, Z).signal }
), this;
}
[Ze = b]() {
const { validationMessage: t, validity: e } = this.shadowRoot.querySelector("input") ?? {};
return o(this, m).setValidity(e, t), this;
}
[Ue = C]() {
return this.validity.valid ? o(this, m).states.delete("invalid") : o(this, m).states.add("invalid"), this;
}
};
Z = /* @__PURE__ */ new WeakMap();
l = /* @__PURE__ */ new WeakMap();
m = /* @__PURE__ */ new WeakMap();
F = /* @__PURE__ */ new WeakMap();
p([
v("id"),
_("reidentified")
], d.prototype, "id", 1);
p([
v("inputmode"),
_("remoded")
], d.prototype, "inputMode", 1);
p([
v("label"),
_("relabelled")
], d.prototype, "label", 1);
p([
v("max"),
_("maximised"),
c(C),
c(b)
], d.prototype, "max", 1);
p([
v("maxlength"),
_("maxed"),
c(C),
c(b)
], d.prototype, "maxLength", 1);
p([
v("min"),
_("minimised"),
c(C),
c(b)
], d.prototype, "min", 1);
p([
v("minlength"),
_("mined"),
c(C),
c(b)
], d.prototype, "minLength", 1);
p([
v("name"),
_("renamed")
], d.prototype, "name", 1);
p([
v("pattern", ft),
_("patterned"),
c(C),
c(b)
], d.prototype, "pattern", 1);
p([
v("readonly", ft),
_("readonlyed")
], d.prototype, "readonly", 1);
p([
v("required", ft),
_("requireded"),
c(C),
c(b)
], d.prototype, "required", 1);
p([
v("step"),
_("stepped"),
c(C),
c(b)
], d.prototype, "step", 1);
p([
v("type"),
_("retarget"),
c(C),
c(b)
], d.prototype, "type", 1);
p([
v("value"),
_("changed"),
c(C),
c(b)
], d.prototype, "value", 1);
p([
ot.input("input", Or)
], d.prototype, Ye, 1);
p([
ot.invalid("*", Lt)
], d.prototype, Xe, 1);
p([
E
], d.prototype, Qe, 1);
p([
cr,
c(b)
], d.prototype, "reset", 1);
p([
pr
], d.prototype, Je, 1);
p([
Sr
], d.prototype, Ze, 1);
p([
ot.invalid("*", Lt)
], d.prototype, Ue, 1);
d = p([
y("o-text-field"),
x(ma, Ea)
], d);
var Sa = Object.defineProperty, Pa = Object.getOwnPropertyDescriptor, je = (t) => {
throw TypeError(t);
}, Ct = (t, e, r, i) => {
for (var a = i > 1 ? void 0 : i ? Pa(e, r) : e, n = t.length - 1, s; n >= 0; n--)
(s = t[n]) && (a = (i ? s(e, r, a) : s(a)) || a);
return i && a && Sa(e, r, a), a;
}, tr = (t, e, r) => e.has(t) || je("Cannot " + r), Yt = (t, e, r) => (tr(t, e, "read from private field"), r ? r.call(t) : e.get(t)), Aa = (t, e, r) => e.has(t) ? je("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), Oa = (t, e, r, i) => (tr(t, e, "write to private field"), e.set(t, r), r), er, rr, ar, J;
let at = class extends $(w) {
constructor() {
super(), Aa(this, J), Oa(this, J, this.attachInternals());
}
[ar = A]() {
return this.parentElement.removeAttribute("type"), this;
}
[rr = g]() {
return this.isConnected && (this.disabled ? this.parentElement.removeAttribute("type") : this.parentElement.setAttribute("type", this.value)), this;
}
[er = O]() {
return this.parentElement.validity.typeMismatch ? Yt(this, J).states.add("invalid") : Yt(this, J).states.delete("invalid"), this;
}
};
J = /* @__PURE__ */ new WeakMap();
Ct([
E
], at.prototype, ar, 1);
Ct([
P
], at.prototype, rr, 1);
Ct([
h.changed(),
h.invalidated(),
h.retarget()
], at.prototype, er, 1);
at = Ct([
y("o-type-validator"),
x(q, D)
], at);