@aceshooting/lyra-ui 32.0.0 → 33.0.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 +224 -1380
- package/README.md +36 -7
- package/custom-elements.slim.json +1 -0
- package/design-tokens.json +1 -1
- package/dist/accent-roles.css +1 -0
- package/dist/all.d.ts +1 -1
- package/dist/all.js +1 -1
- package/dist/autoloader.d.ts +10 -0
- package/dist/autoloader.js +1 -1
- package/dist/cli/migrate-wa.mjs +54 -44
- package/dist/cli/migration-contract.json.gz +0 -0
- package/dist/components/agent-tools/budget-meter/budget-meter.class.d.ts +1 -0
- package/dist/components/agent-tools/budget-meter/budget-meter.styles.js +1 -1
- package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.d.ts +1 -1
- package/dist/components/charts/chart/box-plot.class.d.ts +3 -0
- package/dist/components/charts/chart/chart-band.js +1 -1
- package/dist/components/charts/chart/chart-input-projection.js +1 -1
- package/dist/components/charts/chart/chart-surface.styles.js +1 -1
- package/dist/components/charts/chart/chart-types.d.ts +16 -2
- package/dist/components/charts/chart/chart.class.d.ts +4 -1
- package/dist/components/charts/chart/chart.class.js +3 -3
- package/dist/components/charts/chart/lite-chart.class.d.ts +3 -0
- package/dist/components/charts/chart/lite-chart.styles.js +1 -1
- package/dist/components/conversation/chat-composer/chat-composer.class.d.ts +10 -0
- package/dist/components/conversation/code-block/code-block-base.class.d.ts +31 -3
- package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-core.class.d.ts +46 -2
- package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-shared.d.ts +6 -2
- package/dist/components/conversation/code-block/code-block-shared.js +5 -4
- package/dist/components/conversation/code-block/code-block.class.d.ts +48 -3
- package/dist/components/conversation/code-block/code-block.class.js +1 -1
- package/dist/components/conversation/code-block/code-block.styles.js +1 -1
- package/dist/components/conversation/code-block/code-grammar-registry.d.ts +35 -0
- package/dist/components/conversation/code-block/code-grammar-registry.js +1 -0
- package/dist/components/conversation/markdown/markdown-core.class.d.ts +12 -0
- package/dist/components/conversation/markdown/markdown.class.d.ts +12 -0
- package/dist/components/conversation/markdown/markdown.styles.js +1 -1
- package/dist/components/conversation/model-select/model-select.class.d.ts +12 -5
- package/dist/components/conversation/selection-toolbar/selection-toolbar.class.d.ts +1 -1
- package/dist/components/conversation/suggestion-chips/suggestion-chips.class.d.ts +1 -0
- package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +1 -1
- package/dist/components/conversation/thread-list/thread-list.class.d.ts +3 -0
- package/dist/components/conversation/thread-list/thread-list.styles.js +1 -1
- package/dist/components/conversation/usage-badge/usage-badge.class.d.ts +1 -1
- package/dist/components/conversation/voice-picker/voice-picker.class.d.ts +12 -5
- package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +4 -0
- package/dist/components/data/heatmap/heatmap.class.d.ts +21 -2
- package/dist/components/data/heatmap/heatmap.class.js +2 -2
- package/dist/components/data/heatmap/heatmap.styles.js +1 -1
- package/dist/components/data/stat/stat.class.d.ts +24 -1
- package/dist/components/data/stat/stat.class.js +2 -2
- package/dist/components/data/stat/stat.styles.js +1 -1
- package/dist/components/data/table/table-row-attributes.js +1 -0
- package/dist/components/data/table/table-support.d.ts +64 -5
- package/dist/components/data/table/table-support.js +1 -1
- package/dist/components/data/table/table.class.d.ts +78 -7
- package/dist/components/data/table/table.class.js +10 -10
- package/dist/components/data/table/table.styles.js +1 -1
- package/dist/components/data/timeline/timeline-item.class.d.ts +27 -5
- package/dist/components/data/timeline/timeline-item.class.js +11 -7
- package/dist/components/data/timeline/timeline-item.styles.js +1 -1
- package/dist/components/data/timeline/timeline.class.d.ts +54 -8
- package/dist/components/data/timeline/timeline.class.js +11 -7
- package/dist/components/data/timeline/timeline.styles.js +1 -1
- package/dist/components/data/tree/tree-item.class.d.ts +2 -0
- package/dist/components/data/tree/tree-item.class.js +2 -2
- package/dist/components/data/tree/tree-item.styles.js +1 -1
- package/dist/components/forms/button/button.class.d.ts +13 -0
- package/dist/components/forms/button/button.styles.js +1 -1
- package/dist/components/forms/catalog-picker-base.d.ts +14 -1
- package/dist/components/forms/checkbox/checkbox.class.js +1 -1
- package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +28 -2
- package/dist/components/forms/checkbox-group/checkbox-group.class.js +3 -3
- package/dist/components/forms/checkbox-group/checkbox-group.styles.js +1 -1
- package/dist/components/forms/code-editor/code-editor.class.d.ts +18 -3
- package/dist/components/forms/code-editor/code-editor.styles.js +1 -1
- package/dist/components/forms/color-picker/color-picker.class.d.ts +25 -5
- package/dist/components/forms/color-picker/color-picker.class.js +3 -3
- package/dist/components/forms/color-picker/color-picker.styles.js +1 -1
- package/dist/components/forms/combobox/combobox-option-html.js +1 -0
- package/dist/components/forms/combobox/combobox.class.d.ts +140 -12
- package/dist/components/forms/combobox/combobox.class.js +113 -22
- package/dist/components/forms/combobox/combobox.styles.js +1 -1
- package/dist/components/forms/country-picker/country-picker.class.d.ts +4 -3
- package/dist/components/forms/currency-picker/currency-picker.class.d.ts +4 -3
- package/dist/components/forms/date-picker/date-input.class.d.ts +53 -3
- package/dist/components/forms/date-picker/date-input.class.js +2 -2
- package/dist/components/forms/date-picker/date-input.styles.js +1 -1
- package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +14 -0
- package/dist/components/forms/emoji-picker/emoji-picker.class.js +1 -1
- package/dist/components/forms/icon-button/icon-button.class.d.ts +2 -1
- package/dist/components/forms/icon-button/icon-button.styles.js +1 -1
- package/dist/components/forms/input/input-shared.d.ts +24 -3
- package/dist/components/forms/input/input.styles.js +1 -1
- package/dist/components/forms/input/time-input.class.d.ts +19 -4
- package/dist/components/forms/input/time-input.styles.js +1 -1
- package/dist/components/forms/locale-picker/locale-picker.class.d.ts +17 -5
- package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -1
- package/dist/components/forms/otp-input/otp-input.class.d.ts +8 -3
- package/dist/components/forms/otp-input/otp-input.styles.js +1 -1
- package/dist/components/forms/phone-input/phone-input.class.d.ts +18 -3
- package/dist/components/forms/phone-input/phone-input.styles.js +1 -1
- package/dist/components/forms/radio/radio-group.class.d.ts +23 -2
- package/dist/components/forms/radio/radio-group.class.js +2 -2
- package/dist/components/forms/radio/radio-group.styles.js +1 -1
- package/dist/components/forms/radio/radio.class.js +2 -2
- package/dist/components/forms/rubric-form/rubric-form.class.d.ts +4 -0
- package/dist/components/forms/select/select.class.d.ts +16 -4
- package/dist/components/forms/select/select.class.js +1 -1
- package/dist/components/forms/select/select.styles.js +1 -1
- package/dist/components/forms/signature-pad/signature-pad.class.d.ts +8 -3
- package/dist/components/forms/signature-pad/signature-pad.styles.js +1 -1
- package/dist/components/forms/slider/slider.class.d.ts +29 -2
- package/dist/components/forms/slider/slider.class.js +3 -3
- package/dist/components/forms/slider/slider.styles.js +1 -1
- package/dist/components/forms/switch/switch.class.d.ts +2 -0
- package/dist/components/forms/switch/switch.styles.js +1 -1
- package/dist/components/forms/textarea/textarea.class.d.ts +20 -3
- package/dist/components/forms/textarea/textarea.styles.js +1 -1
- package/dist/components/forms/time-zone-picker/time-zone-picker.class.d.ts +4 -3
- package/dist/components/forms/token-input/token-input.class.d.ts +99 -21
- package/dist/components/forms/token-input/token-input.class.js +11 -8
- package/dist/components/forms/token-input/token-input.styles.js +1 -1
- package/dist/components/forms/unit-picker/unit-picker.class.d.ts +4 -3
- package/dist/components/layout/app-rail/app-rail.class.d.ts +3 -0
- package/dist/components/layout/app-rail/app-rail.styles.js +1 -1
- package/dist/components/layout/button-group/button-group.class.d.ts +4 -0
- package/dist/components/layout/button-group/button-group.class.js +1 -1
- package/dist/components/layout/card/card.class.d.ts +15 -1
- package/dist/components/layout/card/card.styles.js +1 -1
- package/dist/components/layout/command-palette/command-palette.class.d.ts +1 -1
- package/dist/components/layout/details/details.class.d.ts +6 -0
- package/dist/components/layout/details/details.styles.js +1 -1
- package/dist/components/layout/filter-bar/filter-bar.class.d.ts +6 -0
- package/dist/components/layout/filter-bar/filter-bar.styles.js +1 -1
- package/dist/components/layout/index.d.ts +1 -1
- package/dist/components/layout/index.js +1 -1
- package/dist/components/layout/menu/dropdown-item.class.d.ts +8 -2
- package/dist/components/layout/menu/dropdown-item.class.js +1 -1
- package/dist/components/layout/menu/menu-item.class.d.ts +7 -0
- package/dist/components/layout/menu/menu-item.styles.js +1 -1
- package/dist/components/layout/menu/menu-label.class.d.ts +5 -0
- package/dist/components/layout/menu/menu-label.class.js +1 -1
- package/dist/components/layout/menu/menu.class.d.ts +4 -1
- package/dist/components/layout/menu/menu.styles.js +1 -1
- package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.d.ts +1 -1
- package/dist/components/layout/page/page.class.d.ts +9 -1
- package/dist/components/layout/page/page.class.js +2 -2
- package/dist/components/layout/segmented/segmented.class.d.ts +22 -3
- package/dist/components/layout/segmented/segmented.class.js +3 -4
- package/dist/components/layout/segmented/segmented.styles.js +1 -1
- package/dist/components/layout/stepper/step.class.d.ts +102 -0
- package/dist/components/layout/stepper/step.class.js +18 -0
- package/dist/components/layout/stepper/step.styles.js +1 -0
- package/dist/components/layout/stepper/stepper.class.d.ts +106 -13
- package/dist/components/layout/stepper/stepper.class.js +6 -2
- package/dist/components/layout/stepper/stepper.styles.js +1 -1
- package/dist/components/layout/tab-group/tab-group.class.d.ts +10 -1
- package/dist/components/layout/tab-group/tab-group.class.js +1 -1
- package/dist/components/layout/tab-group/tab-group.styles.js +1 -1
- package/dist/components/layout/tab-group/tab-panel.class.d.ts +1 -0
- package/dist/components/layout/tab-group/tab-panel.class.js +1 -1
- package/dist/components/layout/tab-group/tab.class.d.ts +4 -0
- package/dist/components/layout/widget/widget.class.d.ts +1 -0
- package/dist/components/layout/widget/widget.styles.js +1 -1
- package/dist/components/lr-code-block-core.d.ts +1 -1
- package/dist/components/lr-code-block.d.ts +1 -1
- package/dist/components/lr-counter.d.ts +1 -0
- package/dist/components/lr-counter.js +1 -0
- package/dist/components/lr-lightbox-item.d.ts +1 -0
- package/dist/components/lr-lightbox-item.js +1 -0
- package/dist/components/lr-lightbox.d.ts +1 -1
- package/dist/components/lr-lightbox.js +1 -1
- package/dist/components/lr-number-ticker.d.ts +1 -0
- package/dist/components/lr-number-ticker.js +1 -0
- package/dist/components/lr-step.d.ts +1 -0
- package/dist/components/lr-step.js +1 -0
- package/dist/components/media/file-input/file-input.class.d.ts +8 -1
- package/dist/components/media/file-input/file-input.class.js +2 -2
- package/dist/components/media/file-input/file-input.styles.js +1 -1
- package/dist/components/media/index.d.ts +1 -1
- package/dist/components/media/index.js +1 -1
- package/dist/components/media/lightbox/lightbox-item.class.d.ts +67 -0
- package/dist/components/media/lightbox/lightbox-item.class.js +9 -0
- package/dist/components/media/lightbox/lightbox-item.styles.js +1 -0
- package/dist/components/media/lightbox/lightbox-source.js +1 -1
- package/dist/components/media/lightbox/lightbox-types.d.ts +4 -1
- package/dist/components/media/lightbox/lightbox.class.d.ts +123 -30
- package/dist/components/media/lightbox/lightbox.class.js +18 -12
- package/dist/components/media/lightbox/lightbox.styles.js +1 -1
- package/dist/components/media/map/map-anchor-avoid.js +1 -1
- package/dist/components/media/map/map-drawing-controller.js +1 -1
- package/dist/components/media/map/map.class.d.ts +137 -7
- package/dist/components/media/map/map.class.js +6 -6
- package/dist/components/media/map/map.styles.js +1 -1
- package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +9 -0
- package/dist/components/media/sequence-playback/sequence-playback.class.js +2 -2
- package/dist/components/media/sequence-playback/sequence-playback.styles.js +1 -1
- package/dist/components/media/video/video.class.d.ts +4 -0
- package/dist/components/media/video/video.class.js +2 -2
- package/dist/components/media/video/video.styles.js +1 -1
- package/dist/components/media/zoomable-frame/zoomable-frame.class.d.ts +15 -0
- package/dist/components/media/zoomable-frame/zoomable-frame.class.js +2 -2
- package/dist/components/overlays/badge/badge.class.d.ts +2 -0
- package/dist/components/overlays/badge/badge.styles.js +1 -1
- package/dist/components/overlays/badge/tag.class.d.ts +2 -0
- package/dist/components/overlays/badge/tag.class.js +1 -1
- package/dist/components/overlays/chip/chip-group.class.d.ts +31 -4
- package/dist/components/overlays/chip/chip-group.class.js +3 -3
- package/dist/components/overlays/context-menu/context-menu.class.d.ts +6 -1
- package/dist/components/overlays/context-menu/context-menu.class.js +1 -1
- package/dist/components/overlays/dialog/dialog.class.d.ts +54 -6
- package/dist/components/overlays/dialog/dialog.class.js +3 -3
- package/dist/components/overlays/dialog/dialog.styles.js +1 -1
- package/dist/components/overlays/dialog/prompt.d.ts +60 -0
- package/dist/components/overlays/dialog/prompt.js +1 -0
- package/dist/components/overlays/drawer/drawer.class.d.ts +22 -1
- package/dist/components/overlays/drawer/drawer.class.js +1 -1
- package/dist/components/overlays/empty/empty.class.d.ts +1 -0
- package/dist/components/overlays/empty/empty.class.js +1 -1
- package/dist/components/overlays/overlay/dropdown.class.d.ts +5 -1
- package/dist/components/overlays/overlay/dropdown.class.js +1 -1
- package/dist/components/overlays/overlay/overlay.styles.js +1 -1
- package/dist/components/overlays/overlay/popover.class.d.ts +30 -4
- package/dist/components/overlays/overlay/popover.class.js +2 -2
- package/dist/components/overlays/overlay/tooltip.class.d.ts +7 -0
- package/dist/components/overlays/overlay/tooltip.class.js +4 -4
- package/dist/components/overlays/toast/toast-item.class.d.ts +3 -2
- package/dist/components/overlays/toast/toast-item.class.js +1 -1
- package/dist/components/overlays/toast/toast-item.styles.js +1 -1
- package/dist/components/overlays/toast/toast.class.d.ts +6 -0
- package/dist/components/overlays/toast/toast.class.js +1 -1
- package/dist/components/retrieval/citation-badge/citation-badge.class.d.ts +1 -1
- package/dist/components/retrieval/entity-chip/entity-chip.class.d.ts +1 -1
- package/dist/components/utility/copy-button/copy-button.class.d.ts +4 -1
- package/dist/components/utility/copy-button/copy-button.class.js +2 -2
- package/dist/components/utility/counter/counter-time.d.ts +15 -0
- package/dist/components/utility/counter/counter-time.js +1 -0
- package/dist/components/utility/counter/counter.class.d.ts +67 -0
- package/dist/components/utility/counter/counter.class.js +1 -0
- package/dist/components/utility/counter/counter.styles.js +1 -0
- package/dist/components/utility/divider/divider.class.d.ts +21 -3
- package/dist/components/utility/divider/divider.class.js +5 -1
- package/dist/components/utility/export-button/export-button.class.d.ts +6 -1
- package/dist/components/utility/export-button/export-button.styles.js +1 -1
- package/dist/components/utility/icon/icon-library-bootstrap.d.ts +50 -0
- package/dist/components/utility/icon/icon-library-bootstrap.js +1 -0
- package/dist/components/utility/icon/icon-library-font-awesome.d.ts +68 -0
- package/dist/components/utility/icon/icon-library-font-awesome.js +1 -0
- package/dist/components/utility/icon/icon-library.d.ts +14 -1
- package/dist/components/utility/icon/icon-library.js +1 -1
- package/dist/components/utility/icon/icon-sprite.js +1 -0
- package/dist/components/utility/icon/icon.class.d.ts +4 -2
- package/dist/components/utility/icon/icon.class.js +2 -2
- package/dist/components/utility/index.d.ts +1 -1
- package/dist/components/utility/index.js +1 -1
- package/dist/components/utility/known-date/known-date.class.d.ts +14 -0
- package/dist/components/utility/mention-popover/mention-popover.class.d.ts +1 -1
- package/dist/components/utility/number-ticker/number-ticker.class.d.ts +66 -0
- package/dist/components/utility/number-ticker/number-ticker.class.js +1 -0
- package/dist/components/utility/number-ticker/number-ticker.styles.js +1 -0
- package/dist/components/utility/tour/tour.class.d.ts +1 -1
- package/dist/components/viewers/include/include.class.d.ts +4 -1
- package/dist/components/viewers/include/include.class.js +1 -1
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +10 -1
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +2 -2
- package/dist/components/viewers/pdf-viewer/pdf-viewer.styles.js +1 -1
- package/dist/custom-elements-jsx.d.ts +1 -1
- package/dist/event-classes.d.ts +2342 -0
- package/dist/event-classes.js +1 -0
- package/dist/events.d.ts +48 -22
- package/dist/framework-types.d.ts +2 -2
- package/dist/internal/accessibility-visibility.js +1 -1
- package/dist/internal/all-defined-arguments.d.ts +19 -0
- package/dist/internal/all-defined-arguments.js +1 -0
- package/dist/internal/autoloader-manifest.js +1 -1
- package/dist/internal/autoloader-tags.d.ts +1 -1
- package/dist/internal/autoloader-tags.js +1 -1
- package/dist/internal/checked-control-label.js +1 -1
- package/dist/internal/component-loaders.generated.js +1 -1
- package/dist/internal/declarative-overlay-action.js +1 -0
- package/dist/internal/dedent.js +7 -0
- package/dist/internal/default-strings/forms.generated.js +1 -1
- package/dist/internal/default-strings/layout.generated.js +1 -1
- package/dist/internal/dev-mode-attribute-warning.development.js +1 -1
- package/dist/internal/document-token-css.generated.js +10 -0
- package/dist/internal/document-tokens.generated.js +2 -11
- package/dist/internal/document-tokens.js +2 -2
- package/dist/internal/dom-guards.js +1 -1
- package/dist/internal/external-label-association.js +1 -0
- package/dist/internal/focus-navigation.js +1 -1
- package/dist/internal/form-control/chrome.styles.js +1 -1
- package/dist/internal/form-control-labels.js +1 -1
- package/dist/internal/form-control.styles.js +1 -1
- package/dist/internal/interactive-control.styles.js +2 -2
- package/dist/internal/labeled-group.js +1 -1
- package/dist/internal/localization-runtime.d.ts +5 -0
- package/dist/internal/localization-runtime.js +1 -1
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +2 -2
- package/dist/internal/lyra-element.d.ts +11 -2
- package/dist/internal/lyra-element.js +2 -2
- package/dist/internal/lyra-event.d.ts +22 -0
- package/dist/internal/lyra-event.js +1 -0
- package/dist/internal/overlay-shared.d.ts +5 -2
- package/dist/internal/overlay-shared.js +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/root-registration-allowlist.js +1 -1
- package/dist/internal/scoped-definitions.generated.js +1 -1
- package/dist/internal/shiki/core.d.ts +4 -1
- package/dist/internal/shiki/tokenize.js +1 -1
- package/dist/internal/srcset.js +1 -0
- package/dist/internal/theme-observation.js +1 -1
- package/dist/lyra.d.ts +1 -1
- package/dist/lyra.js +1 -1
- package/dist/ssr/all.d.ts +1 -1
- package/dist/ssr/all.js +1 -1
- package/dist/ssr.d.ts +5 -5
- package/dist/ssr.js +1 -1
- package/dist/styles/native.css +1 -1
- package/dist/styles/palette.css +1 -0
- package/dist/styles/tokens-root.css +1 -1
- package/dist/styles/utilities.css +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/testing/happy-dom-shims.d.ts +11 -2
- package/dist/testing/happy-dom-shims.js +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/lyra-tag-event-map.d.ts +2 -2
- package/dist/testing/lyra-tag-event-map.js +1 -1
- package/dist/theme-core.css +1 -1
- package/dist/theme.css +1 -1
- package/dist/utilities/defined.d.ts +10 -1
- package/dist/utilities/defined.js +1 -1
- package/dist/utilities/form.d.ts +9 -0
- package/dist/utilities/form.js +1 -0
- package/dist/utilities/index.d.ts +1 -1
- package/dist/utilities/index.js +1 -1
- package/dist/vue.d.ts +1 -1
- package/llms/components/lr-app-rail.md +4 -2
- package/llms/components/lr-badge.md +4 -4
- package/llms/components/lr-bar-chart.md +1 -1
- package/llms/components/lr-box-plot.md +6 -1
- package/llms/components/lr-bubble-chart.md +1 -1
- package/llms/components/lr-budget-meter.md +2 -2
- package/llms/components/lr-button-group.md +7 -3
- package/llms/components/lr-button.md +11 -1
- package/llms/components/lr-card.md +11 -1
- package/llms/components/lr-chart.md +21 -7
- package/llms/components/lr-checkbox-group.md +11 -1
- package/llms/components/lr-chip.md +11 -1
- package/llms/components/lr-citation-badge.md +1 -1
- package/llms/components/lr-code-block-core.md +39 -9
- package/llms/components/lr-code-block.md +59 -6
- package/llms/components/lr-code-editor.md +11 -1
- package/llms/components/lr-color-picker.md +19 -6
- package/llms/components/lr-combobox.md +81 -9
- package/llms/components/lr-context-menu.md +6 -4
- package/llms/components/lr-copy-button.md +6 -4
- package/llms/components/lr-counter.md +60 -0
- package/llms/components/lr-country-picker.md +4 -0
- package/llms/components/lr-currency-picker.md +4 -0
- package/llms/components/lr-date-input.md +1 -1
- package/llms/components/lr-date-picker.md +25 -1
- package/llms/components/lr-details.md +6 -2
- package/llms/components/lr-dialog.md +101 -9
- package/llms/components/lr-divider.md +14 -5
- package/llms/components/lr-doughnut-chart.md +1 -1
- package/llms/components/lr-drawer.md +32 -7
- package/llms/components/lr-dropdown-item.md +1 -1
- package/llms/components/lr-dropdown.md +8 -4
- package/llms/components/lr-emoji-picker.md +10 -1
- package/llms/components/lr-empty.md +3 -2
- package/llms/components/lr-entity-chip.md +1 -1
- package/llms/components/lr-export-button.md +6 -3
- package/llms/components/lr-file-input.md +13 -1
- package/llms/components/lr-filter-bar.md +6 -2
- package/llms/components/lr-graph-query-builder.md +10 -1
- package/llms/components/lr-heatmap.md +20 -3
- package/llms/components/lr-histogram.md +7 -2
- package/llms/components/lr-icon-button.md +3 -1
- package/llms/components/lr-icon.md +104 -0
- package/llms/components/lr-include.md +3 -0
- package/llms/components/lr-input.md +9 -1
- package/llms/components/lr-known-date.md +10 -1
- package/llms/components/lr-lightbox-item.md +14 -0
- package/llms/components/lr-lightbox.md +119 -14
- package/llms/components/lr-line-chart.md +7 -2
- package/llms/components/lr-lite-chart.md +3 -2
- package/llms/components/lr-locale-picker.md +17 -1
- package/llms/components/lr-map.md +122 -11
- package/llms/components/lr-markdown-core.md +15 -4
- package/llms/components/lr-markdown.md +13 -4
- package/llms/components/lr-mention-popover.md +1 -1
- package/llms/components/lr-menu-item.md +1 -1
- package/llms/components/lr-menu-label.md +5 -2
- package/llms/components/lr-menu.md +22 -7
- package/llms/components/lr-model-select.md +13 -3
- package/llms/components/lr-native-time-input.md +11 -1
- package/llms/components/lr-number-input.md +11 -1
- package/llms/components/lr-number-ticker.md +60 -0
- package/llms/components/lr-otp-input.md +11 -1
- package/llms/components/lr-page.md +7 -1
- package/llms/components/lr-pagination.md +18 -0
- package/llms/components/lr-pdf-viewer.md +6 -1
- package/llms/components/lr-phone-input.md +11 -1
- package/llms/components/lr-pie-chart.md +1 -1
- package/llms/components/lr-polar-area-chart.md +1 -1
- package/llms/components/lr-popover.md +26 -6
- package/llms/components/lr-radar-chart.md +1 -1
- package/llms/components/lr-radio-group.md +11 -1
- package/llms/components/lr-rubric-form.md +7 -1
- package/llms/components/lr-scatter-chart.md +1 -1
- package/llms/components/lr-segmented.md +20 -2
- package/llms/components/lr-select.md +11 -3
- package/llms/components/lr-selection-toolbar.md +1 -1
- package/llms/components/lr-sequence-playback.md +8 -2
- package/llms/components/lr-signature-pad.md +8 -1
- package/llms/components/lr-slider.md +17 -4
- package/llms/components/lr-stat.md +20 -5
- package/llms/components/lr-step.md +67 -0
- package/llms/components/lr-stepper.md +64 -8
- package/llms/components/lr-suggestion-chips.md +3 -2
- package/llms/components/lr-switch.md +4 -3
- package/llms/components/lr-tab-group.md +10 -3
- package/llms/components/lr-tab-panel.md +2 -2
- package/llms/components/lr-table.md +87 -8
- package/llms/components/lr-tag.md +1 -1
- package/llms/components/lr-textarea.md +17 -1
- package/llms/components/lr-thread-list.md +4 -2
- package/llms/components/lr-time-input.md +9 -2
- package/llms/components/lr-time-zone-picker.md +4 -0
- package/llms/components/lr-timeline-item.md +1 -1
- package/llms/components/lr-timeline.md +47 -3
- package/llms/components/lr-toast-item.md +1 -1
- package/llms/components/lr-toast.md +8 -3
- package/llms/components/lr-token-input.md +68 -11
- package/llms/components/lr-tool-call-chip.md +1 -1
- package/llms/components/lr-tooltip.md +8 -3
- package/llms/components/lr-tree-item.md +1 -1
- package/llms/components/lr-tree.md +2 -1
- package/llms/components/lr-unit-picker.md +4 -0
- package/llms/components/lr-usage-badge.md +1 -1
- package/llms/components/lr-video.md +5 -4
- package/llms/components/lr-voice-picker.md +10 -2
- package/llms/components/lr-widget.md +2 -2
- package/llms/components/lr-zoomable-frame.md +8 -0
- package/llms/index.md +205 -201
- package/llms/migration.md +103 -16
- package/llms/peers.md +3 -3
- package/llms/shared/events-and-types.md +36 -0
- package/llms/shared/forms-and-accessibility.md +4 -1
- package/llms/shared/frameworks-and-ssr.md +10 -1
- package/llms/shared/imports-and-registration.md +68 -2
- package/llms/shared/localization-and-rtl.md +5 -0
- package/llms/shared/native-styles-and-utilities.md +142 -7
- package/llms/shared/styles-and-tokens.md +60 -6
- package/llms/shared/testing-and-utilities.md +30 -0
- package/llms/shared.md +354 -17
- package/llms/tokens.md +6 -1
- package/llms.txt +3 -3
- package/locales.json +1 -1
- package/package.json +48 -10
- package/registrations.json +1 -1
- package/skills/compose-lyra-interfaces/SKILL.md +1 -1
- package/skills/lyra-ui/SKILL.md +1 -1
- package/skills/lyra-ui/commands/migrate.md +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';
|
|
2
|
+
/** The kind of media an item shows in the lightbox.*/
|
|
3
|
+
export type LyraLightboxItemType='image'|'video';
|
|
4
|
+
/**
|
|
5
|
+
* `<lr-lightbox-item>` -- one image or video of an `<lr-lightbox>`, wrapping the thumbnail that
|
|
6
|
+
* opens it. It mirrors `wa-lightbox-item`. Each item renders a real link to its full-size media
|
|
7
|
+
* (`src`), so a gallery still works without JavaScript and when opened in a new tab; the parent
|
|
8
|
+
* lightbox intercepts a plain click and opens at that item instead. An item without `src` renders
|
|
9
|
+
* a button-like trigger with the same keyboard behavior.
|
|
10
|
+
*
|
|
11
|
+
* Every URL is validated before use: the link `href` must pass `safeLinkHref()` and the media
|
|
12
|
+
* handed to the lightbox must pass `safeMediaSrc()`; a rejected URL leaves the trigger a button
|
|
13
|
+
* and the item out of the viewer's media.
|
|
14
|
+
*
|
|
15
|
+
* `srcset` and `sizes` choose the full-size candidate the lightbox loads: the smallest candidate
|
|
16
|
+
* that covers the viewer's width (or `sizes`, when it is a single `px`/`vw` length), else the
|
|
17
|
+
* largest. `width` and `height` reserve the item's own space (and the viewer's placeholder) before
|
|
18
|
+
* the media loads, so a gallery does not shift as it fills in.
|
|
19
|
+
*
|
|
20
|
+
* **Custom content.** For anything other than an image or a native video (an embed, a player, a
|
|
21
|
+
* comparison, another component), put it in a `<template>` that is a direct child of the item.
|
|
22
|
+
* The lightbox copies the template's content into the slide only while that slide is shown, so
|
|
23
|
+
* nothing in it loads or runs before then, and removes the copy when the slide changes or the
|
|
24
|
+
* viewer closes. The copy is light DOM, so page styles apply. `src` is optional for such an item
|
|
25
|
+
* (it still becomes the no-JavaScript link when set), `width` and `height` give the slide its
|
|
26
|
+
* proportions, and custom content cannot be zoomed. The slotted `<img>` or `thumbnail` remains
|
|
27
|
+
* the item's page thumbnail and its thumbnail in the strip.
|
|
28
|
+
*
|
|
29
|
+
* @customElement lr-lightbox-item
|
|
30
|
+
* @slot - The item's thumbnail, usually an `<img>`. Clicking it opens the lightbox at this item.
|
|
31
|
+
* A direct `<template>` child is not shown here; it holds the item's custom slide content.
|
|
32
|
+
* Leave it empty (with no `thumbnail`) for an item that only appears inside the lightbox.
|
|
33
|
+
* @slot caption - Optional caption text shown with the item in the lightbox. Not displayed on the
|
|
34
|
+
* page; the lightbox reads its text content.
|
|
35
|
+
* @slot play-icon - Optional play icon shown over a video item's thumbnail.
|
|
36
|
+
* @csspart trigger - The link (or button-like anchor) that wraps the thumbnail and opens the lightbox.
|
|
37
|
+
* @csspart thumbnail-image - The image rendered from `thumbnail` when nothing is slotted.
|
|
38
|
+
* @csspart play-button - The play button shown over a video's thumbnail.
|
|
39
|
+
* @cssstate active - Present while this is the current item of an open lightbox.
|
|
40
|
+
* @cssstate empty - Present when nothing is slotted and no `thumbnail` is set; such an item is not
|
|
41
|
+
* displayed on the page.
|
|
42
|
+
* @cssstate morphing - Present while the lightbox runs its open or close motion for this item.
|
|
43
|
+
* @csspart play-glyph - The default play glyph inside the `play-icon` slot.
|
|
44
|
+
* @status stable
|
|
45
|
+
* @since 32.1.0
|
|
46
|
+
*/
|
|
47
|
+
export declare class LyraLightboxItem extends LyraElement{static styles:import("lit").CSSResultGroup[];private triggerEl?;private readonly itemInternals;
|
|
48
|
+
/** The kind of media shown in the lightbox. A `video` item shows a play button over its thumbnail.*/
|
|
49
|
+
type:LyraLightboxItemType;
|
|
50
|
+
/** URL of the full-size image or video. The trigger links to it, so the item works without JavaScript.*/
|
|
51
|
+
src:string;
|
|
52
|
+
/** Image sources for the full-size image, in `<img srcset>` format.*/
|
|
53
|
+
srcset:string;
|
|
54
|
+
/** The `sizes` hint for `srcset`; a single `px` or `vw` length narrows the chosen candidate.*/
|
|
55
|
+
sizes:string;
|
|
56
|
+
/** Alternative text for the full-size media. Defaults to the slotted thumbnail's `alt`.*/
|
|
57
|
+
alt:string;
|
|
58
|
+
/** Plain-text caption shown with the item in the lightbox (the `caption` slot is an alternative).*/
|
|
59
|
+
caption:string;
|
|
60
|
+
/** Thumbnail URL for the strip and the item itself when no `<img>` is slotted.*/
|
|
61
|
+
thumbnail:string;
|
|
62
|
+
/** Intrinsic width of the full-size media in pixels. Pair with `height` to reserve space.*/
|
|
63
|
+
width?:number;
|
|
64
|
+
/** Intrinsic height of the full-size media in pixels.*/
|
|
65
|
+
height?:number;
|
|
66
|
+
/** Focuses the item's trigger.*/
|
|
67
|
+
focus(options?:FocusOptions):void;protected updated(changed:PropertyValues):void;connectedCallback():void;disconnectedCallback():void;private notifyLightbox;private onSlotChange;private onKeyDown;protected render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-lightbox-item':LyraLightboxItem;}}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import{LyraElement}from"../../../internal/lyra-element.js";import{playIcon}from"../../../internal/icons.js";import{tag}from"../../../internal/prefix.js";import{safeLinkHref,safeMediaSrc}from"../../../internal/safe-url.js";import{literalSetConverter}from"../../../internal/converters.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{setCustomState}from"../../../internal/custom-states.js";import{styles}from"./lightbox-item.styles.js";import{chooseSrcsetCandidate}from"../../../internal/srcset.js";const ITEM_TYPES=["image","video"];function dimension(value){const parsed=typeof value=="number"?value:typeof value=="string"&&value.trim()?Number(value):NaN;return Number.isFinite(parsed)&&parsed>0?Math.round(parsed):void 0}class LyraLightboxItem extends LyraElement{constructor(){super(...arguments),this.itemInternals=attachInternalsSafely(this),this.type="image",this.src="",this.srcset="",this.sizes="",this.alt="",this.caption="",this.thumbnail="",this.onSlotChange=()=>{const hasContent=(this.renderRoot.querySelector("slot:not([name])")?.assignedNodes({flatten:!0})??[]).some(node=>node.nodeType===Node.ELEMENT_NODE?node.localName!=="template":!!node.textContent?.trim());this.toggleAttribute("data-empty",!hasContent&&!this.thumbnail),setCustomState(this.itemInternals,"empty",!hasContent&&!this.thumbnail),this.notifyLightbox()},this.onKeyDown=event=>{!safeLinkHref(this.src)&&(event.key==="Enter"||event.key===" ")&&(event.preventDefault(),this.triggerEl?.click())}}static{this.styles=[LyraElement.styles,styles]}get thumbnailElement(){return this.querySelector(":scope > img, :scope img")}get slideTemplate(){return this.querySelector(":scope > template")}get thumbnailSrc(){const image=this.thumbnailElement;return safeMediaSrc(image?.currentSrc||image?.getAttribute("src")||this.thumbnail)??""}get resolvedAlt(){return this.alt||this.thumbnailElement?.alt||""}get captionText(){return this.caption?this.caption:Array.from(this.children).find(child=>child.getAttribute("slot")==="caption")?.textContent?.trim()??""}get mediaSrc(){const chosen=this.src||chooseSrcsetCandidate(this.srcset,this.sizes,this.ownerDocument.defaultView);return safeMediaSrc(chosen)??""}setViewerState(name,present){setCustomState(this.itemInternals,name,present)}focus(options){this.deferFocusUntilRendered(options)||this.triggerEl?.focus(options)}updated(changed){super.updated(changed),this.notifyLightbox()}connectedCallback(){super.connectedCallback(),this.notifyLightbox()}disconnectedCallback(){super.disconnectedCallback(),this.notifyLightbox()}notifyLightbox(){this.closest(tag("lightbox"))?.itemChanged?.()}render(){const href=safeLinkHref(this.src)??void 0,name=this.thumbnailElement?.alt===""&&!this.textContent?.trim()&&this.alt?this.alt:void 0,width=dimension(this.width),height=dimension(this.height),thumbnail=safeMediaSrc(this.thumbnail);return html`
|
|
2
|
+
<a part="trigger" href=${ifDefined(href)} role=${ifDefined(href?void 0:"button")} tabindex=${ifDefined(href?void 0:"0")} aria-haspopup="dialog" aria-label=${ifDefined(name)} @keydown=${this.onKeyDown} >
|
|
3
|
+
<slot @slotchange=${this.onSlotChange}>${thumbnail?html`<img part="thumbnail-image" src=${thumbnail} alt=${this.resolvedAlt} width=${ifDefined(width)} height=${ifDefined(height)} loading="lazy" />`:nothing}</slot>
|
|
4
|
+
<slot name="caption"></slot>
|
|
5
|
+
<span part="play-button" ?hidden=${this.type!=="video"} aria-hidden="true">
|
|
6
|
+
<slot name="play-icon"><span part="play-glyph">${playIcon()}</span></slot>
|
|
7
|
+
</span>
|
|
8
|
+
</a>
|
|
9
|
+
`}}__decorate([query('[part="trigger"]')],LyraLightboxItem.prototype,"triggerEl",void 0),__decorate([property({reflect:!0,converter:literalSetConverter(ITEM_TYPES,"image")})],LyraLightboxItem.prototype,"type",void 0),__decorate([property()],LyraLightboxItem.prototype,"src",void 0),__decorate([property()],LyraLightboxItem.prototype,"srcset",void 0),__decorate([property()],LyraLightboxItem.prototype,"sizes",void 0),__decorate([property()],LyraLightboxItem.prototype,"alt",void 0),__decorate([property()],LyraLightboxItem.prototype,"caption",void 0),__decorate([property()],LyraLightboxItem.prototype,"thumbnail",void 0),__decorate([property({converter:{fromAttribute:value=>dimension(value)}})],LyraLightboxItem.prototype,"width",void 0),__decorate([property({converter:{fromAttribute:value=>dimension(value)}})],LyraLightboxItem.prototype,"height",void 0);export{LyraLightboxItem};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{css}from"lit";import{focusRing,focusRingShorthand,iconHitTarget}from"../../../internal/interactive-control.styles.js";const styles=css` :host{display:inline-block;max-inline-size:100%}:host([data-empty]){display:none}[part=trigger]{position:relative;display:block;${iconHitTarget} color:inherit;text-decoration:none;cursor:pointer;border-radius:var(--lr-radius);transition:var(--lr-transition-interactive)}[part=trigger]:hover{filter:brightness(1.08)}[part=trigger]:active{filter:brightness(0.94)}[part=trigger]:focus-visible{${focusRingShorthand}}:host([data-active]) [part=trigger]{${focusRing}}::slotted(img),[part=thumbnail-image]{display:block;max-inline-size:100%;block-size:auto}slot[name=caption]{display:none}[part=play-button]{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;pointer-events:none}[part=play-button][hidden]{display:none}[part=play-glyph]{display:inline-flex;align-items:center;justify-content:center;inline-size:var(--lr-icon-button-size);block-size:var(--lr-icon-button-size);border-radius:var(--lr-radius-pill);background:var(--lr-lightbox-control-bg,var(--lr-color-neutral));color:var(--lr-lightbox-control-color,var(--lr-color-on-neutral))}:host(:dir(rtl)) [part=play-glyph] svg{transform:none}`;export{styles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SourceRequestController,sourceCount,sourceRevision}from"../../../internal/source-request-controller.js";import{SourceWindowController}from"../../../internal/source-window-controller.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{requireOwnDataValue}from"../../../internal/data-descriptors.js";const MAX_FIELD_UNITS=65536;function field(value,key){if(value===null||typeof value!="object")throw new TypeError("Invalid image record");return requireOwnDataValue(value,key,"Invalid image field")}function text(value,optional=!1){if(!(optional&&value===void 0)){if(typeof value!="string"||value.length>MAX_FIELD_UNITS)throw new TypeError("Invalid image text");return value}}function normalize(value){const key=text(field(value,"key"));if(!key.length)throw new TypeError("Invalid image key");const order=sourceCount(field(value,"order")),image=field(value,"value"),src=text(field(image,"src")),alt=text(field(image,"alt"),!0),caption=text(field(image,"caption"),!0);return Object.freeze({key,order,value:Object.freeze({src,...alt===void 0?{}:{alt},...caption===void 0?{}:{caption}})})}class LightboxSourceController{constructor(host,repaint){this.host=host,this.repaint=repaint,this.locale="",this.dirty=!0,this.transaction=0,this.requestedIndex=-1,this.count=0,this.state="empty",this.requests=new SourceRequestController(host,{channels:["image"],onReset:()=>this.clearImage()}),this.window=new SourceWindowController(host,{pageSize:1,maxRows:3,maxPages:3,maxConcurrent:1,keyOf:record=>record.key,normalize,onChange:repaint}),host.addController(this)}clearImage(){this.requestedIndex=-1,this.pendingImage&&(this.pendingImage.onload=null,this.pendingImage.onerror=null,this.pendingImage.removeAttribute("src"),this.pendingImage=void 0),this.image=void 0,this.state=this.count?"loading":"empty"}refresh(){this.dirty=!0,this.transaction++,this.requests.refresh(),this.window.bind(void 0),this.repaint()}update(input,locale){if(!this.dirty&&input===this.input&&locale===this.locale)return!0;const transaction=++this.transaction;if(this.input=input,this.locale=locale,this.dirty=!1,this.requests.refresh(),transaction!==this.transaction||(this.window.bind(void 0),transaction!==this.transaction))return!1;try{if(input!==void 0){if(input===null||typeof input!="object")throw new TypeError("Invalid image source");const revision=sourceRevision(input.revision);if(transaction!==this.transaction)return!1;const view=input.images;if(transaction!==this.transaction)return!1;const count=sourceCount(view.count);if(transaction!==this.transaction||(this.requests.setSource(input,revision),transaction!==this.transaction)||(this.window.bind({owner:input,revision,epoch:this.requests.epoch,locale,view}),transaction!==this.transaction))return!1;this.count=count}else{if(this.requests.setSource(void 0,void 0),transaction!==this.transaction)return!1;this.count=0}this.state=this.count?"loading":"empty"}catch{if(transaction!==this.transaction||(this.requests.setSource(void 0,void 0),transaction!==this.transaction)||(this.window.bind(void 0),transaction!==this.transaction))return!1;this.count=0,this.state=input===void 0?"empty":"error"}return!0}select(index){if(this.dirty||!this.count||index===this.requestedIndex||!this.host.isConnected)return;this.requests.invalidate("image"),this.clearImage(),this.requestedIndex=index,this.state="loading";const lease=this.requests.begin("image",this.locale);lease&&(this.window.requestRange(index,index+1),this.window.ensure(index).then(ready=>{if(!lease.isCurrent())return;const slot=ready?this.window.source.itemAt(index):void 0;if(slot?.state!=="ready"){this.state="error",this.repaint();return}const value=slot.value.value,src=safeMediaSrc(value.src);if(!src){this.state="error",this.repaint();return}const image=this.host.ownerDocument.createElement("img");this.pendingImage=image;const settle=loaded=>{!lease.isCurrent()||this.pendingImage!==image||(image.onload=null,image.onerror=null,this.pendingImage=void 0,this.image=loaded?Object.freeze({...value,src}):void 0,this.state=loaded?"ready":"error",this.repaint())};image.onload=()=>settle(!0),image.onerror=()=>settle(!1),image.src=src}))}retry(index){if(this.count===0){this.refresh();return}this.requestedIndex=-1,this.select(index),this.repaint()}adopted(){this.requests.adopted(),this.window.adopted(),this.refresh()}hostConnected(){this.dirty=!0,this.repaint()}hostDisconnected(){this.dirty=!0,this.clearImage()}}export{LightboxSourceController};
|
|
1
|
+
import{SourceRequestController,sourceCount,sourceRevision}from"../../../internal/source-request-controller.js";import{SourceWindowController}from"../../../internal/source-window-controller.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{requireOwnDataValue}from"../../../internal/data-descriptors.js";const MAX_FIELD_UNITS=65536;function field(value,key){if(value===null||typeof value!="object")throw new TypeError("Invalid image record");return requireOwnDataValue(value,key,"Invalid image field")}function text(value,optional=!1){if(!(optional&&value===void 0)){if(typeof value!="string"||value.length>MAX_FIELD_UNITS)throw new TypeError("Invalid image text");return value}}function normalize(value){const key=text(field(value,"key"));if(!key.length)throw new TypeError("Invalid image key");const order=sourceCount(field(value,"order")),image=field(value,"value"),src=text(field(image,"src")),alt=text(field(image,"alt"),!0),caption=text(field(image,"caption"),!0),thumbnail=text(field(image,"thumbnail"),!0);return Object.freeze({key,order,value:Object.freeze({src,...alt===void 0?{}:{alt},...caption===void 0?{}:{caption},...thumbnail===void 0?{}:{thumbnail}})})}const SOURCE_THUMBNAIL_WINDOW=15;class LightboxSourceController{constructor(host,repaint){this.host=host,this.repaint=repaint,this.stripBound=!1,this.locale="",this.dirty=!0,this.transaction=0,this.requestedIndex=-1,this.count=0,this.state="empty",this.requests=new SourceRequestController(host,{channels:["image"],onReset:()=>this.clearImage()}),this.window=new SourceWindowController(host,{pageSize:1,maxRows:3,maxPages:3,maxConcurrent:1,keyOf:record=>record.key,normalize,onChange:repaint}),this.strip=new SourceWindowController(host,{pageSize:5,maxRows:25,maxPages:5,maxConcurrent:1,keyOf:record=>record.key,normalize,onChange:repaint}),host.addController(this)}clearImage(){this.requestedIndex=-1,this.pendingImage&&(this.pendingImage.onload=null,this.pendingImage.onerror=null,this.pendingImage.removeAttribute("src"),this.pendingImage=void 0),this.image=void 0,this.state=this.count?"loading":"empty"}refresh(){this.dirty=!0,this.transaction++,this.requests.refresh(),this.window.bind(void 0),this.unbindStrip(),this.repaint()}unbindStrip(){this.stripBound&&(this.stripBound=!1,this.strip.bind(void 0))}requestThumbnails(start,end){if(!(this.dirty||!this.count||!this.input)){if(!this.stripBound){try{this.strip.bind({owner:this.input,revision:sourceRevision(this.input.revision),epoch:this.requests.epoch,locale:this.locale,view:this.input.images})}catch{return}this.stripBound=!0}this.strip.requestRange(start,Math.max(start,end))}}thumbnailAt(index){if(!this.stripBound)return;const slot=this.strip.source.itemAt(index);return slot.state==="ready"?slot.value.value:void 0}update(input,locale){if(!this.dirty&&input===this.input&&locale===this.locale)return!0;const transaction=++this.transaction;if(this.input=input,this.locale=locale,this.dirty=!1,this.unbindStrip(),this.requests.refresh(),transaction!==this.transaction||(this.window.bind(void 0),transaction!==this.transaction))return!1;try{if(input!==void 0){if(input===null||typeof input!="object")throw new TypeError("Invalid image source");const revision=sourceRevision(input.revision);if(transaction!==this.transaction)return!1;const view=input.images;if(transaction!==this.transaction)return!1;const count=sourceCount(view.count);if(transaction!==this.transaction||(this.requests.setSource(input,revision),transaction!==this.transaction)||(this.window.bind({owner:input,revision,epoch:this.requests.epoch,locale,view}),transaction!==this.transaction))return!1;this.count=count}else{if(this.requests.setSource(void 0,void 0),transaction!==this.transaction)return!1;this.count=0}this.state=this.count?"loading":"empty"}catch{if(transaction!==this.transaction||(this.requests.setSource(void 0,void 0),transaction!==this.transaction)||(this.window.bind(void 0),transaction!==this.transaction))return!1;this.count=0,this.state=input===void 0?"empty":"error"}return!0}select(index){if(this.dirty||!this.count||index===this.requestedIndex||!this.host.isConnected)return;this.requests.invalidate("image"),this.clearImage(),this.requestedIndex=index,this.state="loading";const lease=this.requests.begin("image",this.locale);lease&&(this.window.requestRange(index,index+1),this.window.ensure(index).then(ready=>{if(!lease.isCurrent())return;const slot=ready?this.window.source.itemAt(index):void 0;if(slot?.state!=="ready"){this.state="error",this.repaint();return}const value=slot.value.value,src=safeMediaSrc(value.src);if(!src){this.state="error",this.repaint();return}const image=this.host.ownerDocument.createElement("img");this.pendingImage=image;const settle=loaded=>{!lease.isCurrent()||this.pendingImage!==image||(image.onload=null,image.onerror=null,this.pendingImage=void 0,this.image=loaded?Object.freeze({...value,src}):void 0,this.state=loaded?"ready":"error",this.repaint())};image.onload=()=>settle(!0),image.onerror=()=>settle(!1),image.src=src}))}retry(index){if(this.count===0){this.refresh();return}this.requestedIndex=-1,this.select(index),this.repaint()}adopted(){this.requests.adopted(),this.window.adopted(),this.refresh()}hostConnected(){this.dirty=!0,this.repaint()}hostDisconnected(){this.dirty=!0,this.clearImage()}}export{LightboxSourceController,SOURCE_THUMBNAIL_WINDOW};
|
|
@@ -10,6 +10,9 @@ readonly src:string;
|
|
|
10
10
|
* real alt text for meaningful images. */
|
|
11
11
|
readonly alt?:string;
|
|
12
12
|
/** Optional visible caption for this image, rendered in `part="caption"` below the stage.*/
|
|
13
|
-
readonly caption?:string;
|
|
13
|
+
readonly caption?:string;
|
|
14
|
+
/** Optional small image for the `with-thumbnails` strip; the strip falls back to `src`.
|
|
15
|
+
* Validated with `safeMediaSrc()` before use. */
|
|
16
|
+
readonly thumbnail?:string;}
|
|
14
17
|
/** Host-owned access to the complete ordered image collection.*/
|
|
15
18
|
export interface LyraLightboxSource{readonly revision:LyraSourceRevision;readonly images:LyraIndexedView<LyraSourceRecord<LyraLightboxImage>>;}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type{LyraLightboxImage,LyraLightboxSource}from'./lightbox-types.js';export type{LyraLightboxImage,LyraLightboxSource}from'./lightbox-types.js';import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import{type LyraImageFit}from'../../../internal/image-fit.js';export type{LyraImageFit}from'../../../internal/image-fit.js';
|
|
1
|
+
import type{LyraLightboxImage,LyraLightboxSource}from'./lightbox-types.js';export type{LyraLightboxImage,LyraLightboxSource}from'./lightbox-types.js';import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraLightboxItem}from'./lightbox-item.class.js';import{type LyraImageFit}from'../../../internal/image-fit.js';export type{LyraImageFit}from'../../../internal/image-fit.js';
|
|
2
2
|
/**
|
|
3
3
|
* Reason a lightbox was dismissed, forwarded as the `lr-close-request` and `lr-close` event detail --
|
|
4
4
|
* 1:1 copy of `<lr-dialog>`'s own `DialogCloseReason` contract. `'escape'` and `'backdrop'`
|
|
@@ -11,16 +11,20 @@ export type LyraLightboxCloseReason='escape'|'backdrop'|'close-button'|'api'|'un
|
|
|
11
11
|
/** The close affordance, or the lightbox host when removal closes an open instance.*/
|
|
12
12
|
export interface LyraLightboxHideDetail{source:Element;}
|
|
13
13
|
/** The affordance that requested lightbox dismissal.*/
|
|
14
|
-
export interface LyraLightboxCloseDetail{reason:LyraLightboxCloseReason;}
|
|
14
|
+
export interface LyraLightboxCloseDetail{reason:LyraLightboxCloseReason;}
|
|
15
|
+
/** Detail of `lr-item-change`: the new and previous position, with the matching `<lr-lightbox-item>`
|
|
16
|
+
* elements when the lightbox is showing slotted items (`null` for `images`/`imageSource` data). */
|
|
17
|
+
export interface LyraLightboxItemChangeDetail{index:number;previousIndex:number;item:LyraLightboxItem|null;previousItem:LyraLightboxItem|null;}export interface LyraLightboxEventMap{'lr-show':CustomEvent<null>;'lr-after-show':CustomEvent<null>;'lr-hide':CustomEvent<LyraLightboxHideDetail>;'lr-after-hide':CustomEvent<null>;'lr-close-request':CustomEvent<LyraLightboxCloseDetail>;'lr-close':CustomEvent<LyraLightboxCloseDetail>;'lr-index-change':CustomEvent<{index:number;}>;'lr-item-change':CustomEvent<LyraLightboxItemChangeDetail>;
|
|
15
18
|
/** Not emitted by `LyraLightbox` itself -- the embedded `<lr-pan-zoom>` already
|
|
16
19
|
* dispatches this via a composed, bubbling `emit()` call, which continues through this
|
|
17
20
|
* element's own shadow boundary with no re-dispatch needed. Listed here purely for
|
|
18
21
|
* discoverability. */
|
|
19
22
|
'lr-zoom-change':CustomEvent<{zoom:number;}>;}
|
|
20
23
|
/**
|
|
21
|
-
* `<lr-lightbox>` — a full-screen, modal, click-to-enlarge image viewer with prev/next
|
|
22
|
-
* navigation across an ordered set of
|
|
23
|
-
*
|
|
24
|
+
* `<lr-lightbox>` — a full-screen, modal, click-to-enlarge image and video viewer with prev/next
|
|
25
|
+
* navigation across an ordered set of media. It mirrors `wa-lightbox`: slot `<lr-lightbox-item>`
|
|
26
|
+
* children (progressive-enhancement links that work without JavaScript) or drive it from data with
|
|
27
|
+
* `images`/`imageSource`; the original data-driven API is unchanged and takes precedence when set.
|
|
24
28
|
*
|
|
25
29
|
* **Not a form-associated control** -- no `label`/`hint`/`errorText` chrome; its
|
|
26
30
|
* `accessibleLabel` only overrides the dialog's own accessible name. The native-wrapper/
|
|
@@ -46,20 +50,43 @@ export interface LyraLightboxCloseDetail{reason:LyraLightboxCloseReason;}export
|
|
|
46
50
|
* who had Tabbed into the frame's viewport mid-navigation.
|
|
47
51
|
*
|
|
48
52
|
* Lifecycle: `show()` emits cancelable `lr-show` before committing `open=true`, followed by
|
|
49
|
-
* `lr-after-show`
|
|
50
|
-
* `open=false`
|
|
51
|
-
* `lr-close` with `{ reason }` after the state commits, and
|
|
52
|
-
* `lr-after-hide`
|
|
53
|
+
* `lr-after-show` once the open panel has rendered and its enter animation has finished.
|
|
54
|
+
* `hide()`/`close()` and post-render writes to `open=false` emit cancelable `lr-hide` and
|
|
55
|
+
* `lr-close-request`, followed by `lr-close` with `{ reason }` after the state commits, and
|
|
56
|
+
* `lr-after-hide` once the exit animation has finished. Under `prefers-reduced-motion` or a zero
|
|
57
|
+
* `--show-duration`/`--hide-duration` the animations finish at once, so both events follow the
|
|
58
|
+
* render directly. A transition interrupted by the opposite one emits no after-event of its own.
|
|
59
|
+
* The returned promises resolve with the after-events. A veto leaves the property and reflected
|
|
53
60
|
* attribute synchronized. Initial `open` markup is state rather than a transition and emits no
|
|
54
61
|
* lifecycle events. Removing an open instance emits non-cancelable `lr-hide`, `lr-close` with
|
|
55
62
|
* reason `unmount`, and `lr-after-hide`; removal cannot be vetoed.
|
|
56
63
|
*
|
|
57
|
-
* **
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
64
|
+
* **Slotted items.** With `<lr-lightbox-item>` children (at any depth) and no `images`/`imageSource`,
|
|
65
|
+
* the host stays inline on the page and shows the items; opening presents the viewer over the
|
|
66
|
+
* page. Items with `type="video"` play in a native `<video>` that pauses when the slide changes
|
|
67
|
+
* or the viewer closes. `with-thumbnails` adds a thumbnail strip, `without-navigation` hides the
|
|
68
|
+
* previous/next buttons (swipe and arrow keys still work), and `without-zoom` removes zooming.
|
|
69
|
+
* An item whose direct child is a `<template>` shows a copy of that template's content as its
|
|
70
|
+
* slide (see `<lr-lightbox-item>`); the copy is made while the slide is shown and placed in a
|
|
71
|
+
* `<div slot="slide-content">` the lightbox appends to itself, so page styles reach it.
|
|
72
|
+
* Content that handles its own dragging should call `preventDefault()` on `pointerdown` so a swipe
|
|
73
|
+
* does not start there.
|
|
74
|
+
*
|
|
75
|
+
* **Swiping.** In every mode, a touch or pen drag that is clearly horizontal moves the slide with
|
|
76
|
+
* the pointer. Releasing it at least 50px from where it started, toward an existing item, moves to
|
|
77
|
+
* that item and the incoming slide continues from the release point; a shorter drag, a mostly
|
|
78
|
+
* vertical one, a drag past the first or last item without `loop` (which follows the pointer with
|
|
79
|
+
* resistance), and a `pointercancel` settle the slide back into place. Directions reverse under
|
|
80
|
+
* RTL. Under `prefers-reduced-motion` the slide does not follow the pointer and the release
|
|
81
|
+
* navigates or stays without motion. A mouse never swipes, nor does a drag that starts on a
|
|
82
|
+
* control, a link, a video or a form field, or while the image is zoomed in. The open/close and
|
|
83
|
+
* slide motion use the `--show-duration`/`--hide-duration`/`--slide-gap` properties and stop under
|
|
84
|
+
* `prefers-reduced-motion`.
|
|
85
|
+
*
|
|
86
|
+
* **Scope (deliberate, not oversights):** no dot-style indicators (a textual counter scales
|
|
87
|
+
* better to photo-set sizes); no click-on-image-to-navigate (the image is already meaningfully
|
|
88
|
+
* interactive -- it focuses the zoomable frame's viewport and drives its native scroll-to-pan);
|
|
89
|
+
* no inertial fling (only the release distance decides).
|
|
63
90
|
*
|
|
64
91
|
* When opened outside an existing native modal dialog, the modal surface uses an internal
|
|
65
92
|
* native dialog so pointer, keyboard, and focus interaction remain available without moving
|
|
@@ -68,27 +95,43 @@ export interface LyraLightboxCloseDetail{reason:LyraLightboxCloseReason;}export
|
|
|
68
95
|
* the host re-shows only after the close.
|
|
69
96
|
*
|
|
70
97
|
* @customElement lr-lightbox
|
|
98
|
+
* @slot - One or more `<lr-lightbox-item>` elements, with any markup that lays them out.
|
|
71
99
|
* @slot actions - Optional extra toolbar buttons (e.g. download/share/delete), rendered in
|
|
72
100
|
* `part="toolbar"` between the counter and the close button.
|
|
101
|
+
* @slot close-icon - Optional close icon used instead of the default.
|
|
102
|
+
* @slot previous-icon - Optional previous icon used instead of the default.
|
|
103
|
+
* @slot next-icon - Optional next icon used instead of the default.
|
|
104
|
+
* @slot zoom-in-icon - Optional icon on the zoom button while the image can be zoomed in.
|
|
105
|
+
* @slot zoom-out-icon - Optional icon on the zoom button while the image is zoomed in.
|
|
73
106
|
* @event lr-hide - Conditionally cancelable visibility event with the close source in its detail:
|
|
74
107
|
* cancelable before a requested close, non-cancelable when an open instance unmounts.
|
|
75
108
|
* @event lr-close-request - Cancelable proposal before dismissal; `detail: { reason }`.
|
|
76
109
|
* Calling `preventDefault()` keeps the lightbox open.
|
|
77
110
|
* @event lr-close - Non-cancelable accepted dismissal with `{ reason }` detail, including unmount.
|
|
78
111
|
* @event lr-show - Cancelable request fired by `show()` before `open` changes.
|
|
79
|
-
* @event lr-after-show - Fired after a successful `show()` has rendered the open panel
|
|
80
|
-
*
|
|
112
|
+
* @event lr-after-show - Fired after a successful `show()` has rendered the open panel and its
|
|
113
|
+
* enter animation has finished (immediately under reduced motion or a zero duration).
|
|
114
|
+
* @event lr-after-hide - Fired after a successful `hide()`/`close()` has rendered closed and its
|
|
115
|
+
* exit animation has finished (immediately under reduced motion or a zero duration).
|
|
81
116
|
* @event lr-index-change - Fired for `next()`/`previous()`/`goTo()` navigation, including the
|
|
82
|
-
* built-in button and keyboard paths, and when a shrinking `images` moves the
|
|
83
|
-
* fired when a consumer sets `index` directly
|
|
117
|
+
* built-in button, swipe, thumbnail and keyboard paths, and when a shrinking `images` moves the
|
|
118
|
+
* shown image. Not fired when a consumer sets `index` directly (as `<lr-carousel>` does not fire
|
|
119
|
+
* `lr-slide-change` for a direct `currentSlide` write); call `goTo()` to change the item and be
|
|
120
|
+
* notified. Source mode uses the complete logical count
|
|
84
121
|
* and emits the requested index before asynchronous image resolution. `detail: { index }` is always the rendered
|
|
85
122
|
* integer index.
|
|
123
|
+
* @event lr-item-change - Fired alongside `lr-index-change` for the same navigations, with
|
|
124
|
+
* `detail: { index, previousIndex, item, previousItem }` (items are `null` in data mode). Like
|
|
125
|
+
* `lr-index-change` it reports navigation, so writing `index` directly does not fire it, whether
|
|
126
|
+
* the lightbox is open or closed; `goTo()`, `next()` and `previous()` do.
|
|
86
127
|
* @event lr-zoom-change - Not emitted by `LyraLightbox` itself -- see the interface doc above.
|
|
87
128
|
* `detail: { zoom }`.
|
|
129
|
+
* @csspart surface - The viewer's viewport layer. Only positioned and shown while open (slotted mode).
|
|
88
130
|
* @csspart backdrop - The full-viewport scrim, positioned behind `panel`.
|
|
89
|
-
* @csspart panel - `role="dialog"` while open, `aria-modal="true"`, `tabindex="-1"`. Fills the
|
|
131
|
+
* @csspart panel - Also exposed as `dialog`. `role="dialog"` while open, `aria-modal="true"`, `tabindex="-1"`. Fills the
|
|
90
132
|
* padded safe area -- unlike `<lr-dialog>`, it does not shrink-wrap to content, since
|
|
91
133
|
* maximizing image real estate is the point.
|
|
134
|
+
* @csspart dialog - The same element as `panel`.
|
|
92
135
|
* @csspart toolbar - Top row: `counter` (start), the `actions` slot wrapper, `close-button` (end).
|
|
93
136
|
* @csspart counter - Visible, localized "Image N of Total" text. Omitted entirely while
|
|
94
137
|
* `without-counter` is set.
|
|
@@ -101,40 +144,70 @@ export interface LyraLightboxCloseDetail{reason:LyraLightboxCloseReason;}export
|
|
|
101
144
|
* @csspart actions - Wrapper around the `actions` slot; `hidden` when nothing is slotted.
|
|
102
145
|
* @csspart close-button - The close button. Always rendered -- unlike `<lr-dialog>`'s opt-in
|
|
103
146
|
* `closable`, a full-screen lightbox has no other built-in chrome, so this is not optional.
|
|
104
|
-
|
|
147
|
+
|
|
148
|
+
* @csspart stage - Also exposed as `scroll-container`. Houses the embedded `<lr-pan-zoom>` plus the floating
|
|
105
149
|
* `previous-button`/`next-button`.
|
|
150
|
+
* @csspart scroll-container - The same element as `stage`.
|
|
106
151
|
* @csspart source-loading - Source-mode loading message.
|
|
107
152
|
* @csspart source-error - Source descriptor or image loading error.
|
|
108
153
|
* @csspart source-retry - Retry the current source image after an error.
|
|
154
|
+
* @csspart slide - The wrapper around the current image or video.
|
|
155
|
+
* @csspart video - The current video of a `type="video"` item.
|
|
156
|
+
* @csspart zoom-button - Toolbar button that toggles between fitted and zoomed in. Rendered for
|
|
157
|
+
* slotted items only; `images`/`imageSource` galleries keep the embedded `frame-controls`.
|
|
158
|
+
* @csspart thumbnails - The thumbnail strip, rendered only with `with-thumbnails`.
|
|
159
|
+
* @csspart thumbnail - One thumbnail button in the strip.
|
|
160
|
+
* @csspart thumbnail-active - Added to the current item's thumbnail.
|
|
109
161
|
* @csspart frame - The embedded `<lr-pan-zoom>` element itself.
|
|
162
|
+
* @csspart image - The same element as `frame`: the current full-size image's zoomable frame.
|
|
110
163
|
* @csspart frame-viewport - The embedded pan-zoom's scrollable viewport.
|
|
111
164
|
* @csspart frame-content - The embedded pan-zoom's transformed content wrapper.
|
|
112
165
|
* @csspart frame-controls - The embedded pan-zoom's zoom controls.
|
|
113
|
-
* @csspart previous-button - Floating, absolutely positioned inside `stage`. Rendered only when
|
|
166
|
+
* @csspart previous-button - Also exposed as `navigation-button navigation-button-previous`. Floating, absolutely positioned inside `stage`. Rendered only when
|
|
114
167
|
* `images.length > 1`.
|
|
115
168
|
* @csspart previous-glyph - The `chevronIcon()` inside `previous-button`, mirrored under RTL.
|
|
116
|
-
* @csspart next-button - Symmetric to `previous-button
|
|
169
|
+
* @csspart next-button - Symmetric to `previous-button` (`navigation-button navigation-button-next`).
|
|
117
170
|
* @csspart next-glyph - Symmetric to `previous-glyph`.
|
|
171
|
+
* @csspart navigation-button - Both the previous and the next button.
|
|
172
|
+
* @csspart navigation-button-previous - The same element as `previous-button`.
|
|
173
|
+
* @csspart navigation-button-next - The same element as `next-button`.
|
|
118
174
|
* @csspart caption - The current image's caption text. Only rendered when the current image's
|
|
119
175
|
* `caption` is non-empty. Its `id` is the `aria-describedby` target on `panel`.
|
|
120
176
|
* @cssprop --lr-lightbox-overlay-color - The backdrop scrim color.
|
|
177
|
+
* @cssprop [--backdrop-color=var(--lr-color-overlay-strong)] - The backdrop scrim color; `--lr-lightbox-overlay-color` wins when both are set.
|
|
178
|
+
* @cssprop [--backdrop-filter=none] - A filter applied to the page behind the backdrop, e.g. `blur(1rem)`.
|
|
121
179
|
* @cssprop --lr-lightbox-control-bg - Background for every floating/toolbar icon button.
|
|
122
180
|
* @cssprop --lr-lightbox-control-color - Icon/text color paired with `--lr-lightbox-control-bg`.
|
|
181
|
+
* @cssprop [--controls-background=var(--lr-color-neutral)] - Background of the controls, counter and caption; `--lr-lightbox-control-bg` wins when both are set.
|
|
182
|
+
* @cssprop [--controls-color=var(--lr-color-on-neutral)] - Text and icon color of the controls, counter and caption; `--lr-lightbox-control-color` wins when both are set.
|
|
183
|
+
* @cssprop [--spacing=var(--lr-space-s)] - Space between the toolbar, the media, the caption and the thumbnail strip.
|
|
123
184
|
* @cssprop --lr-lightbox-control-hover-bg - Hovered control background. Defaults to `--lr-color-brand-quiet`.
|
|
124
185
|
* @cssprop --lr-lightbox-control-hover-color - Hovered control icon/text color. Defaults to `--lr-color-brand`.
|
|
125
186
|
* @cssprop --lr-lightbox-control-active-bg - Pressed control background. Defaults to the hover background mixed toward `--lr-color-mix-partner`.
|
|
126
187
|
* @cssprop --lr-lightbox-control-active-color - Pressed control icon/text color. Defaults to the hover color.
|
|
188
|
+
* @cssprop [--show-duration=var(--lr-lightbox-panel-duration)] - Opening animation duration.
|
|
189
|
+
* @cssprop [--hide-duration=var(--lr-lightbox-panel-duration)] - Closing animation duration.
|
|
190
|
+
* @cssprop --lr-lightbox-panel-duration - Duration of the viewer's open/close and slide motion. Defaults to `--lr-duration-base`.
|
|
191
|
+
* @cssprop [--slide-gap=var(--lr-lightbox-slide-gap)] - Space the incoming slide travels past the edge. Defaults to `--lr-space-l`.
|
|
192
|
+
* @cssprop --lr-lightbox-slide-gap - Public form of `--slide-gap`.
|
|
193
|
+
* @cssprop [--thumbnail-size=var(--lr-lightbox-thumbnail-size)] - Inline and block size of each thumbnail.
|
|
194
|
+
* @cssprop --lr-lightbox-thumbnail-size - Public form of `--thumbnail-size`. Defaults to `--lr-size-3-5rem`.
|
|
195
|
+
* @cssprop [--media-border-radius=var(--lr-lightbox-media-radius)] - Corner radius of the media.
|
|
196
|
+
* @cssprop --lr-lightbox-media-radius - Public form of `--media-border-radius`. Defaults to `0`.
|
|
127
197
|
* @cssprop --lr-lightbox-status-color - Color of the source-mode loading and error messages on the backdrop.
|
|
198
|
+
* @cssstate open - Present while the lightbox is open.
|
|
199
|
+
* @cssstate zoomed - Present while the current image is zoomed in.
|
|
128
200
|
* @status stable
|
|
129
201
|
* @since 4.0.0
|
|
130
202
|
*/
|
|
131
|
-
export declare class LyraLightbox extends LyraElement<LyraLightboxEventMap>{static styles:import("lit").CSSResultGroup[];private readonly hostDescription;adoptedCallback():void;private _open;
|
|
203
|
+
export declare class LyraLightbox extends LyraElement<LyraLightboxEventMap>{protected static collectionSupport:import("../../../internal/lyra-element.js").LyraCollectionSupport;protected static readonly immutableEventDetails:readonly string[];protected static readonly identityEventDetailProperties:Readonly<{'lr-item-change':readonly string[];}>;static styles:import("lit").CSSResultGroup[];private readonly hostDescription;adoptedCallback():void;private _open;
|
|
132
204
|
/** Whether the lightbox is open. Post-render writes run the same cancelable lifecycle as
|
|
133
205
|
* `show()`/`hide()`/`close()`; initial markup is state and emits nothing. */
|
|
134
206
|
get open():boolean;set open(next:boolean);protected static readonly identityCollectionObjectProperties:readonly string[];private _imageSource?;private navigationIntent;private pendingIndexChange?;private sourceBindingCurrent;private sourceState;private readonly sourceController;
|
|
135
207
|
/** Optional host-owned full image collection. Takes precedence over images; undefined restores
|
|
136
208
|
* legacy input. Reassign, including the same source, or call requestUpdate() after mutation.
|
|
137
|
-
* Only the current image loads; at most three descriptors are retained
|
|
209
|
+
* Only the current image loads; at most three descriptors are retained (with `with-thumbnails`,
|
|
210
|
+
* a separate strip window also reads the descriptors of the 15 positions around the current one). Each key/src/alt/caption
|
|
138
211
|
* is limited to 65,536 UTF-16 units. Invalid defined sources fail closed with a retry action.
|
|
139
212
|
* index remains the requested logical index while its image loads. */
|
|
140
213
|
get imageSource():LyraLightboxSource|undefined;set imageSource(value:LyraLightboxSource|undefined);requestUpdate(...args:Parameters<LyraElement['requestUpdate']>):void;private imageCount;private _images;private _imagesSource?;private _fit;
|
|
@@ -155,9 +228,20 @@ loop:boolean;
|
|
|
155
228
|
lightDismiss:boolean;
|
|
156
229
|
/** Hides only the visible `part="counter"`. The accessibility `part="live-region"`
|
|
157
230
|
* announcement remains active so navigation is still conveyed when visual chrome is hidden.
|
|
158
|
-
*
|
|
159
|
-
* attributes on a modal that already churns them. */
|
|
231
|
+
* Not reflected, matching the published contract. */
|
|
160
232
|
withoutCounter:boolean;
|
|
233
|
+
/** Shows a strip of thumbnails for jumping between items. Each uses the item's `thumbnail`
|
|
234
|
+
* (slotted items and `images`/`imageSource` records), else the full image. With `imageSource`
|
|
235
|
+
* the strip covers the 15 positions around the current one and reads only their descriptors;
|
|
236
|
+
* a position whose descriptor is still loading shows its number. */
|
|
237
|
+
withThumbnails:boolean;
|
|
238
|
+
/** Hides the previous/next buttons. Swiping and the arrow keys still navigate.*/
|
|
239
|
+
withoutNavigation:boolean;
|
|
240
|
+
/** Disables zooming and removes the zoom button and the embedded zoom controls.*/
|
|
241
|
+
withoutZoom:boolean;
|
|
242
|
+
/** A label that names the viewer for assistive technology, e.g. "Vacation photos". A host
|
|
243
|
+
* `aria-label` wins over it; blank falls back to the localized default. Reflected. */
|
|
244
|
+
label:string;
|
|
161
245
|
/** Base image sizing policy, using the same vocabulary as `<lr-image-viewer>`. `actual`
|
|
162
246
|
* preserves the current natural-size behavior; `contain` fits the complete image inside the
|
|
163
247
|
* available stage and `width` fills its inline size. Fit recalculates from layout when the
|
|
@@ -171,7 +255,15 @@ maxZoom:number;
|
|
|
171
255
|
/** Passed through to the embedded `<lr-pan-zoom>` as `.zoomStep`.*/
|
|
172
256
|
zoomStep:number;
|
|
173
257
|
/** A nonblank host label names the dialog. Blank labels use the localized `lightboxLabel` default.*/
|
|
174
|
-
accessibleLabel:string|null;private readonly slotPresence;private
|
|
258
|
+
accessibleLabel:string|null;private readonly slotPresence;private itemsVersion;private zoomLevel;private itemRecords;private itemImages;private itemObserver?;private renderedIndex;private renderedRecord?;private lastShownSrc;private firstUpdateDone;private swipe?;private transitionAnimations;private morphGeneration;private morphingItem?;private lastItemSignature;
|
|
259
|
+
/** The slotted `<lr-lightbox-item>` elements in document order, including those without usable media.*/
|
|
260
|
+
get items():LyraLightboxItem[];
|
|
261
|
+
/** The current slotted item, or `undefined` in data mode. Useful for download/share buttons in `actions`.*/
|
|
262
|
+
get currentItem():LyraLightboxItem|undefined;private get itemMode();private get activeImages();private collectItems;private syncItems;private onHostClick;
|
|
263
|
+
/** Zooms the current image in by one step. A no-op for video, or with `without-zoom`.*/
|
|
264
|
+
zoomIn():void;
|
|
265
|
+
/** Zooms the current image out by one step. A no-op for video, or with `without-zoom`.*/
|
|
266
|
+
zoomOut():void;private canZoom;private toggleZoom;private onZoomChange;private pauseVideos;private onSwipeStart;private onSwipeMove;private onSwipeEnd;private onSwipeCancel;private releaseDrag;private swipeIsForward;private hasNeighbor;private slideElement;private swipeRelease;private liveText;private frameEl?;private readonly lightboxInternals;private overlay?;private readonly nativeModal;private readonly modalSurface;private readonly announcements;private sourceErrorAnnounced;private sourceHasRendered;private lastSourceImage?;private announcementBaseline?;private connectionGeneration;private transitionGeneration;private readonly openRequest;private readonly captionId;private currentIndex;private syncImages;private changeTo;
|
|
175
267
|
/** Advances to the next image, respecting `loop`.*/
|
|
176
268
|
next():void;
|
|
177
269
|
/** Moves to the previous image, respecting `loop`.*/
|
|
@@ -180,7 +272,8 @@ previous():void;
|
|
|
180
272
|
* clamping or loop wrapping, so `lr-index-change.detail.index` is always the rendered
|
|
181
273
|
* integer index. Non-finite values are no-ops. */
|
|
182
274
|
goTo(index:number):void;
|
|
183
|
-
/** Request opening, then resolve once the open panel is rendered
|
|
275
|
+
/** Request opening, then resolve once the open panel is rendered and its enter animation has
|
|
276
|
+
* finished (immediately under reduced motion or a zero duration). */
|
|
184
277
|
show():Promise<void>;
|
|
185
278
|
/** Close with the standard API reason.*/
|
|
186
279
|
hide():Promise<void>;
|
|
@@ -190,4 +283,4 @@ hide():Promise<void>;
|
|
|
190
283
|
* `'backdrop'`/`'close-button'`; a consumer's own close affordance (e.g. an `actions`-slotted
|
|
191
284
|
* button) should call this directly with its own reason string.
|
|
192
285
|
*/
|
|
193
|
-
close(reason?:LyraLightboxCloseReason):Promise<void>;private closeFrom;private applyOpenState;private syncOpenAttribute;private updateLiveRegion;private captureAnnouncementBaseline;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;connectedCallback():void;disconnectedCallback():void;private activateOverlay;private deactivateOverlay;private onBackdropClick;private onCloseButtonClick;private onPanelKeyDown;constructor();render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-lightbox':LyraLightbox;}}
|
|
286
|
+
close(reason?:LyraLightboxCloseReason):Promise<void>;private closeFrom;private cancelTransitionAnimations;private settleAnimations;private surfaceSpec;private startSurfaceAnimations;private playExit;private animateSlide;private customSlide?;private syncCustomSlide;private removeCustomSlide;private markMorphing;private applyOpenState;private syncOpenAttribute;private updateLiveRegion;private captureAnnouncementBaseline;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;connectedCallback():void;disconnectedCallback():void;private activateOverlay;private deactivateOverlay;private onBackdropClick;private onCloseButtonClick;private onPanelKeyDown;constructor();private thumbnailRange;private renderThumbnails;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-lightbox':LyraLightbox;}}
|
|
@@ -1,33 +1,39 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{tag}from"../../../internal/prefix.js";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{ModalOpenRequest}from"../../../internal/modal-open-request.js";import{ModalSurfaceController}from"../../../internal/modal-surface-controller.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{html,nothing}from"lit";import{live}from"lit/directives/live.js";import{property,query,state}from"lit/decorators.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{LyraElement}from"../../../internal/lyra-element.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{isAccessibilityVisible,nextId,srOnly}from"../../../internal/a11y.js";import{closeIcon,chevronIcon}from"../../../internal/icons.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{finiteCount,finiteInteger}from"../../../internal/numbers.js";import{shouldIgnoreNavigationKey}from"../../../internal/list-navigation.js";import{normalizeImageFit}from"../../../internal/image-fit.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{styles}from"./lightbox.styles.js";import{LightboxSourceController}from"./lightbox-source.js";import{keyEventOwnedByInnerControl}from"../../../internal/hotkey.js";import{isElement}from"../../../internal/rendered-tree-traversal.js";import{repairControlFocusOnUpdate}from"../../../internal/control-focus-repair.js";import{trackScrollRegions}from"../../../internal/scroll-region.js";import{blankNumberConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_imageViewerFailedToLoad,LYRA_DEFAULT_lightboxImagePosition,LYRA_DEFAULT_lightboxLabel}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_close,LYRA_DEFAULT_loading,LYRA_DEFAULT_next,LYRA_DEFAULT_previous,LYRA_DEFAULT_retry}from"../../../internal/default-strings/shared.generated.js";const MAX_LIGHTBOX_IMAGES=1e4,EMPTY_LIGHTBOX_IMAGES=/* @__PURE__ */(()=>Object.freeze([]))();function snapshotLightboxImages(value){try{if(!Array.isArray(value))return EMPTY_LIGHTBOX_IMAGES;const count=Math.min(value.length,MAX_LIGHTBOX_IMAGES),images=[];for(let index=0;index<count;index++)try{const candidate=value[index];if(typeof candidate!="object"||candidate===null)continue;const src=candidate.src;if(typeof src!="string")continue;const alt=candidate.alt,caption=candidate.caption;images.push(Object.freeze({src,...typeof alt=="string"?{alt}:{},...typeof caption=="string"?{caption}:{}}))}catch{}return images.length?Object.freeze(images):EMPTY_LIGHTBOX_IMAGES}catch{return EMPTY_LIGHTBOX_IMAGES}}function queueDocumentMicrotask(ownerDocument,callback){const ownerWindow=ownerDocument.defaultView;if(ownerWindow){ownerWindow.queueMicrotask(callback);return}Promise.resolve().then(callback)}class LyraLightbox extends LyraElement{static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close,imageViewerFailedToLoad:LYRA_DEFAULT_imageViewerFailedToLoad,lightboxImagePosition:LYRA_DEFAULT_lightboxImagePosition,lightboxLabel:LYRA_DEFAULT_lightboxLabel,loading:LYRA_DEFAULT_loading,next:LYRA_DEFAULT_next,previous:LYRA_DEFAULT_previous,retry:LYRA_DEFAULT_retry}}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,srOnly,styles]}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted(),this.hostDescription.adopted(),this.sourceController.adopted()}get open(){return this._open}set open(next){const normalized=!!next;if(!this.openRequest.coalesce(normalized)&&normalized!==this._open){if(!this.hasUpdated){this.applyOpenState(normalized);return}normalized?this.show():this.close("api")}}static{this.identityCollectionObjectProperties=Object.freeze(["imageSource"])}get imageSource(){return this._imageSource}set imageSource(value){const previous=this._imageSource;this.navigationIntent++,this.sourceBindingCurrent=!1,this._imageSource=value,this.sourceController?.refresh(),this.frameEl&&(this.frameEl.src=""),this.requestUpdate("imageSource",previous)}requestUpdate(...args){args[0]===void 0&&this._imageSource!==void 0&&(this.navigationIntent++,this.sourceBindingCurrent=!1,this.sourceController?.refresh(),this.frameEl&&(this.frameEl.src="")),super.requestUpdate(...args)}imageCount(){return this.imageSource===void 0?this.images.length:this.sourceController.count}get images(){return this._images}set images(value){if(value===this._imagesSource||value===this._images)return;this._imagesSource=value;const old=this._images;this._images=snapshotLightboxImages(value),this.requestUpdate("images",old)}get index(){return this._index}set index(value){this.navigationIntent++;const previous=this._index;this._index=value,value!==previous&&this.imageSource!==void 0&&(this.sourceController?.select(this.currentIndex()),this.frameEl&&(this.frameEl.src="")),this.requestUpdate("index",previous)}get fit(){return this._fit}set fit(value){const old=this._fit;this._fit=normalizeImageFit(value,"actual"),this.requestUpdate("fit",old)}currentIndex(){const count=this.imageCount();return count===0?0:finiteCount(this.index,0,count-1)}syncImages(){const current=this.currentIndex();this.index!==current&&(this.index=current)}changeTo(index){const count=this.imageCount();if(count===0||!Number.isFinite(index))return;const requested=finiteInteger(index,0),next=this.loop?(requested%count+count)%count:Math.min(count-1,Math.max(0,requested));next!==this.currentIndex()&&(this.pendingIndexChange=this.navigationIntent+1,this.index=next)}next(){this.changeTo(this.currentIndex()+1)}previous(){this.changeTo(this.currentIndex()-1)}goTo(index){this.changeTo(index)}async show(){if(this.openRequest.coalesce(!0)||this._open)return;this.openRequest.begin(!0);const prevented=this.emit("lr-show",null,{cancelable:!0}).defaultPrevented,superseded=this.openRequest.superseded(!0);if(this.openRequest.finish(),prevented||superseded){this.syncOpenAttribute();return}this.applyOpenState(!0);const generation=++this.transitionGeneration;await this.updateComplete,generation===this.transitionGeneration&&this._open&&this.emit("lr-after-show",null)}hide(){return this.close("api")}async close(reason="api"){return this.closeFrom(reason,this)}async closeFrom(reason,source){if(this.openRequest.coalesce(!1)||!this._open)return;if(this.openRequest.begin(!1),this.emit("lr-hide",{source},{cancelable:!0}).defaultPrevented||this.openRequest.superseded(!1)){this.openRequest.finish(),this.syncOpenAttribute();return}if(this.emit("lr-close-request",{reason},{cancelable:!0}).defaultPrevented||this.openRequest.superseded(!1)){this.openRequest.finish(),this.syncOpenAttribute();return}this.openRequest.finish(),this.applyOpenState(!1);const generation=++this.transitionGeneration;this.emit("lr-close",{reason}),await this.updateComplete,generation===this.transitionGeneration&&!this._open&&this.emit("lr-after-hide",null)}applyOpenState(next){const old=this._open;this._open=next,this.requestUpdate("open",old)}syncOpenAttribute(){this.toggleAttribute("open",this._open)}updateLiveRegion(){const count=this.imageCount(),formatter=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:0,useGrouping:!1});this.liveText=count===0?"":this.localize("lightboxImagePosition",void 0,{index:formatter.format(this.currentIndex()+1),total:formatter.format(count)})}captureAnnouncementBaseline(){this.announcementBaseline={index:this.currentIndex(),images:this.images,source:this.imageSource}}willUpdate(changed){if(super.willUpdate(changed),this.sourceBindingCurrent=this.sourceController.update(this.imageSource,this.effectiveLocale),this.sourceBindingCurrent&&(changed.has("images")||changed.has("index")||changed.has("imageSource")||changed.has("sourceState"))){const index=changed.has("index")?void 0:this.index,intent=this.navigationIntent+1;this.syncImages(),index!==void 0&&this.index!==index&&this.navigationIntent===intent&&this.sourceBindingCurrent&&(this.pendingIndexChange=intent)}if(this.sourceBindingCurrent&&this.imageSource!==void 0&&this.sourceController.select(this.currentIndex()),this.sourceBindingCurrent||queueDocumentMicrotask(this.ownerDocument,()=>{this.isConnected&&this.sourceState++}),this.sourceBindingCurrent&&(changed.has("index")||changed.has("images")||changed.has("imageSource")||changed.has("sourceState")||changed.has("strings")||changed.has("locale"))&&this.updateLiveRegion(),changed.has("open"))if(this.open)this.modalSurface.open(()=>this.activateOverlay());else{const hadOverlay=this.overlay!==void 0;this.modalSurface.close(hadOverlay,()=>this.deactivateOverlay(),()=>!this.open)}}updated(changed){super.updated(changed),!(this.announcementBaseline?.index===this.currentIndex()&&this.announcementBaseline.images===this.images&&this.announcementBaseline.source===this.imageSource)&&this.sourceBindingCurrent&&this.open&&this.liveText!==""&&isAccessibilityVisible(this)&&(changed.has("index")||changed.has("images")||changed.has("imageSource"))&&this.announcements.announcePolite(this.liveText);const sourceError=this.sourceBindingCurrent&&this.imageSource!==void 0&&this.sourceController.state==="error";sourceError||(this.sourceErrorAnnounced=!1),sourceError&&!this.sourceErrorAnnounced&&this.sourceHasRendered&&this.open&&isAccessibilityVisible(this)&&(this.sourceErrorAnnounced=!0,this.announcements.announcePolite(this.localize("imageViewerFailedToLoad"))),this.sourceHasRendered=!0,this.isConnected&&this.sourceBindingCurrent&&this.captureAnnouncementBaseline(),changed.has("open")&&this.open&&(this.modalSurface.show(),this.overlay?.focusInitial());let currentSourceChanged=!1;if(changed.has("images")){const previousImages=changed.get("images"),previousIndex=changed.has("index")?changed.get("index")??0:this.index;currentSourceChanged=previousImages?.[previousImages.length>0?finiteCount(previousIndex,0,previousImages.length-1):0]?.src!==this.images[this.currentIndex()]?.src}const sourceImage=this.imageSource===void 0?void 0:this.sourceController.image;currentSourceChanged||=changed.has("imageSource")||sourceImage!==void 0&&sourceImage!==this.lastSourceImage,this.lastSourceImage=sourceImage,this.open&&(changed.has("index")||currentSourceChanged)&&this.frameEl?.resetView();const intent=this.pendingIndexChange;this.pendingIndexChange=void 0,intent===this.navigationIntent&&this.emit("lr-index-change",{index:this.index})}connectedCallback(){super.connectedCallback();const generation=++this.connectionGeneration,connectionDocument=this.ownerDocument;this.captureAnnouncementBaseline(),this.hasUpdated&&this.open&&(this.overlay?.isActive()?this.overlay.resume():this.activateOverlay(),queueDocumentMicrotask(connectionDocument,()=>{this.connectionGeneration===generation&&this.ownerDocument===connectionDocument&&this.isConnected&&this.open&&(this.modalSurface.show(),this.overlay?.focusInitial())}))}disconnectedCallback(){const generation=++this.connectionGeneration,connectionDocument=this.ownerDocument;this.announcementBaseline=void 0,this.sourceErrorAnnounced=!1,this.sourceHasRendered=!1,this.lastSourceImage=void 0,super.disconnectedCallback(),this.modalSurface.disconnect(),this.overlay?.suspend(),this.open&&queueDocumentMicrotask(connectionDocument,()=>{this.connectionGeneration===generation&&this.ownerDocument===connectionDocument&&!this.isConnected&&this.open&&(this.transitionGeneration++,this.emit("lr-hide",{source:this}),this.applyOpenState(!1),this.emit("lr-close",{reason:"unmount"}),this.emit("lr-after-hide",null))})}activateOverlay(){this.overlay?.isActive()||(this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="panel"]')??null,onEscape:()=>{const panel=this.renderRoot.querySelector('[part="panel"]')??this;this.closeFrom("escape",panel)},onBackdrop:()=>{const backdrop=this.renderRoot.querySelector('[part="backdrop"]')??this;this.closeFrom("backdrop",backdrop)},preferredInitialFocus:()=>this.shadowRoot?.querySelector('[part="close-button"]')??null,lockScroll:!0,suspendWhenUnrendered:!0}))}deactivateOverlay(){this.overlay?.deactivate(),this.overlay=void 0}constructor(){super(),this.hostDescription=new HostDescriptionController(this,()=>this.renderRoot.querySelector(this.nativeModal.requested?"dialog[data-native-modal-carrier]":'[part="panel"][role="dialog"]')),this._open=!1,this.navigationIntent=0,this.sourceBindingCurrent=!0,this.sourceState=0,this.sourceController=new LightboxSourceController(this,()=>{this.sourceState++}),this._images=EMPTY_LIGHTBOX_IMAGES,this._fit="actual",this._index=0,this.loop=!1,this.lightDismiss=!1,this.withoutCounter=!1,this.minZoom=.5,this.maxZoom=4,this.zoomStep=.25,this.accessibleLabel=null,this.slotPresence=new SlotPresenceController(this),this.liveText="",this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{this.overlay?.isTopmost()&&this.closeFrom("escape",this.renderRoot.querySelector('[part="panel"]')??this)},onUnexpectedClose:()=>{this.hide().then(()=>{this.open&&this.modalSurface.show()})}}),this.modalSurface=new ModalSurfaceController(this,this.nativeModal),this.announcements=new AnnouncementSinkController(this,{eager:["polite"]}),this.sourceErrorAnnounced=!1,this.sourceHasRendered=!1,this.connectionGeneration=0,this.transitionGeneration=0,this.openRequest=new ModalOpenRequest,this.captionId=nextId("lightbox-caption"),this.onBackdropClick=()=>{this.lightDismiss&&this.overlay?.dismissBackdrop()},this.onCloseButtonClick=()=>{const button=this.renderRoot.querySelector('[part="close-button"]')??this;this.closeFrom("close-button",button)},this.onPanelKeyDown=event=>{if(event.defaultPrevented||shouldIgnoreNavigationKey(event)||event.shiftKey)return;for(const target of event.composedPath()){if(target===this)break;if(isElement(target)&&target.getRootNode()!==this.shadowRoot&&target.matches('a[href], button, [role="button"], [role="link"]'))return}if(keyEventOwnedByInnerControl(event,{container:this,ownerTag:tag("pan-zoom")}))return;const rtl=this.effectiveDirection==="rtl",forwardKey=rtl?"ArrowLeft":"ArrowRight",backwardKey=rtl?"ArrowRight":"ArrowLeft";event.key===forwardKey?(event.preventDefault(),this.next()):event.key===backwardKey?(event.preventDefault(),this.previous()):event.key==="Home"?(event.preventDefault(),this.goTo(0)):event.key==="End"&&(event.preventDefault(),this.goTo(this.imageCount()-1))},repairControlFocusOnUpdate(this,()=>[this.renderRoot.querySelector('[part="close-button"]'),this.renderRoot.querySelector('[part="frame"]')]),trackScrollRegions(this,()=>{const el=this.renderRoot.querySelector('[part="caption"]');return[el&&{el,role:!1}]})}render(){const count=this.imageCount(),current=this.currentIndex(),image=this.imageSource===void 0?count>0?this.images[current]:void 0:this.sourceController.image,sourceState=this.imageSource===void 0?void 0:this.sourceController.state,label=this.accessibleLabel?.trim()?this.accessibleLabel:this.localize("lightboxLabel"),hasCaption=!!image?.caption,formatter=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:0,useGrouping:!1}),positionText=count>0?this.localize("lightboxImagePosition",void 0,{index:formatter.format(current+1),total:formatter.format(count)}):"";return this.nativeModal.render(html`
|
|
1
|
+
import{__decorate}from"tslib";import{tag}from"../../../internal/prefix.js";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{ModalOpenRequest}from"../../../internal/modal-open-request.js";import{ModalSurfaceController}from"../../../internal/modal-surface-controller.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{html,nothing}from"lit";import{keyed}from"lit/directives/keyed.js";import{ifDefined}from"lit/directives/if-defined.js";import{live}from"lit/directives/live.js";import{property,query,state}from"lit/decorators.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{LyraElement}from"../../../internal/lyra-element.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{isAccessibilityVisible,nextId,srOnly}from"../../../internal/a11y.js";import{closeIcon,chevronIcon,minusIcon,playIcon,plusIcon}from"../../../internal/icons.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{animateRegistered}from"../../../internal/registered-animation.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{finiteCount,finiteInteger}from"../../../internal/numbers.js";import{shouldIgnoreNavigationKey}from"../../../internal/list-navigation.js";import{normalizeImageFit}from"../../../internal/image-fit.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{styles}from"./lightbox.styles.js";import{LightboxSourceController,SOURCE_THUMBNAIL_WINDOW}from"./lightbox-source.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{keyEventOwnedByInnerControl}from"../../../internal/hotkey.js";import{isElement}from"../../../internal/rendered-tree-traversal.js";import{repairControlFocusOnUpdate}from"../../../internal/control-focus-repair.js";import{trackScrollRegions}from"../../../internal/scroll-region.js";import{blankNumberConverter}from"../../../internal/converters.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{setCustomState}from"../../../internal/custom-states.js";import{LYRA_DEFAULT_imageViewerFailedToLoad,LYRA_DEFAULT_lightboxImagePosition,LYRA_DEFAULT_lightboxLabel}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_close,LYRA_DEFAULT_loading,LYRA_DEFAULT_next,LYRA_DEFAULT_previous,LYRA_DEFAULT_retry,LYRA_DEFAULT_zoomIn,LYRA_DEFAULT_zoomOut}from"../../../internal/default-strings/shared.generated.js";const MAX_LIGHTBOX_IMAGES=1e4,EMPTY_LIGHTBOX_IMAGES=/* @__PURE__ */(()=>Object.freeze([]))();function snapshotLightboxImages(value){try{if(!Array.isArray(value))return EMPTY_LIGHTBOX_IMAGES;const count=Math.min(value.length,MAX_LIGHTBOX_IMAGES),images=[];for(let index=0;index<count;index++)try{const candidate=value[index];if(typeof candidate!="object"||candidate===null)continue;const src=candidate.src;if(typeof src!="string")continue;const alt=candidate.alt,caption=candidate.caption,thumbnail=candidate.thumbnail;images.push(Object.freeze({src,...typeof alt=="string"?{alt}:{},...typeof caption=="string"?{caption}:{},...typeof thumbnail=="string"?{thumbnail}:{}}))}catch{}return images.length?Object.freeze(images):EMPTY_LIGHTBOX_IMAGES}catch{return EMPTY_LIGHTBOX_IMAGES}}function setItemViewerState(item,name,present){item.setViewerState?.(name,present)}const SWIPE_DISTANCE=50,SWIPE_SLOP=10,SWIPE_EDGE_RESISTANCE=.3,CUSTOM_SLIDE_SLOT="slide-content",CUSTOM_SLIDE_ATTRIBUTE="data-lightbox-slide",SWIPE_EXEMPT='video, button, a[href], input, select, textarea, [contenteditable]:not([contenteditable="false"])',MAX_THUMBNAILS=200,SHOW_DURATION_PROPERTY="--show-duration",HIDE_DURATION_PROPERTY="--hide-duration";function queueDocumentMicrotask(ownerDocument,callback){const ownerWindow=ownerDocument.defaultView;if(ownerWindow){ownerWindow.queueMicrotask(callback);return}Promise.resolve().then(callback)}class LyraLightbox extends LyraElement{static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close,imageViewerFailedToLoad:LYRA_DEFAULT_imageViewerFailedToLoad,lightboxImagePosition:LYRA_DEFAULT_lightboxImagePosition,lightboxLabel:LYRA_DEFAULT_lightboxLabel,loading:LYRA_DEFAULT_loading,next:LYRA_DEFAULT_next,previous:LYRA_DEFAULT_previous,retry:LYRA_DEFAULT_retry,zoomIn:LYRA_DEFAULT_zoomIn,zoomOut:LYRA_DEFAULT_zoomOut}}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-item-change"])}static{this.identityEventDetailProperties=Object.freeze({"lr-item-change":Object.freeze(["item","previousItem"])})}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,srOnly,styles]}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted(),this.hostDescription.adopted(),this.sourceController.adopted()}get open(){return this._open}set open(next){const normalized=!!next;if(!this.openRequest.coalesce(normalized)&&normalized!==this._open){if(!this.hasUpdated){this.applyOpenState(normalized);return}normalized?this.show():this.close("api")}}static{this.identityCollectionObjectProperties=Object.freeze(["imageSource"])}get imageSource(){return this._imageSource}set imageSource(value){const previous=this._imageSource;this.navigationIntent++,this.sourceBindingCurrent=!1,this._imageSource=value,this.sourceController?.refresh(),this.frameEl&&(this.frameEl.src=""),this.requestUpdate("imageSource",previous)}requestUpdate(...args){args[0]===void 0&&this._imageSource!==void 0&&(this.navigationIntent++,this.sourceBindingCurrent=!1,this.sourceController?.refresh(),this.frameEl&&(this.frameEl.src="")),super.requestUpdate(...args)}imageCount(){return this.imageSource===void 0?this.activeImages.length:this.sourceController.count}get images(){return this._images}set images(value){if(value===this._imagesSource||value===this._images)return;this._imagesSource=value;const old=this._images;this._images=snapshotLightboxImages(value),this.requestUpdate("images",old)}get index(){return this._index}set index(value){this.navigationIntent++;const previous=this._index;this._index=value,value!==previous&&this.imageSource!==void 0&&(this.sourceController?.select(this.currentIndex()),this.frameEl&&(this.frameEl.src="")),this.requestUpdate("index",previous)}get fit(){return this._fit}set fit(value){const old=this._fit;this._fit=normalizeImageFit(value,"actual"),this.requestUpdate("fit",old)}get items(){return this.collectItems()}get currentItem(){return this.itemMode?this.itemRecords[this.currentIndex()]?.element:void 0}get itemMode(){return this.imageSource===void 0&&this._images.length===0&&this.itemRecords.length>0}get activeImages(){return this.itemMode?this.itemImages:this._images}collectItems(){const own=tag("lightbox");return Array.from(this.querySelectorAll(tag("lightbox-item"))).filter(element=>element.closest(own)===this&&!element.closest(`[${CUSTOM_SLIDE_ATTRIBUTE}]`))}itemChanged(){this.syncItems()}syncItems(){const records=[],images=[];for(const element of this.collectItems()){const raw=element,src=raw.mediaSrc??safeMediaSrc(element.getAttribute("src"))??"",template=raw.slideTemplate??element.querySelector(":scope > template")??void 0;if(!src&&!template)continue;const type=template?"custom":(raw.type??element.getAttribute("type"))==="video"?"video":"image",alt=raw.resolvedAlt??element.getAttribute("alt")??"",caption=raw.captionText??element.getAttribute("caption")??"",width=Number(raw.width??element.getAttribute("width")),height=Number(raw.height??element.getAttribute("height"));records.push({element,type,...template?{template}:{},thumbnail:raw.thumbnailSrc??safeMediaSrc(element.getAttribute("thumbnail"))??"",...Number.isFinite(width)&&width>0?{width}:{},...Number.isFinite(height)&&height>0?{height}:{}}),images.push(Object.freeze({src,alt,...caption?{caption}:{}}))}const signature=records.map((record,i)=>`${i}\0${images[i].src}\0${images[i].alt}\0${images[i].caption??""}\0${record.type}\0${record.thumbnail}\0${record.width??""}x${record.height??""}`).join(""),sameElements=records.length===this.itemRecords.length&&records.every((record,i)=>record.element===this.itemRecords[i].element&&record.template===this.itemRecords[i].template);signature===this.lastItemSignature&&sameElements||(this.lastItemSignature=signature,this.itemRecords=Object.freeze(records),this.itemImages=images.length?Object.freeze(images):EMPTY_LIGHTBOX_IMAGES,this.itemsVersion++)}zoomIn(){this.canZoom()&&this.frameEl?.zoomIn()}zoomOut(){this.canZoom()&&this.frameEl?.zoomOut()}canZoom(){const type=this.itemMode?this.itemRecords[this.currentIndex()]?.type:void 0;return!this.withoutZoom&&type!=="video"&&type!=="custom"}pauseVideos(){if(this.hasUpdated)for(const video of this.renderRoot.querySelectorAll("video"))video.pause()}releaseDrag(settle){const swipe=this.swipe;this.swipe=void 0;const slide=this.slideElement();if(!slide||!slide.hasAttribute("data-dragging"))return;const from=slide.style.transform;if(slide.style.removeProperty("transform"),slide.removeAttribute("data-dragging"),!settle||!swipe?.dragging||!from)return;const animation=animateRegistered(this,slide,"lightbox.slide.return",this.effectiveDirection,{keyframes:[{transform:from},{transform:"translateX(0)"}],durationProperties:["--lr-lightbox-panel-duration","--lr-duration-base"],easingProperties:["--lr-easing-standard"]});animation&&animation.finished.catch(()=>{})}swipeIsForward(dx){return this.effectiveDirection==="rtl"?dx>0:dx<0}hasNeighbor(forward){const count=this.imageCount();if(count<2)return!1;if(this.loop)return!0;const current=this.currentIndex();return forward?current<count-1:current>0}slideElement(){return this.hasUpdated?this.renderRoot.querySelector('[part="slide"]'):null}currentIndex(){const count=this.imageCount();return count===0?0:finiteCount(this.index,0,count-1)}syncImages(){const current=this.currentIndex();this.index!==current&&(this.index=current)}changeTo(index){const count=this.imageCount();if(count===0||!Number.isFinite(index))return;const requested=finiteInteger(index,0),next=this.loop?(requested%count+count)%count:Math.min(count-1,Math.max(0,requested));next!==this.currentIndex()&&(this.pendingIndexChange=this.navigationIntent+1,this.index=next)}next(){this.changeTo(this.currentIndex()+1)}previous(){this.changeTo(this.currentIndex()-1)}goTo(index){this.changeTo(index)}async show(){if(this.openRequest.coalesce(!0)||this._open)return;this.openRequest.begin(!0);const prevented=this.emit("lr-show",null,{cancelable:!0}).defaultPrevented,superseded=this.openRequest.superseded(!0);if(this.openRequest.finish(),prevented||superseded){this.syncOpenAttribute();return}this.cancelTransitionAnimations(),this.removeAttribute("data-closing"),this.applyOpenState(!0);const generation=++this.transitionGeneration;await this.updateComplete,!(generation!==this.transitionGeneration||!this._open)&&(await this.settleAnimations(),generation===this.transitionGeneration&&this._open&&this.emit("lr-after-show",null))}hide(){return this.close("api")}async close(reason="api"){return this.closeFrom(reason,this)}async closeFrom(reason,source){if(this.openRequest.coalesce(!1)||!this._open)return;if(this.openRequest.begin(!1),this.emit("lr-hide",{source},{cancelable:!0}).defaultPrevented||this.openRequest.superseded(!1)){this.openRequest.finish(),this.syncOpenAttribute();return}if(this.emit("lr-close-request",{reason},{cancelable:!0}).defaultPrevented||this.openRequest.superseded(!1)){this.openRequest.finish(),this.syncOpenAttribute();return}this.openRequest.finish(),this.cancelTransitionAnimations(),this.isConnected&&this.setAttribute("data-closing",""),this.pauseVideos(),this.applyOpenState(!1);const generation=++this.transitionGeneration;if(this.emit("lr-close",{reason}),await this.updateComplete,generation!==this.transitionGeneration||this._open){this._open&&this.removeAttribute("data-closing");return}await this.playExit(),!(generation!==this.transitionGeneration||this._open)&&(this.removeAttribute("data-closing"),this.syncCustomSlide(),this.emit("lr-after-hide",null))}cancelTransitionAnimations(){for(const animation of this.transitionAnimations)animation.cancel();this.transitionAnimations=[]}async settleAnimations(){const running=this.transitionAnimations;await Promise.all(running.map(animation=>animation.finished.catch(()=>{}))),this.transitionAnimations===running&&(this.transitionAnimations=[])}surfaceSpec(showing,panel){const offset="translateY(calc(-1 * var(--lr-size-0-5rem)))";return{keyframes:panel?showing?[{opacity:0,transform:offset},{opacity:1,transform:"translateY(0)"}]:[{opacity:1,transform:"translateY(0)"},{opacity:0,transform:offset}]:showing?[{opacity:0},{opacity:1}]:[{opacity:1},{opacity:0}],durationProperties:[showing?SHOW_DURATION_PROPERTY:HIDE_DURATION_PROPERTY,"--lr-lightbox-panel-duration","--lr-duration-base"],easingProperties:["--lr-easing-standard"]}}startSurfaceAnimations(showing){const panel=this.renderRoot.querySelector('[part~="panel"]'),backdrop=this.renderRoot.querySelector('[part="backdrop"]'),direction=this.effectiveDirection;return[panel&&animateRegistered(this,panel,showing?"lightbox.show":"lightbox.hide",direction,this.surfaceSpec(showing,!0)),backdrop&&animateRegistered(this,backdrop,showing?"lightbox.overlay.show":"lightbox.overlay.hide",direction,this.surfaceSpec(showing,!1))].filter(animation=>animation!=null)}async playExit(){!this.isConnected||this.nativeModal.requested||(this.cancelTransitionAnimations(),this.transitionAnimations=this.startSurfaceAnimations(!1),this.markMorphing(this.renderedRecord?.element??this.currentItem,this.transitionAnimations),await this.settleAnimations())}animateSlide(forward){const slide=this.renderRoot.querySelector('[part="slide"]');if(!slide)return;const gap="var(--slide-gap, var(--lr-lightbox-slide-gap, var(--lr-space-l)))",from=sign2=>`translateX(calc(${sign2} * (100% + ${gap})))`,spec=sign2=>({keyframes:[{opacity:0,transform:from(sign2)},{opacity:1,transform:"translateX(0)"}],rtlKeyframes:[{opacity:0,transform:from(-sign2)},{opacity:1,transform:"translateX(0)"}],durationProperties:["--lr-lightbox-panel-duration","--lr-duration-base"],easingProperties:["--lr-easing-standard"]}),sign=forward?1:-1,release=this.swipeRelease;this.swipeRelease=0;let motion=spec(sign);if(release){const keyframes=[{opacity:0,transform:`translateX(calc(${this.effectiveDirection==="rtl"?-sign:sign} * (100% + ${gap}) + ${release}px))`},{opacity:1,transform:"translateX(0)"}];motion={...motion,keyframes,rtlKeyframes:keyframes}}const animation=animateRegistered(this,slide,forward?"lightbox.slide.next":"lightbox.slide.previous",this.effectiveDirection,motion);animation&&animation.finished.catch(()=>{})}syncCustomSlide(){const record=this.isConnected&&(this.open||this.hasAttribute("data-closing"))&&this.itemMode?this.itemRecords[this.currentIndex()]:void 0,wanted=record?.type==="custom"&&record.template?record:void 0;if(this.customSlide&&this.customSlide.record.template===wanted?.template&&this.customSlide.record.element===wanted?.element||(this.removeCustomSlide(),!wanted?.template))return;const doc=this.ownerDocument,element=doc.createElement("div");element.slot=CUSTOM_SLIDE_SLOT,element.setAttribute(CUSTOM_SLIDE_ATTRIBUTE,""),wanted.width&&wanted.height&&(element.setAttribute("data-ratio",""),element.style.setProperty("--_lr-lightbox-slide-ratio",String(wanted.width/wanted.height))),element.append(doc.importNode(wanted.template.content,!0)),this.customSlide={record:wanted,element},this.append(element)}removeCustomSlide(){const current=this.customSlide;this.customSlide=void 0,current?.element.remove()}markMorphing(item,animations){const generation=++this.morphGeneration;this.morphingItem&&setItemViewerState(this.morphingItem,"morphing",!1),this.morphingItem=void 0,!(!item||animations.length===0)&&(this.morphingItem=item,setItemViewerState(item,"morphing",!0),Promise.all(animations.map(animation=>animation.finished.catch(()=>{}))).then(()=>{generation===this.morphGeneration&&(setItemViewerState(item,"morphing",!1),this.morphingItem=void 0)}))}applyOpenState(next){const old=this._open;this._open=next,this.requestUpdate("open",old)}syncOpenAttribute(){this.toggleAttribute("open",this._open)}updateLiveRegion(){const count=this.imageCount(),formatter=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:0,useGrouping:!1});this.liveText=count===0?"":this.localize("lightboxImagePosition",void 0,{index:formatter.format(this.currentIndex()+1),total:formatter.format(count)})}captureAnnouncementBaseline(){this.announcementBaseline={index:this.currentIndex(),images:this.activeImages,source:this.imageSource}}willUpdate(changed){if(super.willUpdate(changed),this.sourceBindingCurrent=this.sourceController.update(this.imageSource,this.effectiveLocale),this.toggleAttribute("data-items",this.itemMode),(changed.has("index")||changed.has("open"))&&this.pauseVideos(),(changed.has("index")||changed.has("open")||changed.has("zoomLevel"))&&this.swipe&&this.releaseDrag(!1),(changed.has("index")||changed.has("imageSource")||changed.has("itemsVersion"))&&this.zoomLevel!==1&&(this.zoomLevel=1),this.sourceBindingCurrent&&(changed.has("itemsVersion")||changed.has("images")||changed.has("index")||changed.has("imageSource")||changed.has("sourceState"))){const index=changed.has("index")?void 0:this.index,intent=this.navigationIntent+1;this.syncImages(),index!==void 0&&this.index!==index&&this.navigationIntent===intent&&this.sourceBindingCurrent&&(this.pendingIndexChange=intent)}if(this.sourceBindingCurrent&&this.imageSource!==void 0){this.sourceController.select(this.currentIndex());const count=this.sourceController.count;this.withThumbnails&&count>1&&this.sourceController.requestThumbnails(...this.thumbnailRange(count,this.currentIndex()))}if(this.sourceBindingCurrent||queueDocumentMicrotask(this.ownerDocument,()=>{this.isConnected&&this.sourceState++}),this.sourceBindingCurrent&&(changed.has("index")||changed.has("itemsVersion")||changed.has("images")||changed.has("imageSource")||changed.has("sourceState")||changed.has("strings")||changed.has("locale"))&&this.updateLiveRegion(),changed.has("open"))if(this.open)this.modalSurface.open(()=>this.activateOverlay());else{const hadOverlay=this.overlay!==void 0;this.modalSurface.close(hadOverlay,()=>this.deactivateOverlay(),()=>!this.open)}}updated(changed){super.updated(changed),!(this.announcementBaseline?.index===this.currentIndex()&&this.announcementBaseline.images===this.activeImages&&this.announcementBaseline.source===this.imageSource)&&this.sourceBindingCurrent&&this.open&&this.liveText!==""&&isAccessibilityVisible(this)&&(changed.has("index")||changed.has("itemsVersion")||changed.has("images")||changed.has("imageSource"))&&this.announcements.announcePolite(this.liveText);const sourceError=this.sourceBindingCurrent&&this.imageSource!==void 0&&this.sourceController.state==="error";sourceError||(this.sourceErrorAnnounced=!1),sourceError&&!this.sourceErrorAnnounced&&this.sourceHasRendered&&this.open&&isAccessibilityVisible(this)&&(this.sourceErrorAnnounced=!0,this.announcements.announcePolite(this.localize("imageViewerFailedToLoad"))),this.sourceHasRendered=!0,this.isConnected&&this.sourceBindingCurrent&&this.captureAnnouncementBaseline(),changed.has("open")&&this.open&&(this.modalSurface.show(),this.overlay?.focusInitial());let currentSourceChanged=!1;if(changed.has("images")){const previousImages=changed.get("images"),previousIndex=changed.has("index")?changed.get("index")??0:this.index;currentSourceChanged=previousImages?.[previousImages.length>0?finiteCount(previousIndex,0,previousImages.length-1):0]?.src!==this.images[this.currentIndex()]?.src}const sourceImage=this.imageSource===void 0?void 0:this.sourceController.image;currentSourceChanged||=changed.has("imageSource")||sourceImage!==void 0&&sourceImage!==this.lastSourceImage,this.lastSourceImage=sourceImage;const shownSrc=this.imageSource===void 0?this.activeImages[this.currentIndex()]?.src??"":"";this.itemMode&&changed.has("itemsVersion")&&shownSrc!==this.lastShownSrc&&(currentSourceChanged=!0),this.lastShownSrc=shownSrc,this.open&&(changed.has("index")||currentSourceChanged)&&this.frameEl?.resetView();const current=this.currentIndex(),record=this.itemMode?this.itemRecords[current]:void 0;this.open&&this.firstUpdateDone&&changed.has("index")&&this.renderedIndex!==current&&this.animateSlide(this.effectiveDirection==="rtl"?current<this.renderedIndex:current>this.renderedIndex),changed.has("open")&&this.open&&this.firstUpdateDone&&(this.cancelTransitionAnimations(),this.transitionAnimations=this.startSurfaceAnimations(!0),this.markMorphing(record?.element,this.transitionAnimations));for(const item of this.itemRecords){const active=this.open&&item===record;item.element.toggleAttribute("data-active",active),setItemViewerState(item.element,"active",active)}setCustomState(this.lightboxInternals,"open",this.open),setCustomState(this.lightboxInternals,"zoomed",this.zoomLevel>1);const intent=this.pendingIndexChange;this.pendingIndexChange=void 0,intent===this.navigationIntent&&(this.emit("lr-index-change",{index:this.index}),this.emit("lr-item-change",{index:this.index,previousIndex:this.renderedIndex,item:record?.element??null,previousItem:this.renderedRecord?.element??null})),this.renderedIndex=current,this.renderedRecord=record,this.firstUpdateDone=!0,this.swipeRelease=0,this.syncCustomSlide()}connectedCallback(){super.connectedCallback();const generation=++this.connectionGeneration,connectionDocument=this.ownerDocument;this.addEventListener("click",this.onHostClick),this.syncItems(),typeof MutationObserver=="function"&&(this.itemObserver?.disconnect(),this.itemObserver=new MutationObserver(()=>this.syncItems()),this.itemObserver.observe(this,{childList:!0,subtree:!0})),this.captureAnnouncementBaseline(),this.hasUpdated&&this.open&&(this.overlay?.isActive()?this.overlay.resume():this.activateOverlay(),queueDocumentMicrotask(connectionDocument,()=>{this.connectionGeneration===generation&&this.ownerDocument===connectionDocument&&this.isConnected&&this.open&&(this.modalSurface.show(),this.overlay?.focusInitial())}))}disconnectedCallback(){const generation=++this.connectionGeneration,connectionDocument=this.ownerDocument;this.announcementBaseline=void 0,this.sourceErrorAnnounced=!1,this.sourceHasRendered=!1,this.lastSourceImage=void 0,this.removeEventListener("click",this.onHostClick),this.itemObserver?.disconnect(),this.itemObserver=void 0,this.releaseDrag(!1),this.removeCustomSlide(),this.cancelTransitionAnimations(),this.removeAttribute("data-closing"),super.disconnectedCallback(),this.modalSurface.disconnect(),this.overlay?.suspend(),this.open&&queueDocumentMicrotask(connectionDocument,()=>{this.connectionGeneration===generation&&this.ownerDocument===connectionDocument&&!this.isConnected&&this.open&&(this.transitionGeneration++,this.emit("lr-hide",{source:this}),this.applyOpenState(!1),this.emit("lr-close",{reason:"unmount"}),this.emit("lr-after-hide",null))})}activateOverlay(){this.overlay?.isActive()||(this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part~="panel"]')??null,onEscape:()=>{const panel=this.renderRoot.querySelector('[part~="panel"]')??this;this.closeFrom("escape",panel)},onBackdrop:()=>{const backdrop=this.renderRoot.querySelector('[part="backdrop"]')??this;this.closeFrom("backdrop",backdrop)},preferredInitialFocus:()=>this.shadowRoot?.querySelector('[part="close-button"]')??null,lockScroll:!0,suspendWhenUnrendered:!0}))}deactivateOverlay(){this.overlay?.deactivate(),this.overlay=void 0}constructor(){super(),this.hostDescription=new HostDescriptionController(this,()=>this.renderRoot.querySelector(this.nativeModal.requested?"dialog[data-native-modal-carrier]":'[part~="panel"][role="dialog"]')),this._open=!1,this.navigationIntent=0,this.sourceBindingCurrent=!0,this.sourceState=0,this.sourceController=new LightboxSourceController(this,()=>{this.sourceState++}),this._images=EMPTY_LIGHTBOX_IMAGES,this._fit="actual",this._index=0,this.loop=!1,this.lightDismiss=!1,this.withoutCounter=!1,this.withThumbnails=!1,this.withoutNavigation=!1,this.withoutZoom=!1,this.label="",this.minZoom=.5,this.maxZoom=4,this.zoomStep=.25,this.accessibleLabel=null,this.slotPresence=new SlotPresenceController(this),this.itemsVersion=0,this.zoomLevel=1,this.itemRecords=[],this.itemImages=EMPTY_LIGHTBOX_IMAGES,this.renderedIndex=0,this.lastShownSrc="",this.firstUpdateDone=!1,this.transitionAnimations=[],this.morphGeneration=0,this.lastItemSignature="",this.onHostClick=event=>{if(event.defaultPrevented||event.button!==0||event.metaKey||event.ctrlKey||event.shiftKey||event.altKey||!this.itemMode)return;const itemTag=tag("lightbox-item"),item=event.composedPath().find(node=>isElement(node)&&node.localName===itemTag);if(!item||item.closest(tag("lightbox"))!==this)return;const position=this.itemRecords.findIndex(record=>record.element===item);position<0||(event.preventDefault(),this.index=position,this.show())},this.toggleZoom=()=>{this.zoomLevel>1?this.frameEl?.resetZoom():this.zoomIn()},this.onZoomChange=event=>{const zoom=event.detail?.zoom;typeof zoom=="number"&&Number.isFinite(zoom)&&(this.zoomLevel=zoom)},this.onSwipeStart=event=>{event.defaultPrevented||event.pointerType==="mouse"||!event.isPrimary||this.imageCount()<2||this.zoomLevel>1||event.composedPath().some(node=>isElement(node)&&node.matches(SWIPE_EXEMPT))||(this.releaseDrag(!1),this.swipe={id:event.pointerId,x:event.clientX,y:event.clientY,dx:0,dragging:!1})},this.onSwipeMove=event=>{const swipe=this.swipe;if(!swipe||swipe.id!==event.pointerId)return;const dx=event.clientX-swipe.x,dy=event.clientY-swipe.y;if(swipe.dx=dx,!swipe.dragging){if(Math.abs(dx)<SWIPE_SLOP||Math.abs(dx)<Math.abs(dy)*1.2)return;swipe.dragging=!0}if(prefersReducedMotion(this))return;const slide=this.slideElement();if(!slide)return;for(const animation of slide.getAnimations())animation.cancel();const offset=this.hasNeighbor(this.swipeIsForward(dx))?dx:dx*SWIPE_EDGE_RESISTANCE;slide.style.transform=`translateX(${offset}px)`,slide.toggleAttribute("data-dragging",!0)},this.onSwipeEnd=event=>{const swipe=this.swipe;if(!swipe||swipe.id!==event.pointerId)return;const dx=event.clientX-swipe.x,dy=event.clientY-swipe.y,forward=this.swipeIsForward(dx);if(!(Math.abs(dx)>=SWIPE_DISTANCE&&Math.abs(dx)>=Math.abs(dy)*1.2&&this.hasNeighbor(forward))){this.releaseDrag(!0);return}this.swipeRelease=swipe.dragging&&!prefersReducedMotion(this)?dx:0,this.releaseDrag(!1),forward?this.next():this.previous(),this.pendingIndexChange===void 0&&(this.swipeRelease=0)},this.onSwipeCancel=event=>{this.swipe?.id===event.pointerId&&this.releaseDrag(!0)},this.swipeRelease=0,this.liveText="",this.lightboxInternals=attachInternalsSafely(this),this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{this.overlay?.isTopmost()&&this.closeFrom("escape",this.renderRoot.querySelector('[part~="panel"]')??this)},onUnexpectedClose:()=>{this.hide().then(()=>{this.open&&this.modalSurface.show()})}}),this.modalSurface=new ModalSurfaceController(this,this.nativeModal),this.announcements=new AnnouncementSinkController(this,{eager:["polite"]}),this.sourceErrorAnnounced=!1,this.sourceHasRendered=!1,this.connectionGeneration=0,this.transitionGeneration=0,this.openRequest=new ModalOpenRequest,this.captionId=nextId("lightbox-caption"),this.onBackdropClick=()=>{this.lightDismiss&&this.overlay?.dismissBackdrop()},this.onCloseButtonClick=()=>{const button=this.renderRoot.querySelector('[part="close-button"]')??this;this.closeFrom("close-button",button)},this.onPanelKeyDown=event=>{if(event.defaultPrevented||shouldIgnoreNavigationKey(event)||event.shiftKey)return;for(const target of event.composedPath()){if(target===this)break;if(isElement(target)&&target.getRootNode()!==this.shadowRoot&&target.matches('a[href], button, [role="button"], [role="link"], [role="slider"], input, select, textarea, [contenteditable]:not([contenteditable="false"])'))return}if(event.composedPath().some(node=>isElement(node)&&node.localName==="video")||keyEventOwnedByInnerControl(event,{container:this,ownerTag:tag("pan-zoom")}))return;const rtl=this.effectiveDirection==="rtl",forwardKey=rtl?"ArrowLeft":"ArrowRight",backwardKey=rtl?"ArrowRight":"ArrowLeft";event.key===forwardKey?(event.preventDefault(),this.next()):event.key===backwardKey?(event.preventDefault(),this.previous()):event.key==="Home"?(event.preventDefault(),this.goTo(0)):event.key==="End"&&(event.preventDefault(),this.goTo(this.imageCount()-1))},repairControlFocusOnUpdate(this,()=>[this.renderRoot.querySelector('[part="close-button"]'),this.renderRoot.querySelector('[part~="frame"]')]),trackScrollRegions(this,()=>{const el=this.renderRoot.querySelector('[part="caption"]');return[el&&{el,role:!1}]})}thumbnailRange(count,current){const size=this.imageSource===void 0?MAX_THUMBNAILS:SOURCE_THUMBNAIL_WINDOW,start=Math.max(0,Math.min(current-Math.floor(size/2),count-size));return[start,Math.min(count,start+size)]}renderThumbnails(count,current){if(!this.withThumbnails||count<2)return nothing;const sourceMode=this.imageSource!==void 0,[start,end]=this.thumbnailRange(count,current),formatter=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:0,useGrouping:!1}),thumbs=[];for(let i=start;i<end;i++){const image=sourceMode?this.sourceController.thumbnailAt(i):this.activeImages[i];if(!image&&!sourceMode)continue;const record=this.itemMode?this.itemRecords[i]:void 0,media=record?record.thumbnail||(record.type==="image"?image?.src:""):image?.thumbnail||image?.src,source=safeMediaSrc(media),active=i===current,position=this.localize("lightboxImagePosition",void 0,{index:formatter.format(i+1),total:formatter.format(count)}),content=source?html`<img src=${source} alt="" loading="lazy" decoding="async" />`:record?.type==="video"?playIcon():html`<span aria-hidden="true">${formatter.format(i+1)}</span>`;thumbs.push(html`<button type="button" part=${active?"thumbnail thumbnail-active":"thumbnail"} aria-label=${image?.alt||position} aria-current=${active?"true":"false"} @click=${()=>this.goTo(i)} >${content}</button>`)}return html`<div part="thumbnails">${thumbs}</div>`}render(){const count=this.imageCount(),current=this.currentIndex(),image=this.imageSource===void 0?count>0?this.activeImages[current]:void 0:this.sourceController.image,record=this.itemMode?this.itemRecords[current]:void 0,isVideo=record?.type==="video",isCustom=record?.type==="custom",mediaSrc=isVideo?safeMediaSrc(image?.src)??"":"",sourceState=this.imageSource===void 0?void 0:this.sourceController.state,label=this.accessibleLabel?.trim()?this.accessibleLabel:(this.label??"").trim()?this.label:this.localize("lightboxLabel"),hasCaption=!!image?.caption,formatter=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:0,useGrouping:!1}),positionText=count>0?this.localize("lightboxImagePosition",void 0,{index:formatter.format(current+1),total:formatter.format(count)}):"",zoomed=this.zoomLevel>1,showZoom=this.itemMode&&!this.withoutZoom&&!isVideo&&!isCustom&&count>0;return html`<slot></slot><div part="surface">${this.nativeModal.render(html`
|
|
2
2
|
<div part="backdrop" @click=${this.onBackdropClick}></div>
|
|
3
|
-
<div part="panel" role=${this.open&&!this.nativeModal.requested?"dialog":nothing} aria-modal=${this.open&&!this.nativeModal.requested?"true":nothing} aria-label=${this.nativeModal.requested?nothing:label} aria-describedby=${hasCaption&&!this.nativeModal.requested?this.captionId:nothing} tabindex="-1" @keydown=${this.onPanelKeyDown} >
|
|
3
|
+
<div part="panel dialog" role=${this.open&&!this.nativeModal.requested?"dialog":nothing} aria-modal=${this.open&&!this.nativeModal.requested?"true":nothing} aria-label=${this.nativeModal.requested?nothing:label} aria-describedby=${hasCaption&&!this.nativeModal.requested?this.captionId:nothing} tabindex="-1" @keydown=${this.onPanelKeyDown} >
|
|
4
4
|
<div part="toolbar">
|
|
5
5
|
${!this.withoutCounter&&count>0?html`<span part="counter">${positionText}</span>`:nothing}
|
|
6
6
|
<div part="actions" ?hidden=${!this.slotPresence.has("actions")}>
|
|
7
7
|
<slot name="actions"></slot>
|
|
8
8
|
</div>
|
|
9
|
+
${showZoom?html`<button part="zoom-button" type="button" aria-label=${this.localize(zoomed?"zoomOut":"zoomIn")} @click=${this.toggleZoom} >${zoomed?html`<slot name="zoom-out-icon">${minusIcon()}</slot>`:html`<slot name="zoom-in-icon">${plusIcon()}</slot>`}</button>`:nothing}
|
|
9
10
|
<button part="close-button" type="button" aria-label=${this.localize("close")} @click=${this.onCloseButtonClick}>
|
|
10
|
-
|
|
11
|
+
<slot name="close-icon">${closeIcon()}</slot>
|
|
11
12
|
</button>
|
|
12
13
|
</div>
|
|
13
|
-
<div part="stage" aria-busy=${sourceState==="loading"?"true":"false"}>
|
|
14
|
+
<div part="stage scroll-container" aria-busy=${sourceState==="loading"?"true":"false"} @pointerdown=${this.onSwipeStart} @pointermove=${this.onSwipeMove} @pointerup=${this.onSwipeEnd} @pointercancel=${this.onSwipeCancel} >
|
|
14
15
|
${sourceState==="loading"?html`<p part="source-loading">${this.localize("loading")}</p>`:nothing}
|
|
15
16
|
${sourceState==="error"?html`<div part="source-error">${this.localize("imageViewerFailedToLoad")}<button part="source-retry" type="button" @click=${()=>this.sourceController.retry(this.currentIndex())}>${this.localize("retry")}</button></div>`:nothing}
|
|
16
|
-
${count>1?html`
|
|
17
|
-
<button part="previous-button" type="button" aria-label=${this.localize("previous")} ?disabled=${!this.loop&¤t===0} @click=${this.previous} >
|
|
18
|
-
<span part="previous-glyph">${chevronIcon()}</span>
|
|
17
|
+
${count>1&&!this.withoutNavigation?html`
|
|
18
|
+
<button part="previous-button navigation-button navigation-button-previous" type="button" aria-label=${this.localize("previous")} ?disabled=${!this.loop&¤t===0} @click=${this.previous} >
|
|
19
|
+
<span part="previous-glyph"><slot name="previous-icon">${chevronIcon()}</slot></span>
|
|
19
20
|
</button>
|
|
20
21
|
`:nothing}
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
<div part="slide">
|
|
23
|
+
${isVideo?keyed(current,html`<video part="video" controls playsinline preload="metadata" src=${mediaSrc} poster=${ifDefined(record?.thumbnail||void 0)} aria-label=${ifDefined(image?.alt||void 0)} width=${ifDefined(record?.width)} height=${ifDefined(record?.height)} ></video>`):nothing}
|
|
24
|
+
${isCustom?html`<slot name=${CUSTOM_SLIDE_SLOT}></slot>`:nothing}
|
|
25
|
+
<lr-pan-zoom part="frame image" exportparts="viewport:frame-viewport,content:frame-content,controls:frame-controls" ?hidden=${isVideo||isCustom} .src=${live(isVideo||isCustom?"":image?.src??"")} alt=${image?.alt??""} .fit=${this.fit} .minZoom=${this.withoutZoom?1:this.minZoom} .maxZoom=${this.withoutZoom?1:this.maxZoom} .zoomStep=${this.zoomStep} .accessibleLabel=${positionText||null} @focus=${event=>event.stopPropagation()} @blur=${event=>event.stopPropagation()} @lr-zoom-change=${this.onZoomChange} ></lr-pan-zoom>
|
|
26
|
+
</div>
|
|
27
|
+
${count>1&&!this.withoutNavigation?html`
|
|
28
|
+
<button part="next-button navigation-button navigation-button-next" type="button" aria-label=${this.localize("next")} ?disabled=${!this.loop&¤t===count-1} @click=${this.next} >
|
|
29
|
+
<span part="next-glyph"><slot name="next-icon">${chevronIcon()}</slot></span>
|
|
25
30
|
</button>
|
|
26
31
|
`:nothing}
|
|
27
32
|
</div>
|
|
28
33
|
${hasCaption?html`<p part="caption" id=${this.captionId}>${image.caption}</p>`:nothing}
|
|
34
|
+
${this.renderThumbnails(count,current)}
|
|
29
35
|
<span part="live-region" class="sr-only" aria-hidden="true" >${this.liveText}</span
|
|
30
36
|
>
|
|
31
37
|
${this.nativeModal.renderHelperSlot()}
|
|
32
38
|
</div>
|
|
33
|
-
`,{label,describedBy:hasCaption?this.captionId:null})}}__decorate([property({type:Boolean,reflect:!0})],LyraLightbox.prototype,"open",null),__decorate([state()],LyraLightbox.prototype,"sourceState",void 0),__decorate([property({attribute:!1,noAccessor:!0,hasChanged:()=>!0})],LyraLightbox.prototype,"imageSource",null),__decorate([property({attribute:!1})],LyraLightbox.prototype,"images",null),__decorate([property({converter:blankNumberConverter(0),reflect:!0,noAccessor:!0})],LyraLightbox.prototype,"index",null),__decorate([property({type:Boolean,reflect:!0})],LyraLightbox.prototype,"loop",void 0),__decorate([property({type:Boolean,attribute:"light-dismiss"})],LyraLightbox.prototype,"lightDismiss",void 0),__decorate([property({type:Boolean,attribute:"without-counter"})],LyraLightbox.prototype,"withoutCounter",void 0),__decorate([property({reflect:!0})],LyraLightbox.prototype,"fit",null),__decorate([property({converter:blankNumberConverter(.5),attribute:"min-zoom"})],LyraLightbox.prototype,"minZoom",void 0),__decorate([property({converter:blankNumberConverter(4),attribute:"max-zoom"})],LyraLightbox.prototype,"maxZoom",void 0),__decorate([property({converter:blankNumberConverter(.25),attribute:"zoom-step"})],LyraLightbox.prototype,"zoomStep",void 0),__decorate([property({attribute:"aria-label"})],LyraLightbox.prototype,"accessibleLabel",void 0),__decorate([state()],LyraLightbox.prototype,"liveText",void 0),__decorate([query(tag("pan-zoom"))],LyraLightbox.prototype,"frameEl",void 0);export{LyraLightbox};
|
|
39
|
+
`,{label,describedBy:hasCaption?this.captionId:null})}</div>`}}__decorate([property({type:Boolean,reflect:!0})],LyraLightbox.prototype,"open",null),__decorate([state()],LyraLightbox.prototype,"sourceState",void 0),__decorate([property({attribute:!1,noAccessor:!0,hasChanged:()=>!0})],LyraLightbox.prototype,"imageSource",null),__decorate([property({attribute:!1})],LyraLightbox.prototype,"images",null),__decorate([property({converter:blankNumberConverter(0),reflect:!0,noAccessor:!0})],LyraLightbox.prototype,"index",null),__decorate([property({type:Boolean,reflect:!0})],LyraLightbox.prototype,"loop",void 0),__decorate([property({type:Boolean,attribute:"light-dismiss"})],LyraLightbox.prototype,"lightDismiss",void 0),__decorate([property({type:Boolean,attribute:"without-counter"})],LyraLightbox.prototype,"withoutCounter",void 0),__decorate([property({type:Boolean,reflect:!0,attribute:"with-thumbnails"})],LyraLightbox.prototype,"withThumbnails",void 0),__decorate([property({type:Boolean,reflect:!0,attribute:"without-navigation"})],LyraLightbox.prototype,"withoutNavigation",void 0),__decorate([property({type:Boolean,reflect:!0,attribute:"without-zoom"})],LyraLightbox.prototype,"withoutZoom",void 0),__decorate([property({reflect:!0})],LyraLightbox.prototype,"label",void 0),__decorate([property({reflect:!0})],LyraLightbox.prototype,"fit",null),__decorate([property({converter:blankNumberConverter(.5),attribute:"min-zoom"})],LyraLightbox.prototype,"minZoom",void 0),__decorate([property({converter:blankNumberConverter(4),attribute:"max-zoom"})],LyraLightbox.prototype,"maxZoom",void 0),__decorate([property({converter:blankNumberConverter(.25),attribute:"zoom-step"})],LyraLightbox.prototype,"zoomStep",void 0),__decorate([property({attribute:"aria-label"})],LyraLightbox.prototype,"accessibleLabel",void 0),__decorate([state()],LyraLightbox.prototype,"itemsVersion",void 0),__decorate([state()],LyraLightbox.prototype,"zoomLevel",void 0),__decorate([state()],LyraLightbox.prototype,"liveText",void 0),__decorate([query(tag("pan-zoom"))],LyraLightbox.prototype,"frameEl",void 0);export{LyraLightbox};
|