jedison 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1817,6 +1817,12 @@ class Instance extends EventEmitter {
1817
1817
  value: this.getValue(),
1818
1818
  settings: this.jedison.options.settings
1819
1819
  };
1820
+ if (typeof this.value === "string") {
1821
+ templateData.length = this.value.length;
1822
+ if (typeof this.schema.maxLength === "number") {
1823
+ templateData.remaining = this.schema.maxLength - this.value.length;
1824
+ }
1825
+ }
1820
1826
  if (template == null ? void 0 : template.includes("{{ functions.")) {
1821
1827
  templateData.functions = this.resolveTemplateFunctions(
1822
1828
  this.jedison.options.functions
@@ -3225,6 +3231,17 @@ class EditorStringTextarea extends EditorString {
3225
3231
  titleHidden: getSchemaXOption(this.instance.schema, "titleHidden"),
3226
3232
  info: this.getInfo()
3227
3233
  });
3234
+ const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.options.useConstraintAttributes;
3235
+ if (useConstraintAttributes === true) {
3236
+ const schemaMinLength = getSchemaMinLength(this.instance.schema);
3237
+ const schemaMaxLength = getSchemaMaxLength(this.instance.schema);
3238
+ if (isSet(schemaMinLength)) {
3239
+ this.control.input.setAttribute("minlength", schemaMinLength);
3240
+ }
3241
+ if (isSet(schemaMaxLength)) {
3242
+ this.control.input.setAttribute("maxlength", schemaMaxLength);
3243
+ }
3244
+ }
3228
3245
  }
3229
3246
  adaptForTable() {
3230
3247
  this.theme.adaptForTableTextareaControl(this.control);
@@ -3236,7 +3253,7 @@ class EditorStringTextarea extends EditorString {
3236
3253
  });
3237
3254
  }
3238
3255
  refreshUI() {
3239
- this.refreshDisabledState();
3256
+ super.refreshUI();
3240
3257
  this.control.input.value = this.instance.getValue();
3241
3258
  }
3242
3259
  }
@@ -3350,6 +3367,21 @@ class EditorStringInput extends EditorString {
3350
3367
  if (optionFormat === "color" && this.instance.value.length === 0) {
3351
3368
  this.instance.setValue("#000000", false, "user");
3352
3369
  }
3370
+ const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.options.useConstraintAttributes;
3371
+ if (useConstraintAttributes === true) {
3372
+ const schemaMinLength = getSchemaMinLength(this.instance.schema);
3373
+ const schemaMaxLength = getSchemaMaxLength(this.instance.schema);
3374
+ const schemaPattern = getSchemaPattern(this.instance.schema);
3375
+ if (isSet(schemaMinLength)) {
3376
+ this.control.input.setAttribute("minlength", schemaMinLength);
3377
+ }
3378
+ if (isSet(schemaMaxLength)) {
3379
+ this.control.input.setAttribute("maxlength", schemaMaxLength);
3380
+ }
3381
+ if (isSet(schemaPattern)) {
3382
+ this.control.input.setAttribute("pattern", schemaPattern);
3383
+ }
3384
+ }
3353
3385
  }
