@schukai/monster 3.64.0 → 3.65.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 +32 -0
- package/example/components/form/button.mjs +1 -1
- package/example/components/form/field-set.mjs +4 -0
- package/example/components/form/select.mjs +1 -1
- package/package.json +2 -1
- package/source/components/datatable/datatable/header.mjs +228 -221
- package/source/components/datatable/style/dataset.pcss +1 -0
- package/source/components/datatable/style/datatable.pcss +1 -0
- package/source/components/datatable/stylesheet/change-button.mjs +8 -4
- package/source/components/datatable/stylesheet/column-bar.mjs +8 -4
- package/source/components/datatable/stylesheet/dataset.mjs +9 -5
- package/source/components/datatable/stylesheet/datasource.mjs +8 -4
- package/source/components/datatable/stylesheet/datatable.mjs +9 -5
- package/source/components/datatable/stylesheet/embedded-pagination.mjs +8 -4
- package/source/components/datatable/stylesheet/filter-button.mjs +8 -4
- package/source/components/datatable/stylesheet/filter-controls-defaults.mjs +8 -4
- package/source/components/datatable/stylesheet/filter-date-range.mjs +8 -4
- package/source/components/datatable/stylesheet/filter-range.mjs +8 -4
- package/source/components/datatable/stylesheet/filter.mjs +8 -4
- package/source/components/datatable/stylesheet/pagination.mjs +8 -4
- package/source/components/datatable/stylesheet/save-button.mjs +8 -4
- package/source/components/datatable/stylesheet/select-filter.mjs +8 -4
- package/source/components/datatable/stylesheet/status.mjs +8 -4
- package/source/components/form/button.mjs +263 -281
- package/source/components/form/field-set.mjs +300 -0
- package/source/components/form/popper.mjs +13 -480
- package/source/components/form/style/field-set.pcss +13 -0
- package/source/components/form/stylesheet/action-button.mjs +8 -4
- package/source/components/form/stylesheet/api-button.mjs +8 -4
- package/source/components/form/stylesheet/button-bar.mjs +9 -5
- package/source/components/form/stylesheet/button.mjs +8 -4
- package/source/components/form/stylesheet/confirm-button.mjs +9 -5
- package/source/components/form/stylesheet/context-error.mjs +8 -4
- package/source/components/form/stylesheet/context-help.mjs +8 -4
- package/source/components/form/stylesheet/field-set.mjs +31 -0
- package/source/components/form/stylesheet/form.mjs +9 -5
- package/source/components/form/stylesheet/message-state-button.mjs +8 -4
- package/source/components/form/stylesheet/popper-button.mjs +8 -4
- package/source/components/form/stylesheet/select.mjs +8 -4
- package/source/components/form/stylesheet/state-button.mjs +8 -4
- package/source/components/form/stylesheet/toggle-switch.mjs +8 -4
- package/source/components/form/stylesheet/tree-select.mjs +8 -4
- package/source/components/host/collapse.mjs +14 -516
- package/source/components/host/config-manager.mjs +9 -2
- package/source/components/host/constants.mjs +9 -4
- package/source/components/host/details.mjs +14 -253
- package/source/components/host/stylesheet/call-button.mjs +8 -4
- package/source/components/host/stylesheet/config-manager.mjs +8 -4
- package/source/components/host/stylesheet/host.mjs +9 -5
- package/source/components/host/stylesheet/overlay.mjs +9 -5
- package/source/components/host/stylesheet/toggle-button.mjs +8 -4
- package/source/components/host/stylesheet/viewer.mjs +8 -4
- package/source/components/layout/collapse.mjs +542 -0
- package/source/components/layout/details.mjs +271 -0
- package/source/components/layout/panel.mjs +6 -0
- package/source/components/layout/popper.mjs +476 -0
- package/source/components/{host → layout}/stylesheet/collapse.mjs +8 -4
- package/source/components/{host → layout}/stylesheet/details.mjs +8 -4
- package/source/components/layout/stylesheet/panel.mjs +8 -4
- package/source/components/{form → layout}/stylesheet/popper.mjs +8 -4
- package/source/components/layout/stylesheet/split-panel.mjs +8 -4
- package/source/components/layout/stylesheet/tabs.mjs +8 -4
- package/source/components/layout/stylesheet/width-toggle.mjs +8 -4
- package/source/components/layout/tabs.mjs +3 -3
- package/source/components/layout/width-toggle.mjs +3 -3
- package/source/components/navigation/style/table-of-content.pcss +84 -0
- package/source/components/navigation/stylesheet/table-of-content.mjs +31 -0
- package/source/components/navigation/table-of-content.mjs +418 -0
- package/source/components/notify/stylesheet/message.mjs +8 -4
- package/source/components/notify/stylesheet/notify.mjs +8 -4
- package/source/components/state/stylesheet/log.mjs +8 -4
- package/source/components/state/stylesheet/state.mjs +9 -5
- package/source/components/style/link.pcss +0 -1
- package/source/components/style/mixin/typography.pcss +7 -7
- package/source/components/style/typography.pcss +1 -1
- package/source/components/stylesheet/badge.mjs +8 -4
- package/source/components/stylesheet/border.mjs +8 -4
- package/source/components/stylesheet/button.mjs +8 -4
- package/source/components/stylesheet/card.mjs +8 -4
- package/source/components/stylesheet/color.mjs +8 -4
- package/source/components/stylesheet/common.mjs +8 -4
- package/source/components/stylesheet/control.mjs +8 -4
- package/source/components/stylesheet/data-grid.mjs +8 -4
- package/source/components/stylesheet/display.mjs +8 -4
- package/source/components/stylesheet/floating-ui.mjs +8 -4
- package/source/components/stylesheet/form.mjs +8 -4
- package/source/components/stylesheet/host.mjs +8 -4
- package/source/components/stylesheet/icons.mjs +8 -4
- package/source/components/stylesheet/link.mjs +8 -4
- package/source/components/stylesheet/mixin/badge.mjs +31 -0
- package/source/components/stylesheet/mixin/button.mjs +31 -0
- package/source/components/stylesheet/mixin/form.mjs +31 -0
- package/source/components/stylesheet/mixin/hover.mjs +31 -0
- package/source/components/stylesheet/mixin/icon.mjs +31 -0
- package/source/components/stylesheet/mixin/media.mjs +31 -0
- package/source/components/stylesheet/mixin/property.mjs +31 -0
- package/source/components/stylesheet/mixin/skeleton.mjs +31 -0
- package/source/components/stylesheet/mixin/spinner.mjs +31 -0
- package/source/components/stylesheet/mixin/typography.mjs +31 -0
- package/source/components/stylesheet/normalize.mjs +8 -4
- package/source/components/stylesheet/popper.mjs +8 -4
- package/source/components/stylesheet/property.mjs +8 -4
- package/source/components/stylesheet/ripple.mjs +8 -4
- package/source/components/stylesheet/skeleton.mjs +8 -4
- package/source/components/stylesheet/space.mjs +8 -4
- package/source/components/stylesheet/spinner.mjs +8 -4
- package/source/components/stylesheet/table.mjs +8 -4
- package/source/components/stylesheet/theme.mjs +8 -4
- package/source/components/stylesheet/typography.mjs +9 -5
- package/source/components/tree-menu/stylesheet/tree-menu.mjs +8 -4
- package/source/dom/ready.mjs +10 -4
- package/source/monster.mjs +17 -80
- package/source/types/proxyobserver.mjs +4 -2
- package/source/types/version.mjs +1 -1
- package/test/cases/monster.mjs +1 -1
- package/test/web/tests.js +4 -4
- package/source/components/form/form-field.mjs +0 -341
- package/source/components/form/style/form-field.pcss +0 -4
- package/source/components/form/stylesheet/form-field.mjs +0 -27
- /package/source/components/{host → layout}/style/collapse.pcss +0 -0
- /package/source/components/{host → layout}/style/details.pcss +0 -0
- /package/source/components/{form → layout}/style/popper.pcss +0 -0
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright schukai GmbH and
|
|
2
|
+
* Copyright © schukai GmbH and all contributing authors, {{copyRightYear}}. All rights reserved.
|
|
3
3
|
* Node module: @schukai/monster
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the GNU Affero General Public License version 3 (AGPLv3).
|
|
6
|
+
* The full text of the license can be found at: https://www.gnu.org/licenses/agpl-3.0.en.html
|
|
7
|
+
*
|
|
8
|
+
* For those who do not wish to adhere to the AGPLv3, a commercial license is available.
|
|
9
|
+
* Acquiring a commercial license allows you to use this software without complying with the AGPLv3 terms.
|
|
10
|
+
* For more information about purchasing a commercial license, please contact schukai GmbH.
|
|
6
11
|
*/
|
|
7
|
-
|
|
8
|
-
import {
|
|
12
|
+
|
|
13
|
+
import {instanceSymbol} from "../../constants.mjs";
|
|
14
|
+
import {addAttributeToken} from "../../dom/attributes.mjs";
|
|
9
15
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
ATTRIBUTE_ERRORMESSAGE,
|
|
17
|
+
ATTRIBUTE_ROLE,
|
|
12
18
|
} from "../../dom/constants.mjs";
|
|
13
|
-
import {
|
|
19
|
+
import {CustomControl} from "../../dom/customcontrol.mjs";
|
|
14
20
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
assembleMethodSymbol,
|
|
22
|
+
attributeObserverSymbol,
|
|
23
|
+
registerCustomElement,
|
|
18
24
|
} from "../../dom/customelement.mjs";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
+
import {findTargetElementFromEvent} from "../../dom/events.mjs";
|
|
26
|
+
import {isFunction} from "../../types/is.mjs";
|
|
27
|
+
import {ATTRIBUTE_BUTTON_CLASS} from "./constants.mjs";
|
|
28
|
+
import {ButtonStyleSheet} from "./stylesheet/button.mjs";
|
|
29
|
+
import {RippleStyleSheet} from "../stylesheet/ripple.mjs";
|
|
30
|
+
import {fireCustomEvent} from "../../dom/events.mjs";
|
|
25
31
|
|
|
26
|
-
export {
|
|
32
|
+
export {Button};
|
|
27
33
|
|
|
28
34
|
/**
|
|
29
35
|
* @private
|
|
@@ -32,281 +38,257 @@ export { Button };
|
|
|
32
38
|
export const buttonElementSymbol = Symbol("buttonElement");
|
|
33
39
|
|
|
34
40
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* ```html
|
|
43
|
-
* <monster-button></monster-button>
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* Or you can create this CustomControl directly in Javascript:
|
|
47
|
-
*
|
|
48
|
-
* ```js
|
|
49
|
-
* import {Button} from '@schukai/monster/components/form/button.mjs';
|
|
50
|
-
* document.createElement('monster-button');
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
* The `data-monster-button-class` attribute can be used to change the CSS class of the button.
|
|
54
|
-
*
|
|
55
|
-
* @externalExample ../../../example/components/form/button.mjs
|
|
56
|
-
* @startuml button.png
|
|
57
|
-
* skinparam monochrome true
|
|
58
|
-
* skinparam shadowing false
|
|
59
|
-
* HTMLElement <|-- CustomElement
|
|
60
|
-
* CustomElement <|-- CustomControl
|
|
61
|
-
* CustomControl <|-- Button
|
|
62
|
-
* @enduml
|
|
63
|
-
*
|
|
41
|
+
* A button
|
|
42
|
+
*
|
|
43
|
+
* @fragments /fragments/components/form/button/
|
|
44
|
+
*
|
|
45
|
+
* @example /examples/components/form/button-simple
|
|
46
|
+
* @example /examples/components/form/button-with-click-event
|
|
47
|
+
*
|
|
64
48
|
* @since 1.5.0
|
|
65
49
|
* @copyright schukai GmbH
|
|
66
|
-
* @
|
|
67
|
-
* @
|
|
50
|
+
* @summary A beautiful button that can make your life easier and also looks good.
|
|
51
|
+
* @fires monster-button-clicked this event is triggered when the button is clicked. It contains the field {button} with the button instance.
|
|
52
|
+
*
|
|
68
53
|
*/
|
|
69
54
|
class Button extends CustomControl {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return [RippleStyleSheet, ButtonStyleSheet];
|
|
253
|
-
}
|
|
55
|
+
/**
|
|
56
|
+
* This method is called by the <code>instanceof</code> operator.
|
|
57
|
+
* @return {symbol}
|
|
58
|
+
* @since 2.1.0
|
|
59
|
+
*/
|
|
60
|
+
static get [instanceSymbol]() {
|
|
61
|
+
return Symbol.for("@schukai/monster/components/form/button@@instance");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @return {Button}
|
|
67
|
+
*/
|
|
68
|
+
[assembleMethodSymbol]() {
|
|
69
|
+
super[assembleMethodSymbol]();
|
|
70
|
+
initControlReferences.call(this);
|
|
71
|
+
initEventHandler.call(this);
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The <code>Button.click()</code> method simulates a click on the internal button element.
|
|
77
|
+
*
|
|
78
|
+
* @since 3.27.0
|
|
79
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click}
|
|
80
|
+
*/
|
|
81
|
+
click() {
|
|
82
|
+
if (this.getOption("disabled") === true) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (
|
|
87
|
+
this[buttonElementSymbol] &&
|
|
88
|
+
isFunction(this[buttonElementSymbol].click)
|
|
89
|
+
) {
|
|
90
|
+
this[buttonElementSymbol].click();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The Button.focus() method sets focus on the internal button element.
|
|
96
|
+
*
|
|
97
|
+
* @since 3.27.0
|
|
98
|
+
* @param {Object} options
|
|
99
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus}
|
|
100
|
+
*/
|
|
101
|
+
focus(options) {
|
|
102
|
+
if (this.getOption("disabled") === true) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (
|
|
107
|
+
this[buttonElementSymbol] &&
|
|
108
|
+
isFunction(this[buttonElementSymbol].focus)
|
|
109
|
+
) {
|
|
110
|
+
this[buttonElementSymbol].focus(options);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The Button.blur() method removes focus from the internal button element.
|
|
116
|
+
*/
|
|
117
|
+
blur() {
|
|
118
|
+
if (
|
|
119
|
+
this[buttonElementSymbol] &&
|
|
120
|
+
isFunction(this[buttonElementSymbol].blur)
|
|
121
|
+
) {
|
|
122
|
+
this[buttonElementSymbol].blur();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* This method determines which attributes are to be monitored by `attributeChangedCallback()`.
|
|
128
|
+
*
|
|
129
|
+
* @return {string[]}
|
|
130
|
+
*/
|
|
131
|
+
static get observedAttributes() {
|
|
132
|
+
const attributes = super.observedAttributes;
|
|
133
|
+
attributes.push(ATTRIBUTE_BUTTON_CLASS);
|
|
134
|
+
return attributes;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals}
|
|
139
|
+
* @return {boolean}
|
|
140
|
+
*/
|
|
141
|
+
static get formAssociated() {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The current value of the button.
|
|
147
|
+
*
|
|
148
|
+
* ```javascript
|
|
149
|
+
* e = document.querySelector('monster-button');
|
|
150
|
+
* console.log(e.value)
|
|
151
|
+
* ```
|
|
152
|
+
*
|
|
153
|
+
* @return {string} The value of the button
|
|
154
|
+
*/
|
|
155
|
+
get value() {
|
|
156
|
+
return this.getOption("value");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Set the value of the button.
|
|
161
|
+
*
|
|
162
|
+
* ```javascript
|
|
163
|
+
* e = document.querySelector('monster-button');
|
|
164
|
+
* e.value=1
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @param {string} value
|
|
168
|
+
* @return {void}
|
|
169
|
+
* @throws {Error} unsupported type
|
|
170
|
+
*/
|
|
171
|
+
set value(value) {
|
|
172
|
+
this.setOption("value", value);
|
|
173
|
+
try {
|
|
174
|
+
this?.setFormValue(this.value);
|
|
175
|
+
} catch (e) {
|
|
176
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* To set the options via the html tag the attribute `data-monster-options` must be used.
|
|
182
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
|
183
|
+
*
|
|
184
|
+
* The individual configuration values can be found in the table.
|
|
185
|
+
*
|
|
186
|
+
* @property {Object} templates Template definitions
|
|
187
|
+
* @property {string} templates.main Main template
|
|
188
|
+
* @property {Object} labels Labels
|
|
189
|
+
* @property {string} labels.button="<slot></slot>" Button label
|
|
190
|
+
* @property {Object} actions Callbacks
|
|
191
|
+
* @property {string} actions.click="throw Error" Callback when clicked
|
|
192
|
+
* @property {Object} classes CSS classes
|
|
193
|
+
* @property {string} classes.button="monster-button-primary" CSS class for the button
|
|
194
|
+
* @property {boolean} disabled=false Disabled state
|
|
195
|
+
* @property {Object} effects Effects
|
|
196
|
+
* @property {boolean} effects.ripple=true Ripple effect
|
|
197
|
+
*/
|
|
198
|
+
get defaults() {
|
|
199
|
+
return Object.assign({}, super.defaults, {
|
|
200
|
+
templates: {
|
|
201
|
+
main: getTemplate(),
|
|
202
|
+
},
|
|
203
|
+
labels: {
|
|
204
|
+
button: "<slot></slot>",
|
|
205
|
+
},
|
|
206
|
+
classes: {
|
|
207
|
+
button: "monster-button-primary",
|
|
208
|
+
},
|
|
209
|
+
disabled: false,
|
|
210
|
+
actions: {
|
|
211
|
+
click: () => {
|
|
212
|
+
throw new Error("the click action is not defined");
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
effects: {
|
|
216
|
+
ripple: true,
|
|
217
|
+
},
|
|
218
|
+
value: null,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
*
|
|
224
|
+
* @return {string}
|
|
225
|
+
*/
|
|
226
|
+
static getTag() {
|
|
227
|
+
return "monster-button";
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
*
|
|
232
|
+
* @return {CSSStyleSheet[]}
|
|
233
|
+
*/
|
|
234
|
+
static getCSSStyleSheet() {
|
|
235
|
+
return [RippleStyleSheet, ButtonStyleSheet];
|
|
236
|
+
}
|
|
254
237
|
}
|
|
255
238
|
|
|
256
239
|
/**
|
|
257
240
|
* @private
|
|
258
241
|
* @return {initEventHandler}
|
|
259
|
-
* @fires Monster.Components.Form.event:monster-button-clicked
|
|
260
242
|
*/
|
|
261
243
|
function initEventHandler() {
|
|
262
|
-
|
|
263
|
-
|
|
244
|
+
const self = this;
|
|
245
|
+
const button = this[buttonElementSymbol];
|
|
264
246
|
|
|
265
|
-
|
|
247
|
+
const type = "click";
|
|
266
248
|
|
|
267
|
-
|
|
268
|
-
|
|
249
|
+
button.addEventListener(type, function (event) {
|
|
250
|
+
const callback = self.getOption("actions.click");
|
|
269
251
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
252
|
+
fireCustomEvent(self, "monster-button-clicked", {
|
|
253
|
+
button: self,
|
|
254
|
+
});
|
|
273
255
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
256
|
+
if (!isFunction(callback)) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
277
259
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
260
|
+
const element = findTargetElementFromEvent(
|
|
261
|
+
event,
|
|
262
|
+
ATTRIBUTE_ROLE,
|
|
263
|
+
"control",
|
|
264
|
+
);
|
|
283
265
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
266
|
+
if (!(element instanceof Node && self.hasNode(element))) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
287
269
|
|
|
288
|
-
|
|
289
|
-
|
|
270
|
+
callback.call(self, event);
|
|
271
|
+
});
|
|
290
272
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
273
|
+
if (self.getOption("effects.ripple")) {
|
|
274
|
+
button.addEventListener("click", createRipple.bind(self));
|
|
275
|
+
}
|
|
294
276
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
277
|
+
// data-monster-options
|
|
278
|
+
self[attributeObserverSymbol][ATTRIBUTE_BUTTON_CLASS] = function (value) {
|
|
279
|
+
self.setOption("classes.button", value);
|
|
280
|
+
};
|
|
299
281
|
|
|
300
|
-
|
|
282
|
+
return this;
|
|
301
283
|
}
|
|
302
284
|
|
|
303
285
|
/**
|
|
304
286
|
* @private
|
|
305
287
|
*/
|
|
306
288
|
function initControlReferences() {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
289
|
+
this[buttonElementSymbol] = this.shadowRoot.querySelector(
|
|
290
|
+
`[${ATTRIBUTE_ROLE}=button]`,
|
|
291
|
+
);
|
|
310
292
|
}
|
|
311
293
|
|
|
312
294
|
/**
|
|
@@ -314,8 +296,8 @@ function initControlReferences() {
|
|
|
314
296
|
* @return {string}
|
|
315
297
|
*/
|
|
316
298
|
function getTemplate() {
|
|
317
|
-
|
|
318
|
-
|
|
299
|
+
// language=HTML
|
|
300
|
+
return `
|
|
319
301
|
<div data-monster-role="control" part="control">
|
|
320
302
|
<button data-monster-attributes="disabled path:disabled | if:true, class path:classes.button"
|
|
321
303
|
data-monster-role="button"
|
|
@@ -325,23 +307,23 @@ function getTemplate() {
|
|
|
325
307
|
}
|
|
326
308
|
|
|
327
309
|
function createRipple(event) {
|
|
328
|
-
|
|
310
|
+
const button = this[buttonElementSymbol];
|
|
329
311
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
312
|
+
const circle = document.createElement("span");
|
|
313
|
+
const diameter = Math.max(button.clientWidth, button.clientHeight);
|
|
314
|
+
const radius = diameter / 2;
|
|
333
315
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
316
|
+
circle.style.width = circle.style.height = `${diameter}px`;
|
|
317
|
+
circle.style.left = `${event.clientX - button.offsetLeft - radius}px`;
|
|
318
|
+
circle.style.top = `${event.clientY - button.offsetTop - radius}px`;
|
|
319
|
+
circle.classList.add("monster-fx-ripple");
|
|
338
320
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
321
|
+
const ripples = button.getElementsByClassName("monster-fx-ripple");
|
|
322
|
+
for (const ripple of ripples) {
|
|
323
|
+
ripple.remove();
|
|
324
|
+
}
|
|
343
325
|
|
|
344
|
-
|
|
326
|
+
button.appendChild(circle);
|
|
345
327
|
}
|
|
346
328
|
|
|
347
329
|
registerCustomElement(Button);
|