alchemy-widget 0.1.6 → 0.2.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/assets/stylesheets/{alchemy-widgets.scss → alchemy_widgets.scss} +169 -54
  3. package/bootstrap.js +101 -2
  4. package/controller/alchemy_widgets_controller.js +64 -0
  5. package/element/00-widget_base_element.js +105 -4
  6. package/element/05-widget_element.js +33 -21
  7. package/element/10-container_elements.js +27 -32
  8. package/element/11-alchemy_widgets_list_element.js +2 -2
  9. package/element/20-add_area_element.js +22 -22
  10. package/element/table_of_contents_element.js +144 -11
  11. package/element/widget_actionbar_element.js +92 -0
  12. package/element/widget_context_element.js +39 -23
  13. package/element/widget_toolbar_element.js +295 -50
  14. package/helper/widget_action.js +10 -10
  15. package/helper/widgets/00-widget.js +244 -27
  16. package/helper/widgets/01-container.js +29 -7
  17. package/helper/widgets/05-list.js +1 -1
  18. package/helper/widgets/alchemy_field_widget.js +112 -0
  19. package/helper/widgets/alchemy_form_widget.js +183 -0
  20. package/helper/widgets/alchemy_table_widget.js +71 -0
  21. package/helper/widgets/alchemy_tabs_widget.js +193 -0
  22. package/helper/widgets/hawkejs_template.js +60 -0
  23. package/helper/widgets/header.js +8 -10
  24. package/helper/widgets/html.js +52 -3
  25. package/helper/widgets/markdown.js +18 -13
  26. package/helper/widgets/partial.js +1 -3
  27. package/helper/widgets/sourcecode.js +5 -7
  28. package/helper/widgets/table_of_contents.js +2 -4
  29. package/helper/widgets/text.js +15 -15
  30. package/helper/widgets_helper.js +26 -0
  31. package/package.json +3 -2
  32. package/view/elements/table_of_contents.hwk +33 -9
  33. package/view/form/inputs/edit/widget.hwk +2 -2
  34. package/view/form/inputs/edit/widgets.hwk +2 -2
  35. package/view/widget/elements/al_widget_toolbar.hwk +49 -0
  36. package/view/widget/widget_config.hwk +7 -4
  37. package/assets/stylesheets/alchemy-widget-symbols.scss +0 -191
@@ -5,14 +5,18 @@
5
5
  *
6
6
  * @author Jelle De Loecker <jelle@elevenways.be>
7
7
  * @since 0.1.0
8
- * @version 0.1.0
8
+ * @version 0.2.1
9
9
  *
10
10
  * @param {Object} config
11
11
  */
