bhl-forms 0.0.32 → 0.0.35

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.
@@ -4804,8 +4804,8 @@ const invalidSetter$1 = (node, _context, property) => {
4804
4804
  reset: trap$1(resetValue$1),
4805
4805
  resetConfig: trap$1(resetConfig$1),
4806
4806
  setErrors: trap$1(setErrors$1$1),
4807
- submit: trap$1(submit$3),
4808
- t: trap$1(text$3),
4807
+ submit: trap$1(submit$1),
4808
+ t: trap$1(text$2),
4809
4809
  use: trap$1(use$1),
4810
4810
  name: trap$1(getName$1, false, false),
4811
4811
  walk: trap$1(walkTree$1)
@@ -5151,12 +5151,12 @@ function getNode$2(node, _context, locator) {
5151
5151
  pointer = node;
5152
5152
  break;
5153
5153
  default:
5154
- pointer = pointer.children.find((c2) => String(c2.name) === String(name)) || select$4(pointer, name);
5154
+ pointer = pointer.children.find((c2) => String(c2.name) === String(name)) || select$3(pointer, name);
5155
5155
  }
5156
5156
  }
5157
5157
  return pointer || void 0;
5158
5158
  }
5159
- function select$4(node, selector) {
5159
+ function select$3(node, selector) {
5160
5160
  const matches3 = String(selector).match(/^(find)\((.*)\)$/);
5161
5161
  if (matches3) {
5162
5162
  const [, action, argStr] = matches3;
@@ -5174,11 +5174,11 @@ function find$1(node, _context, searchTerm, searcher) {
5174
5174
  return bfs$1(node, searchTerm, searcher);
5175
5175
  }
5176
5176
  function bfs$1(tree, searchValue, searchGoal = "name") {
5177
- const search2 = typeof searchGoal === "string" ? (n2) => n2[searchGoal] == searchValue : searchGoal;
5177
+ const search = typeof searchGoal === "string" ? (n2) => n2[searchGoal] == searchValue : searchGoal;
5178
5178
  const stack = [tree];
5179
5179
  while (stack.length) {
5180
5180
  const node = stack.shift();
5181
- if (search2(node, searchValue))
5181
+ if (search(node, searchValue))
5182
5182
  return node;
5183
5183
  stack.push(...node.children);
5184
5184
  }
@@ -5243,13 +5243,13 @@ function createConfig$2(target = {}, parent) {
5243
5243
  }
5244
5244
  });
5245
5245
  }
5246
- function text$3(node, _context, key, type = "ui") {
5246
+ function text$2(node, _context, key, type = "ui") {
5247
5247
  const fragment2 = typeof key === "string" ? { key, value: key, type } : key;
5248
5248
  const value = node.hook.text.dispatch(fragment2);
5249
5249
  node.emit("text", value, false);
5250
5250
  return value.value;
5251
5251
  }
5252
- function submit$3(node) {
5252
+ function submit$1(node) {
5253
5253
  const name = node.name;
5254
5254
  do {
5255
5255
  if (node.props.isForm === true)
@@ -5267,15 +5267,16 @@ function resetValue$1(node, _context, value) {
5267
5267
  }
5268
5268
  function setErrors$1$1(node, _context, localErrors, childErrors) {
5269
5269
  const sourceKey = `${node.name}-set`;
5270
- createMessages$1(node, localErrors, childErrors).forEach((errors2) => {
5271
- node.store.apply(errors2, (message2) => message2.meta.source === sourceKey);
5270
+ const errors2 = node.hook.setErrors.dispatch({ localErrors, childErrors });
5271
+ createMessages$1(node, errors2.localErrors, errors2.childErrors).forEach((errors22) => {
5272
+ node.store.apply(errors22, (message2) => message2.meta.source === sourceKey);
5272
5273
  });
5273
5274
  return node;
5274
5275
  }
5275
- function clearErrors$1$1(node, context, clearChildErrors = true) {
5276
+ function clearErrors$1$1(node, context, clearChildErrors = true, sourceKey) {
5276
5277
  setErrors$1$1(node, context, []);
5277
5278
  if (clearChildErrors) {
5278
- const sourceKey = `${node.name}-set`;
5279
+ sourceKey = sourceKey || `${node.name}-set`;
5279
5280
  node.walk((child) => {
5280
5281
  child.store.filter((message2) => {
5281
5282
  return !(message2.type === "error" && message2.meta && message2.meta.source === sourceKey);
@@ -6452,8 +6453,8 @@ const traps = {
6452
6453
  reset: trap(resetValue),
6453
6454
  resetConfig: trap(resetConfig),
6454
6455
  setErrors: trap(setErrors$1),
6455
- submit: trap(submit$2),
6456
- t: trap(text$2),
6456
+ submit: trap(submit),
6457
+ t: trap(text$1),
6457
6458
  use: trap(use),
6458
6459
  name: trap(getName, false, false),
6459
6460
  walk: trap(walkTree)
@@ -6821,12 +6822,12 @@ function getNode(node, _context, locator) {
6821
6822
  pointer = node;
6822
6823
  break;
6823
6824
  default:
6824
- pointer = pointer.children.find((c2) => String(c2.name) === String(name)) || select$3(pointer, name);
6825
+ pointer = pointer.children.find((c2) => String(c2.name) === String(name)) || select$2(pointer, name);
6825
6826
  }
6826
6827
  }
6827
6828
  return pointer || void 0;
6828
6829
  }
6829
- function select$3(node, selector) {
6830
+ function select$2(node, selector) {
6830
6831
  const matches3 = String(selector).match(/^(find)\((.*)\)$/);
6831
6832
  if (matches3) {
6832
6833
  const [, action, argStr] = matches3;
@@ -6844,11 +6845,11 @@ function find(node, _context, searchTerm, searcher) {
6844
6845
  return bfs(node, searchTerm, searcher);
6845
6846
  }
6846
6847
  function bfs(tree, searchValue, searchGoal = "name") {
6847
- const search2 = typeof searchGoal === "string" ? (n2) => n2[searchGoal] == searchValue : searchGoal;
6848
+ const search = typeof searchGoal === "string" ? (n2) => n2[searchGoal] == searchValue : searchGoal;
6848
6849
  const stack = [tree];
6849
6850
  while (stack.length) {
6850
6851
  const node = stack.shift();
6851
- if (search2(node, searchValue))
6852
+ if (search(node, searchValue))
6852
6853
  return node;
6853
6854
  stack.push(...node.children);
6854
6855
  }
@@ -6913,13 +6914,13 @@ function createConfig(target = {}, parent) {
6913
6914
  }
6914
6915
  });
6915
6916
  }
6916
- function text$2(node, _context, key, type = "ui") {
6917
+ function text$1(node, _context, key, type = "ui") {
6917
6918
  const fragment2 = typeof key === "string" ? { key, value: key, type } : key;
6918
6919
  const value = node.hook.text.dispatch(fragment2);
6919
6920
  node.emit("text", value, false);
6920
6921
  return value.value;
6921
6922
  }
6922
- function submit$2(node) {
6923
+ function submit(node) {
6923
6924
  const name = node.name;
6924
6925
  do {
6925
6926
  if (node.props.isForm === true)
@@ -6937,15 +6938,16 @@ function resetValue(node, _context, value) {
6937
6938
  }
6938
6939
  function setErrors$1(node, _context, localErrors, childErrors) {
6939
6940
  const sourceKey = `${node.name}-set`;
6940
- createMessages(node, localErrors, childErrors).forEach((errors2) => {
6941
- node.store.apply(errors2, (message2) => message2.meta.source === sourceKey);
6941
+ const errors2 = node.hook.setErrors.dispatch({ localErrors, childErrors });
6942
+ createMessages(node, errors2.localErrors, errors2.childErrors).forEach((errors3) => {
6943
+ node.store.apply(errors3, (message2) => message2.meta.source === sourceKey);
6942
6944
  });
6943
6945
  return node;
6944
6946
  }
6945
- function clearErrors$1(node, context, clearChildErrors = true) {
6947
+ function clearErrors$1(node, context, clearChildErrors = true, sourceKey) {
6946
6948
  setErrors$1(node, context, []);
6947
6949
  if (clearChildErrors) {
6948
- const sourceKey = `${node.name}-set`;
6950
+ sourceKey = sourceKey || `${node.name}-set`;
6949
6951
  node.walk((child) => {
6950
6952
  child.store.filter((message2) => {
6951
6953
  return !(message2.type === "error" && message2.meta && message2.meta.source === sourceKey);
@@ -7112,11 +7114,11 @@ function sugar(node) {
7112
7114
  };
7113
7115
  }
7114
7116
  if (isSugar(node)) {
7115
- const _a = node, { $formkit: type, for: iterator, if: condition, children, key, bind } = _a, props2 = __objRest(_a, ["$formkit", "for", "if", "children", "key", "bind"]);
7117
+ const _a = node, { $formkit: type, for: iterator, if: condition, children, bind } = _a, props2 = __objRest(_a, ["$formkit", "for", "if", "children", "bind"]);
7116
7118
  return Object.assign({
7117
7119
  $cmp: "FormKit",
7118
7120
  props: __spreadProps(__spreadValues({}, props2), { type })
7119
- }, condition ? { if: condition } : {}, iterator ? { for: iterator } : {}, children ? { children } : {}, key ? { key } : {}, bind ? { bind } : {});
7121
+ }, condition ? { if: condition } : {}, iterator ? { for: iterator } : {}, children ? { children } : {}, bind ? { bind } : {});
7120
7122
  }
7121
7123
  return node;
7122
7124
  }
@@ -7430,143 +7432,158 @@ function clearErrors(id, clearChildren = true) {
7430
7432
  warn(652, id);
7431
7433
  }
7432
7434
  }
7433
- const outer = composable("outer", () => ({
7435
+ const FORMKIT_VERSION = "1.0.0-beta.9";
7436
+ function createLibraryPlugin(...libraries) {
7437
+ const library = libraries.reduce((merged, lib) => extend(merged, lib), {});
7438
+ const plugin2 = () => {
7439
+ };
7440
+ plugin2.library = function(node) {
7441
+ const type = camel(node.props.type);
7442
+ if (has(library, type)) {
7443
+ node.define(library[type]);
7444
+ }
7445
+ };
7446
+ return plugin2;
7447
+ }
7448
+ const outer = createSection("outer", () => ({
7434
7449
  $el: "div",
7435
7450
  attrs: {
7436
- class: "$classes.outer",
7451
+ key: "$id",
7437
7452
  "data-type": "$type",
7438
7453
  "data-multiple": "$attrs.multiple",
7439
7454
  "data-disabled": "$disabled || undefined",
7440
7455
  "data-complete": "$state.complete || undefined",
7441
7456
  "data-invalid": "$state.valid === false && $state.validationVisible || undefined",
7442
7457
  "data-errors": "$state.errors || undefined",
7443
- "data-submitted": "$state.submitted || undefined"
7458
+ "data-submitted": "$state.submitted || undefined",
7459
+ "data-prefix-icon": "$_rawPrefixIcon !== undefined || undefined",
7460
+ "data-suffix-icon": "$_rawSuffixIcon !== undefined || undefined",
7461
+ "data-prefix-icon-click": "$onPrefixIconClick !== undefined || undefined",
7462
+ "data-suffix-icon-click": "$onSuffixIconClick !== undefined || undefined"
7463
+ }
7464
+ }), true);
7465
+ const inner = createSection("inner", "div");
7466
+ const wrapper = createSection("wrapper", "div");
7467
+ const label = createSection("label", () => ({
7468
+ $el: "label",
7469
+ if: "$label",
7470
+ attrs: {
7471
+ for: "$id"
7444
7472
  }
7445
7473
  }));
7446
- const wrapper$2 = composable("wrapper", () => ({
7447
- $el: "div",
7474
+ const messages = createSection("messages", () => ({
7475
+ $el: "ul",
7476
+ if: "$fns.length($messages)"
7477
+ }));
7478
+ const message = createSection("message", () => ({
7479
+ $el: "li",
7480
+ for: ["message", "$messages"],
7448
7481
  attrs: {
7449
- class: "$classes.wrapper"
7482
+ key: "$message.key",
7483
+ id: `$id + '-' + $message.key`,
7484
+ "data-message-type": "$message.type"
7450
7485
  }
7451
7486
  }));
7452
- const inner = composable("inner", () => ({
7487
+ const prefix = createSection("prefix", null);
7488
+ const suffix = createSection("suffix", null);
7489
+ const help = createSection("help", () => ({
7453
7490
  $el: "div",
7491
+ if: "$help",
7454
7492
  attrs: {
7455
- class: "$classes.inner"
7493
+ id: '$: "help-" + $id'
7456
7494
  }
7457
7495
  }));
7458
- const help = (schema = {}, children = [], target = "help", cond = "$help") => ({
7459
- if: `$slots.${target}`,
7460
- then: `$slots.${target}`,
7461
- else: extend({
7462
- $el: "div",
7463
- attrs: {
7464
- id: `$: "help-" + ${target == "optionHelp" ? "$option.attrs.id" : "$id"}`,
7465
- class: `$classes.${target}`
7466
- },
7467
- if: cond,
7468
- children
7469
- }, schema)
7470
- });
7471
- const messages = composable("messages", () => ({
7472
- $el: "ul",
7473
- if: "$fns.length($messages)",
7496
+ const fieldset = createSection("fieldset", () => ({
7497
+ $el: "fieldset",
7474
7498
  attrs: {
7475
- class: "$classes.messages",
7476
- "aria-live": '$type === "form" && "assertive" || "polite"'
7499
+ id: "$id",
7500
+ "aria-describedby": {
7501
+ if: "$help",
7502
+ then: '$: "help-" + $id',
7503
+ else: void 0
7504
+ }
7477
7505
  }
7478
7506
  }));
7479
- const message = composable("message", () => ({
7480
- $el: "li",
7481
- for: ["message", "$messages"],
7507
+ const decorator = createSection("decorator", () => ({
7508
+ $el: "span",
7482
7509
  attrs: {
7483
- key: "$message.key",
7484
- class: "$classes.message",
7485
- id: `$id + '-' + $message.key`,
7486
- "data-message-type": "$message.type"
7510
+ "aria-hidden": "true"
7487
7511
  }
7488
7512
  }));
7489
- const prefix = composable("prefix", () => ({ $el: null }));
7490
- const suffix = composable("suffix", () => ({ $el: null }));
7491
- function isSchemaObject(schema) {
7492
- return typeof schema === "object" && ("$el" in schema || "$cmp" in schema || "$formkit" in schema);
7493
- }
7494
- function extendSchema(schema, extension = {}) {
7495
- if (typeof schema === "string") {
7496
- return isSchemaObject(extension) || typeof extension === "string" ? extension : schema;
7497
- } else if (Array.isArray(schema)) {
7498
- return isSchemaObject(extension) ? extension : schema;
7499
- }
7500
- return extend(schema, extension);
7501
- }
7502
- function composable(key, schema) {
7503
- return (extendWith = {}, children = void 0) => {
7504
- const root = typeof schema === "function" ? schema(children) : typeof schema === "object" ? clone(schema) : schema;
7505
- const isObj = isSchemaObject(root);
7506
- if (isObj && !("children" in root) && children) {
7507
- if (Array.isArray(children)) {
7508
- if (children.length) {
7509
- root.children = children;
7510
- }
7511
- } else {
7512
- root.children = [children];
7513
+ const box = createSection("input", () => ({
7514
+ $el: "input",
7515
+ bind: "$attrs",
7516
+ attrs: {
7517
+ type: "$type",
7518
+ name: "$node.props.altName || $node.name",
7519
+ disabled: "$option.attrs.disabled || $disabled",
7520
+ onInput: "$handlers.toggleChecked",
7521
+ checked: "$fns.eq($_value, $onValue)",
7522
+ onBlur: "$handlers.blur",
7523
+ value: "$: true",
7524
+ id: "$id",
7525
+ "aria-describedby": {
7526
+ if: "$options.length",
7527
+ then: {
7528
+ if: "$option.help",
7529
+ then: '$: "help-" + $option.attrs.id',
7530
+ else: void 0
7531
+ },
7532
+ else: {
7533
+ if: "$help",
7534
+ then: '$: "help-" + $id',
7535
+ else: void 0
7513
7536
  }
7514
7537
  }
7515
- const extended = extendSchema(root, extendWith);
7516
- return {
7517
- if: `$slots.${key}`,
7518
- then: `$slots.${key}`,
7519
- else: Array.isArray(extended) ? extended : [extended]
7520
- };
7521
- };
7522
- }
7523
- const label = composable("label", () => ({
7538
+ }
7539
+ }));
7540
+ const legend = createSection("legend", () => ({
7541
+ $el: "legend",
7542
+ if: "$label"
7543
+ }));
7544
+ const boxOption = createSection("option", () => ({
7545
+ $el: "li",
7546
+ for: ["option", "$options"],
7547
+ attrs: {
7548
+ "data-disabled": "$option.attrs.disabled || $disabled"
7549
+ }
7550
+ }));
7551
+ const boxOptions = createSection("options", "ul");
7552
+ const boxWrapper = createSection("wrapper", () => ({
7524
7553
  $el: "label",
7525
- if: "$label",
7526
7554
  attrs: {
7527
- for: "$id",
7528
- class: "$classes.label"
7555
+ "data-disabled": {
7556
+ if: "$options.length",
7557
+ then: void 0,
7558
+ else: "$disabled"
7559
+ }
7529
7560
  }
7530
7561
  }));
7531
- const text$1 = composable("input", () => ({
7532
- $el: "input",
7562
+ const boxHelp = createSection("optionHelp", () => ({
7563
+ $el: "div",
7564
+ if: "$option.help",
7565
+ attrs: {
7566
+ id: '$: "help-" + $option.attrs.id'
7567
+ }
7568
+ }));
7569
+ const boxLabel = createSection("label", "span");
7570
+ const buttonInput = createSection("input", () => ({
7571
+ $el: "button",
7533
7572
  bind: "$attrs",
7534
7573
  attrs: {
7535
7574
  type: "$type",
7536
7575
  disabled: "$disabled",
7537
- class: "$classes.input",
7538
7576
  name: "$node.name",
7539
- onInput: "$handlers.DOMInput",
7540
- onBlur: "$handlers.blur",
7541
- value: "$_value",
7542
- id: "$id",
7543
- "aria-describedby": "$describedBy"
7577
+ id: "$id"
7544
7578
  }
7545
7579
  }));
7546
- const textSchema$1 = (extensions = {}) => [
7547
- outer(extensions.outer, [
7548
- wrapper$2(extensions.wrapper, [
7549
- label(extensions.label, "$label"),
7550
- inner(extensions.inner, [
7551
- prefix(extensions.prefix),
7552
- text$1(extensions.input),
7553
- suffix(extensions.suffix)
7554
- ])
7555
- ]),
7556
- help(extensions.help, "$help"),
7557
- messages(extensions.messages, [
7558
- message(extensions.message, "$message.value")
7559
- ])
7560
- ])
7561
- ];
7562
- const file$1 = composable("input", () => ({
7580
+ const buttonLabel = createSection("default", null);
7581
+ const fileInput = createSection("input", () => ({
7563
7582
  $el: "input",
7564
7583
  bind: "$attrs",
7565
7584
  attrs: {
7566
7585
  type: "file",
7567
- foo: "bar",
7568
7586
  disabled: "$disabled",
7569
- class: "$classes.input",
7570
7587
  name: "$node.name",
7571
7588
  onChange: "$handlers.files",
7572
7589
  onBlur: "$handlers.blur",
@@ -7574,80 +7591,65 @@ const file$1 = composable("input", () => ({
7574
7591
  "aria-describedby": "$describedBy"
7575
7592
  }
7576
7593
  }));
7577
- const fileList = composable("fileList", () => ({
7594
+ const fileItem = createSection("fileItem", () => ({
7595
+ $el: "li",
7596
+ for: ["file", "$value"]
7597
+ }));
7598
+ const fileList = createSection("fileList", () => ({
7578
7599
  $el: "ul",
7579
7600
  if: "$value.length",
7580
7601
  attrs: {
7581
- class: "$classes.fileList",
7582
7602
  "data-has-multiple": {
7583
7603
  if: "$value.length > 1",
7584
7604
  then: "true"
7585
7605
  }
7586
7606
  }
7587
7607
  }));
7588
- const fileItem = composable("fileItem", () => ({
7589
- $el: "li",
7590
- for: ["file", "$value"],
7608
+ const fileName = createSection("fileName", () => ({
7609
+ $el: "span",
7591
7610
  attrs: {
7592
- class: "$classes.fileItem"
7611
+ class: "$classes.fileName"
7593
7612
  }
7594
7613
  }));
7595
- const fileName = composable("fileName", () => ({
7596
- $el: "span",
7614
+ const fileRemove = createSection("fileRemove", () => ({
7615
+ $el: "button",
7597
7616
  attrs: {
7598
- class: "$classes.fileName"
7617
+ onClick: "$handlers.resetFiles"
7599
7618
  }
7600
7619
  }));
7601
- const noFiles = composable("noFiles", () => ({
7620
+ const noFiles = createSection("noFiles", () => ({
7602
7621
  $el: "span",
7603
- if: "$value.length == 0",
7622
+ if: "$value.length == 0"
7623
+ }));
7624
+ const formInput = createSection("form", () => ({
7625
+ $el: "form",
7626
+ bind: "$attrs",
7604
7627
  attrs: {
7605
- class: "$classes.noFiles"
7628
+ id: "$id",
7629
+ name: "$node.name",
7630
+ onSubmit: "$handlers.submit",
7631
+ "data-loading": "$state.loading || undefined"
7606
7632
  }
7633
+ }), true);
7634
+ const actions = createSection("actions", () => ({
7635
+ $el: "div",
7636
+ if: "$actions"
7607
7637
  }));
7608
- const removeFiles = composable("removeFiles", () => ({
7609
- $el: "a",
7610
- attrs: {
7611
- href: "#",
7612
- class: "$classes.removeFiles",
7613
- onClick: "$handlers.resetFiles"
7638
+ const submitInput = createSection("submit", () => ({
7639
+ $cmp: "FormKit",
7640
+ bind: "$submitAttrs",
7641
+ props: {
7642
+ ignore: true,
7643
+ type: "submit",
7644
+ disabled: "$disabled",
7645
+ label: "$submitLabel"
7614
7646
  }
7615
7647
  }));
7616
- const fileSchema = (extensions = {}) => [
7617
- outer(extensions.outer, [
7618
- wrapper$2(extensions.wrapper, [
7619
- label(extensions.label, "$label"),
7620
- inner(extensions.inner, [
7621
- prefix(extensions.prefix),
7622
- file$1(extensions.input),
7623
- fileList(extensions.fileList, [
7624
- fileItem(extensions.file, [
7625
- fileName(extensions.fileName, "$file.name"),
7626
- {
7627
- if: "$value.length == 1",
7628
- then: removeFiles(extensions.removeFiles, "$ui.remove.value")
7629
- }
7630
- ])
7631
- ]),
7632
- {
7633
- if: "$value.length > 1",
7634
- then: removeFiles(extensions.removeFiles, "$ui.removeAll.value")
7635
- },
7636
- noFiles(extensions.noFiles, "$ui.noFiles.value"),
7637
- suffix(extensions.suffix)
7638
- ])
7639
- ]),
7640
- help(extensions.help, "$help"),
7641
- messages(extensions.messages, [
7642
- message(extensions.message, "$message.value")
7643
- ])
7644
- ])
7645
- ];
7646
- const textarea$1 = composable("input", () => ({
7647
- $el: "textarea",
7648
+ const textInput = createSection("input", () => ({
7649
+ $el: "input",
7648
7650
  bind: "$attrs",
7649
7651
  attrs: {
7650
- class: "$classes.input",
7652
+ type: "$type",
7651
7653
  disabled: "$disabled",
7652
7654
  name: "$node.name",
7653
7655
  onInput: "$handlers.DOMInput",
@@ -7655,36 +7657,10 @@ const textarea$1 = composable("input", () => ({
7655
7657
  value: "$_value",
7656
7658
  id: "$id",
7657
7659
  "aria-describedby": "$describedBy"
7658
- },
7659
- children: "$initialValue"
7660
+ }
7660
7661
  }));
7661
- const textareaSchema = (extensions = {}) => [
7662
- outer(extensions.outer, [
7663
- wrapper$2(extensions.wrapper, [
7664
- label(extensions.label, "$label"),
7665
- inner(extensions.inner, [
7666
- prefix(extensions.prefix),
7667
- textarea$1(extensions.input),
7668
- suffix(extensions.suffix)
7669
- ])
7670
- ]),
7671
- help(extensions.help, "$help"),
7672
- messages(extensions.messages, [
7673
- message(extensions.message, "$message.value")
7674
- ])
7675
- ])
7676
- ];
7677
- const hiddenSchema = (extensions = {}) => [
7678
- text$1(extensions.input)
7679
- ];
7680
- const fragment = (schema = {}, children = []) => Object.keys(schema).length || typeof children !== "string" ? extend({ $el: "div", children }, schema) : children;
7681
- const groupSchema = (extensions = {}) => {
7682
- return [fragment(extensions.wrapper, "$slots.default")];
7683
- };
7684
- const listSchema = (extensions = {}) => {
7685
- return [fragment(extensions.wrapper, "$slots.default")];
7686
- };
7687
- const select$2 = composable("input", (children) => ({
7662
+ const fragment = createSection("wrapper", null, true);
7663
+ const selectInput$1 = createSection("input", () => ({
7688
7664
  $el: "select",
7689
7665
  bind: "$attrs",
7690
7666
  attrs: {
@@ -7703,262 +7679,83 @@ const select$2 = composable("input", (children) => ({
7703
7679
  onInput: "$handlers.selectInput",
7704
7680
  onBlur: "$handlers.blur",
7705
7681
  "aria-describedby": "$describedBy"
7706
- },
7707
- children: {
7708
- if: "$slots.default",
7709
- then: "$slots.default",
7710
- else: children
7711
- }
7712
- }));
7713
- const option = (schema = {}, children = []) => ({
7714
- if: "$slots.option",
7715
- then: [
7716
- {
7717
- $el: "text",
7718
- if: "$options.length",
7719
- for: ["option", "$options"],
7720
- children: "$slots.option"
7721
- }
7722
- ],
7723
- else: extend({
7724
- $el: "option",
7725
- if: "$options.length",
7726
- for: ["option", "$options"],
7727
- bind: "$option.attrs",
7728
- attrs: {
7729
- class: "$classes.option",
7730
- value: "$option.value",
7731
- selected: "$fns.isSelected($option.value)"
7732
- },
7733
- children
7734
- }, schema)
7735
- });
7736
- const textSchema = (extensions = {}) => [
7737
- outer(extensions.outer, [
7738
- wrapper$2(extensions.wrapper, [
7739
- label(extensions.label, "$label"),
7740
- inner(extensions.inner, [
7741
- prefix(extensions.prefix),
7742
- select$2(extensions.input, [option(extensions.option, "$option.label")]),
7743
- suffix(extensions.suffix)
7744
- ])
7745
- ]),
7746
- help(extensions.help, "$help"),
7747
- messages(extensions.messages, [
7748
- message(extensions.message, "$message.value")
7749
- ])
7750
- ])
7751
- ];
7752
- const boxLabel = composable("label", (children) => ({
7753
- $el: "span",
7754
- if: typeof children === "string" ? children : "$: true",
7755
- attrs: {
7756
- class: "$classes.label"
7757
7682
  }
7758
7683
  }));
7759
- const wrapper$1 = composable("wrapper", () => ({
7760
- $el: "label",
7684
+ const option = createSection("option", () => ({
7685
+ $el: "option",
7686
+ for: ["option", "$options"],
7687
+ bind: "$option.attrs",
7761
7688
  attrs: {
7762
- class: "$classes.wrapper",
7763
- "data-disabled": {
7764
- if: "$options.length",
7765
- then: void 0,
7766
- else: "$disabled"
7767
- }
7689
+ class: "$classes.option",
7690
+ value: "$option.value",
7691
+ selected: "$fns.isSelected($option.value)"
7768
7692
  }
7769
7693
  }));
7770
- const box = composable("input", () => ({
7771
- $el: "input",
7694
+ const optionSlot = () => ({
7695
+ $el: null,
7696
+ if: "$options.length",
7697
+ for: ["option", "$options"],
7698
+ children: "$slots.option"
7699
+ });
7700
+ const textareaInput = createSection("input", () => ({
7701
+ $el: "textarea",
7772
7702
  bind: "$attrs",
7773
7703
  attrs: {
7774
- type: "$type",
7775
- class: "$classes.input",
7776
- name: "$node.props.altName || $node.name",
7777
- disabled: "$option.attrs.disabled || $disabled",
7778
- onInput: "$handlers.toggleChecked",
7779
- checked: "$fns.eq($_value, $onValue)",
7704
+ disabled: "$disabled",
7705
+ name: "$node.name",
7706
+ onInput: "$handlers.DOMInput",
7780
7707
  onBlur: "$handlers.blur",
7781
- value: "$: true",
7782
- id: "$id",
7783
- "aria-describedby": {
7784
- if: "$options.length",
7785
- then: {
7786
- if: "$option.help",
7787
- then: '$: "help-" + $option.attrs.id',
7788
- else: void 0
7789
- },
7790
- else: {
7791
- if: "$help",
7792
- then: '$: "help-" + $id',
7793
- else: void 0
7794
- }
7795
- }
7796
- }
7797
- }));
7798
- const fieldset = composable("fieldset", () => ({
7799
- $el: "fieldset",
7800
- attrs: {
7708
+ value: "$_value",
7801
7709
  id: "$id",
7802
- class: "$classes.fieldset",
7803
- "aria-describedby": {
7804
- if: "$help",
7805
- then: '$: "help-" + $id',
7806
- else: void 0
7807
- }
7808
- }
7809
- }));
7810
- const legend = composable("legend", () => ({
7811
- $el: "legend",
7812
- if: "$label",
7813
- attrs: {
7814
- class: "$classes.legend"
7815
- }
7816
- }));
7817
- const boxes = composable("option", () => ({
7818
- $el: "li",
7819
- for: ["option", "$options"],
7820
- attrs: {
7821
- class: "$classes.option",
7822
- "data-disabled": "$option.attrs.disabled || $disabled"
7823
- }
7824
- }));
7825
- const wrapper = composable("options", () => ({
7826
- $el: "ul",
7827
- attrs: {
7828
- class: "$classes.options"
7829
- }
7830
- }));
7831
- const decorator = composable("decorator", () => ({
7832
- $el: "span",
7833
- attrs: {
7834
- class: "$classes.decorator",
7835
- "aria-hidden": "true"
7836
- }
7710
+ "aria-describedby": "$describedBy"
7711
+ },
7712
+ children: "$initialValue"
7837
7713
  }));
7838
- const boxSchema = (extensions = {}) => {
7839
- const singleCheckbox = [
7840
- wrapper$1(extensions.wrapper, [
7841
- inner(extensions.inner, [
7842
- prefix(extensions.prefix),
7843
- box(extensions.input),
7844
- decorator(extensions.decorator),
7845
- suffix(extensions.suffix)
7846
- ]),
7847
- boxLabel(extensions.label, "$label")
7848
- ]),
7849
- help(extensions.help, "$help")
7850
- ];
7851
- const multiCheckbox = fieldset(extensions.fieldset, [
7852
- legend(extensions.legend, "$label"),
7853
- help(extensions.help, "$help"),
7854
- wrapper(extensions.options, [
7855
- boxes(extensions.option, [
7856
- wrapper$1(extensions.wrapper, [
7857
- inner(extensions.inner, [
7858
- prefix(extensions.prefix),
7859
- box(extend({
7860
- bind: "$option.attrs",
7861
- attrs: {
7862
- id: "$option.attrs.id",
7863
- value: "$option.value",
7864
- checked: "$fns.isChecked($option.value)"
7865
- }
7866
- }, extensions.input || {})),
7867
- decorator(extensions.decorator),
7868
- suffix(extensions.suffix)
7869
- ]),
7870
- boxLabel(extensions.label, "$option.label")
7871
- ]),
7872
- help(extensions.optionHelp, "$option.help", "optionHelp", "$option.help")
7873
- ])
7874
- ])
7875
- ]);
7876
- return [
7877
- outer(extensions.outer, [
7878
- {
7879
- if: "$options.length",
7880
- then: multiCheckbox,
7881
- else: singleCheckbox
7882
- },
7883
- messages(extensions.messages, [
7884
- message(extensions.message, "$message.value")
7885
- ])
7886
- ])
7887
- ];
7714
+ const icon = (sectionKey, el) => {
7715
+ return createSection(`${sectionKey}Icon`, () => {
7716
+ const rawIconProp = `_raw${sectionKey.charAt(0).toUpperCase()}${sectionKey.slice(1)}Icon`;
7717
+ return {
7718
+ if: `$${sectionKey}Icon && $${rawIconProp}`,
7719
+ $el: `${el ? el : "span"}`,
7720
+ attrs: {
7721
+ class: `$classes.${sectionKey}Icon + " formkit-icon"`,
7722
+ innerHTML: `$${rawIconProp}`,
7723
+ onClick: `$handlers.iconClick(${sectionKey})`,
7724
+ for: {
7725
+ if: `${el === "label"}`,
7726
+ then: "$id"
7727
+ }
7728
+ }
7729
+ };
7730
+ })();
7888
7731
  };
7889
- const actions = composable("actions", () => ({
7890
- $el: "div",
7891
- if: "$actions",
7892
- attrs: {
7893
- class: "$classes.actions"
7894
- }
7895
- }));
7896
- const form$2 = composable("form", () => ({
7897
- $el: "form",
7898
- bind: "$attrs",
7899
- attrs: {
7900
- id: "$id",
7901
- class: "$classes.form",
7902
- name: "$node.name",
7903
- onSubmit: "$handlers.submit",
7904
- "data-loading": "$state.loading || undefined"
7905
- }
7906
- }));
7907
- const submit$1 = composable("submit", () => ({
7908
- $cmp: "FormKit",
7909
- bind: "$submitAttrs",
7910
- props: {
7911
- ignore: true,
7912
- type: "submit",
7913
- disabled: "$disabled",
7914
- label: "$submitLabel"
7915
- }
7916
- }));
7917
- const formSchema = (extensions = {}) => {
7918
- return [
7919
- form$2(extensions.form, [
7920
- "$slots.default",
7921
- messages(extensions.messages, [
7922
- message(extensions.message, "$message.value")
7923
- ]),
7924
- actions(extensions.actions, [submit$1(extensions.submit)])
7925
- ])
7926
- ];
7927
- };
7928
- const button$1 = composable("input", () => ({
7929
- $el: "button",
7930
- bind: "$attrs",
7931
- attrs: {
7932
- type: "$type",
7933
- disabled: "$disabled",
7934
- class: "$classes.input",
7935
- name: "$node.name",
7936
- id: "$id"
7937
- }
7938
- }));
7939
- const buttonSchema = (extensions = {}) => [
7940
- outer(extensions.outer, [
7941
- messages(extensions.messages, [
7942
- message(extensions.message, "$message.value")
7943
- ]),
7944
- wrapper$2(extensions.wrapper, [
7945
- button$1(extensions.input, [
7946
- prefix(extensions.prefix),
7947
- {
7948
- if: "$slots.default",
7949
- then: "$slots.default",
7950
- else: {
7951
- if: "$label",
7952
- then: "$label",
7953
- else: "$ui.submit.value"
7954
- }
7955
- },
7956
- suffix(extensions.suffix)
7957
- ])
7958
- ]),
7959
- help(extensions.help, "$help")
7960
- ])
7961
- ];
7732
+ function normalizeBoxes(node) {
7733
+ return function(prop, next) {
7734
+ if (prop.prop === "options" && Array.isArray(prop.value)) {
7735
+ prop.value = prop.value.map((option2) => {
7736
+ var _a;
7737
+ if (!((_a = option2.attrs) === null || _a === void 0 ? void 0 : _a.id)) {
7738
+ return extend(option2, {
7739
+ attrs: { id: `${node.name}-option-${kebab(String(option2.value))}` }
7740
+ });
7741
+ }
7742
+ return option2;
7743
+ });
7744
+ if (node.props.type === "checkbox" && !Array.isArray(node.value)) {
7745
+ if (node.isCreated) {
7746
+ node.input([], false);
7747
+ } else {
7748
+ node.on("created", () => {
7749
+ if (!Array.isArray(node.value)) {
7750
+ node.input([], false);
7751
+ }
7752
+ });
7753
+ }
7754
+ }
7755
+ }
7756
+ return next(prop);
7757
+ };
7758
+ }
7962
7759
  function normalizeOptions(options2) {
7963
7760
  let i2 = 1;
7964
7761
  if (Array.isArray(options2)) {
@@ -8013,102 +7810,6 @@ function options(node) {
8013
7810
  return next(prop);
8014
7811
  });
8015
7812
  }
8016
- function isSelected(node, option2) {
8017
- node.context && node.context.value;
8018
- const value = optionValue(node.props.options, option2);
8019
- return Array.isArray(node._value) ? node._value.some((optionA) => shouldSelect(optionA, value)) : node.value === void 0 && !option2 || shouldSelect(value, node._value);
8020
- }
8021
- function selectInput(node, e2) {
8022
- const target = e2.target;
8023
- const value = target.hasAttribute("multiple") ? Array.from(target.selectedOptions).map((o2) => optionValue(node.props.options, o2.value)) : optionValue(node.props.options, target.value);
8024
- node.input(value);
8025
- }
8026
- function applyPlaceholder(options2, placeholder) {
8027
- if (!options2.some((option2) => option2.attrs && option2.attrs["data-is-placeholder"])) {
8028
- return [
8029
- {
8030
- label: placeholder,
8031
- value: "",
8032
- attrs: {
8033
- hidden: true,
8034
- disabled: true,
8035
- "data-is-placeholder": "true"
8036
- }
8037
- },
8038
- ...options2
8039
- ];
8040
- }
8041
- return options2;
8042
- }
8043
- function select$1(node) {
8044
- node.on("created", () => {
8045
- var _a, _b, _c;
8046
- const isMultiple = undefine((_a = node.props.attrs) === null || _a === void 0 ? void 0 : _a.multiple);
8047
- if (!isMultiple && node.props.placeholder && Array.isArray(node.props.options)) {
8048
- node.hook.prop(({ prop, value }, next) => {
8049
- if (prop === "options") {
8050
- value = applyPlaceholder(value, node.props.placeholder);
8051
- }
8052
- return next({ prop, value });
8053
- });
8054
- node.props.options = applyPlaceholder(node.props.options, node.props.placeholder);
8055
- }
8056
- if (isMultiple) {
8057
- if (node.value === void 0) {
8058
- node.input([], false);
8059
- }
8060
- } else if (node.context && !node.context.options) {
8061
- node.props.attrs = Object.assign({}, node.props.attrs, {
8062
- value: node._value
8063
- });
8064
- node.on("input", ({ payload }) => {
8065
- node.props.attrs = Object.assign({}, node.props.attrs, {
8066
- value: payload
8067
- });
8068
- });
8069
- }
8070
- if ((_b = node.context) === null || _b === void 0 ? void 0 : _b.handlers) {
8071
- node.context.handlers.selectInput = selectInput.bind(null, node);
8072
- }
8073
- if ((_c = node.context) === null || _c === void 0 ? void 0 : _c.fns) {
8074
- node.context.fns.isSelected = isSelected.bind(null, node);
8075
- }
8076
- });
8077
- node.hook.input((value, next) => {
8078
- var _a, _b, _c;
8079
- if (!node.props.placeholder && value === void 0 && Array.isArray((_a = node.props) === null || _a === void 0 ? void 0 : _a.options) && node.props.options.length && !undefine((_c = (_b = node.props) === null || _b === void 0 ? void 0 : _b.attrs) === null || _c === void 0 ? void 0 : _c.multiple)) {
8080
- value = "__original" in node.props.options[0] ? node.props.options[0].__original : node.props.options[0].value;
8081
- }
8082
- return next(value);
8083
- });
8084
- }
8085
- function normalizeBoxes(node) {
8086
- return function(prop, next) {
8087
- if (prop.prop === "options" && Array.isArray(prop.value)) {
8088
- prop.value = prop.value.map((option2) => {
8089
- var _a;
8090
- if (!((_a = option2.attrs) === null || _a === void 0 ? void 0 : _a.id)) {
8091
- return extend(option2, {
8092
- attrs: { id: `${node.name}-option-${kebab(String(option2.value))}` }
8093
- });
8094
- }
8095
- return option2;
8096
- });
8097
- if (node.props.type === "checkbox" && !Array.isArray(node.value)) {
8098
- if (node.isCreated) {
8099
- node.input([], false);
8100
- } else {
8101
- node.on("created", () => {
8102
- if (!Array.isArray(node.value)) {
8103
- node.input([], false);
8104
- }
8105
- });
8106
- }
8107
- }
8108
- }
8109
- return next(prop);
8110
- };
8111
- }
8112
7813
  function toggleChecked$1(node, e2) {
8113
7814
  const el = e2.target;
8114
7815
  if (el instanceof HTMLInputElement) {
@@ -8155,32 +7856,6 @@ function checkboxes(node) {
8155
7856
  });
8156
7857
  node.hook.prop(normalizeBoxes(node));
8157
7858
  }
8158
- function toggleChecked(node, event) {
8159
- if (event.target instanceof HTMLInputElement) {
8160
- node.input(optionValue(node.props.options, event.target.value));
8161
- }
8162
- }
8163
- function isChecked(node, value) {
8164
- var _a, _b;
8165
- (_a = node.context) === null || _a === void 0 ? void 0 : _a.value;
8166
- (_b = node.context) === null || _b === void 0 ? void 0 : _b._value;
8167
- return shouldSelect(optionValue(node.props.options, value), node._value);
8168
- }
8169
- function radios(node) {
8170
- node.on("created", () => {
8171
- var _a, _b;
8172
- if (!Array.isArray(node.props.options)) {
8173
- warn(350, node);
8174
- }
8175
- if ((_a = node.context) === null || _a === void 0 ? void 0 : _a.handlers) {
8176
- node.context.handlers.toggleChecked = toggleChecked.bind(null, node);
8177
- }
8178
- if ((_b = node.context) === null || _b === void 0 ? void 0 : _b.fns) {
8179
- node.context.fns.isChecked = isChecked.bind(null, node);
8180
- }
8181
- });
8182
- node.hook.prop(normalizeBoxes(node));
8183
- }
8184
7859
  function disables(node) {
8185
7860
  node.on("created", () => {
8186
7861
  node.props.disabled = undefine(node.props.disabled);
@@ -8196,6 +7871,82 @@ function disables(node) {
8196
7871
  node.config.disabled = undefine(node.props.disabled);
8197
7872
  });
8198
7873
  }
7874
+ function localize(key, value) {
7875
+ return (node) => {
7876
+ node.store.set(createMessage({
7877
+ key,
7878
+ type: "ui",
7879
+ value: value || key,
7880
+ meta: {
7881
+ localize: true,
7882
+ i18nArgs: [node]
7883
+ }
7884
+ }));
7885
+ };
7886
+ }
7887
+ const isBrowser = typeof window !== "undefined";
7888
+ function removeHover(e2) {
7889
+ if (e2.target instanceof HTMLElement && e2.target.hasAttribute("data-file-hover")) {
7890
+ e2.target.removeAttribute("data-file-hover");
7891
+ }
7892
+ }
7893
+ function preventStrayDrop(type, e2) {
7894
+ if (!(e2.target instanceof HTMLInputElement)) {
7895
+ e2.preventDefault();
7896
+ } else if (type === "dragover") {
7897
+ e2.target.setAttribute("data-file-hover", "true");
7898
+ }
7899
+ if (type === "drop") {
7900
+ removeHover(e2);
7901
+ }
7902
+ }
7903
+ function files(node) {
7904
+ localize("noFiles", "Select file")(node);
7905
+ localize("removeAll", "Remove all")(node);
7906
+ localize("remove")(node);
7907
+ if (isBrowser) {
7908
+ if (!window._FormKit_File_Drop) {
7909
+ window.addEventListener("dragover", preventStrayDrop.bind(null, "dragover"));
7910
+ window.addEventListener("drop", preventStrayDrop.bind(null, "drop"));
7911
+ window.addEventListener("dragleave", removeHover);
7912
+ window._FormKit_File_Drop = true;
7913
+ }
7914
+ }
7915
+ node.on("created", () => {
7916
+ if (!Array.isArray(node.value)) {
7917
+ node.input([], false);
7918
+ }
7919
+ if (!node.context)
7920
+ return;
7921
+ node.context.handlers.resetFiles = (e2) => {
7922
+ e2.preventDefault();
7923
+ node.input([]);
7924
+ if (node.props.id && isBrowser) {
7925
+ const el = document.getElementById(node.props.id);
7926
+ if (el)
7927
+ el.value = "";
7928
+ }
7929
+ };
7930
+ node.context.handlers.files = (e2) => {
7931
+ var _a, _b;
7932
+ const files2 = [];
7933
+ if (e2.target instanceof HTMLInputElement && e2.target.files) {
7934
+ for (let i2 = 0; i2 < e2.target.files.length; i2++) {
7935
+ let file2;
7936
+ if (file2 = e2.target.files.item(i2)) {
7937
+ files2.push({ name: file2.name, file: file2 });
7938
+ }
7939
+ }
7940
+ node.input(files2);
7941
+ }
7942
+ if (node.context)
7943
+ node.context.files = files2;
7944
+ if (typeof ((_a = node.props.attrs) === null || _a === void 0 ? void 0 : _a.onChange) === "function") {
7945
+ (_b = node.props.attrs) === null || _b === void 0 ? void 0 : _b.onChange(e2);
7946
+ }
7947
+ };
7948
+ });
7949
+ }
8199
7950
  function handleSubmit(node, submitEvent) {
8200
7951
  return __async(this, null, function* () {
8201
7952
  submitEvent.preventDefault();
@@ -8226,7 +7977,7 @@ function handleSubmit(node, submitEvent) {
8226
7977
  }
8227
7978
  } else {
8228
7979
  if (typeof node.props.onSubmit === "function") {
8229
- const retVal = node.props.onSubmit(clone(node.value), node);
7980
+ const retVal = node.props.onSubmit(node.hook.submit.dispatch(clone(node.value)), node);
8230
7981
  if (retVal instanceof Promise) {
8231
7982
  const autoDisable = node.props.disabled === void 0 && node.props.submitBehavior !== "live";
8232
7983
  if (autoDisable)
@@ -8262,155 +8013,235 @@ function form$1(node) {
8262
8013
  });
8263
8014
  node.on("settled:blocking", () => node.store.remove("incomplete"));
8264
8015
  }
8265
- function localize(key, value) {
8266
- return (node) => {
8267
- node.store.set(createMessage({
8268
- key,
8269
- type: "ui",
8270
- value: value || key,
8271
- meta: {
8272
- localize: true,
8273
- i18nArgs: [node]
8274
- }
8275
- }));
8276
- };
8277
- }
8278
- const isBrowser = typeof window !== "undefined";
8279
- function removeHover(e2) {
8280
- if (e2.target instanceof HTMLElement && e2.target.hasAttribute("data-file-hover")) {
8281
- e2.target.removeAttribute("data-file-hover");
8016
+ function ignore(node) {
8017
+ if (node.props.ignore === void 0) {
8018
+ node.props.ignore = true;
8019
+ node.parent = null;
8282
8020
  }
8283
8021
  }
8284
- function preventStrayDrop(type, e2) {
8285
- if (!(e2.target instanceof HTMLInputElement)) {
8286
- e2.preventDefault();
8287
- } else if (type === "dragover") {
8288
- e2.target.setAttribute("data-file-hover", "true");
8289
- }
8290
- if (type === "drop") {
8291
- removeHover(e2);
8022
+ function initialValue(node) {
8023
+ node.on("created", () => {
8024
+ if (node.context) {
8025
+ node.context.initialValue = node.value || "";
8026
+ }
8027
+ });
8028
+ }
8029
+ function toggleChecked(node, event) {
8030
+ if (event.target instanceof HTMLInputElement) {
8031
+ node.input(optionValue(node.props.options, event.target.value));
8292
8032
  }
8293
8033
  }
8294
- function files(node) {
8295
- localize("noFiles", "Select file")(node);
8296
- localize("removeAll", "Remove all")(node);
8297
- localize("remove")(node);
8298
- if (isBrowser) {
8299
- if (!window._FormKit_File_Drop) {
8300
- window.addEventListener("dragover", preventStrayDrop.bind(null, "dragover"));
8301
- window.addEventListener("drop", preventStrayDrop.bind(null, "drop"));
8302
- window.addEventListener("dragleave", removeHover);
8303
- window._FormKit_File_Drop = true;
8034
+ function isChecked(node, value) {
8035
+ var _a, _b;
8036
+ (_a = node.context) === null || _a === void 0 ? void 0 : _a.value;
8037
+ (_b = node.context) === null || _b === void 0 ? void 0 : _b._value;
8038
+ return shouldSelect(optionValue(node.props.options, value), node._value);
8039
+ }
8040
+ function radios(node) {
8041
+ node.on("created", () => {
8042
+ var _a, _b;
8043
+ if (!Array.isArray(node.props.options)) {
8044
+ warn(350, node);
8045
+ }
8046
+ if ((_a = node.context) === null || _a === void 0 ? void 0 : _a.handlers) {
8047
+ node.context.handlers.toggleChecked = toggleChecked.bind(null, node);
8048
+ }
8049
+ if ((_b = node.context) === null || _b === void 0 ? void 0 : _b.fns) {
8050
+ node.context.fns.isChecked = isChecked.bind(null, node);
8304
8051
  }
8052
+ });
8053
+ node.hook.prop(normalizeBoxes(node));
8054
+ }
8055
+ function isSelected(node, option2) {
8056
+ node.context && node.context.value;
8057
+ const value = optionValue(node.props.options, option2);
8058
+ return Array.isArray(node._value) ? node._value.some((optionA) => shouldSelect(optionA, value)) : node.value === void 0 && !option2 || shouldSelect(value, node._value);
8059
+ }
8060
+ function selectInput(node, e2) {
8061
+ const target = e2.target;
8062
+ const value = target.hasAttribute("multiple") ? Array.from(target.selectedOptions).map((o2) => optionValue(node.props.options, o2.value)) : optionValue(node.props.options, target.value);
8063
+ node.input(value);
8064
+ }
8065
+ function applyPlaceholder(options2, placeholder) {
8066
+ if (!options2.some((option2) => option2.attrs && option2.attrs["data-is-placeholder"])) {
8067
+ return [
8068
+ {
8069
+ label: placeholder,
8070
+ value: "",
8071
+ attrs: {
8072
+ hidden: true,
8073
+ disabled: true,
8074
+ "data-is-placeholder": "true"
8075
+ }
8076
+ },
8077
+ ...options2
8078
+ ];
8305
8079
  }
8080
+ return options2;
8081
+ }
8082
+ function select$1(node) {
8306
8083
  node.on("created", () => {
8307
- if (!Array.isArray(node.value)) {
8308
- node.input([], false);
8084
+ var _a, _b, _c;
8085
+ const isMultiple = undefine((_a = node.props.attrs) === null || _a === void 0 ? void 0 : _a.multiple);
8086
+ if (!isMultiple && node.props.placeholder && Array.isArray(node.props.options)) {
8087
+ node.hook.prop(({ prop, value }, next) => {
8088
+ if (prop === "options") {
8089
+ value = applyPlaceholder(value, node.props.placeholder);
8090
+ }
8091
+ return next({ prop, value });
8092
+ });
8093
+ node.props.options = applyPlaceholder(node.props.options, node.props.placeholder);
8309
8094
  }
8310
- if (!node.context)
8311
- return;
8312
- node.context.handlers.resetFiles = (e2) => {
8313
- e2.preventDefault();
8314
- node.input([]);
8315
- if (node.props.id && isBrowser) {
8316
- const el = document.getElementById(node.props.id);
8317
- if (el)
8318
- el.value = "";
8095
+ if (isMultiple) {
8096
+ if (node.value === void 0) {
8097
+ node.input([], false);
8319
8098
  }
8320
- };
8321
- node.context.handlers.files = (e2) => {
8322
- var _a, _b;
8323
- const files2 = [];
8324
- if (e2.target instanceof HTMLInputElement && e2.target.files) {
8325
- for (let i2 = 0; i2 < e2.target.files.length; i2++) {
8326
- let file2;
8327
- if (file2 = e2.target.files.item(i2)) {
8328
- files2.push({ name: file2.name, file: file2 });
8329
- }
8099
+ } else if (node.context && !node.context.options) {
8100
+ node.props.attrs = Object.assign({}, node.props.attrs, {
8101
+ value: node._value
8102
+ });
8103
+ node.on("input", ({ payload }) => {
8104
+ node.props.attrs = Object.assign({}, node.props.attrs, {
8105
+ value: payload
8106
+ });
8107
+ });
8108
+ }
8109
+ if ((_b = node.context) === null || _b === void 0 ? void 0 : _b.handlers) {
8110
+ node.context.handlers.selectInput = selectInput.bind(null, node);
8111
+ }
8112
+ if ((_c = node.context) === null || _c === void 0 ? void 0 : _c.fns) {
8113
+ node.context.fns.isSelected = isSelected.bind(null, node);
8114
+ }
8115
+ });
8116
+ node.hook.input((value, next) => {
8117
+ var _a, _b, _c;
8118
+ if (!node.props.placeholder && value === void 0 && Array.isArray((_a = node.props) === null || _a === void 0 ? void 0 : _a.options) && node.props.options.length && !undefine((_c = (_b = node.props) === null || _b === void 0 ? void 0 : _b.attrs) === null || _c === void 0 ? void 0 : _c.multiple)) {
8119
+ value = "__original" in node.props.options[0] ? node.props.options[0].__original : node.props.options[0].value;
8120
+ }
8121
+ return next(value);
8122
+ });
8123
+ }
8124
+ function defaultIcon(sectionKey, defaultIcon2) {
8125
+ return (node) => {
8126
+ if (node.props[`${sectionKey}Icon`] === void 0) {
8127
+ node.props[`${sectionKey}Icon`] = `default:${defaultIcon2}`;
8128
+ }
8129
+ };
8130
+ }
8131
+ function isSchemaObject(schema) {
8132
+ return typeof schema === "object" && ("$el" in schema || "$cmp" in schema || "$formkit" in schema);
8133
+ }
8134
+ function isSlotCondition(node) {
8135
+ if (isConditional(node) && node.if && node.if.startsWith("$slots.") && typeof node.then === "string" && node.then.startsWith("$slots.") && "else" in node) {
8136
+ return true;
8137
+ }
8138
+ return false;
8139
+ }
8140
+ function extendSchema(schema, extension = {}) {
8141
+ if (typeof schema === "string") {
8142
+ return isSchemaObject(extension) || typeof extension === "string" ? extension : schema;
8143
+ } else if (Array.isArray(schema)) {
8144
+ return isSchemaObject(extension) ? extension : schema;
8145
+ }
8146
+ return extend(schema, extension);
8147
+ }
8148
+ function createSection(section, el, root = false) {
8149
+ return (...children) => {
8150
+ const extendable = (extensions) => {
8151
+ const node = !el || typeof el === "string" ? { $el: el } : el();
8152
+ if (isDOM(node) || isComponent(node)) {
8153
+ if (!node.meta) {
8154
+ node.meta = { section };
8155
+ }
8156
+ if (children.length && !node.children) {
8157
+ node.children = [
8158
+ ...children.map((child) => typeof child === "string" ? child : child(extensions))
8159
+ ];
8160
+ }
8161
+ if (isDOM(node)) {
8162
+ node.attrs = __spreadValues({
8163
+ class: `$classes.${section}`
8164
+ }, node.attrs || {});
8330
8165
  }
8331
- node.input(files2);
8332
- }
8333
- if (node.context)
8334
- node.context.files = files2;
8335
- if (typeof ((_a = node.props.attrs) === null || _a === void 0 ? void 0 : _a.onChange) === "function") {
8336
- (_b = node.props.attrs) === null || _b === void 0 ? void 0 : _b.onChange(e2);
8337
8166
  }
8167
+ return {
8168
+ if: `$slots.${section}`,
8169
+ then: `$slots.${section}`,
8170
+ else: section in extensions ? extendSchema(node, extensions[section]) : node
8171
+ };
8338
8172
  };
8339
- });
8173
+ return root ? createRoot(extendable) : extendable;
8174
+ };
8340
8175
  }
8341
- function ignore(node) {
8342
- if (node.props.ignore === void 0) {
8343
- node.props.ignore = true;
8344
- node.parent = null;
8345
- }
8176
+ function createRoot(rootSection) {
8177
+ return (extensions) => {
8178
+ return [rootSection(extensions)];
8179
+ };
8346
8180
  }
8347
- function initialValue(node) {
8348
- node.on("created", () => {
8349
- if (node.context) {
8350
- node.context.initialValue = node.value || "";
8181
+ function $if(condition, then, otherwise) {
8182
+ return (extensions) => {
8183
+ const node = then(extensions);
8184
+ if (otherwise) {
8185
+ return {
8186
+ if: condition,
8187
+ then: node,
8188
+ else: otherwise(extensions)
8189
+ };
8190
+ } else if (isSlotCondition(node)) {
8191
+ Object.assign(node.else, { if: condition });
8192
+ } else if (isSchemaObject(node)) {
8193
+ Object.assign(node, { if: condition });
8351
8194
  }
8352
- });
8195
+ return node;
8196
+ };
8353
8197
  }
8354
- const textClassification$1 = {
8355
- type: "input",
8356
- schema: textSchema$1
8357
- };
8358
- const color = textClassification$1;
8359
- const date$1 = textClassification$1;
8360
- const datetimeLocal = textClassification$1;
8361
- const email$1 = textClassification$1;
8362
- const month = textClassification$1;
8363
- const number$1 = textClassification$1;
8364
- const password = textClassification$1;
8365
- const search = textClassification$1;
8366
- const tel = textClassification$1;
8367
- const time = textClassification$1;
8368
- const text = textClassification$1;
8369
- const url$1 = textClassification$1;
8370
- const week = textClassification$1;
8371
- const range = textClassification$1;
8372
- const textarea = {
8373
- type: "input",
8374
- schema: textareaSchema,
8375
- features: [initialValue]
8376
- };
8377
- const buttonClassification$1 = {
8198
+ function $extend(section, extendWith) {
8199
+ return (extensions) => {
8200
+ const node = section({});
8201
+ if (isSlotCondition(node)) {
8202
+ if (Array.isArray(node.else))
8203
+ return node;
8204
+ node.else = extendSchema(extendSchema(node.else, extendWith), extensions);
8205
+ return node;
8206
+ }
8207
+ return extendSchema(extendSchema(node, extendWith), extensions);
8208
+ };
8209
+ }
8210
+ function $root(section) {
8211
+ return createRoot(section);
8212
+ }
8213
+ const button = {
8214
+ schema: outer(messages(message("$message.value")), wrapper(buttonInput(icon("prefix"), prefix(), buttonLabel("$label || $ui.submit.value"), suffix(), icon("suffix"))), help("$help")),
8378
8215
  type: "input",
8379
- schema: buttonSchema,
8216
+ props: [],
8380
8217
  features: [localize("submit"), ignore]
8381
8218
  };
8382
- const submit = buttonClassification$1;
8383
- const button = buttonClassification$1;
8384
- const hidden = {
8385
- type: "input",
8386
- schema: hiddenSchema
8387
- };
8388
- const select = {
8389
- type: "input",
8390
- schema: textSchema,
8391
- props: ["options", "placeholder"],
8392
- features: [options, select$1]
8393
- };
8394
8219
  const checkbox = {
8220
+ schema: outer($if("$options == undefined", boxWrapper(inner(prefix(), box(), decorator(), suffix()), $if("$label", boxLabel("$label"))), fieldset(legend("$label"), help("$help"), boxOptions(boxOption(boxWrapper(inner(prefix(), $extend(box(), {
8221
+ bind: "$option.attrs",
8222
+ attrs: {
8223
+ id: "$option.attrs.id",
8224
+ value: "$option.value",
8225
+ checked: "$fns.isChecked($option.value)"
8226
+ }
8227
+ }), decorator(), suffix()), $if("$option.label", boxLabel("$option.label"))), boxHelp("$option.help"))))), $if("$options.length === 0 && $help", help("$help")), messages(message("$message.value"))),
8395
8228
  type: "input",
8396
- schema: boxSchema,
8397
8229
  props: ["options", "onValue", "offValue"],
8398
8230
  features: [options, checkboxes]
8399
8231
  };
8400
- const radio = {
8232
+ const file = {
8233
+ schema: outer(wrapper(label("$label"), inner(icon("prefix", "label"), prefix(), fileInput(), fileList(fileItem(icon("fileItem"), fileName("$file.name"), $if("$value.length === 1", fileRemove(icon("fileRemove"), "$ui.remove.value")))), $if("$value.length > 1", fileRemove("$ui.removeAll.value")), noFiles(icon("fileItem"), "$ui.noFiles.value"), suffix(), icon("suffix"))), help("$help"), messages(message("$message.value"))),
8401
8234
  type: "input",
8402
- schema: boxSchema,
8403
- props: ["options"],
8404
- features: [options, radios]
8405
- };
8406
- const group = {
8407
- type: "group",
8408
- schema: groupSchema,
8409
- features: [disables]
8235
+ props: [],
8236
+ features: [
8237
+ files,
8238
+ defaultIcon("fileItem", "fileDoc"),
8239
+ defaultIcon("fileRemove", "close")
8240
+ ]
8410
8241
  };
8411
8242
  const form = {
8243
+ schema: formInput("$slots.default", messages(message("$message.value")), actions(submitInput())),
8412
8244
  type: "group",
8413
- schema: formSchema,
8414
8245
  props: [
8415
8246
  "actions",
8416
8247
  "submit",
@@ -8421,57 +8252,83 @@ const form = {
8421
8252
  ],
8422
8253
  features: [form$1, disables]
8423
8254
  };
8255
+ const group = {
8256
+ schema: fragment("$slots.default"),
8257
+ type: "group",
8258
+ props: [],
8259
+ features: [disables]
8260
+ };
8261
+ const hidden = {
8262
+ schema: $root(textInput()),
8263
+ type: "input",
8264
+ props: [],
8265
+ features: []
8266
+ };
8424
8267
  const list$1 = {
8268
+ schema: fragment("$slots.default"),
8425
8269
  type: "list",
8426
- schema: listSchema,
8270
+ props: [],
8427
8271
  features: [disables]
8428
8272
  };
8429
- const file = {
8273
+ const radio = {
8274
+ schema: outer($if("$options == undefined", boxWrapper(inner(prefix(), box(), decorator(), suffix()), $if("$label", boxLabel("$label"))), fieldset(legend("$label"), help("$help"), boxOptions(boxOption(boxWrapper(inner(prefix(), $extend(box(), {
8275
+ bind: "$option.attrs",
8276
+ attrs: {
8277
+ id: "$option.attrs.id",
8278
+ value: "$option.value",
8279
+ checked: "$fns.isChecked($option.value)"
8280
+ }
8281
+ }), decorator(), suffix()), $if("$option.label", boxLabel("$option.label"))), boxHelp("$option.help"))))), $if("$options.length === 0 && $help", help("$help")), messages(message("$message.value"))),
8282
+ type: "input",
8283
+ props: ["options", "onValue", "offValue"],
8284
+ features: [options, radios]
8285
+ };
8286
+ const select = {
8287
+ schema: outer(wrapper(label("$label"), inner(icon("prefix"), prefix(), selectInput$1($if("$slots.default", () => "$slots.default", $if("$slots.option", optionSlot, option("$option.label")))), icon("select"), suffix(), icon("suffix"))), help("$help"), messages(message("$message.value"))),
8288
+ type: "input",
8289
+ props: ["options", "placeholder"],
8290
+ features: [options, select$1, defaultIcon("select", "down")]
8291
+ };
8292
+ const textarea = {
8293
+ schema: outer(wrapper(label("$label"), inner(icon("prefix", "label"), prefix(), textareaInput(), suffix(), icon("suffix"))), help("$help"), messages(message("$message.value"))),
8294
+ type: "input",
8295
+ props: [],
8296
+ features: [initialValue]
8297
+ };
8298
+ const text = {
8299
+ schema: outer(wrapper(label("$label"), inner(icon("prefix", "label"), prefix(), textInput(), suffix(), icon("suffix"))), help("$help"), messages(message("$message.value"))),
8430
8300
  type: "input",
8431
- schema: fileSchema,
8432
- features: [files],
8433
- props: ["files"]
8301
+ props: [],
8302
+ features: []
8434
8303
  };
8435
- var inputs = /* @__PURE__ */ Object.freeze({
8304
+ var index$1 = /* @__PURE__ */ Object.freeze({
8436
8305
  __proto__: null,
8437
- color,
8438
- date: date$1,
8439
- datetimeLocal,
8440
- email: email$1,
8441
- month,
8442
- number: number$1,
8443
- password,
8444
- search,
8445
- tel,
8446
- time,
8447
- text,
8448
- url: url$1,
8449
- week,
8450
- range,
8451
- textarea,
8452
- submit,
8453
8306
  button,
8454
- hidden,
8455
- select,
8307
+ submit: button,
8456
8308
  checkbox,
8457
- radio,
8458
- group,
8309
+ file,
8459
8310
  form,
8311
+ group,
8312
+ hidden,
8460
8313
  list: list$1,
8461
- file
8314
+ radio,
8315
+ select,
8316
+ textarea,
8317
+ text,
8318
+ color: text,
8319
+ date: text,
8320
+ datetimeLocal: text,
8321
+ email: text,
8322
+ month: text,
8323
+ number: text,
8324
+ password: text,
8325
+ search: text,
8326
+ tel: text,
8327
+ time: text,
8328
+ url: text,
8329
+ week: text,
8330
+ range: text
8462
8331
  });
8463
- function createLibraryPlugin(...libraries) {
8464
- const library = libraries.reduce((merged, lib) => extend(merged, lib), {});
8465
- const plugin2 = () => {
8466
- };
8467
- plugin2.library = function(node) {
8468
- const type = camel(node.props.type);
8469
- if (has(library, type)) {
8470
- node.define(library[type]);
8471
- }
8472
- };
8473
- return plugin2;
8474
- }
8475
8332
  const accepted = function accepted2({ value }) {
8476
8333
  return ["yes", "on", "1", 1, true, "true"].includes(value);
8477
8334
  };
@@ -8482,7 +8339,7 @@ const date_after = function({ value }, compare = false) {
8482
8339
  };
8483
8340
  const alpha = function({ value }, set2 = "default") {
8484
8341
  const sets = {
8485
- default: /^[a-zA-ZÀ-ÖØ-öø-ÿĄąĆćĘꣳŃńŚśŹźŻż]+$/,
8342
+ default: /^[a-zA-ZÀ-ÖØ-öø-ÿĄąĆćČčĎďĘęĚ죳ŃńŇňŘřŚśŠšŤťŮůŹźŻŽžż]+$/,
8486
8343
  latin: /^[a-zA-Z]+$/
8487
8344
  };
8488
8345
  const selectedSet = has(sets, set2) ? set2 : "default";
@@ -8490,7 +8347,7 @@ const alpha = function({ value }, set2 = "default") {
8490
8347
  };
8491
8348
  const alpha_spaces = function({ value }, set2 = "default") {
8492
8349
  const sets = {
8493
- default: /^[a-zA-ZÀ-ÖØ-öø-ÿĄąĆćĘꣳŃńŚśŹźŻż ]+$/,
8350
+ default: /^[a-zA-ZÀ-ÖØ-öø-ÿĄąĆćČčĎďĘęĚ죳ŃńŇňŘřŚśŠšŤťŮůŹźŻŽžż ]+$/,
8494
8351
  latin: /^[a-zA-Z ]+$/
8495
8352
  };
8496
8353
  const selectedSet = has(sets, set2) ? set2 : "default";
@@ -9090,7 +8947,7 @@ function date2(date3) {
9090
8947
  function order(first, second) {
9091
8948
  return Number(first) >= Number(second) ? [second, first] : [first, second];
9092
8949
  }
9093
- const ui$m = {
8950
+ const ui$q = {
9094
8951
  add: "Add",
9095
8952
  remove: "Remove",
9096
8953
  removeAll: "Remove all",
@@ -9098,7 +8955,7 @@ const ui$m = {
9098
8955
  submit: "Submit",
9099
8956
  noFiles: "No file chosen"
9100
8957
  };
9101
- const validation$m = {
8958
+ const validation$q = {
9102
8959
  accepted({ name }) {
9103
8960
  return `Please accept the ${name}.`;
9104
8961
  },
@@ -9202,8 +9059,8 @@ const validation$m = {
9202
9059
  };
9203
9060
  var en = /* @__PURE__ */ Object.freeze({
9204
9061
  __proto__: null,
9205
- ui: ui$m,
9206
- validation: validation$m
9062
+ ui: ui$q,
9063
+ validation: validation$q
9207
9064
  });
9208
9065
  function createI18nPlugin(registry2) {
9209
9066
  return function i18nPlugin(node) {
@@ -9244,6 +9101,238 @@ function parseLocale(locale, availableLocales) {
9244
9101
  }
9245
9102
  return false;
9246
9103
  }
9104
+ function generateClasses(classes) {
9105
+ const classesBySectionKey = {};
9106
+ Object.keys(classes).forEach((type) => {
9107
+ Object.keys(classes[type]).forEach((sectionKey) => {
9108
+ if (!classesBySectionKey[sectionKey]) {
9109
+ classesBySectionKey[sectionKey] = {
9110
+ [type]: classes[type][sectionKey]
9111
+ };
9112
+ } else {
9113
+ classesBySectionKey[sectionKey][type] = classes[type][sectionKey];
9114
+ }
9115
+ });
9116
+ });
9117
+ Object.keys(classesBySectionKey).forEach((sectionKey) => {
9118
+ const classesObject = classesBySectionKey[sectionKey];
9119
+ classesBySectionKey[sectionKey] = function(node, sectionKey2) {
9120
+ return addClassesBySection(node, sectionKey2, classesObject);
9121
+ };
9122
+ });
9123
+ return classesBySectionKey;
9124
+ }
9125
+ function addClassesBySection(node, _sectionKey, classesByType) {
9126
+ const type = node.props.type;
9127
+ let classList = "";
9128
+ if (classesByType.global) {
9129
+ classList += classesByType.global + " ";
9130
+ }
9131
+ if (classesByType[type]) {
9132
+ classList += classesByType[type];
9133
+ }
9134
+ const listParts = classList.split("$reset");
9135
+ if (listParts.length > 1) {
9136
+ return `$reset ${listParts[listParts.length - 1].trim()}`;
9137
+ }
9138
+ return listParts[0].trim();
9139
+ }
9140
+ let documentStyles = void 0;
9141
+ let documentThemeLinkTag = null;
9142
+ let themeDidLoad;
9143
+ let themeHasLoaded = false;
9144
+ let themeWasRequested = false;
9145
+ const themeLoaded = new Promise((res) => {
9146
+ themeDidLoad = () => {
9147
+ themeHasLoaded = true;
9148
+ res();
9149
+ };
9150
+ });
9151
+ const isClient = typeof window !== "undefined" && typeof fetch !== "undefined";
9152
+ documentStyles = isClient ? getComputedStyle(document.documentElement) : void 0;
9153
+ const iconRegistry = {};
9154
+ const iconRequests = {};
9155
+ function createThemePlugin(theme2, icons, iconLoaderUrl, iconLoader) {
9156
+ if (icons) {
9157
+ Object.assign(iconRegistry, icons);
9158
+ }
9159
+ if (isClient && !themeWasRequested && (documentStyles === null || documentStyles === void 0 ? void 0 : documentStyles.getPropertyValue("--formkit-theme"))) {
9160
+ themeDidLoad();
9161
+ themeWasRequested = true;
9162
+ } else if (theme2 && !themeWasRequested && isClient) {
9163
+ loadTheme(theme2);
9164
+ } else if (!themeWasRequested && isClient) {
9165
+ themeDidLoad();
9166
+ }
9167
+ const themePlugin = function themePlugin2(node) {
9168
+ var _a, _b;
9169
+ node.addProps(["iconLoader", "iconLoaderUrl"]);
9170
+ node.props.iconHandler = createIconHandler(((_a = node.props) === null || _a === void 0 ? void 0 : _a.iconLoader) ? node.props.iconLoader : iconLoader, ((_b = node.props) === null || _b === void 0 ? void 0 : _b.iconLoaderUrl) ? node.props.iconLoaderUrl : iconLoaderUrl);
9171
+ loadIconPropIcons(node, node.props.iconHandler);
9172
+ node.on("created", () => {
9173
+ var _a2;
9174
+ if ((_a2 = node === null || node === void 0 ? void 0 : node.context) === null || _a2 === void 0 ? void 0 : _a2.handlers) {
9175
+ node.context.handlers.iconClick = (sectionKey) => {
9176
+ const clickHandlerProp = `on${sectionKey.charAt(0).toUpperCase()}${sectionKey.slice(1)}IconClick`;
9177
+ const handlerFunction = node.props[clickHandlerProp];
9178
+ if (handlerFunction && typeof handlerFunction === "function") {
9179
+ return (e2) => {
9180
+ return handlerFunction(node, e2);
9181
+ };
9182
+ }
9183
+ return void 0;
9184
+ };
9185
+ }
9186
+ });
9187
+ };
9188
+ themePlugin.iconHandler = createIconHandler(iconLoader, iconLoaderUrl);
9189
+ return themePlugin;
9190
+ }
9191
+ function loadTheme(theme2) {
9192
+ if (!theme2 || !isClient || typeof getComputedStyle !== "function") {
9193
+ return;
9194
+ }
9195
+ themeWasRequested = true;
9196
+ documentThemeLinkTag = document.getElementById("formkit-theme");
9197
+ if (theme2 && isClient && (!(documentStyles === null || documentStyles === void 0 ? void 0 : documentStyles.getPropertyValue("--formkit-theme")) && !documentThemeLinkTag || (documentThemeLinkTag === null || documentThemeLinkTag === void 0 ? void 0 : documentThemeLinkTag.getAttribute("data-theme")) && (documentThemeLinkTag === null || documentThemeLinkTag === void 0 ? void 0 : documentThemeLinkTag.getAttribute("data-theme")) !== theme2)) {
9198
+ const formkitVersion = FORMKIT_VERSION.startsWith("__") ? "latest" : FORMKIT_VERSION;
9199
+ const themeUrl = `https://cdn.jsdelivr.net/npm/@formkit/themes@${formkitVersion}/dist/${theme2}/theme.css`;
9200
+ const link = document.createElement("link");
9201
+ link.type = "text/css";
9202
+ link.rel = "stylesheet";
9203
+ link.id = "formkit-theme";
9204
+ link.setAttribute("data-theme", theme2);
9205
+ link.onload = () => {
9206
+ documentStyles = getComputedStyle(document.documentElement);
9207
+ themeDidLoad();
9208
+ };
9209
+ document.head.appendChild(link);
9210
+ link.href = themeUrl;
9211
+ if (documentThemeLinkTag) {
9212
+ documentThemeLinkTag.remove();
9213
+ }
9214
+ }
9215
+ }
9216
+ function createIconHandler(iconLoader, iconLoaderUrl) {
9217
+ return (iconName) => {
9218
+ if (typeof iconName === "boolean") {
9219
+ return;
9220
+ }
9221
+ if (iconName.startsWith("<svg")) {
9222
+ return iconName;
9223
+ }
9224
+ if (typeof iconName !== "string")
9225
+ return;
9226
+ const icon2 = iconRegistry[iconName];
9227
+ const isDefault = iconName.startsWith("default:");
9228
+ iconName = isDefault ? iconName.split(":")[1] : iconName;
9229
+ let loadedIcon = void 0;
9230
+ if (icon2 || iconName in iconRegistry) {
9231
+ return icon2;
9232
+ } else if (!iconRequests[iconName]) {
9233
+ loadedIcon = getIconFromStylesheet(iconName);
9234
+ loadedIcon = isClient && typeof loadedIcon === "undefined" ? Promise.resolve(loadedIcon) : loadedIcon;
9235
+ if (loadedIcon instanceof Promise) {
9236
+ iconRequests[iconName] = loadedIcon.then((iconValue) => {
9237
+ if (!iconValue && typeof iconName === "string" && !isDefault) {
9238
+ return loadedIcon = typeof iconLoader === "function" ? iconLoader(iconName) : getRemoteIcon(iconName, iconLoaderUrl);
9239
+ }
9240
+ return iconValue;
9241
+ }).then((finalIcon) => {
9242
+ if (typeof iconName === "string") {
9243
+ iconRegistry[isDefault ? `default:${iconName}` : iconName] = finalIcon;
9244
+ }
9245
+ return finalIcon;
9246
+ });
9247
+ } else if (typeof loadedIcon === "string") {
9248
+ iconRegistry[isDefault ? `default:${iconName}` : iconName] = loadedIcon;
9249
+ return loadedIcon;
9250
+ }
9251
+ }
9252
+ return iconRequests[iconName];
9253
+ };
9254
+ }
9255
+ function getIconFromStylesheet(iconName) {
9256
+ if (!isClient)
9257
+ return;
9258
+ if (themeHasLoaded) {
9259
+ return loadStylesheetIcon(iconName);
9260
+ } else {
9261
+ return themeLoaded.then(() => {
9262
+ return loadStylesheetIcon(iconName);
9263
+ });
9264
+ }
9265
+ }
9266
+ function loadStylesheetIcon(iconName) {
9267
+ const cssVarIcon = documentStyles === null || documentStyles === void 0 ? void 0 : documentStyles.getPropertyValue(`--fk-icon-${iconName}`);
9268
+ if (cssVarIcon) {
9269
+ const icon2 = atob(cssVarIcon);
9270
+ if (icon2.startsWith("<svg")) {
9271
+ iconRegistry[iconName] = icon2;
9272
+ return icon2;
9273
+ }
9274
+ }
9275
+ return void 0;
9276
+ }
9277
+ function getRemoteIcon(iconName, iconLoaderUrl) {
9278
+ const formkitVersion = FORMKIT_VERSION.startsWith("__") ? "latest" : FORMKIT_VERSION;
9279
+ const fetchUrl = typeof iconLoaderUrl === "function" ? iconLoaderUrl(iconName) : `https://cdn.jsdelivr.net/npm/@formkit/icons@${formkitVersion}/dist/icons/${iconName}.svg`;
9280
+ if (!isClient)
9281
+ return void 0;
9282
+ return fetch(`${fetchUrl}`).then((r2) => __async(this, null, function* () {
9283
+ const icon2 = yield r2.text();
9284
+ if (icon2.startsWith("<svg")) {
9285
+ return icon2;
9286
+ }
9287
+ return void 0;
9288
+ })).catch((e2) => {
9289
+ console.error(e2);
9290
+ return void 0;
9291
+ });
9292
+ }
9293
+ function loadIconPropIcons(node, iconHandler) {
9294
+ const iconRegex = /^[a-zA-Z-]+(?:-icon|Icon)$/;
9295
+ const iconProps = Object.keys(node.props).filter((prop) => {
9296
+ return iconRegex.test(prop);
9297
+ });
9298
+ iconProps.forEach((sectionKey) => {
9299
+ return loadPropIcon(node, iconHandler, sectionKey);
9300
+ });
9301
+ }
9302
+ function loadPropIcon(node, iconHandler, sectionKey) {
9303
+ const iconName = node.props[sectionKey];
9304
+ const loadedIcon = iconHandler(iconName);
9305
+ const rawIconProp = `_raw${sectionKey.charAt(0).toUpperCase()}${sectionKey.slice(1)}`;
9306
+ const clickHandlerProp = `on${sectionKey.charAt(0).toUpperCase()}${sectionKey.slice(1)}Click`;
9307
+ node.addProps([rawIconProp, clickHandlerProp]);
9308
+ node.on(`prop:${sectionKey}`, reloadIcon);
9309
+ if (loadedIcon instanceof Promise) {
9310
+ return loadedIcon.then((svg) => {
9311
+ node.props[rawIconProp] = svg;
9312
+ });
9313
+ } else {
9314
+ node.props[rawIconProp] = loadedIcon;
9315
+ }
9316
+ return;
9317
+ }
9318
+ function reloadIcon(event) {
9319
+ var _a;
9320
+ const node = event.origin;
9321
+ const iconName = event.payload;
9322
+ const iconHandler = (_a = node === null || node === void 0 ? void 0 : node.props) === null || _a === void 0 ? void 0 : _a.iconHandler;
9323
+ const sectionKey = event.name.split(":")[1];
9324
+ const rawIconProp = `_raw${sectionKey.charAt(0).toUpperCase()}${sectionKey.slice(1)}`;
9325
+ if (iconHandler && typeof iconHandler === "function") {
9326
+ const loadedIcon = iconHandler(iconName);
9327
+ if (loadedIcon instanceof Promise) {
9328
+ return loadedIcon.then((svg) => {
9329
+ node.props[rawIconProp] = svg;
9330
+ });
9331
+ } else {
9332
+ node.props[rawIconProp] = loadedIcon;
9333
+ }
9334
+ }
9335
+ }
9247
9336
  let registered = false;
9248
9337
  const errors = {
9249
9338
  100: ({ data: node }) => `Only groups, lists, and forms can have children (${node.name}).`,
@@ -9265,7 +9354,8 @@ const warnings = {
9265
9354
  350: ({ data: node }) => `Invalid options prop for radio input (${node.name}). See https://formkit.com/inputs/radio`,
9266
9355
  650: 'Schema "$get()" must use the id of an input to access.',
9267
9356
  651: ({ data: id }) => `Cannot setErrors() on "${id}" because no such id exists.`,
9268
- 652: ({ data: id }) => `Cannot clearErrors() on "${id}" because no such id exists.`
9357
+ 652: ({ data: id }) => `Cannot clearErrors() on "${id}" because no such id exists.`,
9358
+ 800: ({ data: name }) => `${name} is deprecated.`
9269
9359
  };
9270
9360
  const decodeErrors = (error2, next) => {
9271
9361
  if (error2.code in errors) {
@@ -9546,6 +9636,8 @@ function parseSchema(library, schema) {
9546
9636
  return null;
9547
9637
  const instanceScope = instanceScopes.get(instanceKey) || [];
9548
9638
  for (const key in values) {
9639
+ if (Array.isArray(values) && key === "length")
9640
+ continue;
9549
9641
  const iterationData = Object.defineProperty(__spreadValues(__spreadProps(__spreadValues({}, instanceScope.reduce((previousIterationData, scopedData) => {
9550
9642
  if (previousIterationData.__idata) {
9551
9643
  return __spreadValues(__spreadValues({}, previousIterationData), scopedData);
@@ -9920,7 +10012,10 @@ const pseudoProps = [
9920
10012
  "preserve",
9921
10013
  /^preserve(-e|E)rrors/,
9922
10014
  /^[a-z]+(?:-visibility|Visibility)$/,
9923
- /^[a-zA-Z-]+(?:-class|Class)$/
10015
+ /^[a-zA-Z-]+(?:-class|Class)$/,
10016
+ "prefixIcon",
10017
+ "suffixIcon",
10018
+ /^[a-zA-Z-]+(?:-icon|Icon)$/
9924
10019
  ];
9925
10020
  function classesToNodeProps(node, props2) {
9926
10021
  if (props2.classes) {
@@ -10040,6 +10135,8 @@ function useInput(props2, context, options2 = {}) {
10040
10135
  const sourceKey = `${node.name}-prop`;
10041
10136
  watchEffect(() => {
10042
10137
  const keys = Object.keys(props2.inputErrors);
10138
+ if (!keys.length)
10139
+ node.clearErrors(true, sourceKey);
10043
10140
  const messages2 = keys.reduce((messages3, key) => {
10044
10141
  let value2 = props2.inputErrors[key];
10045
10142
  if (typeof value2 === "string")
@@ -10197,7 +10294,12 @@ const vueBindings = function vueBindings2(node) {
10197
10294
  eq
10198
10295
  },
10199
10296
  handlers: {
10200
- blur: () => node.store.set(createMessage({ key: "blurred", visible: false, value: true })),
10297
+ blur: (e2) => {
10298
+ node.store.set(createMessage({ key: "blurred", visible: false, value: true }));
10299
+ if (typeof node.props.attrs.onBlur === "function") {
10300
+ node.props.attrs.onBlur(e2);
10301
+ }
10302
+ },
10201
10303
  touch: () => {
10202
10304
  node.store.set(createMessage({ key: "dirty", visible: false, value: true }));
10203
10305
  },
@@ -10250,18 +10352,25 @@ const vueBindings = function vueBindings2(node) {
10250
10352
  });
10251
10353
  });
10252
10354
  }
10253
- const rootProps = [
10254
- "help",
10255
- "label",
10256
- "disabled",
10257
- "options",
10258
- "type",
10259
- "attrs",
10260
- "preserve",
10261
- "preserveErrors",
10262
- "id"
10263
- ];
10264
- observeProps(rootProps);
10355
+ const rootProps = () => {
10356
+ const props2 = [
10357
+ "help",
10358
+ "label",
10359
+ "disabled",
10360
+ "options",
10361
+ "type",
10362
+ "attrs",
10363
+ "preserve",
10364
+ "preserveErrors",
10365
+ "id"
10366
+ ];
10367
+ const iconPattern = /^[a-zA-Z-]+(?:-icon|Icon)$/;
10368
+ const matchingProps = Object.keys(node.props).filter((prop) => {
10369
+ return iconPattern.test(prop);
10370
+ });
10371
+ return props2.concat(matchingProps);
10372
+ };
10373
+ observeProps(rootProps());
10265
10374
  function definedAs(definition) {
10266
10375
  if (definition.props)
10267
10376
  observeProps(definition.props);
@@ -10322,14 +10431,71 @@ const vueBindings = function vueBindings2(node) {
10322
10431
  node.emit("context", node, false);
10323
10432
  };
10324
10433
  const defaultConfig = (options2 = {}) => {
10325
- const _a = options2, { rules = {}, locales = {}, inputs: inputs$1 = {}, messages: messages2 = {}, locale = void 0 } = _a, nodeOptions = __objRest(_a, ["rules", "locales", "inputs", "messages", "locale"]);
10434
+ const _a = options2, { rules = {}, locales = {}, inputs: inputs$1 = {}, messages: messages2 = {}, locale = void 0, theme: theme2 = void 0, iconLoaderUrl = void 0, iconLoader = void 0, icons = {} } = _a, nodeOptions = __objRest(_a, ["rules", "locales", "inputs", "messages", "locale", "theme", "iconLoaderUrl", "iconLoader", "icons"]);
10326
10435
  const validation = createValidationPlugin(__spreadValues(__spreadValues({}, defaultRules), rules || {}));
10327
10436
  const i18n = createI18nPlugin(extend(__spreadValues({ en }, locales || {}), messages2));
10328
- const library = createLibraryPlugin(inputs, inputs$1);
10437
+ const library = createLibraryPlugin(index$1, inputs$1);
10438
+ const themePlugin = createThemePlugin(theme2, icons, iconLoaderUrl, iconLoader);
10329
10439
  return extend(__spreadValues({
10330
- plugins: [library, vueBindings, i18n, validation]
10440
+ plugins: [library, themePlugin, vueBindings, i18n, validation]
10331
10441
  }, !locale ? {} : { config: { locale } }), nodeOptions || {}, true);
10332
10442
  };
10443
+ defineComponent({
10444
+ props: {
10445
+ icon: {
10446
+ type: String,
10447
+ default: ""
10448
+ },
10449
+ iconLoader: {
10450
+ type: Function,
10451
+ default: null
10452
+ },
10453
+ iconLoaderUrl: {
10454
+ type: Function,
10455
+ default: null
10456
+ }
10457
+ },
10458
+ setup(props2) {
10459
+ var _a, _b;
10460
+ const icon2 = ref(void 0);
10461
+ const config = inject(optionsSymbol, {});
10462
+ const parent = inject(parentSymbol, null);
10463
+ let iconHandler = void 0;
10464
+ if (props2.iconLoader && typeof props2.iconLoader === "function") {
10465
+ iconHandler = createIconHandler(props2.iconLoader);
10466
+ } else if (parent && ((_a = parent.props) === null || _a === void 0 ? void 0 : _a.iconLoader)) {
10467
+ iconHandler = createIconHandler(parent.props.iconLoader);
10468
+ } else if (props2.iconLoaderUrl && typeof props2.iconLoaderUrl === "function") {
10469
+ iconHandler = createIconHandler(iconHandler, props2.iconLoaderUrl);
10470
+ } else {
10471
+ const iconPlugin = (_b = config === null || config === void 0 ? void 0 : config.plugins) === null || _b === void 0 ? void 0 : _b.find((plugin2) => {
10472
+ return typeof plugin2.iconHandler === "function";
10473
+ });
10474
+ if (iconPlugin) {
10475
+ iconHandler = iconPlugin.iconHandler;
10476
+ }
10477
+ }
10478
+ if (iconHandler && typeof iconHandler === "function") {
10479
+ const iconOrPromise = iconHandler(props2.icon);
10480
+ if (iconOrPromise instanceof Promise) {
10481
+ iconOrPromise.then((iconValue) => {
10482
+ icon2.value = iconValue;
10483
+ });
10484
+ } else {
10485
+ icon2.value = iconOrPromise;
10486
+ }
10487
+ }
10488
+ return () => {
10489
+ if (icon2.value) {
10490
+ return h$1("span", {
10491
+ class: "formkit-icon",
10492
+ innerHTML: icon2.value
10493
+ });
10494
+ }
10495
+ return null;
10496
+ };
10497
+ }
10498
+ });
10333
10499
  var createPlugin$3 = {};
10334
10500
  var createPlugin$2 = {};
10335
10501
  Object.defineProperty(createPlugin$2, "__esModule", {
@@ -10371,42 +10537,6 @@ var _default = _createPlugin.default;
10371
10537
  createPlugin$3.default = _default;
10372
10538
  let createPlugin = createPlugin$3;
10373
10539
  var plugin = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default;
10374
- function generateClasses(classes) {
10375
- const classesBySectionKey = {};
10376
- Object.keys(classes).forEach((type) => {
10377
- Object.keys(classes[type]).forEach((sectionKey) => {
10378
- if (!classesBySectionKey[sectionKey]) {
10379
- classesBySectionKey[sectionKey] = {
10380
- [type]: classes[type][sectionKey]
10381
- };
10382
- } else {
10383
- classesBySectionKey[sectionKey][type] = classes[type][sectionKey];
10384
- }
10385
- });
10386
- });
10387
- Object.keys(classesBySectionKey).forEach((sectionKey) => {
10388
- const classesObject = classesBySectionKey[sectionKey];
10389
- classesBySectionKey[sectionKey] = function(node, sectionKey2) {
10390
- return addClassesBySection(node, sectionKey2, classesObject);
10391
- };
10392
- });
10393
- return classesBySectionKey;
10394
- }
10395
- function addClassesBySection(node, _sectionKey, classesByType) {
10396
- const type = node.props.type;
10397
- let classList = "";
10398
- if (classesByType.global) {
10399
- classList += classesByType.global + " ";
10400
- }
10401
- if (classesByType[type]) {
10402
- classList += classesByType[type];
10403
- }
10404
- const listParts = classList.split("$reset");
10405
- if (listParts.length > 1) {
10406
- return `$reset ${listParts[listParts.length - 1].trim()}`;
10407
- }
10408
- return listParts[0].trim();
10409
- }
10410
10540
  plugin(({ addVariant }) => {
10411
10541
  console.warn("@formkit/tailwindcss is deprecated in favor of @formkit/themes");
10412
10542
  addVariant("formkit-disabled", [
@@ -10695,6 +10825,10 @@ function schemaFromUrl(url3) {
10695
10825
  return schemaObj;
10696
10826
  });
10697
10827
  }
10828
+ const getBaseDomain = () => {
10829
+ var parts = window.location.host.split(".");
10830
+ return parts.slice(-2).join(".");
10831
+ };
10698
10832
  const flattenObj = (obj) => {
10699
10833
  const flattened = {};
10700
10834
  Object.keys(obj).forEach((key) => {
@@ -10830,6 +10964,7 @@ var theme = {
10830
10964
  };
10831
10965
  var index = "";
10832
10966
  const apps = {};
10967
+ const defaultSubmitUrl = "https://webhooks." + getBaseDomain() + "/api/v1/form_leads_ext";
10833
10968
  const init = () => {
10834
10969
  const classes = generateClasses(theme);
10835
10970
  const forms = window.bhlFormDefs || [];
@@ -10850,10 +10985,13 @@ const init = () => {
10850
10985
  }
10851
10986
  }
10852
10987
  let schemaObj = schema;
10853
- if (typeof schema === "string") {
10988
+ if (schema instanceof Function) {
10989
+ schemaObj = schema();
10990
+ } else if (typeof schema === "string") {
10854
10991
  schemaObj = yield schemaFromUrl(schema);
10855
10992
  }
10856
10993
  const data = form2.data || {};
10994
+ data.submitUrl = data.submitUrl || defaultSubmitUrl;
10857
10995
  data.prepData = data.prepData || prepData;
10858
10996
  data.fireStepEvent = data.fireStepEvent || fireStepEvent;
10859
10997
  const app = createApp(_sfc_main, { schema: schemaObj, data }).use(plugin$1, defaultConfig({