3354
3386
  adaptForTable() {
3355
3387
  this.theme.adaptForTableInputControl(this.control);
@@ -4023,13 +4055,18 @@ class EditorArrayTable extends EditorArray {
4023
4055
  this.control.childrenSlot.innerHTML = "";
4024
4056
  const table = this.theme.getTable();
4025
4057
  this.control.childrenSlot.appendChild(table.container);
4058
+ const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.options.arrayDelete;
4059
+ const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.options.arrayMove;
4060
+ const arrayButtonsPosition = getSchemaXOption(this.instance.schema, "arrayButtonsPosition") ?? this.instance.jedison.options.arrayButtonsPosition;
4026
4061
  const th = this.theme.getTableHeader();
4027
4062
  const { label } = this.theme.getFakeLabel({
4028
4063
  content: "Controls",
4029
4064
  visuallyHidden: true
4030
4065
  });
4031
4066
  th.appendChild(label);
4032
- table.thead.appendChild(th);
4067
+ if (arrayButtonsPosition === "left") {
4068
+ table.thead.appendChild(th);
4069
+ }
4033
4070
  if (this.instance.children.length) {
4034
4071
  const schemaItems = getSchemaItems(this.instance.schema);
4035
4072
  const thTitle = this.theme.getTableHeader();
@@ -4050,11 +4087,12 @@ class EditorArrayTable extends EditorArray {
4050
4087
  }
4051
4088
  table.thead.appendChild(thTitle);
4052
4089
  }
4053
- const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.options.arrayDelete;
4054
- const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.options.arrayMove;
4090
+ if (arrayButtonsPosition === "right") {
4091
+ table.thead.appendChild(th);
4092
+ }
4055
4093
  this.instance.children.forEach((child, index2) => {
4056
4094
  const tbodyRow = document.createElement("tr");
4057
- const buttonsTd = this.theme.getTableDefinition();
4095
+ const buttonsTd = this.theme.getTableDefinition({ isButtonColumn: true });
4058
4096
  const { deleteBtn, moveUpBtn, moveDownBtn, dragBtn, btnGroup } = this.getButtons(index2);
4059
4097
  if (this.isSortable()) {
4060
4098
  btnGroup.appendChild(dragBtn);
@@ -4067,11 +4105,16 @@ class EditorArrayTable extends EditorArray {
4067
4105
  btnGroup.appendChild(moveDownBtn);
4068
4106
  }
4069
4107
  buttonsTd.appendChild(btnGroup);
4070
- tbodyRow.appendChild(buttonsTd);
4108
+ if (arrayButtonsPosition === "left") {
4109
+ tbodyRow.appendChild(buttonsTd);
4110
+ }
4071
4111
  const td = this.theme.getTableDefinition();
4072
4112
  child.ui.adaptForTable(child, td);
4073
4113
  td.appendChild(child.ui.control.container);
4074
4114
  tbodyRow.appendChild(td);
4115
+ if (arrayButtonsPosition === "right") {
4116
+ tbodyRow.appendChild(buttonsTd);
4117
+ }
4075
4118
  table.tbody.appendChild(tbodyRow);
4076
4119
  });
4077
4120
  this.refreshSortable(table.tbody);
@@ -4135,13 +4178,18 @@ class EditorArrayTableObject extends EditorArray {
4135
4178
  this.control.childrenSlot.innerHTML = "";
4136
4179
  const table = this.theme.getTable();
4137
4180
  this.control.childrenSlot.appendChild(table.container);
4181
+ const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.options.arrayDelete;
4182
+ const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.options.arrayMove;
4183
+ const arrayButtonsPosition = getSchemaXOption(this.instance.schema, "arrayButtonsPosition") ?? this.instance.jedison.options.arrayButtonsPosition;
4138
4184
  const th = this.theme.getTableHeader();
4139
4185
  const { label } = this.theme.getFakeLabel({
4140
4186
  content: "Controls",
4141
4187
  visuallyHidden: true
4142
4188
  });
4143
4189
  th.appendChild(label);
4144
- table.thead.appendChild(th);
4190
+ if (arrayButtonsPosition === "left") {
4191
+ table.thead.appendChild(th);
4192
+ }
4145
4193
  if (this.instance.getValue().length === 0) {
4146
4194
  table.table.removeChild(table.thead);
4147
4195
  }
@@ -4169,11 +4217,12 @@ class EditorArrayTableObject extends EditorArray {
4169
4217
  }
4170
4218
  table.thead.appendChild(th2);
4171
4219
  });
4172
- const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.options.arrayDelete;
4173
- const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.options.arrayMove;
4220
+ if (arrayButtonsPosition === "right") {
4221
+ table.thead.appendChild(th);
4222
+ }
4174
4223
  this.instance.children.forEach((child, index2) => {
4175
4224
  const tbodyRow = document.createElement("tr");
4176
- const buttonsTd = this.theme.getTableDefinition();
4225
+ const buttonsTd = this.theme.getTableDefinition({ isButtonColumn: true });
4177
4226
  const { deleteBtn, moveUpBtn, moveDownBtn, dragBtn, btnGroup } = this.getButtons(index2);
4178
4227
  if (this.isSortable()) {
4179
4228
  btnGroup.appendChild(dragBtn);
@@ -4186,7 +4235,9 @@ class EditorArrayTableObject extends EditorArray {
4186
4235
  btnGroup.appendChild(moveDownBtn);
4187
4236
  }
4188
4237
  buttonsTd.appendChild(btnGroup);
4189
- tbodyRow.appendChild(buttonsTd);
4238
+ if (arrayButtonsPosition === "left") {
4239
+ tbodyRow.appendChild(buttonsTd);
4240
+ }
4190
4241
  if (child.children.length) {
4191
4242
  child.children.forEach((grandchild) => {
4192
4243
  const td = this.theme.getTableDefinition();
@@ -4200,6 +4251,9 @@ class EditorArrayTableObject extends EditorArray {
4200
4251
  td.appendChild(child.ui.control.container);
4201
4252
  tbodyRow.appendChild(td);
4202
4253
  }
4254
+ if (arrayButtonsPosition === "right") {
4255
+ tbodyRow.appendChild(buttonsTd);
4256
+ }
4203
4257
  table.tbody.appendChild(tbodyRow);
4204
4258
  });
4205
4259
  this.refreshSortable(table.tbody);
@@ -4910,8 +4964,11 @@ class EditorNumberRange extends EditorNumber {
4910
4964
  titleHidden: getSchemaXOption(this.instance.schema, "titleHidden"),
4911
4965
  info: this.getInfo()
4912
4966
  });
4913
- this.control.input.setAttribute("min", optionMin);
4914
- this.control.input.setAttribute("max", optionMax);
4967
+ const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.options.useConstraintAttributes;
4968
+ if (useConstraintAttributes === true) {
4969
+ this.control.input.setAttribute("min", optionMin);
4970
+ this.control.input.setAttribute("max", optionMax);
4971
+ }
4915
4972
  this.control.input.setAttribute("step", optionStep);
4916
4973
  const inputAttributes = getSchemaXOption(this.instance.schema, "inputAttributes");
4917
4974
  if (inputAttributes && typeof inputAttributes === "object") {
@@ -5376,6 +5433,7 @@ class Jedison extends EventEmitter {
5376
5433
  arrayDelete: true,
5377
5434
  arrayMove: true,
5378
5435
  arrayAdd: true,
5436
+ arrayButtonsPosition: "left",
5379
5437
  startCollapsed: false,
5380
5438
  deactivateNonRequired: false,
5381
5439
  schema: {},
@@ -7454,8 +7512,11 @@ class Theme {
7454
7512
  /**
7455
7513
  * Returns a <td> element
7456
7514
  */
7457
- getTableDefinition() {
7515
+ getTableDefinition(config = {}) {
7458
7516
  const td = document.createElement("td");
7517
+ if (config.isButtonColumn) {
7518
+ td.style.width = "1%";
7519
+ }
7459
7520
  td.style.whiteSpace = "nowrap";
7460
7521
  return td;
7461
7522
  }
@@ -7594,6 +7655,7 @@ class ThemeBootstrap3 extends Theme {
7594
7655
  getBtnGroup() {
7595
7656
  const html = super.getBtnGroup();
7596
7657
  html.classList.add("btn-group");
7658
+ html.style.display = "inline-flex";
7597
7659
  return html;
7598
7660
  }
7599
7661
  getButton(config) {