@iyulab/lowline-form 0.5.0 → 0.6.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.
@@ -8131,9 +8131,9 @@ var Is = (e, t) => {
8131
8131
  this.parser = new on({ frontMatter: Is });
8132
8132
  }
8133
8133
  extractSchema(e) {
8134
- let t = {};
8135
- return (typeof e == "string" ? this.parser.parseFormdown(e) : e).forms.forEach((e, n) => {
8136
- t[e.name] = this.convertFieldToSchema(e, n);
8134
+ let t = {}, n = typeof e == "string" ? this.parser.parseFormdown(e) : e, r = /* @__PURE__ */ new Set();
8135
+ return n.forms.forEach((e, n) => {
8136
+ r.has(e.name) || (r.add(e.name), t[e.name] = this.convertFieldToSchema(e, n));
8137
8137
  }), t;
8138
8138
  }
8139
8139
  convertFieldToSchema(e, t) {
@@ -8214,8 +8214,13 @@ function Vs(e, t) {
8214
8214
  required: r && i && n(e?.requiredIf, !1)
8215
8215
  };
8216
8216
  }
8217
+ function Hs(e, t) {
8218
+ let n = {};
8219
+ for (let [r, i] of Object.entries(e)) n[r] = Vs(i.conditions, t);
8220
+ return n;
8221
+ }
8217
8222
  // node_modules/@formdown/core/dist/constraints.js
8218
- var Hs = Object.freeze({
8223
+ var Us = Object.freeze({
8219
8224
  required: "{label} is required",
8220
8225
  minLength: "Must be at least {min} characters",
8221
8226
  maxLength: "Must be at most {max} characters",
@@ -8229,24 +8234,24 @@ var Hs = Object.freeze({
8229
8234
  dateMin: "Date must be on or after {min}",
8230
8235
  dateMax: "Date must be on or before {max}",
8231
8236
  pattern: "Value does not match required format"
8232
- }), Us = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, Ws = /^[\d\s\-+()]+$/, Gs = /^\d{4}-\d{2}-\d{2}$/;
8233
- function Ks(e) {
8237
+ }), Ws = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, Gs = /^[\d\s\-+()]+$/, Ks = /^\d{4}-\d{2}-\d{2}$/;
8238
+ function qs(e) {
8234
8239
  return e == null || e === !1 ? !0 : Array.isArray(e) ? e.length === 0 : String(e).trim() === "";
8235
8240
  }
8236
- function qs(e, t, n = {}) {
8241
+ function Js(e, t, n = {}) {
8237
8242
  return e.replace(/\{(label|min|max)\}/g, (e, r) => {
8238
8243
  if (r === "label") return t.label || t.name || "Field";
8239
8244
  let i = n[r];
8240
8245
  return i === void 0 ? "" : String(i);
8241
8246
  });
8242
8247
  }
8243
- function Js(e) {
8248
+ function Ys(e) {
8244
8249
  if (e === void 0 || e === "") return;
8245
8250
  let t = Number(e);
8246
8251
  return Number.isFinite(t) ? t : void 0;
8247
8252
  }
8248
- function Ys(e, t, n = {}) {
8249
- let r = Xs(e, t, n);
8253
+ function Xs(e, t, n = {}) {
8254
+ let r = Zs(e, t, n);
8250
8255
  if (r.length === 0 || !t.errorMessage) return r;
8251
8256
  let [i] = r, a = i.rule === "required" ? t.requiredMessage : i.rule === "pattern" ? t.patternMessage : void 0;
8252
8257
  return [{
@@ -8254,17 +8259,17 @@ function Ys(e, t, n = {}) {
8254
8259
  message: a || t.errorMessage
8255
8260
  }];
8256
8261
  }
8257
- function Xs(e, t, n) {
8262
+ function Zs(e, t, n) {
8258
8263
  let r = {
8259
- ...Hs,
8264
+ ...Us,
8260
8265
  ...n
8261
8266
  }, i = (e, n) => ({
8262
8267
  rule: e,
8263
- message: qs(r[e], t, n)
8268
+ message: Js(r[e], t, n)
8264
8269
  });
8265
- if (Ks(e)) return t.required ? [{
8270
+ if (qs(e)) return t.required ? [{
8266
8271
  rule: "required",
8267
- message: t.requiredMessage || qs(r.required, t)
8272
+ message: t.requiredMessage || Js(r.required, t)
8268
8273
  }] : [];
8269
8274
  let a = t.validation ?? {}, o = [], s = Array.isArray(e) ? "" : String(e);
8270
8275
  switch (t.type) {
@@ -8272,12 +8277,12 @@ function Xs(e, t, n) {
8272
8277
  case "range": {
8273
8278
  let t = typeof e == "number" ? e : Number(s.trim());
8274
8279
  if (!Number.isFinite(t)) return [i("number")];
8275
- let n = Js(a.min), r = Js(a.max);
8280
+ let n = Ys(a.min), r = Ys(a.max);
8276
8281
  n !== void 0 && t < n && o.push(i("min", { min: n })), r !== void 0 && t > r && o.push(i("max", { max: r }));
8277
8282
  break;
8278
8283
  }
8279
8284
  case "email":
8280
- if (!Us.test(s)) return [i("email")];
8285
+ if (!Ws.test(s)) return [i("email")];
8281
8286
  break;
8282
8287
  case "url":
8283
8288
  try {
@@ -8287,11 +8292,11 @@ function Xs(e, t, n) {
8287
8292
  }
8288
8293
  break;
8289
8294
  case "tel":
8290
- if (!Ws.test(s)) return [i("tel")];
8295
+ if (!Gs.test(s)) return [i("tel")];
8291
8296
  break;
8292
8297
  case "date": {
8293
- if (!Gs.test(s) || Number.isNaN(Date.parse(s))) return [i("date")];
8294
- let e = typeof a.min == "string" && Gs.test(a.min) ? a.min : void 0, t = typeof a.max == "string" && Gs.test(a.max) ? a.max : void 0;
8298
+ if (!Ks.test(s) || Number.isNaN(Date.parse(s))) return [i("date")];
8299
+ let e = typeof a.min == "string" && Ks.test(a.min) ? a.min : void 0, t = typeof a.max == "string" && Ks.test(a.max) ? a.max : void 0;
8295
8300
  e !== void 0 && s < e && o.push(i("dateMin", { min: e })), t !== void 0 && s > t && o.push(i("dateMax", { max: t }));
8296
8301
  break;
8297
8302
  }
@@ -8300,14 +8305,14 @@ function Xs(e, t, n) {
8300
8305
  let n = [...e].length;
8301
8306
  a.minlength !== void 0 && n < a.minlength && o.push(i("minLength", { min: a.minlength })), a.maxlength !== void 0 && n > a.maxlength && o.push(i("maxLength", { max: a.maxlength }));
8302
8307
  let s = t.pattern ?? a.pattern;
8303
- s && !Zs(s, e) && o.push({
8308
+ s && !Qs(s, e) && o.push({
8304
8309
  rule: "pattern",
8305
- message: t.patternMessage || qs(r.pattern, t)
8310
+ message: t.patternMessage || Js(r.pattern, t)
8306
8311
  });
8307
8312
  }
8308
8313
  return o;
8309
8314
  }
8310
- function Zs(e, t) {
8315
+ function Qs(e, t) {
8311
8316
  try {
8312
8317
  return RegExp(`^(?:${e})$`, "v").test(t);
8313
8318
  } catch {
@@ -8319,19 +8324,19 @@ function Zs(e, t) {
8319
8324
  }
8320
8325
  }
8321
8326
  // node_modules/@formdown/core/dist/validate.js
8322
- function Qs(e, t, n = {}) {
8327
+ function $s(e, t, n = {}) {
8323
8328
  let r = t.name || "field";
8324
- return Ys(e, t, n.messages).map(({ message: e }) => ({
8329
+ return Xs(e, t, n.messages).map(({ message: e }) => ({
8325
8330
  field: r,
8326
8331
  message: e
8327
8332
  }));
8328
8333
  }
8329
- function $s(e, t, n = {}) {
8334
+ function ec(e, t, n = {}) {
8330
8335
  let r = [];
8331
8336
  return Object.entries(t).forEach(([t, i]) => {
8332
8337
  let a = Vs(i.conditions, e);
8333
8338
  if (a.visible && a.enabled) {
8334
- r.push(...Qs(e[t], {
8339
+ r.push(...$s(e[t], {
8335
8340
  ...i,
8336
8341
  name: t,
8337
8342
  required: i.required || a.required
@@ -8350,7 +8355,7 @@ function $s(e, t, n = {}) {
8350
8355
  };
8351
8356
  }
8352
8357
  // node_modules/@formdown/core/dist/form-data-binding.js
8353
- var ec = class {
8358
+ var tc = class {
8354
8359
  constructor(e = null, t = {}) {
8355
8360
  this.schema = e, this.data = {}, this.changeListeners = /* @__PURE__ */ new Set(), this.fieldChangeListeners = /* @__PURE__ */ new Set(), this.validationListeners = /* @__PURE__ */ new Set(), this.isUpdating = !1, this.initializeFromSchema(), this.updateInternal(t, !1);
8356
8361
  }
@@ -8398,7 +8403,7 @@ var ec = class {
8398
8403
  }
8399
8404
  validateField(e, t, n) {
8400
8405
  if (!this.schema || !this.schema[e]) return [];
8401
- let r = Qs(t === void 0 ? this.get(e) : t, {
8406
+ let r = $s(t === void 0 ? this.get(e) : t, {
8402
8407
  ...this.schema[e],
8403
8408
  name: e
8404
8409
  }, n);
@@ -8409,7 +8414,7 @@ var ec = class {
8409
8414
  isValid: !0,
8410
8415
  errors: []
8411
8416
  };
8412
- let t = $s(this.getAll(), this.schema, e), n = /* @__PURE__ */ new Map();
8417
+ let t = ec(this.getAll(), this.schema, e), n = /* @__PURE__ */ new Map();
8413
8418
  return t.errors.forEach((e) => {
8414
8419
  n.has(e.field) || n.set(e.field, []), n.get(e.field).push(e);
8415
8420
  }), n.forEach((e, t) => {
@@ -8508,7 +8513,7 @@ var ec = class {
8508
8513
  }
8509
8514
  });
8510
8515
  }
8511
- }, tc = class {
8516
+ }, nc = class {
8512
8517
  processCheckboxGroup(e, t) {
8513
8518
  try {
8514
8519
  let n = t.querySelectorAll(`input[type="checkbox"][name="${e}"]`);
@@ -8593,7 +8598,7 @@ var ec = class {
8593
8598
  case "datetime-local":
8594
8599
  case "month":
8595
8600
  case "week": return e.value || "";
8596
- case "file": return e.value && e.value.split("\\").pop() || "";
8601
+ case "file": return "";
8597
8602
  default: return e.value || "";
8598
8603
  }
8599
8604
  }
@@ -8681,7 +8686,7 @@ var ec = class {
8681
8686
  }
8682
8687
  }
8683
8688
  validateFieldValue(e, t, n) {
8684
- let r = Ys(e, {
8689
+ let r = Xs(e, {
8685
8690
  type: t,
8686
8691
  required: n?.required,
8687
8692
  pattern: n?.pattern,
@@ -8726,9 +8731,9 @@ var ec = class {
8726
8731
  default: return "text";
8727
8732
  }
8728
8733
  }
8729
- }, nc = class {
8734
+ }, rc = class {
8730
8735
  constructor() {
8731
- this.fieldRegistry = {}, this.syncLock = !1, this.fieldProcessor = new tc();
8736
+ this.fieldRegistry = {}, this.syncLock = !1, this.fieldProcessor = new nc();
8732
8737
  }
8733
8738
  bindFieldToElement(e, t) {
8734
8739
  return this.fieldRegistry[e] || (this.fieldRegistry[e] = /* @__PURE__ */ new Set()), this.fieldRegistry[e].add(t), {
@@ -8807,7 +8812,7 @@ var ec = class {
8807
8812
  }
8808
8813
  }), n;
8809
8814
  }
8810
- }, rc = class {
8815
+ }, ic = class {
8811
8816
  constructor() {
8812
8817
  this.customValidators = /* @__PURE__ */ new Map(), this.validationCache = /* @__PURE__ */ new Map(), this.asyncValidationTimers = /* @__PURE__ */ new Map();
8813
8818
  }
@@ -8890,7 +8895,7 @@ var ec = class {
8890
8895
  if (t.push({
8891
8896
  name: "constraints",
8892
8897
  validator: (t) => {
8893
- let n = Ys(t, {
8898
+ let n = Xs(t, {
8894
8899
  name: e.fieldName,
8895
8900
  type: e.fieldType,
8896
8901
  label: typeof e.schema.label == "string" ? e.schema.label : void 0,
@@ -9019,7 +9024,7 @@ var ec = class {
9019
9024
  EXTENSION_ERROR: "formdown:extension:error",
9020
9025
  SCHEMA_CHANGE: "formdown:schema:change",
9021
9026
  SCHEMA_VALIDATED: "formdown:schema:validated"
9022
- }, ic = class {
9027
+ }, ac = class {
9023
9028
  constructor(e = {}) {
9024
9029
  this.eventBuses = /* @__PURE__ */ new Map(), this.eventBridges = /* @__PURE__ */ new Map(), this.globalEventConfig = {
9025
9030
  enableFormEvents: !0,
@@ -9207,7 +9212,7 @@ var ec = class {
9207
9212
  activeBridges: this.getActiveBridges().length
9208
9213
  };
9209
9214
  }
9210
- }, ac = class e {
9215
+ }, oc = class e {
9211
9216
  constructor(e = {}) {
9212
9217
  this.options = e, this.content = "", this.parsedContent = null, this.schema = null, this.dataBinding = null, this.eventListeners = /* @__PURE__ */ new Map(), this._pendingDefaults = null, this.fieldProcessor = null, this.domBinder = null, this.validationManager = null, this.eventOrchestrator = null, this.parser = new on({
9213
9218
  frontMatter: Is,
@@ -9217,7 +9222,7 @@ var ec = class {
9217
9222
  });
9218
9223
  }
9219
9224
  parse(e) {
9220
- return this.content = e, this.parsedContent = this.parser.parseFormdown(e), this.schema = Rs(this.parsedContent), this.dataBinding = new ec(this.schema), this._pendingDefaults &&= (this.dataBinding.applyDefaults(this._pendingDefaults.defaults, this._pendingDefaults.options), null), this.setupDataBindingEvents(), this.parsedContent;
9225
+ return this.content = e, this.parsedContent = this.parser.parseFormdown(e), this.schema = Rs(this.parsedContent), this.dataBinding = new tc(this.schema), this._pendingDefaults &&= (this.dataBinding.applyDefaults(this._pendingDefaults.defaults, this._pendingDefaults.options), null), this.setupDataBindingEvents(), this.parsedContent;
9221
9226
  }
9222
9227
  render(e = {}) {
9223
9228
  if (!this.parsedContent) throw Error("No content parsed. Call parse() first.");
@@ -9229,6 +9234,9 @@ var ec = class {
9229
9234
  getData() {
9230
9235
  return this.dataBinding ? this.dataBinding.getAll() : {};
9231
9236
  }
9237
+ getConditionStates() {
9238
+ return this.schema ? Hs(this.schema, this.getData()) : {};
9239
+ }
9232
9240
  setFieldValue(e, t) {
9233
9241
  this.dataBinding && this.dataBinding.set(e, t);
9234
9242
  }
@@ -9332,16 +9340,16 @@ var ec = class {
9332
9340
  })), this.parse(e.content), e.data && this.updateData(e.data);
9333
9341
  }
9334
9342
  createFieldProcessor() {
9335
- return this.fieldProcessor ||= new tc(), this.fieldProcessor;
9343
+ return this.fieldProcessor ||= new nc(), this.fieldProcessor;
9336
9344
  }
9337
9345
  createDOMBinder() {
9338
- return this.domBinder ||= new nc(), this.domBinder;
9346
+ return this.domBinder ||= new rc(), this.domBinder;
9339
9347
  }
9340
9348
  createValidationManager() {
9341
- return this.validationManager ||= new rc(), this.validationManager;
9349
+ return this.validationManager ||= new ic(), this.validationManager;
9342
9350
  }
9343
9351
  createEventOrchestrator() {
9344
- return this.eventOrchestrator ||= new ic(), this.eventOrchestrator;
9352
+ return this.eventOrchestrator ||= new ac(), this.eventOrchestrator;
9345
9353
  }
9346
9354
  processFieldValue(e, t) {
9347
9355
  let n = this.createFieldProcessor(), r = this.getField(e);
@@ -9410,7 +9418,9 @@ var ec = class {
9410
9418
  t ||= this.createDOMBinder();
9411
9419
  let n = e.target, r = n?.name || n?.id;
9412
9420
  if (r && e.type === "change") {
9413
- let e = this.createFieldProcessor(), t = e.getFieldType(n), i = e.extractFieldValue(n, t);
9421
+ let e = this.createFieldProcessor(), t = e.getFieldType(n);
9422
+ if (t === "file") return;
9423
+ let i = e.extractFieldValue(n, t);
9414
9424
  this.setFieldValue(r, i);
9415
9425
  }
9416
9426
  }
@@ -9449,36 +9459,36 @@ var ec = class {
9449
9459
  }
9450
9460
  };
9451
9461
  // node_modules/@formdown/ui/dist/index.es.js
9452
- function oc(e) {
9453
- return e.localName.includes("-") ? customElements.get(e.localName) : void 0;
9454
- }
9455
9462
  function sc(e) {
9456
- return e.hasAttribute("name") && oc(e)?.formAssociated === !0;
9463
+ return e.localName.includes("-") ? customElements.get(e.localName) : void 0;
9457
9464
  }
9458
9465
  function cc(e) {
9459
- return Array.from(e.querySelectorAll("[name]")).filter((e) => sc(e));
9466
+ return e.hasAttribute("name") && sc(e)?.formAssociated === !0;
9460
9467
  }
9461
9468
  function lc(e) {
9469
+ return Array.from(e.querySelectorAll("[name]")).filter((e) => cc(e));
9470
+ }
9471
+ function uc(e) {
9462
9472
  let t = Array.from(e.querySelectorAll("[name]")).filter((e) => e.localName.includes("-") && !customElements.get(e.localName)).map((e) => e.localName);
9463
9473
  return [...new Set(t)];
9464
9474
  }
9465
- function uc(e) {
9475
+ function dc(e) {
9466
9476
  let t = e.value;
9467
9477
  return t == null ? "" : typeof t == "boolean" || typeof t == "string" ? t : Array.isArray(t) ? t.map(String) : String(t);
9468
9478
  }
9469
- function dc(e, t) {
9479
+ function fc(e, t) {
9470
9480
  e.value = t ?? "";
9471
9481
  }
9472
- function fc(e, t, n) {
9482
+ function pc(e, t, n) {
9473
9483
  e.toggleAttribute("disabled", !t), e.toggleAttribute("required", n);
9474
9484
  }
9475
- function pc(e) {
9485
+ function mc(e) {
9476
9486
  return e === !0 || typeof e == "string" && e.toLowerCase() === "true";
9477
9487
  }
9478
- function mc(e, t, n) {
9479
- sc(e) ? dc(e, t) : e instanceof HTMLInputElement ? n === "checkbox" || e.type === "checkbox" ? e.checked = Array.isArray(t) ? t.map(String).includes(e.value) : e.value === "true" ? pc(t) : t != null && String(t) === e.value : n === "radio" || e.type === "radio" ? e.checked = t != null && e.value === String(t) : e.value = String(t ?? "") : e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? e.value = String(t ?? "") : e.hasAttribute("contenteditable") && (e.textContent = String(t ?? ""));
9488
+ function hc(e, t, n) {
9489
+ cc(e) ? fc(e, t) : e instanceof HTMLInputElement ? n === "checkbox" || e.type === "checkbox" ? e.checked = Array.isArray(t) ? t.map(String).includes(e.value) : e.value === "true" ? mc(t) : t != null && String(t) === e.value : n === "radio" || e.type === "radio" ? e.checked = t != null && e.value === String(t) : e.value = String(t ?? "") : e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? e.value = String(t ?? "") : e.hasAttribute("contenteditable") && (e.textContent = String(t ?? ""));
9480
9490
  }
9481
- function hc(e, t) {
9491
+ function gc(e, t) {
9482
9492
  let n = [];
9483
9493
  for (let [r, i] of Object.entries(t)) {
9484
9494
  let t = (Array.isArray(i) ? i : [i]).filter((e) => e != null && typeof e != "boolean").map(String).filter((e) => e !== "");
@@ -9508,7 +9518,7 @@ function hc(e, t) {
9508
9518
  }
9509
9519
  return n;
9510
9520
  }
9511
- var gc = /* @__PURE__ */ new Set([
9521
+ var _c = /* @__PURE__ */ new Set([
9512
9522
  "date",
9513
9523
  "time",
9514
9524
  "datetime-local",
@@ -9517,43 +9527,43 @@ var gc = /* @__PURE__ */ new Set([
9517
9527
  "number",
9518
9528
  "range",
9519
9529
  "color"
9520
- ]), _c = "data-formdown-unread", vc = "formdown-unread";
9521
- function yc(e, t) {
9530
+ ]), vc = "data-formdown-unread", yc = "formdown-unread";
9531
+ function bc(e, t) {
9522
9532
  return e.type === "color" ? e.value === t.toLowerCase() : e.value === t;
9523
9533
  }
9524
- function bc(e, t, n) {
9534
+ function xc(e, t, n) {
9525
9535
  let r = (e.getAttribute("aria-describedby") ?? "").split(/\s+/).filter((e) => e && e !== t);
9526
9536
  n && r.push(t), r.length > 0 ? e.setAttribute("aria-describedby", r.join(" ")) : e.removeAttribute("aria-describedby");
9527
9537
  }
9528
- function xc(e, t) {
9538
+ function Sc(e, t) {
9529
9539
  for (let n of Array.from(e.querySelectorAll("input"))) {
9530
- if (!gc.has(n.type)) continue;
9531
- let e = t[n.name], r = typeof e == "string" || typeof e == "number" ? String(e) : "", i = r !== "" && !yc(n, r), a = `${n.id || n.name}_unread`, o = n.nextElementSibling?.classList.contains(vc) ? n.nextElementSibling : null;
9540
+ if (!_c.has(n.type)) continue;
9541
+ let e = t[n.name], r = typeof e == "string" || typeof e == "number" ? String(e) : "", i = r !== "" && !bc(n, r), a = `${n.id || n.name}_unread`, o = n.nextElementSibling?.classList.contains(yc) ? n.nextElementSibling : null;
9532
9542
  if (!i) {
9533
- o && o.remove(), n.hasAttribute(_c) && (n.removeAttribute(_c), bc(n, a, !1));
9543
+ o && o.remove(), n.hasAttribute(vc) && (n.removeAttribute(vc), xc(n, a, !1));
9534
9544
  continue;
9535
9545
  }
9536
- n.setAttribute(_c, "true");
9546
+ n.setAttribute(vc, "true");
9537
9547
  let s = o ?? n.ownerDocument.createElement("span");
9538
- s.className = vc, s.id = a, s.setAttribute("part", "unread-value"), s.setAttribute(_c, n.name), s.textContent = r, o || n.after(s), bc(n, a, !0);
9548
+ s.className = yc, s.id = a, s.setAttribute("part", "unread-value"), s.setAttribute(vc, n.name), s.textContent = r, o || n.after(s), xc(n, a, !0);
9539
9549
  }
9540
9550
  }
9541
- var Sc = "data-formdown-choice", Cc = "data-formdown-unlisted", wc = (e) => e.label ?? e.value;
9542
- function Tc(e, t) {
9551
+ var Cc = "data-formdown-choice", wc = "data-formdown-unlisted", Tc = (e) => e.label ?? e.value;
9552
+ function Ec(e, t) {
9543
9553
  let n = [];
9544
9554
  for (let n of Array.from(e.querySelectorAll("select"))) {
9545
9555
  if (n.hasAttribute("data-formdown-has-other")) continue;
9546
9556
  let e = t[n.name] ?? [];
9547
- for (let t of Array.from(n.options)) t.hasAttribute(Sc) && !e.some((e) => e.value === t.value) && t.remove();
9557
+ for (let t of Array.from(n.options)) t.hasAttribute(Cc) && !e.some((e) => e.value === t.value) && t.remove();
9548
9558
  for (let t of e) {
9549
9559
  let e = Array.from(n.options).find((e) => e.value === t.value);
9550
9560
  if (e) {
9551
- (e.hasAttribute(Cc) || e.hasAttribute(Sc)) && Ec(e, t);
9561
+ (e.hasAttribute(wc) || e.hasAttribute(Cc)) && Dc(e, t);
9552
9562
  continue;
9553
9563
  }
9554
9564
  let r = n.ownerDocument.createElement("option");
9555
- r.value = t.value, Ec(r, t);
9556
- let i = Array.from(n.options).find((e) => e.hasAttribute(Cc));
9565
+ r.value = t.value, Dc(r, t);
9566
+ let i = Array.from(n.options).find((e) => e.hasAttribute(wc));
9557
9567
  n.insertBefore(r, i ?? null);
9558
9568
  }
9559
9569
  }
@@ -9561,21 +9571,21 @@ function Tc(e, t) {
9561
9571
  for (let t of Array.from(e.querySelectorAll("input[type=\"radio\"], input[type=\"checkbox\"]"))) r.set(t.name, [...r.get(t.name) ?? [], t]);
9562
9572
  for (let [e, i] of r) {
9563
9573
  if (i.every((e) => e.type === "checkbox" && e.value === "true") || i.some((e) => e.hasAttribute("data-formdown-other-radio") || e.hasAttribute("data-formdown-other-checkbox"))) continue;
9564
- let r = t[e] ?? [], a = i.filter((e) => e.hasAttribute(Sc) && !r.some((t) => t.value === e.value)), o = [...i];
9574
+ let r = t[e] ?? [], a = i.filter((e) => e.hasAttribute(Cc) && !r.some((t) => t.value === e.value)), o = [...i];
9565
9575
  for (let t of r) {
9566
9576
  let r = o.find((e) => e.value === t.value);
9567
9577
  if (r) {
9568
- if (r.hasAttribute(Cc) || r.hasAttribute(Sc)) {
9569
- r.removeAttribute(Cc), r.setAttribute(Sc, "true");
9578
+ if (r.hasAttribute(wc) || r.hasAttribute(Cc)) {
9579
+ r.removeAttribute(wc), r.setAttribute(Cc, "true");
9570
9580
  let e = r.closest("label")?.querySelector("span");
9571
- e && (e.textContent = wc(t));
9581
+ e && (e.textContent = Tc(t));
9572
9582
  }
9573
9583
  continue;
9574
9584
  }
9575
- let i = o.filter((e) => !e.hasAttribute(Cc)), a = i[i.length - 1] ?? o[o.length - 1], s = a.closest("label"), c = a.ownerDocument, l = c.createElement("input");
9576
- l.type = a.type, l.name = e, l.value = t.value, l.id = `${e}_choice_${n.length}_${o.length}`, l.setAttribute(Sc, "true");
9585
+ let i = o.filter((e) => !e.hasAttribute(wc)), a = i[i.length - 1] ?? o[o.length - 1], s = a.closest("label"), c = a.ownerDocument, l = c.createElement("input");
9586
+ l.type = a.type, l.name = e, l.value = t.value, l.id = `${e}_choice_${n.length}_${o.length}`, l.setAttribute(Cc, "true");
9577
9587
  let u = c.createElement("span");
9578
- u.textContent = wc(t);
9588
+ u.textContent = Tc(t);
9579
9589
  let d = c.createElement("label");
9580
9590
  d.className = s?.className || "formdown-option-label", d.setAttribute("part", s?.getAttribute("part") || "option-label"), d.htmlFor = l.id, d.append(l, u), (s ?? a).after(d), o.splice(o.indexOf(a) + 1, 0, l), n.push(l);
9581
9591
  }
@@ -9601,25 +9611,25 @@ function Tc(e, t) {
9601
9611
  let o = a ?? n.ownerDocument.createElement("datalist");
9602
9612
  o.id = r, o.replaceChildren(...i.map((e) => {
9603
9613
  let t = n.ownerDocument.createElement("option");
9604
- return t.value = e.value, t.label = wc(e), t;
9614
+ return t.value = e.value, t.label = Tc(e), t;
9605
9615
  })), a || n.after(o), n.setAttribute("list", r);
9606
9616
  }
9607
9617
  return n;
9608
9618
  }
9609
- function Ec(e, t) {
9610
- e.removeAttribute(Cc), e.setAttribute(Sc, "true"), e.textContent = wc(t);
9619
+ function Dc(e, t) {
9620
+ e.removeAttribute(wc), e.setAttribute(Cc, "true"), e.textContent = Tc(t);
9611
9621
  }
9612
- var Dc = "data-formdown-note", Oc = "data-formdown-value", kc = "data-formdown-placeholder", Ac = "formdown-ghost", jc = "formdown-suggested";
9613
- function Mc(e, t) {
9622
+ var Oc = "data-formdown-note", kc = "data-formdown-value", Ac = "data-formdown-placeholder", jc = "formdown-ghost", Mc = "formdown-suggested";
9623
+ function Nc(e, t) {
9614
9624
  let n = Array.from(e.querySelectorAll("[name]")).filter((e) => e.getAttribute("name") === t);
9615
9625
  if (n.length > 0) return n;
9616
9626
  let r = Array.from(e.querySelectorAll("[data-field-name]")).find((e) => e.dataset.fieldName === t);
9617
9627
  return r ? [r] : [];
9618
9628
  }
9619
- function Nc(e) {
9629
+ function Pc(e) {
9620
9630
  return e.isContentEditable || e.getAttribute("contenteditable") === "true";
9621
9631
  }
9622
- function Pc(e) {
9632
+ function Fc(e) {
9623
9633
  return e instanceof HTMLTextAreaElement || e instanceof HTMLInputElement && ![
9624
9634
  "radio",
9625
9635
  "checkbox",
@@ -9632,45 +9642,45 @@ function Pc(e) {
9632
9642
  "reset"
9633
9643
  ].includes(e.type);
9634
9644
  }
9635
- function Fc(e, t) {
9636
- e.classList.remove(t), e.classList.length === 0 && e.removeAttribute("class");
9637
- }
9638
9645
  function Ic(e, t) {
9639
- let n = Nc(e) ? "data-placeholder" : Pc(e) ? "placeholder" : null;
9640
- n && (e.hasAttribute(kc) || e.setAttribute(kc, e.getAttribute(n) ?? ""), e.setAttribute(n, t), e.classList.add(Ac));
9646
+ e.classList.remove(t), e.classList.length === 0 && e.removeAttribute("class");
9641
9647
  }
9642
9648
  function Lc(e, t) {
9649
+ let n = Pc(e) ? "data-placeholder" : Fc(e) ? "placeholder" : null;
9650
+ n && (e.hasAttribute(Ac) || e.setAttribute(Ac, e.getAttribute(n) ?? ""), e.setAttribute(n, t), e.classList.add(jc));
9651
+ }
9652
+ function Rc(e, t) {
9643
9653
  let [n] = e;
9644
9654
  return n instanceof HTMLSelectElement ? Array.from(n.options).find((e) => e.value === t)?.textContent?.trim() || t : e.find((e) => e instanceof HTMLInputElement && (e.type === "radio" || e.type === "checkbox") && e.value === t)?.closest("label")?.textContent?.trim() || t;
9645
9655
  }
9646
- function Rc(e) {
9656
+ function zc(e) {
9647
9657
  let [t] = e;
9648
9658
  if (t instanceof HTMLSelectElement) return Array.from(t.selectedOptions).map((e) => e.value).filter(Boolean);
9649
9659
  if (t instanceof HTMLInputElement && (t.type === "radio" || t.type === "checkbox")) return e.filter((e) => e instanceof HTMLInputElement && e.checked).map((e) => e.value);
9650
9660
  let n;
9651
- return n = sc(t) ? uc(t) : t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement ? t.value : Nc(t) ? (t.textContent ?? "").trim() : "", (Array.isArray(n) ? n : [String(n)]).filter((e) => e !== "");
9661
+ return n = cc(t) ? dc(t) : t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement ? t.value : Pc(t) ? (t.textContent ?? "").trim() : "", (Array.isArray(n) ? n : [String(n)]).filter((e) => e !== "");
9652
9662
  }
9653
- function zc(e, t) {
9663
+ function Bc(e, t) {
9654
9664
  let n = e[0].closest(".formdown-field")?.querySelector("[part~=\"label\"], [part~=\"legend\"]")?.textContent?.trim();
9655
9665
  return n ? n.replace(/\s*\*$/, "") : t;
9656
9666
  }
9657
- function Bc(e) {
9658
- for (let t of Array.from(e.querySelectorAll(`[${Dc}]`))) {
9659
- let n = Mc(e, t.getAttribute(Dc)), r = n.length > 0 ? Rc(n) : [];
9660
- for (let e of Array.from(t.querySelectorAll(`[${Oc}]`))) e.setAttribute("aria-pressed", String(r.includes(e.getAttribute(Oc))));
9667
+ function Vc(e) {
9668
+ for (let t of Array.from(e.querySelectorAll(`[${Oc}]`))) {
9669
+ let n = Nc(e, t.getAttribute(Oc)), r = n.length > 0 ? zc(n) : [];
9670
+ for (let e of Array.from(t.querySelectorAll(`[${kc}]`))) e.setAttribute("aria-pressed", String(r.includes(e.getAttribute(kc))));
9661
9671
  }
9662
9672
  }
9663
- function Vc(e, t, n, r, i, a) {
9673
+ function Hc(e, t, n, r, i, a) {
9664
9674
  let o = n.suggestions ?? [];
9665
9675
  if (!n.note && o.length === 0) return;
9666
9676
  let s = e.createElement(r ? "span" : "div");
9667
- if (s.className = "formdown-field-note", s.setAttribute("part", "field-note"), s.setAttribute(Dc, t), o.length > 0 && (s.setAttribute("role", "group"), s.setAttribute("aria-label", n.label ?? `Suggestions for ${zc(a, t)}`)), n.note) {
9677
+ if (s.className = "formdown-field-note", s.setAttribute("part", "field-note"), s.setAttribute(Oc, t), o.length > 0 && (s.setAttribute("role", "group"), s.setAttribute("aria-label", n.label ?? `Suggestions for ${Bc(a, t)}`)), n.note) {
9668
9678
  let t = e.createElement("span");
9669
9679
  t.className = "formdown-field-note-text", t.textContent = n.note, s.append(t);
9670
9680
  }
9671
9681
  for (let n of o) {
9672
9682
  let r = e.createElement("button");
9673
- r.type = "button", r.className = "formdown-suggestion", r.setAttribute("part", "suggestion"), r.setAttribute(Oc, n), r.textContent = Lc(a, n), r.addEventListener("click", () => i.onPick(t, n)), s.append(r);
9683
+ r.type = "button", r.className = "formdown-suggestion", r.setAttribute("part", "suggestion"), r.setAttribute(kc, n), r.textContent = Rc(a, n), r.addEventListener("click", () => i.onPick(t, n)), s.append(r);
9674
9684
  }
9675
9685
  if (n.decline && o.length > 0) {
9676
9686
  let r = e.createElement("button");
@@ -9678,52 +9688,52 @@ function Vc(e, t, n, r, i, a) {
9678
9688
  }
9679
9689
  return s;
9680
9690
  }
9681
- function Hc(e) {
9682
- for (let t of Array.from(e.querySelectorAll(`[${Dc}]`))) t.remove();
9683
- for (let t of Array.from(e.querySelectorAll(`[${kc}]`))) {
9684
- let e = Nc(t) ? "data-placeholder" : "placeholder", n = t.getAttribute(kc) ?? "";
9685
- n ? t.setAttribute(e, n) : t.removeAttribute(e), t.removeAttribute(kc), Fc(t, Ac);
9691
+ function Uc(e) {
9692
+ for (let t of Array.from(e.querySelectorAll(`[${Oc}]`))) t.remove();
9693
+ for (let t of Array.from(e.querySelectorAll(`[${Ac}]`))) {
9694
+ let e = Pc(t) ? "data-placeholder" : "placeholder", n = t.getAttribute(Ac) ?? "";
9695
+ n ? t.setAttribute(e, n) : t.removeAttribute(e), t.removeAttribute(Ac), Ic(t, jc);
9686
9696
  }
9687
- for (let t of Array.from(e.querySelectorAll(`.${jc}`))) Fc(t, jc);
9697
+ for (let t of Array.from(e.querySelectorAll(`.${Mc}`))) Ic(t, Mc);
9688
9698
  }
9689
- function Uc(e, t, n) {
9690
- let r = Gc(e);
9691
- Hc(e);
9699
+ function Wc(e, t, n) {
9700
+ let r = Kc(e);
9701
+ Uc(e);
9692
9702
  let i = e.ownerDocument ?? e;
9693
9703
  for (let [r, a] of Object.entries(t)) {
9694
- let t = Mc(e, r);
9704
+ let t = Nc(e, r);
9695
9705
  if (t.length === 0) continue;
9696
9706
  let [o] = t, s = a.suggestions ?? [];
9697
- s.length > 0 && Ic(o, s[0]);
9698
- for (let e of t) e instanceof HTMLInputElement && (e.type === "radio" || e.type === "checkbox") && s.includes(e.value) && e.closest("label")?.classList.add(jc);
9699
- let c = Nc(o), l = Vc(i, r, a, c, n, t);
9707
+ s.length > 0 && Lc(o, s[0]);
9708
+ for (let e of t) e instanceof HTMLInputElement && (e.type === "radio" || e.type === "checkbox") && s.includes(e.value) && e.closest("label")?.classList.add(Mc);
9709
+ let c = Pc(o), l = Hc(i, r, a, c, n, t);
9700
9710
  l && (c ? o.after(l) : (o.closest(".formdown-field") ?? o.parentElement ?? o).append(l));
9701
9711
  }
9702
- Bc(e), r !== null && Kc(e, r);
9712
+ Vc(e), r !== null && qc(e, r);
9703
9713
  }
9704
- function Wc(e) {
9714
+ function Gc(e) {
9705
9715
  let t = e.getRootNode?.();
9706
9716
  return t && "activeElement" in t ? t : null;
9707
9717
  }
9708
- function Gc(e) {
9709
- let t = Wc(e)?.activeElement;
9710
- return !t || !e.contains(t) ? null : t.closest(`[${Dc}]`)?.getAttribute(Dc) ?? null;
9718
+ function Kc(e) {
9719
+ let t = Gc(e)?.activeElement;
9720
+ return !t || !e.contains(t) ? null : t.closest(`[${Oc}]`)?.getAttribute(Oc) ?? null;
9711
9721
  }
9712
- function Kc(e, t) {
9713
- let n = Wc(e)?.activeElement;
9722
+ function qc(e, t) {
9723
+ let n = Gc(e)?.activeElement;
9714
9724
  if (n && e.contains(n)) return;
9715
- let r = qc(e, t);
9716
- r && Qc(r);
9725
+ let r = Jc(e, t);
9726
+ r && $c(r);
9717
9727
  }
9718
- function qc(e, t) {
9719
- let n = Mc(e, t), r = n.find((e) => e instanceof HTMLInputElement && e.checked) ?? n[0];
9720
- return (r && nl(r)) ?? r;
9728
+ function Jc(e, t) {
9729
+ let n = Nc(e, t), r = n.find((e) => e instanceof HTMLInputElement && e.checked) ?? n[0];
9730
+ return (r && rl(r)) ?? r;
9721
9731
  }
9722
- function Jc(e) {
9723
- return e.closest("[hidden]") || e instanceof HTMLInputElement && e.type === "hidden" || "disabled" in e && e.disabled || sc(e) && e.hasAttribute("disabled") ? !1 : !Nc(e) || e.getAttribute("contenteditable") !== "false";
9732
+ function Yc(e) {
9733
+ return e.closest("[hidden]") || e instanceof HTMLInputElement && e.type === "hidden" || "disabled" in e && e.disabled || cc(e) && e.hasAttribute("disabled") ? !1 : !Pc(e) || e.getAttribute("contenteditable") !== "false";
9724
9734
  }
9725
- var Yc = /* @__PURE__ */ new WeakSet();
9726
- function Xc(e) {
9735
+ var Xc = /* @__PURE__ */ new WeakSet();
9736
+ function Zc(e) {
9727
9737
  if (e.isContentEditable) {
9728
9738
  let t = e.getRootNode().getSelection?.() ?? window.getSelection();
9729
9739
  if (!t) return;
@@ -9733,34 +9743,34 @@ function Xc(e) {
9733
9743
  e.setSelectionRange(e.value.length, e.value.length);
9734
9744
  } catch {}
9735
9745
  }
9736
- function Zc(e, t) {
9746
+ function Qc(e, t) {
9737
9747
  let n;
9738
- if (t !== void 0) n = qc(e, t), n && !Jc(n) && (n = void 0);
9748
+ if (t !== void 0) n = Jc(e, t), n && !Yc(n) && (n = void 0);
9739
9749
  else {
9740
- let t = Array.from(e.querySelectorAll("[name], [data-field-name]")).find(Jc), r = t?.getAttribute("name") ?? t?.dataset.fieldName;
9741
- n = r == null ? void 0 : qc(e, r);
9750
+ let t = Array.from(e.querySelectorAll("[name], [data-field-name]")).find(Yc), r = t?.getAttribute("name") ?? t?.dataset.fieldName;
9751
+ n = r == null ? void 0 : Jc(e, r);
9742
9752
  }
9743
- return n && Qc(n), !!n && Wc(e)?.activeElement === n;
9753
+ return n && $c(n), !!n && Gc(e)?.activeElement === n;
9744
9754
  }
9745
- function Qc(e) {
9746
- Yc.add(e), e.focus(), e.getRootNode().activeElement !== e && Yc.delete(e), Xc(e);
9755
+ function $c(e) {
9756
+ Xc.add(e), e.focus(), e.getRootNode().activeElement !== e && Xc.delete(e), Zc(e);
9747
9757
  }
9748
- var $c = "data-formdown-filtered", el = /* @__PURE__ */ new WeakMap(), tl = 0;
9749
- function nl(e) {
9750
- return e instanceof HTMLSelectElement ? el.get(e)?.input : void 0;
9758
+ var el = "data-formdown-filtered", tl = /* @__PURE__ */ new WeakMap(), nl = 0;
9759
+ function rl(e) {
9760
+ return e instanceof HTMLSelectElement ? tl.get(e)?.input : void 0;
9751
9761
  }
9752
- function rl(e, t) {
9762
+ function il(e, t) {
9753
9763
  for (let n of Array.from(e.querySelectorAll("select"))) {
9754
- let e = el.get(n);
9755
- !n.multiple && !n.hasAttribute("data-formdown-has-other") && il(n).length > t ? ll(e ?? sl(n)) : e && cl(e);
9764
+ let e = tl.get(n);
9765
+ !n.multiple && !n.hasAttribute("data-formdown-has-other") && al(n).length > t ? ul(e ?? cl(n)) : e && ll(e);
9756
9766
  }
9757
9767
  }
9758
- function il(e) {
9768
+ function al(e) {
9759
9769
  return Array.from(e.options).filter((e) => !e.disabled && !e.hidden);
9760
9770
  }
9761
- var al = (e) => e.label || e.textContent || e.value, ol = (e) => e.normalize("NFC").toLocaleLowerCase();
9762
- function sl(e) {
9763
- let t = e.ownerDocument, n = ++tl, r = t.createElement("span");
9771
+ var ol = (e) => e.label || e.textContent || e.value, sl = (e) => e.normalize("NFC").toLocaleLowerCase();
9772
+ function cl(e) {
9773
+ let t = e.ownerDocument, n = ++nl, r = t.createElement("span");
9764
9774
  r.className = "formdown-select-filter";
9765
9775
  let i = t.createElement("input");
9766
9776
  i.type = "text", i.className = "formdown-select-filter-input", i.id = `formdown-filter-${n}`, i.setAttribute("role", "combobox"), i.setAttribute("aria-autocomplete", "list"), i.setAttribute("aria-expanded", "false"), i.autocomplete = "off", i.spellcheck = !1;
@@ -9769,7 +9779,7 @@ function sl(e) {
9769
9779
  let o = t.createElement("ul");
9770
9780
  o.id = `formdown-filter-list-${n}`, o.className = "formdown-select-filter-list", o.setAttribute("role", "listbox"), o.hidden = !0, i.setAttribute("aria-controls", o.id);
9771
9781
  let s = e.id ? Array.from(e.getRootNode().querySelectorAll("label")).find((t) => t.htmlFor === e.id) : void 0;
9772
- s && (s.id ||= `formdown-filter-label-${n}`, i.setAttribute("aria-labelledby", s.id)), e.setAttribute($c, "true"), e.tabIndex = -1, e.setAttribute("aria-hidden", "true"), e.before(r), r.append(i, o, e);
9782
+ s && (s.id ||= `formdown-filter-label-${n}`, i.setAttribute("aria-labelledby", s.id)), e.setAttribute(el, "true"), e.tabIndex = -1, e.setAttribute("aria-hidden", "true"), e.before(r), r.append(i, o, e);
9773
9783
  let c = {
9774
9784
  select: e,
9775
9785
  wrapper: r,
@@ -9778,22 +9788,22 @@ function sl(e) {
9778
9788
  shown: [],
9779
9789
  active: -1
9780
9790
  };
9781
- el.set(e, c);
9791
+ tl.set(e, c);
9782
9792
  let l = () => i.focus();
9783
9793
  return e.addEventListener("focus", l), c.off = () => e.removeEventListener("focus", l), i.addEventListener("focus", () => {
9784
- Yc.delete(i) || setTimeout(() => i.select(), 0);
9785
- }), i.addEventListener("click", () => o.hidden ? dl(c, "") : fl(c)), i.addEventListener("input", () => dl(c, i.value)), i.addEventListener("blur", () => {
9786
- fl(c), i.value = ul(e);
9787
- }), i.addEventListener("keydown", (e) => hl(c, e)), o.addEventListener("mousedown", (e) => e.preventDefault()), o.addEventListener("click", (e) => {
9794
+ Xc.delete(i) || setTimeout(() => i.select(), 0);
9795
+ }), i.addEventListener("click", () => o.hidden ? fl(c, "") : pl(c)), i.addEventListener("input", () => fl(c, i.value)), i.addEventListener("blur", () => {
9796
+ pl(c), i.value = dl(e);
9797
+ }), i.addEventListener("keydown", (e) => gl(c, e)), o.addEventListener("mousedown", (e) => e.preventDefault()), o.addEventListener("click", (e) => {
9788
9798
  let t = e.target.closest("[role=\"option\"]");
9789
- t && ml(c, c.shown[Number(t.getAttribute("data-index"))]);
9799
+ t && hl(c, c.shown[Number(t.getAttribute("data-index"))]);
9790
9800
  }), c;
9791
9801
  }
9792
- function cl(e) {
9802
+ function ll(e) {
9793
9803
  let { select: t, wrapper: n } = e;
9794
- e.off?.(), t.removeAttribute($c), t.removeAttribute("tabindex"), t.removeAttribute("aria-hidden"), n.before(t), n.remove(), el.delete(t);
9804
+ e.off?.(), t.removeAttribute(el), t.removeAttribute("tabindex"), t.removeAttribute("aria-hidden"), n.before(t), n.remove(), tl.delete(t);
9795
9805
  }
9796
- function ll(e) {
9806
+ function ul(e) {
9797
9807
  let { select: t, input: n } = e;
9798
9808
  n.disabled = t.disabled, n.required = t.required;
9799
9809
  for (let e of [
@@ -9805,27 +9815,27 @@ function ll(e) {
9805
9815
  let r = t.getAttribute(e);
9806
9816
  r === null ? n.removeAttribute(e) : n.setAttribute(e, r);
9807
9817
  }
9808
- t.ownerDocument && n.getRootNode().activeElement !== n && (n.value = ul(t)), e.list.hidden || dl(e, n.value === ul(t) ? "" : n.value);
9818
+ t.ownerDocument && n.getRootNode().activeElement !== n && (n.value = dl(t)), e.list.hidden || fl(e, n.value === dl(t) ? "" : n.value);
9809
9819
  }
9810
- function ul(e) {
9820
+ function dl(e) {
9811
9821
  let t = e.selectedIndex >= 0 ? e.options[e.selectedIndex] : void 0;
9812
- return t ? al(t) : "";
9822
+ return t ? ol(t) : "";
9813
9823
  }
9814
- function dl(e, t) {
9815
- let { select: n, input: r, list: i } = e, a = ol(t.trim());
9816
- e.shown = il(n).filter((e) => !a || ol(al(e)).includes(a));
9824
+ function fl(e, t) {
9825
+ let { select: n, input: r, list: i } = e, a = sl(t.trim());
9826
+ e.shown = al(n).filter((e) => !a || sl(ol(e)).includes(a));
9817
9827
  let o = n.ownerDocument;
9818
9828
  i.replaceChildren(...e.shown.map((e, t) => {
9819
9829
  let n = o.createElement("li");
9820
- return n.id = `${i.id}-${t}`, n.setAttribute("role", "option"), n.setAttribute("data-index", String(t)), n.setAttribute("aria-selected", String(e.selected)), n.textContent = al(e), n;
9830
+ return n.id = `${i.id}-${t}`, n.setAttribute("role", "option"), n.setAttribute("data-index", String(t)), n.setAttribute("aria-selected", String(e.selected)), n.textContent = ol(e), n;
9821
9831
  })), i.hidden = e.shown.length === 0, r.setAttribute("aria-expanded", String(!i.hidden));
9822
9832
  let s = e.shown.findIndex((e) => e.selected);
9823
- pl(e, a ? e.shown.length ? 0 : -1 : s);
9833
+ ml(e, a ? e.shown.length ? 0 : -1 : s);
9824
9834
  }
9825
- function fl(e) {
9835
+ function pl(e) {
9826
9836
  e.list.hidden = !0, e.list.replaceChildren(), e.shown = [], e.active = -1, e.input.setAttribute("aria-expanded", "false"), e.input.removeAttribute("aria-activedescendant");
9827
9837
  }
9828
- function pl(e, t) {
9838
+ function ml(e, t) {
9829
9839
  let n = e.list.children;
9830
9840
  if (e.active >= 0 && n[e.active]?.classList.remove("active"), e.active = t, t < 0) {
9831
9841
  e.input.removeAttribute("aria-activedescendant");
@@ -9834,47 +9844,47 @@ function pl(e, t) {
9834
9844
  let r = n[t];
9835
9845
  r && (r.classList.add("active"), e.input.setAttribute("aria-activedescendant", r.id), r.scrollIntoView?.({ block: "nearest" }));
9836
9846
  }
9837
- function ml(e, t) {
9847
+ function hl(e, t) {
9838
9848
  let { select: n, input: r } = e;
9839
9849
  if (!t) return;
9840
9850
  let i = n.value !== t.value;
9841
- n.value = t.value, r.value = al(t), fl(e), i && (n.dispatchEvent(new Event("input", {
9851
+ n.value = t.value, r.value = ol(t), pl(e), i && (n.dispatchEvent(new Event("input", {
9842
9852
  bubbles: !0,
9843
9853
  composed: !0
9844
9854
  })), n.dispatchEvent(new Event("change", { bubbles: !0 })));
9845
9855
  }
9846
- function hl(e, t) {
9856
+ function gl(e, t) {
9847
9857
  if (t.isComposing) return;
9848
9858
  let n = !e.list.hidden;
9849
9859
  switch (t.key) {
9850
9860
  case "ArrowDown":
9851
- t.preventDefault(), n ? e.shown.length && pl(e, Math.min(e.active + 1, e.shown.length - 1)) : dl(e, "");
9861
+ t.preventDefault(), n ? e.shown.length && ml(e, Math.min(e.active + 1, e.shown.length - 1)) : fl(e, "");
9852
9862
  break;
9853
9863
  case "ArrowUp":
9854
- t.preventDefault(), n ? e.shown.length && pl(e, Math.max(e.active - 1, 0)) : dl(e, "");
9864
+ t.preventDefault(), n ? e.shown.length && ml(e, Math.max(e.active - 1, 0)) : fl(e, "");
9855
9865
  break;
9856
9866
  case "Enter":
9857
- n && (t.preventDefault(), t.stopImmediatePropagation(), e.active >= 0 ? ml(e, e.shown[e.active]) : fl(e));
9867
+ n && (t.preventDefault(), t.stopImmediatePropagation(), e.active >= 0 ? hl(e, e.shown[e.active]) : pl(e));
9858
9868
  break;
9859
9869
  case "Escape":
9860
- n && (t.preventDefault(), t.stopPropagation(), fl(e)), e.input.value = ul(e.select), e.input.select();
9870
+ n && (t.preventDefault(), t.stopPropagation(), pl(e)), e.input.value = dl(e.select), e.input.select();
9861
9871
  break;
9862
- case "Tab": n && fl(e);
9872
+ case "Tab": n && pl(e);
9863
9873
  }
9864
9874
  }
9865
- function gl(e, t, n) {
9875
+ function _l(e, t, n) {
9866
9876
  for (let [r, i] of Object.entries(t)) {
9867
9877
  if (!i.conditions) continue;
9868
- let t = Vs(i.conditions, n), a = Array.from(e.querySelectorAll("input, select, textarea, [data-field-name]")).concat(cc(e)).filter((e) => (e.getAttribute("name") ?? e.getAttribute("data-field-name")) === r);
9878
+ let t = Vs(i.conditions, n), a = Array.from(e.querySelectorAll("input, select, textarea, [data-field-name]")).concat(lc(e)).filter((e) => (e.getAttribute("name") ?? e.getAttribute("data-field-name")) === r);
9869
9879
  for (let e of a) {
9870
9880
  let n = e.closest(".formdown-field") ?? e;
9871
9881
  n.hidden = !t.visible;
9872
9882
  let r = !!i.required || t.required;
9873
- e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement ? (e.disabled = !t.enabled, e instanceof HTMLInputElement && (e.type === "radio" || e.type === "checkbox") || (e.required = r)) : sc(e) ? fc(e, t.enabled, r) : e.setAttribute("contenteditable", t.enabled ? "true" : "false"), e.setAttribute("aria-disabled", String(!t.enabled)), e.setAttribute("aria-required", String(r));
9883
+ e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement ? (e.disabled = !t.enabled, e instanceof HTMLInputElement && (e.type === "radio" || e.type === "checkbox") || (e.required = r)) : cc(e) ? pc(e, t.enabled, r) : e.setAttribute("contenteditable", t.enabled ? "true" : "false"), e.setAttribute("aria-disabled", String(!t.enabled)), e.setAttribute("aria-required", String(r));
9874
9884
  }
9875
9885
  }
9876
9886
  }
9877
- function _l(e) {
9887
+ function vl(e) {
9878
9888
  let t = /* @__PURE__ */ new Map();
9879
9889
  for (let [n, r] of Object.entries(e ?? {})) {
9880
9890
  if (!r.compute) continue;
@@ -9883,7 +9893,7 @@ function _l(e) {
9883
9893
  }
9884
9894
  return t;
9885
9895
  }
9886
- function vl(e, t) {
9896
+ function yl(e, t) {
9887
9897
  let n = { ...t }, r = {};
9888
9898
  for (let [t, i] of e) {
9889
9899
  let e = i.evaluate(n), a = e === void 0 ? "" : String(e);
@@ -9891,7 +9901,7 @@ function vl(e, t) {
9891
9901
  }
9892
9902
  return r;
9893
9903
  }
9894
- var yl = h`
9904
+ var bl = h`
9895
9905
  :host {
9896
9906
  display: block;
9897
9907
  font-family: var(--formdown-font-family, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
@@ -10723,11 +10733,11 @@ var yl = h`
10723
10733
  }
10724
10734
  }
10725
10735
  `;
10726
- function bl(e) {
10736
+ function xl(e) {
10727
10737
  let t = [...new Set(Object.values(e ?? {}).map((e) => e.type))];
10728
10738
  return j().getFieldTypeRegistry().getStylesForTypes(t);
10729
10739
  }
10730
- var xl = class {
10740
+ var Sl = class {
10731
10741
  constructor(e) {
10732
10742
  this.css = "", this.root = e;
10733
10743
  }
@@ -10743,17 +10753,17 @@ var xl = class {
10743
10753
  adoptable() {
10744
10754
  return "adoptedStyleSheets" in this.root && typeof CSSStyleSheet < "u" && "replaceSync" in CSSStyleSheet.prototype;
10745
10755
  }
10746
- }, Sl = "data-formdown-error-for", Cl = "data-formdown-described-by", wl = "field-error";
10747
- function Tl(e, t) {
10756
+ }, Cl = "data-formdown-error-for", wl = "data-formdown-described-by", Tl = "field-error";
10757
+ function El(e, t) {
10748
10758
  let n = Array.from(e.querySelectorAll("[name]")).filter((e) => e.getAttribute("name") === t);
10749
10759
  if (n.length > 0) return n;
10750
10760
  let r = Array.from(e.querySelectorAll("[data-field-name]")).find((e) => e.dataset.fieldName === t);
10751
10761
  return r ? [r] : [];
10752
10762
  }
10753
- function El(e) {
10763
+ function Dl(e) {
10754
10764
  return e.isContentEditable || e.getAttribute("contenteditable") === "true";
10755
10765
  }
10756
- function Dl(e) {
10766
+ function Ol(e) {
10757
10767
  let t = /* @__PURE__ */ new Map();
10758
10768
  for (let { field: n, message: r } of e) {
10759
10769
  let e = t.get(n) ?? [];
@@ -10761,37 +10771,37 @@ function Dl(e) {
10761
10771
  }
10762
10772
  return t;
10763
10773
  }
10764
- function Ol(e, t) {
10765
- for (let n of Array.from(e.querySelectorAll(`[${Sl}]`))) (t === void 0 || n.getAttribute(Sl) === t) && n.remove();
10766
- let n = Array.from(e.querySelectorAll(`[${Cl}]`));
10774
+ function kl(e, t) {
10775
+ for (let n of Array.from(e.querySelectorAll(`[${Cl}]`))) (t === void 0 || n.getAttribute(Cl) === t) && n.remove();
10776
+ let n = Array.from(e.querySelectorAll(`[${wl}]`));
10767
10777
  for (let e of n) {
10768
10778
  if (t !== void 0 && (e.getAttribute("name") ?? e.dataset.fieldName) !== t) continue;
10769
- let n = e.getAttribute(Cl);
10770
- n ? e.setAttribute("aria-describedby", n) : e.removeAttribute("aria-describedby"), e.removeAttribute(Cl), e.removeAttribute("aria-invalid"), e.classList.remove(wl), e.classList.length === 0 && e.removeAttribute("class");
10779
+ let n = e.getAttribute(wl);
10780
+ n ? e.setAttribute("aria-describedby", n) : e.removeAttribute("aria-describedby"), e.removeAttribute(wl), e.removeAttribute("aria-invalid"), e.classList.remove(Tl), e.classList.length === 0 && e.removeAttribute("class");
10771
10781
  }
10772
10782
  }
10773
- function kl(e, t, n) {
10774
- Ol(e, t);
10775
- let r = Tl(e, t), i = r[0];
10783
+ function Al(e, t, n) {
10784
+ kl(e, t);
10785
+ let r = El(e, t), i = r[0];
10776
10786
  if (!i || n.length === 0) return;
10777
- let a = El(i), o = i.ownerDocument.createElement(a ? "span" : "div");
10778
- o.className = "validation-error-message", o.setAttribute("part", "field-error"), o.setAttribute(Sl, t), o.id = `${i.id || `formdown-${t}`}-validation`, o.textContent = n.join("\n");
10779
- for (let e of r) e.setAttribute(Cl, e.getAttribute("aria-describedby") ?? ""), e.setAttribute("aria-describedby", [e.getAttribute("aria-describedby"), o.id].filter(Boolean).join(" ")), e.setAttribute("aria-invalid", "true"), e.classList.add(wl);
10787
+ let a = Dl(i), o = i.ownerDocument.createElement(a ? "span" : "div");
10788
+ o.className = "validation-error-message", o.setAttribute("part", "field-error"), o.setAttribute(Cl, t), o.id = `${i.id || `formdown-${t}`}-validation`, o.textContent = n.join("\n");
10789
+ for (let e of r) e.setAttribute(wl, e.getAttribute("aria-describedby") ?? ""), e.setAttribute("aria-describedby", [e.getAttribute("aria-describedby"), o.id].filter(Boolean).join(" ")), e.setAttribute("aria-invalid", "true"), e.classList.add(Tl);
10780
10790
  a ? i.after(o) : (i.closest(".formdown-field") ?? i.parentElement ?? i).append(o);
10781
10791
  }
10782
- function Al(e, t) {
10783
- Ol(e);
10784
- for (let [n, r] of t) kl(e, n, r);
10792
+ function jl(e, t) {
10793
+ kl(e);
10794
+ for (let [n, r] of t) Al(e, n, r);
10785
10795
  }
10786
- function jl(e, t, n, r) {
10796
+ function Ml(e, t, n, r) {
10787
10797
  var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
10788
10798
  if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
10789
10799
  else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
10790
10800
  return i > 3 && a && Object.defineProperty(t, n, a), a;
10791
10801
  }
10792
- var Ml = class extends Ge {
10802
+ var Nl = class extends Ge {
10793
10803
  static {
10794
- this.styles = yl;
10804
+ this.styles = bl;
10795
10805
  }
10796
10806
  get data() {
10797
10807
  return this._data;
@@ -10806,7 +10816,7 @@ var Ml = class extends Ge {
10806
10816
  }
10807
10817
  focusField(e) {
10808
10818
  let t = this.shadowRoot?.querySelector("#content-container");
10809
- return t ? Zc(t, e) : !1;
10819
+ return t ? Qc(t, e) : !1;
10810
10820
  }
10811
10821
  updateField(e, t) {
10812
10822
  this.data = {
@@ -10818,7 +10828,7 @@ var Ml = class extends Ge {
10818
10828
  await this.extensionsReady, super.scheduleUpdate();
10819
10829
  }
10820
10830
  constructor() {
10821
- super(), this.content = "", this.bodyHtml = "trust", this.fieldStates = {}, this.choices = {}, this.filterSelectAbove = 20, this.messages = {}, this.shownErrors = /* @__PURE__ */ new Set(), this._data = {}, this.fieldRegistry = /* @__PURE__ */ new Map(), this._isUpdatingUI = !1, this._schema = null, this.computed = /* @__PURE__ */ new Map(), this.formManager = new ac(), this.domBinder = this.formManager.createDOMBinder(), this.setupCoreUIBridge(), this.setupFormManagerEvents();
10831
+ super(), this.content = "", this.bodyHtml = "trust", this.fieldStates = {}, this.choices = {}, this.filterSelectAbove = 20, this.messages = {}, this.shownErrors = /* @__PURE__ */ new Set(), this._data = {}, this.fieldRegistry = /* @__PURE__ */ new Map(), this._isUpdatingUI = !1, this._schema = null, this.computed = /* @__PURE__ */ new Map(), this.formManager = new oc(), this.domBinder = this.formManager.createDOMBinder(), this.setupCoreUIBridge(), this.setupFormManagerEvents();
10822
10832
  }
10823
10833
  setupCoreUIBridge() {
10824
10834
  this.formManager.setupComponentBridge({
@@ -10854,15 +10864,15 @@ var Ml = class extends Ge {
10854
10864
  isValid: !0,
10855
10865
  errors: []
10856
10866
  };
10857
- let e = this.formManager.validate({ messages: this.messages }), t = Dl(e.errors), n = this.shadowRoot?.querySelector("#content-container");
10858
- return n && Al(n, t), this.shownErrors = new Set(t.keys()), e;
10867
+ let e = this.formManager.validate({ messages: this.messages }), t = Ol(e.errors), n = this.shadowRoot?.querySelector("#content-container");
10868
+ return n && jl(n, t), this.shownErrors = new Set(t.keys()), e;
10859
10869
  }
10860
10870
  recheckShownErrors() {
10861
10871
  if (this.shownErrors.size === 0 || !this._schema) return;
10862
10872
  let e = this.shadowRoot?.querySelector("#content-container");
10863
10873
  if (!e) return;
10864
- let t = Dl($s(this.formManager.getData(), this._schema, { messages: this.messages }).errors), n = new Map([...t].filter(([e]) => this.shownErrors.has(e)));
10865
- Al(e, n), this.shownErrors = new Set(n.keys());
10874
+ let t = Ol(ec(this.formManager.getData(), this._schema, { messages: this.messages }).errors), n = new Map([...t].filter(([e]) => this.shownErrors.has(e)));
10875
+ jl(e, n), this.shownErrors = new Set(n.keys());
10866
10876
  }
10867
10877
  getSchema() {
10868
10878
  return this._schema;
@@ -10879,7 +10889,7 @@ var Ml = class extends Ge {
10879
10889
  render() {
10880
10890
  if (!this.content || !this.content.trim()) return De`<div class="error">No Formdown content provided</div>`;
10881
10891
  try {
10882
- this.formManager.parse(this.content), this._schema = this.formManager.getSchema(), this.computed = _l(this._schema), this.data && Object.keys(this.data).length > 0 && this.formManager.updateData(this.data);
10892
+ this.formManager.parse(this.content), this._schema = this.formManager.getSchema(), this.computed = vl(this._schema), this.data && Object.keys(this.data).length > 0 && this.formManager.updateData(this.data);
10883
10893
  let e = this.formManager.renderToTemplate({
10884
10894
  container: this,
10885
10895
  html: this.bodyHtml
@@ -10899,12 +10909,12 @@ var Ml = class extends Ge {
10899
10909
  this.syncUIFromData();
10900
10910
  }, 0)), e.has("data") && this.syncUIFromData(), (e.has("data") || e.has("messages")) && !e.has("content") && this.recheckShownErrors(), e.has("fieldStates") && !e.has("content") && this.drawFieldStates(), e.has("choices") && !e.has("content") && !e.has("data") && this.syncUIFromData(), e.has("filterSelectAbove") && !e.has("content")) {
10901
10911
  let e = this.shadowRoot?.querySelector("#content-container");
10902
- e && rl(e, this.filterSelectAbove);
10912
+ e && il(e, this.filterSelectAbove);
10903
10913
  }
10904
10914
  }
10905
10915
  drawFieldStates() {
10906
10916
  let e = this.shadowRoot?.querySelector("#content-container");
10907
- e && Uc(e, this.fieldStates ?? {}, {
10917
+ e && Wc(e, this.fieldStates ?? {}, {
10908
10918
  onPick: (e, t) => this.dispatchEvent(new CustomEvent("formdown-suggestion-pick", {
10909
10919
  detail: {
10910
10920
  field: e,
@@ -10924,7 +10934,7 @@ var Ml = class extends Ge {
10924
10934
  if (this.content && this.content.trim()) try {
10925
10935
  let e = this.shadowRoot?.querySelector("#content-container");
10926
10936
  if (!e) return;
10927
- this.formManager.parse(this.content), this._schema = this.formManager.getSchema(), this.computed = _l(this._schema), this.fieldTypeSheet ??= new xl(this.shadowRoot), this.fieldTypeSheet.set(bl(this._schema)), this.data && Object.keys(this.data).length > 0 && this.formManager.updateData(this.data);
10937
+ this.formManager.parse(this.content), this._schema = this.formManager.getSchema(), this.computed = vl(this._schema), this.fieldTypeSheet ??= new Sl(this.shadowRoot), this.fieldTypeSheet.set(xl(this._schema)), this.data && Object.keys(this.data).length > 0 && this.formManager.updateData(this.data);
10928
10938
  let t = this.formManager.renderToTemplate({
10929
10939
  container: this,
10930
10940
  html: this.bodyHtml
@@ -10953,14 +10963,14 @@ var Ml = class extends Ge {
10953
10963
  let t = e, n = this.getFieldName(t);
10954
10964
  n && (this.registerField(n, t), this.setupFieldEventHandlers(t, n));
10955
10965
  }), this.setupCustomControls(e);
10956
- for (let t of lc(e)) customElements.whenDefined(t).then(() => {
10966
+ for (let t of uc(e)) customElements.whenDefined(t).then(() => {
10957
10967
  e.isConnected && (this.setupCustomControls(e), this.syncUIFromData());
10958
10968
  });
10959
10969
  let t = e.querySelectorAll("input:not([type=\"radio\"]):not([type=\"checkbox\"]), [contenteditable=\"true\"]");
10960
10970
  this.setupBasicKeyboardNavigation(t);
10961
10971
  }
10962
10972
  setupCustomControls(e) {
10963
- for (let t of cc(e)) {
10973
+ for (let t of lc(e)) {
10964
10974
  let e = t.getAttribute("name");
10965
10975
  this.fieldRegistry.get(e)?.has(t) || (this.registerField(e, t), this.setupFieldEventHandlers(t, e));
10966
10976
  }
@@ -10980,14 +10990,28 @@ var Ml = class extends Ge {
10980
10990
  setupFieldEventHandlers(e, t) {
10981
10991
  this.domBinder.bindFieldToElement(t, e);
10982
10992
  let n = (n) => {
10993
+ if (e instanceof HTMLInputElement && e.type === "file") {
10994
+ if (n.type === "change") {
10995
+ let n = Array.from(e.files ?? []);
10996
+ this.dispatchEvent(new CustomEvent("formdown-file-pick", {
10997
+ detail: {
10998
+ field: t,
10999
+ files: n
11000
+ },
11001
+ bubbles: !0,
11002
+ composed: !0
11003
+ }));
11004
+ }
11005
+ return;
11006
+ }
10983
11007
  let r = this.data[t];
10984
11008
  this.formManager.handleUIEvent(n, this.domBinder);
10985
11009
  let i = this.getFieldValueFromElement(e);
10986
- Nl(r, i) || this.updateDataReactively(t, i);
11010
+ Pl(r, i) || this.updateDataReactively(t, i);
10987
11011
  };
10988
11012
  e.addEventListener("input", n), e.addEventListener("change", n), e.addEventListener("focus", (e) => {
10989
11013
  let t = e.target;
10990
- Yc.delete(t) || (t.hasAttribute("contenteditable") && setTimeout(() => {
11014
+ Xc.delete(t) || (t.hasAttribute("contenteditable") && setTimeout(() => {
10991
11015
  let e = document.createRange(), n = window.getSelection();
10992
11016
  n && t.textContent && (e.selectNodeContents(t), n.removeAllRanges(), n.addRange(e));
10993
11017
  }, 0), t instanceof HTMLInputElement && t.type !== "file" && t.type !== "checkbox" && t.type !== "radio" && setTimeout(() => {
@@ -11005,7 +11029,7 @@ var Ml = class extends Ge {
11005
11029
  }, this.emitFieldEvents(e, t));
11006
11030
  }
11007
11031
  followComputed() {
11008
- let e = vl(this.computed, this.formManager.getData());
11032
+ let e = yl(this.computed, this.formManager.getData());
11009
11033
  for (let [t, n] of Object.entries(e)) this.formManager.setFieldValue(t, n);
11010
11034
  return e;
11011
11035
  }
@@ -11014,11 +11038,11 @@ var Ml = class extends Ge {
11014
11038
  this._isUpdatingUI = !0;
11015
11039
  try {
11016
11040
  let e = this.shadowRoot?.activeElement, t = this.shadowRoot?.querySelector("#content-container");
11017
- if (t) for (let e of [...Tc(t, this.choices ?? {}), ...hc(t, this.data)]) this.registerField(e.name, e), this.setupFieldEventHandlers(e, e.name);
11041
+ if (t) for (let e of [...Ec(t, this.choices ?? {}), ...gc(t, this.data)]) this.registerField(e.name, e), this.setupFieldEventHandlers(e, e.name);
11018
11042
  this.domBinder.getValueAssignments(this.data).forEach(({ element: t, value: n, fieldType: r }) => {
11019
11043
  let i = t;
11020
- i !== e && mc(i, n, r);
11021
- }), t && xc(t, this.data), t && this._schema && gl(t, this._schema, this.data), t && rl(t, this.filterSelectAbove), t && Bc(t);
11044
+ i !== e && hc(i, n, r);
11045
+ }), t && Sc(t, this.data), t && this._schema && _l(t, this._schema, this.data), t && il(t, this.filterSelectAbove), t && Vc(t);
11022
11046
  } finally {
11023
11047
  this._isUpdatingUI = !1, this.domBinder.releaseSyncLock();
11024
11048
  }
@@ -11028,7 +11052,7 @@ var Ml = class extends Ge {
11028
11052
  return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? e.name || e.id || null : e.dataset.fieldName || e.id || null;
11029
11053
  }
11030
11054
  getFieldValueFromElement(e) {
11031
- if (sc(e)) return uc(e);
11055
+ if (cc(e)) return dc(e);
11032
11056
  if (e instanceof HTMLInputElement) {
11033
11057
  if (e.type === "checkbox") {
11034
11058
  let t = e.name, n = this.formManager.createFieldProcessor().processCheckboxGroup(t, {
@@ -11067,12 +11091,15 @@ var Ml = class extends Ge {
11067
11091
  getFormData() {
11068
11092
  return this.formManager.getData();
11069
11093
  }
11094
+ getConditionStates() {
11095
+ return this.formManager.getConditionStates();
11096
+ }
11070
11097
  getDefaultValues() {
11071
11098
  return this.formManager.getDefaultValues();
11072
11099
  }
11073
11100
  clearValidationStates() {
11074
11101
  let e = this.shadowRoot?.querySelector("#content-container");
11075
- e && (Ol(e), this.shownErrors.clear());
11102
+ e && (kl(e), this.shownErrors.clear());
11076
11103
  }
11077
11104
  resetForm() {
11078
11105
  this.formManager.reset(), this.data = this.formManager.getData(), this.clearValidationStates();
@@ -11086,33 +11113,33 @@ var Ml = class extends Ge {
11086
11113
  let n = t.querySelector(`[data-field-name="${CSS.escape(e)}"]`) ?? t.querySelector(`#${CSS.escape(e)}`);
11087
11114
  r = n ? [n] : [];
11088
11115
  }
11089
- for (let e of r) mc(e, n, e instanceof HTMLInputElement ? e.type : e.dataset.fieldType ?? "text"), e.dispatchEvent(new Event("input", { bubbles: !0 }));
11116
+ for (let e of r) hc(e, n, e instanceof HTMLInputElement ? e.type : e.dataset.fieldType ?? "text"), e.dispatchEvent(new Event("input", { bubbles: !0 }));
11090
11117
  }), this.data = { ...e });
11091
11118
  }
11092
11119
  };
11093
- jl([O()], Ml.prototype, "content", void 0), jl([O({ attribute: "body-html" })], Ml.prototype, "bodyHtml", void 0), jl([O({ attribute: !1 })], Ml.prototype, "fieldStates", void 0), jl([O({ attribute: !1 })], Ml.prototype, "choices", void 0), jl([O({
11120
+ Ml([O()], Nl.prototype, "content", void 0), Ml([O({ attribute: "body-html" })], Nl.prototype, "bodyHtml", void 0), Ml([O({ attribute: !1 })], Nl.prototype, "fieldStates", void 0), Ml([O({ attribute: !1 })], Nl.prototype, "choices", void 0), Ml([O({
11094
11121
  attribute: "filter-select-above",
11095
11122
  type: Number
11096
- })], Ml.prototype, "filterSelectAbove", void 0), jl([O({ attribute: !1 })], Ml.prototype, "messages", void 0), jl([O({ type: Object })], Ml.prototype, "data", null), Ml = jl([qe("formdown-ui")], Ml);
11097
- function Nl(e, t) {
11123
+ })], Nl.prototype, "filterSelectAbove", void 0), Ml([O({ attribute: !1 })], Nl.prototype, "messages", void 0), Ml([O({ type: Object })], Nl.prototype, "data", null), Nl = Ml([qe("formdown-ui")], Nl);
11124
+ function Pl(e, t) {
11098
11125
  if (Array.isArray(t)) {
11099
11126
  let n = Array.isArray(e) ? e.map(String) : e == null ? [] : [String(e)];
11100
11127
  return n.length === t.length && n.every((e, n) => e === t[n]);
11101
11128
  }
11102
- return e == null ? t === "" || t === !1 : typeof t == "boolean" ? pc(e) === t : String(e) === t;
11129
+ return e == null ? t === "" || t === !1 : typeof t == "boolean" ? mc(e) === t : String(e) === t;
11103
11130
  }
11104
11131
  // \0@oxc-project+runtime@0.155.0/helpers/esm/decorate.js
11105
- function Pl(e, t, n, r) {
11132
+ function Fl(e, t, n, r) {
11106
11133
  var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
11107
11134
  if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
11108
11135
  else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
11109
11136
  return i > 3 && a && Object.defineProperty(t, n, a), a;
11110
11137
  }
11111
11138
  // src/lowline-form.ts
11112
- var Fl = 300, $ = class extends Ge {
11139
+ var Il = 300, $ = class extends Ge {
11113
11140
  constructor(...e) {
11114
11141
  super(...e), this.src = "/lowline", this.form = "", this.record = "", this.content = "", this.data = {}, this.rate = .05, this.strings = i, this.client = new c(this.src), this.fieldStates = {}, this.canJudge = !0, this.changed = () => {
11115
- clearTimeout(this.asking), this.asking = setTimeout(() => void this.ask(), Fl);
11142
+ clearTimeout(this.asking), this.asking = setTimeout(() => void this.ask(), Il);
11116
11143
  }, this.picked = (e) => {
11117
11144
  let { field: t, value: n } = e.detail;
11118
11145
  this.session?.picked(t);
@@ -11216,5 +11243,5 @@ var Fl = 300, $ = class extends Ge {
11216
11243
  super.disconnectedCallback(), clearTimeout(this.asking);
11217
11244
  }
11218
11245
  };
11219
- Pl([O()], $.prototype, "src", void 0), Pl([O()], $.prototype, "form", void 0), Pl([O()], $.prototype, "record", void 0), Pl([O()], $.prototype, "content", void 0), Pl([O({ attribute: !1 })], $.prototype, "data", void 0), Pl([O({ type: Number })], $.prototype, "rate", void 0), Pl([O({ attribute: !1 })], $.prototype, "strings", void 0), Pl([Ze("formdown-ui")], $.prototype, "formdown", void 0), $ = Pl([qe("lowline-form")], $);
11246
+ Fl([O()], $.prototype, "src", void 0), Fl([O()], $.prototype, "form", void 0), Fl([O()], $.prototype, "record", void 0), Fl([O()], $.prototype, "content", void 0), Fl([O({ attribute: !1 })], $.prototype, "data", void 0), Fl([O({ type: Number })], $.prototype, "rate", void 0), Fl([O({ attribute: !1 })], $.prototype, "strings", void 0), Fl([Ze("formdown-ui")], $.prototype, "formdown", void 0), $ = Fl([qe("lowline-form")], $);
11220
11247
  export { e as Draft, c as LowlineClient, s as LowlineError, $ as LowlineForm, a as Session, i as englishStrings, r as valuesOf };
package/dist/session.d.ts CHANGED
@@ -10,7 +10,7 @@ export type Basis = {
10
10
  similarity: number;
11
11
  };
12
12
  /** Why a decided field is shown no suggestion. */
13
- export type Abstain = 'off' | 'no-evidence' | 'unsure' | 'not-allowed' | 'needs-judgement' | 'not-a-choice' | 'malformed';
13
+ export type Abstain = 'off' | 'no-evidence' | 'unsure' | 'not-allowed' | 'needs-judgement' | 'not-a-choice' | 'malformed' | 'together';
14
14
  /** What the host's engine says to show for one decided field. */
15
15
  export interface Proposal {
16
16
  field: string;
@@ -21,6 +21,8 @@ export interface Proposal {
21
21
  basis?: Basis[];
22
22
  abstain: Abstain | null;
23
23
  asks?: [string, string][];
24
+ /** For `together`: the fields of its group, still open, that are shown no suggestion. */
25
+ with?: string[];
24
26
  /**
25
27
  * How often an answer of this kind for this field has been right — the replay's precision at the threshold the
26
28
  * suggestion was held to. Absent with no suggestion, for a judgement or a value from elsewhere, and before thresholds
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iyulab/lowline-form",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "The Lowline form element: a formdown form whose decided fields are suggested from the records people confirmed, talking to a Lowline host's routes.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,7 +40,7 @@
40
40
  "bundle": "vite build --config vite.bundle.config.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@formdown/ui": "^0.24.0",
43
+ "@formdown/ui": "^0.25.0",
44
44
  "lit": "^3.3.3"
45
45
  },
46
46
  "devDependencies": {