bhl-forms 0.0.80 → 0.0.82

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.
@@ -4684,13 +4684,13 @@ const getCoords$1 = (elem) => {
4684
4684
  left: box2.left + window.pageXOffset
4685
4685
  };
4686
4686
  };
4687
- const postJSON = (url3, data) => __async(this, null, function* () {
4687
+ const postData = (url3, data, contentType = "application/json") => __async(this, null, function* () {
4688
4688
  dbg$1("Post to: " + url3);
4689
4689
  const raw2 = yield fetch(url3, {
4690
4690
  method: "POST",
4691
4691
  headers: {
4692
4692
  "Accept": "application/json",
4693
- "Content-Type": "application/json"
4693
+ "Content-Type": contentType
4694
4694
  },
4695
4695
  body: JSON.stringify(data)
4696
4696
  });
@@ -4704,7 +4704,7 @@ const postJSON = (url3, data) => __async(this, null, function* () {
4704
4704
  return res;
4705
4705
  });
4706
4706
  const redirectTo = (url3) => {
4707
- window.location.href = url3;
4707
+ window.location = url3;
4708
4708
  };
4709
4709
  const openNewTab = (url3) => {
4710
4710
  var otherTab = window.open();
@@ -4824,6 +4824,14 @@ function usePrepop() {
4824
4824
  };
4825
4825
  return { prepopPlugin: prepopPlugin2, prepopSettings };
4826
4826
  }
4827
+ const explicitKeys$1 = [
4828
+ "__key",
4829
+ "__init",
4830
+ "__shim",
4831
+ "__original",
4832
+ "__index",
4833
+ "__prevKey"
4834
+ ];
4827
4835
  function token$1() {
4828
4836
  return Math.random().toString(36).substring(2, 15);
4829
4837
  }
@@ -4863,7 +4871,7 @@ function camel$1(str) {
4863
4871
  function kebab$1(str) {
4864
4872
  return str.replace(/([a-z0-9])([A-Z])/g, (_s, trail, cap) => trail + "-" + cap.toLowerCase()).replace(" ", "-").toLowerCase();
4865
4873
  }
4866
- function clone$1(obj, explicit = ["__key", "__init"]) {
4874
+ function clone$1(obj, explicit = explicitKeys$1) {
4867
4875
  if (obj === null || obj instanceof RegExp || obj instanceof Date || obj instanceof Map || obj instanceof Set || typeof File === "function" && obj instanceof File)
4868
4876
  return obj;
4869
4877
  let returnObject;
@@ -5208,7 +5216,7 @@ function createValue$1(options2) {
5208
5216
  } else if (options2.type === "list") {
5209
5217
  return init$2(Array.isArray(options2.value) ? options2.value : []);
5210
5218
  }
5211
- return options2.value === null ? "" : options2.value;
5219
+ return options2.value;
5212
5220
  }
5213
5221
  function input$1(node, context, value, async = true) {
5214
5222
  context._value = validateInput$1(node, node.hook.input.dispatch(value));
@@ -5333,6 +5341,14 @@ function define$1(node, context, definition) {
5333
5341
  type: node.type,
5334
5342
  value: context.value
5335
5343
  });
5344
+ if (definition.forceTypeProp) {
5345
+ if (node.props.type)
5346
+ node.props.originalType = node.props.type;
5347
+ context.props.type = definition.forceTypeProp;
5348
+ }
5349
+ if (definition.family) {
5350
+ context.props.family = definition.family;
5351
+ }
5336
5352
  if (definition.features) {
5337
5353
  definition.features.forEach((feature) => feature(node));
5338
5354
  }
@@ -5917,7 +5933,7 @@ const dataDefaults = {
5917
5933
  redirectTo(redirectUrl);
5918
5934
  }
5919
5935
  },
5920
- submit: (postUrl, prepData2 = null, redirect = null) => (formData, node) => __async(this, null, function* () {
5936
+ submit: (postUrl, prepData2 = null, redirect = null, contentType = "application/json") => (formData, node) => __async(this, null, function* () {
5921
5937
  if (prepData2 && prepData2 != "null") {
5922
5938
  if (!(prepData2 instanceof Function)) {
5923
5939
  throw "prepData must be a function";
@@ -5926,13 +5942,14 @@ const dataDefaults = {
5926
5942
  }
5927
5943
  let abort = false;
5928
5944
  try {
5929
- const res = yield postJSON(postUrl, formData);
5945
+ const res = yield postData(postUrl, formData, contentType);
5930
5946
  node.clearErrors();
5931
5947
  } catch (err) {
5948
+ console.error(err);
5932
5949
  abort = handleSubmitError(err, node);
5933
5950
  }
5934
5951
  if (abort) {
5935
- return false;
5952
+ return;
5936
5953
  }
5937
5954
  if (typeof redirect === "string" && redirect !== "null") {
5938
5955
  if (formData) {
@@ -5940,9 +5957,8 @@ const dataDefaults = {
5940
5957
  }
5941
5958
  redirectTo(redirect);
5942
5959
  } else if (redirect) {
5943
- redirect(formData, node);
5960
+ yield redirect(formData, node);
5944
5961
  }
5945
- return true;
5946
5962
  }),
5947
5963
  stringify: (value) => JSON.stringify(value, null, 2)
5948
5964
  };
@@ -5972,6 +5988,14 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign(__default__, {
5972
5988
  };
5973
5989
  }
5974
5990
  });
5991
+ const explicitKeys = [
5992
+ "__key",
5993
+ "__init",
5994
+ "__shim",
5995
+ "__original",
5996
+ "__index",
5997
+ "__prevKey"
5998
+ ];
5975
5999
  function token() {
5976
6000
  return Math.random().toString(36).substring(2, 15);
5977
6001
  }
@@ -6202,7 +6226,21 @@ function camel(str) {
6202
6226
  function kebab(str) {
6203
6227
  return str.replace(/([a-z0-9])([A-Z])/g, (_s, trail, cap) => trail + "-" + cap.toLowerCase()).replace(" ", "-").toLowerCase();
6204
6228
  }
6205
- function clone(obj, explicit = ["__key", "__init"]) {
6229
+ function shallowClone(obj, explicit = explicitKeys) {
6230
+ if (obj !== null && typeof obj === "object") {
6231
+ let returnObject;
6232
+ if (Array.isArray(obj))
6233
+ returnObject = [...obj];
6234
+ else if (isPojo(obj))
6235
+ returnObject = __spreadValues({}, obj);
6236
+ if (returnObject) {
6237
+ applyExplicit(obj, returnObject, explicit);
6238
+ return returnObject;
6239
+ }
6240
+ }
6241
+ return obj;
6242
+ }
6243
+ function clone(obj, explicit = explicitKeys) {
6206
6244
  if (obj === null || obj instanceof RegExp || obj instanceof Date || obj instanceof Map || obj instanceof Set || typeof File === "function" && obj instanceof File)
6207
6245
  return obj;
6208
6246
  let returnObject;
@@ -6260,6 +6298,17 @@ function init$1(obj) {
6260
6298
  function slugify(str) {
6261
6299
  return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]/g, " ").trim().replace(/\s+/g, "-");
6262
6300
  }
6301
+ function applyExplicit(original, obj, explicit) {
6302
+ for (const key of explicit) {
6303
+ if (key in original) {
6304
+ Object.defineProperty(obj, key, {
6305
+ enumerable: false,
6306
+ value: original[key]
6307
+ });
6308
+ }
6309
+ }
6310
+ return obj;
6311
+ }
6263
6312
  function createDispatcher$1() {
6264
6313
  const middleware = [];
6265
6314
  let currentIndex = 0;
@@ -6867,7 +6916,7 @@ function createValue(options2) {
6867
6916
  } else if (options2.type === "list") {
6868
6917
  return init$1(Array.isArray(options2.value) ? options2.value : []);
6869
6918
  }
6870
- return options2.value === null ? "" : options2.value;
6919
+ return options2.value;
6871
6920
  }
6872
6921
  function input(node, context, value, async = true) {
6873
6922
  context._value = validateInput(node, node.hook.input.dispatch(value));
@@ -7814,7 +7863,7 @@ function clearErrors(id, clearChildren = true) {
7814
7863
  warn(652, id);
7815
7864
  }
7816
7865
  }
7817
- const FORMKIT_VERSION = "1.0.0-beta.10";
7866
+ const FORMKIT_VERSION = "1.0.0-beta.11";
7818
7867
  function createLibraryPlugin(...libraries) {
7819
7868
  const library = libraries.reduce((merged, lib) => extend(merged, lib), {});
7820
7869
  const plugin2 = () => {
@@ -7827,6 +7876,64 @@ function createLibraryPlugin(...libraries) {
7827
7876
  };
7828
7877
  return plugin2;
7829
7878
  }
7879
+ function normalizeOptions(options2) {
7880
+ let i2 = 1;
7881
+ if (Array.isArray(options2)) {
7882
+ return options2.map((option2) => {
7883
+ if (typeof option2 === "string" || typeof option2 === "number") {
7884
+ return {
7885
+ label: String(option2),
7886
+ value: String(option2)
7887
+ };
7888
+ }
7889
+ if (typeof option2 == "object") {
7890
+ if ("value" in option2 && typeof option2.value !== "string") {
7891
+ Object.assign(option2, {
7892
+ value: `__mask_${i2++}`,
7893
+ __original: option2.value
7894
+ });
7895
+ }
7896
+ }
7897
+ return option2;
7898
+ });
7899
+ }
7900
+ return Object.keys(options2).map((value) => {
7901
+ return {
7902
+ label: options2[value],
7903
+ value
7904
+ };
7905
+ });
7906
+ }
7907
+ function optionValue(options2, value) {
7908
+ if (Array.isArray(options2)) {
7909
+ for (const option2 of options2) {
7910
+ if (value == option2.value) {
7911
+ return "__original" in option2 ? option2.__original : option2.value;
7912
+ }
7913
+ }
7914
+ }
7915
+ return value;
7916
+ }
7917
+ function shouldSelect(valueA, valueB) {
7918
+ if (valueA == valueB)
7919
+ return true;
7920
+ if (isPojo(valueA) && isPojo(valueB))
7921
+ return eq(valueA, valueB);
7922
+ return false;
7923
+ }
7924
+ function options(node) {
7925
+ node.hook.prop((prop, next) => {
7926
+ if (prop.prop === "options") {
7927
+ if (typeof prop.value === "function") {
7928
+ node.props.optionsLoader = prop.value;
7929
+ prop.value = [];
7930
+ } else {
7931
+ prop.value = normalizeOptions(prop.value);
7932
+ }
7933
+ }
7934
+ return next(prop);
7935
+ });
7936
+ }
7830
7937
  const outer = createSection("outer", () => ({
7831
7938
  $el: "div",
7832
7939
  attrs: {
@@ -8140,60 +8247,6 @@ function normalizeBoxes(node) {
8140
8247
  return next(prop);
8141
8248
  };
8142
8249
  }
8143
- function normalizeOptions(options2) {
8144
- let i2 = 1;
8145
- if (Array.isArray(options2)) {
8146
- return options2.map((option2) => {
8147
- if (typeof option2 === "string" || typeof option2 === "number") {
8148
- return {
8149
- label: option2,
8150
- value: option2
8151
- };
8152
- }
8153
- if (typeof option2 == "object") {
8154
- if ("value" in option2 && typeof option2.value !== "string") {
8155
- Object.assign(option2, {
8156
- value: `__mask_${i2++}`,
8157
- __original: option2.value
8158
- });
8159
- }
8160
- }
8161
- return option2;
8162
- });
8163
- }
8164
- return Object.keys(options2).map((value) => {
8165
- return {
8166
- label: options2[value],
8167
- value
8168
- };
8169
- });
8170
- }
8171
- function optionValue(options2, value) {
8172
- if (Array.isArray(options2)) {
8173
- for (const option2 of options2) {
8174
- if (value == option2.value) {
8175
- return "__original" in option2 ? option2.__original : option2.value;
8176
- }
8177
- }
8178
- }
8179
- return value;
8180
- }
8181
- function shouldSelect(valueA, valueB) {
8182
- if (valueA == valueB)
8183
- return true;
8184
- if (isPojo(valueA) && isPojo(valueB))
8185
- return eq(valueA, valueB);
8186
- return false;
8187
- }
8188
- function options(node) {
8189
- node.hook.prop((prop, next) => {
8190
- if (prop.prop === "options") {
8191
- const options2 = normalizeOptions(prop.value);
8192
- prop.value = options2;
8193
- }
8194
- return next(prop);
8195
- });
8196
- }
8197
8250
  function toggleChecked$1(node, e) {
8198
8251
  const el = e.target;
8199
8252
  if (el instanceof HTMLInputElement) {
@@ -8582,12 +8635,15 @@ function createRoot(rootSection) {
8582
8635
  function $if(condition, then, otherwise) {
8583
8636
  return (extensions) => {
8584
8637
  const node = then(extensions);
8585
- if (otherwise) {
8586
- return {
8638
+ if (otherwise || isSchemaObject(node) && "if" in node || isSlotCondition(node)) {
8639
+ const conditionalNode = {
8587
8640
  if: condition,
8588
- then: node,
8589
- else: otherwise(extensions)
8641
+ then: node
8590
8642
  };
8643
+ if (otherwise) {
8644
+ conditionalNode.else = otherwise(extensions);
8645
+ }
8646
+ return conditionalNode;
8591
8647
  } else if (isSlotCondition(node)) {
8592
8648
  Object.assign(node.else, { if: condition });
8593
8649
  } else if (isSchemaObject(node)) {
@@ -8629,7 +8685,7 @@ const checkbox = {
8629
8685
  }), decorator(icon("decorator")), suffix()), $if("$option.label", boxLabel("$option.label"))), boxHelp("$option.help"))))), $if("$options == undefined && $help", help("$help")), messages(message("$message.value"))),
8630
8686
  type: "input",
8631
8687
  family: "box",
8632
- props: ["options", "onValue", "offValue"],
8688
+ props: ["options", "onValue", "offValue", "optionsLoader"],
8633
8689
  features: [
8634
8690
  options,
8635
8691
  checkboxes,
@@ -8687,16 +8743,16 @@ const radio = {
8687
8743
  value: "$option.value",
8688
8744
  checked: "$fns.isChecked($option.value)"
8689
8745
  }
8690
- }), decorator(icon("decorator")), suffix()), $if("$option.label", boxLabel("$option.label"))), boxHelp("$option.help"))))), $if("$options == undefined && $help", help("$help")), messages(message("$message.value"))),
8746
+ }), decorator(icon("decorator")), suffix()), $if("$option.label", boxLabel("$option.label"))), boxHelp("$option.help"))))), $if("$options === undefined && $help", help("$help")), messages(message("$message.value"))),
8691
8747
  type: "input",
