@riverty/web-components 6.2.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +78 -0
- package/custom-elements.json +4 -0
- package/package.json +3 -2
- package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -5
- package/dist/cjs/focusable-Oll_rmtP.js +0 -28
- package/dist/cjs/formData-B2DZyLxP.js +0 -44
- package/dist/cjs/index-BnETQtSf.js +0 -1834
- package/dist/cjs/index.cjs.js +0 -2
- package/dist/cjs/loader.cjs.js +0 -13
- package/dist/cjs/r-accordion-panel.cjs.entry.js +0 -24
- package/dist/cjs/r-accordion-section.cjs.entry.js +0 -125
- package/dist/cjs/r-accordion-trigger.cjs.entry.js +0 -93
- package/dist/cjs/r-accordion.cjs.entry.js +0 -20
- package/dist/cjs/r-alert.cjs.entry.js +0 -146
- package/dist/cjs/r-badge.cjs.entry.js +0 -40
- package/dist/cjs/r-button.cjs.entry.js +0 -149
- package/dist/cjs/r-checkbox-group.cjs.entry.js +0 -232
- package/dist/cjs/r-checkbox.cjs.entry.js +0 -269
- package/dist/cjs/r-design-system-devtools.cjs.entry.js +0 -31
- package/dist/cjs/r-dialog.cjs.entry.js +0 -107
- package/dist/cjs/r-hint_2.cjs.entry.js +0 -50
- package/dist/cjs/r-icon-button_2.cjs.entry.js +0 -467
- package/dist/cjs/r-icon.cjs.entry.js +0 -284
- package/dist/cjs/r-illustration.cjs.entry.js +0 -396
- package/dist/cjs/r-input-code.cjs.entry.js +0 -432
- package/dist/cjs/r-input-date.cjs.entry.js +0 -519
- package/dist/cjs/r-input-password.cjs.entry.js +0 -265
- package/dist/cjs/r-input-phone-number.cjs.entry.js +0 -2525
- package/dist/cjs/r-input.cjs.entry.js +0 -402
- package/dist/cjs/r-list-item.cjs.entry.js +0 -109
- package/dist/cjs/r-pagination.cjs.entry.js +0 -314
- package/dist/cjs/r-panel.cjs.entry.js +0 -184
- package/dist/cjs/r-popover-action.cjs.entry.js +0 -80
- package/dist/cjs/r-popover-content.cjs.entry.js +0 -62
- package/dist/cjs/r-popover-headline.cjs.entry.js +0 -28
- package/dist/cjs/r-popover-trigger.cjs.entry.js +0 -70
- package/dist/cjs/r-popover.cjs.entry.js +0 -347
- package/dist/cjs/r-progress-bar.cjs.entry.js +0 -25
- package/dist/cjs/r-radio-button-description.cjs.entry.js +0 -18
- package/dist/cjs/r-radio-button-leading.cjs.entry.js +0 -18
- package/dist/cjs/r-radio-button-title.cjs.entry.js +0 -18
- package/dist/cjs/r-radio-button-trailing.cjs.entry.js +0 -18
- package/dist/cjs/r-radio-button.cjs.entry.js +0 -139
- package/dist/cjs/r-radio-group.cjs.entry.js +0 -425
- package/dist/cjs/r-select-option.cjs.entry.js +0 -130
- package/dist/cjs/r-select.cjs.entry.js +0 -1101
- package/dist/cjs/r-skip-link.cjs.entry.js +0 -19
- package/dist/cjs/r-stepper-item.cjs.entry.js +0 -42
- package/dist/cjs/r-stepper.cjs.entry.js +0 -99
- package/dist/cjs/r-tab-panel.cjs.entry.js +0 -26
- package/dist/cjs/r-tab.cjs.entry.js +0 -62
- package/dist/cjs/r-tabs-list.cjs.entry.js +0 -175
- package/dist/cjs/r-tabs.cjs.entry.js +0 -277
- package/dist/cjs/r-textarea.cjs.entry.js +0 -270
- package/dist/cjs/r-toast-group.cjs.entry.js +0 -46
- package/dist/cjs/r-toast.cjs.entry.js +0 -306
- package/dist/cjs/style-observer-D9zSP9wP.js +0 -1118
- package/dist/cjs/theming-NqxjhVJS.js +0 -109
- package/dist/cjs/web-components.cjs.js +0 -25
- package/dist/collection/collection-manifest.json +0 -60
- package/dist/collection/components/accordion/accordion.css +0 -24
- package/dist/collection/components/accordion/accordion.js +0 -90
- package/dist/collection/components/accordion/exports.js +0 -1
- package/dist/collection/components/accordion-panel/accordion-panel.css +0 -50
- package/dist/collection/components/accordion-panel/accordion-panel.js +0 -86
- package/dist/collection/components/accordion-section/accordion-section.css +0 -27
- package/dist/collection/components/accordion-section/accordion-section.js +0 -235
- package/dist/collection/components/accordion-trigger/accordion-trigger.css +0 -93
- package/dist/collection/components/accordion-trigger/accordion-trigger.js +0 -220
- package/dist/collection/components/alert/alert.css +0 -119
- package/dist/collection/components/alert/alert.js +0 -526
- package/dist/collection/components/alert/exports.js +0 -2
- package/dist/collection/components/badge/badge.css +0 -52
- package/dist/collection/components/badge/badge.js +0 -120
- package/dist/collection/components/badge/exports.js +0 -1
- package/dist/collection/components/button/button.css +0 -180
- package/dist/collection/components/button/button.js +0 -510
- package/dist/collection/components/button/exports.js +0 -5
- package/dist/collection/components/checkbox/checkbox.css +0 -116
- package/dist/collection/components/checkbox/checkbox.js +0 -777
- package/dist/collection/components/checkbox-group/checkbox-group.css +0 -48
- package/dist/collection/components/checkbox-group/checkbox-group.js +0 -718
- package/dist/collection/components/design-system-devtools/design-system-devtools.js +0 -59
- package/dist/collection/components/dialog/dialog.css +0 -125
- package/dist/collection/components/dialog/dialog.js +0 -345
- package/dist/collection/components/dialog/exports.js +0 -9
- package/dist/collection/components/hint/exports.js +0 -1
- package/dist/collection/components/hint/hint.css +0 -63
- package/dist/collection/components/hint/hint.js +0 -114
- package/dist/collection/components/icon/all-kit.js +0 -2
- package/dist/collection/components/icon/data.js +0 -90
- package/dist/collection/components/icon/exports.js +0 -7
- package/dist/collection/components/icon/icon.css +0 -105
- package/dist/collection/components/icon/icon.js +0 -379
- package/dist/collection/components/icon/riverty-kit.js +0 -2
- package/dist/collection/components/icon-button/icon-button.css +0 -105
- package/dist/collection/components/icon-button/icon-button.js +0 -343
- package/dist/collection/components/illustration/data.js +0 -112
- package/dist/collection/components/illustration/exports.js +0 -3
- package/dist/collection/components/illustration/illustration.js +0 -540
- package/dist/collection/components/illustration/illustration.scss +0 -56
- package/dist/collection/components/illustration/illustrations-ui-kit.js +0 -2
- package/dist/collection/components/input/exports.js +0 -16
- package/dist/collection/components/input/input.css +0 -180
- package/dist/collection/components/input/input.js +0 -1572
- package/dist/collection/components/input-code/exports.js +0 -2
- package/dist/collection/components/input-code/input-code.css +0 -127
- package/dist/collection/components/input-code/input-code.js +0 -1139
- package/dist/collection/components/input-date/exports.js +0 -1
- package/dist/collection/components/input-date/input-date.css +0 -148
- package/dist/collection/components/input-date/input-date.js +0 -1228
- package/dist/collection/components/input-password/exports.js +0 -1
- package/dist/collection/components/input-password/input-password.css +0 -25
- package/dist/collection/components/input-password/input-password.js +0 -1051
- package/dist/collection/components/input-phone-number/input-phone-number.css +0 -61
- package/dist/collection/components/input-phone-number/input-phone-number.js +0 -874
- package/dist/collection/components/label/label.css +0 -38
- package/dist/collection/components/label/label.js +0 -47
- package/dist/collection/components/list-item/list-item/exports.js +0 -2
- package/dist/collection/components/list-item/list-item/list-item.css +0 -199
- package/dist/collection/components/list-item/list-item/list-item.js +0 -467
- package/dist/collection/components/pagination/exports.js +0 -3
- package/dist/collection/components/pagination/pagination.css +0 -118
- package/dist/collection/components/pagination/pagination.js +0 -799
- package/dist/collection/components/panel/exports.js +0 -1
- package/dist/collection/components/panel/panel.css +0 -192
- package/dist/collection/components/panel/panel.js +0 -473
- package/dist/collection/components/popover/exports.js +0 -3
- package/dist/collection/components/popover/popover.css +0 -251
- package/dist/collection/components/popover/popover.js +0 -741
- package/dist/collection/components/popover-action/popover-action.css +0 -21
- package/dist/collection/components/popover-action/popover-action.js +0 -150
- package/dist/collection/components/popover-content/popover-content.css +0 -9
- package/dist/collection/components/popover-content/popover-content.js +0 -130
- package/dist/collection/components/popover-headline/popover-headline.css +0 -7
- package/dist/collection/components/popover-headline/popover-headline.js +0 -28
- package/dist/collection/components/popover-trigger/exports.js +0 -1
- package/dist/collection/components/popover-trigger/popover-trigger.css +0 -4
- package/dist/collection/components/popover-trigger/popover-trigger.js +0 -163
- package/dist/collection/components/progress-bar/progress-bar.css +0 -41
- package/dist/collection/components/progress-bar/progress-bar.js +0 -71
- package/dist/collection/components/radio-button/radio-button.css +0 -126
- package/dist/collection/components/radio-button/radio-button.js +0 -559
- package/dist/collection/components/radio-button-description/radio-button-description.css +0 -5
- package/dist/collection/components/radio-button-description/radio-button-description.js +0 -22
- package/dist/collection/components/radio-button-leading/radio-button-leading.css +0 -3
- package/dist/collection/components/radio-button-leading/radio-button-leading.js +0 -22
- package/dist/collection/components/radio-button-title/radio-button-title.css +0 -8
- package/dist/collection/components/radio-button-title/radio-button-title.js +0 -22
- package/dist/collection/components/radio-button-trailing/radio-button-trailing.css +0 -6
- package/dist/collection/components/radio-button-trailing/radio-button-trailing.js +0 -22
- package/dist/collection/components/radio-group/exports.js +0 -1
- package/dist/collection/components/radio-group/radio-group.css +0 -65
- package/dist/collection/components/radio-group/radio-group.js +0 -1020
- package/dist/collection/components/select/exports.js +0 -1
- package/dist/collection/components/select/select.css +0 -247
- package/dist/collection/components/select/select.js +0 -2011
- package/dist/collection/components/select-option/select-option.css +0 -93
- package/dist/collection/components/select-option/select-option.js +0 -459
- package/dist/collection/components/skip-link/exports.js +0 -1
- package/dist/collection/components/skip-link/skip-link.css +0 -37
- package/dist/collection/components/skip-link/skip-link.js +0 -52
- package/dist/collection/components/stepper/stepper.css +0 -25
- package/dist/collection/components/stepper/stepper.js +0 -216
- package/dist/collection/components/stepper-item/stepper-item.css +0 -62
- package/dist/collection/components/stepper-item/stepper-item.js +0 -171
- package/dist/collection/components/tab/tab.css +0 -81
- package/dist/collection/components/tab/tab.js +0 -169
- package/dist/collection/components/tab-panel/tab-panel.css +0 -19
- package/dist/collection/components/tab-panel/tab-panel.js +0 -72
- package/dist/collection/components/tabs/tabs.css +0 -4
- package/dist/collection/components/tabs/tabs.js +0 -345
- package/dist/collection/components/tabs-list/exports.js +0 -2
- package/dist/collection/components/tabs-list/tabs-list.css +0 -58
- package/dist/collection/components/tabs-list/tabs-list.js +0 -294
- package/dist/collection/components/textarea/exports.js +0 -8
- package/dist/collection/components/textarea/textarea.css +0 -148
- package/dist/collection/components/textarea/textarea.js +0 -1055
- package/dist/collection/components/toast/exports.js +0 -3
- package/dist/collection/components/toast/toast.css +0 -179
- package/dist/collection/components/toast/toast.js +0 -812
- package/dist/collection/components/toast-group/exports.js +0 -1
- package/dist/collection/components/toast-group/toast-group.css +0 -37
- package/dist/collection/components/toast-group/toast-group.js +0 -49
- package/dist/collection/components/tooltip/exports.js +0 -3
- package/dist/collection/components/tooltip/tooltip.css +0 -106
- package/dist/collection/components/tooltip/tooltip.js +0 -500
- package/dist/collection/index.js +0 -1
- package/dist/collection/utils/focusable.js +0 -24
- package/dist/collection/utils/formData.js +0 -40
- package/dist/collection/utils/theming.js +0 -103
- package/dist/esm/app-globals-DQuL1Twl.js +0 -3
- package/dist/esm/focusable-ky1yonnS.js +0 -26
- package/dist/esm/formData-DvLT8-y3.js +0 -42
- package/dist/esm/index-CTxpqopm.js +0 -1806
- package/dist/esm/index.js +0 -1
- package/dist/esm/loader.js +0 -11
- package/dist/esm/r-accordion-panel.entry.js +0 -22
- package/dist/esm/r-accordion-section.entry.js +0 -123
- package/dist/esm/r-accordion-trigger.entry.js +0 -91
- package/dist/esm/r-accordion.entry.js +0 -18
- package/dist/esm/r-alert.entry.js +0 -144
- package/dist/esm/r-badge.entry.js +0 -38
- package/dist/esm/r-button.entry.js +0 -147
- package/dist/esm/r-checkbox-group.entry.js +0 -230
- package/dist/esm/r-checkbox.entry.js +0 -267
- package/dist/esm/r-design-system-devtools.entry.js +0 -29
- package/dist/esm/r-dialog.entry.js +0 -105
- package/dist/esm/r-hint_2.entry.js +0 -47
- package/dist/esm/r-icon-button_2.entry.js +0 -464
- package/dist/esm/r-icon.entry.js +0 -282
- package/dist/esm/r-illustration.entry.js +0 -394
- package/dist/esm/r-input-code.entry.js +0 -430
- package/dist/esm/r-input-date.entry.js +0 -517
- package/dist/esm/r-input-password.entry.js +0 -263
- package/dist/esm/r-input-phone-number.entry.js +0 -2523
- package/dist/esm/r-input.entry.js +0 -400
- package/dist/esm/r-list-item.entry.js +0 -107
- package/dist/esm/r-pagination.entry.js +0 -312
- package/dist/esm/r-panel.entry.js +0 -182
- package/dist/esm/r-popover-action.entry.js +0 -78
- package/dist/esm/r-popover-content.entry.js +0 -60
- package/dist/esm/r-popover-headline.entry.js +0 -26
- package/dist/esm/r-popover-trigger.entry.js +0 -68
- package/dist/esm/r-popover.entry.js +0 -345
- package/dist/esm/r-progress-bar.entry.js +0 -23
- package/dist/esm/r-radio-button-description.entry.js +0 -16
- package/dist/esm/r-radio-button-leading.entry.js +0 -16
- package/dist/esm/r-radio-button-title.entry.js +0 -16
- package/dist/esm/r-radio-button-trailing.entry.js +0 -16
- package/dist/esm/r-radio-button.entry.js +0 -137
- package/dist/esm/r-radio-group.entry.js +0 -423
- package/dist/esm/r-select-option.entry.js +0 -128
- package/dist/esm/r-select.entry.js +0 -1099
- package/dist/esm/r-skip-link.entry.js +0 -17
- package/dist/esm/r-stepper-item.entry.js +0 -40
- package/dist/esm/r-stepper.entry.js +0 -97
- package/dist/esm/r-tab-panel.entry.js +0 -24
- package/dist/esm/r-tab.entry.js +0 -60
- package/dist/esm/r-tabs-list.entry.js +0 -173
- package/dist/esm/r-tabs.entry.js +0 -275
- package/dist/esm/r-textarea.entry.js +0 -268
- package/dist/esm/r-toast-group.entry.js +0 -44
- package/dist/esm/r-toast.entry.js +0 -304
- package/dist/esm/style-observer-4Uv3PpKT.js +0 -1116
- package/dist/esm/theming-DD2IrjpG.js +0 -106
- package/dist/esm/web-components.js +0 -21
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/types/components/accordion/accordion.d.ts +0 -27
- package/dist/types/components/accordion/exports.d.ts +0 -2
- package/dist/types/components/accordion-panel/accordion-panel.d.ts +0 -10
- package/dist/types/components/accordion-section/accordion-section.d.ts +0 -36
- package/dist/types/components/accordion-trigger/accordion-trigger.d.ts +0 -33
- package/dist/types/components/alert/alert.d.ts +0 -67
- package/dist/types/components/alert/exports.d.ts +0 -4
- package/dist/types/components/badge/badge.d.ts +0 -23
- package/dist/types/components/badge/exports.d.ts +0 -2
- package/dist/types/components/button/button.d.ts +0 -89
- package/dist/types/components/button/exports.d.ts +0 -10
- package/dist/types/components/checkbox/checkbox.d.ts +0 -136
- package/dist/types/components/checkbox-group/checkbox-group.d.ts +0 -122
- package/dist/types/components/design-system-devtools/design-system-devtools.d.ts +0 -15
- package/dist/types/components/dialog/dialog.d.ts +0 -69
- package/dist/types/components/dialog/exports.d.ts +0 -10
- package/dist/types/components/hint/exports.d.ts +0 -2
- package/dist/types/components/hint/hint.d.ts +0 -20
- package/dist/types/components/icon/all-kit.d.ts +0 -2890
- package/dist/types/components/icon/data.d.ts +0 -145
- package/dist/types/components/icon/exports.d.ts +0 -152
- package/dist/types/components/icon/icon.d.ts +0 -37
- package/dist/types/components/icon/riverty-kit.d.ts +0 -139
- package/dist/types/components/icon-button/icon-button.d.ts +0 -69
- package/dist/types/components/illustration/data.d.ts +0 -52
- package/dist/types/components/illustration/exports.d.ts +0 -23
- package/dist/types/components/illustration/illustration.d.ts +0 -51
- package/dist/types/components/illustration/illustrations-ui-kit.d.ts +0 -21
- package/dist/types/components/input/exports.d.ts +0 -10
- package/dist/types/components/input/input.d.ts +0 -300
- package/dist/types/components/input-code/exports.d.ts +0 -4
- package/dist/types/components/input-code/input-code.d.ts +0 -175
- package/dist/types/components/input-date/exports.d.ts +0 -5
- package/dist/types/components/input-date/input-date.d.ts +0 -172
- package/dist/types/components/input-password/exports.d.ts +0 -1
- package/dist/types/components/input-password/input-password.d.ts +0 -184
- package/dist/types/components/input-phone-number/input-phone-number.d.ts +0 -128
- package/dist/types/components/label/label.d.ts +0 -9
- package/dist/types/components/list-item/list-item/exports.d.ts +0 -4
- package/dist/types/components/list-item/list-item/list-item.d.ts +0 -61
- package/dist/types/components/pagination/exports.d.ts +0 -6
- package/dist/types/components/pagination/pagination.d.ts +0 -140
- package/dist/types/components/panel/exports.d.ts +0 -2
- package/dist/types/components/panel/panel.d.ts +0 -56
- package/dist/types/components/popover/exports.d.ts +0 -6
- package/dist/types/components/popover/popover.d.ts +0 -131
- package/dist/types/components/popover-action/popover-action.d.ts +0 -24
- package/dist/types/components/popover-content/popover-content.d.ts +0 -22
- package/dist/types/components/popover-headline/popover-headline.d.ts +0 -6
- package/dist/types/components/popover-trigger/exports.d.ts +0 -2
- package/dist/types/components/popover-trigger/popover-trigger.d.ts +0 -31
- package/dist/types/components/progress-bar/progress-bar.d.ts +0 -10
- package/dist/types/components/radio-button/radio-button.d.ts +0 -92
- package/dist/types/components/radio-button-description/radio-button-description.d.ts +0 -8
- package/dist/types/components/radio-button-leading/radio-button-leading.d.ts +0 -8
- package/dist/types/components/radio-button-title/radio-button-title.d.ts +0 -8
- package/dist/types/components/radio-button-trailing/radio-button-trailing.d.ts +0 -8
- package/dist/types/components/radio-group/exports.d.ts +0 -2
- package/dist/types/components/radio-group/radio-group.d.ts +0 -178
- package/dist/types/components/select/exports.d.ts +0 -2
- package/dist/types/components/select/select.d.ts +0 -317
- package/dist/types/components/select-option/select-option.d.ts +0 -113
- package/dist/types/components/skip-link/exports.d.ts +0 -2
- package/dist/types/components/skip-link/skip-link.d.ts +0 -6
- package/dist/types/components/stepper/stepper.d.ts +0 -22
- package/dist/types/components/stepper-item/stepper-item.d.ts +0 -23
- package/dist/types/components/tab/tab.d.ts +0 -23
- package/dist/types/components/tab-panel/tab-panel.d.ts +0 -7
- package/dist/types/components/tabs/tabs.d.ts +0 -49
- package/dist/types/components/tabs-list/exports.d.ts +0 -4
- package/dist/types/components/tabs-list/tabs-list.d.ts +0 -41
- package/dist/types/components/textarea/exports.d.ts +0 -2
- package/dist/types/components/textarea/textarea.d.ts +0 -158
- package/dist/types/components/toast/exports.d.ts +0 -6
- package/dist/types/components/toast/toast.d.ts +0 -146
- package/dist/types/components/toast-group/exports.d.ts +0 -2
- package/dist/types/components/toast-group/toast-group.d.ts +0 -9
- package/dist/types/components/tooltip/exports.d.ts +0 -6
- package/dist/types/components/tooltip/tooltip.d.ts +0 -131
- package/dist/types/components.d.ts +0 -6286
- package/dist/types/index.d.ts +0 -1
- package/dist/types/stencil-public-runtime.d.ts +0 -1732
- package/dist/types/types/jsx-shim.d.ts +0 -13
- package/dist/types/types/style-observer.d.ts +0 -20
- package/dist/types/utils/focusable.d.ts +0 -1
- package/dist/types/utils/formData.d.ts +0 -1
- package/dist/types/utils/theming.d.ts +0 -15
- package/dist/web-components/index.esm.js +0 -0
- package/dist/web-components/p-02b22f8e.entry.js +0 -1
- package/dist/web-components/p-075a8dc8.entry.js +0 -1
- package/dist/web-components/p-0a34d33b.entry.js +0 -1
- package/dist/web-components/p-10cc9983.entry.js +0 -1
- package/dist/web-components/p-253068b9.entry.js +0 -1
- package/dist/web-components/p-3b8c8951.entry.js +0 -1
- package/dist/web-components/p-3beacdab.entry.js +0 -1
- package/dist/web-components/p-4214867d.entry.js +0 -1
- package/dist/web-components/p-42c857e9.entry.js +0 -1
- package/dist/web-components/p-44f87e16.entry.js +0 -1
- package/dist/web-components/p-477614c5.entry.js +0 -1
- package/dist/web-components/p-495ba3d2.entry.js +0 -1
- package/dist/web-components/p-4Uv3PpKT.js +0 -1
- package/dist/web-components/p-4de76291.entry.js +0 -1
- package/dist/web-components/p-55600d47.entry.js +0 -1
- package/dist/web-components/p-562051aa.entry.js +0 -1
- package/dist/web-components/p-5b850e0f.entry.js +0 -1
- package/dist/web-components/p-6013dfc8.entry.js +0 -1
- package/dist/web-components/p-62e7ae04.entry.js +0 -1
- package/dist/web-components/p-71519d37.entry.js +0 -1
- package/dist/web-components/p-88f7b47f.entry.js +0 -1
- package/dist/web-components/p-8975a6a3.entry.js +0 -1
- package/dist/web-components/p-8e125826.entry.js +0 -1
- package/dist/web-components/p-91cc0bde.entry.js +0 -1
- package/dist/web-components/p-93435fcd.entry.js +0 -1
- package/dist/web-components/p-947969d7.entry.js +0 -1
- package/dist/web-components/p-95396b5c.entry.js +0 -1
- package/dist/web-components/p-9de3a1a5.entry.js +0 -1
- package/dist/web-components/p-9f583ed1.entry.js +0 -1
- package/dist/web-components/p-B9rsR6cQ.js +0 -1
- package/dist/web-components/p-CTxpqopm.js +0 -2
- package/dist/web-components/p-DQuL1Twl.js +0 -1
- package/dist/web-components/p-DvLT8-y3.js +0 -1
- package/dist/web-components/p-a1086abe.entry.js +0 -1
- package/dist/web-components/p-bbba6d79.entry.js +0 -1
- package/dist/web-components/p-bde44ec4.entry.js +0 -1
- package/dist/web-components/p-bfc7e6c0.entry.js +0 -1
- package/dist/web-components/p-c1030394.entry.js +0 -1
- package/dist/web-components/p-c1f59ed1.entry.js +0 -1
- package/dist/web-components/p-c80a5541.entry.js +0 -1
- package/dist/web-components/p-c96ee61a.entry.js +0 -1
- package/dist/web-components/p-caf8f067.entry.js +0 -1
- package/dist/web-components/p-cc363c3d.entry.js +0 -1
- package/dist/web-components/p-cf4ff357.entry.js +0 -1
- package/dist/web-components/p-d0310ed4.entry.js +0 -1
- package/dist/web-components/p-d1412932.entry.js +0 -1
- package/dist/web-components/p-d2447e30.entry.js +0 -1
- package/dist/web-components/p-dc9cca06.entry.js +0 -1
- package/dist/web-components/p-e5b943a2.entry.js +0 -1
- package/dist/web-components/p-e67b13df.entry.js +0 -1
- package/dist/web-components/p-efec231a.entry.js +0 -1
- package/dist/web-components/p-f867e4c3.entry.js +0 -1
- package/dist/web-components/p-ky1yonnS.js +0 -1
- package/dist/web-components/web-components.esm.js +0 -1
- package/loader/cdn.js +0 -1
- package/loader/index.cjs.js +0 -1
- package/loader/index.d.ts +0 -24
- package/loader/index.es2017.js +0 -1
- package/loader/index.js +0 -2
|
@@ -1,1118 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// In Safari < 18.2, transitioning custom properties of syntax `*` or `<string>`
|
|
4
|
-
// causes an infinite loop of `transitionrun` or `transitionstart` events.
|
|
5
|
-
// We use this test to detect the bug.
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Detect if the browser is affected by the Safari transition loop bug.
|
|
9
|
-
* @see https://bugs.webkit.org/show_bug.cgi?id=279012
|
|
10
|
-
* @returns {Promise<boolean>}
|
|
11
|
-
*/
|
|
12
|
-
var TRANSITIONRUN_EVENT_LOOP = {
|
|
13
|
-
value: undefined,
|
|
14
|
-
get valuePending () {
|
|
15
|
-
if (this.value !== undefined) {
|
|
16
|
-
return this.value;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let dummy = document.createElement("div");
|
|
20
|
-
document.body.appendChild(dummy);
|
|
21
|
-
let property = "--bar-" + Date.now();
|
|
22
|
-
dummy.style.cssText = `${property}: 1; transition: ${property} 1ms step-start allow-discrete`;
|
|
23
|
-
|
|
24
|
-
delete this.valuePending;
|
|
25
|
-
return (this.valuePending = new Promise(resolve => {
|
|
26
|
-
let eventsCount = 0;
|
|
27
|
-
requestAnimationFrame(() => {
|
|
28
|
-
setTimeout(_ => resolve(eventsCount > 1), 50);
|
|
29
|
-
dummy.addEventListener("transitionrun", _ => eventsCount++);
|
|
30
|
-
dummy.style.setProperty(property, "2");
|
|
31
|
-
});
|
|
32
|
-
})
|
|
33
|
-
.then(v => (this.value = v))
|
|
34
|
-
.finally(() => dummy.remove()));
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// Detect https://issues.chromium.org/issues/360159391
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Detect if the browser is affected by the unregistered transition bug.
|
|
42
|
-
* @see https://issues.chromium.org/issues/360159391
|
|
43
|
-
* @returns {Promise<boolean>}
|
|
44
|
-
*/
|
|
45
|
-
var UNREGISTERED_TRANSITION = {
|
|
46
|
-
value: undefined,
|
|
47
|
-
get valuePending () {
|
|
48
|
-
if (this.value !== undefined) {
|
|
49
|
-
return this.value;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
let dummy = document.createElement("div");
|
|
53
|
-
document.body.appendChild(dummy);
|
|
54
|
-
let property = "--foo-" + Date.now();
|
|
55
|
-
dummy.style.cssText = `${property}: 1; transition: ${property} 1ms step-start allow-discrete`;
|
|
56
|
-
|
|
57
|
-
delete this.valuePending;
|
|
58
|
-
return (this.valuePending = new Promise(resolve => {
|
|
59
|
-
requestAnimationFrame(() => {
|
|
60
|
-
setTimeout(_ => resolve(true), 30);
|
|
61
|
-
dummy.addEventListener("transitionstart", _ => resolve(false));
|
|
62
|
-
dummy.style.setProperty(property, "2");
|
|
63
|
-
});
|
|
64
|
-
})
|
|
65
|
-
.then(v => (this.value = v))
|
|
66
|
-
.finally(() => dummy.remove()));
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Check if a CSS custom property is registered.
|
|
72
|
-
* This function will return `false` for custom properties that behave identically to non-registered properties (e.g., registered inherited properties with syntax "*").
|
|
73
|
-
* @param {string} property - The property to check.
|
|
74
|
-
* @param {Window} [window] - The window to check in.
|
|
75
|
-
* @returns {boolean}
|
|
76
|
-
*/
|
|
77
|
-
function isRegisteredProperty (property, window = globalThis) {
|
|
78
|
-
let document = window.document;
|
|
79
|
-
|
|
80
|
-
let dummy = document.createElement("div");
|
|
81
|
-
document.body.append(dummy);
|
|
82
|
-
|
|
83
|
-
let invalidValue = "foo(bar)"; // a value that is invalid for any registered syntax
|
|
84
|
-
dummy.style.setProperty(property, invalidValue);
|
|
85
|
-
let value = getComputedStyle(dummy).getPropertyValue(property);
|
|
86
|
-
|
|
87
|
-
let ret = true;
|
|
88
|
-
if (value === invalidValue) {
|
|
89
|
-
// We might have either unregistered or registered custom property with syntax "*".
|
|
90
|
-
// If it's non-inherited, we can be sure it's registered.
|
|
91
|
-
// But if it's inherited, it's OK if we (re-)register it with syntax "*" in any case.
|
|
92
|
-
let child = dummy.appendChild(document.createElement("div"));
|
|
93
|
-
let inheritedValue = getComputedStyle(child).getPropertyValue(property);
|
|
94
|
-
ret = inheritedValue !== invalidValue;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
dummy.remove();
|
|
98
|
-
|
|
99
|
-
return ret;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const INITIAL_VALUES = {
|
|
103
|
-
"<angle>": "0deg",
|
|
104
|
-
"<color>": "transparent",
|
|
105
|
-
"<custom-ident>": "none",
|
|
106
|
-
"<image>": "linear-gradient(transparent 0% 100%)",
|
|
107
|
-
"<integer>": "0",
|
|
108
|
-
"<length>": "0px",
|
|
109
|
-
"<length-percentage>": "0px",
|
|
110
|
-
"<number>": "0",
|
|
111
|
-
"<percentage>": "0%",
|
|
112
|
-
"<resolution>": "1dppx",
|
|
113
|
-
"<string>": "''",
|
|
114
|
-
"<time>": "0s",
|
|
115
|
-
"<transform-function>": "scale(1)",
|
|
116
|
-
"<transform-list>": "scale(1)",
|
|
117
|
-
"<url>": "url('')",
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Register a CSS custom property if it’s not already registered.
|
|
122
|
-
* @param {string} property - Property name.
|
|
123
|
-
* @param {Object} [meta] - Property definition.
|
|
124
|
-
* @param {string} [meta.syntax] - Property syntax.
|
|
125
|
-
* @param {boolean} [meta.inherits] - Whether the property inherits.
|
|
126
|
-
* @param {*} [meta.initialValue] - Initial value.
|
|
127
|
-
* @param {Window} [window] - Window to register the property in.
|
|
128
|
-
*/
|
|
129
|
-
function gentleRegisterProperty (property, meta = {}, window = globalThis) {
|
|
130
|
-
if (
|
|
131
|
-
!property.startsWith("--") ||
|
|
132
|
-
!window.CSS?.registerProperty ||
|
|
133
|
-
isRegisteredProperty(property, window)
|
|
134
|
-
) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
let definition = {
|
|
139
|
-
name: property,
|
|
140
|
-
syntax: meta.syntax || "*",
|
|
141
|
-
inherits: meta.inherits ?? true,
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
if (meta.initialValue !== undefined) {
|
|
145
|
-
definition.initialValue = meta.initialValue;
|
|
146
|
-
}
|
|
147
|
-
else if (definition.syntax !== "*" && definition.syntax in INITIAL_VALUES) {
|
|
148
|
-
definition.initialValue = INITIAL_VALUES[definition.syntax];
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
window.CSS.registerProperty(definition);
|
|
153
|
-
}
|
|
154
|
-
catch (e) {
|
|
155
|
-
let error = e;
|
|
156
|
-
let rethrow = true;
|
|
157
|
-
|
|
158
|
-
if (e instanceof window.DOMException) {
|
|
159
|
-
if (e.name === "InvalidModificationError") {
|
|
160
|
-
// Property is already registered, which is fine
|
|
161
|
-
rethrow = false;
|
|
162
|
-
}
|
|
163
|
-
else if (e.name === "SyntaxError") {
|
|
164
|
-
// In Safari < 18.2 (where we face the infinite loop bug),
|
|
165
|
-
// there is no way to provide an initial value for a custom property with a syntax of "<string>".
|
|
166
|
-
// There will always be an error: “The given initial value does not parse for the given syntax.”
|
|
167
|
-
// So we try again with universal syntax.
|
|
168
|
-
// We do the same for any other syntax that is not supported.
|
|
169
|
-
definition.syntax = "*";
|
|
170
|
-
|
|
171
|
-
try {
|
|
172
|
-
window.CSS.registerProperty(definition);
|
|
173
|
-
rethrow = false;
|
|
174
|
-
}
|
|
175
|
-
catch (e) {
|
|
176
|
-
error = e;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (rethrow) {
|
|
182
|
-
// Re-throw any other errors
|
|
183
|
-
throw new Error(`Failed to register custom property ${property}: ${error.message}`, {
|
|
184
|
-
cause: error,
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Detect if the browser is affected by the Safari adopted style sheet bug:
|
|
192
|
-
* removing a CSS custom property from an adopted stylesheet in a ShadowRoot
|
|
193
|
-
* does not update the computed value as expected and doesn't trigger a transition.
|
|
194
|
-
* @returns {{value: boolean, valuePending: boolean}}
|
|
195
|
-
*/
|
|
196
|
-
var ADOPTED_STYLE_SHEET = {
|
|
197
|
-
get value () {
|
|
198
|
-
let dummy = document.createElement("div");
|
|
199
|
-
document.body.append(dummy);
|
|
200
|
-
dummy.attachShadow({ mode: "open" });
|
|
201
|
-
|
|
202
|
-
if (Object.isFrozen(dummy.shadowRoot.adoptedStyleSheets)) {
|
|
203
|
-
// The browser doesn't support the modern adoptedStyleSheets API, i.e., it is not affected by the bug
|
|
204
|
-
dummy.remove();
|
|
205
|
-
delete this.value;
|
|
206
|
-
|
|
207
|
-
return (this.value = false);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
gentleRegisterProperty("--style-observer-adopted-style-sheet-bug", {
|
|
211
|
-
syntax: "<number>",
|
|
212
|
-
inherits: true,
|
|
213
|
-
initialValue: 0,
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
let sheet = new CSSStyleSheet();
|
|
217
|
-
sheet.insertRule(`
|
|
218
|
-
:host {
|
|
219
|
-
/* This declaration shouldn't be empty for the bug to trigger */
|
|
220
|
-
color: transparent;
|
|
221
|
-
}
|
|
222
|
-
`);
|
|
223
|
-
|
|
224
|
-
dummy.shadowRoot.adoptedStyleSheets.push(sheet);
|
|
225
|
-
let style = sheet.cssRules[0].style;
|
|
226
|
-
|
|
227
|
-
style.setProperty("--style-observer-adopted-style-sheet-bug", "1");
|
|
228
|
-
let cs = getComputedStyle(dummy);
|
|
229
|
-
let oldValue = cs.getPropertyValue("--style-observer-adopted-style-sheet-bug");
|
|
230
|
-
|
|
231
|
-
style.removeProperty("--style-observer-adopted-style-sheet-bug");
|
|
232
|
-
cs = getComputedStyle(dummy);
|
|
233
|
-
let newValue = cs.getPropertyValue("--style-observer-adopted-style-sheet-bug");
|
|
234
|
-
|
|
235
|
-
dummy.remove();
|
|
236
|
-
delete this.value;
|
|
237
|
-
|
|
238
|
-
return (this.value = oldValue === newValue);
|
|
239
|
-
},
|
|
240
|
-
get valuePending () {
|
|
241
|
-
delete this.valuePending;
|
|
242
|
-
return this.value;
|
|
243
|
-
},
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
const detectors = { TRANSITIONRUN_EVENT_LOOP, UNREGISTERED_TRANSITION, ADOPTED_STYLE_SHEET };
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Data structure for all detected bugs.
|
|
250
|
-
* All bugs start off as true, and once their promises resolve, that is replaced with the actual value
|
|
251
|
-
*/
|
|
252
|
-
const bugs = {
|
|
253
|
-
detectAll () {
|
|
254
|
-
return Promise.all(Object.values(detectors).map(detector => detector.valuePending));
|
|
255
|
-
},
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
for (let bug in detectors) {
|
|
259
|
-
let detector = detectors[bug];
|
|
260
|
-
Object.defineProperty(bugs, bug, {
|
|
261
|
-
get () {
|
|
262
|
-
if (detector.value !== undefined) {
|
|
263
|
-
delete detector.valuePending;
|
|
264
|
-
delete this[bug];
|
|
265
|
-
|
|
266
|
-
return (this[bug] = detector.value);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
detector.valuePending.then(value => {
|
|
270
|
-
delete this[bug];
|
|
271
|
-
this[bug] = value;
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
// Until we know, assume the bug is present
|
|
275
|
-
return true;
|
|
276
|
-
},
|
|
277
|
-
configurable: true,
|
|
278
|
-
enumerable: true,
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* A WeakMap that maps keys to Sets of values, allowing multiple values per key.
|
|
284
|
-
*/
|
|
285
|
-
class MultiWeakMap extends WeakMap {
|
|
286
|
-
has (key, value) {
|
|
287
|
-
if (arguments.length === 1) {
|
|
288
|
-
return super.has(key);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
let set = super.get(key);
|
|
292
|
-
return set?.has(value) || false;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
add (key, value) {
|
|
296
|
-
let set = super.get(key) ?? new Set();
|
|
297
|
-
set.add(value);
|
|
298
|
-
super.set(key, set);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
delete (key, ...values) {
|
|
302
|
-
let set = super.get(key);
|
|
303
|
-
if (set) {
|
|
304
|
-
for (let value of values) {
|
|
305
|
-
set.delete(value);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (set.size === 0) {
|
|
309
|
-
super.delete(key);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Convert a value to an array. `undefined` and `null` values are converted to an empty array.
|
|
317
|
-
* @param {*} value - The value to convert.
|
|
318
|
-
* @returns {any[]} The converted array.
|
|
319
|
-
*/
|
|
320
|
-
function toArray (value) {
|
|
321
|
-
if (value === undefined || value === null) {
|
|
322
|
-
return [];
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (Array.isArray(value)) {
|
|
326
|
-
return value;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// Don't convert "foo" into ["f", "o", "o"]
|
|
330
|
-
if (typeof value !== "string" && typeof value[Symbol.iterator] === "function") {
|
|
331
|
-
return Array.from(value);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
return [value];
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Wait for a given number of milliseconds or a `requestAnimationFrame`.
|
|
339
|
-
* @param {number} ms - The number of milliseconds to wait.
|
|
340
|
-
* @returns {Promise<void>}
|
|
341
|
-
*/
|
|
342
|
-
function wait (ms) {
|
|
343
|
-
if (ms) {
|
|
344
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
return new Promise(resolve => requestAnimationFrame(resolve));
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
let dummy;
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* Get the longhands for a given property.
|
|
354
|
-
* @param {string} property - The property to get the longhands for.
|
|
355
|
-
* @returns {string[]} The longhands.
|
|
356
|
-
* @see https://lea.verou.me/blog/2020/07/introspecting-css-via-the-css-om-getting-supported-properties-shorthands-longhands/
|
|
357
|
-
*/
|
|
358
|
-
function getLonghands (property) {
|
|
359
|
-
dummy ??= document.createElement("div");
|
|
360
|
-
let style = dummy.style;
|
|
361
|
-
style[property] = "inherit"; // a value that works in every property
|
|
362
|
-
let ret = [...style];
|
|
363
|
-
|
|
364
|
-
if (ret.length === 0) {
|
|
365
|
-
// Fallback, in case
|
|
366
|
-
ret = [property];
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
style.cssText = ""; // clean up
|
|
370
|
-
|
|
371
|
-
return ret;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Parse a CSS `<time>` value.
|
|
376
|
-
* @param {string } cssTime - A string that contains CSS `<time>` values.
|
|
377
|
-
* @return { number[] } Any times found, in milliseconds.
|
|
378
|
-
*/
|
|
379
|
-
function parseTimes (cssTime) {
|
|
380
|
-
let matches = cssTime.matchAll(/(?:^|\s)([+-]?(?:\d+|\d*\.\d+))\s*(ms|s)?(?=\s|$)/g);
|
|
381
|
-
let ret = [];
|
|
382
|
-
|
|
383
|
-
for (let match of matches) {
|
|
384
|
-
let [, value, unit] = match;
|
|
385
|
-
value = parseFloat(value);
|
|
386
|
-
|
|
387
|
-
if (unit === "s") {
|
|
388
|
-
value *= 1000;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
ret.push(value);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
return ret;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* Get the duration and delay of a CSS transition for a given property.
|
|
399
|
-
* @param {string} property - The CSS property name.
|
|
400
|
-
* @param {string} transitions - The computed value of the `transition` property.
|
|
401
|
-
* @returns { { duration: number, delay: number } } The duration and delay, in milliseconds.
|
|
402
|
-
*/
|
|
403
|
-
function getTimesFor (property, transitions) {
|
|
404
|
-
transitions = splitCommas(transitions);
|
|
405
|
-
let propertyRegex;
|
|
406
|
-
|
|
407
|
-
if (property === "all") {
|
|
408
|
-
propertyRegex = /\b\w+\b/g;
|
|
409
|
-
}
|
|
410
|
-
else {
|
|
411
|
-
let properties = [...new Set([...getLonghands(property), property, "all"])];
|
|
412
|
-
propertyRegex = RegExp(`(?:^|\\s)(${properties.join("|")})\\b`);
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
let lastRelevantTransition = transitions.findLast(transition => propertyRegex.test(transition));
|
|
416
|
-
let times = lastRelevantTransition ? parseTimes(lastRelevantTransition) : [0, 0];
|
|
417
|
-
|
|
418
|
-
if (times.length === 0) {
|
|
419
|
-
times = [0, 0];
|
|
420
|
-
}
|
|
421
|
-
else if (times.length === 1) {
|
|
422
|
-
times.push(0);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
let [duration, delay] = times;
|
|
426
|
-
return { duration, delay };
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Split a value by commas, ignoring commas within parentheses and trimming whitespace.
|
|
431
|
-
* @param {string} value - The value to split.
|
|
432
|
-
* @returns {string[]} The split values.
|
|
433
|
-
*/
|
|
434
|
-
function splitCommas (value) {
|
|
435
|
-
let ret = [];
|
|
436
|
-
let lastIndex = 0;
|
|
437
|
-
let stack = [];
|
|
438
|
-
|
|
439
|
-
for (let match of value.matchAll(/[,()]/g)) {
|
|
440
|
-
let char = match[0];
|
|
441
|
-
|
|
442
|
-
if (char === ",") {
|
|
443
|
-
if (stack.length === 0) {
|
|
444
|
-
let item = value.slice(lastIndex, match.index);
|
|
445
|
-
ret.push(item.trim());
|
|
446
|
-
lastIndex = match.index + 1;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
else if (char === "(") {
|
|
450
|
-
stack.push("(");
|
|
451
|
-
}
|
|
452
|
-
else if (char === ")") {
|
|
453
|
-
stack.pop();
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
if (lastIndex < value.length) {
|
|
458
|
-
// Push any remaining string
|
|
459
|
-
let item = value.slice(lastIndex);
|
|
460
|
-
ret.push(item.trim());
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
return ret;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* Monitor the presence of an element in the document.
|
|
468
|
-
* This observer fires the callback in situations like:
|
|
469
|
-
* - The element is added to the DOM
|
|
470
|
-
* - The element gets slotted or its slot starts existing (but not when moved to another slot)
|
|
471
|
-
* - The element becomes visible from display: none
|
|
472
|
-
*/
|
|
473
|
-
|
|
474
|
-
class RenderedObserver {
|
|
475
|
-
/**
|
|
476
|
-
* All currently observed targets
|
|
477
|
-
* @type {WeakSet<Element>}
|
|
478
|
-
*/
|
|
479
|
-
#targets = new Set();
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* Documents to IntersectionObserver instances
|
|
483
|
-
* @type {WeakMap<Document, IntersectionObserver>}
|
|
484
|
-
*/
|
|
485
|
-
#intersectionObservers = new WeakMap();
|
|
486
|
-
|
|
487
|
-
constructor (callback) {
|
|
488
|
-
this.callback = callback;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Begin observing the presence of an element.
|
|
493
|
-
* @param {Element} element - The element to observe.
|
|
494
|
-
*/
|
|
495
|
-
observe (element) {
|
|
496
|
-
if (this.#targets.has(element)) {
|
|
497
|
-
// Already observing this element
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
let doc = element.ownerDocument;
|
|
502
|
-
let io = this.#intersectionObservers.get(doc);
|
|
503
|
-
|
|
504
|
-
if (!io) {
|
|
505
|
-
io = new IntersectionObserver(
|
|
506
|
-
entries => {
|
|
507
|
-
this.callback(entries.map(({ target }) => ({ target })));
|
|
508
|
-
},
|
|
509
|
-
{ root: doc.documentElement },
|
|
510
|
-
);
|
|
511
|
-
|
|
512
|
-
this.#intersectionObservers.set(doc, io);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
this.#targets.add(element);
|
|
516
|
-
io.observe(element);
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* Stop observing the presence of an element.
|
|
521
|
-
* @param {Element} [element] - The element to stop observing. If not provided, all targets will be unobserved.
|
|
522
|
-
*/
|
|
523
|
-
unobserve (element) {
|
|
524
|
-
if (!element) {
|
|
525
|
-
// Unobserve all targets
|
|
526
|
-
for (const target of this.#targets) {
|
|
527
|
-
this.unobserve(target);
|
|
528
|
-
}
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
let doc = element.ownerDocument;
|
|
533
|
-
let io = this.#intersectionObservers.get(doc);
|
|
534
|
-
|
|
535
|
-
io?.unobserve(element);
|
|
536
|
-
this.#targets.delete(element);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
const allowDiscrete = globalThis.CSS?.supports?.("transition-behavior", "allow-discrete")
|
|
541
|
-
? " allow-discrete"
|
|
542
|
-
: "";
|
|
543
|
-
|
|
544
|
-
if (globalThis.document) {
|
|
545
|
-
gentleRegisterProperty("--style-observer-transition", { inherits: false });
|
|
546
|
-
bugs.detectAll();
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* @typedef { object } StyleObserverOptionsObject
|
|
551
|
-
* @property { string[] } properties - The properties to observe.
|
|
552
|
-
*/
|
|
553
|
-
/**
|
|
554
|
-
* @typedef { StyleObserverOptionsObject | string | string[] } StyleObserverOptions
|
|
555
|
-
*/
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* @callback StyleObserverCallback
|
|
559
|
-
* @param {Record[]} records
|
|
560
|
-
* @returns {void}
|
|
561
|
-
*/
|
|
562
|
-
|
|
563
|
-
/**
|
|
564
|
-
* @typedef { Object } Record
|
|
565
|
-
* @property {Element} target - The element that changed.
|
|
566
|
-
* @property {string} property - The property that changed.
|
|
567
|
-
* @property {string} value - The new value of the property.
|
|
568
|
-
* @property {string} oldValue - The old value of the property.
|
|
569
|
-
*/
|
|
570
|
-
|
|
571
|
-
class ElementStyleObserver {
|
|
572
|
-
/**
|
|
573
|
-
* Observed properties to their old values.
|
|
574
|
-
* @type {Map<string, string>}
|
|
575
|
-
*/
|
|
576
|
-
properties;
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
* Get the names of all properties currently being observed.
|
|
580
|
-
* @type { string[] }
|
|
581
|
-
*/
|
|
582
|
-
get propertyNames () {
|
|
583
|
-
return [...this.properties.keys()];
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
* The element being observed.
|
|
588
|
-
* @type {Element}
|
|
589
|
-
*/
|
|
590
|
-
target;
|
|
591
|
-
|
|
592
|
-
/**
|
|
593
|
-
* The callback to call when the element's style changes.
|
|
594
|
-
* @type {StyleObserverCallback}
|
|
595
|
-
*/
|
|
596
|
-
callback;
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* The observer options.
|
|
600
|
-
* @type {StyleObserverOptions}
|
|
601
|
-
*/
|
|
602
|
-
options;
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* Whether the observer has been initialized.
|
|
606
|
-
* @type {boolean}
|
|
607
|
-
*/
|
|
608
|
-
#initialized = false;
|
|
609
|
-
|
|
610
|
-
/**
|
|
611
|
-
* @param {Element} target
|
|
612
|
-
* @param {StyleObserverCallback} callback
|
|
613
|
-
* @param {StyleObserverOptions} [options]
|
|
614
|
-
*/
|
|
615
|
-
constructor (target, callback, options = {}) {
|
|
616
|
-
this.constructor.all.add(target, this);
|
|
617
|
-
this.properties = new Map();
|
|
618
|
-
this.target = target;
|
|
619
|
-
this.callback = callback;
|
|
620
|
-
this.options = { properties: [], ...options };
|
|
621
|
-
let properties = toArray(options.properties);
|
|
622
|
-
|
|
623
|
-
this.renderedObserver = new RenderedObserver(records => {
|
|
624
|
-
if (this.propertyNames.length > 0) {
|
|
625
|
-
this.handleEvent();
|
|
626
|
-
}
|
|
627
|
-
});
|
|
628
|
-
|
|
629
|
-
if (properties.length > 0) {
|
|
630
|
-
this.observe(properties);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* Called the first time observe() is called to initialize the target.
|
|
636
|
-
*/
|
|
637
|
-
#init () {
|
|
638
|
-
if (this.#initialized) {
|
|
639
|
-
return;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
let firstTime = this.constructor.all.get(this.target).size === 1;
|
|
643
|
-
this.updateTransition({ firstTime });
|
|
644
|
-
|
|
645
|
-
this.#initialized = true;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
resolveOptions (options) {
|
|
649
|
-
return Object.assign(resolveOptions(options), this.options);
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
/**
|
|
653
|
-
* Handle a potential property change
|
|
654
|
-
* @private
|
|
655
|
-
* @param {TransitionEvent} [event]
|
|
656
|
-
*/
|
|
657
|
-
async handleEvent (event) {
|
|
658
|
-
if (event && !this.properties.has(event.propertyName)) {
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
if (
|
|
663
|
-
(bugs.TRANSITIONRUN_EVENT_LOOP && event?.type === "transitionrun") ||
|
|
664
|
-
this.options.throttle > 0
|
|
665
|
-
) {
|
|
666
|
-
let eventName = bugs.TRANSITIONRUN_EVENT_LOOP ? "transitionrun" : "transitionstart";
|
|
667
|
-
let delay = Math.max(this.options.throttle, 50);
|
|
668
|
-
|
|
669
|
-
if (bugs.TRANSITIONRUN_EVENT_LOOP) {
|
|
670
|
-
// Safari < 18.2 fires `transitionrun` events too often, so we need to debounce.
|
|
671
|
-
// Wait at least the amount of time needed for the transition to run + 1 frame (~16ms)
|
|
672
|
-
let times = getTimesFor(
|
|
673
|
-
event.propertyName,
|
|
674
|
-
getComputedStyle(this.target).transition,
|
|
675
|
-
);
|
|
676
|
-
delay = Math.max(delay, times.duration + times.delay + 16);
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
this.target.removeEventListener(eventName, this);
|
|
680
|
-
await wait(delay);
|
|
681
|
-
this.target.addEventListener(eventName, this);
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
let cs = getComputedStyle(this.target);
|
|
685
|
-
let records = [];
|
|
686
|
-
|
|
687
|
-
// Other properties may have changed in the meantime
|
|
688
|
-
for (let property of this.propertyNames) {
|
|
689
|
-
let value = cs.getPropertyValue(property);
|
|
690
|
-
let oldValue = this.properties.get(property);
|
|
691
|
-
|
|
692
|
-
if (value !== oldValue) {
|
|
693
|
-
records.push({ target: this.target, property, value, oldValue });
|
|
694
|
-
this.properties.set(property, value);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
if (records.length > 0) {
|
|
699
|
-
this.callback(records);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
/**
|
|
704
|
-
* Observe the target for changes to one or more CSS properties.
|
|
705
|
-
* @param {string | string[]} properties
|
|
706
|
-
* @return {void}
|
|
707
|
-
*/
|
|
708
|
-
observe (properties) {
|
|
709
|
-
properties = toArray(properties);
|
|
710
|
-
|
|
711
|
-
// Drop properties already being observed
|
|
712
|
-
properties = properties.filter(property => !this.properties.has(property));
|
|
713
|
-
|
|
714
|
-
if (properties.length === 0) {
|
|
715
|
-
// Nothing new to observe
|
|
716
|
-
return;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
this.#init();
|
|
720
|
-
|
|
721
|
-
let cs = getComputedStyle(this.target);
|
|
722
|
-
|
|
723
|
-
for (let property of properties) {
|
|
724
|
-
if (bugs.UNREGISTERED_TRANSITION && !this.constructor.properties.has(property)) {
|
|
725
|
-
// Init property
|
|
726
|
-
gentleRegisterProperty(property, undefined, this.target.ownerDocument.defaultView);
|
|
727
|
-
this.constructor.properties.add(property);
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
let value = cs.getPropertyValue(property);
|
|
731
|
-
this.properties.set(property, value);
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
if (bugs.TRANSITIONRUN_EVENT_LOOP) {
|
|
735
|
-
this.target.addEventListener("transitionrun", this);
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
this.target.addEventListener("transitionstart", this);
|
|
739
|
-
this.target.addEventListener("transitionend", this);
|
|
740
|
-
this.updateTransitionProperties();
|
|
741
|
-
|
|
742
|
-
this.renderedObserver.observe(this.target);
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
/**
|
|
746
|
-
* Update the `--style-observer-transition` property to include all observed properties.
|
|
747
|
-
*/
|
|
748
|
-
updateTransitionProperties () {
|
|
749
|
-
// Clear our own transition
|
|
750
|
-
this.setProperty("--style-observer-transition", "");
|
|
751
|
-
|
|
752
|
-
let transitionProperties = new Set(
|
|
753
|
-
getComputedStyle(this.target).transitionProperty.split(", "),
|
|
754
|
-
);
|
|
755
|
-
let properties = [];
|
|
756
|
-
|
|
757
|
-
for (let observer of this.constructor.all.get(this.target)) {
|
|
758
|
-
properties.push(...observer.propertyNames);
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
properties = [...new Set(properties)]; // Dedupe
|
|
762
|
-
|
|
763
|
-
// Only add properties not already present
|
|
764
|
-
let transition = properties
|
|
765
|
-
.filter(property => !transitionProperties.has(property))
|
|
766
|
-
.map(property => `${property} 1ms step-start${allowDiscrete}`)
|
|
767
|
-
.join(", ");
|
|
768
|
-
|
|
769
|
-
this.setProperty("--style-observer-transition", transition);
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
/**
|
|
773
|
-
* @type { string | undefined }
|
|
774
|
-
*/
|
|
775
|
-
#inlineTransition;
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
* Update the target's transition property or refresh it if it was overwritten.
|
|
779
|
-
* @param {object} options
|
|
780
|
-
* @param {boolean} [options.firstTime] - Whether this is the first time the transition is being set.
|
|
781
|
-
*/
|
|
782
|
-
updateTransition ({ firstTime } = {}) {
|
|
783
|
-
const sot = "var(--style-observer-transition, --style-observer-noop)";
|
|
784
|
-
const inlineTransition = this.getProperty("transition");
|
|
785
|
-
let transition;
|
|
786
|
-
|
|
787
|
-
// NOTE This code assumes that if there is an inline style, it takes precedence over other styles
|
|
788
|
-
// This is not always true (think of !important), but will do for now.
|
|
789
|
-
if (firstTime ? inlineTransition : !inlineTransition.includes(sot)) {
|
|
790
|
-
// Either we are starting with an inline style being there, or our inline style was overwritten
|
|
791
|
-
transition = this.#inlineTransition = inlineTransition;
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
if (transition === undefined && (firstTime || !this.#inlineTransition)) {
|
|
795
|
-
// Just update based on most current computed style
|
|
796
|
-
if (inlineTransition.includes(sot)) {
|
|
797
|
-
this.setProperty("transition", "");
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
transition = getComputedStyle(this.target).transition;
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
if (transition === "all") {
|
|
804
|
-
transition = "";
|
|
805
|
-
}
|
|
806
|
-
else {
|
|
807
|
-
// Don't disable transitions on properties we are observing. See https://github.com/LeaVerou/style-observer/issues/107
|
|
808
|
-
transition = transition.replace(/^none\b/, "");
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
// Note that in Safari < 18.2 this fires no `transitionrun` or `transitionstart` events:
|
|
812
|
-
// transition: all, var(--style-observer-transition, all);
|
|
813
|
-
// so we can't just concatenate with whatever the existing value is
|
|
814
|
-
const prefix = transition ? transition + ", " : "";
|
|
815
|
-
this.setProperty("transition", prefix + sot);
|
|
816
|
-
|
|
817
|
-
this.updateTransitionProperties();
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
/**
|
|
821
|
-
* Whether the target has an open shadow root (and the modern adoptedStyleSheets API is supported).
|
|
822
|
-
* @type { boolean }
|
|
823
|
-
* @private
|
|
824
|
-
*/
|
|
825
|
-
get _isHost () {
|
|
826
|
-
return (
|
|
827
|
-
this.target.shadowRoot && !bugs.ADOPTED_STYLE_SHEET && !Object.isFrozen(this.target.shadowRoot.adoptedStyleSheets)
|
|
828
|
-
);
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
/**
|
|
832
|
-
* Shadow style sheet. Only used if _isHost is true.
|
|
833
|
-
* @type { CSSStyleSheet | undefined }
|
|
834
|
-
* @private
|
|
835
|
-
*/
|
|
836
|
-
_shadowSheet;
|
|
837
|
-
|
|
838
|
-
/**
|
|
839
|
-
* Any styles we've set on the target, for any reason.
|
|
840
|
-
* @type { Record<string, string> }
|
|
841
|
-
* @private
|
|
842
|
-
*/
|
|
843
|
-
_styles = {};
|
|
844
|
-
|
|
845
|
-
/**
|
|
846
|
-
* Set a CSS property on the target.
|
|
847
|
-
* @param {string} property
|
|
848
|
-
* @param {string} value
|
|
849
|
-
* @param {string} [priority]
|
|
850
|
-
* @return {void}
|
|
851
|
-
*/
|
|
852
|
-
setProperty (property, value, priority) {
|
|
853
|
-
let inlineStyle = this.target.style;
|
|
854
|
-
let style = inlineStyle;
|
|
855
|
-
if (this._isHost) {
|
|
856
|
-
// This has an open shadow root.
|
|
857
|
-
// We can use an adopted shadow style to avoid manipulating its style attribute
|
|
858
|
-
if (!this._shadowSheet) {
|
|
859
|
-
this._shadowSheet = new CSSStyleSheet();
|
|
860
|
-
this._shadowSheet.insertRule(`:host { }`);
|
|
861
|
-
this.target.shadowRoot.adoptedStyleSheets.push(this._shadowSheet);
|
|
862
|
-
|
|
863
|
-
if (Object.keys(this._styles).length > 0) {
|
|
864
|
-
// It was previously not a host, so we need to port the properties over
|
|
865
|
-
for (let property in this._styles) {
|
|
866
|
-
let value = this._styles[property];
|
|
867
|
-
this.setProperty(property, value);
|
|
868
|
-
|
|
869
|
-
// Remove from inline style if it hasn't changed externally
|
|
870
|
-
if (inlineStyle.getPropertyValue(property) === value) {
|
|
871
|
-
inlineStyle.removeProperty(property);
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
style = this._shadowSheet.cssRules[0].style;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
style.setProperty(property, value, priority);
|
|
881
|
-
// Store reserialized value for later comparison
|
|
882
|
-
this._styles[property] = this.getProperty(property);
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
/**
|
|
886
|
-
* Get a CSS property from the target.
|
|
887
|
-
* @param {string} property
|
|
888
|
-
* @return {string}
|
|
889
|
-
*/
|
|
890
|
-
getProperty (property) {
|
|
891
|
-
let style = this._shadowSheet?.cssRules[0]?.style ?? this.target.style;
|
|
892
|
-
return style.getPropertyValue(property);
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
/**
|
|
896
|
-
* Stop observing a target for changes to one or more CSS properties.
|
|
897
|
-
* @param { string | string[] } [properties] Properties to stop observing. Defaults to all observed properties.
|
|
898
|
-
* @return {void}
|
|
899
|
-
*/
|
|
900
|
-
unobserve (properties) {
|
|
901
|
-
properties = toArray(properties);
|
|
902
|
-
|
|
903
|
-
// Drop properties not being observed anyway
|
|
904
|
-
properties = properties.filter(property => this.properties.has(property));
|
|
905
|
-
|
|
906
|
-
for (let property of properties) {
|
|
907
|
-
this.properties.delete(property);
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
if (this.properties.size === 0) {
|
|
911
|
-
// No longer observing any properties
|
|
912
|
-
this.target.removeEventListener("transitionrun", this);
|
|
913
|
-
this.target.removeEventListener("transitionstart", this);
|
|
914
|
-
this.target.removeEventListener("transitionend", this);
|
|
915
|
-
this.renderedObserver.unobserve(this.target);
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
this.updateTransitionProperties();
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
/** All properties ever observed by this class. */
|
|
922
|
-
static properties = new Set();
|
|
923
|
-
|
|
924
|
-
/**
|
|
925
|
-
* All instances ever observed by this class.
|
|
926
|
-
*/
|
|
927
|
-
static all = new MultiWeakMap();
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
/**
|
|
931
|
-
* Resolve the observer options.
|
|
932
|
-
* @param {StyleObserverOptions} options
|
|
933
|
-
* @returns {StyleObserverOptionsObject}
|
|
934
|
-
*/
|
|
935
|
-
function resolveOptions (options) {
|
|
936
|
-
if (!options) {
|
|
937
|
-
return {};
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
if (typeof options === "string" || Array.isArray(options)) {
|
|
941
|
-
options = { properties: toArray(options) };
|
|
942
|
-
}
|
|
943
|
-
else if (typeof options === "object") {
|
|
944
|
-
options = { properties: [], ...options };
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
return options;
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
/**
|
|
951
|
-
* @typedef {import("./element-style-observer.js").StyleObserverCallback} StyleObserverCallback
|
|
952
|
-
*/
|
|
953
|
-
|
|
954
|
-
/**
|
|
955
|
-
* @typedef { Object } StyleObserverOptions
|
|
956
|
-
* @property {string | string[]} [properties] - The properties to observe.
|
|
957
|
-
* @property {Element | Element[]} [targets] - The elements to observe.
|
|
958
|
-
*/
|
|
959
|
-
|
|
960
|
-
class StyleObserver {
|
|
961
|
-
/**
|
|
962
|
-
* @type { WeakMap<Element, ElementStyleObserver> }
|
|
963
|
-
*/
|
|
964
|
-
elementObservers = new WeakMap();
|
|
965
|
-
|
|
966
|
-
/**
|
|
967
|
-
* @param {StyleObserverCallback} callback
|
|
968
|
-
* @param {StyleObserverOptions | string | string[]} [options]
|
|
969
|
-
*/
|
|
970
|
-
constructor (callback, options) {
|
|
971
|
-
this.callback = callback;
|
|
972
|
-
|
|
973
|
-
options = resolveOptions(options);
|
|
974
|
-
options.targets ??= [];
|
|
975
|
-
|
|
976
|
-
if (options.target) {
|
|
977
|
-
options.targets.push(options.target);
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
this.options = options;
|
|
981
|
-
|
|
982
|
-
if (this.options.targets.length > 0 && this.options.properties.length > 0) {
|
|
983
|
-
this.observe(this.options.targets, this.options.properties);
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
/**
|
|
988
|
-
* @type {StyleObserverCallback}
|
|
989
|
-
*/
|
|
990
|
-
changed (records) {
|
|
991
|
-
// TODO throttle & combine records
|
|
992
|
-
this.callback(records);
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
/**
|
|
996
|
-
* Observe one or more targets for changes to one or more CSS properties.
|
|
997
|
-
*
|
|
998
|
-
* @overload
|
|
999
|
-
* @param {Element | Element[]} targets
|
|
1000
|
-
* @param {string | string[]} properties
|
|
1001
|
-
* @returns {void}
|
|
1002
|
-
*
|
|
1003
|
-
* @overload
|
|
1004
|
-
* @param {string | string[]} properties
|
|
1005
|
-
* @param {Element | Element[]} targets
|
|
1006
|
-
* @returns {void}
|
|
1007
|
-
*
|
|
1008
|
-
* @overload
|
|
1009
|
-
* @param {...(string | Element | (string | Element)[]) } propertiesOrTargets
|
|
1010
|
-
* @returns {void}
|
|
1011
|
-
*/
|
|
1012
|
-
observe (...args) {
|
|
1013
|
-
let { targets, properties } = resolveArgs(...args);
|
|
1014
|
-
|
|
1015
|
-
if (targets.length === 0) {
|
|
1016
|
-
// Default to constructor-specified targets
|
|
1017
|
-
targets = this.options.targets;
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
if (targets.length === 0) {
|
|
1021
|
-
return;
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
for (let target of targets) {
|
|
1025
|
-
let observer = this.elementObservers.get(target);
|
|
1026
|
-
|
|
1027
|
-
if (!observer) {
|
|
1028
|
-
observer = new ElementStyleObserver(
|
|
1029
|
-
target,
|
|
1030
|
-
records => this.changed(records),
|
|
1031
|
-
this.options,
|
|
1032
|
-
);
|
|
1033
|
-
this.elementObservers.set(target, observer);
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
observer.observe(properties);
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
/**
|
|
1041
|
-
* Stop observing one or more targets for changes to one or more CSS properties.
|
|
1042
|
-
*
|
|
1043
|
-
* @overload
|
|
1044
|
-
* @param {Element | Element[]} targets
|
|
1045
|
-
* @param {string | string[]} properties
|
|
1046
|
-
* @returns {void}
|
|
1047
|
-
*
|
|
1048
|
-
* @overload
|
|
1049
|
-
* @param {string | string[]} properties
|
|
1050
|
-
* @param {Element | Element[]} targets
|
|
1051
|
-
* @returns {void}
|
|
1052
|
-
*
|
|
1053
|
-
* @overload
|
|
1054
|
-
* @param {...(string | Element | (string | Element)[]) } propertiesOrTargets
|
|
1055
|
-
* @returns {void}
|
|
1056
|
-
*/
|
|
1057
|
-
unobserve (...args) {
|
|
1058
|
-
let { targets, properties } = resolveArgs(...args);
|
|
1059
|
-
|
|
1060
|
-
if (targets.length === 0) {
|
|
1061
|
-
// Default to constructor-specified targets
|
|
1062
|
-
targets = this.options.targets;
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
if (targets.length === 0) {
|
|
1066
|
-
return;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
if (properties.length === 0) {
|
|
1070
|
-
// Default to constructor-specified properties
|
|
1071
|
-
properties = this.options.properties;
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
for (let target of targets) {
|
|
1075
|
-
let observer = this.elementObservers.get(target);
|
|
1076
|
-
|
|
1077
|
-
if (observer) {
|
|
1078
|
-
observer.unobserve(properties);
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
/**
|
|
1084
|
-
* Update the transition for one or more targets.
|
|
1085
|
-
* @param {Element | Element[]} targets
|
|
1086
|
-
* @returns {void}
|
|
1087
|
-
*/
|
|
1088
|
-
updateTransition (targets) {
|
|
1089
|
-
for (let target of toArray(targets)) {
|
|
1090
|
-
let observer = this.elementObservers.get(target);
|
|
1091
|
-
|
|
1092
|
-
if (observer) {
|
|
1093
|
-
observer.updateTransition();
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
/**
|
|
1100
|
-
* Resolve the targets and properties from the arguments.
|
|
1101
|
-
* @param {Element | Element[] | string | string[]} targets
|
|
1102
|
-
* @param {Element | Element[] | string | string[]} properties
|
|
1103
|
-
* @returns {{ targets: Element[], properties: string[] }}
|
|
1104
|
-
*/
|
|
1105
|
-
function resolveArgs (targets, properties) {
|
|
1106
|
-
let args = [...toArray(targets), ...toArray(properties)];
|
|
1107
|
-
targets = [];
|
|
1108
|
-
properties = [];
|
|
1109
|
-
|
|
1110
|
-
for (let arg of args) {
|
|
1111
|
-
let arr = typeof arg === "string" || arg instanceof String ? properties : targets;
|
|
1112
|
-
arr.push(arg);
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
return { targets, properties };
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
exports.StyleObserver = StyleObserver;
|