@structured-field/widget-editor 1.0.3 → 1.1.1

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.
@@ -1,4 +1,4 @@
1
- var script$b = {
1
+ var script$c = {
2
2
  name: 'StringEditor',
3
3
  props: {
4
4
  schema: { type: Object, required: true },
@@ -5586,6 +5586,11 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
5586
5586
  function createTextVNode(text = " ", flag = 0) {
5587
5587
  return createVNode(Text, null, text, flag);
5588
5588
  }
5589
+ function createStaticVNode(content, numberOfNodes) {
5590
+ const vnode = createVNode(Static, null, content);
5591
+ vnode.staticCount = numberOfNodes;
5592
+ return vnode;
5593
+ }
5589
5594
  function createCommentVNode(text = "", asBlock = false) {
5590
5595
  return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text);
5591
5596
  }
@@ -6690,7 +6695,7 @@ class VueElement extends BaseClass {
6690
6695
  _update() {
6691
6696
  const vnode = this._createVNode();
6692
6697
  if (this._app) vnode.appContext = this._app._context;
6693
- render$c(vnode, this._root);
6698
+ render$d(vnode, this._root);
6694
6699
  }
6695
6700
  _createVNode() {
6696
6701
  const baseProps = {};
@@ -6957,7 +6962,7 @@ let renderer;
6957
6962
  function ensureRenderer() {
6958
6963
  return renderer || (renderer = createRenderer(rendererOptions));
6959
6964
  }
6960
- const render$c = ((...args) => {
6965
+ const render$d = ((...args) => {
6961
6966
  ensureRenderer().render(...args);
6962
6967
  });
6963
6968
  const createApp = ((...args) => {
@@ -6998,14 +7003,14 @@ function normalizeContainer(container) {
6998
7003
  return container;
6999
7004
  }
7000
7005
 
7001
- const _hoisted_1$a = ["value", "placeholder"];
7002
- const _hoisted_2$8 = ["value", "placeholder"];
7003
- const _hoisted_3$7 = {
7006
+ const _hoisted_1$b = ["value", "placeholder"];
7007
+ const _hoisted_2$9 = ["value", "placeholder"];
7008
+ const _hoisted_3$8 = {
7004
7009
  key: 2,
7005
7010
  class: "errorlist"
7006
7011
  };
7007
7012
 
7008
- function render$b(_ctx, _cache, $props, $setup, $data, $options) {
7013
+ function render$c(_ctx, _cache, $props, $setup, $data, $options) {
7009
7014
  return (openBlock(), createElementBlock("div", {
7010
7015
  class: normalizeClass(["sf-field", { errors: $options.fieldErrors.length }])
7011
7016
  }, [
@@ -7020,7 +7025,7 @@ function render$b(_ctx, _cache, $props, $setup, $data, $options) {
7020
7025
  value: $props.modelValue,
7021
7026
  placeholder: $props.schema.placeholder || '',
7022
7027
  onInput: _cache[0] || (_cache[0] = $event => (_ctx.$emit('update:modelValue', $event.target.value)))
7023
- }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_1$a))
7028
+ }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_1$b))
7024
7029
  : (openBlock(), createElementBlock("input", {
7025
7030
  key: 1,
7026
7031
  type: "text",
@@ -7028,9 +7033,9 @@ function render$b(_ctx, _cache, $props, $setup, $data, $options) {
7028
7033
  value: $props.modelValue != null ? String($props.modelValue) : '',
7029
7034
  placeholder: $props.schema.placeholder || '',
7030
7035
  onInput: _cache[1] || (_cache[1] = $event => (_ctx.$emit('update:modelValue', $event.target.value)))
7031
- }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_2$8)),
7036
+ }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_2$9)),
7032
7037
  ($options.fieldErrors.length)
7033
- ? (openBlock(), createElementBlock("ul", _hoisted_3$7, [
7038
+ ? (openBlock(), createElementBlock("ul", _hoisted_3$8, [
7034
7039
  (openBlock(true), createElementBlock(Fragment, null, renderList($options.fieldErrors, (err, i) => {
7035
7040
  return (openBlock(), createElementBlock("li", { key: i }, toDisplayString(err), 1 /* TEXT */))
7036
7041
  }), 128 /* KEYED_FRAGMENT */))
@@ -7039,10 +7044,10 @@ function render$b(_ctx, _cache, $props, $setup, $data, $options) {
7039
7044
  ], 2 /* CLASS */))
7040
7045
  }
7041
7046
 
7042
- script$b.render = render$b;
7043
- script$b.__file = "src/editors/StringEditor.vue";
7047
+ script$c.render = render$c;
7048
+ script$c.__file = "src/editors/StringEditor.vue";
7044
7049
 
7045
- var script$a = {
7050
+ var script$b = {
7046
7051
  name: 'NumberEditor',
7047
7052
  props: {
7048
7053
  schema: { type: Object, required: true },
@@ -7083,13 +7088,13 @@ var script$a = {
7083
7088
  },
7084
7089
  };
7085
7090
 
7086
- const _hoisted_1$9 = ["step", "min", "max", "value"];
7087
- const _hoisted_2$7 = {
7091
+ const _hoisted_1$a = ["step", "min", "max", "value"];
7092
+ const _hoisted_2$8 = {
7088
7093
  key: 0,
7089
7094
  class: "errorlist"
7090
7095
  };
7091
7096
 
7092
- function render$a(_ctx, _cache, $props, $setup, $data, $options) {
7097
+ function render$b(_ctx, _cache, $props, $setup, $data, $options) {
7093
7098
  return (openBlock(), createElementBlock("div", {
7094
7099
  class: normalizeClass(["sf-field", { errors: $options.fieldErrors.length }])
7095
7100
  }, [
@@ -7104,9 +7109,9 @@ function render$a(_ctx, _cache, $props, $setup, $data, $options) {
7104
7109
  max: $props.schema.maximum != null ? String($props.schema.maximum) : undefined,
7105
7110
  value: $props.modelValue != null ? $props.modelValue : '',
7106
7111
  onInput: _cache[0] || (_cache[0] = (...args) => ($options.onInput && $options.onInput(...args)))
7107
- }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_1$9),
7112
+ }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_1$a),
7108
7113
  ($options.fieldErrors.length)
7109
- ? (openBlock(), createElementBlock("ul", _hoisted_2$7, [
7114
+ ? (openBlock(), createElementBlock("ul", _hoisted_2$8, [
7110
7115
  (openBlock(true), createElementBlock(Fragment, null, renderList($options.fieldErrors, (err, i) => {
7111
7116
  return (openBlock(), createElementBlock("li", { key: i }, toDisplayString(err), 1 /* TEXT */))
7112
7117
  }), 128 /* KEYED_FRAGMENT */))
@@ -7115,10 +7120,10 @@ function render$a(_ctx, _cache, $props, $setup, $data, $options) {
7115
7120
  ], 2 /* CLASS */))
7116
7121
  }
7117
7122
 
7118
- script$a.render = render$a;
7119
- script$a.__file = "src/editors/NumberEditor.vue";
7123
+ script$b.render = render$b;
7124
+ script$b.__file = "src/editors/NumberEditor.vue";
7120
7125
 
7121
- var script$9 = {
7126
+ var script$a = {
7122
7127
  name: 'BooleanEditor',
7123
7128
  props: {
7124
7129
  schema: { type: Object, required: true },
@@ -7144,28 +7149,28 @@ var script$9 = {
7144
7149
  },
7145
7150
  };
7146
7151
 
7147
- const _hoisted_1$8 = { class: "sf-checkbox-label" };
7148
- const _hoisted_2$6 = ["checked"];
7149
- const _hoisted_3$6 = {
7152
+ const _hoisted_1$9 = { class: "sf-checkbox-label" };
7153
+ const _hoisted_2$7 = ["checked"];
7154
+ const _hoisted_3$7 = {
7150
7155
  key: 0,
7151
7156
  class: "errorlist"
7152
7157
  };
7153
7158
 
7154
- function render$9(_ctx, _cache, $props, $setup, $data, $options) {
7159
+ function render$a(_ctx, _cache, $props, $setup, $data, $options) {
7155
7160
  return (openBlock(), createElementBlock("div", {
7156
7161
  class: normalizeClass(["sf-field sf-field-boolean", { errors: $options.fieldErrors.length }])
7157
7162
  }, [
7158
- createBaseVNode("label", _hoisted_1$8, [
7163
+ createBaseVNode("label", _hoisted_1$9, [
7159
7164
  createBaseVNode("input", {
7160
7165
  type: "checkbox",
7161
7166
  class: "sf-checkbox",
7162
7167
  checked: !!$props.modelValue,
7163
7168
  onChange: _cache[0] || (_cache[0] = $event => (_ctx.$emit('update:modelValue', $event.target.checked)))
7164
- }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_2$6),
7169
+ }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_2$7),
7165
7170
  createTextVNode(" " + toDisplayString($options.title), 1 /* TEXT */)
7166
7171
  ]),
7167
7172
  ($options.fieldErrors.length)
7168
- ? (openBlock(), createElementBlock("ul", _hoisted_3$6, [
7173
+ ? (openBlock(), createElementBlock("ul", _hoisted_3$7, [
7169
7174
  (openBlock(true), createElementBlock(Fragment, null, renderList($options.fieldErrors, (err, i) => {
7170
7175
  return (openBlock(), createElementBlock("li", { key: i }, toDisplayString(err), 1 /* TEXT */))
7171
7176
  }), 128 /* KEYED_FRAGMENT */))
@@ -7174,10 +7179,10 @@ function render$9(_ctx, _cache, $props, $setup, $data, $options) {
7174
7179
  ], 2 /* CLASS */))
7175
7180
  }
7176
7181
 
7177
- script$9.render = render$9;
7178
- script$9.__file = "src/editors/BooleanEditor.vue";
7182
+ script$a.render = render$a;
7183
+ script$a.__file = "src/editors/BooleanEditor.vue";
7179
7184
 
7180
- var script$8 = {
7185
+ var script$9 = {
7181
7186
  name: 'SelectEditor',
7182
7187
  props: {
7183
7188
  schema: { type: Object, required: true },
@@ -7210,14 +7215,14 @@ var script$8 = {
7210
7215
  },
7211
7216
  };
7212
7217
 
7213
- const _hoisted_1$7 = ["value"];
7214
- const _hoisted_2$5 = ["value"];
7215
- const _hoisted_3$5 = {
7218
+ const _hoisted_1$8 = ["value"];
7219
+ const _hoisted_2$6 = ["value"];
7220
+ const _hoisted_3$6 = {
7216
7221
  key: 0,
7217
7222
  class: "errorlist"
7218
7223
  };
7219
7224
 
7220
- function render$8(_ctx, _cache, $props, $setup, $data, $options) {
7225
+ function render$9(_ctx, _cache, $props, $setup, $data, $options) {
7221
7226
  return (openBlock(), createElementBlock("div", {
7222
7227
  class: normalizeClass(["sf-field", { errors: $options.fieldErrors.length }])
7223
7228
  }, [
@@ -7233,11 +7238,11 @@ function render$8(_ctx, _cache, $props, $setup, $data, $options) {
7233
7238
  return (openBlock(), createElementBlock("option", {
7234
7239
  key: opt,
7235
7240
  value: String(opt)
7236
- }, toDisplayString(opt), 9 /* TEXT, PROPS */, _hoisted_2$5))
7241
+ }, toDisplayString(opt), 9 /* TEXT, PROPS */, _hoisted_2$6))
7237
7242
  }), 128 /* KEYED_FRAGMENT */))
7238
- ], 40 /* PROPS, NEED_HYDRATION */, _hoisted_1$7),
7243
+ ], 40 /* PROPS, NEED_HYDRATION */, _hoisted_1$8),
7239
7244
  ($options.fieldErrors.length)
7240
- ? (openBlock(), createElementBlock("ul", _hoisted_3$5, [
7245
+ ? (openBlock(), createElementBlock("ul", _hoisted_3$6, [
7241
7246
  (openBlock(true), createElementBlock(Fragment, null, renderList($options.fieldErrors, (err, i) => {
7242
7247
  return (openBlock(), createElementBlock("li", { key: i }, toDisplayString(err), 1 /* TEXT */))
7243
7248
  }), 128 /* KEYED_FRAGMENT */))
@@ -7246,10 +7251,10 @@ function render$8(_ctx, _cache, $props, $setup, $data, $options) {
7246
7251
  ], 2 /* CLASS */))
7247
7252
  }
7248
7253
 
7249
- script$8.render = render$8;
7250
- script$8.__file = "src/editors/SelectEditor.vue";
7254
+ script$9.render = render$9;
7255
+ script$9.__file = "src/editors/SelectEditor.vue";
7251
7256
 
7252
- var script$7 = {
7257
+ var script$8 = {
7253
7258
  name: 'HiddenEditor',
7254
7259
  props: {
7255
7260
  schema: { type: Object, required: true },
@@ -7277,20 +7282,116 @@ var script$7 = {
7277
7282
  },
7278
7283
  };
7279
7284
 
7280
- const _hoisted_1$6 = { style: {"display":"none"} };
7285
+ const _hoisted_1$7 = { style: {"display":"none"} };
7286
+
7287
+ function render$8(_ctx, _cache, $props, $setup, $data, $options) {
7288
+ return (openBlock(), createElementBlock("div", _hoisted_1$7))
7289
+ }
7290
+
7291
+ script$8.render = render$8;
7292
+ script$8.__file = "src/editors/HiddenEditor.vue";
7293
+
7294
+ var script$7 = {
7295
+ name: 'SfIcon',
7296
+ props: {
7297
+ name: { type: String, required: true },
7298
+ size: { type: [Number, String], default: 14 },
7299
+ },
7300
+ };
7301
+
7302
+ const _hoisted_1$6 = ["width", "height"];
7303
+ const _hoisted_2$5 = {
7304
+ key: 4,
7305
+ points: "6 9 12 15 18 9"
7306
+ };
7307
+ const _hoisted_3$5 = {
7308
+ key: 5,
7309
+ points: "18 15 12 9 6 15"
7310
+ };
7281
7311
 
7282
7312
  function render$7(_ctx, _cache, $props, $setup, $data, $options) {
7283
- return (openBlock(), createElementBlock("div", _hoisted_1$6))
7313
+ return (openBlock(), createElementBlock("svg", {
7314
+ class: "sf-icon",
7315
+ width: $props.size,
7316
+ height: $props.size,
7317
+ viewBox: "0 0 24 24",
7318
+ fill: "none",
7319
+ stroke: "currentColor",
7320
+ "stroke-width": "2.5",
7321
+ "stroke-linecap": "round",
7322
+ "stroke-linejoin": "round"
7323
+ }, [
7324
+ ($props.name === 'plus')
7325
+ ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
7326
+ _cache[0] || (_cache[0] = createBaseVNode("line", {
7327
+ x1: "12",
7328
+ y1: "5",
7329
+ x2: "12",
7330
+ y2: "19"
7331
+ }, null, -1 /* CACHED */)),
7332
+ _cache[1] || (_cache[1] = createBaseVNode("line", {
7333
+ x1: "5",
7334
+ y1: "12",
7335
+ x2: "19",
7336
+ y2: "12"
7337
+ }, null, -1 /* CACHED */))
7338
+ ], 64 /* STABLE_FRAGMENT */))
7339
+ : ($props.name === 'times')
7340
+ ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
7341
+ _cache[2] || (_cache[2] = createBaseVNode("line", {
7342
+ x1: "6",
7343
+ y1: "6",
7344
+ x2: "18",
7345
+ y2: "18"
7346
+ }, null, -1 /* CACHED */)),
7347
+ _cache[3] || (_cache[3] = createBaseVNode("line", {
7348
+ x1: "6",
7349
+ y1: "18",
7350
+ x2: "18",
7351
+ y2: "6"
7352
+ }, null, -1 /* CACHED */))
7353
+ ], 64 /* STABLE_FRAGMENT */))
7354
+ : ($props.name === 'arrow-up')
7355
+ ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
7356
+ _cache[4] || (_cache[4] = createBaseVNode("line", {
7357
+ x1: "12",
7358
+ y1: "19",
7359
+ x2: "12",
7360
+ y2: "5"
7361
+ }, null, -1 /* CACHED */)),
7362
+ _cache[5] || (_cache[5] = createBaseVNode("polyline", { points: "5 12 12 5 19 12" }, null, -1 /* CACHED */))
7363
+ ], 64 /* STABLE_FRAGMENT */))
7364
+ : ($props.name === 'arrow-down')
7365
+ ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
7366
+ _cache[6] || (_cache[6] = createBaseVNode("line", {
7367
+ x1: "12",
7368
+ y1: "5",
7369
+ x2: "12",
7370
+ y2: "19"
7371
+ }, null, -1 /* CACHED */)),
7372
+ _cache[7] || (_cache[7] = createBaseVNode("polyline", { points: "19 12 12 19 5 12" }, null, -1 /* CACHED */))
7373
+ ], 64 /* STABLE_FRAGMENT */))
7374
+ : ($props.name === 'chevron-down')
7375
+ ? (openBlock(), createElementBlock("polyline", _hoisted_2$5))
7376
+ : ($props.name === 'chevron-up')
7377
+ ? (openBlock(), createElementBlock("polyline", _hoisted_3$5))
7378
+ : ($props.name === 'grip')
7379
+ ? (openBlock(), createElementBlock(Fragment, { key: 6 }, [
7380
+ _cache[8] || (_cache[8] = createStaticVNode("<circle cx=\"9\" cy=\"7\" r=\"1\" fill=\"currentColor\" stroke=\"none\"></circle><circle cx=\"15\" cy=\"7\" r=\"1\" fill=\"currentColor\" stroke=\"none\"></circle><circle cx=\"9\" cy=\"12\" r=\"1\" fill=\"currentColor\" stroke=\"none\"></circle><circle cx=\"15\" cy=\"12\" r=\"1\" fill=\"currentColor\" stroke=\"none\"></circle><circle cx=\"9\" cy=\"17\" r=\"1\" fill=\"currentColor\" stroke=\"none\"></circle><circle cx=\"15\" cy=\"17\" r=\"1\" fill=\"currentColor\" stroke=\"none\"></circle>", 6))
7381
+ ], 64 /* STABLE_FRAGMENT */))
7382
+ : createCommentVNode("v-if", true)
7383
+ ], 8 /* PROPS */, _hoisted_1$6))
7284
7384
  }
7285
7385
 
7286
7386
  script$7.render = render$7;
7287
- script$7.__file = "src/editors/HiddenEditor.vue";
7387
+ script$7.__file = "src/editors/SfIcon.vue";
7288
7388
 
7289
7389
  var script$6 = {
7290
7390
  name: 'ObjectEditor',
7291
7391
  beforeCreate() {
7292
7392
  if (!this.$options.components) this.$options.components = {};
7293
7393
  this.$options.components.SchemaEditor = script$1;
7394
+ this.$options.components.SfIcon = script$7;
7294
7395
  },
7295
7396
  props: {
7296
7397
  schema: { type: Object, required: true },
@@ -7299,6 +7400,11 @@ var script$6 = {
7299
7400
  form: { type: Object, required: true },
7300
7401
  },
7301
7402
  emits: ['update:modelValue'],
7403
+ data() {
7404
+ return {
7405
+ collapsed: false,
7406
+ };
7407
+ },
7302
7408
  computed: {
7303
7409
  isRoot() {
7304
7410
  return this.path.length === 0;
@@ -7306,12 +7412,30 @@ var script$6 = {
7306
7412
  title() {
7307
7413
  return this.schema.title || this.humanize(this.path[this.path.length - 1]) || '';
7308
7414
  },
7415
+ summary() {
7416
+ const val = this.modelValue || {};
7417
+ const parts = [];
7418
+ for (const key of Object.keys(this.schema.properties || {})) {
7419
+ if (parts.length >= 3) break;
7420
+ const v = val[key];
7421
+ if (v !== null && v !== undefined && v !== '' && typeof v !== 'object') {
7422
+ parts.push(String(v));
7423
+ }
7424
+ }
7425
+ return parts.join(' · ');
7426
+ },
7309
7427
  },
7310
7428
  methods: {
7311
7429
  humanize(str) {
7312
7430
  if (!str) return '';
7313
7431
  return str.replace(/_/g, ' ').replace(/([a-z])([A-Z])/g, '$1 $2').replace(/^./, s => s.toUpperCase());
7314
7432
  },
7433
+ collapse() {
7434
+ this.collapsed = true;
7435
+ },
7436
+ expand() {
7437
+ this.collapsed = false;
7438
+ },
7315
7439
  onChildChange(key, value) {
7316
7440
  const newVal = { ...(this.modelValue || {}), [key]: value };
7317
7441
  this.$emit('update:modelValue', newVal);
@@ -7324,20 +7448,22 @@ const _hoisted_1$5 = {
7324
7448
  class: "sf-object sf-object-root"
7325
7449
  };
7326
7450
  const _hoisted_2$4 = { class: "sf-object-fields" };
7327
- const _hoisted_3$4 = {
7328
- key: 1,
7329
- class: "sf-object"
7451
+ const _hoisted_3$4 = { class: "sf-object-title" };
7452
+ const _hoisted_4$3 = ["aria-label"];
7453
+ const _hoisted_5$3 = { class: "sf-object-title-text" };
7454
+ const _hoisted_6$3 = {
7455
+ key: 0,
7456
+ class: "sf-object-summary"
7330
7457
  };
7331
- const _hoisted_4$3 = { class: "sf-object-title" };
7332
- const _hoisted_5$3 = { class: "sf-object-fields" };
7458
+ const _hoisted_7$2 = { class: "sf-object-fields" };
7333
7459
 
7334
7460
  function render$6(_ctx, _cache, $props, $setup, $data, $options) {
7335
7461
  const _component_SchemaEditor = resolveComponent("SchemaEditor");
7462
+ const _component_SfIcon = resolveComponent("SfIcon");
7336
7463
 
7337
7464
  return ($options.isRoot)
7338
7465
  ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
7339
7466
  createBaseVNode("div", _hoisted_2$4, [
7340
- createCommentVNode(" {{ schema.properties }}\n <span v-for=\"(propSchema, key) in schema.properties\" :key=\"key\">\n {{ key }}: {{ form.resolveSchema(propSchema) }}\n </span> "),
7341
7467
  (openBlock(true), createElementBlock(Fragment, null, renderList(($props.schema.properties || {}), (propSchema, key) => {
7342
7468
  return (openBlock(), createBlock(_component_SchemaEditor, {
7343
7469
  key: key,
@@ -7350,9 +7476,28 @@ function render$6(_ctx, _cache, $props, $setup, $data, $options) {
7350
7476
  }), 128 /* KEYED_FRAGMENT */))
7351
7477
  ])
7352
7478
  ]))
7353
- : (openBlock(), createElementBlock("fieldset", _hoisted_3$4, [
7354
- createBaseVNode("legend", _hoisted_4$3, toDisplayString($options.title), 1 /* TEXT */),
7355
- createBaseVNode("div", _hoisted_5$3, [
7479
+ : (openBlock(), createElementBlock("fieldset", {
7480
+ key: 1,
7481
+ class: normalizeClass(["sf-object", { 'sf-object-collapsed': $data.collapsed }])
7482
+ }, [
7483
+ createBaseVNode("legend", _hoisted_3$4, [
7484
+ createBaseVNode("button", {
7485
+ type: "button",
7486
+ class: "sf-collapse-btn",
7487
+ "aria-label": $data.collapsed ? 'Expand' : 'Collapse',
7488
+ onClick: _cache[0] || (_cache[0] = $event => ($data.collapsed = !$data.collapsed))
7489
+ }, [
7490
+ createVNode(_component_SfIcon, {
7491
+ name: $data.collapsed ? 'chevron-down' : 'chevron-up',
7492
+ size: 12
7493
+ }, null, 8 /* PROPS */, ["name"])
7494
+ ], 8 /* PROPS */, _hoisted_4$3),
7495
+ createBaseVNode("span", _hoisted_5$3, toDisplayString($options.title), 1 /* TEXT */),
7496
+ ($data.collapsed && $options.summary)
7497
+ ? (openBlock(), createElementBlock("span", _hoisted_6$3, toDisplayString($options.summary), 1 /* TEXT */))
7498
+ : createCommentVNode("v-if", true)
7499
+ ]),
7500
+ withDirectives(createBaseVNode("div", _hoisted_7$2, [
7356
7501
  (openBlock(true), createElementBlock(Fragment, null, renderList(($props.schema.properties || {}), (propSchema, key) => {
7357
7502
  return (openBlock(), createBlock(_component_SchemaEditor, {
7358
7503
  key: key,
@@ -7363,8 +7508,10 @@ function render$6(_ctx, _cache, $props, $setup, $data, $options) {
7363
7508
  "onUpdate:modelValue": $event => ($options.onChildChange(key, $event))
7364
7509
  }, null, 8 /* PROPS */, ["schema", "model-value", "path", "form", "onUpdate:modelValue"]))
7365
7510
  }), 128 /* KEYED_FRAGMENT */))
7511
+ ], 512 /* NEED_PATCH */), [
7512
+ [vShow, !$data.collapsed]
7366
7513
  ])
7367
- ]))
7514
+ ], 2 /* CLASS */))
7368
7515
  }
7369
7516
 
7370
7517
  script$6.render = render$6;
@@ -7416,6 +7563,7 @@ var script$5 = {
7416
7563
  beforeCreate() {
7417
7564
  if (!this.$options.components) this.$options.components = {};
7418
7565
  this.$options.components.SchemaEditor = script$1;
7566
+ this.$options.components.SfIcon = script$7;
7419
7567
  },
7420
7568
  props: {
7421
7569
  schema: { type: Object, required: true },
@@ -7428,6 +7576,9 @@ var script$5 = {
7428
7576
  const arr = Array.isArray(this.modelValue) ? this.modelValue : [];
7429
7577
  return {
7430
7578
  items: arr.map(v => ({ _key: keyCounter++, value: v })),
7579
+ dragSourceIndex: null,
7580
+ dragOverIndex: null,
7581
+ allCollapsed: false,
7431
7582
  };
7432
7583
  },
7433
7584
  computed: {
@@ -7468,6 +7619,44 @@ var script$5 = {
7468
7619
  this.items[index].value = value;
7469
7620
  this.emitValue();
7470
7621
  },
7622
+ onDragStart(index, event) {
7623
+ this.dragSourceIndex = index;
7624
+ event.dataTransfer.effectAllowed = 'move';
7625
+ event.dataTransfer.setData('text/plain', String(index));
7626
+ },
7627
+ onDragOver(index) {
7628
+ if (this.dragSourceIndex !== null && index !== this.dragSourceIndex) {
7629
+ this.dragOverIndex = index;
7630
+ }
7631
+ },
7632
+ onDragLeave(index) {
7633
+ if (this.dragOverIndex === index) {
7634
+ this.dragOverIndex = null;
7635
+ }
7636
+ },
7637
+ onDrop(index) {
7638
+ if (this.dragSourceIndex === null || this.dragSourceIndex === index) return;
7639
+ const moved = this.items.splice(this.dragSourceIndex, 1)[0];
7640
+ this.items.splice(index, 0, moved);
7641
+ this.dragSourceIndex = null;
7642
+ this.dragOverIndex = null;
7643
+ this.emitValue();
7644
+ },
7645
+ onDragEnd() {
7646
+ this.dragSourceIndex = null;
7647
+ this.dragOverIndex = null;
7648
+ },
7649
+ toggleCollapseAll() {
7650
+ this.allCollapsed = !this.allCollapsed;
7651
+ const editors = this.$refs.itemEditors;
7652
+ if (!editors) return;
7653
+ const list = Array.isArray(editors) ? editors : [editors];
7654
+ if (this.allCollapsed) {
7655
+ list.forEach(editor => editor?.collapseAll?.());
7656
+ } else {
7657
+ list.forEach(editor => editor?.expandAll?.());
7658
+ }
7659
+ },
7471
7660
  emitValue() {
7472
7661
  this.$emit('update:modelValue', this.items.map(i => i.value));
7473
7662
  },
@@ -7477,20 +7666,28 @@ var script$5 = {
7477
7666
  const _hoisted_1$4 = { class: "sf-array-header" };
7478
7667
  const _hoisted_2$3 = { class: "sf-label" };
7479
7668
  const _hoisted_3$3 = { class: "sf-array-count" };
7480
- const _hoisted_4$2 = { class: "sf-array-items" };
7481
- const _hoisted_5$2 = { class: "sf-array-item-header" };
7482
- const _hoisted_6$2 = { class: "sf-array-item-index" };
7483
- const _hoisted_7$1 = { class: "sf-array-item-actions" };
7484
- const _hoisted_8$1 = ["onClick"];
7485
- const _hoisted_9$1 = ["onClick"];
7486
- const _hoisted_10$1 = ["onClick"];
7487
- const _hoisted_11 = { class: "sf-array-item-body" };
7488
- const _hoisted_12 = {
7669
+ const _hoisted_4$2 = ["title"];
7670
+ const _hoisted_5$2 = { class: "sf-array-items" };
7671
+ const _hoisted_6$2 = ["onDragstart", "onDragover", "onDragleave", "onDrop"];
7672
+ const _hoisted_7$1 = { class: "sf-array-item-header" };
7673
+ const _hoisted_8$1 = { class: "sf-array-item-left" };
7674
+ const _hoisted_9$1 = {
7675
+ class: "sf-drag-handle",
7676
+ title: "Drag to reorder"
7677
+ };
7678
+ const _hoisted_10$1 = { class: "sf-array-item-index" };
7679
+ const _hoisted_11 = { class: "sf-array-item-actions" };
7680
+ const _hoisted_12 = ["onClick"];
7681
+ const _hoisted_13 = ["onClick"];
7682
+ const _hoisted_14 = ["onClick"];
7683
+ const _hoisted_15 = ["onDrop"];
7684
+ const _hoisted_16 = {
7489
7685
  key: 0,
7490
7686
  class: "errorlist"
7491
7687
  };
7492
7688
 
7493
7689
  function render$5(_ctx, _cache, $props, $setup, $data, $options) {
7690
+ const _component_SfIcon = resolveComponent("SfIcon");
7494
7691
  const _component_SchemaEditor = resolveComponent("SchemaEditor");
7495
7692
 
7496
7693
  return (openBlock(), createElementBlock("div", {
@@ -7503,60 +7700,92 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
7503
7700
  type: "button",
7504
7701
  class: "sf-btn sf-btn-add",
7505
7702
  onClick: _cache[0] || (_cache[0] = $event => ($options.addItem()))
7506
- }, [...(_cache[1] || (_cache[1] = [
7507
- createBaseVNode("i", { class: "fas fa-plus" }, null, -1 /* CACHED */),
7508
- createTextVNode(" Add ", -1 /* CACHED */)
7509
- ]))])
7703
+ }, [
7704
+ createVNode(_component_SfIcon, { name: "plus" }),
7705
+ _cache[4] || (_cache[4] = createTextVNode(" Add ", -1 /* CACHED */))
7706
+ ]),
7707
+ ($data.items.length)
7708
+ ? (openBlock(), createElementBlock("span", {
7709
+ key: 0,
7710
+ class: "sf-array-collapse-toggle",
7711
+ title: $data.allCollapsed ? 'Expand all' : 'Collapse all',
7712
+ onClick: _cache[1] || (_cache[1] = (...args) => ($options.toggleCollapseAll && $options.toggleCollapseAll(...args)))
7713
+ }, [
7714
+ createVNode(_component_SfIcon, {
7715
+ name: $data.allCollapsed ? 'chevron-down' : 'chevron-up'
7716
+ }, null, 8 /* PROPS */, ["name"])
7717
+ ], 8 /* PROPS */, _hoisted_4$2))
7718
+ : createCommentVNode("v-if", true)
7510
7719
  ]),
7511
- createBaseVNode("div", _hoisted_4$2, [
7720
+ createBaseVNode("div", _hoisted_5$2, [
7512
7721
  (openBlock(true), createElementBlock(Fragment, null, renderList($data.items, (item, index) => {
7513
7722
  return (openBlock(), createElementBlock("div", {
7514
7723
  key: item._key,
7515
- class: "sf-array-item"
7724
+ class: normalizeClass(["sf-array-item", { 'sf-drag-over': $data.dragOverIndex === index, 'sf-dragging': $data.dragSourceIndex === index }]),
7725
+ draggable: "true",
7726
+ onDragstart: $event => ($options.onDragStart(index, $event)),
7727
+ onDragover: withModifiers($event => ($options.onDragOver(index)), ["prevent"]),
7728
+ onDragleave: $event => ($options.onDragLeave(index)),
7729
+ onDrop: withModifiers($event => ($options.onDrop(index)), ["prevent"]),
7730
+ onDragend: _cache[3] || (_cache[3] = (...args) => ($options.onDragEnd && $options.onDragEnd(...args)))
7516
7731
  }, [
7517
- createBaseVNode("div", _hoisted_5$2, [
7518
- createBaseVNode("span", _hoisted_6$2, "#" + toDisplayString(index + 1), 1 /* TEXT */),
7519
- createBaseVNode("div", _hoisted_7$1, [
7732
+ createBaseVNode("div", _hoisted_7$1, [
7733
+ createBaseVNode("div", _hoisted_8$1, [
7734
+ createBaseVNode("span", _hoisted_9$1, [
7735
+ createVNode(_component_SfIcon, { name: "grip" })
7736
+ ]),
7737
+ createBaseVNode("span", _hoisted_10$1, "#" + toDisplayString(index + 1), 1 /* TEXT */)
7738
+ ]),
7739
+ createBaseVNode("div", _hoisted_11, [
7520
7740
  (index > 0)
7521
7741
  ? (openBlock(), createElementBlock("button", {
7522
7742
  key: 0,
7523
7743
  type: "button",
7524
7744
  class: "sf-btn sf-btn-sm",
7525
7745
  onClick: $event => ($options.moveItem(index, -1))
7526
- }, [...(_cache[2] || (_cache[2] = [
7527
- createBaseVNode("i", { class: "fas fa-arrow-up" }, null, -1 /* CACHED */)
7528
- ]))], 8 /* PROPS */, _hoisted_8$1))
7746
+ }, [
7747
+ createVNode(_component_SfIcon, { name: "arrow-up" })
7748
+ ], 8 /* PROPS */, _hoisted_12))
7749
+ : createCommentVNode("v-if", true),
7750
+ (index < $data.items.length - 1)
7751
+ ? (openBlock(), createElementBlock("button", {
7752
+ key: 1,
7753
+ type: "button",
7754
+ class: "sf-btn sf-btn-sm",
7755
+ onClick: $event => ($options.moveItem(index, 1))
7756
+ }, [
7757
+ createVNode(_component_SfIcon, { name: "arrow-down" })
7758
+ ], 8 /* PROPS */, _hoisted_13))
7529
7759
  : createCommentVNode("v-if", true),
7530
- createBaseVNode("button", {
7531
- type: "button",
7532
- class: "sf-btn sf-btn-sm",
7533
- onClick: $event => ($options.moveItem(index, 1))
7534
- }, [...(_cache[3] || (_cache[3] = [
7535
- createBaseVNode("i", { class: "fas fa-arrow-down" }, null, -1 /* CACHED */)
7536
- ]))], 8 /* PROPS */, _hoisted_9$1),
7537
7760
  createBaseVNode("button", {
7538
7761
  type: "button",
7539
7762
  class: "sf-btn sf-btn-sm sf-btn-danger",
7540
7763
  onClick: $event => ($options.removeItem(index))
7541
- }, [...(_cache[4] || (_cache[4] = [
7542
- createBaseVNode("i", { class: "fas fa-times" }, null, -1 /* CACHED */)
7543
- ]))], 8 /* PROPS */, _hoisted_10$1)
7764
+ }, [
7765
+ createVNode(_component_SfIcon, { name: "times" })
7766
+ ], 8 /* PROPS */, _hoisted_14)
7544
7767
  ])
7545
7768
  ]),
7546
- createBaseVNode("div", _hoisted_11, [
7769
+ createBaseVNode("div", {
7770
+ class: "sf-array-item-body",
7771
+ onDragover: _cache[2] || (_cache[2] = withModifiers(() => {}, ["prevent"])),
7772
+ onDrop: withModifiers($event => ($options.onDrop(index)), ["prevent"])
7773
+ }, [
7547
7774
  createVNode(_component_SchemaEditor, {
7775
+ ref_for: true,
7776
+ ref: "itemEditors",
7548
7777
  schema: $options.itemSchema,
7549
7778
  "model-value": item.value,
7550
7779
  path: [...$props.path, String(index)],
7551
7780
  form: $props.form,
7552
7781
  "onUpdate:modelValue": $event => ($options.onItemChange(index, $event))
7553
7782
  }, null, 8 /* PROPS */, ["schema", "model-value", "path", "form", "onUpdate:modelValue"])
7554
- ])
7555
- ]))
7783
+ ], 40 /* PROPS, NEED_HYDRATION */, _hoisted_15)
7784
+ ], 42 /* CLASS, PROPS, NEED_HYDRATION */, _hoisted_6$2))
7556
7785
  }), 128 /* KEYED_FRAGMENT */))
7557
7786
  ]),
7558
7787
  ($options.fieldErrors.length)
7559
- ? (openBlock(), createElementBlock("ul", _hoisted_12, [
7788
+ ? (openBlock(), createElementBlock("ul", _hoisted_16, [
7560
7789
  (openBlock(true), createElementBlock(Fragment, null, renderList($options.fieldErrors, (err, i) => {
7561
7790
  return (openBlock(), createElementBlock("li", { key: i }, toDisplayString(err), 1 /* TEXT */))
7562
7791
  }), 128 /* KEYED_FRAGMENT */))
@@ -7573,6 +7802,7 @@ var script$4 = {
7573
7802
  beforeCreate() {
7574
7803
  if (!this.$options.components) this.$options.components = {};
7575
7804
  this.$options.components.SchemaEditor = script$1;
7805
+ this.$options.components.SfIcon = script$7;
7576
7806
  },
7577
7807
  props: {
7578
7808
  schema: { type: Object, required: true },
@@ -7640,6 +7870,7 @@ const _hoisted_3$2 = {
7640
7870
  };
7641
7871
 
7642
7872
  function render$4(_ctx, _cache, $props, $setup, $data, $options) {
7873
+ const _component_SfIcon = resolveComponent("SfIcon");
7643
7874
  const _component_SchemaEditor = resolveComponent("SchemaEditor");
7644
7875
 
7645
7876
  return (openBlock(), createElementBlock("div", {
@@ -7656,12 +7887,12 @@ function render$4(_ctx, _cache, $props, $setup, $data, $options) {
7656
7887
  }, [
7657
7888
  ($data.isNull)
7658
7889
  ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
7659
- _cache[2] || (_cache[2] = createBaseVNode("i", { class: "fas fa-plus" }, null, -1 /* CACHED */)),
7660
- _cache[3] || (_cache[3] = createTextVNode(" Add ", -1 /* CACHED */))
7890
+ createVNode(_component_SfIcon, { name: "plus" }),
7891
+ _cache[2] || (_cache[2] = createTextVNode(" Add ", -1 /* CACHED */))
7661
7892
  ], 64 /* STABLE_FRAGMENT */))
7662
7893
  : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
7663
- _cache[4] || (_cache[4] = createBaseVNode("i", { class: "fas fa-times" }, null, -1 /* CACHED */)),
7664
- _cache[5] || (_cache[5] = createTextVNode(" Remove ", -1 /* CACHED */))
7894
+ createVNode(_component_SfIcon, { name: "times" }),
7895
+ _cache[3] || (_cache[3] = createTextVNode(" Remove ", -1 /* CACHED */))
7665
7896
  ], 64 /* STABLE_FRAGMENT */))
7666
7897
  ], 2 /* CLASS */)
7667
7898
  ]),
@@ -7795,6 +8026,7 @@ script$3.__file = "src/editors/UnionEditor.vue";
7795
8026
 
7796
8027
  var script$2 = {
7797
8028
  name: 'RelationEditor',
8029
+ components: { SfIcon: script$7 },
7798
8030
  props: {
7799
8031
  schema: { type: Object, required: true },
7800
8032
  modelValue: { default: null },
@@ -7846,8 +8078,8 @@ var script$2 = {
7846
8078
  return this.form.getErrorsForPath(this.path);
7847
8079
  },
7848
8080
  filteredResults() {
7849
- const selectedIds = new Set(this.selected.map(s => `${s.id}-${s.model || ''}`));
7850
- return this.searchResults.filter(item => !selectedIds.has(`${item.id}-${item.model || ''}`));
8081
+ const selectedIds = new Set(this.selected.map(item => this.itemKey(item)));
8082
+ return this.searchResults.filter(item => !selectedIds.has(this.itemKey(item)));
7851
8083
  },
7852
8084
  },
7853
8085
  created() {
@@ -7978,6 +8210,8 @@ const _hoisted_10 = {
7978
8210
  };
7979
8211
 
7980
8212
  function render$2(_ctx, _cache, $props, $setup, $data, $options) {
8213
+ const _component_SfIcon = resolveComponent("SfIcon");
8214
+
7981
8215
  return (openBlock(), createElementBlock("div", {
7982
8216
  class: normalizeClass(["sf-field sf-relation", { errors: $options.fieldErrors.length }]),
7983
8217
  ref: "root"
@@ -8001,9 +8235,9 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
8001
8235
  type: "button",
8002
8236
  class: "sf-relation-tag-remove",
8003
8237
  onClick: withModifiers($event => ($options.removeItem(item)), ["stop"])
8004
- }, [...(_cache[5] || (_cache[5] = [
8005
- createBaseVNode("i", { class: "fas fa-times" }, null, -1 /* CACHED */)
8006
- ]))], 8 /* PROPS */, _hoisted_4))
8238
+ }, [
8239
+ createVNode(_component_SfIcon, { name: "times" })
8240
+ ], 8 /* PROPS */, _hoisted_4))
8007
8241
  : createCommentVNode("v-if", true)
8008
8242
  ]))
8009
8243
  }), 128 /* KEYED_FRAGMENT */))
@@ -8068,11 +8302,11 @@ const MAX_DEPTH = 12;
8068
8302
  var script$1 = {
8069
8303
  name: 'SchemaEditor',
8070
8304
  components: {
8071
- StringEditor: script$b,
8072
- NumberEditor: script$a,
8073
- BooleanEditor: script$9,
8074
- SelectEditor: script$8,
8075
- HiddenEditor: script$7,
8305
+ StringEditor: script$c,
8306
+ NumberEditor: script$b,
8307
+ BooleanEditor: script$a,
8308
+ SelectEditor: script$9,
8309
+ HiddenEditor: script$8,
8076
8310
  ObjectEditor: script$6,
8077
8311
  ArrayEditor: script$5,
8078
8312
  NullableEditor: script$4,
@@ -8086,6 +8320,18 @@ var script$1 = {
8086
8320
  form: { type: Object, required: true },
8087
8321
  },
8088
8322
  emits: ['update:modelValue'],
8323
+ methods: {
8324
+ collapseAll() {
8325
+ const editor = this.$refs.editor;
8326
+ if (editor?.collapse) editor.collapse();
8327
+ if (editor?.collapseAll) editor.collapseAll();
8328
+ },
8329
+ expandAll() {
8330
+ const editor = this.$refs.editor;
8331
+ if (editor?.expand) editor.expand();
8332
+ if (editor?.expandAll) editor.expandAll();
8333
+ },
8334
+ },
8089
8335
  computed: {
8090
8336
  editorComponent() {
8091
8337
  const schema = this.schema;
@@ -8110,6 +8356,7 @@ var script$1 = {
8110
8356
 
8111
8357
  function render$1(_ctx, _cache, $props, $setup, $data, $options) {
8112
8358
  return (openBlock(), createBlock(resolveDynamicComponent($options.editorComponent), {
8359
+ ref: "editor",
8113
8360
  schema: $props.schema,
8114
8361
  "model-value": $props.modelValue,
8115
8362
  path: $props.path,
@@ -8280,5 +8527,5 @@ function registerCustomElement(tagName = 'schema-form') {
8280
8527
  }
8281
8528
  }
8282
8529
 
8283
- export { script$5 as ArrayEditor, script$9 as BooleanEditor, script$7 as HiddenEditor, script$4 as NullableEditor, script$a as NumberEditor, script$6 as ObjectEditor, script$2 as RelationEditor, script$1 as SchemaEditor, script as SchemaForm, SchemaFormElement, script$8 as SelectEditor, script$b as StringEditor, script$3 as UnionEditor, registerCustomElement };
8530
+ export { script$5 as ArrayEditor, script$a as BooleanEditor, script$8 as HiddenEditor, script$4 as NullableEditor, script$b as NumberEditor, script$6 as ObjectEditor, script$2 as RelationEditor, script$1 as SchemaEditor, script as SchemaForm, SchemaFormElement, script$9 as SelectEditor, script$c as StringEditor, script$3 as UnionEditor, registerCustomElement };
8284
8531
  //# sourceMappingURL=structured-widget-editor.esm.js.map