alchemy-form 0.1.12 → 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.
Files changed (88) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/assets/stylesheets/form/alchemy_form.scss +2 -16
  3. package/assets/stylesheets/form/elements/_button.scss +52 -0
  4. package/assets/stylesheets/form/{alchemy_code_input.scss → elements/_code_input.scss} +1 -1
  5. package/assets/stylesheets/form/{alchemy_feedback_input.scss → elements/_feedback_input.scss} +6 -8
  6. package/assets/stylesheets/form/{alchemy_field.scss → elements/_field.scss} +1 -1
  7. package/assets/stylesheets/form/{alchemy_field_array.scss → elements/_field_array.scss} +2 -2
  8. package/assets/stylesheets/form/{alchemy_field_translatable.scss → elements/_field_translatable.scss} +1 -1
  9. package/assets/stylesheets/form/elements/_form.scss +16 -0
  10. package/assets/stylesheets/form/{alchemy_pager.scss → elements/_pager.scss} +1 -1
  11. package/assets/stylesheets/form/{query_builder.scss → elements/_query_builder.scss} +7 -7
  12. package/assets/stylesheets/form/{alchemy_select.scss → elements/_select.scss} +2 -2
  13. package/assets/stylesheets/form/elements/_state.scss +8 -0
  14. package/assets/stylesheets/form/{alchemy_table.scss → elements/_table.scss} +2 -2
  15. package/assets/stylesheets/form/elements/_tabs.scss +47 -0
  16. package/assets/stylesheets/form/{alchemy_toggle.scss → elements/_toggle.scss} +1 -1
  17. package/assets/stylesheets/form/elements/index.scss +14 -0
  18. package/element/00_form_base.js +16 -8
  19. package/element/05_feedback_input.js +4 -13
  20. package/element/10_alchemy_field_custom.js +13 -15
  21. package/element/10_dataprovider.js +282 -0
  22. package/element/15_alchemy_field_entry.js +8 -10
  23. package/element/20_query_builder_base.js +4 -13
  24. package/element/25_query_builder_data.js +2 -2
  25. package/element/30_tab_base.js +29 -0
  26. package/element/40_stateful.js +125 -0
  27. package/element/al_button.js +109 -0
  28. package/element/{code_input.js → al_code_input.js} +1 -10
  29. package/element/{alchemy_field.js → al_field.js} +15 -24
  30. package/element/{alchemy_field_array.js → al_field_array.js} +7 -18
  31. package/element/{alchemy_field_array_entry.js → al_field_array_entry.js} +7 -9
  32. package/element/{alchemy_field_schema.js → al_field_schema.js} +3 -3
  33. package/element/{alchemy_field_translatable.js → al_field_translatable.js} +6 -17
  34. package/element/{alchemy_field_translatable_entry.js → al_field_translatable_entry.js} +2 -4
  35. package/element/{alchemy_form.js → al_form.js} +7 -16
  36. package/element/{alchemy_label.js → al_label.js} +1 -10
  37. package/element/{number_input.js → al_number_input.js} +2 -2
  38. package/element/{alchemy_pager.js → al_pager.js} +49 -41
  39. package/element/{alchemy_password_input.js → al_password_input.js} +0 -0
  40. package/element/{query_builder.js → al_query_builder.js} +3 -12
  41. package/element/{query_builder_entry.js → al_query_builder_entry.js} +2 -2
  42. package/element/{query_builder_group.js → al_query_builder_group.js} +7 -7
  43. package/element/{query_builder_value.js → al_query_builder_value.js} +2 -2
  44. package/element/{query_builder_variable.js → al_query_builder_variable.js} +1 -1
  45. package/element/{alchemy_select.js → al_select.js} +35 -108
  46. package/element/{alchemy_select_item.js → al_select_item.js} +15 -9
  47. package/element/al_state.js +26 -0
  48. package/element/{string_input.js → al_string_input.js} +2 -2
  49. package/element/al_tab_button.js +138 -0
  50. package/element/al_tab_context.js +102 -0
  51. package/element/al_tab_list.js +66 -0
  52. package/element/al_tab_panel.js +44 -0
  53. package/element/{alchemy_table.js → al_table.js} +187 -174
  54. package/element/{alchemy_toggle.js → al_toggle.js} +1 -10
  55. package/helper/form_actions/00_form_action.js +15 -4
  56. package/helper/form_actions/url_action.js +3 -2
  57. package/helper/query_builder_variable_definition/boolean_variable_definition.js +1 -1
  58. package/helper_field/query_builder_field.js +2 -2
  59. package/package.json +2 -2
  60. package/view/form/elements/alchemy_button.hwk +1 -0
  61. package/view/form/elements/alchemy_field.hwk +4 -4
  62. package/view/form/elements/alchemy_field_array.hwk +2 -2
  63. package/view/form/elements/alchemy_field_schema.hwk +2 -2
  64. package/view/form/elements/alchemy_field_translatable.hwk +2 -2
  65. package/view/form/elements/alchemy_field_translatable_entry.hwk +2 -2
  66. package/view/form/elements/query_builder.hwk +1 -1
  67. package/view/form/elements/query_builder_entry.hwk +6 -6
  68. package/view/form/elements/query_builder_value.hwk +2 -2
  69. package/view/form/elements/query_builder_variable.hwk +2 -2
  70. package/view/form/inputs/edit/belongs_to.hwk +2 -2
  71. package/view/form/inputs/edit/boolean.hwk +2 -2
  72. package/view/form/inputs/edit/enum.hwk +2 -2
  73. package/view/form/inputs/edit/has_and_belongs_to_many.hwk +2 -2
  74. package/view/form/inputs/edit/html.hwk +2 -2
  75. package/view/form/inputs/edit/query_builder.hwk +2 -2
  76. package/view/form/inputs/edit/query_builder_assignment.hwk +2 -2
  77. package/view/form/inputs/edit/query_builder_value.hwk +2 -2
  78. package/view/form/inputs/edit/query_builder_variable.hwk +2 -2
  79. package/view/form/inputs/edit/schema.hwk +2 -2
  80. package/view/form/inputs/edit/sourcecode.hwk +2 -2
  81. package/view/form/inputs/edit_inline/boolean.hwk +2 -2
  82. package/view/form/inputs/view/string.hwk +6 -1
  83. package/view/form/inputs/view_inline/datetime.hwk +8 -4
  84. package/view/form/inputs/view_inline/string.hwk +6 -1
  85. package/view/form/wrappers/default/default.hwk +2 -2
  86. package/helper/widgets/alchemy_field_widget.js +0 -112
  87. package/helper/widgets/alchemy_form_widget.js +0 -183
  88. package/helper/widgets/alchemy_table_widget.js +0 -67
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.2.0 (2022-11-02)
2
+
3
+ * Use the `al-` prefix for all custom elements instead of nothing or `alchemy-`
4
+ * Add tab-elements & widget
5
+ * Add abstract `WithDataprovider` class and make `al-table` and `al-select` use it
6
+ * Allow `al-table` to reuse existing rows and prevent render flashes
7
+ * Add `al-state` and the abstract `Stateful` class for elements with states
8
+ * Add `al-button` element
9
+ * Allow adding a suffix option to certain fields
10
+ * Allow using `al-table` pager without a url
11
+ * Move widgets to `alchemy-widgets` plugin, because that depends on `alchemy-form`
12
+
1
13
  ## 0.1.12 (2022-10-12)