8692
8748
  family: "box",
8693
- props: ["options", "onValue", "offValue"],
8749
+ props: ["options", "onValue", "offValue", "optionsLoader"],
8694
8750
  features: [options, radios, defaultIcon("decorator", "radioDecorator")]
8695
8751
  };
8696
8752
  const select = {
8697
8753
  schema: outer(wrapper(label("$label"), inner(icon("prefix"), prefix(), selectInput$1($if("$slots.default", () => "$slots.default", $if("$slots.option", optionSlot, option("$option.label")))), $if("$attrs.multiple !== undefined", () => "", icon("select")), suffix(), icon("suffix"))), help("$help"), messages(message("$message.value"))),
8698
8754
  type: "input",
8699
- props: ["options", "placeholder"],
8755
+ props: ["options", "placeholder", "optionsLoader"],
8700
8756
  features: [options, select$1, defaultIcon("select", "select")]
8701
8757
  };
8702
8758
  const textarea = {
@@ -8743,6 +8799,7 @@ var index$1 = /* @__PURE__ */ Object.freeze({
8743
8799
  const accepted = function accepted2({ value }) {
8744
8800
  return ["yes", "on", "1", 1, true, "true"].includes(value);
8745
8801
  };
8802
+ accepted.skipEmpty = false;
8746
8803
  const date_after = function({ value }, compare = false) {
8747
8804
  const timestamp = Date.parse(compare || new Date());
8748
8805
  const fieldValue = Date.parse(String(value));
@@ -9364,7 +9421,11 @@ const ui$s = {
9364
9421
  removeAll: "Remove all",
9365
9422
  incomplete: "Sorry, not all fields are filled out correctly.",
9366
9423
  submit: "Submit",
9367
- noFiles: "No file chosen"
9424
+ noFiles: "No file chosen",
9425
+ moveUp: "Move up",
9426
+ moveDown: "Move down",
9427
+ isLoading: "Loading...",
9428
+ loadMore: "Load more"
9368
9429
  };
9369
9430
  const validation$s = {
9370
9431
  accepted({ name }) {
@@ -9643,7 +9704,7 @@ function createIconHandler(iconLoader, iconLoaderUrl) {
9643
9704
  iconName = isDefault ? iconName.split(":")[1] : iconName;
9644
9705
  let loadedIcon = void 0;
9645
9706
  if (icon2 || iconName in iconRegistry) {
9646
- return icon2;
9707
+ return iconRegistry[iconName];
9647
9708
  } else if (!iconRequests[iconName]) {
9648
9709
  loadedIcon = getIconFromStylesheet(iconName);
9649
9710
  loadedIcon = isClient && typeof loadedIcon === "undefined" ? Promise.resolve(loadedIcon) : loadedIcon;
@@ -9759,6 +9820,7 @@ const errors = {
9759
9820
  106: ({ data: name }) => `Cannot submit because (${name}) is not in a form.`,
9760
9821
  107: ({ data: [node, value] }) => `Cannot set ${node.name} to non object value: ${value}`,
9761
9822
  108: ({ data: [node, value] }) => `Cannot set ${node.name} to non array value: ${value}`,
9823
+ 300: ({ data: [node] }) => `Cannot set behavior prop to overscroll (on ${node.name} input) when options prop is a function.`,
9762
9824
  600: ({ data: node }) => `Unknown input type${typeof node.props.type === "string" ? ' "' + node.props.type + '"' : ""} ("${node.name}")`,
9763
9825
  601: ({ data: node }) => `Input definition${typeof node.props.type === "string" ? ' "' + node.props.type + '"' : ""} is missing a schema or component property (${node.name}).`
9764
9826
  };
@@ -9817,17 +9879,20 @@ function getValue(set2, path) {
9817
9879
  return void 0;
9818
9880
  }
9819
9881
  let foundValue = void 0;
9820
- path.reduce((obj, segment, i2, arr) => {
9821
- if (typeof obj !== "object") {
9882
+ let obj = set2;
9883
+ for (const i2 in path) {
9884
+ const key = path[i2];
9885
+ if (typeof obj !== "object" || obj === null) {
9822
9886
  foundValue = void 0;
9823
- return arr.splice(1);
9887
+ break;
9824
9888
  }
9825
- const currentValue = obj[segment];
9826
- if (i2 === path.length - 1 && currentValue !== void 0) {
9889
+ const currentValue = obj[key];
9890
+ if (Number(i2) === path.length - 1 && currentValue !== void 0) {
9827
9891
  foundValue = currentValue;
9892
+ break;
9828
9893
  }
9829
- return obj[segment];
9830
- }, set2);
9894
+ obj = currentValue;
9895
+ }
9831
9896
  return foundValue;
9832
9897
  }
9833
9898
  function get$1(nodeRefs, id) {
@@ -10601,6 +10666,9 @@ function useInput(props2, context, options2 = {}) {
10601
10666
  else
10602
10667
  (_a = node.at(path)) === null || _a === void 0 ? void 0 : _a.input(value2, false);
10603
10668
  });
10669
+ if (node.value !== value) {
10670
+ node.emit("modelUpdated");
10671
+ }
10604
10672
  }
10605
10673
  onUnmounted(() => node.destroy());
10606
10674
  return node;
@@ -10822,12 +10890,20 @@ const vueBindings = function vueBindings2(node) {
10822
10890
  node.props.definition && definedAs(node.props.definition);
10823
10891
  node.on("added-props", ({ payload }) => observeProps(payload));
10824
10892
  node.on("input", ({ payload }) => {
10825
- _value.value = payload;
10826
- triggerRef(_value);
10893
+ if (node.type !== "input" && !isRef(payload) && !isReactive(payload)) {
10894
+ _value.value = shallowClone(payload);
10895
+ } else {
10896
+ _value.value = payload;
10897
+ triggerRef(_value);
10898
+ }
10827
10899
  });
10828
10900
  node.on("commit", ({ payload }) => {
10829
- value.value = _value.value = payload;
10830
- triggerRef(value);
10901
+ if (node.type !== "input" && !isRef(payload) && !isReactive(payload)) {
10902
+ value.value = _value.value = shallowClone(payload);
10903
+ } else {
10904
+ value.value = _value.value = payload;
10905
+ triggerRef(value);
10906
+ }
10831
10907
  node.emit("modelUpdated");
10832
10908
  if (!context.state.dirty && node.isCreated && hasTicked && !eq(value.value, node.props._init))
10833
10909
  context.handlers.touch();
@@ -11268,7 +11344,7 @@ const doRedirect = (redirectUrl, newTabUrl) => {
11268
11344
  dbg("redirect:", redirectUrl, "newTab:", newTabUrl);
11269
11345
  redirectTo(redirectUrl);
11270
11346
  };
11271
- const handleRedirect = (formData, node) => {
11347
+ const handleRedirect = (formData, node) => __async(this, null, function* () {
11272
11348
  try {
11273
11349
  var redirectUrl = getRedirect(formData, node);
11274
11350
  if (redirectUrl && redirectUrl !== "null") {
@@ -11287,13 +11363,16 @@ const handleRedirect = (formData, node) => {
11287
11363
  } else {
11288
11364
  doRedirect(redirectUrl, null);
11289
11365
  }
11366
+ yield new Promise((resolve2) => setTimeout(resolve2, 2e3));
11367
+ } else {
11368
+ rollbar("warning", "No redirectUrl found");
11290
11369
  }
11291
11370
  } catch (err) {
11292
11371
  const msg = "failed to handleRedirect: " + err.toString();
11293
11372
  console.warn(msg);
11294
11373
  rollbar("warning", msg);
11295
11374
  }
11296
- };
11375
+ });
11297
11376
  const textClassification = {
11298
11377
  label: "t-block t-mb-3 t-font-semibold t-text-base formkit-invalid:t-text-red-500",
11299
11378
  inner: `