alchemy-form 0.1.11 → 0.2.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.
- package/CHANGELOG.md +29 -0
- package/assets/stylesheets/form/alchemy_form.scss +2 -16
- package/assets/stylesheets/form/elements/_button.scss +52 -0
- package/assets/stylesheets/form/{alchemy_code_input.scss → elements/_code_input.scss} +1 -1
- package/assets/stylesheets/form/{alchemy_feedback_input.scss → elements/_feedback_input.scss} +6 -8
- package/assets/stylesheets/form/{alchemy_field.scss → elements/_field.scss} +1 -1
- package/assets/stylesheets/form/{alchemy_field_array.scss → elements/_field_array.scss} +2 -2
- package/assets/stylesheets/form/{alchemy_field_translatable.scss → elements/_field_translatable.scss} +1 -1
- package/assets/stylesheets/form/elements/_form.scss +16 -0
- package/assets/stylesheets/form/{alchemy_pager.scss → elements/_pager.scss} +1 -1
- package/assets/stylesheets/form/{query_builder.scss → elements/_query_builder.scss} +7 -7
- package/assets/stylesheets/form/{alchemy_select.scss → elements/_select.scss} +2 -2
- package/assets/stylesheets/form/elements/_state.scss +8 -0
- package/assets/stylesheets/form/{alchemy_table.scss → elements/_table.scss} +2 -2
- package/assets/stylesheets/form/elements/_tabs.scss +47 -0
- package/assets/stylesheets/form/{alchemy_toggle.scss → elements/_toggle.scss} +1 -1
- package/assets/stylesheets/form/elements/index.scss +14 -0
- package/controller/form_api_controller.js +0 -1
- package/element/00_form_base.js +16 -8
- package/element/05_feedback_input.js +4 -13
- package/element/10_alchemy_field_custom.js +13 -15
- package/element/10_dataprovider.js +282 -0
- package/element/15_alchemy_field_entry.js +8 -10
- package/element/20_query_builder_base.js +4 -13
- package/element/25_query_builder_data.js +2 -2
- package/element/30_tab_base.js +29 -0
- package/element/40_stateful.js +125 -0
- package/element/al_button.js +109 -0
- package/element/{code_input.js → al_code_input.js} +1 -10
- package/element/{alchemy_field.js → al_field.js} +82 -41
- package/element/{alchemy_field_array.js → al_field_array.js} +7 -18
- package/element/{alchemy_field_array_entry.js → al_field_array_entry.js} +7 -9
- package/element/{alchemy_field_schema.js → al_field_schema.js} +23 -11
- package/element/{alchemy_field_translatable.js → al_field_translatable.js} +6 -17
- package/element/{alchemy_field_translatable_entry.js → al_field_translatable_entry.js} +2 -4
- package/element/{alchemy_form.js → al_form.js} +7 -16
- package/element/{alchemy_label.js → al_label.js} +1 -10
- package/element/{number_input.js → al_number_input.js} +2 -2
- package/element/{alchemy_pager.js → al_pager.js} +49 -41
- package/element/{alchemy_password_input.js → al_password_input.js} +0 -0
- package/element/{query_builder.js → al_query_builder.js} +3 -12
- package/element/{query_builder_entry.js → al_query_builder_entry.js} +8 -7
- package/element/{query_builder_group.js → al_query_builder_group.js} +7 -7
- package/element/{query_builder_value.js → al_query_builder_value.js} +2 -2
- package/element/{query_builder_variable.js → al_query_builder_variable.js} +1 -1
- package/element/{alchemy_select.js → al_select.js} +35 -108
- package/element/{alchemy_select_item.js → al_select_item.js} +33 -13
- package/element/al_state.js +26 -0
- package/element/{string_input.js → al_string_input.js} +2 -2
- package/element/al_tab_button.js +138 -0
- package/element/al_tab_context.js +102 -0
- package/element/al_tab_list.js +66 -0
- package/element/al_tab_panel.js +44 -0
- package/element/{alchemy_table.js → al_table.js} +204 -185
- package/element/{alchemy_toggle.js → al_toggle.js} +1 -10
- package/helper/form_actions/00_form_action.js +15 -4
- package/helper/form_actions/url_action.js +3 -2
- package/helper/query_builder_ns.js +108 -0
- package/helper/query_builder_variable_definition/00_variable_definition.js +52 -1
- package/helper/query_builder_variable_definition/boolean_variable_definition.js +1 -1
- package/helper_field/query_builder_field.js +49 -28
- package/helper_field/query_builder_value.js +0 -45
- package/helper_field/query_builder_variable.js +0 -45
- package/package.json +2 -2
- package/view/form/elements/alchemy_button.hwk +1 -0
- package/view/form/elements/alchemy_field.hwk +4 -4
- package/view/form/elements/alchemy_field_array.hwk +2 -2
- package/view/form/elements/alchemy_field_schema.hwk +2 -2
- package/view/form/elements/alchemy_field_translatable.hwk +2 -2
- package/view/form/elements/alchemy_field_translatable_entry.hwk +2 -2
- package/view/form/elements/alchemy_select_item.hwk +1 -3
- package/view/form/elements/query_builder.hwk +1 -1
- package/view/form/elements/query_builder_entry.hwk +6 -6
- package/view/form/elements/query_builder_value.hwk +2 -2
- package/view/form/elements/query_builder_variable.hwk +2 -2
- package/view/form/inputs/edit/belongs_to.hwk +2 -2
- package/view/form/inputs/edit/boolean.hwk +2 -2
- package/view/form/inputs/edit/enum.hwk +2 -2
- package/view/form/inputs/edit/has_and_belongs_to_many.hwk +2 -2
- package/view/form/inputs/edit/html.hwk +2 -2
- package/view/form/inputs/edit/query_builder.hwk +2 -2
- package/view/form/inputs/edit/query_builder_assignment.hwk +2 -2
- package/view/form/inputs/edit/query_builder_value.hwk +2 -2
- package/view/form/inputs/edit/query_builder_variable.hwk +2 -2
- package/view/form/inputs/edit/schema.hwk +2 -2
- package/view/form/inputs/edit/sourcecode.hwk +2 -2
- package/view/form/inputs/edit_inline/boolean.hwk +2 -2
- package/view/form/inputs/view/string.hwk +6 -1
- package/view/form/inputs/view_inline/datetime.hwk +8 -4
- package/view/form/inputs/view_inline/enum.hwk +1 -0
- package/view/form/inputs/view_inline/string.hwk +6 -1
- package/view/form/select/qb_item.hwk +1 -0
- package/view/form/wrappers/default/default.hwk +2 -2
- package/helper/widgets/alchemy_field_widget.js +0 -137
- package/helper/widgets/alchemy_form_widget.js +0 -169
- package/helper/widgets/alchemy_table_widget.js +0 -53
- package/view/form/inputs/view_inline/file.hwk +0 -6
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The al-state element
|
|
3
|
+
*
|
|
4
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
|
+
* @since 0.2.0
|
|
6
|
+
* @version 0.2.0
|
|
7
|
+
*/
|
|
8
|
+
const State = Function.inherits('Alchemy.Element.Form.Stateful', 'State');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The name of the state this element represents
|
|
12
|
+
*
|
|
13
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
14
|
+
* @since 0.2.0
|
|
15
|
+
* @version 0.2.0
|
|
16
|
+
*/
|
|
17
|
+
State.setAttribute('state-name');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Is this state active?
|
|
21
|
+
*
|
|
22
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
23
|
+
* @since 0.2.0
|
|
24
|
+
* @version 0.2.0
|
|
25
|
+
*/
|
|
26
|
+
State.setAttribute('active', {boolean: true});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
2
|
+
* The al-string-input custom element
|
|
3
3
|
*
|
|
4
4
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
5
|
* @since 0.1.0
|
|
@@ -306,7 +306,7 @@ StringInput.setMethod(async function revalidate(trigger, force) {
|
|
|
306
306
|
* @since 0.1.3
|
|
307
307
|
* @version 0.1.3
|
|
308
308
|
*/
|
|
309
|
-
|
|
309
|
+
StringInput.setMethod(function introduced() {
|
|
310
310
|
|
|
311
311
|
const that = this,
|
|
312
312
|
input = this.input_el;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The al-tab-button element
|
|
3
|
+
*
|
|
4
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
|
+
* @since 0.2.0
|
|
6
|
+
* @version 0.2.0
|
|
7
|
+
*/
|
|
8
|
+
const TabButton = Function.inherits('Alchemy.Element.Form.TabBase', 'TabButton');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Set the ARIA role of the element
|
|
12
|
+
*
|
|
13
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
14
|
+
* @since 0.2.0
|
|
15
|
+
* @version 0.2.0
|
|
16
|
+
*/
|
|
17
|
+
TabButton.setRole('tab');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Only the active tab should be tabable
|
|
21
|
+
*
|
|
22
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
23
|
+
* @since 0.2.0
|
|
24
|
+
* @version 0.2.0
|
|
25
|
+
*/
|
|
26
|
+
TabButton.setAttribute('tabindex', {default: -1});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The name of the tab
|
|
30
|
+
*
|
|
31
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
32
|
+
* @since 0.2.0
|
|
33
|
+
* @version 0.2.0
|
|
34
|
+
*/
|
|
35
|
+
TabButton.setAttribute('tab-name');
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Is this tab active?
|
|
39
|
+
*
|
|
40
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
41
|
+
* @since 0.2.0
|
|
42
|
+
* @version 0.2.0
|
|
43
|
+
*/
|
|
44
|
+
TabButton.setAttribute('active', null, function setActive(value) {
|
|
45
|
+
|
|
46
|
+
if (value != null) {
|
|
47
|
+
this.activate(value);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return value;
|
|
51
|
+
}, {boolean: true});
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get the corresponding tab content element
|
|
55
|
+
*
|
|
56
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
57
|
+
* @since 0.2.0
|
|
58
|
+
* @version 0.2.0
|
|
59
|
+
*/
|
|
60
|
+
TabButton.setMethod(function getContentElement() {
|
|
61
|
+
|
|
62
|
+
const tab_name = this.dataset.tabName;
|
|
63
|
+
|
|
64
|
+
if (!tab_name) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let context = this.tab_context;
|
|
69
|
+
|
|
70
|
+
if (!context) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return context.querySelector('al-tab-content[tab-name="' + tab_name + '"]');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Activate this tab
|
|
79
|
+
*
|
|
80
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
81
|
+
* @since 0.2.0
|
|
82
|
+
* @version 0.2.0
|
|
83
|
+
*/
|
|
84
|
+
TabButton.setMethod(function activate(value) {
|
|
85
|
+
|
|
86
|
+
let context = this.tab_context;
|
|
87
|
+
|
|
88
|
+
if (!context) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (value == null) {
|
|
93
|
+
value = true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let all_buttons = context.getAllTabButtons(),
|
|
97
|
+
all_contents = context.getAllTabContents();
|
|
98
|
+
|
|
99
|
+
this.setAttributeSilent('active', value);
|
|
100
|
+
|
|
101
|
+
// If this tab is activated, others have to be deactivated
|
|
102
|
+
if (value) {
|
|
103
|
+
for (let button of all_buttons) {
|
|
104
|
+
if (button != this && button.active) {
|
|
105
|
+
button.active = false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
this.setAttribute('aria-selected', true);
|
|
110
|
+
this.setAttribute('tabindex', 0);
|
|
111
|
+
} else {
|
|
112
|
+
this.removeAttribute('aria-selected');
|
|
113
|
+
this.setAttribute('tabindex', -1);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
for (let content of all_contents) {
|
|
117
|
+
if (content.tab_name == this.tab_name) {
|
|
118
|
+
content.active = value;
|
|
119
|
+
} else if (value) {
|
|
120
|
+
content.active = false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Added to the DOM for the first time
|
|
128
|
+
*
|
|
129
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
130
|
+
* @since 0.2.0
|
|
131
|
+
* @version 0.2.0
|
|
132
|
+
*/
|
|
133
|
+
TabButton.setMethod(function introduced() {
|
|
134
|
+
|
|
135
|
+
this.addEventListener('click', e => {
|
|
136
|
+
this.activate();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The al-tab-context element
|
|
3
|
+
*
|
|
4
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
|
+
* @since 0.2.0
|
|
6
|
+
* @version 0.2.0
|
|
7
|
+
*/
|
|
8
|
+
const TabContext = Function.inherits('Alchemy.Element.Form.TabBase', 'TabContext');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The "value", or active tab
|
|
12
|
+
*
|
|
13
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
14
|
+
* @since 0.2.0
|
|
15
|
+
* @version 0.2.0
|
|
16
|
+
*
|
|
17
|
+
* @return {AlchemyTabButton[]}
|
|
18
|
+
*/
|
|
19
|
+
TabContext.setAttribute('value', function getValue(value) {
|
|
20
|
+
|
|
21
|
+
let all_buttons = this.getAllTabButtons();
|
|
22
|
+
|
|
23
|
+
if (all_buttons.length) {
|
|
24
|
+
value = '';
|
|
25
|
+
|
|
26
|
+
for (let entry of all_buttons) {
|
|
27
|
+
if (entry.active) {
|
|
28
|
+
value = entry.tab_name;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return value;
|
|
35
|
+
|
|
36
|
+
}, function setValue(value) {
|
|
37
|
+
|
|
38
|
+
let all_buttons = this.getAllTabButtons(),
|
|
39
|
+
activated = false;
|
|
40
|
+
|
|
41
|
+
if (all_buttons.length) {
|
|
42
|
+
for (let entry of all_buttons) {
|
|
43
|
+
if (entry.tab_name == value) {
|
|
44
|
+
entry.active = true;
|
|
45
|
+
activated = true;
|
|
46
|
+
} else {
|
|
47
|
+
entry.active = false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// If nothing was activated, activate the first one
|
|
52
|
+
if (!activated) {
|
|
53
|
+
all_buttons[0].active = true;
|
|
54
|
+
value = all_buttons[0].tab_name;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return value;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Do something when this element is retained
|
|
63
|
+
*
|
|
64
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
65
|
+
* @since 0.2.0
|
|
66
|
+
* @version 0.2.0
|
|
67
|
+
*/
|
|
68
|
+
TabContext.setMethod(function retained() {
|
|
69
|
+
|
|
70
|
+
let value = this.value;
|
|
71
|
+
|
|
72
|
+
if (!value) {
|
|
73
|
+
// Trigger setValue, which will select the first tab
|
|
74
|
+
this.value = '';
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get all the tab buttons
|
|
80
|
+
*
|
|
81
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
82
|
+
* @since 0.2.0
|
|
83
|
+
* @version 0.2.0
|
|
84
|
+
*
|
|
85
|
+
* @return {AlchemyTabButton[]}
|
|
86
|
+
*/
|
|
87
|
+
TabContext.setMethod(function getAllTabButtons() {
|
|
88
|
+
return this.queryAllNotNested('al-tab-button');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Get all the tab contents
|
|
93
|
+
*
|
|
94
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
95
|
+
* @since 0.2.0
|
|
96
|
+
* @version 0.2.0
|
|
97
|
+
*
|
|
98
|
+
* @return {AlchemyTabButton[]}
|
|
99
|
+
*/
|
|
100
|
+
TabContext.setMethod(function getAllTabContents() {
|
|
101
|
+
return this.queryAllNotNested('al-tab-panel');
|
|
102
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The al-tab-list element
|
|
3
|
+
*
|
|
4
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
|
+
* @since 0.2.0
|
|
6
|
+
* @version 0.2.0
|
|
7
|
+
*/
|
|
8
|
+
const TabList = Function.inherits('Alchemy.Element.Form.TabBase', 'TabList');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Set the ARIA role of the element
|
|
12
|
+
*
|
|
13
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
14
|
+
* @since 0.2.0
|
|
15
|
+
* @version 0.2.0
|
|
16
|
+
*/
|
|
17
|
+
TabList.setRole('tablist');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Move the current selection
|
|
21
|
+
*
|
|
22
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
23
|
+
* @since 0.2.0
|
|
24
|
+
* @version 0.2.0
|
|
25
|
+
*
|
|
26
|
+
* @param {Number} direction
|
|
27
|
+
*/
|
|
28
|
+
TabList.setMethod(function moveSelection(direction) {
|
|
29
|
+
|
|
30
|
+
let active_tab = this.querySelector('al-tab-button[active]'),
|
|
31
|
+
all_tabs = Array.cast(this.querySelectorAll('al-tab-button')),
|
|
32
|
+
index = all_tabs.indexOf(active_tab);
|
|
33
|
+
|
|
34
|
+
index += direction;
|
|
35
|
+
|
|
36
|
+
let new_tab = all_tabs.atLoop(index);
|
|
37
|
+
|
|
38
|
+
if (new_tab) {
|
|
39
|
+
new_tab.active = true;
|
|
40
|
+
new_tab.focus();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Added to the DOM for the first time
|
|
46
|
+
*
|
|
47
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
48
|
+
* @since 0.2.0
|
|
49
|
+
* @version 0.2.0
|
|
50
|
+
*/
|
|
51
|
+
TabList.setMethod(function introduced() {
|
|
52
|
+
|
|
53
|
+
// Arrows are only detected on keydown
|
|
54
|
+
this.addEventListener('keydown', e => {
|
|
55
|
+
|
|
56
|
+
let direction = 0;
|
|
57
|
+
|
|
58
|
+
if (e.key == 'ArrowLeft') {
|
|
59
|
+
direction = -1;
|
|
60
|
+
} else if (e.key == 'ArrowRight') {
|
|
61
|
+
direction = 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.moveSelection(direction);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The al-tab-content element
|
|
3
|
+
*
|
|
4
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
|
+
* @since 0.2.0
|
|
6
|
+
* @version 0.2.0
|
|
7
|
+
*/
|
|
8
|
+
const TabPanel = Function.inherits('Alchemy.Element.Form.TabBase', 'TabPanel');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Set the ARIA role of the element
|
|
12
|
+
*
|
|
13
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
14
|
+
* @since 0.2.0
|
|
15
|
+
* @version 0.2.0
|
|
16
|
+
*/
|
|
17
|
+
TabPanel.setRole('tabpanel');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Make it tabable by default
|
|
21
|
+
*
|
|
22
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
23
|
+
* @since 0.2.0
|
|
24
|
+
* @version 0.2.0
|
|
25
|
+
*/
|
|
26
|
+
TabPanel.setAttribute('tabindex', {default: 0});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The name of the tab
|
|
30
|
+
*
|
|
31
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
32
|
+
* @since 0.2.0
|
|
33
|
+
* @version 0.2.0
|
|
34
|
+
*/
|
|
35
|
+
TabPanel.setAttribute('tab-name');
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Is this tab active?
|
|
39
|
+
*
|
|
40
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
41
|
+
* @since 0.2.0
|
|
42
|
+
* @version 0.2.0
|
|
43
|
+
*/
|
|
44
|
+
TabPanel.setAttribute('active', {boolean: true});
|