2
14
 
3
15
  * Don't let users manually add form widgets
@@ -1,16 +1,2 @@
1
- alchemy-form {
2
- .error-area:empty {
3
- display: none;
4
- }
5
-
6
- .error-area:not(:empty) {
7
- border: 1px solid #a80000;
8
- color: #a80000;
9
- padding: 0.2rem;
10
- }
11
- }
12
-
13
- alchemy-label {
14
- display: block;
15
- cursor: default;
16
- }
1
+ @import "./general/index.scss";
2
+ @import "./elements/index.scss";
@@ -0,0 +1,52 @@
1
+ :root {
2
+ --al-button-font-size: 1em;
3
+ --al-button-font-weight: 400;
4
+ --al-button-bg-color: rgb(89, 105, 225);
5
+ --al-button-bg-color-hover: rgb(105, 118, 218);
6
+ --al-button-text-color: white;
7
+ }
8
+
9
+ al-button {
10
+ display: inline-block;
11
+ font-size: var(--al-button-font-size);
12
+ font-weight: var(--al-button-font-weight);
13
+ background-color: var(--al-button-bg-color);
14
+ color: var(--al-button-text-color);
15
+ cursor: pointer;
16
+ user-select: none;
17
+
18
+ position: relative;
19
+ padding: 0.5em 1em;
20
+ text-align: center;
21
+ text-decoration: none;
22
+ vertical-align: bottom;
23
+ transition: 0.1s;
24
+ overflow: hidden;
25
+ line-height: 1.5;
26
+
27
+ al-icon,
28
+ .icon {
29
+ line-height: 1 !important;
30
+ }
31
+
32
+ .apb-content {
33
+ display: flex;
34
+ gap: 0.5em;
35
+ height: 100%;
36
+
37
+ > * {
38
+ flex: auto;
39
+ align-self: center;
40
+ }
41
+ }
42
+
43
+ &[disabled] {
44
+ pointer-events: none;
45
+ filter: saturate(0.5);
46
+ cursor: not-allowed;
47
+ }
48
+
49
+ &:hover {
50
+ background-color: var(--al-button-bg-color-hover);
51
+ }
52
+ }
@@ -1,4 +1,4 @@
1
- alchemy-code-input {
1
+ al-code-input {
2
2
  display: inline-block;
3
3
  height: 30rem;
4
4
  width: 100%;
@@ -1,5 +1,3 @@
1
- @import "./general/index.scss";
2
-
3
1
  .textareabox,
4
2
  .inputbox {
5
3
  $inputbox: &;
@@ -43,14 +41,14 @@
43
41
  }
44
42
 
45
43
  .inputfield,
46
- alchemy-string-input {
44
+ al-string-input {
47
45
  $inputfield: &;
48
46
  position: relative;
49
47
  display: flex;
50
48
  flex-direction: column;
51
49
  margin: 0;
52
50
 
53
- & +.rest-fields > string-input:first-of-type {
51
+ & +.rest-fields > al-string-input:first-of-type {
54
52
  margin-top: 3rem;
55
53
  }
56
54
 
@@ -175,7 +173,7 @@ alchemy-string-input {
175
173
  }
176
174
  }
177
175
 
178
- alchemy-string-input {
176
+ al-string-input {
179
177
  .inputlabel {
180
178
  .label {
181
179
  margin-bottom: 0 !important;
@@ -183,8 +181,8 @@ alchemy-string-input {
183
181
  }
184
182
  }
185
183
 
186
- alchemy-password-input {
187
- @extend alchemy-string-input;
184
+ al-password-input {
185
+ @extend al-string-input;
188
186
 
189
187
  & > label:first-of-type {
190
188
  margin-bottom: 2rem;
@@ -253,7 +251,7 @@ alchemy-password-input {
253
251
  }
254
252
  }
255
253
 
256
- alchemy-number-input {
254
+ al-number-input {
257
255
  $numberinput: &;
258
256
  display: flex;
259
257
  flex-flow: column wrap;
@@ -1,4 +1,4 @@
1
- alchemy-field {
1
+ al-field {
2
2
  display: block;
3
3
 
4
4
  &[field-type="boolean"] {
@@ -1,8 +1,8 @@
1
- alchemy-field-array {
1
+ al-field-array {
2
2
  display: block;
3
3
  }
4
4
 
5
- alchemy-field-array-entry {
5
+ al-field-array-entry {
6
6
  display: flex;
7
7
 
8
8
  > .button {
@@ -1,4 +1,4 @@
1
- alchemy-field-translatable {
1
+ al-field-translatable {
2
2
  display: block;
3
3
  position: relative;
4
4
 
@@ -0,0 +1,16 @@
1
+ al-form {
2
+ .error-area:empty {
3
+ display: none;
4
+ }
5
+
6
+ .error-area:not(:empty) {
7
+ border: 1px solid #a80000;
8
+ color: #a80000;
9
+ padding: 0.2rem;
10
+ }
11
+ }
12
+
13
+ al-label {
14
+ display: block;
15
+ cursor: default;
16
+ }
@@ -1,4 +1,4 @@
1
- alchemy-pager {
1
+ al-pager {
2
2
  display: flex;
3
3
 
4
4
  ul {
@@ -12,14 +12,14 @@
12
12
  --qb-btn-border-color: #d3d3d3;
13
13
  }
14
14
 
15
- alchemy-query-builder {
15
+ al-query-builder {
16
16
  display: block;
17
17
  border-color: var(--qb-border-color);
18
18
  padding: 1rem;
19
19
  position: relative;
20
20
  }
21
21
 
22
- alchemy-query-builder-group {
22
+ al-query-builder-group {
23
23
  display: block;
24
24
  padding: 10px;
25
25
  padding-bottom: 6px;
@@ -85,20 +85,20 @@ alchemy-query-builder-group {
85
85
  }
86
86
  }
87
87
 
88
- alchemy-query-builder-value {
88
+ al-query-builder-value {
89
89
  min-width: 10rem;
90
90
  }
91
91
 
92
- alchemy-query-builder-entry {
92
+ al-query-builder-entry {
93
93
  min-width: 40rem;
94
94
  }
95
95
 
96
- alchemy-query-builder-value,
97
- alchemy-query-builder-entry {
96
+ al-query-builder-value,
97
+ al-query-builder-entry {
98
98
  display: flex;
99
99
  gap: 0.7rem;
100
100
 
101
- alchemy-select {
101
+ al-select {
102
102
  min-width: 11rem;
103
103
  }
104
104
 
@@ -1,4 +1,4 @@
1
- alchemy-select {
1
+ al-select {
2
2
  box-sizing: border-box;
3
3
  position: relative;
4
4
  display: block;
@@ -195,7 +195,7 @@ alchemy-select {
195
195
  }
196
196
 
197
197
  &[multiple] .value-wrapper {
198
- alchemy-select-item {
198
+ al-select-item {
199
199
  display: inline-block;
200
200
 
201
201
  text-shadow: 0 1px 0 rgba(0,51,83,0.3);
@@ -0,0 +1,8 @@
1
+ al-state {
2
+ display: block;
3
+
4
+ // Inactive states should always be hidden
5
+ &:not([active]) {
6
+ display: none !important;
7
+ }
8
+ }
@@ -1,4 +1,4 @@
1
- alchemy-table {
1
+ al-table {
2
2
  display: flex;
3
3
  flex-flow: column;
4
4
  border: 1px solid #dadee0;
@@ -21,7 +21,7 @@ alchemy-table {
21
21
  font-weight: 500;
22
22
  font-size: 0.9rem;
23
23
 
24
- al-ico {
24
+ al-icon {
25
25
  margin-left: 1rem;
26
26
  }
27
27
 
@@ -0,0 +1,47 @@
1
+ al-tab-list {
2
+ display: flex;
3
+ gap: 0.75rem;
4
+ }
5
+
6
+ al-tab-button {
7
+ font-size: 1.1rem;
8
+ border: none;
9
+ display: table-cell;
10
+ text-align: center;
11
+ vertical-align: middle;
12
+ overflow: hidden;
13
+ cursor: pointer;
14
+ padding: 0.5rem 1rem;
15
+ border-radius: 5px 5px 0 0;
16
+ border: 1px solid var(--alchemy-tab-button-border, gray);
17
+ border-bottom: 1px solid transparent;
18
+ z-index: 1;
19
+ background: var(--alchemy-tab-button-background, white);
20
+ user-select: none;
21
+
22
+ al-icon {
23
+ margin-right: 0.5rem;
24
+ }
25
+
26
+ &[active] {
27
+ font-weight: bold;
28
+ z-index: 3;
29
+ border-bottom: 1px solid var(--alchemy-tab-panel-background, white);
30
+ }
31
+ }
32
+
33
+ al-tab-panel {
34
+ display: block;
35
+ position: relative;
36
+
37
+ padding: 0.7rem;
38
+ border: 1px solid var(--alchemy-tab-panel-border, gray);
39
+ border-radius: 0 0 5px 5px;
40
+ background: var(--alchemy-tab-panel-background, white);
41
+ z-index: 2;
42
+ margin-top: -1px;
43
+
44
+ &:not([active]) {
45
+ display: none !important;
46
+ }
47
+ }
@@ -1,4 +1,4 @@
1
- alchemy-toggle {
1
+ al-toggle {
2
2
  display: flex;
3
3
  position: relative;
4
4
  align-items: center;
@@ -0,0 +1,14 @@
1
+ @import "_button.scss";
2
+ @import "_code_input.scss";
3
+ @import "_feedback_input.scss";
4
+ @import "_field.scss";
5
+ @import "_field_array.scss";
6
+ @import "_field_translatable.scss";
7
+ @import "_form.scss";
8
+ @import "_pager.scss";
9
+ @import "_query_builder.scss";
10
+ @import "_select.scss";
11
+ @import "_state.scss";
12
+ @import "_table.scss";
13
+ @import "_toggle.scss";
14
+ @import "_tabs.scss";
@@ -1,30 +1,38 @@
1
1
  /**
2
- * The base class for all other alchemy-form elements
2
+ * The base class for all other al-form elements
3
3
  *
4
4
  * @author Jelle De Loecker <jelle@elevenways.be>
5
5
  * @since 0.1.0
6
6
  * @version 0.1.0
7
7
  */
8
- var Base = Function.inherits('Alchemy.Element', 'Alchemy.Element.Form', 'Base');
8
+ const Base = Function.inherits('Alchemy.Element', 'Alchemy.Element.Form', 'Base');
9
9
 
10
10
  /**
11
11
  * Set the custom element prefix
12
12
  *
13
13
  * @author Jelle De Loecker <jelle@elevenways.be>
14
14
  * @since 0.1.0
15
- * @version 0.1.0
15
+ * @version 0.2.0
16
16
  */
17
- Base.setStatic('custom_element_prefix', 'alchemy');
17
+ Base.setStatic('custom_element_prefix', 'al');
18
18
 
19
19
  /**
20
- * Don't register this as a custom element,
21
- * but don't let child classes inherit this
20
+ * This is a static class (so it won't be registered)
22
21
  *
23
22
  * @author Jelle De Loecker <jelle@elevenways.be>
24
23
  * @since 0.1.0
25
- * @version 0.1.0
24
+ * @version 0.2.0
25
+ */
26
+ Base.makeAbstractClass();
27
+
28
+ /**
29
+ * The stylesheet to load for this element
30
+ *
31
+ * @author Jelle De Loecker <jelle@elevenways.be>
32
+ * @since 0.2.0
33
+ * @version 0.2.0
26
34
  */
27
- Base.setStatic('is_abstract_class', true, false);
35
+ Base.setStylesheetFile('form/alchemy_form');
28
36
 
29
37
  /**
30
38
  * Add a getter that looks for a parent of a specific type
@@ -14,18 +14,9 @@ var FeedbackInput = Function.inherits('Alchemy.Element.Form.Base', 'FeedbackInpu
14
14
  *
15
15
  * @author Jelle De Loecker <jelle@elevenways.be>
16
16
  * @since 0.1.0
17
- * @version 0.1.0
17
+ * @version 0.2.0
18
18
  */
19
- FeedbackInput.setStatic('is_abstract_class', true, false);
20
-
21
- /**
22
- * The stylesheet to load for this element
23
- *
24
- * @author Jelle De Loecker <jelle@elevenways.be>
25
- * @since 0.1.3
26
- * @version 0.1.3
27
- */
28
- FeedbackInput.setStylesheetFile('form/alchemy_feedback_input');
19
+ FeedbackInput.makeAbstractClass();
29
20
 
30
21
  /**
31
22
  * The readonly attribute
@@ -170,7 +161,7 @@ FeedbackInput.setMethod(function removeErrors() {
170
161
  *
171
162
  * @author Jelle De Loecker <jelle@elevenways.be>
172
163
  * @since 0.1.3
173
- * @version 0.1.3
164
+ * @version 0.2.0
174
165
  *
175
166
  * @return {<micro-copy>|String}
176
167
  */
@@ -187,7 +178,7 @@ FeedbackInput.setMethod(function convertMessage(message, parameters) {
187
178
  return message;
188
179
  }
189
180
 
190
- microcopy = this.createElement('micro-copy');
181
+ microcopy = this.createElement('al-microcopy');
191
182
  microcopy.key = message.after('microcopy:');
192
183
 
193
184
  if (!parameters) {
@@ -1,13 +1,11 @@
1
1
  /**
2
- * The basis for alchemy-field-array and such element
2
+ * The basis for al-field-array and such element
3
3
  *
4
4
  * @author Jelle De Loecker <jelle@elevenways.be>
5
5
  * @since 0.1.0
6
6
  * @version 0.1.0
7
7
  */
8
- var FieldCustom = Function.inherits('Alchemy.Element.Form.Base', function FieldCustom() {
9
- FieldCustom.super.call(this);
10
- });
8
+ const FieldCustom = Function.inherits('Alchemy.Element.Form.Base', 'FieldCustom');
11
9
 
12
10
  /**
13
11
  * Don't register this as a custom element,
@@ -15,38 +13,38 @@ var FieldCustom = Function.inherits('Alchemy.Element.Form.Base', function FieldC
15
13
  *
16
14
  * @author Jelle De Loecker <jelle@elevenways.be>
17
15
  * @since 0.1.0
18
- * @version 0.1.0
16
+ * @version 0.2.0
19
17
  */
20
- FieldCustom.setStatic('is_abstract_class', true, false);
18
+ FieldCustom.makeAbstractClass();
21
19
 
22
20
  /**
23
- * Get a reference to the alchemy-field parent
21
+ * Get a reference to the al-field parent
24
22
  *
25
23
  * @author Jelle De Loecker <jelle@elevenways.be>
26
24
  * @since 0.1.0
27
- * @version 0.1.0
25
+ * @version 0.2.0
28
26
  */
29
27
  FieldCustom.enforceProperty(function alchemy_field(new_value, old_value) {
30
28
 
31
29
  if (!new_value) {
32
- new_value = this.queryUp('alchemy-field');
30
+ new_value = this.queryUp('al-field');
33
31
  }
34
32
 
35
33
  return new_value;
36
34
  });
37
35
 
38
36
  /**
39
- * Get a reference to the alchemy-field or alchemy-field-translatable parent
37
+ * Get a reference to the al-field or al-field-translatable parent
40
38
  *
41
39
  * @author Jelle De Loecker <jelle@elevenways.be>
42
40
  * @since 0.1.0
43
- * @version 0.1.0
41
+ * @version 0.2.0
44
42
  */
45
43
  FieldCustom.enforceProperty(function field_context(new_value, old_value) {
46
44
 
47
45
  if (!new_value) {
48
- let translatable = this.queryUp('alchemy-field-translatable-entry'),
49
- field = this.queryUp('alchemy-field');
46
+ let translatable = this.queryUp('al-field-translatable-entry'),
47
+ field = this.queryUp('al-field');
50
48
 
51
49
  if (translatable && translatable != this && field.contains(translatable)) {
52
50
  new_value = translatable;
@@ -67,11 +65,11 @@ FieldCustom.enforceProperty(function field_context(new_value, old_value) {
67
65
  *
68
66
  * @author Jelle De Loecker <jelle@elevenways.be>
69
67
  * @since 0.1.0
70
- * @version 0.1.0
68
+ * @version 0.2.0
71
69
  */
72
70
  FieldCustom.setProperty(function is_array() {
73
71
 
74
- let field = this.queryUp('alchemy-field');
72
+ let field = this.queryUp('al-field');
75
73
 
76
74
  if (field) {
77
75
  return field.is_array;