material 3.5.3 → 3.5.4
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/dist/components/badge/api.js +156 -156
- package/dist/components/badge/badge.js +9 -9
- package/dist/components/badge/config.js +43 -43
- package/dist/components/badge/constants.js +13 -13
- package/dist/components/badge/features.js +75 -75
- package/dist/components/bottom-app-bar/bottom-app-bar.js +98 -98
- package/dist/components/bottom-app-bar/config.js +5 -5
- package/dist/components/bottom-app-bar/constants.js +8 -8
- package/dist/components/bottom-sheet/api.js +52 -52
- package/dist/components/bottom-sheet/bottom-sheet.js +9 -9
- package/dist/components/bottom-sheet/config.js +17 -17
- package/dist/components/bottom-sheet/constants.js +24 -24
- package/dist/components/bottom-sheet/features/drag.js +91 -91
- package/dist/components/bottom-sheet/features/state.js +148 -148
- package/dist/components/bottom-sheet/features/structure.js +85 -85
- package/dist/components/button/api.js +265 -265
- package/dist/components/button/button.js +15 -15
- package/dist/components/button/config.js +39 -39
- package/dist/components/button/constants.js +21 -21
- package/dist/components/button/features/progress.js +167 -167
- package/dist/components/button/features/toggle.js +31 -31
- package/dist/components/button-group/button-group.js +389 -389
- package/dist/components/button-group/config.js +106 -106
- package/dist/components/button-group/constants.js +62 -62
- package/dist/components/card/api.js +88 -88
- package/dist/components/card/card.js +11 -11
- package/dist/components/card/config.js +131 -131
- package/dist/components/card/constants.js +39 -39
- package/dist/components/card/content.js +175 -175
- package/dist/components/carousel/api.js +49 -49
- package/dist/components/carousel/arrangement.js +51 -51
- package/dist/components/carousel/carousel.js +2 -2
- package/dist/components/carousel/config.js +31 -31
- package/dist/components/carousel/constants.js +17 -17
- package/dist/components/carousel/features/scroll.js +469 -469
- package/dist/components/carousel/features/slides.js +125 -125
- package/dist/components/carousel/keylines.js +244 -244
- package/dist/components/carousel/strategy.js +185 -185
- package/dist/components/checkbox/api.js +87 -87
- package/dist/components/checkbox/checkbox.js +55 -55
- package/dist/components/checkbox/config.js +44 -44
- package/dist/components/checkbox/constants.js +10 -10
- package/dist/components/chips/api.js +157 -157
- package/dist/components/chips/chip/chip.js +275 -275
- package/dist/components/chips/chips.js +25 -25
- package/dist/components/chips/config.js +73 -73
- package/dist/components/chips/constants.js +2 -2
- package/dist/components/chips/features/chip-items.js +15 -15
- package/dist/components/chips/features/container.js +39 -39
- package/dist/components/chips/features/controller.js +317 -317
- package/dist/components/chips/features/dom.js +52 -52
- package/dist/components/datepicker/api.js +6 -6
- package/dist/components/datepicker/config.js +3 -3
- package/dist/components/datepicker/constants.js +39 -39
- package/dist/components/datepicker/datepicker.js +675 -675
- package/dist/components/datepicker/render.js +153 -153
- package/dist/components/datepicker/types.js +6 -6
- package/dist/components/datepicker/utils.js +157 -157
- package/dist/components/dialog/api.js +109 -109
- package/dist/components/dialog/config.js +29 -29
- package/dist/components/dialog/constants.js +35 -35
- package/dist/components/dialog/dialog.js +16 -16
- package/dist/components/dialog/features.js +739 -739
- package/dist/components/divider/config.js +4 -4
- package/dist/components/divider/constants.js +10 -10
- package/dist/components/divider/divider.js +6 -6
- package/dist/components/divider/features.js +72 -72
- package/dist/components/drawer/api.js +73 -73
- package/dist/components/drawer/config.js +61 -61
- package/dist/components/drawer/constants.js +32 -32
- package/dist/components/drawer/drawer.js +38 -38
- package/dist/components/drawer/features/headline.js +34 -34
- package/dist/components/drawer/features/items.js +203 -203
- package/dist/components/drawer/features/state.js +206 -206
- package/dist/components/extended-fab/api.js +92 -92
- package/dist/components/extended-fab/config.js +65 -65
- package/dist/components/extended-fab/constants.js +30 -30
- package/dist/components/extended-fab/extended-fab.js +51 -51
- package/dist/components/fab/api.js +65 -65
- package/dist/components/fab/config.js +46 -46
- package/dist/components/fab/constants.js +25 -25
- package/dist/components/fab/fab.js +9 -9
- package/dist/components/fab-menu/config.js +9 -9
- package/dist/components/fab-menu/constants.js +15 -15
- package/dist/components/fab-menu/fab-menu.js +310 -310
- package/dist/components/fab-menu/stagger.js +18 -18
- package/dist/components/icon-button/api.js +195 -195
- package/dist/components/icon-button/config.js +79 -79
- package/dist/components/icon-button/constants.js +43 -43
- package/dist/components/icon-button/features/toggle.js +116 -116
- package/dist/components/icon-button/icon-button.js +15 -15
- package/dist/components/list/api.js +55 -55
- package/dist/components/list/config.js +56 -56
- package/dist/components/list/constants.js +25 -25
- package/dist/components/list/features/anatomy.js +41 -41
- package/dist/components/list/features/renderer.js +136 -136
- package/dist/components/list/features/selection.js +118 -118
- package/dist/components/list/list.js +9 -9
- package/dist/components/loading-indicator/api.js +117 -117
- package/dist/components/loading-indicator/config.js +13 -13
- package/dist/components/loading-indicator/constants.js +23 -23
- package/dist/components/loading-indicator/features/motion.js +33 -33
- package/dist/components/loading-indicator/features/renderer.js +121 -121
- package/dist/components/loading-indicator/loading-indicator.js +8 -8
- package/dist/components/menu/api.js +76 -76
- package/dist/components/menu/config.js +73 -73
- package/dist/components/menu/constants.js +45 -45
- package/dist/components/menu/features/controller.js +507 -507
- package/dist/components/menu/features/keyboard.js +292 -292
- package/dist/components/menu/features/layer.js +13 -13
- package/dist/components/menu/features/loader.js +61 -61
- package/dist/components/menu/features/opener.js +288 -288
- package/dist/components/menu/features/position.js +279 -279
- package/dist/components/menu/features/registry.js +7 -7
- package/dist/components/menu/features/submenu.js +386 -386
- package/dist/components/menu/features/tasks.js +45 -45
- package/dist/components/menu/menu.js +16 -16
- package/dist/components/menu/on-demand.js +138 -138
- package/dist/components/navigation-bar/navigation-bar.js +144 -144
- package/dist/components/navigation-rail/config.js +11 -11
- package/dist/components/navigation-rail/constants.js +8 -8
- package/dist/components/navigation-rail/navigation-rail.js +237 -237
- package/dist/components/progress/api.js +207 -207
- package/dist/components/progress/config.js +137 -137
- package/dist/components/progress/constants.js +88 -88
- package/dist/components/progress/features/canvas.js +291 -291
- package/dist/components/progress/features/circular.js +69 -69
- package/dist/components/progress/features/colors.js +41 -41
- package/dist/components/progress/features/linear.js +96 -96
- package/dist/components/progress/features/motion.js +87 -87
- package/dist/components/progress/features/state.js +35 -35
- package/dist/components/progress/progress.js +11 -11
- package/dist/components/radios/api.js +54 -54
- package/dist/components/radios/config.js +19 -19
- package/dist/components/radios/constants.js +10 -10
- package/dist/components/radios/radio.js +161 -161
- package/dist/components/radios/radios.js +12 -12
- package/dist/components/search/api.js +116 -116
- package/dist/components/search/config.js +66 -66
- package/dist/components/search/constants.js +75 -75
- package/dist/components/search/features/input.js +238 -238
- package/dist/components/search/features/states.js +279 -279
- package/dist/components/search/features/structure.js +212 -212
- package/dist/components/search/features/suggestions.js +234 -234
- package/dist/components/search/search.js +30 -30
- package/dist/components/select/api.js +92 -92
- package/dist/components/select/config.js +46 -46
- package/dist/components/select/constants.js +39 -39
- package/dist/components/select/features.js +485 -485
- package/dist/components/select/select.js +17 -17
- package/dist/components/side-sheet/api.js +46 -46
- package/dist/components/side-sheet/config.js +19 -19
- package/dist/components/side-sheet/constants.js +22 -22
- package/dist/components/side-sheet/features/state.js +132 -132
- package/dist/components/side-sheet/features/structure.js +89 -89
- package/dist/components/side-sheet/side-sheet.js +8 -8
- package/dist/components/slider/config.js +54 -54
- package/dist/components/slider/constants.js +54 -54
- package/dist/components/slider/features/axis.js +14 -14
- package/dist/components/slider/features/controller.js +944 -944
- package/dist/components/slider/features/dom.js +104 -104
- package/dist/components/slider/features/states.js +83 -83
- package/dist/components/slider/slider.js +16 -16
- package/dist/components/snackbar/api.js +199 -199
- package/dist/components/snackbar/config.js +24 -24
- package/dist/components/snackbar/constants.js +41 -41
- package/dist/components/snackbar/features.js +115 -115
- package/dist/components/snackbar/layer.js +72 -72
- package/dist/components/snackbar/position.js +20 -20
- package/dist/components/snackbar/queue.js +89 -89
- package/dist/components/snackbar/snackbar.js +12 -12
- package/dist/components/split-button/api.js +137 -137
- package/dist/components/split-button/config.js +11 -11
- package/dist/components/split-button/constants.js +24 -24
- package/dist/components/split-button/features/buttons.js +35 -35
- package/dist/components/split-button/features/menu.js +12 -12
- package/dist/components/split-button/split-button.js +11 -11
- package/dist/components/switch/api.js +101 -101
- package/dist/components/switch/config.js +20 -20
- package/dist/components/switch/constants.js +29 -29
- package/dist/components/switch/features.js +123 -123
- package/dist/components/switch/switch.js +13 -13
- package/dist/components/tabs/api.js +104 -104
- package/dist/components/tabs/config.js +20 -20
- package/dist/components/tabs/constants.js +40 -40
- package/dist/components/tabs/features.js +159 -159
- package/dist/components/tabs/indicator.js +151 -151
- package/dist/components/tabs/responsive.js +59 -59
- package/dist/components/tabs/tab.js +218 -218
- package/dist/components/tabs/tabs.js +27 -27
- package/dist/components/tabs/utils.js +121 -121
- package/dist/components/text-field/api.js +212 -212
- package/dist/components/text-field/config.js +30 -30
- package/dist/components/text-field/constants.js +54 -54
- package/dist/components/text-field/features/counter.js +51 -51
- package/dist/components/text-field/features/density.js +36 -36
- package/dist/components/text-field/features/error.js +55 -55
- package/dist/components/text-field/features/field.js +30 -30
- package/dist/components/text-field/features/leading-icon.js +52 -52
- package/dist/components/text-field/features/placement.js +146 -146
- package/dist/components/text-field/features/prefix-text.js +48 -48
- package/dist/components/text-field/features/required.js +48 -48
- package/dist/components/text-field/features/suffix-text.js +48 -48
- package/dist/components/text-field/features/supporting-text.js +85 -85
- package/dist/components/text-field/features/trailing-icon.js +88 -88
- package/dist/components/text-field/text-field.js +11 -11
- package/dist/components/timepicker/api.js +275 -275
- package/dist/components/timepicker/config.js +31 -31
- package/dist/components/timepicker/constants.js +52 -52
- package/dist/components/timepicker/dial.js +164 -164
- package/dist/components/timepicker/render.js +400 -400
- package/dist/components/timepicker/timepicker.js +40 -40
- package/dist/components/timepicker/types.js +8 -8
- package/dist/components/timepicker/utils.js +67 -67
- package/dist/components/toolbar/config.js +35 -35
- package/dist/components/toolbar/constants.js +17 -17
- package/dist/components/toolbar/toolbar.js +188 -188
- package/dist/components/tooltip/api.js +309 -309
- package/dist/components/tooltip/config.js +32 -32
- package/dist/components/tooltip/constants.js +38 -38
- package/dist/components/tooltip/tooltip.js +20 -20
- package/dist/components/tooltip/types.js +15 -15
- package/dist/components/top-app-bar/config.js +5 -5
- package/dist/components/top-app-bar/constants.js +25 -25
- package/dist/components/top-app-bar/top-app-bar.js +158 -158
- package/dist/core/canvas/animation.js +30 -30
- package/dist/core/canvas/drawing.js +52 -52
- package/dist/core/canvas/resize.js +47 -47
- package/dist/core/canvas/utils.js +101 -101
- package/dist/core/compose/base.js +5 -5
- package/dist/core/compose/cleanup.js +47 -47
- package/dist/core/compose/component.js +132 -132
- package/dist/core/compose/features/badge.js +56 -56
- package/dist/core/compose/features/checkable.js +37 -37
- package/dist/core/compose/features/constants.js +1 -1
- package/dist/core/compose/features/debounce.js +39 -39
- package/dist/core/compose/features/disabled.js +61 -61
- package/dist/core/compose/features/events.js +19 -19
- package/dist/core/compose/features/icon.js +66 -66
- package/dist/core/compose/features/input.js +63 -63
- package/dist/core/compose/features/lifecycle.js +71 -71
- package/dist/core/compose/features/position.js +31 -31
- package/dist/core/compose/features/ripple.js +76 -76
- package/dist/core/compose/features/size.js +5 -5
- package/dist/core/compose/features/style.js +7 -7
- package/dist/core/compose/features/text.js +49 -49
- package/dist/core/compose/features/textinput.js +164 -164
- package/dist/core/compose/features/textlabel.js +47 -47
- package/dist/core/compose/features/throttle.js +39 -39
- package/dist/core/compose/features/track.js +24 -24
- package/dist/core/compose/features/variant.js +5 -5
- package/dist/core/compose/features/withEvents.js +48 -48
- package/dist/core/compose/pipe.js +4 -4
- package/dist/core/compose/utils/type-guards.js +6 -6
- package/dist/core/config/component.js +54 -54
- package/dist/core/config/global.js +6 -6
- package/dist/core/config.js +9 -9
- package/dist/core/dom/attributes.js +38 -38
- package/dist/core/dom/classes.js +74 -74
- package/dist/core/dom/create.js +133 -133
- package/dist/core/dom/direction.js +28 -28
- package/dist/core/dom/events.js +80 -80
- package/dist/core/dom/focus.js +38 -38
- package/dist/core/dom/form-value.js +10 -10
- package/dist/core/dom/html.js +7 -7
- package/dist/core/dom/layer.js +134 -134
- package/dist/core/dom/roving.js +69 -69
- package/dist/core/dom/utils.js +38 -38
- package/dist/core/navigation/destinations.js +103 -103
- package/dist/core/navigation/ripple.js +39 -39
- package/dist/core/shapes/cubic.js +55 -55
- package/dist/core/shapes/material.js +164 -164
- package/dist/core/shapes/polygon.js +198 -198
- package/dist/core/state/emitter.js +29 -29
- package/dist/core/state/events.js +30 -30
- package/dist/core/state/store.js +55 -55
- package/dist/core/theme/tokens.js +28 -28
- package/dist/core/utils/attributes.js +8 -8
- package/dist/core/utils/background.js +29 -29
- package/dist/core/utils/color.js +21 -21
- package/dist/core/utils/mobile.js +28 -28
- package/dist/core/utils/object.js +17 -17
- package/dist/core/utils/performance.js +111 -111
- package/dist/core/utils/theme.js +49 -49
- package/dist/core/utils/url.js +0 -0
- package/dist/core/utils/warn.js +14 -14
- package/dist/elements/adapter.js +51 -51
- package/dist/elements/badge.js +23 -23
- package/dist/elements/bottom-app-bar.js +32 -32
- package/dist/elements/bottom-sheet.js +81 -81
- package/dist/elements/button-group.js +151 -151
- package/dist/elements/button.js +40 -40
- package/dist/elements/card.js +89 -89
- package/dist/elements/carousel.js +101 -101
- package/dist/elements/checkbox.js +44 -44
- package/dist/elements/chips.js +185 -185
- package/dist/elements/datepicker.js +101 -101
- package/dist/elements/define.js +571 -571
- package/dist/elements/dialog.js +134 -134
- package/dist/elements/divider.js +16 -16
- package/dist/elements/drawer.js +118 -118
- package/dist/elements/extended-fab.js +29 -29
- package/dist/elements/fab-menu.js +58 -58
- package/dist/elements/fab.js +18 -18
- package/dist/elements/form-button.js +14 -14
- package/dist/elements/icon-button.js +42 -42
- package/dist/elements/index.js +87 -87
- package/dist/elements/lifecycle.js +8 -8
- package/dist/elements/list.js +162 -162
- package/dist/elements/loading-indicator.js +19 -19
- package/dist/elements/menu.js +169 -169
- package/dist/elements/navigation-bar.js +58 -58
- package/dist/elements/navigation-rail.js +110 -110
- package/dist/elements/preupgrade/badge.css +1 -1
- package/dist/elements/preupgrade/bottom-app-bar.css +1 -1
- package/dist/elements/preupgrade/bottom-sheet.css +1 -1
- package/dist/elements/preupgrade/button-group.css +1 -1
- package/dist/elements/preupgrade/button.css +1 -1
- package/dist/elements/preupgrade/card.css +1 -1
- package/dist/elements/preupgrade/carousel.css +1 -1
- package/dist/elements/preupgrade/checkbox.css +1 -1
- package/dist/elements/preupgrade/chips.css +1 -1
- package/dist/elements/preupgrade/datepicker.css +1 -1
- package/dist/elements/preupgrade/dialog.css +1 -1
- package/dist/elements/preupgrade/divider.css +1 -1
- package/dist/elements/preupgrade/drawer.css +1 -1
- package/dist/elements/preupgrade/extended-fab.css +1 -1
- package/dist/elements/preupgrade/fab-menu.css +1 -1
- package/dist/elements/preupgrade/fab.css +1 -1
- package/dist/elements/preupgrade/icon-button.css +1 -1
- package/dist/elements/preupgrade/list.css +1 -1
- package/dist/elements/preupgrade/loading-indicator.css +1 -1
- package/dist/elements/preupgrade/menu.css +1 -1
- package/dist/elements/preupgrade/navigation-bar.css +1 -1
- package/dist/elements/preupgrade/navigation-rail.css +1 -1
- package/dist/elements/preupgrade/progress.css +1 -1
- package/dist/elements/preupgrade/radios.css +1 -1
- package/dist/elements/preupgrade/search.css +1 -1
- package/dist/elements/preupgrade/select.css +1 -1
- package/dist/elements/preupgrade/side-sheet.css +1 -1
- package/dist/elements/preupgrade/slider.css +1 -1
- package/dist/elements/preupgrade/snackbar.css +1 -1
- package/dist/elements/preupgrade/split-button.css +1 -1
- package/dist/elements/preupgrade/switch.css +1 -1
- package/dist/elements/preupgrade/tabs.css +1 -1
- package/dist/elements/preupgrade/text-field.css +1 -1
- package/dist/elements/preupgrade/timepicker.css +1 -1
- package/dist/elements/preupgrade/toolbar.css +1 -1
- package/dist/elements/preupgrade/tooltip.css +1 -1
- package/dist/elements/preupgrade/top-app-bar.css +1 -1
- package/dist/elements/preupgrade.css +1 -1
- package/dist/elements/preupgrade.js +0 -1
- package/dist/elements/progress.js +32 -32
- package/dist/elements/radios.js +105 -105
- package/dist/elements/search.js +189 -189
- package/dist/elements/select.js +124 -124
- package/dist/elements/sheet.js +49 -49
- package/dist/elements/side-sheet.js +53 -53
- package/dist/elements/slider.js +117 -117
- package/dist/elements/snackbar.js +45 -45
- package/dist/elements/split-button.js +82 -82
- package/dist/elements/styles.js +27 -27
- package/dist/elements/switch.js +43 -43
- package/dist/elements/tabs.js +96 -96
- package/dist/elements/text-field.js +117 -117
- package/dist/elements/timepicker.js +142 -142
- package/dist/elements/toolbar.js +63 -63
- package/dist/elements/tooltip.js +111 -111
- package/dist/elements/top-app-bar.js +75 -75
- package/dist/package.json +1 -1
- package/dist/react/create.js +113 -113
- package/dist/react/shadow.js +8 -8
- package/dist/solid/create.js +122 -122
- package/dist/solid/shadow.js +6 -6
- package/dist/ssr/react.js +2 -310
- package/dist/ssr/solid.js +1 -16
- package/dist/ssr/svelte.js +1 -73
- package/dist/ssr/vue.js +1 -71
- package/dist/styles/badge.css +1 -1
- package/dist/styles/base.css +1 -1
- package/dist/styles/bottom-app-bar.css +1 -1
- package/dist/styles/bottom-sheet.css +1 -1
- package/dist/styles/button-group.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/chips.css +1 -1
- package/dist/styles/contrast.css +1 -1
- package/dist/styles/datepicker.css +1 -1
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/divider.css +1 -1
- package/dist/styles/drawer.css +1 -1
- package/dist/styles/extended-fab.css +1 -1
- package/dist/styles/fab-menu.css +1 -1
- package/dist/styles/fab.css +1 -1
- package/dist/styles/icon-button.css +1 -1
- package/dist/styles/list.css +1 -1
- package/dist/styles/loading-indicator.css +1 -1
- package/dist/styles/menu.css +1 -1
- package/dist/styles/navigation-bar.css +1 -1
- package/dist/styles/navigation-rail.css +1 -1
- package/dist/styles/progress.css +1 -1
- package/dist/styles/radios.css +1 -1
- package/dist/styles/search.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/side-sheet.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/split-button.css +1 -1
- package/dist/styles/switch.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/timepicker.css +1 -1
- package/dist/styles/toolbar.css +1 -1
- package/dist/styles/tooltip.css +1 -1
- package/dist/styles/top-app-bar.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/styles/utilities.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/themes/autumn-contrast.css +1 -1
- package/dist/themes/autumn.css +1 -1
- package/dist/themes/baseline-contrast.css +1 -1
- package/dist/themes/baseline.css +1 -1
- package/dist/themes/brownbeige-contrast.css +1 -1
- package/dist/themes/brownbeige.css +1 -1
- package/dist/themes/content-contrast.css +1 -1
- package/dist/themes/content.css +1 -1
- package/dist/themes/desert-contrast.css +1 -1
- package/dist/themes/desert.css +1 -1
- package/dist/themes/expressive-contrast.css +1 -1
- package/dist/themes/expressive.css +1 -1
- package/dist/themes/fidelity-contrast.css +1 -1
- package/dist/themes/fidelity.css +1 -1
- package/dist/themes/forest-contrast.css +1 -1
- package/dist/themes/forest.css +1 -1
- package/dist/themes/fruit-salad-contrast.css +1 -1
- package/dist/themes/fruit-salad.css +1 -1
- package/dist/themes/highcontrast-contrast.css +1 -1
- package/dist/themes/highcontrast.css +1 -1
- package/dist/themes/monochrome-contrast.css +1 -1
- package/dist/themes/monochrome.css +1 -1
- package/dist/themes/neutral-contrast.css +1 -1
- package/dist/themes/neutral.css +1 -1
- package/dist/themes/ocean-contrast.css +1 -1
- package/dist/themes/ocean.css +1 -1
- package/dist/themes/rainbow-contrast.css +1 -1
- package/dist/themes/rainbow.css +1 -1
- package/dist/themes/sageivory-contrast.css +1 -1
- package/dist/themes/sageivory.css +1 -1
- package/dist/themes/spring-contrast.css +1 -1
- package/dist/themes/spring.css +1 -1
- package/dist/themes/summer-contrast.css +1 -1
- package/dist/themes/summer.css +1 -1
- package/dist/themes/sunset-contrast.css +1 -1
- package/dist/themes/sunset.css +1 -1
- package/dist/themes/tealcaramel-contrast.css +1 -1
- package/dist/themes/tealcaramel.css +1 -1
- package/dist/themes/vibrant-contrast.css +1 -1
- package/dist/themes/vibrant.css +1 -1
- package/dist/vue/create.js +123 -123
- package/dist/vue/shadow.js +6 -6
- package/package.json +1 -1
package/dist/elements/define.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
if (kind === "a" && !f)
|
|
3
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
5
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
6
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
7
7
|
};
|
|
8
8
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
if (kind === "m")
|
|
10
|
+
throw new TypeError("Private method is not writable");
|
|
11
|
+
if (kind === "a" && !f)
|
|
12
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
13
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
14
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
16
|
};
|
|
17
17
|
import { MOUNT, DISPOSE } from "./lifecycle.js";
|
|
18
18
|
import { PREFIX } from "../core/config.js";
|
|
@@ -22,586 +22,586 @@ export { DEFAULT_PREFIX };
|
|
|
22
22
|
export const SHADOW_BASE_STYLES = ["ripple"];
|
|
23
23
|
const BASE_HOST_DISPLAY = ":host{display:inline-block}";
|
|
24
24
|
const BASE_HOST_ALWAYS = ":host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}" +
|
|
25
|
-
|
|
25
|
+
"@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}";
|
|
26
26
|
export const BASE_HOST_STYLES = BASE_HOST_DISPLAY + BASE_HOST_ALWAYS;
|
|
27
27
|
const ownsHostDisplay = (hostStyles) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
28
|
+
const css = hostStyles
|
|
29
|
+
.replace(/\/\*[\s\S]*?\*\//g, "")
|
|
30
|
+
.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g, "");
|
|
31
|
+
let depth = 0;
|
|
32
|
+
for (let i = 0; i < css.length; i++) {
|
|
33
|
+
const char = css[i];
|
|
34
|
+
if (char === "{") {
|
|
35
|
+
depth++;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (char === "}") {
|
|
39
|
+
depth--;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (char !== ":" || depth !== 0 || !css.startsWith(":host", i))
|
|
43
|
+
continue;
|
|
44
|
+
let block = i + 5;
|
|
45
|
+
while (/\s/.test(css[block] ?? ""))
|
|
46
|
+
block++;
|
|
47
|
+
if (css[block] !== "{")
|
|
48
|
+
continue;
|
|
49
|
+
let before = i;
|
|
50
|
+
while (before > 0 && /\s/.test(css[before - 1]))
|
|
51
|
+
before--;
|
|
52
|
+
if (before > 0 && css[before - 1] !== "}")
|
|
53
|
+
continue;
|
|
54
|
+
let flat = "";
|
|
55
|
+
let closed = false;
|
|
56
|
+
for (let j = block + 1; j < css.length; j++) {
|
|
57
|
+
const char2 = css[j];
|
|
58
|
+
if (char2 === "}") {
|
|
59
|
+
closed = true;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
if (char2 === "{") {
|
|
63
|
+
flat = "";
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
flat += char2;
|
|
67
|
+
}
|
|
68
|
+
if (closed && /(?:^|;)\s*display\s*:/.test(flat))
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
72
|
};
|
|
73
73
|
export const hostStyleText = (spec) => {
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const own = spec.hostStyles ?? "";
|
|
75
|
+
return (ownsHostDisplay(own) ? BASE_HOST_ALWAYS : BASE_HOST_STYLES) + own;
|
|
76
76
|
};
|
|
77
77
|
const camel = (name) => name.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
78
78
|
const kebab = (name) => name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
79
79
|
const read = (host, name, type) => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
80
|
+
const raw = host.getAttribute(name);
|
|
81
|
+
if (type === "boolean")
|
|
82
|
+
return raw !== null;
|
|
83
|
+
if (raw === null)
|
|
84
|
+
return null;
|
|
85
|
+
if (type === "number") {
|
|
86
|
+
const n = Number(raw);
|
|
87
|
+
return Number.isNaN(n) ? null : n;
|
|
88
|
+
}
|
|
89
|
+
return raw;
|
|
90
90
|
};
|
|
91
91
|
const write = (host, name, type, value) => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
if (type === "boolean")
|
|
93
|
+
host.toggleAttribute(name, value !== false && value !== null && value !== undefined);
|
|
94
|
+
else if (value === null || value === undefined)
|
|
95
|
+
host.removeAttribute(name);
|
|
96
|
+
else
|
|
97
|
+
host.setAttribute(name, String(value));
|
|
98
98
|
};
|
|
99
99
|
const CLASS_PREFIX = `${PREFIX}-`;
|
|
100
100
|
const partNames = (node) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
const names = [];
|
|
102
|
+
for (const name of Array.from(node.classList)) {
|
|
103
|
+
if (!name.startsWith(CLASS_PREFIX) || /--/.test(name))
|
|
104
|
+
continue;
|
|
105
|
+
const bem = name.slice(CLASS_PREFIX.length);
|
|
106
|
+
const at = bem.indexOf("__");
|
|
107
|
+
const part = at < 0 ? bem : bem.slice(at + 2);
|
|
108
|
+
if (!names.includes(part))
|
|
109
|
+
names.push(part);
|
|
110
|
+
}
|
|
111
|
+
return names;
|
|
112
112
|
};
|
|
113
113
|
const isDeclarativeTemplate = (node) => node.nodeType === 1 && node.localName === "template" && node.hasAttribute("shadowrootmode");
|
|
114
114
|
const removeDeclarativeTemplates = (host) => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
for (const child of Array.from(host.children))
|
|
116
|
+
if (isDeclarativeTemplate(child))
|
|
117
|
+
child.remove();
|
|
118
118
|
};
|
|
119
119
|
const hasContent = (host) => Array.from(host.childNodes).some((node) => (node.nodeType === 1 && !isDeclarativeTemplate(node)) || (node.nodeType === 3 && (node.textContent ?? "").trim() !== ""));
|
|
120
120
|
export const createElementClass = (spec) => {
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
121
|
+
var _MElement_instances, _MElement_pending, _MElement_restoreState, _MElement_silent, _MElement_dirty, _MElement_cleanup, _MElement_observer, _MElement_parts, _MElement_slot, _MElement_quietly, _MElement_upgradeProperties, _MElement_config, _MElement_build, _MElement_exposeParts, _MElement_teardown, _MElement_rebuild, _MElement_syncForm;
|
|
122
|
+
const backed = [...(spec.model ? [spec.model] : []), ...(spec.defaults ?? [])];
|
|
123
|
+
const backing = new Set(backed.map(kebab));
|
|
124
|
+
class MElement extends HTMLElement {
|
|
125
|
+
get dirty() {
|
|
126
|
+
return __classPrivateFieldGet(this, _MElement_dirty, "f");
|
|
127
|
+
}
|
|
128
|
+
constructor() {
|
|
129
|
+
super();
|
|
130
|
+
_MElement_instances.add(this);
|
|
131
|
+
this.component = null;
|
|
132
|
+
_MElement_pending.set(this, new Map());
|
|
133
|
+
_MElement_restoreState.set(this, null);
|
|
134
|
+
_MElement_silent.set(this, 0);
|
|
135
|
+
_MElement_dirty.set(this, false);
|
|
136
|
+
_MElement_cleanup.set(this, []);
|
|
137
|
+
_MElement_observer.set(this, null);
|
|
138
|
+
_MElement_parts.set(this, null);
|
|
139
|
+
_MElement_slot.set(this, null);
|
|
140
|
+
this.attachShadow({ mode: "open", delegatesFocus: true });
|
|
141
|
+
this.internals = spec.form && typeof this.attachInternals === "function" ? this.attachInternals() : null;
|
|
142
|
+
if (backed.length) {
|
|
143
|
+
for (const [event, eventSpec] of Object.entries(spec.events ?? {})) {
|
|
144
|
+
if (eventSpec.state)
|
|
145
|
+
continue;
|
|
146
|
+
this.addEventListener(event, (e) => {
|
|
147
|
+
if (e.target === this)
|
|
148
|
+
__classPrivateFieldSet(this, _MElement_dirty, true, "f");
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
[(_MElement_pending = new WeakMap(), _MElement_restoreState = new WeakMap(), _MElement_silent = new WeakMap(), _MElement_dirty = new WeakMap(), _MElement_cleanup = new WeakMap(), _MElement_observer = new WeakMap(), _MElement_parts = new WeakMap(), _MElement_slot = new WeakMap(), _MElement_instances = new WeakSet(), MOUNT)]() {
|
|
154
|
+
this.connectedCallback();
|
|
155
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_exposeParts).call(this, this.shadowRoot);
|
|
156
|
+
}
|
|
157
|
+
[DISPOSE]() {
|
|
158
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_teardown).call(this);
|
|
159
|
+
}
|
|
160
|
+
connectedCallback() {
|
|
161
|
+
if (spec.marker)
|
|
162
|
+
this.toggleAttribute(spec.marker, true);
|
|
163
|
+
removeDeclarativeTemplates(this);
|
|
164
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_upgradeProperties).call(this);
|
|
165
|
+
if (!this.component)
|
|
166
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_build).call(this);
|
|
167
|
+
}
|
|
168
|
+
disconnectedCallback() {
|
|
169
|
+
queueMicrotask(() => {
|
|
170
|
+
if (!this.isConnected)
|
|
171
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_teardown).call(this);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
attributeChangedCallback(name, previous, next) {
|
|
175
|
+
if (!this.component || previous === next)
|
|
176
|
+
return;
|
|
177
|
+
if (spec.slot && name === spec.slot.attribute) {
|
|
178
|
+
if (__classPrivateFieldGet(this, _MElement_slot, "f"))
|
|
179
|
+
__classPrivateFieldGet(this, _MElement_slot, "f").textContent = next ?? "";
|
|
180
|
+
else if (next)
|
|
181
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_rebuild).call(this, true);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const attribute = spec.attributes?.[name];
|
|
185
|
+
if (!attribute)
|
|
186
|
+
return;
|
|
187
|
+
if (__classPrivateFieldGet(this, _MElement_dirty, "f") && backing.has(name))
|
|
188
|
+
return;
|
|
189
|
+
if (attribute.update) {
|
|
190
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_quietly).call(this, () => attribute.update?.(this.component, read(this, name, attribute.type), this));
|
|
191
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_syncForm).call(this);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_rebuild).call(this, true);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
formResetCallback() {
|
|
198
|
+
__classPrivateFieldSet(this, _MElement_dirty, false, "f");
|
|
199
|
+
__classPrivateFieldGet(this, _MElement_pending, "f").clear();
|
|
200
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_rebuild).call(this, false);
|
|
201
|
+
}
|
|
202
|
+
formStateRestoreCallback(state) {
|
|
203
|
+
if (typeof state !== "string" || !spec.form?.restore)
|
|
204
|
+
return;
|
|
205
|
+
__classPrivateFieldSet(this, _MElement_dirty, true, "f");
|
|
206
|
+
if (!this.component) {
|
|
207
|
+
__classPrivateFieldSet(this, _MElement_restoreState, state, "f");
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_quietly).call(this, () => spec.form?.restore?.(this.component, state));
|
|
211
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_syncForm).call(this);
|
|
212
|
+
}
|
|
213
|
+
formDisabledCallback(disabled) {
|
|
214
|
+
const form = spec.form;
|
|
215
|
+
if (this.component && form?.disable)
|
|
216
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_quietly).call(this, () => form.disable?.(this.component, disabled));
|
|
217
|
+
}
|
|
218
|
+
getProperty(name) {
|
|
219
|
+
const property = spec.properties?.[name];
|
|
220
|
+
if (!property)
|
|
221
|
+
return undefined;
|
|
222
|
+
return this.component ? property.get(this.component) : __classPrivateFieldGet(this, _MElement_pending, "f").get(name);
|
|
223
|
+
}
|
|
224
|
+
setProperty(name, value) {
|
|
225
|
+
const property = spec.properties?.[name];
|
|
226
|
+
if (!property)
|
|
227
|
+
return;
|
|
228
|
+
if (backed.includes(name))
|
|
229
|
+
__classPrivateFieldSet(this, _MElement_dirty, true, "f");
|
|
230
|
+
if (!this.component) {
|
|
231
|
+
__classPrivateFieldGet(this, _MElement_pending, "f").set(name, value);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_quietly).call(this, () => property.set(this.component, value));
|
|
235
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_syncForm).call(this);
|
|
236
|
+
}
|
|
237
|
+
callMethod(name, args) {
|
|
238
|
+
const component = this.component;
|
|
239
|
+
const method = component?.[name];
|
|
240
|
+
if (typeof method !== "function")
|
|
241
|
+
return undefined;
|
|
242
|
+
const before = backed.map((property) => this.getProperty(property));
|
|
243
|
+
const result = method.apply(component, args);
|
|
244
|
+
if (backed.some((property, i) => this.getProperty(property) !== before[i]))
|
|
245
|
+
__classPrivateFieldSet(this, _MElement_dirty, true, "f");
|
|
246
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_syncForm).call(this);
|
|
247
|
+
return result === component ? this : result;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
_MElement_quietly = function _MElement_quietly(fn) {
|
|
251
|
+
var _a, _b;
|
|
252
|
+
__classPrivateFieldSet(this, _MElement_silent, (_a = __classPrivateFieldGet(this, _MElement_silent, "f"), _a++, _a), "f");
|
|
253
|
+
try {
|
|
254
|
+
fn();
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
__classPrivateFieldSet(this, _MElement_silent, (_b = __classPrivateFieldGet(this, _MElement_silent, "f"), _b--, _b), "f");
|
|
258
|
+
}
|
|
259
|
+
}, _MElement_upgradeProperties = function _MElement_upgradeProperties() {
|
|
260
|
+
const names = [
|
|
261
|
+
...Object.keys(spec.attributes ?? {}).map(camel),
|
|
262
|
+
...Object.keys(spec.properties ?? {}),
|
|
263
|
+
...(spec.slot ? [camel(spec.slot.attribute)] : []),
|
|
264
|
+
];
|
|
265
|
+
const self = this;
|
|
266
|
+
for (const name of names) {
|
|
267
|
+
if (Object.prototype.hasOwnProperty.call(this, name)) {
|
|
268
|
+
const value = self[name];
|
|
269
|
+
delete self[name];
|
|
270
|
+
self[name] = value;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}, _MElement_config = function _MElement_config() {
|
|
274
|
+
const config = {};
|
|
275
|
+
for (const [name, attribute] of Object.entries(spec.attributes ?? {})) {
|
|
276
|
+
if (!attribute.config)
|
|
277
|
+
continue;
|
|
278
|
+
const value = read(this, name, attribute.type);
|
|
279
|
+
if (value !== null && value !== false)
|
|
280
|
+
config[attribute.config] = value;
|
|
281
|
+
}
|
|
282
|
+
if (spec.slot) {
|
|
283
|
+
const text = this.getAttribute(spec.slot.attribute);
|
|
284
|
+
if (text || hasContent(this)) {
|
|
285
|
+
const slot = document.createElement("slot");
|
|
286
|
+
slot.textContent = text ?? "";
|
|
287
|
+
config[spec.slot.config] = slot;
|
|
288
|
+
__classPrivateFieldSet(this, _MElement_slot, slot, "f");
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
Object.assign(config, spec.config?.(this));
|
|
292
|
+
for (const [name, property] of Object.entries(spec.properties ?? {})) {
|
|
293
|
+
if (property.config && __classPrivateFieldGet(this, _MElement_pending, "f").has(name)) {
|
|
294
|
+
config[property.config] = __classPrivateFieldGet(this, _MElement_pending, "f").get(name);
|
|
295
|
+
__classPrivateFieldGet(this, _MElement_pending, "f").delete(name);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return config;
|
|
299
|
+
}, _MElement_build = function _MElement_build() {
|
|
300
|
+
trackDirection(this);
|
|
301
|
+
const root = this.shadowRoot;
|
|
302
|
+
applyStyles(root, [`host:${spec.name}`, ...SHADOW_BASE_STYLES, ...spec.styles]);
|
|
303
|
+
const component = spec.create(__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_config).call(this));
|
|
304
|
+
this.component = component;
|
|
305
|
+
if (__classPrivateFieldGet(this, _MElement_slot, "f") && !component.element.contains(__classPrivateFieldGet(this, _MElement_slot, "f")))
|
|
306
|
+
__classPrivateFieldSet(this, _MElement_slot, null, "f");
|
|
307
|
+
root.append(component.element);
|
|
308
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_exposeParts).call(this, root);
|
|
309
|
+
const events = component;
|
|
310
|
+
for (const [event, eventSpec] of Object.entries(spec.events ?? {})) {
|
|
311
|
+
const handler = (payload) => {
|
|
312
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_syncForm).call(this);
|
|
313
|
+
if (__classPrivateFieldGet(this, _MElement_silent, "f"))
|
|
314
|
+
return;
|
|
315
|
+
const detail = eventSpec.detail ? eventSpec.detail(payload) : payload;
|
|
316
|
+
this.dispatchEvent(new CustomEvent(event, { detail, bubbles: true, composed: true }));
|
|
317
|
+
};
|
|
318
|
+
if ( /*#__PURE__*/(() => {
|
|
319
|
+
try {
|
|
320
|
+
return process.env.NODE_ENV !== "production";
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
})() && process.env.NODE_ENV !== "production")
|
|
326
|
+
Object.assign(handler, { __h: this });
|
|
327
|
+
events.on?.(event, handler);
|
|
328
|
+
__classPrivateFieldGet(this, _MElement_cleanup, "f").push(() => events.off?.(event, handler));
|
|
329
|
+
}
|
|
330
|
+
for (const event of spec.form?.events ?? []) {
|
|
331
|
+
if (spec.events?.[event])
|
|
332
|
+
continue;
|
|
333
|
+
const handler = () => __classPrivateFieldGet(this, _MElement_instances, "m", _MElement_syncForm).call(this);
|
|
334
|
+
events.on?.(event, handler);
|
|
335
|
+
__classPrivateFieldGet(this, _MElement_cleanup, "f").push(() => events.off?.(event, handler));
|
|
336
|
+
}
|
|
337
|
+
for (const [name, value] of __classPrivateFieldGet(this, _MElement_pending, "f")) {
|
|
338
|
+
const property = spec.properties?.[name];
|
|
339
|
+
if (property)
|
|
340
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_quietly).call(this, () => property.set(component, value));
|
|
341
|
+
}
|
|
342
|
+
__classPrivateFieldGet(this, _MElement_pending, "f").clear();
|
|
343
|
+
if (__classPrivateFieldGet(this, _MElement_restoreState, "f") !== null) {
|
|
344
|
+
const state = __classPrivateFieldGet(this, _MElement_restoreState, "f");
|
|
345
|
+
__classPrivateFieldSet(this, _MElement_restoreState, null, "f");
|
|
346
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_quietly).call(this, () => spec.form?.restore?.(component, state));
|
|
347
|
+
}
|
|
348
|
+
if (spec.form?.activate) {
|
|
349
|
+
const onClick = (event) => {
|
|
350
|
+
if (event.composedPath()[0] === this)
|
|
351
|
+
spec.form?.activate?.(component);
|
|
352
|
+
};
|
|
353
|
+
this.addEventListener("click", onClick);
|
|
354
|
+
__classPrivateFieldGet(this, _MElement_cleanup, "f").push(() => this.removeEventListener("click", onClick));
|
|
355
|
+
}
|
|
356
|
+
const cleanup = spec.setup?.(this, component);
|
|
357
|
+
if (cleanup)
|
|
358
|
+
__classPrivateFieldGet(this, _MElement_cleanup, "f").push(cleanup);
|
|
359
|
+
{
|
|
360
|
+
__classPrivateFieldSet(this, _MElement_observer, new MutationObserver(() => {
|
|
361
|
+
removeDeclarativeTemplates(this);
|
|
362
|
+
const observe = spec.observeChildren;
|
|
363
|
+
let updated = false;
|
|
364
|
+
const component = this.component;
|
|
365
|
+
if (typeof observe === "function" && component) {
|
|
366
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_quietly).call(this, () => {
|
|
367
|
+
updated = observe(this, component);
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
if (updated) {
|
|
371
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_syncForm).call(this);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (observe || (spec.slot && !__classPrivateFieldGet(this, _MElement_slot, "f") && hasContent(this)))
|
|
375
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_rebuild).call(this, true);
|
|
376
|
+
}), "f");
|
|
377
|
+
__classPrivateFieldGet(this, _MElement_observer, "f").observe(this, {
|
|
378
|
+
childList: true,
|
|
379
|
+
subtree: !!spec.observeChildren,
|
|
380
|
+
attributes: !!spec.observeChildren,
|
|
381
|
+
characterData: !!spec.observeChildren,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_syncForm).call(this);
|
|
385
|
+
}, _MElement_exposeParts = function _MElement_exposeParts(root) {
|
|
386
|
+
const name = (node) => {
|
|
387
|
+
const names = partNames(node);
|
|
388
|
+
if (spec.slot && __classPrivateFieldGet(this, _MElement_slot, "f")?.parentElement === node && !names.includes(spec.slot.attribute)) {
|
|
389
|
+
names.push(spec.slot.attribute);
|
|
390
|
+
}
|
|
391
|
+
const value = names.join(" ");
|
|
392
|
+
if ((node.getAttribute("part") ?? "") === value)
|
|
393
|
+
return;
|
|
394
|
+
if (value)
|
|
395
|
+
node.setAttribute("part", value);
|
|
396
|
+
else
|
|
397
|
+
node.removeAttribute("part");
|
|
398
|
+
};
|
|
399
|
+
const nameAll = (node) => {
|
|
400
|
+
name(node);
|
|
401
|
+
for (const child of Array.from(node.querySelectorAll("*")))
|
|
402
|
+
name(child);
|
|
403
|
+
};
|
|
404
|
+
for (const child of Array.from(root.children))
|
|
405
|
+
nameAll(child);
|
|
406
|
+
__classPrivateFieldSet(this, _MElement_parts, __classPrivateFieldGet(this, _MElement_parts, "f") ?? new MutationObserver((records) => {
|
|
407
|
+
for (const record of records) {
|
|
408
|
+
for (const node of Array.from(record.addedNodes))
|
|
409
|
+
if (node.nodeType === 1)
|
|
410
|
+
nameAll(node);
|
|
411
|
+
}
|
|
412
|
+
}), "f");
|
|
413
|
+
__classPrivateFieldGet(this, _MElement_parts, "f").observe(root, { childList: true, subtree: true });
|
|
414
|
+
}, _MElement_teardown = function _MElement_teardown() {
|
|
415
|
+
const component = this.component;
|
|
416
|
+
const observer = __classPrivateFieldGet(this, _MElement_observer, "f");
|
|
417
|
+
const parts = __classPrivateFieldGet(this, _MElement_parts, "f");
|
|
418
|
+
__classPrivateFieldSet(this, _MElement_observer, null, "f");
|
|
419
|
+
__classPrivateFieldSet(this, _MElement_parts, null, "f");
|
|
420
|
+
let failure;
|
|
421
|
+
let failed = false;
|
|
422
|
+
const attempt = (cleanup) => {
|
|
423
|
+
try {
|
|
424
|
+
cleanup();
|
|
425
|
+
}
|
|
426
|
+
catch (error) {
|
|
427
|
+
if (!failed)
|
|
428
|
+
failure = error;
|
|
429
|
+
failed = true;
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
attempt(() => observer?.disconnect());
|
|
433
|
+
attempt(() => parts?.disconnect());
|
|
434
|
+
for (const cleanup of __classPrivateFieldGet(this, _MElement_cleanup, "f").splice(0))
|
|
435
|
+
attempt(cleanup);
|
|
436
|
+
if (component) {
|
|
437
|
+
attempt(() => component.destroy());
|
|
438
|
+
attempt(() => component.element.remove());
|
|
439
|
+
}
|
|
440
|
+
this.component = null;
|
|
441
|
+
__classPrivateFieldSet(this, _MElement_slot, null, "f");
|
|
442
|
+
if (failed)
|
|
443
|
+
throw failure;
|
|
444
|
+
}, _MElement_rebuild = function _MElement_rebuild(keepState) {
|
|
445
|
+
if (this.component && keepState) {
|
|
446
|
+
for (const [name, property] of Object.entries(spec.properties ?? {})) {
|
|
447
|
+
if (!__classPrivateFieldGet(this, _MElement_dirty, "f") && backed.includes(name))
|
|
448
|
+
continue;
|
|
449
|
+
__classPrivateFieldGet(this, _MElement_pending, "f").set(name, property.get(this.component));
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_teardown).call(this);
|
|
453
|
+
if (this.isConnected)
|
|
454
|
+
__classPrivateFieldGet(this, _MElement_instances, "m", _MElement_build).call(this);
|
|
455
|
+
}, _MElement_syncForm = function _MElement_syncForm() {
|
|
456
|
+
const form = spec.form;
|
|
457
|
+
const internals = this.internals;
|
|
458
|
+
if (!form || !internals || !this.component)
|
|
459
|
+
return;
|
|
460
|
+
const value = form.value(this.component, this);
|
|
461
|
+
if (form.state)
|
|
462
|
+
internals.setFormValue(value, form.state(this.component));
|
|
463
|
+
else
|
|
464
|
+
internals.setFormValue(value);
|
|
465
|
+
const control = form.control?.(this.component);
|
|
466
|
+
if (control) {
|
|
467
|
+
const validity = control.validity;
|
|
468
|
+
if (!(validity.valid && internals.validity.valid)) {
|
|
469
|
+
internals.setValidity(validity, control.validationMessage, control);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
MElement.formAssociated = !!spec.form;
|
|
474
|
+
MElement.observedAttributes = [
|
|
475
|
+
...Object.keys(spec.attributes ?? {}),
|
|
476
|
+
...(spec.slot ? [spec.slot.attribute] : []),
|
|
477
|
+
];
|
|
478
|
+
if ( /*#__PURE__*/(() => {
|
|
479
|
+
try {
|
|
480
|
+
return process.env.NODE_ENV !== "production";
|
|
481
|
+
}
|
|
482
|
+
catch {
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
})() && process.env.NODE_ENV !== "production") {
|
|
486
|
+
const add = MElement.prototype.addEventListener;
|
|
487
|
+
MElement.prototype.addEventListener = function (type, listener, options) {
|
|
488
|
+
Reflect.apply(add, this, [type, listener, options]);
|
|
489
|
+
if (listener)
|
|
490
|
+
spec.events?.[type]?.listen?.(this);
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
const proto = MElement.prototype;
|
|
494
|
+
for (const [name, attribute] of Object.entries(spec.attributes ?? {})) {
|
|
495
|
+
const property = camel(name);
|
|
496
|
+
if (property in proto || spec.properties?.[property])
|
|
497
|
+
continue;
|
|
498
|
+
Object.defineProperty(proto, property, {
|
|
499
|
+
configurable: true,
|
|
500
|
+
get() {
|
|
501
|
+
return read(this, name, attribute.type);
|
|
502
|
+
},
|
|
503
|
+
set(value) {
|
|
504
|
+
write(this, name, attribute.type, value);
|
|
505
|
+
},
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
if (spec.slot) {
|
|
509
|
+
const { attribute } = spec.slot;
|
|
510
|
+
const property = camel(attribute);
|
|
511
|
+
if (!(property in proto) && !spec.properties?.[property]) {
|
|
512
|
+
Object.defineProperty(proto, property, {
|
|
513
|
+
configurable: true,
|
|
514
|
+
get() {
|
|
515
|
+
return this.getAttribute(attribute) ?? (this.textContent ?? "").trim();
|
|
516
|
+
},
|
|
517
|
+
set(value) {
|
|
518
|
+
write(this, attribute, "string", value);
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
for (const name of Object.keys(spec.properties ?? {})) {
|
|
524
|
+
Object.defineProperty(proto, name, {
|
|
525
|
+
configurable: true,
|
|
526
|
+
get() {
|
|
527
|
+
return this.getProperty(name);
|
|
528
|
+
},
|
|
529
|
+
set(value) {
|
|
530
|
+
this.setProperty(name, value);
|
|
531
|
+
},
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
for (const name of spec.methods ?? []) {
|
|
535
|
+
Object.defineProperty(proto, name, {
|
|
536
|
+
configurable: true,
|
|
537
|
+
value(...args) {
|
|
538
|
+
return this.callMethod(name, args);
|
|
539
|
+
},
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
return MElement;
|
|
543
543
|
};
|
|
544
544
|
export const createDeclarationClass = (attributes) => {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
545
|
+
const names = Object.keys(attributes).map(camel);
|
|
546
|
+
class Declaration extends HTMLElement {
|
|
547
|
+
connectedCallback() {
|
|
548
|
+
removeDeclarativeTemplates(this);
|
|
549
|
+
const self = this;
|
|
550
|
+
for (const name of names) {
|
|
551
|
+
if (Object.prototype.hasOwnProperty.call(this, name)) {
|
|
552
|
+
const value = self[name];
|
|
553
|
+
delete self[name];
|
|
554
|
+
self[name] = value;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
for (const [name, attribute] of Object.entries(attributes)) {
|
|
560
|
+
Object.defineProperty(Declaration.prototype, camel(name), {
|
|
561
|
+
configurable: true,
|
|
562
|
+
get() {
|
|
563
|
+
return read(this, name, attribute.type);
|
|
564
|
+
},
|
|
565
|
+
set(value) {
|
|
566
|
+
write(this, name, attribute.type, value);
|
|
567
|
+
},
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
return Declaration;
|
|
571
571
|
};
|
|
572
572
|
export const defineElement = (spec) => {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
573
|
+
let element = null;
|
|
574
|
+
const getElement = () => (element ?? (element = createElementClass(spec)));
|
|
575
|
+
const registered = new Set();
|
|
576
|
+
let prepared = false;
|
|
577
|
+
return {
|
|
578
|
+
spec,
|
|
579
|
+
get element() {
|
|
580
|
+
return getElement();
|
|
581
|
+
},
|
|
582
|
+
define(options = {}) {
|
|
583
|
+
const tag = `${options.prefix ?? DEFAULT_PREFIX}-${spec.name}`;
|
|
584
|
+
if (!prepared) {
|
|
585
|
+
prepared = true;
|
|
586
|
+
registerStyles({ [`host:${spec.name}`]: hostStyleText(spec) });
|
|
587
|
+
const missing = [...SHADOW_BASE_STYLES, ...spec.styles].filter((name) => !hasStyles(name));
|
|
588
|
+
if (missing.length) {
|
|
589
|
+
console.warn(`<${tag}> has no CSS for ${missing.join(", ")}: import "material/elements/css/${spec.name}" first.`);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
const existing = customElements.get(tag);
|
|
593
|
+
if (existing) {
|
|
594
|
+
if (!registered.has(existing)) {
|
|
595
|
+
console.warn(`<${tag}> is already defined by another script; keeping the first definition.`);
|
|
596
|
+
}
|
|
597
|
+
return tag;
|
|
598
|
+
}
|
|
599
|
+
const base = getElement();
|
|
600
|
+
const ctor = registered.size === 0 ? base : class extends base {
|
|
601
|
+
};
|
|
602
|
+
customElements.define(tag, ctor);
|
|
603
|
+
registered.add(ctor);
|
|
604
|
+
return tag;
|
|
605
|
+
},
|
|
606
|
+
};
|
|
607
607
|
};
|