web-mojo 2.1.458 → 2.1.498

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.
Files changed (66) hide show
  1. package/dist/admin.cjs.js +1 -1
  2. package/dist/admin.cjs.js.map +1 -1
  3. package/dist/admin.es.js +29 -187
  4. package/dist/admin.es.js.map +1 -1
  5. package/dist/auth.cjs.js +1 -1
  6. package/dist/auth.cjs.js.map +1 -1
  7. package/dist/auth.es.js +3 -3
  8. package/dist/auth.es.js.map +1 -1
  9. package/dist/charts.cjs.js +1 -1
  10. package/dist/charts.es.js +2 -2
  11. package/dist/chat.css +392 -0
  12. package/dist/chunks/ChatView-D4ZiYBzL.js +2 -0
  13. package/dist/chunks/ChatView-D4ZiYBzL.js.map +1 -0
  14. package/dist/chunks/{FilePreviewView-CehLQVJa.js → ChatView-DkK2PBny.js} +620 -84
  15. package/dist/chunks/ChatView-DkK2PBny.js.map +1 -0
  16. package/dist/chunks/{ContextMenu-BjQymcpo.js → ContextMenu-A1PxR6Zt.js} +2 -2
  17. package/dist/chunks/{ContextMenu-BjQymcpo.js.map → ContextMenu-A1PxR6Zt.js.map} +1 -1
  18. package/dist/chunks/{ContextMenu-C0sdb9u5.js → ContextMenu-B4LTfsNs.js} +2 -2
  19. package/dist/chunks/{ContextMenu-C0sdb9u5.js.map → ContextMenu-B4LTfsNs.js.map} +1 -1
  20. package/dist/chunks/{DataView-DDe4NgiH.js → DataView-BIfnT2oG.js} +2 -2
  21. package/dist/chunks/{DataView-DDe4NgiH.js.map → DataView-BIfnT2oG.js.map} +1 -1
  22. package/dist/chunks/{DataView-Cl4kRP-W.js → DataView-DGEl3x72.js} +2 -2
  23. package/dist/chunks/{DataView-Cl4kRP-W.js.map → DataView-DGEl3x72.js.map} +1 -1
  24. package/dist/chunks/{Dialog-upGYwvdZ.js → Dialog-DtSluuiz.js} +5 -5
  25. package/dist/chunks/{Dialog-upGYwvdZ.js.map → Dialog-DtSluuiz.js.map} +1 -1
  26. package/dist/chunks/{Dialog-DAQdjRci.js → Dialog-pH-ua3tF.js} +2 -2
  27. package/dist/chunks/{Dialog-DAQdjRci.js.map → Dialog-pH-ua3tF.js.map} +1 -1
  28. package/dist/chunks/{FormView-B7pwdxqX.js → FormView-CDG8qMdU.js} +3 -3
  29. package/dist/chunks/FormView-CDG8qMdU.js.map +1 -0
  30. package/dist/chunks/{FormView-C9PgTIH2.js → FormView-DrvkHPA-.js} +99 -10
  31. package/dist/chunks/FormView-DrvkHPA-.js.map +1 -0
  32. package/dist/chunks/{MetricsChart-TwtfTNEA.js → MetricsChart-Bo0ky0UE.js} +2 -2
  33. package/dist/chunks/{MetricsChart-TwtfTNEA.js.map → MetricsChart-Bo0ky0UE.js.map} +1 -1
  34. package/dist/chunks/{MetricsChart-x15UvXRk.js → MetricsChart-DJU0UetE.js} +3 -3
  35. package/dist/chunks/{MetricsChart-x15UvXRk.js.map → MetricsChart-DJU0UetE.js.map} +1 -1
  36. package/dist/chunks/{PDFViewer-tK1fntDR.js → PDFViewer-8HA3oUBX.js} +2 -2
  37. package/dist/chunks/{PDFViewer-tK1fntDR.js.map → PDFViewer-8HA3oUBX.js.map} +1 -1
  38. package/dist/chunks/{PDFViewer---ebUwfT.js → PDFViewer-CydWqbUF.js} +3 -3
  39. package/dist/chunks/{PDFViewer---ebUwfT.js.map → PDFViewer-CydWqbUF.js.map} +1 -1
  40. package/dist/chunks/{Page-q5Gme_r0.js → Page-dP8b4UdB.js} +2 -2
  41. package/dist/chunks/{Page-q5Gme_r0.js.map → Page-dP8b4UdB.js.map} +1 -1
  42. package/dist/chunks/{Page-BUXs6-fN.js → Page-nrJqRb7x.js} +2 -2
  43. package/dist/chunks/{Page-BUXs6-fN.js.map → Page-nrJqRb7x.js.map} +1 -1
  44. package/dist/chunks/{TopNav-os-U9FQP.js → TopNav-DfikMNXj.js} +2 -2
  45. package/dist/chunks/{TopNav-os-U9FQP.js.map → TopNav-DfikMNXj.js.map} +1 -1
  46. package/dist/chunks/{TopNav-BOMPjms6.js → TopNav-jh5jqV3e.js} +2 -2
  47. package/dist/chunks/{TopNav-BOMPjms6.js.map → TopNav-jh5jqV3e.js.map} +1 -1
  48. package/dist/chunks/{WebApp-BONphh_h.js → WebApp-BdmNWAj2.js} +13 -17
  49. package/dist/chunks/{WebApp-BONphh_h.js.map → WebApp-BdmNWAj2.js.map} +1 -1
  50. package/dist/chunks/{WebApp-DUxotRc-.js → WebApp-D801tYpF.js} +2 -2
  51. package/dist/chunks/{WebApp-DUxotRc-.js.map → WebApp-D801tYpF.js.map} +1 -1
  52. package/dist/css/web-mojo.css +1 -1
  53. package/dist/docit.cjs.js +1 -1
  54. package/dist/docit.es.js +5 -5
  55. package/dist/index.cjs.js +1 -1
  56. package/dist/index.cjs.js.map +1 -1
  57. package/dist/index.es.js +86 -83
  58. package/dist/index.es.js.map +1 -1
  59. package/dist/lightbox.cjs.js +1 -1
  60. package/dist/lightbox.es.js +4 -4
  61. package/package.json +2 -2
  62. package/dist/chunks/FilePreviewView-7-RBir4g.js +0 -2
  63. package/dist/chunks/FilePreviewView-7-RBir4g.js.map +0 -1
  64. package/dist/chunks/FilePreviewView-CehLQVJa.js.map +0 -1
  65. package/dist/chunks/FormView-B7pwdxqX.js.map +0 -1
  66. package/dist/chunks/FormView-C9PgTIH2.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { M as Mustache, h as MOJOUtils, V as View } from "./WebApp-BONphh_h.js";