12
12
  const Widget = Function.inherits('Alchemy.Base', 'Alchemy.Widget', function Widget(config) {
13
13
 
14
14
  // The configuration of this widget
15
- this.config = config || {};
15
+ if (config) {
16
+ this.config = config;
17
+ }
18
+
19
+ this.originalconfig = this.config;
16
20
 
17
21
  // Are we currently editing?
18
22
  this.editing = false;
@@ -72,6 +76,24 @@ Widget.setProperty(function element() {
72
76
  return this.widget = element;
73
77
  });
74
78
 
79
+ /**
80
+ * The config object
81
+ *
82
+ * @author Jelle De Loecker <jelle@elevenways.be>
83
+ * @since 0.2.1
84
+ * @version 0.2.1
85
+ *
86
+ * @type {Object}
87
+ */
88
+ Widget.enforceProperty(function config(new_value) {
89
+
90
+ if (!new_value) {
91
+ new_value = {};
92
+ }
93
+
94
+ return new_value;
95
+ });
96
+
75
97
  /**
76
98
  * A reference to the renderer
77
99
  *
@@ -96,12 +118,37 @@ Widget.enforceProperty(function hawkejs_renderer(new_value) {
96
118
  return new_value;
97
119
  });
98
120
 
121
+ /**
122
+ * Visibility of the widget
123
+ *
124
+ * @author Jelle De Loecker <jelle@elevenways.be>
125
+ * @since 0.2.1
126
+ * @version 0.2.1
127
+ *
128
+ * @type {Boolean}
129
+ */
130
+ Widget.enforceProperty(function is_hidden(new_value) {
131
+
132
+ if (new_value == null) {
133
+ new_value = this.config.hidden;
134
+
135
+ if (new_value == null) {
136
+ new_value = false;
137
+ }
138
+ } else {
139
+ this.config.hidden = new_value;
140
+ this.queueVisibilityUpdate();
141
+ }
142
+
143
+ return new_value;
144
+ });
145
+
99
146
  /**
100
147
  * Prepare the schema & actions
101
148
  *
102
149
  * @author Jelle De Loecker <jelle@elevenways.be>
103
150
  * @since 0.1.0
104
- * @version 0.1.6
151
+ * @version 0.2.1
105
152
  */
106
153
  Widget.constitute(function prepareSchema() {
107
154
 
@@ -114,7 +161,7 @@ Widget.constitute(function prepareSchema() {
114
161
  // Extra classnames for the wrapper
115
162
  this.schema.addField('wrapper_class_names', 'String', {
116
163
  title : 'Wrapper CSS classes',
117
- description : 'Configure extra CSS classes to the wrapper `alchemy-widget` element',
164
+ description : 'Configure extra CSS classes to the wrapper `al-widget` element',
118
165
  array: true,
119
166
  widget_config_editable: true,
120
167
  });
@@ -126,6 +173,47 @@ Widget.constitute(function prepareSchema() {
126
173
  array: true,
127
174
  });
128
175
 
176
+ // Should this widget be hidden?
177
+ this.schema.addField('hidden', 'Boolean', {
178
+ title : 'Should this widget be hidden?',
179
+ description : 'Hidden widgets are only visible during editing',
180
+ default : false,
181
+ });
182
+
183
+ this.schema.addField('language', 'String', {
184
+ title : 'Language override',
185
+ description : 'If the content of this widget is in a different language, set it here',
186
+ widget_config_editable : true,
187
+ });
188
+
189
+ // Add the "copy to clipboard" action
190
+ let copy = this.createAction('copy', 'Copy to clipboard');
191
+
192
+ copy.setHandler(function copyAction(widget_el, handle) {
193
+ return widget_el.copyConfigToClipboard();
194
+ });
195
+
196
+ copy.setTester(function copyAction(widget_el, handle) {
197
+ return true;
198
+ });
199
+
200
+ copy.setIcon('clipboard');
201
+ copy.close_actionbar = true;
202
+
203
+ // Add the "paste from clipboard" action
204
+ let paste = this.createAction('paste', 'Replace from clipboard');
205
+
206
+ paste.setHandler(function pasteAction(widget_el, handle) {
207
+ return widget_el.pasteConfigFromClipboard();
208
+ });
209
+
210
+ paste.setTester(function pasteAction(widget_el, handle) {
211
+ return widget_el.getConfigFromClipboard();
212
+ });
213
+
214
+ paste.setIcon('paste');
215
+ paste.close_actionbar = true;
216
+
129
217
  // Add the "save" action
130
218
  let save = this.createAction('save', 'Save');
131
219
 
@@ -139,10 +227,40 @@ Widget.constitute(function prepareSchema() {
139
227
 
140
228
  save.setIcon('floppy-disk');
141
229
 
230
+ // Add the hide action
231
+ let hide = this.createAction('hide', 'Hide');
232
+
233
+ hide.close_actionbar = true;
234
+
235
+ hide.setHandler(function hideAction(widget_el, handle) {
236
+ widget_el.instance.is_hidden = true;
237
+ });
238
+
239
+ hide.setTester(function hideTester(widget_el, handle) {
240
+ return !widget_el.instance.is_hidden;
241
+ });
242
+
243
+ hide.setIcon('eye-slash');
244
+
245
+ // Add the show action
246
+ let show = this.createAction('show', 'Show');
247
+
248
+ show.close_actionbar = true;
249
+
250
+ show.setHandler(function showAction(widget_el, handle) {
251
+ widget_el.instance.is_hidden = false;
252
+ });
253
+
254
+ show.setTester(function showTester(widget_el, handle) {
255
+ return widget_el.instance.is_hidden;
256
+ });
257
+
258
+ show.setIcon('eye');
259
+
142
260
  // Add the remove action
143
261
  let remove = this.createAction('remove', 'Remove');
144
262
 
145
- remove.close_toolbar = true;
263
+ remove.close_actionbar = true;
146
264
 
147
265
  remove.setHandler(function removeAction(widget_el, handle) {
148
266
  handle.remove();
@@ -157,7 +275,7 @@ Widget.constitute(function prepareSchema() {
157
275
  // Add the config action
158
276
  let config = this.createAction('config', 'Config');
159
277
 
160
- config.close_toolbar = true;
278
+ config.close_actionbar = true;
161
279
  config.setIcon('gears');
162
280
 
163
281
  config.setHandler(function configAction(widget_el, handle) {
@@ -167,7 +285,7 @@ Widget.constitute(function prepareSchema() {
167
285
  // The move-left action
168
286
  let move_left = this.createAction('move-left', 'Move left');
169
287
 
170
- move_left.close_toolbar = true;
288
+ move_left.close_actionbar = true;
171
289
 
172
290
  move_left.setHandler(function moveLeftAction(widget_el, handle) {
173
291
  // Hawkejs custom element method!
@@ -187,7 +305,7 @@ Widget.constitute(function prepareSchema() {
187
305
 
188
306
  let move_right = this.createAction('move-right', 'Move right');
189
307
 
190
- move_right.close_toolbar = true;
308
+ move_right.close_actionbar = true;
191
309
 
192
310
  move_right.setHandler(function moveRightAction(widget_el, handle) {
193
311
  // Hawkejs custom element method!
@@ -202,7 +320,7 @@ Widget.constitute(function prepareSchema() {
202
320
 
203
321
  let next = handle.nextElementSibling;
204
322
 
205
- if (!next || next.tagName == 'ALCHEMY-WIDGET-ADD-AREA') {
323
+ if (!next || next.tagName == 'AL-WIDGET-ADD-AREA') {
206
324
  return false;
207
325
  }
208
326
 
@@ -214,7 +332,7 @@ Widget.constitute(function prepareSchema() {
214
332
  // The move-in-left action
215
333
  let move_in_left = this.createAction('move-in-left', 'Move in left');
216
334
 
217
- move_in_left.close_toolbar = true;
335
+ move_in_left.close_actionbar = true;
218
336
 
219
337
  move_in_left.setHandler(function moveLeftAction(widget_el, handle) {
220
338
  // Hawkejs custom element method!
@@ -239,7 +357,7 @@ Widget.constitute(function prepareSchema() {
239
357
  // The move-in-right action
240
358
  let move_in_right = this.createAction('move-in-right', 'Move in right');
241
359
 
242
- move_in_right.close_toolbar = true;
360
+ move_in_right.close_actionbar = true;
243
361
 
244
362
  move_in_right.setHandler(function moveRightAction(widget_el, handle) {
245
363
  // Hawkejs custom element method!
@@ -421,22 +539,29 @@ Widget.setMethod(function toDry() {
421
539
  });
422
540
 
423
541
  /**
424
- * Get an array of toolbar actions
542
+ * Get an array of actionbar actions
425
543
  *
426
544
  * @author Jelle De Loecker <jelle@elevenways.be>
427
545
  * @since 0.1.0
428
- * @version 0.1.0
546
+ * @version 0.2.0
429
547
  *
430
548
  * @return {Array}
431
549
  */
432
- Widget.setMethod(function getToolbarActions() {
550
+ Widget.setMethod(async function getActionbarActions() {
433
551
 
434
552
  let sorted = this.constructor.actions.getSorted(),
435
553
  result = [],
436
554
  action;
437
555
 
438
556
  for (action of sorted) {
439
- if (action.test(this.widget)) {
557
+
558
+ let tester = action.test(this.widget);
559
+
560
+ if (Pledge.isThenable(tester)) {
561
+ tester = await tester;
562
+ }
563
+
564
+ if (tester) {
440
565
  result.push(action);
441
566
  }
442
567
  }
@@ -476,17 +601,17 @@ Widget.setMethod(function createElement(tag_name) {
476
601
 
477
602
  /**
478
603
  * Create an instance of the HTML element representing this widget
479
- * This will probably be just <alchemy-widget>
604
+ * This will probably be just <al-widget>
480
605
  *
481
606
  * @author Jelle De Loecker <jelle@elevenways.be>
482
607
  * @since 0.1.0
483
- * @version 0.1.0
608
+ * @version 0.2.0
484
609
  *
485
610
  * @return {HTMLElement}
486
611
  */
487
612
  Widget.setMethod(function _createWidgetElement() {
488
613
 
489
- let element = this.createElement('alchemy-widget');
614
+ let element = this.createElement('al-widget');
490
615
 
491
616
  // Set the type of the widget to our type
492
617
  element.type = this.constructor.type_name;
@@ -524,20 +649,34 @@ Widget.setMethod(function _createPopulatedWidgetElement() {
524
649
  return element;
525
650
  });
526
651
 
652
+
653
+ /**
654
+ * Populate the actual widget
655
+ *
656
+ * @author Jelle De Loecker <jelle@elevenways.be>
657
+ * @since 0.2.1
658
+ * @version 0.2.1
659
+ */
660
+ Widget.setMethod(function populateWidget() {
661
+ // Does nothing on its own
662
+ });
663
+
527
664
  /**
528
665
  * Populate the contents of the widget
529
666
  *
530
667
  * @author Jelle De Loecker <jelle@elevenways.be>
531
668
  * @since 0.1.0
532
- * @version 0.1.6
669
+ * @version 0.2.1
533
670
  */
534
- Widget.setMethod(function populateWidget() {
671
+ Widget.setMethod(function finalizePopulatedWidget() {
535
672
 
536
- if (this.config && this.config.wrapper_class_names) {
673
+ const config = this.config;
674
+
675
+ if (config.wrapper_class_names) {
537
676
  let name,
538
677
  i;
539
678
 
540
- let class_names = Array.cast(this.config.wrapper_class_names);
679
+ let class_names = Array.cast(config.wrapper_class_names);
541
680
 
542
681
  for (i = 0; i < class_names.length; i++) {
543
682
  name = class_names[i];
@@ -545,6 +684,12 @@ Widget.setMethod(function populateWidget() {
545
684
  }
546
685
  }
547
686
 
687
+ if (config.language) {
688
+ this.widget.setAttribute('lang', config.language);
689
+ } else {
690
+ this.widget.removeAttribute('lang');
691
+ }
692
+
548
693
  let child_classes = this.widget.child_class;
549
694
 
550
695
  if (child_classes) {
@@ -555,6 +700,68 @@ Widget.setMethod(function populateWidget() {
555
700
  Hawkejs.addClasses(children[i], child_classes);
556
701
  }
557
702
  }
703
+
704
+ let child_roles = this.widget.child_role;
705
+
706
+ if (child_roles) {
707
+ let children = this.widget.children,
708
+ child,
709
+ i;
710
+
711
+ for (i = 0; i < children.length; i++) {
712
+ child = children[i];
713
+
714
+ if (!child.hasAttribute('role')) {
715
+ child.setAttribute('role', child_roles);
716
+ }
717
+ }
718
+ }
719
+
720
+ this.checkVisibility();
721
+ });
722
+
723
+ /**
724
+ * Queue a widget element visibility update
725
+ *
726
+ * @author Jelle De Loecker <jelle@elevenways.be>
727
+ * @since 0.2.1
728
+ * @version 0.2.1
729
+ */
730
+ Widget.setMethod(function queueVisibilityUpdate() {
731
+
732
+ if (this._visibility_update_queue) {
733
+ clearTimeout(this._visibility_update_queue);
734
+ }
735
+
736
+ this._visibility_update_queue = setTimeout(() => {
737
+ this.checkVisibility();
738
+ this._visibility_update_queue = null;
739
+ }, 50);
740
+ });
741
+
742
+ /**
743
+ * Check the widget element visibility
744
+ *
745
+ * @author Jelle De Loecker <jelle@elevenways.be>
746
+ * @since 0.2.1
747
+ * @version 0.2.1
748
+ */
749
+ Widget.setMethod(function checkVisibility() {
750
+
751
+ let should_be_hidden = this.is_hidden;
752
+
753
+ if (this.editing) {
754
+ this.widget.hidden = false;
755
+ } else {
756
+ this.widget.hidden = should_be_hidden;
757
+ }
758
+
759
+ if (should_be_hidden) {
760
+ this.widget.classList.add('aw-hidden');
761
+ } else {
762
+ this.widget.classList.remove('aw-hidden');
763
+ }
764
+
558
765
  });
559
766
 
560
767
  /**
@@ -562,7 +769,7 @@ Widget.setMethod(function populateWidget() {
562
769
  *
563
770
  * @author Jelle De Loecker <jelle@elevenways.be>
564
771
  * @since 0.1.0
565
- * @version 0.1.6
772
+ * @version 0.2.1
566
773
  */
567
774
  Widget.setMethod(async function startEditor() {
568
775
 
@@ -582,6 +789,8 @@ Widget.setMethod(async function startEditor() {
582
789
  if (typeof this._startEditor == 'function') {
583
790
  this._startEditor();
584
791
  }
792
+
793
+ this.checkVisibility();
585
794
  });
586
795
 
587
796
  /**
@@ -589,7 +798,7 @@ Widget.setMethod(async function startEditor() {
589
798
  *
590
799
  * @author Jelle De Loecker <jelle@elevenways.be>
591
800
  * @since 0.1.0
592
- * @version 0.1.0
801
+ * @version 0.2.1
593
802
  */
594
803
  Widget.setMethod(function stopEditor() {
595
804
 
@@ -603,7 +812,13 @@ Widget.setMethod(function stopEditor() {
603
812
 
604
813
  if (typeof this._stopEditor == 'function') {
605
814
  this._stopEditor();
815
+
816
+ // Remove the editing class again
817
+ // (some editors will try to restore the original classes)
818
+ this.widget.classList.remove('aw-editing');
606
819
  }
820
+
821
+ this.checkVisibility();
607
822
  });
608
823
 
609
824
  /**
@@ -611,13 +826,14 @@ Widget.setMethod(function stopEditor() {
611
826
  *
612
827
  * @author Jelle De Loecker <jelle@elevenways.be>
613
828
  * @since 0.1.0
614
- * @version 0.1.6
829
+ * @version 0.2.1
615
830
  */
616
831
  Widget.setMethod(async function rerender() {
617
832
 
618
833
  Hawkejs.removeChildren(this.widget);
619
834
 
620
835
  await this.populateWidget();
836
+ await this.finalizePopulatedWidget();
621
837
 
622
838
  if (this.editing) {
623
839
  this.startEditor();
@@ -642,7 +858,7 @@ Widget.setMethod(function syncConfig() {
642
858
  *
643
859
  * @author Jelle De Loecker <jelle@elevenways.be>
644
860
  * @since 0.1.0
645
- * @version 0.1.12
861
+ * @version 0.2.0
646
862
  */
647
863
  Widget.setMethod(async function showConfig(fields) {
648
864
 
@@ -675,6 +891,7 @@ Widget.setMethod(async function showConfig(fields) {
675
891
  let widget_settings = Object.assign({}, this.syncConfig());
676
892
 
677
893
  let variables = {
894
+ title : this.constructor.title,
678
895
  schema : this.schema,
679
896
  widget_settings,
680
897
  fields : fields
@@ -697,7 +914,7 @@ Widget.setMethod(async function showConfig(fields) {
697
914
  button.addEventListener('click', e => {
698
915
  e.preventDefault();
699
916
 
700
- let form = dialog.querySelector('alchemy-form');
917
+ let form = dialog.querySelector('al-form');
701
918
 
702
919
  Object.assign(this.config, form.value);
703
920
 
@@ -46,18 +46,40 @@ Container.setMethod(function initContainer() {
46
46
  this.populateWidget();
47
47
  });
48
48
 
49
+ /**
50
+ * Populate the widget
51
+ *
52
+ * @author Jelle De Loecker <jelle@elevenways.be>
53
+ * @since 0.2.1
54
+ * @version 0.2.1
55
+ *
56
+ * @return {HTMLElement}
57
+ */
58
+ Container.setMethod(function populateWidget() {
59
+
60
+ const widgets = this.config.widgets;
61
+
62
+ if (widgets?.length) {
63
+ let widget;
64
+
65
+ for (widget of widgets) {
66
+ this.widget.addWidget(widget.type, widget.config);
67
+ }
68
+ }
69
+ });
70
+
49
71
  /**
50
72
  * Create an instance of the HTML element representing this widget
51
73
  *
52
74
  * @author Jelle De Loecker <jelle@elevenways.be>
53
75
  * @since 0.1.0
54
- * @version 0.1.0
76
+ * @version 0.2.0
55
77
  *
56
78
  * @return {HTMLElement}
57
79
  */
58
80
  Container.setMethod(function _createWidgetElement() {
59
81
 
60
- let tag_name = 'alchemy-widgets-' + this.constructor.type_name;
82
+ let tag_name = 'al-widgets-' + this.constructor.type_name;
61
83
 
62
84
  let element = this.createElement(tag_name);
63
85
 
@@ -72,14 +94,14 @@ Container.setMethod(function _createWidgetElement() {
72
94
  *
73
95
  * @author Jelle De Loecker <jelle@elevenways.be>
74
96
  * @since 0.1.0
75
- * @version 0.1.0
97
+ * @version 0.2.0
76
98
  */
77
99
  Container.setMethod(function _startEditor() {
78
100
 
79
- let add_area = this.widget.querySelector(':scope > alchemy-widget-add-area');
101
+ let add_area = this.widget.querySelector(':scope > al-widget-add-area');
80
102
 
81
103
  if (!add_area) {
82
- add_area = this.createElement('alchemy-widget-add-area');
104
+ add_area = this.createElement('al-widget-add-area');
83
105
  this.widget.append(add_area);
84
106
  }
85
107
 
@@ -100,11 +122,11 @@ Container.setMethod(function _startEditor() {
100
122
  *
101
123
  * @author Jelle De Loecker <jelle@elevenways.be>
102
124
  * @since 0.1.0
103
- * @version 0.1.0
125
+ * @version 0.2.0
104
126
  */
105
127
  Container.setMethod(function _stopEditor() {
106
128
 
107
- let add_area = this.widget.querySelector(':scope > alchemy-widget-add-area');
129
+ let add_area = this.widget.querySelector(':scope > al-widget-add-area');
108
130
 
109
131
  if (add_area) {
110
132
  add_area.remove();
@@ -22,7 +22,7 @@ List.setMethod(function initContainer() {
22
22
 
23
23
  let ul = this.createElement('ul');
24
24
 
25
- Classes.Alchemy.Element.Widget.AlchemyWidgets.prototype._appendWidgetElement.call(this.widget, ul);
25
+ Classes.Alchemy.Element.Widget.AlWidgets.prototype._appendWidgetElement.call(this.widget, ul);
26
26
 
27
27
  this.widget.list_element = ul;
28
28
 
@@ -0,0 +1,112 @@
1
+ /**
2
+ * The Field Widget class
3
+ *
4
+ * @constructor
5
+ *
6
+ * @author Jelle De Loecker <jelle@elevenways.be>
7
+ * @since 0.1.0
8
+ * @version 0.1.0
9
+ *
10
+ * @param {Object} data
11
+ */
12
+ const AlchemyField = Function.inherits('Alchemy.Widget', 'AlchemyField');
13
+
14
+ /**
15
+ * Prepare the schema
16
+ *
17
+ * @author Jelle De Loecker <jelle@elevenways.be>
18
+ * @since 0.1.0
19
+ * @version 0.1.12
20
+ */
21
+ AlchemyField.constitute(function prepareSchema() {
22
+
23
+ this.setAddChecker(function(widget_element) {
24
+ return false;
25
+ });
26
+ });
27
+
28
+ /**
29
+ * Find the al-form parent
30
+ *
31
+ * @author Jelle De Loecker <jelle@elevenways.be>
32
+ * @since 0.1.4
33
+ * @version 0.2.0
34
+ */
35
+ AlchemyField.enforceProperty(function alchemy_form(new_value) {
36
+
37
+ if (!new_value && this.config && this.config.alchemy_form) {
38
+ new_value = this.config.alchemy_form;
39
+ }
40
+
41
+ if (!new_value) {
42
+
43
+ let parent = this.parent_instance;
44
+
45
+ while (parent) {
46
+
47
+ new_value = parent.alchemy_form;
48
+
49
+ if (new_value) {
50
+ break;
51
+ }
52
+
53
+ if (parent.element) {
54
+ new_value = parent.element.querySelector('al-form');
55
+
56
+ if (new_value) {
57
+ break;
58
+ }
59
+ }
60
+
61
+ parent = parent.parent_instance;
62
+ }
63
+ }
64
+
65
+ return new_value;
66
+ });
67
+
68
+ /**
69
+ * Populate the widget
70
+ *
71
+ * @author Jelle De Loecker <jelle@elevenways.be>
72
+ * @since 0.1.0
73
+ * @version 0.2.0
74
+ */
75
+ AlchemyField.setMethod(function populateWidget() {
76
+
77
+ let config = this.config;
78
+
79
+ let alchemy_form = this.alchemy_form;
80
+
81
+ let field_el = this.createElement('al-field');
82
+
83
+ if (alchemy_form) {
84
+ field_el.alchemy_form = alchemy_form;
85
+ }
86
+
87
+ field_el.field_name = config.field;
88
+
89
+ field_el.applyOptions(config);
90
+
91
+ this.element.append(field_el);
92
+ });
93
+
94
+ /**
95
+ * Get the config of this widget
96
+ *
97
+ * @author Jelle De Loecker <jelle@elevenways.be>
98
+ * @since 0.1.0
99
+ * @version 0.1.0
100
+ *
101
+ * @return {Object}
102
+ */
103
+ AlchemyField.setMethod(function syncConfig() {
104
+
105
+ let config = this.config;
106
+
107
+ if (!config) {
108
+ config = this.config = {};
109
+ }
110
+
111
+ return this.config;
112
+ });