web-mojo 2.1.380 → 2.1.443

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 (71) 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 +32 -43
  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/chunks/{ContextMenu-BPJJR6l6.js → ContextMenu-Cao6A-Lu.js} +4 -2
  12. package/dist/chunks/{ContextMenu-BPJJR6l6.js.map → ContextMenu-Cao6A-Lu.js.map} +1 -1
  13. package/dist/chunks/ContextMenu-TK4-wzDb.js +3 -0
  14. package/dist/chunks/ContextMenu-TK4-wzDb.js.map +1 -0
  15. package/dist/chunks/DataView-CHoPxbYT.js +2 -0
  16. package/dist/chunks/DataView-CHoPxbYT.js.map +1 -0
  17. package/dist/chunks/{DataView-ED8X_cvp.js → DataView-Qnk-TnHd.js} +17 -3
  18. package/dist/chunks/DataView-Qnk-TnHd.js.map +1 -0
  19. package/dist/chunks/{Dialog-hiboYc1m.js → Dialog-B_ZJYlVS.js} +2 -2
  20. package/dist/chunks/{Dialog-hiboYc1m.js.map → Dialog-B_ZJYlVS.js.map} +1 -1
  21. package/dist/chunks/{Dialog-DmEPwI5D.js → Dialog-DbZ2jB_m.js} +5 -5
  22. package/dist/chunks/{Dialog-DmEPwI5D.js.map → Dialog-DbZ2jB_m.js.map} +1 -1
  23. package/dist/chunks/FilePreviewView-DeGgRRbW.js +2 -0
  24. package/dist/chunks/FilePreviewView-DeGgRRbW.js.map +1 -0
  25. package/dist/chunks/{FilePreviewView-D39a1bWs.js → FilePreviewView-nuZku1yG.js} +68 -19
  26. package/dist/chunks/FilePreviewView-nuZku1yG.js.map +1 -0
  27. package/dist/chunks/{FormView-CCrutTVr.js → FormView-BDKrUX1-.js} +41 -23
  28. package/dist/chunks/FormView-BDKrUX1-.js.map +1 -0
  29. package/dist/chunks/FormView-BZInlDfZ.js +2 -0
  30. package/dist/chunks/FormView-BZInlDfZ.js.map +1 -0
  31. package/dist/chunks/{MetricsChart-D9j0JkfY.js → MetricsChart-Aqum5Znr.js} +3 -3
  32. package/dist/chunks/{MetricsChart-D9j0JkfY.js.map → MetricsChart-Aqum5Znr.js.map} +1 -1
  33. package/dist/chunks/{MetricsChart-B7yBoTzr.js → MetricsChart-BbaBczOZ.js} +2 -2
  34. package/dist/chunks/{MetricsChart-B7yBoTzr.js.map → MetricsChart-BbaBczOZ.js.map} +1 -1
  35. package/dist/chunks/{PDFViewer--7dBYfiB.js → PDFViewer-Bq-NM6JH.js} +2 -2
  36. package/dist/chunks/{PDFViewer--7dBYfiB.js.map → PDFViewer-Bq-NM6JH.js.map} +1 -1
  37. package/dist/chunks/{PDFViewer-BPFrZSlU.js → PDFViewer-CGj7cZut.js} +3 -3
  38. package/dist/chunks/{PDFViewer-BPFrZSlU.js.map → PDFViewer-CGj7cZut.js.map} +1 -1
  39. package/dist/chunks/{Page-DY5i-6Wq.js → Page-BkkXMFuP.js} +2 -2
  40. package/dist/chunks/{Page-DY5i-6Wq.js.map → Page-BkkXMFuP.js.map} +1 -1
  41. package/dist/chunks/{Page-D2Yq8RbO.js → Page-QhPYRY-q.js} +2 -2
  42. package/dist/chunks/{Page-D2Yq8RbO.js.map → Page-QhPYRY-q.js.map} +1 -1
  43. package/dist/chunks/{TopNav-BN3TAAxN.js → TopNav-D6c7gsox.js} +2 -2
  44. package/dist/chunks/{TopNav-BN3TAAxN.js.map → TopNav-D6c7gsox.js.map} +1 -1
  45. package/dist/chunks/{TopNav-BzKZzgE6.js → TopNav-DUwNnOuM.js} +2 -2
  46. package/dist/chunks/{TopNav-BzKZzgE6.js.map → TopNav-DUwNnOuM.js.map} +1 -1
  47. package/dist/chunks/{WebApp-p0nOftj0.js → WebApp-BPWJVv80.js} +19 -13
  48. package/dist/chunks/{WebApp-p0nOftj0.js.map → WebApp-BPWJVv80.js.map} +1 -1
  49. package/dist/chunks/WebApp-CYqazUo5.js +2 -0
  50. package/dist/chunks/{WebApp-Czng9Krl.js.map → WebApp-CYqazUo5.js.map} +1 -1
  51. package/dist/core.css +10 -0
  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.es.js +11 -11
  57. package/dist/lightbox.cjs.js +1 -1
  58. package/dist/lightbox.es.js +4 -4
  59. package/package.json +1 -1
  60. package/dist/chunks/ContextMenu-YwW7txyQ.js +0 -3
  61. package/dist/chunks/ContextMenu-YwW7txyQ.js.map +0 -1
  62. package/dist/chunks/DataView-ED8X_cvp.js.map +0 -1
  63. package/dist/chunks/DataView-ryKnMcUa.js +0 -2
  64. package/dist/chunks/DataView-ryKnMcUa.js.map +0 -1
  65. package/dist/chunks/FilePreviewView-C3beZ-UX.js +0 -2
  66. package/dist/chunks/FilePreviewView-C3beZ-UX.js.map +0 -1
  67. package/dist/chunks/FilePreviewView-D39a1bWs.js.map +0 -1
  68. package/dist/chunks/FormView-CCrutTVr.js.map +0 -1
  69. package/dist/chunks/FormView-wKzv7Fey.js +0 -2
  70. package/dist/chunks/FormView-wKzv7Fey.js.map +0 -1
  71. package/dist/chunks/WebApp-Czng9Krl.js +0 -2