1
+ import { M as Mustache, h as MOJOUtils, V as View } from "./WebApp-BdmNWAj2.js";
2
2
  class FormBuilder {
3
3
  constructor(config = {}) {
4
4
  this.fields = config.fields || [];
@@ -978,7 +978,8 @@ class FormBuilder {
978
978
  } = field;
979
979
  const inputClass = `form-select ${fieldClass}`.trim();
980
980
  const error = this.errors[name];
981
- const fieldValue = this.getFieldValue(name) ?? value;
981
+ const dataValue = this.getFieldValue(name);
982
+ const fieldValue = dataValue ?? value;
982
983
  const attrs = Object.entries(attributes).map(([key, val]) => `${key}="${this.escapeHtml(val)}"`).join(" ");
983
984
  const fieldId = this.getFieldId(name);
984
985
  let optionsHTML = "";
@@ -1537,7 +1538,8 @@ class FormBuilder {
1537
1538
  if (this.structureOnly) {
1538
1539
  return "";
1539
1540
  }
1540
- return MOJOUtils.getContextData(this.data, name);
1541
+ const value = MOJOUtils.getContextData(this.data, name);
1542
+ return value;
1541
1543
  }
1542
1544
  /**
1543
1545
  * Render tag input field
@@ -3037,6 +3039,9 @@ class CollectionSelectView extends View {
3037
3039
  }
3038
3040
  }
3039
3041
  getValue() {
3042
+ if (this.selectedValue === 0 || this.selectedValue === "0") {
3043
+ return null;
3044
+ }
3040
3045
  return this.selectedValue;
3041
3046
  }
3042
3047
  getLabel() {
@@ -3060,6 +3065,9 @@ class CollectionSelectView extends View {
3060
3065
  }
3061
3066
  // FormBuilder integration
3062
3067
  getFormValue() {
3068
+ if (this.selectedValue === 0 || this.selectedValue === "0") {
3069
+ return null;
3070
+ }
3063
3071
  return this.selectedValue;
3064
3072
  }
3065
3073
  setFormValue(value) {
@@ -4255,8 +4263,8 @@ class FormView extends View {
4255
4263
  this.formConfig = formConfig || { fields: fields || [] };
4256
4264
  this.formBuilder = new FormBuilder({
4257
4265
  ...this.formConfig,
4258
- structureOnly: true,
4259
- // Only generate structure, FormView will control values
4266
+ data: this.data,
4267
+ // Pass data so field.value defaults work
4260
4268
  errors
4261
4269
  });
4262
4270
  }
@@ -4271,7 +4279,8 @@ class FormView extends View {
4271
4279
  if (this.model.attributes && typeof this.model.attributes === "object") {
4272
4280
  Object.assign(formData, this.model.attributes);
4273
4281
  } else if (typeof this.model.toJSON === "function") {
4274
- Object.assign(formData, this.model.toJSON());
4282
+ const modelData = this.model.toJSON();
4283
+ Object.assign(formData, modelData);
4275
4284
  } else if (typeof this.model === "object" && this.model.constructor === Object) {
4276
4285
  Object.assign(formData, this.model);
4277
4286
  }
@@ -4332,7 +4341,9 @@ class FormView extends View {
4332
4341
  const fieldElement = this.element.querySelector(`[name="${fieldConfig.name}"]`);
4333
4342
  if (!fieldElement) return;
4334
4343
  const value = MOJOUtils.getContextData(this.data, fieldConfig.name);
4335
- this.setFieldValue(fieldElement, fieldConfig, value);
4344
+ if (value !== void 0 && value !== null) {
4345
+ this.setFieldValue(fieldElement, fieldConfig, value);
4346
+ }
4336
4347
  }
4337
4348
  /**
4338
4349
  * Initialize form components after rendering
@@ -4352,7 +4363,6 @@ class FormView extends View {
4352
4363
  initializeImageFields() {
4353
4364
  const imageFields = this.element.querySelectorAll(".image-drop-zone.droppable");
4354
4365
  if (imageFields.length > 0) {
4355
- applyFileDropMixin(FormView);
4356
4366
  this.enableFileDrop({
4357
4367
  acceptedTypes: ["image/*"],
4358
4368
  maxFileSize: 10 * 1024 * 1024,
@@ -4385,7 +4395,9 @@ class FormView extends View {
4385
4395
  initializeChangeHandlers() {
4386
4396
  if (!this.element) return;
4387
4397
  const inputs = this.element.querySelectorAll("input:not([data-action]), select:not([data-action]), textarea:not([data-action])");
4398
+ console.log("FormView: initializeChangeHandlers - found", inputs.length, "inputs");
4388
4399
  inputs.forEach((input) => {
4400
+ console.log("FormView: Processing input:", input.type, input.name, input.getAttribute("data-change-action"));
4389
4401
  if (input.hasAttribute("data-component") || input.classList.contains("form-check-input")) {
4390
4402
  return;
4391
4403
  }
@@ -4400,6 +4412,15 @@ class FormView extends View {
4400
4412
  if (!input.checked) return;
4401
4413
  } else if (input.multiple && input.selectedOptions) {
4402
4414
  value = Array.from(input.selectedOptions).map((opt) => opt.value);
4415
+ } else if (input.type === "file") {
4416
+ const changeAction = input.getAttribute("data-change-action");
4417
+ if (changeAction === "image-selected") {
4418
+ this.onChangeImageSelected(event, input);
4419
+ return;
4420
+ } else if (changeAction === "file-selected") {
4421
+ this.onChangeFileSelected(event, input);
4422
+ return;
4423
+ }
4403
4424
  }
4404
4425
  this.handleFieldChange(fieldName, value);
4405
4426
  }
@@ -4679,11 +4700,23 @@ class FormView extends View {
4679
4700
  * Handle image upload click
4680
4701
  */
4681
4702
  async onActionClickImageUpload(event, element) {
4703
+ console.log("FormView: onActionClickImageUpload called");
4704
+ console.log("FormView: element:", element);
4682
4705
  const fieldId = element.getAttribute("data-field-id");
4683
- if (!fieldId) return;
4706
+ console.log("FormView: fieldId:", fieldId);
4707
+ if (!fieldId) {
4708
+ console.error("FormView: No fieldId attribute found");
4709
+ return;
4710
+ }
4684
4711
  const fileInput = this.element.querySelector(`#${fieldId}`);
4712
+ console.log("FormView: fileInput:", fileInput);
4685
4713
  if (fileInput && !fileInput.disabled) {
4686
4714
  fileInput.click();
4715
+ console.log("FormView: fileInput.click() called");
4716
+ } else if (!fileInput) {
4717
+ console.error("FormView: fileInput not found for fieldId:", fieldId);
4718
+ } else {
4719
+ console.log("FormView: fileInput is disabled");
4687
4720
  }
4688
4721
  }
4689
4722
  /**
@@ -4812,15 +4845,29 @@ class FormView extends View {
4812
4845
  * Handle image selection
4813
4846
  */
4814
4847
  async onChangeImageSelected(event, element) {
4848
+ console.log("FormView: onChangeImageSelected called");
4849
+ console.log("FormView: element:", element);
4850
+ console.log("FormView: element.files:", element.files);
4815
4851
  const fieldName = element.getAttribute("data-field");
4816
4852
  const file = element.files[0];
4853
+ console.log("FormView: fieldName:", fieldName);
4854
+ console.log("FormView: file:", file);
4817
4855
  if (fieldName && file) {
4856
+ console.log("FormView: fieldName and file exist, processing...");
4818
4857
  const fieldConfig = this.findFieldConfig(fieldName);
4858
+ console.log("FormView: fieldConfig:", fieldConfig);
4819
4859
  const previewUrl = URL.createObjectURL(file);
4860
+ console.log("FormView: previewUrl created:", previewUrl);
4820
4861
  if (fieldConfig && fieldConfig.imageSize) {
4862
+ console.log("FormView: Image cropping is required, imageSize:", fieldConfig.imageSize);
4821
4863
  try {
4822
4864
  const ImageCropView = window.MOJO?.plugins?.ImageCropView;
4865
+ console.log("FormView: ImageCropView available?", !!ImageCropView);
4823
4866
  if (!ImageCropView) {
4867
+ console.log("FormView: ImageCropView not available, falling back to normal handling");
4868
+ this.data[fieldName] = file;
4869
+ await this.updateImagePreview(fieldName, previewUrl);
4870
+ this.emit("image:selected", { field: fieldName, file, form: this });
4824
4871
  return;
4825
4872
  }
4826
4873
  const result = await ImageCropView.showDialog(previewUrl, {
@@ -4853,6 +4900,8 @@ class FormView extends View {
4853
4900
  element.value = "";
4854
4901
  }
4855
4902
  } catch (error) {
4903
+ console.error("FormView: Error during image cropping:", error);
4904
+ console.log("FormView: Falling back to normal image handling after error");
4856
4905
  this.data[fieldName] = file;
4857
4906
  await this.updateImagePreview(fieldName, previewUrl);
4858
4907
  this.emit("image:selected", {
@@ -4867,14 +4916,20 @@ class FormView extends View {
4867
4916
  });
4868
4917
  }
4869
4918
  } else {
4919
+ console.log("FormView: Normal image handling (no cropping)");
4870
4920
  this.data[fieldName] = file;
4921
+ console.log("FormView: File stored in this.data[" + fieldName + "]");
4871
4922
  await this.updateImagePreview(fieldName, previewUrl);
4923
+ console.log("FormView: updateImagePreview completed");
4872
4924
  this.emit("image:selected", {
4873
4925
  field: fieldName,
4874
4926
  file,
4875
4927
  form: this
4876
4928
  });
4929
+ console.log("FormView: image:selected event emitted");
4877
4930
  }
4931
+ } else {
4932
+ console.log("FormView: Missing fieldName or file - not processing");
4878
4933
  }
4879
4934
  }
4880
4935
  /**
@@ -5040,6 +5095,32 @@ class FormView extends View {
5040
5095
  checkboxes.forEach((checkbox) => {
5041
5096
  data[checkbox.name] = checkbox.checked;
5042
5097
  });
5098
+ const numberInputs = form.querySelectorAll('input[type="number"]');
5099
+ numberInputs.forEach((input) => {
5100
+ if (input.name && data[input.name] !== void 0 && data[input.name] !== "") {
5101
+ const num = Number(data[input.name]);
5102
+ if (!isNaN(num)) {
5103
+ data[input.name] = num;
5104
+ }
5105
+ }
5106
+ });
5107
+ this.formConfig.fields?.forEach((field) => {
5108
+ if (field.type === "select" && field.name && data[field.name] !== void 0) {
5109
+ const fieldConfig = this.getFormFieldConfig(field.name);
5110
+ if (fieldConfig?.options && Array.isArray(fieldConfig.options)) {
5111
+ const allNumeric = fieldConfig.options.every((opt) => {
5112
+ const val = typeof opt === "object" ? opt.value : opt;
5113
+ return val === "" || !isNaN(Number(val));
5114
+ });
5115
+ if (allNumeric && data[field.name] !== "") {
5116
+ const num = Number(data[field.name]);
5117
+ if (!isNaN(num)) {
5118
+ data[field.name] = num;
5119
+ }
5120
+ }
5121
+ }
5122
+ }
5123
+ });
5043
5124
  const jsonFields = form.querySelectorAll('[data-field-type="json"]');
5044
5125
  jsonFields.forEach((textarea) => {
5045
5126
  try {
@@ -5048,6 +5129,13 @@ class FormView extends View {
5048
5129
  data[textarea.name] = textarea.value;
5049
5130
  }
5050
5131
  });
5132
+ this.customComponents.forEach((component, fieldName) => {
5133
+ if (component.getFormValue) {
5134
+ data[fieldName] = component.getFormValue();
5135
+ } else if (component.getValue) {
5136
+ data[fieldName] = component.getValue();
5137
+ }
5138
+ });
5051
5139
  for (const [key, value] of Object.entries(this.data)) {
5052
5140
  if (value instanceof File) {
5053
5141
  try {
@@ -5995,6 +6083,7 @@ class FieldStatusManager {
5995
6083
  this.timeouts.clear();
5996
6084
  }
5997
6085
  }
6086
+ applyFileDropMixin(FormView);
5998
6087
  const FormView$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5999
6088
  __proto__: null,
6000
6089
  FormView,
@@ -6005,4 +6094,4 @@ export {
6005
6094
  applyFileDropMixin as a,
6006
6095
  FormView$1 as b
6007
6096
  };
6008
- //# sourceMappingURL=FormView-C9PgTIH2.js.map
6097
+ //# sourceMappingURL=FormView-DrvkHPA-.js.map