@schukai/monster 3.51.5 → 3.52.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +25 -0
- package/README.md +15 -12
- package/example/components/form/button.mjs +10 -0
- package/example/components/form/select.mjs +25 -0
- package/example/components/form/tree-select.mjs +27 -0
- package/example/components/host/host.mjs +0 -0
- package/example/components/notify/message.mjs +4 -0
- package/example/components/notify/notify.mjs +4 -0
- package/example/components/state/log.mjs +0 -0
- package/example/components/state/state.mjs +0 -0
- package/example/data/datasource/server/restapi.mjs +7 -1
- package/package.json +6 -2
- package/source/components/constants.mjs +132 -0
- package/source/components/datatable/columnbar.mjs +310 -0
- package/source/components/datatable/constants.mjs +121 -0
- package/source/components/datatable/dataset.mjs +219 -0
- package/source/components/datatable/datasource/dom.mjs +186 -0
- package/source/components/datatable/datasource/namespace.mjs +13 -0
- package/source/components/datatable/datasource/rest.mjs +400 -0
- package/source/components/datatable/datasource.mjs +102 -0
- package/source/components/datatable/datatable/header.mjs +268 -0
- package/source/components/datatable/datatable/namespace.mjs +13 -0
- package/source/components/datatable/datatable.mjs +789 -0
- package/source/components/datatable/embedded-pagination.mjs +113 -0
- package/source/components/datatable/filter/abstract-base.mjs +31 -0
- package/source/components/datatable/filter/date-range.mjs +1041 -0
- package/source/components/datatable/filter/input.mjs +175 -0
- package/source/components/datatable/filter/namespace.mjs +13 -0
- package/source/components/datatable/filter/range.mjs +671 -0
- package/source/components/datatable/filter/select.mjs +65 -0
- package/source/components/datatable/filter/settings.mjs +116 -0
- package/source/components/datatable/filter-button.mjs +98 -0
- package/source/components/datatable/filter.mjs +929 -0
- package/source/components/datatable/namespace.mjs +11 -0
- package/source/components/datatable/pagination.mjs +456 -0
- package/source/components/datatable/style/column-bar.pcss +123 -0
- package/source/components/datatable/style/dataset.pcss +13 -0
- package/source/components/datatable/style/datasource.pcss +16 -0
- package/source/components/datatable/style/datatable.pcss +239 -0
- package/source/components/datatable/style/embedded-pagination.pcss +101 -0
- package/source/components/datatable/style/filter-button.pcss +22 -0
- package/source/components/datatable/style/filter-controls-defaults.pcss +46 -0
- package/source/components/datatable/style/filter-date-range.pcss +9 -0
- package/source/components/datatable/style/filter-range.pcss +5 -0
- package/source/components/datatable/style/filter.pcss +156 -0
- package/source/components/datatable/style/pagination.pcss +59 -0
- package/source/components/datatable/style/select-filter.pcss +27 -0
- package/source/components/datatable/stylesheet/column-bar.mjs +27 -0
- package/source/components/datatable/stylesheet/dataset.mjs +27 -0
- package/source/components/datatable/stylesheet/datasource.mjs +27 -0
- package/source/components/datatable/stylesheet/datatable.mjs +27 -0
- package/source/components/datatable/stylesheet/embedded-pagination.mjs +27 -0
- package/source/components/datatable/stylesheet/filter-button.mjs +27 -0
- package/source/components/datatable/stylesheet/filter-controls-defaults.mjs +27 -0
- package/source/components/datatable/stylesheet/filter-date-range.mjs +27 -0
- package/source/components/datatable/stylesheet/filter-range.mjs +27 -0
- package/source/components/datatable/stylesheet/filter.mjs +27 -0
- package/source/components/datatable/stylesheet/namespace.mjs +13 -0
- package/source/components/datatable/stylesheet/pagination.mjs +27 -0
- package/source/components/datatable/stylesheet/select-filter.mjs +27 -0
- package/source/components/datatable/util.mjs +60 -0
- package/source/components/form/action-button.mjs +262 -0
- package/source/components/form/api-button.mjs +515 -0
- package/source/components/form/button-bar.mjs +739 -0
- package/source/components/form/button.mjs +350 -0
- package/source/components/form/confirm-button.mjs +330 -0
- package/source/components/form/constants.mjs +111 -0
- package/source/components/form/context-help.mjs +123 -0
- package/source/components/form/events.mjs +84 -0
- package/source/components/form/form.mjs +601 -0
- package/source/components/form/message-state-button.mjs +396 -0
- package/source/components/form/namespace.mjs +13 -0
- package/source/components/form/popper-button.mjs +435 -0
- package/source/components/form/popper.mjs +487 -0
- package/source/components/form/reload.mjs +360 -0
- package/source/components/form/select.mjs +2314 -0
- package/source/components/form/shadow-reload.mjs +137 -0
- package/source/components/form/state-button.mjs +182 -0
- package/source/components/form/style/action-button.pcss +41 -0
- package/source/components/form/style/api-button.pcss +0 -0
- package/source/components/form/style/button-bar.pcss +51 -0
- package/source/components/form/style/button.pcss +8 -0
- package/source/components/form/style/confirm-button.pcss +17 -0
- package/source/components/form/style/context-help.pcss +16 -0
- package/source/components/form/style/form.pcss +10 -0
- package/source/components/form/style/message-state-button.pcss +10 -0
- package/source/components/form/style/popper-button.pcss +16 -0
- package/source/components/form/style/popper.pcss +8 -0
- package/source/components/form/style/select.pcss +265 -0
- package/source/components/form/style/state-button.pcss +116 -0
- package/source/components/form/style/tabs.pcss +173 -0
- package/source/components/form/style/tree-select.pcss +81 -0
- package/source/components/form/stylesheet/action-button.mjs +27 -0
- package/source/components/form/stylesheet/api-button.mjs +27 -0
- package/source/components/form/stylesheet/button-bar.mjs +27 -0
- package/source/components/form/stylesheet/button.mjs +27 -0
- package/source/components/form/stylesheet/confirm-button.mjs +27 -0
- package/source/components/form/stylesheet/context-help.mjs +27 -0
- package/source/components/form/stylesheet/form.mjs +27 -0
- package/source/components/form/stylesheet/message-state-button.mjs +27 -0
- package/source/components/form/stylesheet/namespace.mjs +13 -0
- package/source/components/form/stylesheet/popper-button.mjs +27 -0
- package/source/components/form/stylesheet/popper.mjs +27 -0
- package/source/components/form/stylesheet/select.mjs +27 -0
- package/source/components/form/stylesheet/state-button.mjs +27 -0
- package/source/components/form/stylesheet/tabs.mjs +27 -0
- package/source/components/form/stylesheet/tree-select.mjs +27 -0
- package/source/components/form/tabs.mjs +1029 -0
- package/source/components/form/template.mjs +373 -0
- package/source/components/form/tree-select.mjs +527 -0
- package/source/components/form/types/namespace.mjs +13 -0
- package/source/components/form/types/state.mjs +93 -0
- package/source/components/form/util/fetch.mjs +133 -0
- package/source/components/form/util/floating-ui.mjs +245 -0
- package/source/components/form/util/namespace.mjs +13 -0
- package/source/components/form/util/popper.mjs +49 -0
- package/source/components/host/call-button.mjs +236 -0
- package/source/components/host/collapse.mjs +526 -0
- package/source/components/host/config-manager.mjs +304 -0
- package/source/components/host/constants.mjs +18 -0
- package/source/components/host/details.mjs +268 -0
- package/source/components/host/events.mjs +131 -0
- package/source/components/host/host.mjs +420 -0
- package/source/components/host/namespace.mjs +13 -0
- package/source/components/host/overlay.mjs +339 -0
- package/source/components/host/style/call-button.pcss +36 -0
- package/source/components/host/style/collapse.pcss +67 -0
- package/source/components/host/style/config-manager.pcss +5 -0
- package/source/components/host/style/details.pcss +68 -0
- package/source/components/host/style/host.pcss +43 -0
- package/source/components/host/style/overlay.pcss +73 -0
- package/source/components/host/style/toggle-button.pcss +36 -0
- package/source/components/host/style/viewer.pcss +13 -0
- package/source/components/host/stylesheet/call-button.mjs +27 -0
- package/source/components/host/stylesheet/collapse.mjs +27 -0
- package/source/components/host/stylesheet/config-manager.mjs +27 -0
- package/source/components/host/stylesheet/details.mjs +27 -0
- package/source/components/host/stylesheet/host.mjs +27 -0
- package/source/components/host/stylesheet/namespace.mjs +13 -0
- package/source/components/host/stylesheet/overlay.mjs +27 -0
- package/source/components/host/stylesheet/toggle-button.mjs +27 -0
- package/source/components/host/stylesheet/viewer.mjs +27 -0
- package/source/components/host/toggle-button.mjs +88 -0
- package/source/components/host/util.mjs +23 -0
- package/source/components/host/viewer.mjs +309 -0
- package/source/components/namespace.mjs +14 -0
- package/source/components/notify/constants.mjs +15 -0
- package/source/components/notify/events.mjs +15 -0
- package/source/components/notify/message.mjs +374 -0
- package/source/components/notify/namespace.mjs +15 -0
- package/source/components/notify/notify.mjs +236 -0
- package/source/components/notify/style/message.pcss +57 -0
- package/source/components/notify/style/notify.pcss +118 -0
- package/source/components/notify/stylesheet/message.mjs +27 -0
- package/source/components/notify/stylesheet/namespace.mjs +15 -0
- package/source/components/notify/stylesheet/notify.mjs +27 -0
- package/source/components/state/log/entry.mjs +126 -0
- package/source/components/state/log/namespace.mjs +13 -0
- package/source/components/state/log.mjs +275 -0
- package/source/components/state/namespace.mjs +13 -0
- package/source/components/state/state.mjs +131 -0
- package/source/components/state/style/log.pcss +111 -0
- package/source/components/state/style/state.pcss +113 -0
- package/source/components/state/stylesheet/log.mjs +27 -0
- package/source/components/state/stylesheet/state.mjs +27 -0
- package/source/components/style/badge.pcss +92 -0
- package/source/components/style/border.pcss +77 -0
- package/source/components/style/button.pcss +105 -0
- package/source/components/style/card.pcss +108 -0
- package/source/components/style/color.pcss +257 -0
- package/source/components/style/common.pcss +105 -0
- package/source/components/style/control.pcss +11 -0
- package/source/components/style/data-grid.pcss +43 -0
- package/source/components/style/display.pcss +42 -0
- package/source/components/style/floating-ui.pcss +33 -0
- package/source/components/style/form.pcss +5 -0
- package/source/components/style/host.pcss +15 -0
- package/source/components/style/link.pcss +63 -0
- package/source/components/style/mixin/badge.pcss +18 -0
- package/source/components/style/mixin/button.pcss +52 -0
- package/source/components/style/mixin/form.pcss +247 -0
- package/source/components/style/mixin/hover.pcss +8 -0
- package/source/components/style/mixin/media.pcss +107 -0
- package/source/components/style/mixin/property.pcss +292 -0
- package/source/components/style/mixin/skeleton.pcss +26 -0
- package/source/components/style/mixin/spinner.pcss +24 -0
- package/source/components/style/mixin/typography.pcss +52 -0
- package/source/components/style/normalize.pcss +14 -0
- package/source/components/style/popper.pcss +78 -0
- package/source/components/style/property.pcss +17 -0
- package/source/components/style/ripple.pcss +14 -0
- package/source/components/style/skeleton.pcss +28 -0
- package/source/components/style/space.pcss +47 -0
- package/source/components/style/spinner.pcss +6 -0
- package/source/components/style/table.pcss +46 -0
- package/source/components/style/theme.pcss +119 -0
- package/source/components/style/typography.pcss +131 -0
- package/source/components/stylesheet/badge.mjs +27 -0
- package/source/components/stylesheet/border.mjs +27 -0
- package/source/components/stylesheet/button.mjs +27 -0
- package/source/components/stylesheet/card.mjs +27 -0
- package/source/components/stylesheet/color.mjs +27 -0
- package/source/components/stylesheet/common.mjs +27 -0
- package/source/components/stylesheet/control.mjs +27 -0
- package/source/components/stylesheet/data-grid.mjs +27 -0
- package/source/components/stylesheet/display.mjs +27 -0
- package/source/components/stylesheet/floating-ui.mjs +27 -0
- package/source/components/stylesheet/form.mjs +27 -0
- package/source/components/stylesheet/host.mjs +27 -0
- package/source/components/stylesheet/link.mjs +27 -0
- package/source/components/stylesheet/namespace.mjs +13 -0
- package/source/components/stylesheet/normalize.mjs +27 -0
- package/source/components/stylesheet/popper.mjs +27 -0
- package/source/components/stylesheet/property.mjs +27 -0
- package/source/components/stylesheet/ripple.mjs +27 -0
- package/source/components/stylesheet/skeleton.mjs +27 -0
- package/source/components/stylesheet/space.mjs +27 -0
- package/source/components/stylesheet/spinner.mjs +27 -0
- package/source/components/stylesheet/table.mjs +27 -0
- package/source/components/stylesheet/theme.mjs +27 -0
- package/source/components/stylesheet/tree-menu.mjs +33 -0
- package/source/components/stylesheet/typography.mjs +27 -0
- package/source/components/tree-menu/namespace.mjs +13 -0
- package/source/components/tree-menu/style/tree-menu.pcss +107 -0
- package/source/components/tree-menu/stylesheet/namespace.mjs +13 -0
- package/source/components/tree-menu/stylesheet/tree-menu.mjs +27 -0
- package/source/components/tree-menu/tree-menu.mjs +660 -0
- package/source/constraints/abstract.mjs +17 -24
- package/source/constraints/abstractoperator.mjs +27 -22
- package/source/constraints/andoperator.mjs +20 -17
- package/source/constraints/invalid.mjs +17 -17
- package/source/constraints/isarray.mjs +20 -20
- package/source/constraints/isobject.mjs +20 -20
- package/source/constraints/oroperator.mjs +45 -45
- package/source/constraints/valid.mjs +17 -17
- package/source/data/buildmap.mjs +108 -103
- package/source/data/buildtree.mjs +59 -57
- package/source/data/datasource/dom.mjs +80 -84
- package/source/data/datasource/namespace.mjs +1 -1
- package/source/data/datasource/server/restapi/data-fetch-error.mjs +27 -25
- package/source/data/datasource/server/restapi/writeerror.mjs +35 -32
- package/source/data/datasource/server/restapi.mjs +176 -177
- package/source/data/datasource/server/webconnect.mjs +150 -156
- package/source/data/datasource/server.mjs +62 -63
- package/source/data/datasource/storage/localstorage.mjs +25 -24
- package/source/data/datasource/storage/sessionstorage.mjs +28 -25
- package/source/data/datasource/storage.mjs +74 -73
- package/source/data/datasource.mjs +177 -168
- package/source/data/diff.mjs +98 -97
- package/source/data/extend.mjs +42 -42
- package/source/data/pathfinder.mjs +301 -288
- package/source/data/pipe.mjs +36 -36
- package/source/data/transformer.mjs +742 -726
- package/source/dom/assembler.mjs +44 -44
- package/source/dom/attributes.mjs +142 -122
- package/source/dom/constants.mjs +62 -58
- package/source/dom/customcontrol.mjs +299 -299
- package/source/dom/customelement.mjs +843 -806
- package/source/dom/dimension.mjs +56 -46
- package/source/dom/events.mjs +74 -69
- package/source/dom/focusmanager.mjs +175 -175
- package/source/dom/locale.mjs +28 -28
- package/source/dom/ready.mjs +13 -13
- package/source/dom/resource/data.mjs +117 -111
- package/source/dom/resource/link/stylesheet.mjs +16 -16
- package/source/dom/resource/link.mjs +94 -96
- package/source/dom/resource/script.mjs +72 -74
- package/source/dom/resource.mjs +174 -172
- package/source/dom/resourcemanager.mjs +152 -156
- package/source/dom/slotted.mjs +78 -80
- package/source/dom/template.mjs +126 -112
- package/source/dom/theme.mjs +35 -35
- package/source/dom/updater.mjs +673 -651
- package/source/dom/util/extract-keys.mjs +34 -22
- package/source/dom/util/init-options-from-attributes.mjs +46 -38
- package/source/dom/util/namespace.mjs +13 -0
- package/source/dom/util/set-option-from-attribute.mjs +35 -29
- package/source/dom/util.mjs +112 -81
- package/source/dom/worker/factory.mjs +83 -83
- package/source/i18n/formatter.mjs +75 -73
- package/source/i18n/locale.mjs +146 -144
- package/source/i18n/provider.mjs +70 -64
- package/source/i18n/providers/embed.mjs +136 -127
- package/source/i18n/providers/fetch.mjs +84 -76
- package/source/i18n/translations.mjs +205 -195
- package/source/logging/handler/console.mjs +36 -36
- package/source/logging/handler.mjs +140 -140
- package/source/logging/logentry.mjs +25 -25
- package/source/logging/logger.mjs +177 -175
- package/source/math/random.mjs +63 -59
- package/source/monster.mjs +223 -103
- package/source/net/webconnect/message.mjs +31 -31
- package/source/net/webconnect.mjs +278 -271
- package/source/text/bracketed-key-value-hash.mjs +182 -179
- package/source/text/formatter.mjs +235 -210
- package/source/text/generate-range-comparison-expression.mjs +56 -34
- package/source/text/namespace.mjs +1 -1
- package/source/types/base.mjs +69 -61
- package/source/types/basewithoptions.mjs +46 -46
- package/source/types/binary.mjs +20 -20
- package/source/types/dataurl.mjs +96 -90
- package/source/types/global.mjs +45 -39
- package/source/types/id.mjs +25 -25
- package/source/types/internal.mjs +115 -114
- package/source/types/is.mjs +56 -40
- package/source/types/mediatype.mjs +119 -119
- package/source/types/namespace.mjs +1 -1
- package/source/types/node.mjs +160 -150
- package/source/types/nodelist.mjs +94 -96
- package/source/types/noderecursiveiterator.mjs +50 -50
- package/source/types/observablequeue.mjs +73 -73
- package/source/types/observer.mjs +114 -106
- package/source/types/observerlist.mjs +66 -66
- package/source/types/proxyobserver.mjs +210 -210
- package/source/types/queue.mjs +63 -63
- package/source/types/randomid.mjs +13 -13
- package/source/types/regex.mjs +3 -1
- package/source/types/stack.mjs +64 -64
- package/source/types/tokenlist.mjs +206 -205
- package/source/types/typeof.mjs +12 -10
- package/source/types/uniquequeue.mjs +48 -48
- package/source/types/uuid.mjs +32 -32
- package/source/types/validate.mjs +67 -67
- package/source/types/version.mjs +115 -105
- package/source/util/clone.mjs +103 -91
- package/source/util/comparator.mjs +97 -97
- package/source/util/deadmansswitch.mjs +40 -44
- package/source/util/freeze.mjs +10 -9
- package/source/util/namespace.mjs +1 -1
- package/source/util/processing.mjs +104 -105
- package/source/util/runtime.mjs +56 -44
- package/source/util/trimspaces.mjs +24 -24
- package/test/cases/components/form/button.mjs +122 -0
- package/test/cases/components/form/confirm-button.mjs +127 -0
- package/test/cases/components/form/form.mjs +317 -0
- package/test/cases/components/form/reload.mjs +188 -0
- package/test/cases/components/form/select.mjs +229 -0
- package/test/cases/components/form/state-button.mjs +130 -0
- package/test/cases/components/form/tabs.mjs +98 -0
- package/test/cases/components/form/template.mjs +189 -0
- package/test/cases/components/form/tree-select.mjs +216 -0
- package/test/cases/components/host/details.mjs +68 -0
- package/test/cases/components/host/host.mjs +70 -0
- package/test/cases/components/host/overlay.mjs +60 -0
- package/test/cases/components/host/util.mjs +79 -0
- package/test/cases/components/notify/message.mjs +39 -0
- package/test/cases/components/notify/notify.mjs +89 -0
- package/test/cases/dom/customcontrol.mjs +5 -4
- package/test/cases/math/random.mjs +0 -1
- package/test/cases/monster.mjs +1 -1
- package/test/cases/net/webconnect/message.mjs +0 -1
- package/test/cases/types/node.mjs +1 -1
- package/test/util/chai-dom.mjs +2 -2
- package/test/util/intersection-mock.mjs +69 -0
- package/test/util/jsdom.mjs +41 -25
- package/test/util/localstorage.mjs +1 -0
- package/test/util/resize-observer.mjs +29 -0
- package/test/util/websocket.mjs +4 -1
- package/test/web/import.js +16 -1
- package/test/web/test.html +28 -5
- package/test/web/tests.js +30398 -17879
@@ -0,0 +1,739 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright schukai GmbH and contributors 2023. All Rights Reserved.
|
3
|
+
* Node module: @schukai/monster
|
4
|
+
* This file is licensed under the AGPLv3 License.
|
5
|
+
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
6
|
+
*/
|
7
|
+
import { instanceSymbol } from "../../constants.mjs";
|
8
|
+
import { Pathfinder } from "../../data/pathfinder.mjs";
|
9
|
+
import {
|
10
|
+
addAttributeToken,
|
11
|
+
removeAttributeToken,
|
12
|
+
} from "../../dom/attributes.mjs";
|
13
|
+
import { ATTRIBUTE_ROLE } from "../../dom/constants.mjs";
|
14
|
+
import {
|
15
|
+
assembleMethodSymbol,
|
16
|
+
getSlottedElements,
|
17
|
+
registerCustomElement,
|
18
|
+
} from "../../dom/customelement.mjs";
|
19
|
+
import {
|
20
|
+
CustomElement,
|
21
|
+
attributeObserverSymbol,
|
22
|
+
} from "../../dom/customelement.mjs";
|
23
|
+
import { findTargetElementFromEvent } from "../../dom/events.mjs";
|
24
|
+
import { getDocument } from "../../dom/util.mjs";
|
25
|
+
import { getGlobal } from "../../types/global.mjs";
|
26
|
+
import { ID } from "../../types/id.mjs";
|
27
|
+
import { DeadMansSwitch } from "../../util/deadmansswitch.mjs";
|
28
|
+
import { Processing } from "../../util/processing.mjs";
|
29
|
+
import { STYLE_DISPLAY_MODE_BLOCK } from "./constants.mjs";
|
30
|
+
import { ButtonBarStyleSheet } from "./stylesheet/button-bar.mjs";
|
31
|
+
import { positionPopper } from "./util/floating-ui.mjs";
|
32
|
+
import { convertToPixels } from "../../dom/dimension.mjs";
|
33
|
+
|
34
|
+
export { ButtonBar };
|
35
|
+
|
36
|
+
/**
|
37
|
+
* @private
|
38
|
+
* @type {symbol}
|
39
|
+
*/
|
40
|
+
const timerCallbackSymbol = Symbol("timerCallback");
|
41
|
+
|
42
|
+
/**
|
43
|
+
* local symbol
|
44
|
+
* @private
|
45
|
+
* @type {symbol}
|
46
|
+
*/
|
47
|
+
const resizeObserverSymbol = Symbol("windowResizeObserver");
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @private
|
51
|
+
* @type {symbol}
|
52
|
+
*/
|
53
|
+
const dimensionsSymbol = Symbol("dimensions");
|
54
|
+
|
55
|
+
/**
|
56
|
+
* @private
|
57
|
+
* @type {symbol}
|
58
|
+
*/
|
59
|
+
const controlElementSymbol = Symbol("controlElement");
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @private
|
63
|
+
* @type {symbol}
|
64
|
+
*/
|
65
|
+
const buttonBarSlotElementSymbol = Symbol("buttonBarSlotElement");
|
66
|
+
|
67
|
+
/**
|
68
|
+
* @private
|
69
|
+
* @type {symbol}
|
70
|
+
*/
|
71
|
+
const popperSlotElementSymbol = Symbol("popperSlotElement");
|
72
|
+
|
73
|
+
/**
|
74
|
+
* @private
|
75
|
+
* @type {symbol}
|
76
|
+
*/
|
77
|
+
const buttonBarElementSymbol = Symbol("buttonBarElement");
|
78
|
+
|
79
|
+
/**
|
80
|
+
* @private
|
81
|
+
* @type {symbol}
|
82
|
+
*/
|
83
|
+
const popperElementSymbol = Symbol("popperElement");
|
84
|
+
|
85
|
+
/**
|
86
|
+
* local symbol
|
87
|
+
* @private
|
88
|
+
* @type {symbol}
|
89
|
+
*/
|
90
|
+
const closeEventHandler = Symbol("closeEventHandler");
|
91
|
+
|
92
|
+
/**
|
93
|
+
* @private
|
94
|
+
* @type {symbol}
|
95
|
+
*/
|
96
|
+
const popperSwitchEventHandler = Symbol("popperSwitchEventHandler");
|
97
|
+
|
98
|
+
/**
|
99
|
+
* @private
|
100
|
+
* @type {symbol}
|
101
|
+
*/
|
102
|
+
const popperNavElementSymbol = Symbol("popperNavElement");
|
103
|
+
|
104
|
+
/**
|
105
|
+
* @private
|
106
|
+
* @type {symbol}
|
107
|
+
*/
|
108
|
+
const switchElementSymbol = Symbol("switchElement");
|
109
|
+
|
110
|
+
/**
|
111
|
+
* @private
|
112
|
+
* @type {string}
|
113
|
+
*/
|
114
|
+
const ATTRIBUTE_POPPER_POSITION = "data-monster-popper-position";
|
115
|
+
|
116
|
+
/**
|
117
|
+
* This CustomControl creates a button bar.
|
118
|
+
*
|
119
|
+
* <img src="./images/button-bar.png">
|
120
|
+
*
|
121
|
+
* Dependencies: the system uses functions of the [monsterjs](https://monsterjs.org/) library.
|
122
|
+
*
|
123
|
+
* You can create this control either by specifying the HTML tag `<monster-tabs />` directly in the HTML or using
|
124
|
+
* Javascript via the `document.createElement('monster-tabs');` method.
|
125
|
+
*
|
126
|
+
* ```html
|
127
|
+
* <monster-tabs></monster-tabs>
|
128
|
+
* ```
|
129
|
+
*
|
130
|
+
* Or you can create this CustomControl directly in Javascript:
|
131
|
+
*
|
132
|
+
* ```js
|
133
|
+
* import {ButtonBar} from '@schukai/component-form/source/tab.js';
|
134
|
+
* document.createElement('monster-tabs');
|
135
|
+
* ```
|
136
|
+
*
|
137
|
+
* @startuml button-bar.png
|
138
|
+
* skinparam monochrome true
|
139
|
+
* skinparam shadowing false
|
140
|
+
* HTMLElement <|-- CustomElement
|
141
|
+
* CustomElement <|-- ButtonBar
|
142
|
+
* @enduml
|
143
|
+
*
|
144
|
+
* @since 3.19.0
|
145
|
+
* @copyright schukai GmbH
|
146
|
+
* @memberOf Monster.Components.Form
|
147
|
+
* @summary A configurable tab control
|
148
|
+
* @fires Monster.Components.Form.event:monster-fetched
|
149
|
+
*/
|
150
|
+
class ButtonBar extends CustomElement {
|
151
|
+
/**
|
152
|
+
* This method is called by the `instanceof` operator.
|
153
|
+
* @returns {symbol}
|
154
|
+
*/
|
155
|
+
static get [instanceSymbol]() {
|
156
|
+
return Symbol.for("@schukai/component-form/button-bar@@instance");
|
157
|
+
}
|
158
|
+
|
159
|
+
/**
|
160
|
+
* To set the options via the html tag the attribute `data-monster-options` must be used.
|
161
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
162
|
+
*
|
163
|
+
* The individual configuration values can be found in the table.
|
164
|
+
*
|
165
|
+
* @property {Object} templates Template definitions
|
166
|
+
* @property {string} templates.main Main template
|
167
|
+
* @property {Object} labels
|
168
|
+
* @property {Object} popper FloatingUI popper configuration
|
169
|
+
* @property {string} popper.placement=top Placement of the popper
|
170
|
+
* @property {number} popper.middleware [middlerware](https://floating-ui.js.org/docs/middleware) to be used
|
171
|
+
*/
|
172
|
+
get defaults() {
|
173
|
+
const obj = Object.assign({}, super.defaults, {
|
174
|
+
templates: {
|
175
|
+
main: getTemplate(),
|
176
|
+
},
|
177
|
+
labels: {},
|
178
|
+
popper: {
|
179
|
+
placement: "bottom",
|
180
|
+
},
|
181
|
+
});
|
182
|
+
|
183
|
+
initDefaultsFromAttributes.call(this, obj);
|
184
|
+
|
185
|
+
return obj;
|
186
|
+
}
|
187
|
+
|
188
|
+
/**
|
189
|
+
* This method is called internal and should not be called directly.
|
190
|
+
*/
|
191
|
+
[assembleMethodSymbol]() {;
|
192
|
+
super[assembleMethodSymbol]();
|
193
|
+
|
194
|
+
this[dimensionsSymbol] = new Pathfinder({ data: {} });
|
195
|
+
|
196
|
+
initControlReferences.call(this);
|
197
|
+
initEventhandler.call(this);
|
198
|
+
|
199
|
+
// setup structure
|
200
|
+
initButtonBar.call(this).then(() => {
|
201
|
+
initPopperSwitch.call(this);
|
202
|
+
});
|
203
|
+
}
|
204
|
+
|
205
|
+
/**
|
206
|
+
* This method is called internal and should not be called directly.
|
207
|
+
*
|
208
|
+
* @return {CSSStyleSheet[]}
|
209
|
+
*/
|
210
|
+
static getCSSStyleSheet() {
|
211
|
+
return [ButtonBarStyleSheet];
|
212
|
+
}
|
213
|
+
|
214
|
+
/**
|
215
|
+
* This method is called internal and should not be called directly.
|
216
|
+
*
|
217
|
+
* @return {string}
|
218
|
+
*/
|
219
|
+
static getTag() {
|
220
|
+
return "monster-button-bar";
|
221
|
+
}
|
222
|
+
|
223
|
+
/**
|
224
|
+
* This method is called by the dom and should not be called directly.
|
225
|
+
*
|
226
|
+
* @return {void}
|
227
|
+
*/
|
228
|
+
connectedCallback() {
|
229
|
+
super.connectedCallback();
|
230
|
+
|
231
|
+
const document = getDocument();;
|
232
|
+
|
233
|
+
for (const [, type] of Object.entries(["click", "touch"])) {
|
234
|
+
// close on outside ui-events
|
235
|
+
document.addEventListener(type, this[closeEventHandler]);
|
236
|
+
}
|
237
|
+
|
238
|
+
setTimeout(() => {
|
239
|
+
updatePopper.call(this);
|
240
|
+
updateResizeObserverObservation.call(this);
|
241
|
+
}, 0);
|
242
|
+
}
|
243
|
+
|
244
|
+
/**
|
245
|
+
* This method determines which attributes are to be monitored by `attributeChangedCallback()`.
|
246
|
+
*
|
247
|
+
* @return {string[]}
|
248
|
+
*/
|
249
|
+
static get observedAttributes() {
|
250
|
+
const attributes = super.observedAttributes;
|
251
|
+
attributes.push(ATTRIBUTE_POPPER_POSITION);
|
252
|
+
return attributes;
|
253
|
+
}
|
254
|
+
|
255
|
+
/**
|
256
|
+
* This method is called by the dom and should not be called directly.
|
257
|
+
*
|
258
|
+
* @return {void}
|
259
|
+
*/
|
260
|
+
disconnectedCallback() {
|
261
|
+
super.disconnectedCallback();
|
262
|
+
|
263
|
+
const document = getDocument();
|
264
|
+
|
265
|
+
// close on outside ui-events
|
266
|
+
for (const [, type] of Object.entries(["click", "touch"])) {
|
267
|
+
document.removeEventListener(type, this[closeEventHandler]);
|
268
|
+
}
|
269
|
+
|
270
|
+
disconnectResizeObserver.call(this);
|
271
|
+
}
|
272
|
+
|
273
|
+
/**
|
274
|
+
* Close the slotted dialog.
|
275
|
+
* @return {ButtonBar}
|
276
|
+
*/
|
277
|
+
hideDialog() {
|
278
|
+
hide.call(this);
|
279
|
+
return this;
|
280
|
+
}
|
281
|
+
|
282
|
+
/**
|
283
|
+
* Open the slotted dialog.
|
284
|
+
* @return {ButtonBar}
|
285
|
+
*/
|
286
|
+
showDialog() {
|
287
|
+
show.call(this);
|
288
|
+
return this;
|
289
|
+
}
|
290
|
+
|
291
|
+
/**
|
292
|
+
* Toggle the slotted dialog.
|
293
|
+
* @return {ButtonBar}
|
294
|
+
*/
|
295
|
+
toggleDialog() {
|
296
|
+
toggle.call(this);
|
297
|
+
return this;
|
298
|
+
}
|
299
|
+
}
|
300
|
+
|
301
|
+
/**
|
302
|
+
* @private
|
303
|
+
* @param obj
|
304
|
+
* @returns {*}
|
305
|
+
*/
|
306
|
+
function initDefaultsFromAttributes(obj) {;
|
307
|
+
|
308
|
+
if (this.hasAttribute(ATTRIBUTE_POPPER_POSITION)) {
|
309
|
+
obj.popper.placement = this.getAttribute(ATTRIBUTE_POPPER_POSITION);
|
310
|
+
}
|
311
|
+
|
312
|
+
return obj;
|
313
|
+
}
|
314
|
+
|
315
|
+
/**
|
316
|
+
* @private
|
317
|
+
*/
|
318
|
+
function initEventhandler() {
|
319
|
+
const self = this;
|
320
|
+
/**
|
321
|
+
* @param {Event} event
|
322
|
+
*/
|
323
|
+
self[closeEventHandler] = (event) => {
|
324
|
+
const path = event.composedPath();
|
325
|
+
|
326
|
+
for (const [, element] of Object.entries(path)) {
|
327
|
+
if (element === self) {
|
328
|
+
return;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
|
332
|
+
hide.call(self);
|
333
|
+
};
|
334
|
+
|
335
|
+
if (self[buttonBarSlotElementSymbol]) {
|
336
|
+
self[buttonBarSlotElementSymbol].addEventListener("slotchange", (event) => {
|
337
|
+
checkAndRearrangeButtons.call(self);
|
338
|
+
});
|
339
|
+
}
|
340
|
+
|
341
|
+
if (self[popperElementSymbol]) {
|
342
|
+
self[popperElementSymbol].addEventListener("slotchange", (event) => {
|
343
|
+
checkAndRearrangeButtons.call(self);
|
344
|
+
});
|
345
|
+
}
|
346
|
+
|
347
|
+
// data-monster-options
|
348
|
+
self[attributeObserverSymbol][ATTRIBUTE_POPPER_POSITION] = function (value) {
|
349
|
+
self.setOption("classes.button", value);
|
350
|
+
};
|
351
|
+
|
352
|
+
self[resizeObserverSymbol] = new ResizeObserver((entries) => {
|
353
|
+
if (self[timerCallbackSymbol] instanceof DeadMansSwitch) {
|
354
|
+
try {
|
355
|
+
self[timerCallbackSymbol].touch();
|
356
|
+
return;
|
357
|
+
} catch (e) {
|
358
|
+
// catch Error("has already run");
|
359
|
+
if (e.message !== "has already run") {
|
360
|
+
throw e;
|
361
|
+
}
|
362
|
+
delete self[timerCallbackSymbol];
|
363
|
+
}
|
364
|
+
}
|
365
|
+
|
366
|
+
self[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
|
367
|
+
setTimeout(() => {
|
368
|
+
updatePopper.call(self);
|
369
|
+
self[dimensionsSymbol].setVia("data.calculated", false);
|
370
|
+
checkAndRearrangeButtons.call(self);
|
371
|
+
}, 50);
|
372
|
+
});
|
373
|
+
});
|
374
|
+
|
375
|
+
initSlotChangedHandler.call(self);
|
376
|
+
}
|
377
|
+
|
378
|
+
function initSlotChangedHandler() {;
|
379
|
+
|
380
|
+
this[buttonBarElementSymbol].addEventListener("slotchange", () => {
|
381
|
+
updateResizeObserverObservation.call(this);
|
382
|
+
});
|
383
|
+
}
|
384
|
+
|
385
|
+
function checkAndRearrangeButtons() {;
|
386
|
+
|
387
|
+
if (this[dimensionsSymbol].getVia("data.calculated", false) !== true) {
|
388
|
+
calculateButtonBarDimensions.call(this);
|
389
|
+
}
|
390
|
+
|
391
|
+
rearrangeButtons.call(this);
|
392
|
+
}
|
393
|
+
|
394
|
+
/**
|
395
|
+
* @private
|
396
|
+
* @return {Object}
|
397
|
+
*/
|
398
|
+
function rearrangeButtons() {;
|
399
|
+
|
400
|
+
const switchWidth = this[switchElementSymbol].offsetWidth;
|
401
|
+
|
402
|
+
let sum = switchWidth;
|
403
|
+
const space = this[dimensionsSymbol].getVia("data.space");
|
404
|
+
|
405
|
+
const buttonReferences = this[dimensionsSymbol].getVia(
|
406
|
+
"data.buttonReferences",
|
407
|
+
);
|
408
|
+
|
409
|
+
for (const ref of buttonReferences) {
|
410
|
+
sum += this[dimensionsSymbol].getVia(`data.button.${ref}`);
|
411
|
+
|
412
|
+
let elements = getSlottedElements.call(
|
413
|
+
this,
|
414
|
+
'[data-monster-reference="' + ref + '"]',
|
415
|
+
null,
|
416
|
+
); // null ↦ o
|
417
|
+
if (elements.size === 0) {
|
418
|
+
elements = getSlottedElements.call(
|
419
|
+
this,
|
420
|
+
'[data-monster-reference="' + ref + '"]',
|
421
|
+
"popper",
|
422
|
+
); // null ↦ o
|
423
|
+
}
|
424
|
+
|
425
|
+
const nextValue = elements.values().next();
|
426
|
+
if (!nextValue) {
|
427
|
+
continue;
|
428
|
+
}
|
429
|
+
|
430
|
+
const element = nextValue?.value;
|
431
|
+
if (!(element instanceof HTMLElement)) {
|
432
|
+
continue;
|
433
|
+
}
|
434
|
+
|
435
|
+
const buttonLabel = element.innerText;
|
436
|
+
|
437
|
+
if (sum > space) {
|
438
|
+
element.setAttribute("slot", "popper");
|
439
|
+
} else {
|
440
|
+
element.removeAttribute("slot");
|
441
|
+
}
|
442
|
+
}
|
443
|
+
|
444
|
+
const inVisibleButtons = getSlottedElements.call(this, ":scope", "popper"); // null ↦ o
|
445
|
+
if (inVisibleButtons.size > 0) {
|
446
|
+
this[switchElementSymbol].classList.remove("hidden");
|
447
|
+
} else {
|
448
|
+
this[switchElementSymbol].classList.add("hidden");
|
449
|
+
setTimeout(() => {
|
450
|
+
hide.call(this);
|
451
|
+
}, 1);
|
452
|
+
}
|
453
|
+
}
|
454
|
+
|
455
|
+
/**
|
456
|
+
* @private
|
457
|
+
* @param {HTMLElement} node
|
458
|
+
* @return {number}
|
459
|
+
*/
|
460
|
+
function calcBoxWidth(node) {
|
461
|
+
const dim = getGlobal("window").getComputedStyle(node);
|
462
|
+
const bounding = node.getBoundingClientRect();
|
463
|
+
|
464
|
+
return (
|
465
|
+
convertToPixels(dim["border-left-width"]) +
|
466
|
+
convertToPixels(dim["padding-left"]) +
|
467
|
+
convertToPixels(dim["margin-left"]) +
|
468
|
+
bounding["width"] +
|
469
|
+
convertToPixels(dim["border-right-width"]) +
|
470
|
+
convertToPixels(dim["margin-right"]) +
|
471
|
+
convertToPixels(dim["padding-left"])
|
472
|
+
);
|
473
|
+
}
|
474
|
+
|
475
|
+
/**
|
476
|
+
* @private
|
477
|
+
* @return {Object}
|
478
|
+
*/
|
479
|
+
function calculateButtonBarDimensions() {;
|
480
|
+
|
481
|
+
const computedStyle = getComputedStyle(this.parentElement);
|
482
|
+
if (computedStyle === null) {
|
483
|
+
throw new Error("no computed style");
|
484
|
+
}
|
485
|
+
|
486
|
+
let width = this.parentElement.clientWidth;
|
487
|
+
if (computedStyle.getPropertyValue("box-sizing") !== "border-box") {
|
488
|
+
width = computedStyle.getPropertyValue("width");
|
489
|
+
this[dimensionsSymbol].setVia("data.space", convertToPixels(width));
|
490
|
+
} else {
|
491
|
+
const borderWidth = getComputedStyle(this).getPropertyValue(
|
492
|
+
"--monster-border-width",
|
493
|
+
);
|
494
|
+
if (borderWidth === null) {
|
495
|
+
throw new Error("border-width not defined");
|
496
|
+
}
|
497
|
+
|
498
|
+
const borderWidthWithoutUnit = convertToPixels(borderWidth);
|
499
|
+
|
500
|
+
// space to be allocated
|
501
|
+
this[dimensionsSymbol].setVia(
|
502
|
+
"data.space",
|
503
|
+
width - 2 * borderWidthWithoutUnit,
|
504
|
+
);
|
505
|
+
}
|
506
|
+
|
507
|
+
this[dimensionsSymbol].setVia("data.visible", !(width === 0));
|
508
|
+
|
509
|
+
const buttonReferences = [];
|
510
|
+
|
511
|
+
const visibleButtons = getSlottedElements.call(this, ":scope", null); // null ↦ o
|
512
|
+
|
513
|
+
for (const [, button] of visibleButtons.entries()) {
|
514
|
+
if (!button.hasAttribute("data-monster-reference")) {
|
515
|
+
button.setAttribute("data-monster-reference", new ID("vb").toString());
|
516
|
+
}
|
517
|
+
|
518
|
+
const ref = button.getAttribute("data-monster-reference");
|
519
|
+
if (ref === null) continue;
|
520
|
+
|
521
|
+
buttonReferences.push(ref);
|
522
|
+
this[dimensionsSymbol].setVia(
|
523
|
+
`data.button.${ref}`,
|
524
|
+
calcBoxWidth.call(this, button),
|
525
|
+
);
|
526
|
+
}
|
527
|
+
|
528
|
+
const invisibleButtons = getSlottedElements.call(this, ":scope", "popper"); // null ↦ o
|
529
|
+
for (const [, button] of invisibleButtons.entries()) {
|
530
|
+
if (!button.hasAttribute("data-monster-reference")) {
|
531
|
+
button.setAttribute("data-monster-reference", new ID("ib").toString());
|
532
|
+
}
|
533
|
+
|
534
|
+
const ref = button.getAttribute("data-monster-reference");
|
535
|
+
if (ref === null) continue;
|
536
|
+
|
537
|
+
if (ref.indexOf("ib") !== 0) {
|
538
|
+
buttonReferences.push(ref);
|
539
|
+
}
|
540
|
+
}
|
541
|
+
|
542
|
+
this[dimensionsSymbol].setVia("data.calculated", true);
|
543
|
+
this[dimensionsSymbol].setVia("data.buttonReferences", buttonReferences);
|
544
|
+
}
|
545
|
+
|
546
|
+
/**
|
547
|
+
* @private
|
548
|
+
*/
|
549
|
+
function updateResizeObserverObservation() {;
|
550
|
+
|
551
|
+
this[resizeObserverSymbol].disconnect();
|
552
|
+
|
553
|
+
const slottedNodes = getSlottedElements.call(this);
|
554
|
+
slottedNodes.forEach((node) => {
|
555
|
+
this[resizeObserverSymbol].observe(node);
|
556
|
+
});
|
557
|
+
|
558
|
+
if (this.parentElement === null) return;
|
559
|
+
this[resizeObserverSymbol].observe(this.parentElement);
|
560
|
+
}
|
561
|
+
|
562
|
+
/**
|
563
|
+
* @private
|
564
|
+
*/
|
565
|
+
function disconnectResizeObserver() {;
|
566
|
+
if (this[resizeObserverSymbol] instanceof ResizeObserver) {
|
567
|
+
this[resizeObserverSymbol].disconnect();
|
568
|
+
}
|
569
|
+
}
|
570
|
+
|
571
|
+
/**
|
572
|
+
* @private
|
573
|
+
*/
|
574
|
+
function toggle() {
|
575
|
+
if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
|
576
|
+
hide.call(this);
|
577
|
+
} else {
|
578
|
+
show.call(this);
|
579
|
+
}
|
580
|
+
}
|
581
|
+
|
582
|
+
/**
|
583
|
+
* @private
|
584
|
+
*/
|
585
|
+
function hide() {;
|
586
|
+
|
587
|
+
this[popperElementSymbol].style.display = "none";
|
588
|
+
removeAttributeToken(this[controlElementSymbol], "class", "open");
|
589
|
+
}
|
590
|
+
|
591
|
+
/**
|
592
|
+
* @private
|
593
|
+
* @this PopperButton
|
594
|
+
*/
|
595
|
+
function show() {;
|
596
|
+
|
597
|
+
if (this.getOption("disabled", false) === true) {
|
598
|
+
return;
|
599
|
+
}
|
600
|
+
|
601
|
+
if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
|
602
|
+
return;
|
603
|
+
}
|
604
|
+
|
605
|
+
this[popperElementSymbol].style.visibility = "hidden";
|
606
|
+
this[popperElementSymbol].style.display = STYLE_DISPLAY_MODE_BLOCK;
|
607
|
+
|
608
|
+
addAttributeToken(this[controlElementSymbol], "class", "open");
|
609
|
+
|
610
|
+
updatePopper.call(this);
|
611
|
+
}
|
612
|
+
|
613
|
+
/**
|
614
|
+
* @private
|
615
|
+
*/
|
616
|
+
function updatePopper() {;
|
617
|
+
|
618
|
+
if (this[popperElementSymbol].style.display !== STYLE_DISPLAY_MODE_BLOCK) {
|
619
|
+
return;
|
620
|
+
}
|
621
|
+
|
622
|
+
if (this.getOption("disabled", false) === true) {
|
623
|
+
return;
|
624
|
+
}
|
625
|
+
|
626
|
+
positionPopper.call(
|
627
|
+
this,
|
628
|
+
this[switchElementSymbol],
|
629
|
+
this[popperElementSymbol],
|
630
|
+
this.getOption("popper", {}),
|
631
|
+
);
|
632
|
+
}
|
633
|
+
|
634
|
+
/**
|
635
|
+
* @private
|
636
|
+
* @return {Select}
|
637
|
+
* @throws {Error} no shadow-root is defined
|
638
|
+
*/
|
639
|
+
function initControlReferences() {;
|
640
|
+
|
641
|
+
if (!this.shadowRoot) {
|
642
|
+
throw new Error("no shadow-root is defined");
|
643
|
+
}
|
644
|
+
|
645
|
+
this[controlElementSymbol] = this.shadowRoot.querySelector(
|
646
|
+
`[${ATTRIBUTE_ROLE}=control]`,
|
647
|
+
);
|
648
|
+
this[buttonBarElementSymbol] = this.shadowRoot.querySelector(
|
649
|
+
`[${ATTRIBUTE_ROLE}=button-bar]`,
|
650
|
+
);
|
651
|
+
this[popperElementSymbol] = this.shadowRoot.querySelector(
|
652
|
+
`[${ATTRIBUTE_ROLE}=popper]`,
|
653
|
+
);
|
654
|
+
this[popperNavElementSymbol] = this.shadowRoot.querySelector(
|
655
|
+
`[${ATTRIBUTE_ROLE}=popper-nav]`,
|
656
|
+
);
|
657
|
+
this[switchElementSymbol] = this.shadowRoot.querySelector(
|
658
|
+
`[${ATTRIBUTE_ROLE}=switch]`,
|
659
|
+
);
|
660
|
+
|
661
|
+
this[buttonBarSlotElementSymbol] = null;
|
662
|
+
if (this[buttonBarElementSymbol])
|
663
|
+
this[buttonBarSlotElementSymbol] =
|
664
|
+
this[buttonBarElementSymbol].querySelector(`slot`);
|
665
|
+
this[popperSlotElementSymbol] = null;
|
666
|
+
if (this[popperElementSymbol])
|
667
|
+
this[popperSlotElementSymbol] =
|
668
|
+
this[popperElementSymbol].querySelector(`slot`);
|
669
|
+
}
|
670
|
+
|
671
|
+
/**
|
672
|
+
* @private
|
673
|
+
* @return {Promise<unknown>}
|
674
|
+
* @throws {Error} no shadow-root is defined
|
675
|
+
*
|
676
|
+
*/
|
677
|
+
function initButtonBar() {;
|
678
|
+
|
679
|
+
if (!this.shadowRoot) {
|
680
|
+
throw new Error("no shadow-root is defined");
|
681
|
+
}
|
682
|
+
|
683
|
+
return new Processing(() => {
|
684
|
+
checkAndRearrangeButtons.call(this);
|
685
|
+
}).run();
|
686
|
+
}
|
687
|
+
|
688
|
+
/**
|
689
|
+
* @private
|
690
|
+
*/
|
691
|
+
function initPopperSwitch() {;
|
692
|
+
|
693
|
+
/**
|
694
|
+
* @param {Event} event
|
695
|
+
*/
|
696
|
+
this[popperSwitchEventHandler] = (event) => {
|
697
|
+
const element = findTargetElementFromEvent(event, ATTRIBUTE_ROLE, "switch");
|
698
|
+
|
699
|
+
if (element instanceof HTMLButtonElement) {
|
700
|
+
toggle.call(this);
|
701
|
+
}
|
702
|
+
};
|
703
|
+
|
704
|
+
for (const type of ["click", "touch"]) {
|
705
|
+
this[switchElementSymbol].addEventListener(
|
706
|
+
type,
|
707
|
+
this[popperSwitchEventHandler],
|
708
|
+
);
|
709
|
+
}
|
710
|
+
}
|
711
|
+
|
712
|
+
/**
|
713
|
+
* @private
|
714
|
+
* @return {string}
|
715
|
+
*/
|
716
|
+
function getTemplate() {
|
717
|
+
// language=HTML
|
718
|
+
return `
|
719
|
+
<div data-monster-role="control" part="control">
|
720
|
+
<div data-monster-role="button-bar">
|
721
|
+
<slot></slot>
|
722
|
+
<div part="popper-nav" data-monster-role="popper-nav"
|
723
|
+
tabindex="-1">
|
724
|
+
<button part="popper-switch" data-monster-role="switch"
|
725
|
+
class="monster-button-outline-tertiary hidden">
|
726
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
|
727
|
+
viewBox="0 0 16 16">
|
728
|
+
<path d="M9.5 13a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z"/>
|
729
|
+
</svg>
|
730
|
+
</button>
|
731
|
+
</div>
|
732
|
+
</div>
|
733
|
+
<div data-monster-role="popper">
|
734
|
+
<slot name="popper"></slot>
|
735
|
+
</div>
|
736
|
+
</div>`;
|
737
|
+
}
|
738
|
+
|
739
|
+
registerCustomElement(ButtonBar);
|