@@ -1,4 +1,4 @@
1
- import { M as Mustache, h as MOJOUtils, V as View } from "./WebApp-p0nOftj0.js";
1
+ import { M as Mustache, h as MOJOUtils, V as View } from "./WebApp-BPWJVv80.js";
2
2
  class FormBuilder {
3
3
  constructor(config = {}) {
4
4
  this.fields = config.fields || [];
@@ -345,10 +345,7 @@ class FormBuilder {
345
345
  const fieldsHTML = this.buildFieldsHTML();
346
346
  const buttonsHTML = this.buildButtonsHTML();
347
347
  return `
348
- <form class="${this.options.formClass}"
349
- method="${this.options.formMethod}"
350
- ${this.options.formAction ? `action="${this.options.formAction}"` : ""}
351
- novalidate>
348
+ <form class="${this.options.formClass}" novalidate>
352
349
  ${fieldsHTML}
353
350
  ${buttonsHTML}
354
351
  </form>
@@ -2754,6 +2751,8 @@ class CollectionSelectView extends View {
2754
2751
  this.handleDocumentClick = this.handleDocumentClick.bind(this);
2755
2752
  this.handleKeyDown = this.handleKeyDown.bind(this);
2756
2753
  this.handleInputEvents = this.handleInputEvents.bind(this);
2754
+ }
2755
+ onInit() {
2757
2756
  if (this.collection) {
2758
2757
  this.setupCollection();
2759
2758
  }
@@ -2791,16 +2790,18 @@ class CollectionSelectView extends View {
2791
2790
  }
2792
2791
  async loadSelectedItem() {
2793
2792
  try {
2793
+ if (!this.selectedValue || this.selectedValue == "0") return;
2794
+ if (this.selectedLabel) return;
2794
2795
  const selectedModel = this.collection?.get(this.selectedValue);
2795
2796
  if (selectedModel) {
2796
2797
  this.selectedLabel = selectedModel.get(this.labelField);
2797
- this.render();
2798
+ this.render(false);
2798
2799
  return;
2799
2800
  }
2800
2801
  let model = await this.collection.fetchOne(this.selectedValue);
2801
2802
  if (model) {
2802
2803
  this.selectedLabel = model.get(this.labelField, `${model.constructor.name} #${model.id}`);
2803
- this.render();
2804
+ this.render(false);
2804
2805
  }
2805
2806
  } catch (error) {
2806
2807
  console.error("Error loading selected item:", error);
@@ -4172,7 +4173,7 @@ class FormView extends View {
4172
4173
  fields,
4173
4174
  model = null,
4174
4175
  data = {},
4175
- defaults = {},
4176
+ defaults = null,
4176
4177
  errors = {},
4177
4178
  fileHandling = "base64",
4178
4179
  // 'base64' | 'multipart'
@@ -4186,7 +4187,7 @@ class FormView extends View {
4186
4187
  ...viewOptions
4187
4188
  });
4188
4189
  this.model = model;
4189
- this.defaults = defaults;
4190
+ this.defaults = defaults || data;
4190
4191
  this._originalData = data;
4191
4192
  this.errors = errors;
4192
4193
  this.loading = false;
@@ -4241,21 +4242,33 @@ class FormView extends View {
4241
4242
  this.populateFormValues();
4242
4243
  this.initializeFormComponents();
4243
4244
  this.initializeChangeHandlers();
4245
+ const form = this.getFormElement();
4246
+ if (form) {
4247
+ form.addEventListener("submit", (e) => {
4248
+ e.preventDefault();
4249
+ return false;
4250
+ });
4251
+ }
4244
4252
  }
4245
4253
  /**
4246
4254
  * Populate all form fields with current data values
4247
4255
  */
4248
4256
  populateFormValues() {
4249
4257
  if (!this.element || !this.formConfig?.fields) return;
4250
- this.formConfig.fields.forEach((field) => {
4251
- if (field.type === "group" && field.fields) {
4252
- field.fields.forEach((groupField) => {
4253
- this.populateFieldValue(groupField);
4254
- });
4255
- } else {
4256
- this.populateFieldValue(field);
4257
- }
4258
- });
4258
+ this._isPopulating = true;
4259
+ try {
4260
+ this.formConfig.fields.forEach((field) => {
4261
+ if (field.type === "group" && field.fields) {
4262
+ field.fields.forEach((groupField) => {
4263
+ this.populateFieldValue(groupField);
4264
+ });
4265
+ } else {
4266
+ this.populateFieldValue(field);
4267
+ }
4268
+ });
4269
+ } finally {
4270
+ this._isPopulating = false;
4271
+ }
4259
4272
  }
4260
4273
  /**
4261
4274
  * Populate a single field with its value from data
@@ -4323,7 +4336,7 @@ class FormView extends View {
4323
4336
  return;
4324
4337
  }
4325
4338
  input.addEventListener("change", (event) => {
4326
- if (this._isFormDrivenChange) return;
4339
+ if (this._isPopulating) return;
4327
4340
  const fieldName = input.name;
4328
4341
  if (fieldName) {
4329
4342
  let value = input.value;
@@ -4339,7 +4352,7 @@ class FormView extends View {
4339
4352
  });
4340
4353
  if (input.type === "text" || input.type === "email" || input.type === "url" || input.tagName === "TEXTAREA") {
4341
4354
  input.addEventListener("input", (event) => {
4342
- if (this._isFormDrivenChange) return;
4355
+ if (this._isPopulating) return;
4343
4356
  const fieldName = input.name;
4344
4357
  if (fieldName) {
4345
4358
  this.handleFieldChange(fieldName, input.value);
@@ -4396,6 +4409,10 @@ class FormView extends View {
4396
4409
  containerId: null
4397
4410
  // We'll mount directly
4398
4411
  });
4412
+ let value = MOJOUtils.getContextData(this.data, fieldName);
4413
+ if (value) {
4414
+ collectionSelect.setFormValue(value);
4415
+ }
4399
4416
  collectionSelect.render(true, placeholder);
4400
4417
  this.customComponents.set(fieldName, collectionSelect);
4401
4418
  collectionSelect.on("change", (data) => {
@@ -5061,7 +5078,7 @@ class FormView extends View {
5061
5078
  getFieldCurrentValue(fieldElement, fieldConfig) {
5062
5079
  switch (fieldConfig.type) {
5063
5080
  case "checkbox":
5064
- return fieldElement.checked;
5081
+ case "toggle":
5065
5082
  case "switch":
5066
5083
  return fieldElement.checked;
5067
5084
  case "radio":
@@ -5083,6 +5100,7 @@ class FormView extends View {
5083
5100
  setFieldValue(fieldElement, fieldConfig, newValue) {
5084
5101
  switch (fieldConfig.type) {
5085
5102
  case "checkbox":
5103
+ case "toggle":
5086
5104
  case "switch":
5087
5105
  fieldElement.checked = Boolean(newValue);
5088
5106
  break;
@@ -5297,7 +5315,7 @@ class FormView extends View {
5297
5315
  }
5298
5316
  }
5299
5317
  }
5300
- if (fieldType === "switch" || fieldType === "checkbox") {
5318
+ if (fieldType === "switch" || fieldType === "checkbox" || fieldType === "toggle") {
5301
5319
  const newBool = !!newValue;
5302
5320
  const originalBool = !!originalValue;
5303
5321
  return newBool !== originalBool;
@@ -5933,4 +5951,4 @@ export {
5933
5951
  applyFileDropMixin as a,
5934
5952
  FormView$1 as b
5935
5953
  };
5936
- //# sourceMappingURL=FormView-CCrutTVr.js.map
5954
+ //# sourceMappingURL=FormView-BDKrUX1-.js.map