@aceshooting/lyra-ui 30.9.0 → 31.1.1
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 +361 -335
- package/dist/ai/adapters/ag-ui.js +1 -1
- package/dist/autoloader-cdn.js +1 -1
- package/dist/components/agent-tools/activity-feed/activity-feed.class.js +1 -1
- package/dist/components/agent-tools/budget-meter/budget-meter.class.d.ts +12 -1
- package/dist/components/agent-tools/budget-meter/budget-meter.class.js +4 -4
- package/dist/components/agent-tools/compare-panel/compare-panel.class.js +1 -1
- package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +1 -1
- package/dist/components/agent-tools/thinking-panel/thinking-panel.class.js +1 -1
- package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.class.js +1 -1
- package/dist/components/charts/chart/box-plot.class.js +2 -2
- package/dist/components/charts/chart/chart-sync.js +1 -1
- package/dist/components/charts/chart/chart.class.d.ts +1 -1
- package/dist/components/charts/chart/chart.class.js +4 -4
- package/dist/components/charts/chart/lite-chart-axis-layout.js +1 -1
- package/dist/components/charts/chart/lite-chart.class.js +2 -2
- package/dist/components/conversation/chat-composer/chat-composer.class.d.ts +26 -11
- package/dist/components/conversation/chat-composer/chat-composer.class.js +11 -9
- package/dist/components/conversation/chat-composer/chat-composer.styles.js +1 -1
- package/dist/components/conversation/chat-message/chat-message.class.d.ts +27 -3
- package/dist/components/conversation/chat-message/chat-message.class.js +14 -12
- package/dist/components/conversation/chat-message/chat-message.styles.js +1 -1
- package/dist/components/conversation/chat-viewport/chat-viewport.class.d.ts +29 -2
- package/dist/components/conversation/chat-viewport/chat-viewport.class.js +2 -2
- package/dist/components/conversation/chat-viewport/chat-viewport.styles.js +1 -1
- package/dist/components/conversation/code-block/code-block-shared.js +1 -1
- package/dist/components/conversation/markdown/markdown-base.class.d.ts +1 -1
- package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
- package/dist/components/conversation/markdown/markdown-code-header.js +1 -1
- package/dist/components/conversation/markdown/markdown-core.class.d.ts +10 -0
- package/dist/components/conversation/markdown/markdown-core.class.js +1 -1
- package/dist/components/conversation/markdown/markdown-shared.d.ts +7 -2
- package/dist/components/conversation/markdown/markdown-shared.js +3 -3
- package/dist/components/conversation/markdown/markdown.class.d.ts +10 -0
- package/dist/components/conversation/markdown/markdown.class.js +1 -1
- package/dist/components/conversation/message-feedback/message-feedback.class.d.ts +11 -3
- package/dist/components/conversation/message-feedback/message-feedback.class.js +12 -6
- package/dist/components/conversation/message-feedback/message-feedback.styles.js +1 -1
- package/dist/components/conversation/message-parts/message-parts.class.js +1 -1
- package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +8 -4
- package/dist/components/conversation/prompt-input/prompt-input.class.js +3 -2
- package/dist/components/conversation/push-to-talk/push-to-talk.class.js +1 -1
- package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +4 -0
- package/dist/components/conversation/streaming-text/streaming-text-base.class.js +1 -1
- package/dist/components/conversation/streaming-text/streaming-text-core.class.d.ts +1 -1
- package/dist/components/conversation/streaming-text/streaming-text-core.class.js +1 -0
- package/dist/components/conversation/streaming-text/streaming-text.class.d.ts +1 -1
- package/dist/components/conversation/streaming-text/streaming-text.class.js +1 -0
- package/dist/components/conversation/suggestion-chips/suggestion-chips.class.d.ts +17 -3
- package/dist/components/conversation/suggestion-chips/suggestion-chips.class.js +3 -3
- package/dist/components/conversation/suggestion-chips/suggestion-chips.d.ts +1 -1
- package/dist/components/conversation/suggestion-chips/suggestion-chips.js +1 -1
- package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +1 -1
- package/dist/components/conversation/thread-list/thread-list.class.d.ts +1 -1
- package/dist/components/conversation/thread-list/thread-list.class.js +3 -3
- package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
- package/dist/components/data/data-grid/data-grid.class.d.ts +10 -10
- package/dist/components/data/data-grid/data-grid.class.js +1 -1
- package/dist/components/data/document-library/document-library-cursor.js +1 -0
- package/dist/components/data/document-library/document-library-types.d.ts +20 -0
- package/dist/components/data/document-library/document-library.class.d.ts +37 -26
- package/dist/components/data/document-library/document-library.class.js +20 -11
- package/dist/components/data/document-library/document-library.styles.js +1 -1
- package/dist/components/data/file-tree/file-tree.class.js +1 -1
- package/dist/components/data/flow-canvas/flow-canvas.class.d.ts +1 -1
- package/dist/components/data/flow-canvas/flow-canvas.class.js +2 -2
- package/dist/components/data/heatmap/heatmap.class.d.ts +1 -1
- package/dist/components/data/heatmap/heatmap.class.js +1 -1
- package/dist/components/data/pagination/pagination.class.js +1 -1
- package/dist/components/data/table/table.class.d.ts +31 -2
- package/dist/components/data/table/table.class.js +3 -3
- package/dist/components/data/table/table.styles.js +1 -1
- package/dist/components/data/timeline/timeline-cluster.js +1 -1
- package/dist/components/data/timeline/timeline-item.class.d.ts +10 -3
- package/dist/components/data/timeline/timeline-item.class.js +16 -12
- package/dist/components/data/timeline/timeline-item.styles.js +1 -1
- package/dist/components/data/timeline/timeline.class.d.ts +14 -2
- package/dist/components/data/timeline/timeline.class.js +9 -5
- package/dist/components/data/tree/tree-item.class.js +1 -1
- package/dist/components/data/tree/tree.class.d.ts +2 -0
- package/dist/components/data/tree/tree.class.js +1 -1
- package/dist/components/forms/button/button.class.d.ts +8 -6
- package/dist/components/forms/button/button.class.js +2 -2
- package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
- package/dist/components/forms/color-picker/color-core.js +1 -1
- package/dist/components/forms/combobox/combobox.class.d.ts +20 -12
- package/dist/components/forms/combobox/combobox.class.js +2 -2
- package/dist/components/forms/date-picker/date-input.class.d.ts +1 -1
- package/dist/components/forms/date-picker/date-input.class.js +1 -1
- package/dist/components/forms/icon-button/icon-button.class.d.ts +4 -2
- package/dist/components/forms/icon-button/icon-button.class.js +2 -2
- package/dist/components/forms/input/input-shared.js +2 -2
- package/dist/components/forms/input/number-input-locale.js +1 -0
- package/dist/components/forms/input/number-input.class.d.ts +19 -2
- package/dist/components/forms/input/number-input.class.js +2 -2
- package/dist/components/forms/locale-picker/locale-picker.class.d.ts +3 -3
- package/dist/components/forms/locale-picker/locale-picker.class.js +1 -1
- package/dist/components/layout/app-rail-group/app-rail-group.class.js +1 -1
- package/dist/components/layout/details/accordion-item.class.js +1 -1
- package/dist/components/layout/dock-panel/dock-panel.class.d.ts +1 -1
- package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
- package/dist/components/layout/menu/menu.class.js +1 -1
- package/dist/components/layout/multi-split/multi-split.class.js +1 -1
- package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.js +1 -1
- package/dist/components/layout/page/page.class.d.ts +3 -3
- package/dist/components/layout/page/page.class.js +1 -1
- package/dist/components/layout/segmented/segmented.class.d.ts +20 -7
- package/dist/components/layout/segmented/segmented.class.js +34 -24
- package/dist/components/layout/segmented/segmented.styles.js +1 -1
- package/dist/components/layout/stepper/stepper.styles.js +1 -1
- package/dist/components/layout/tab-group/tab-group.class.d.ts +8 -1
- package/dist/components/layout/tab-group/tab-group.class.js +1 -1
- package/dist/components/layout/tab-group/tab.class.d.ts +7 -1
- package/dist/components/layout/tab-group/tab.class.js +1 -1
- package/dist/components/layout/virtual-list/virtual-list.class.d.ts +2 -2
- package/dist/components/layout/virtual-list/virtual-list.class.js +1 -1
- package/dist/components/media/animated-image/animated-image.class.js +1 -1
- package/dist/components/media/attachment-chip/attachment-chip.class.d.ts +21 -14
- package/dist/components/media/attachment-chip/attachment-chip.class.js +1 -1
- package/dist/components/media/attachment-trigger/attachment-trigger.class.d.ts +36 -12
- package/dist/components/media/attachment-trigger/attachment-trigger.class.js +3 -3
- package/dist/components/media/drop-zone/drop-zone.class.d.ts +23 -5
- package/dist/components/media/drop-zone/drop-zone.class.js +2 -2
- package/dist/components/media/drop-zone/drop-zone.styles.js +1 -1
- package/dist/components/media/file-icon/file-icon.class.js +1 -1
- package/dist/components/media/flag/flag-url-resolver.js +1 -1
- package/dist/components/media/image-viewer/image-viewer.class.d.ts +2 -2
- package/dist/components/media/image-viewer/image-viewer.class.js +1 -1
- package/dist/components/media/map/map-anchor-controller.js +1 -1
- package/dist/components/media/map/map-canvas-target.js +1 -0
- package/dist/components/media/map/map-owned-features.js +1 -1
- package/dist/components/media/map/map-scene-elevated-lines.js +2 -2
- package/dist/components/media/map/map-scene-render-controller.js +1 -1
- package/dist/components/media/map/map.class.d.ts +15 -6
- package/dist/components/media/map/map.class.js +4 -4
- package/dist/components/media/map/map.styles.js +1 -1
- package/dist/components/media/pan-zoom/pan-zoom.class.js +1 -1
- package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +21 -9
- package/dist/components/media/sequence-playback/sequence-playback.class.js +7 -6
- package/dist/components/media/sequence-playback/sequence-playback.styles.js +1 -1
- package/dist/components/media/video/video.class.d.ts +3 -3
- package/dist/components/media/video/video.class.js +3 -1
- package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
- package/dist/components/overlays/chip/chip.class.js +1 -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/tooltip.class.d.ts +5 -1
- package/dist/components/overlays/overlay/tooltip.class.js +3 -3
- package/dist/components/retrieval/embedding-explorer/embedding-explorer-engine.js +1 -1
- package/dist/components/retrieval/graph/graph-node-renderer.js +1 -1
- package/dist/components/retrieval/graph/graph-spatial-controller.js +1 -1
- package/dist/components/retrieval/graph/graph.class.d.ts +1 -1
- package/dist/components/retrieval/graph/graph.class.js +1 -1
- package/dist/components/retrieval/ingestion-queue/ingestion-queue-presentation.d.ts +11 -0
- package/dist/components/retrieval/ingestion-queue/ingestion-queue-presentation.js +1 -0
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.d.ts +18 -7
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +13 -26
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.styles.js +1 -1
- package/dist/components/retrieval/mind-map/mind-map.class.js +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.d.ts +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +3 -3
- package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +1 -1
- package/dist/components/utility/diff-view/diff-view.class.d.ts +5 -5
- package/dist/components/utility/diff-view/diff-view.class.js +1 -1
- package/dist/components/utility/icon/icon.class.js +1 -1
- package/dist/components/utility/json-viewer/json-viewer.class.d.ts +16 -1
- package/dist/components/utility/json-viewer/json-viewer.class.js +4 -4
- package/dist/components/utility/json-viewer/json-viewer.styles.js +1 -1
- package/dist/components/utility/known-date/known-date.class.js +1 -1
- package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
- package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
- package/dist/components/viewers/calendar-viewer/calendar-viewer.class.js +1 -1
- package/dist/components/viewers/contact-viewer/contact-viewer.class.js +1 -1
- package/dist/components/viewers/csv-viewer/csv-viewer.class.js +1 -1
- package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +1 -1
- package/dist/components/viewers/document-preview/document-preview.class.js +2 -2
- package/dist/components/viewers/docx-viewer/docx-viewer.class.d.ts +1 -1
- package/dist/components/viewers/docx-viewer/docx-viewer.class.js +2 -2
- package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
- package/dist/components/viewers/email-viewer/email-viewer.class.d.ts +1 -1
- package/dist/components/viewers/email-viewer/email-viewer.class.js +2 -2
- package/dist/components/viewers/html-viewer/html-viewer.class.js +1 -1
- package/dist/components/viewers/include/include.class.js +1 -1
- package/dist/components/viewers/model-viewer/model-viewer.class.js +1 -1
- package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +2 -2
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +2 -2
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +2 -2
- package/dist/components/viewers/pptx-viewer/pptx-viewer.class.js +1 -1
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
- package/dist/components/viewers/svg-viewer/svg-viewer.class.js +1 -1
- package/dist/components/viewers/table-viewer-shared.js +4 -4
- package/dist/components/viewers/xml-viewer/xml-viewer.class.js +2 -2
- package/dist/data-sources.d.ts +10 -0
- package/dist/events.d.ts +9 -4
- package/dist/framework-types.d.ts +1 -1
- package/dist/internal/anchored-overlay-runtime.js +1 -1
- package/dist/internal/catalog-picker.js +1 -1
- package/dist/internal/default-strings/conversation.generated.js +1 -1
- package/dist/internal/default-strings/data.generated.js +1 -1
- package/dist/internal/default-strings/retrieval.generated.js +1 -1
- package/dist/internal/document-tokens.js +2 -2
- package/dist/internal/drop-session-controller.js +1 -1
- package/dist/internal/engine-3d.js +1 -1
- package/dist/internal/icon-only-content.js +1 -1
- package/dist/internal/layered-layout.js +1 -1
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +1 -1
- package/dist/internal/lyra-element.js +2 -2
- package/dist/internal/map-custom-layer-controller.js +1 -1
- package/dist/internal/media-panorama.js +1 -1
- package/dist/internal/native-modal-context.js +1 -1
- package/dist/internal/overlay-manager.js +1 -1
- package/dist/internal/overlay-order.js +1 -1
- package/dist/internal/overlay-stack.js +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/runtime-diagnostics.js +1 -0
- package/dist/internal/safe-url.js +1 -1
- package/dist/internal/scoped-definitions.generated.js +1 -1
- package/dist/internal/scroll-overflow.js +1 -1
- package/dist/internal/source-cursor-controller.js +1 -0
- package/dist/internal/source-cursor-projection.js +1 -0
- package/dist/internal/source-page-scope.js +1 -1
- package/dist/internal/source-window-controller.js +1 -1
- package/dist/internal/text-quote.js +1 -1
- package/dist/internal/viewer-search.js +1 -1
- package/dist/lyra.d.ts +1 -1
- package/dist/sequence-time-binding.js +1 -1
- package/dist/simulation-clock.js +1 -1
- package/dist/styles/reservations.css +1 -1
- package/dist/styles/reservations.styles.js +1 -1
- package/dist/testing/happy-dom-shims.js +1 -1
- package/dist/theme/theme-bootstrap.js +1 -1
- package/dist/theme/theme.js +1 -1
- package/dist/utilities/overlay-manager.d.ts +2 -0
- package/llms/components/lr-attachment-chip.md +27 -12
- package/llms/components/lr-attachment-trigger.md +27 -7
- package/llms/components/lr-budget-meter.md +31 -0
- package/llms/components/lr-button.md +6 -4
- package/llms/components/lr-chat-composer.md +26 -9
- package/llms/components/lr-chat-message.md +44 -3
- package/llms/components/lr-chat-viewport.md +39 -2
- package/llms/components/lr-combobox.md +27 -1
- package/llms/components/lr-data-grid.md +2 -0
- package/llms/components/lr-dialog.md +10 -0
- package/llms/components/lr-diff-view.md +6 -0
- package/llms/components/lr-document-library.md +90 -6
- package/llms/components/lr-drop-zone.md +26 -2
- package/llms/components/lr-graph.md +5 -0
- package/llms/components/lr-icon-button.md +2 -1
- package/llms/components/lr-ingestion-queue.md +76 -8
- package/llms/components/lr-json-viewer.md +51 -0
- package/llms/components/lr-lite-chart.md +2 -1
- package/llms/components/lr-locale-picker.md +5 -0
- package/llms/components/lr-map.md +33 -0
- package/llms/components/lr-markdown-core.md +2 -1
- package/llms/components/lr-markdown.md +20 -4
- package/llms/components/lr-menu.md +3 -1
- package/llms/components/lr-message-feedback.md +38 -3
- package/llms/components/lr-number-input.md +28 -1
- package/llms/components/lr-page.md +4 -2
- package/llms/components/lr-prompt-input.md +6 -3
- package/llms/components/lr-segmented.md +30 -10
- package/llms/components/lr-sequence-playback.md +47 -12
- package/llms/components/lr-streaming-text-core.md +3 -2
- package/llms/components/lr-streaming-text.md +4 -1
- package/llms/components/lr-suggestion-chips.md +28 -5
- package/llms/components/lr-tab-group.md +13 -1
- package/llms/components/lr-tab.md +5 -0
- package/llms/components/lr-table.md +25 -4
- package/llms/components/lr-timeline-item.md +1 -1
- package/llms/components/lr-timeline.md +38 -4
- package/llms/components/lr-tooltip.md +3 -1
- package/llms/components/lr-tree.md +4 -0
- package/llms/components/lr-virtual-list.md +4 -1
- package/llms/peers.md +2 -2
- package/llms/shared/events-and-types.md +61 -2
- package/llms/shared/forms-and-accessibility.md +46 -4
- package/llms/shared/imports-and-registration.md +154 -110
- package/llms/shared/testing-and-utilities.md +5 -1
- package/llms/shared.md +266 -117
- package/locales.json +1 -1
- package/package.json +22 -21
- package/registrations.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{observeReducedMotion}from"../../../internal/motion-observer.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{playIcon,pauseIcon}from"../../../internal/icons.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{styles}from"./animated-image.styles.js";import{resolveBoundedCanvasAllocation}from"../../../internal/canvas.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{LYRA_DEFAULT_animatedImageDefaultAlt,LYRA_DEFAULT_pauseWithContext,LYRA_DEFAULT_playWithContext}from"../../../internal/default-strings/media.generated.js";const MAX_FROZEN_FRAME_DIMENSION=8192,MAX_FROZEN_FRAME_PIXELS=16777216;class LyraAnimatedImage extends LyraElement{constructor(){super(...arguments),this.src="",this.play=!1,this.ignoreReducedMotion=!1,this.accessibleLabel="",this.hasLoaded=!1,this.hasError=!1,this._playing=!1,this.userPlay=!1,this.connectionEventBaselinePending=!0,this.onMotionPreferenceChange=()=>{this.requestUpdate()},this.onImageLoad=event=>{if(!this.isConnected||event.currentTarget!==this.imageEl)return;this.hasError=!1,this.hasLoaded=!0;const img=this.imageEl,canvas=this.canvasEl;if(img&&canvas){const width=img.naturalWidth,height=img.naturalHeight,allocation=resolveBoundedCanvasAllocation({cssWidth:width,cssHeight:height,desiredScale:1,maxDimension:MAX_FROZEN_FRAME_DIMENSION,maxPixels:MAX_FROZEN_FRAME_PIXELS});canvas.width=allocation.pixelWidth,canvas.height=allocation.pixelHeight;const ctx=canvas.getContext("2d");ctx&&(ctx.scale(allocation.scaleX,allocation.scaleY),ctx.drawImage(img,0,0,width,height))}this.emit("lr-load",null)},this.onImageError=event=>{!this.isConnected||event.currentTarget!==this.imageEl||(this.hasLoaded=!1,this.hasError=!0,this.emit("lr-error",null))},this.onToggleClick=()=>{this.userPlay=this.play=!this.play},this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)}}static{this.defaultStrings={...super.defaultStrings,animatedImageDefaultAlt:LYRA_DEFAULT_animatedImageDefaultAlt,pauseWithContext:LYRA_DEFAULT_pauseWithContext,playWithContext:LYRA_DEFAULT_playWithContext}}static{this.knownUnobservedAttributes=["playing"]}static{this.styles=[LyraElement.styles,styles]}get playing(){return this._playing}connectedCallback(){super.connectedCallback(),this.connectionEventBaselinePending=!0,this.stopMotionWatch=observeReducedMotion(this,this.onMotionPreferenceChange),this.requestUpdate()}disconnectedCallback(){this.connectionEventBaselinePending=!0,this.stopMotionWatch?.(),this.stopMotionWatch=void 0,super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed);const mayEmitConnectionTransition=this.isConnected&&!this.connectionEventBaselinePending;changed.has("src")&&(this.hasLoaded=!1,this.hasError=!1,this.src
|
|
1
|
+
import{__decorate}from"tslib";import{observeReducedMotion}from"../../../internal/motion-observer.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{playIcon,pauseIcon}from"../../../internal/icons.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{styles}from"./animated-image.styles.js";import{resolveBoundedCanvasAllocation}from"../../../internal/canvas.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{LYRA_DEFAULT_animatedImageDefaultAlt,LYRA_DEFAULT_pauseWithContext,LYRA_DEFAULT_playWithContext}from"../../../internal/default-strings/media.generated.js";const MAX_FROZEN_FRAME_DIMENSION=8192,MAX_FROZEN_FRAME_PIXELS=16777216;class LyraAnimatedImage extends LyraElement{constructor(){super(...arguments),this.src="",this.play=!1,this.ignoreReducedMotion=!1,this.accessibleLabel="",this.hasLoaded=!1,this.hasError=!1,this._playing=!1,this.userPlay=!1,this.connectionEventBaselinePending=!0,this.onMotionPreferenceChange=()=>{this.requestUpdate()},this.onImageLoad=event=>{if(!this.isConnected||event.currentTarget!==this.imageEl)return;this.hasError=!1,this.hasLoaded=!0;const img=this.imageEl,canvas=this.canvasEl;if(img&&canvas){const width=img.naturalWidth,height=img.naturalHeight,allocation=resolveBoundedCanvasAllocation({cssWidth:width,cssHeight:height,desiredScale:1,maxDimension:MAX_FROZEN_FRAME_DIMENSION,maxPixels:MAX_FROZEN_FRAME_PIXELS});canvas.width=allocation.pixelWidth,canvas.height=allocation.pixelHeight;const ctx=canvas.getContext("2d");ctx&&(ctx.scale(allocation.scaleX,allocation.scaleY),ctx.drawImage(img,0,0,width,height))}this.emit("lr-load",null)},this.onImageError=event=>{!this.isConnected||event.currentTarget!==this.imageEl||(this.hasLoaded=!1,this.hasError=!0,this.emit("lr-error",null))},this.onToggleClick=()=>{this.userPlay=this.play=!this.play},this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)}}static{this.defaultStrings={...super.defaultStrings,animatedImageDefaultAlt:LYRA_DEFAULT_animatedImageDefaultAlt,pauseWithContext:LYRA_DEFAULT_pauseWithContext,playWithContext:LYRA_DEFAULT_playWithContext}}static{this.knownUnobservedAttributes=["playing"]}static{this.styles=[LyraElement.styles,styles]}get playing(){return this._playing}connectedCallback(){super.connectedCallback(),this.connectionEventBaselinePending=!0,this.stopMotionWatch=observeReducedMotion(this,this.onMotionPreferenceChange),this.requestUpdate()}disconnectedCallback(){this.connectionEventBaselinePending=!0,this.stopMotionWatch?.(),this.stopMotionWatch=void 0,super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed);const mayEmitConnectionTransition=this.isConnected&&!this.connectionEventBaselinePending;changed.has("src")&&(this.hasLoaded=!1,this.hasError=!1,(this.src?.trim()??"")!==""&&safeMediaSrc(this.src)===null&&(this.hasError=!0,mayEmitConnectionTransition&&this.emit("lr-error",null))),this.play||(this.userPlay=!1);const nextPlaying=this.play&&(this.ignoreReducedMotion||this.userPlay||!prefersReducedMotion(this));nextPlaying!==this._playing&&(this._playing=nextPlaying,this.toggleAttribute("playing",nextPlaying),mayEmitConnectionTransition&&this.emit(nextPlaying?"lr-play":"lr-pause",null)),this.toggleAttribute("data-loaded",this.hasLoaded)}updated(changed){super.updated(changed),this.isConnected&&(this.connectionEventBaselinePending=!1)}get effectiveAlt(){return this.alt??""}get toggleLabel(){const authoredLabel=hostAriaLabel(this);if(authoredLabel)return authoredLabel;if(this.accessibleLabel)return this.accessibleLabel;const name=this.effectiveAlt||this.localize("animatedImageDefaultAlt");return this.playing?this.localize("pauseWithContext",void 0,{name}):this.localize("playWithContext",void 0,{name})}focus(options){this.playButtonEl?.focus(options)}blur(){this.playButtonEl?.blur()}click(){this.playButtonEl?.click()}render(){const src=safeMediaSrc(this.src),alt=this.effectiveAlt,frozen=this.hasLoaded&&!this.playing,showControls=this.hasLoaded&&!this.hasError;return html`
|
|
2
2
|
<div part="base">
|
|
3
3
|
<img
|
|
4
4
|
part="image"
|
|
@@ -12,12 +12,19 @@ import{type PropertyValues,type PropertyDeclaration,type TemplateResult}from'lit
|
|
|
12
12
|
* for reconstructing a chip from server-persisted attachment metadata
|
|
13
13
|
* (e.g. after a page reload, when no real `File` object exists any more).
|
|
14
14
|
*
|
|
15
|
-
* `file`
|
|
16
|
-
* The image thumbnail
|
|
17
|
-
* blob URL, created in the
|
|
18
|
-
* renders and revoked
|
|
19
|
-
* changes away from the object it was created for,
|
|
20
|
-
*
|
|
15
|
+
* `file` wins for `name`/`bytes`/`mime-type` when both are present — see each
|
|
16
|
+
* accessor's own doc. The image thumbnail and the preview source for a real
|
|
17
|
+
* `File` default to a cached `URL.createObjectURL()` blob URL, created in the
|
|
18
|
+
* update lifecycle immediately before the thumbnail renders and revoked
|
|
19
|
+
* automatically once `file` changes away from the object it was created for,
|
|
20
|
+
* once host-supplied sources make it unnecessary, and on disconnect — this
|
|
21
|
+
* component never leaks a blob URL. A non-empty, safe `thumbnail-src` (and a
|
|
22
|
+
* non-empty `preview-src`) takes precedence over that blob URL even while
|
|
23
|
+
* `file` is set, so a page whose Content-Security-Policy has no `blob:` in
|
|
24
|
+
* `img-src` can keep passing the `File` for name/size/type and supply its own
|
|
25
|
+
* `data:` or same-origin thumbnail: with both set (or `thumbnail-src` plus
|
|
26
|
+
* `without-preview`) no blob URL is ever created. Otherwise, showing a `File`'s
|
|
27
|
+
* own image needs `blob:` in `img-src`.
|
|
21
28
|
*
|
|
22
29
|
* Identifying *which* attachment a `lr-remove`/`lr-retry`/`lr-preview-request` event is about:
|
|
23
30
|
* set `attachment-id="..."` when you have a stable server-side attachment identity. The platform
|
|
@@ -98,14 +105,14 @@ name:string;private _bytes?;get bytes():number|undefined;set bytes(value:number|
|
|
|
98
105
|
attachmentId:string;
|
|
99
106
|
/** MIME type, used only while `file` is unset.*/
|
|
100
107
|
mimeType:string;
|
|
101
|
-
/** Thumbnail image URL,
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* `
|
|
105
|
-
*
|
|
108
|
+
/** Thumbnail image URL. Rendered whenever present and safe, also while `file` is set: it then
|
|
109
|
+
* replaces the blob URL a `File`'s own image thumbnail would otherwise use (see the class doc),
|
|
110
|
+
* for example a small `data:` thumbnail under a Content-Security-Policy without `blob:`. Like
|
|
111
|
+
* the no-`file` case it renders regardless of the MIME type, since a generated thumbnail is
|
|
112
|
+
* always an image. Unsafe schemes are ignored. */
|
|
106
113
|
thumbnailSrc:string;
|
|
107
|
-
/** URL used to preview or download the attachment
|
|
108
|
-
*
|
|
114
|
+
/** URL used to preview or download the attachment. While `file` is set and this is empty, the
|
|
115
|
+
* `File` is previewed through a temporary blob URL instead; a non-empty value wins over it. */
|
|
109
116
|
previewSrc:string;
|
|
110
117
|
/** Hides the preview action, which otherwise renders whenever a `file` or `preview-src` is
|
|
111
118
|
* available. */
|
|
@@ -150,4 +157,4 @@ uploadFailedLabel?:string;
|
|
|
150
157
|
/** Override for the empty-name fallback shown (and used as the `title` tooltip) when neither
|
|
151
158
|
* `file` nor `name` supply a filename -- for i18n/locale. Defaults to `'Untitled file'`,
|
|
152
159
|
* reproducing today's exact hardcoded text byte-for-byte. */
|
|
153
|
-
untitledLabel?:string;private objectUrl?;private objectUrlFile?;private readonly announcements;private readonly fallbackId;private get effectiveName();private get effectiveSize();private get effectiveMimeType();private get effectivePreviewSrc();private get resolvedId();private get hasNumericProgress();private get clampedProgress();private get compactDensity();private get effectiveStatus();private ensureObjectUrl;private revokeObjectUrl;private connectedStatusTransition;requestUpdate(name?:PropertyKey,oldValue?:unknown,options?:PropertyDeclaration):void;connectedCallback():void;adoptedCallback():void;protected willUpdate(changed:PropertyValues):void;disconnectedCallback():void;private get localizedUploadFailedLabel();private onRemoveClick;private onRetryClick;private onPreviewClick;private renderThumbnail;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-attachment-chip':LyraAttachmentChip;}}
|
|
160
|
+
untitledLabel?:string;private objectUrl?;private objectUrlFile?;private readonly announcements;private readonly fallbackId;private get effectiveName();private get effectiveSize();private get effectiveMimeType();private get effectivePreviewSrc();private get hostThumbnailSrc();private fileNeedsObjectUrl;private get resolvedId();private get hasNumericProgress();private get clampedProgress();private get compactDensity();private get effectiveStatus();private ensureObjectUrl;private revokeObjectUrl;private connectedStatusTransition;requestUpdate(name?:PropertyKey,oldValue?:unknown,options?:PropertyDeclaration):void;connectedCallback():void;adoptedCallback():void;protected willUpdate(changed:PropertyValues):void;disconnectedCallback():void;private get localizedUploadFailedLabel();private onRemoveClick;private onRetryClick;private onPreviewClick;private renderThumbnail;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-attachment-chip':LyraAttachmentChip;}}
|
|
@@ -11,7 +11,7 @@ import{__decorate}from"tslib";import{html,nothing,svg}from"lit";import{property}
|
|
|
11
11
|
aria-hidden="true"
|
|
12
12
|
focusable="false"
|
|
13
13
|
><polyline points="1 4 1 10 7 10"></polyline><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"></path></svg>
|
|
14
|
-
`}function statusText(status,uploadingText,uploadFailedLabel){return status==="error"?uploadFailedLabel:status==="uploading"?uploadingText:""}function fillMessage(message,values){return message.replace(/\{(label|percent)\}/g,(match,key)=>values[key]??match)}class LyraAttachmentChip extends LyraElement{constructor(){super(...arguments),this.name="",this.attachmentId="",this.mimeType="",this.thumbnailSrc="",this.previewSrc="",this.withoutPreview=!1,this.status="pending",this.progress=0,this.withoutRemoveButton=!1,this.thumbnailOnly=!1,this.announcements=new AnnouncementSinkController(this,{eager:["assertive"]}),this.fallbackId=nextId("attachment-chip"),this.connectedStatusTransition=!1,this.onRemoveClick=()=>{this.emit("lr-remove",{attachmentId:this.resolvedId})},this.onRetryClick=()=>{this.emit("lr-retry",{attachmentId:this.resolvedId})},this.onPreviewClick=()=>{this.effectivePreviewSrc&&this.emit("lr-preview-request",{attachmentId:this.resolvedId,name:this.effectiveName,mimeType:this.effectiveMimeType,src:this.effectivePreviewSrc})}}static{this.defaultStrings={...super.defaultStrings,attachmentPreviewFile:LYRA_DEFAULT_attachmentPreviewFile,attachmentPreviewName:LYRA_DEFAULT_attachmentPreviewName,attachmentRetryWithContext:LYRA_DEFAULT_attachmentRetryWithContext,attachmentUntitledFile:LYRA_DEFAULT_attachmentUntitledFile,attachmentUploadFailed:LYRA_DEFAULT_attachmentUploadFailed,attachmentUploadingIndeterminate:LYRA_DEFAULT_attachmentUploadingIndeterminate,attachmentUploadingProgress:LYRA_DEFAULT_attachmentUploadingProgress,attachmentUploadingWithContext:LYRA_DEFAULT_attachmentUploadingWithContext,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,fileSizeUnitB:LYRA_DEFAULT_fileSizeUnitB,fileSizeUnitGb:LYRA_DEFAULT_fileSizeUnitGb,fileSizeUnitKb:LYRA_DEFAULT_fileSizeUnitKb,fileSizeUnitMb:LYRA_DEFAULT_fileSizeUnitMb,fileSizeUnitTb:LYRA_DEFAULT_fileSizeUnitTb,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,removeWithContext:LYRA_DEFAULT_removeWithContext,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get bytes(){return this._bytes}set bytes(value){const old=this._bytes;this._bytes=typeof value=="number"&&Number.isFinite(value)&&value>=0?finiteRange(value,0,0):void 0,this.requestUpdate("bytes",old)}get size(){return this._size}set size(next){const raw=this.getAttribute("size"),normalized=raw!==null&&optionalSizeConverter.normalize(raw)!==void 0?optionalSizeConverter.normalize(next):normalizeReflectedOptionalSize(this,next),old=this._size;old!==normalized&&(this._size=normalized,this.requestUpdate("size",old))}get effectiveName(){return this.file?this.file.name:this.name}get effectiveSize(){return this.file?Number.isFinite(this.file.size)&&this.file.size>=0?finiteRange(this.file.size,0,0):void 0:this.bytes}get effectiveMimeType(){return this.file?this.file.type:this.mimeType}get effectivePreviewSrc(){return this.file?this.objectUrl??"":this.previewSrc}get resolvedId(){return this.attachmentId.trim().length>0?this.attachmentId:this.file?`${this.file.name}:${this.file.size}:${this.file.lastModified}`:this.fallbackId}get hasNumericProgress(){return this.status==="uploading"&&this.clampedProgress>0}get clampedProgress(){return finiteRange(this.progress,0,0,100)}get compactDensity(){return isCompactSize(this.size)}get effectiveStatus(){return this.status==="uploading"||this.status==="error"||this.status==="success"?this.status:"pending"}ensureObjectUrl(file){return this.objectUrlFile===file&&this.objectUrl?this.objectUrl:(this.revokeObjectUrl(),this.objectUrl=URL.createObjectURL(file),this.objectUrlFile=file,this.objectUrl)}revokeObjectUrl(){this.objectUrl&&URL.revokeObjectURL(this.objectUrl),this.objectUrl=void 0,this.objectUrlFile=void 0}requestUpdate(name,oldValue,options){name==="status"&&this.isConnected&&this.hasUpdated&&oldValue!==this.status&&(this.connectedStatusTransition=!0),super.requestUpdate(name,oldValue,options)}connectedCallback(){super.connectedCallback(),this.connectedStatusTransition=!1,this.hasUpdated&&this.requestUpdate()}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}willUpdate(changed){super.willUpdate(changed),changed.has("status")&&this.status!==this.effectiveStatus&&(this.status=this.effectiveStatus),this.isConnected&&this.hasUpdated&&this.connectedStatusTransition&&this.status==="error"&&this.announcements.announceAssertive(this.localizedUploadFailedLabel),this.connectedStatusTransition=!1,this.isConnected&&this.file&&
|
|
14
|
+
`}function statusText(status,uploadingText,uploadFailedLabel){return status==="error"?uploadFailedLabel:status==="uploading"?uploadingText:""}function fillMessage(message,values){return message.replace(/\{(label|percent)\}/g,(match,key)=>values[key]??match)}class LyraAttachmentChip extends LyraElement{constructor(){super(...arguments),this.name="",this.attachmentId="",this.mimeType="",this.thumbnailSrc="",this.previewSrc="",this.withoutPreview=!1,this.status="pending",this.progress=0,this.withoutRemoveButton=!1,this.thumbnailOnly=!1,this.announcements=new AnnouncementSinkController(this,{eager:["assertive"]}),this.fallbackId=nextId("attachment-chip"),this.connectedStatusTransition=!1,this.onRemoveClick=()=>{this.emit("lr-remove",{attachmentId:this.resolvedId})},this.onRetryClick=()=>{this.emit("lr-retry",{attachmentId:this.resolvedId})},this.onPreviewClick=()=>{this.effectivePreviewSrc&&this.emit("lr-preview-request",{attachmentId:this.resolvedId,name:this.effectiveName,mimeType:this.effectiveMimeType,src:this.effectivePreviewSrc})}}static{this.defaultStrings={...super.defaultStrings,attachmentPreviewFile:LYRA_DEFAULT_attachmentPreviewFile,attachmentPreviewName:LYRA_DEFAULT_attachmentPreviewName,attachmentRetryWithContext:LYRA_DEFAULT_attachmentRetryWithContext,attachmentUntitledFile:LYRA_DEFAULT_attachmentUntitledFile,attachmentUploadFailed:LYRA_DEFAULT_attachmentUploadFailed,attachmentUploadingIndeterminate:LYRA_DEFAULT_attachmentUploadingIndeterminate,attachmentUploadingProgress:LYRA_DEFAULT_attachmentUploadingProgress,attachmentUploadingWithContext:LYRA_DEFAULT_attachmentUploadingWithContext,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,fileSizeUnitB:LYRA_DEFAULT_fileSizeUnitB,fileSizeUnitGb:LYRA_DEFAULT_fileSizeUnitGb,fileSizeUnitKb:LYRA_DEFAULT_fileSizeUnitKb,fileSizeUnitMb:LYRA_DEFAULT_fileSizeUnitMb,fileSizeUnitTb:LYRA_DEFAULT_fileSizeUnitTb,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,removeWithContext:LYRA_DEFAULT_removeWithContext,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get bytes(){return this._bytes}set bytes(value){const old=this._bytes;this._bytes=typeof value=="number"&&Number.isFinite(value)&&value>=0?finiteRange(value,0,0):void 0,this.requestUpdate("bytes",old)}get size(){return this._size}set size(next){const raw=this.getAttribute("size"),normalized=raw!==null&&optionalSizeConverter.normalize(raw)!==void 0?optionalSizeConverter.normalize(next):normalizeReflectedOptionalSize(this,next),old=this._size;old!==normalized&&(this._size=normalized,this.requestUpdate("size",old))}get effectiveName(){return this.file?this.file.name:this.name}get effectiveSize(){return this.file?Number.isFinite(this.file.size)&&this.file.size>=0?finiteRange(this.file.size,0,0):void 0:this.bytes}get effectiveMimeType(){return this.file?this.file.type:this.mimeType}get effectivePreviewSrc(){return this.previewSrc?this.previewSrc:this.file?this.objectUrl??"":""}get hostThumbnailSrc(){return safeMediaSrc(this.thumbnailSrc)}fileNeedsObjectUrl(file){const forThumbnail=file.type.startsWith("image/")&&!this.hostThumbnailSrc,forPreview=!this.withoutPreview&&!this.previewSrc;return forThumbnail||forPreview}get resolvedId(){return this.attachmentId.trim().length>0?this.attachmentId:this.file?`${this.file.name}:${this.file.size}:${this.file.lastModified}`:this.fallbackId}get hasNumericProgress(){return this.status==="uploading"&&this.clampedProgress>0}get clampedProgress(){return finiteRange(this.progress,0,0,100)}get compactDensity(){return isCompactSize(this.size)}get effectiveStatus(){return this.status==="uploading"||this.status==="error"||this.status==="success"?this.status:"pending"}ensureObjectUrl(file){return this.objectUrlFile===file&&this.objectUrl?this.objectUrl:(this.revokeObjectUrl(),this.objectUrl=URL.createObjectURL(file),this.objectUrlFile=file,this.objectUrl)}revokeObjectUrl(){this.objectUrl&&URL.revokeObjectURL(this.objectUrl),this.objectUrl=void 0,this.objectUrlFile=void 0}requestUpdate(name,oldValue,options){name==="status"&&this.isConnected&&this.hasUpdated&&oldValue!==this.status&&(this.connectedStatusTransition=!0),super.requestUpdate(name,oldValue,options)}connectedCallback(){super.connectedCallback(),this.connectedStatusTransition=!1,this.hasUpdated&&this.requestUpdate()}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}willUpdate(changed){super.willUpdate(changed),changed.has("status")&&this.status!==this.effectiveStatus&&(this.status=this.effectiveStatus),this.isConnected&&this.hasUpdated&&this.connectedStatusTransition&&this.status==="error"&&this.announcements.announceAssertive(this.localizedUploadFailedLabel),this.connectedStatusTransition=!1,this.isConnected&&this.file&&this.fileNeedsObjectUrl(this.file)?this.ensureObjectUrl(this.file):this.objectUrlFile&&this.revokeObjectUrl()}disconnectedCallback(){super.disconnectedCallback(),this.revokeObjectUrl()}get localizedUploadFailedLabel(){return this.uploadFailedLabel??this.localize("attachmentUploadFailed")}renderThumbnail(){const hostThumbnailSrc=this.hostThumbnailSrc;if(this.file&&!hostThumbnailSrc){const fileImageSrc=this.objectUrl?safeMediaSrc(this.objectUrl):null;return this.effectiveMimeType.startsWith("image/")?fileImageSrc?html`<img src=${fileImageSrc} alt="" />`:html`${fileIcon()}`:html`${fileIcon()}`}return hostThumbnailSrc?html`<img src=${hostThumbnailSrc} alt="" />`:html`${fileIcon()}`}render(){const name=this.effectiveName,untitledLabel=this.untitledLabel??this.localize("attachmentUntitledFile"),displayName=name||untitledLabel,sizeText=this.effectiveSize!==void 0?formatFileSize(this.effectiveSize,unit=>this.localize(FILE_SIZE_UNIT_KEYS[unit]),localizedNumberLabel(this.effectiveLocale)):"",uploadFailedLabel=this.localizedUploadFailedLabel,progressPercent=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:0}).format(Math.round(this.clampedProgress)),uploadingText=this.uploadingLabel!=null?fillMessage(this.uploadingLabel,{label:displayName,percent:progressPercent}):this.hasNumericProgress?this.localize("attachmentUploadingProgress",void 0,{percent:progressPercent}):this.localize("attachmentUploadingIndeterminate"),uploadingWithContext=this.uploadingLabel?uploadingText:this.localize("attachmentUploadingWithContext",void 0,{label:displayName}),retryWithContext=this.retryLabel?fillMessage(this.retryLabel,{label:displayName}):this.localize("attachmentRetryWithContext",void 0,{label:displayName}),removeWithContext=this.removeLabel?fillMessage(this.removeLabel,{label:displayName}):this.localize("removeWithContext",void 0,{label:displayName}),status=this.effectiveStatus,text=statusText(status,uploadingText,uploadFailedLabel),uploading=status==="uploading";return html`
|
|
15
15
|
<div part="base">
|
|
16
16
|
<span part="thumbnail" aria-hidden="true"
|
|
17
17
|
>${this.renderThumbnail()}</span
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type{LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraAppearance,LyraSize}from'../../../internal/variants.js';import type{LyraFileInputRejectedFile}from'../file-input/file-input.class.js';export type LyraAttachmentCapability='files'|'image'|'camera'|'audio';
|
|
2
2
|
/** The capabilities that resolve to a real file selection (as opposed to `camera`/`audio`, which
|
|
3
3
|
* never touch the hidden file input -- see the class doc). */
|
|
4
|
-
export type LyraFileBackedCapability=Exclude<LyraAttachmentCapability,'camera'|'audio'>;
|
|
4
|
+
export type LyraFileBackedCapability=Exclude<LyraAttachmentCapability,'camera'|'audio'>;
|
|
5
|
+
/** The native `capture` values `camera-capture` accepts: which camera a capture-capable (touch)
|
|
6
|
+
* device opens. */
|
|
7
|
+
export type LyraAttachmentCameraCapture='user'|'environment';
|
|
8
|
+
/** The capabilities an `lr-files` event can report: the file-backed ones, plus `camera` while
|
|
9
|
+
* `camera-capture` routes it through the system camera. */
|
|
10
|
+
export type LyraAttachmentFilesCapability=LyraFileBackedCapability|'camera';export interface LyraAttachmentFilesDetail{capability:LyraAttachmentFilesCapability;files:readonly File[];rejected:readonly LyraFileInputRejectedFile[];remainingFiles:number|null;remainingTotalSize:number|null;}export interface LyraAttachmentTriggerEventMap{'lr-camera-request':CustomEvent<null>;'lr-audio-request':CustomEvent<null>;'lr-files':CustomEvent<LyraEventDetailSnapshot<LyraAttachmentFilesDetail>>;blur:FocusEvent;focus:FocusEvent;}
|
|
5
11
|
/**
|
|
6
12
|
* `<lr-attachment-trigger>` — a compact attach affordance designed for a
|
|
7
13
|
* chat composer's start slot (see `<lr-chat-composer>`'s own `start`
|
|
@@ -22,25 +28,35 @@ export type LyraFileBackedCapability=Exclude<LyraAttachmentCapability,'camera'|'
|
|
|
22
28
|
* `<input type="file">` with no `accept` attribute).
|
|
23
29
|
*
|
|
24
30
|
* **`camera`/`audio` are scope-limited by design.** This component does not
|
|
25
|
-
* implement any camera or microphone capture UI itself — no `getUserMedia
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* `
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
* implement any camera or microphone capture UI itself — no `getUserMedia` —
|
|
32
|
+
* because that's entirely a host/browser concern with no single right answer
|
|
33
|
+
* (a desktop web app, a mobile PWA, and a native wrapper all want different
|
|
34
|
+
* things here). Activating `camera` fires `lr-camera-request`; activating
|
|
35
|
+
* `audio` fires `lr-audio-request`. The host owns everything from that point
|
|
36
|
+
* on — typically opening `<lr-push-to-talk>` in a `<lr-overlay>`/popover for
|
|
37
|
+
* `audio`, then handing the resulting blob to something like
|
|
38
|
+
* `<lr-attachment-chip>`.
|
|
39
|
+
*
|
|
40
|
+
* The one opt-in exception is `camera-capture`: set it to `'environment'` or
|
|
41
|
+
* `'user'` and, on an engine that supports the native `capture` attribute
|
|
42
|
+
* (phones and tablets), `camera` opens the shared hidden file input with
|
|
43
|
+
* `accept="image/*"` and that `capture` value synchronously inside the
|
|
44
|
+
* activation, so the system camera opens, and the photo arrives as `lr-files`
|
|
45
|
+
* with `capability: 'camera'`. Where `capture` is unsupported (desktop
|
|
46
|
+
* browsers, which would only show a file picker), `camera` still fires
|
|
47
|
+
* `lr-camera-request`, so one host can keep its own camera dialog there.
|
|
33
48
|
*
|
|
34
49
|
* @customElement lr-attachment-trigger
|
|
35
50
|
* @event lr-files - A file-backed capability's hidden file input produced a real selection.
|
|
36
|
-
* `detail: { capability: 'files' | 'image', files, rejected, remainingFiles,
|
|
51
|
+
* `detail: { capability: 'files' | 'image' | 'camera', files, rejected, remainingFiles,
|
|
52
|
+
* remainingTotalSize }` (`'camera'` only while `camera-capture` routed the capture there),
|
|
37
53
|
* the same shape as `lr-file-input`'s. `files` are the picks matching `accept` (a fresh readonly
|
|
38
54
|
* owner-realm `File[]` snapshot rather than the native input's live `FileList`); the rest, which
|
|
39
55
|
* the OS dialog's "All files" filter can let through, are listed in `rejected`. No size or count
|
|
40
56
|
* limits apply here, so both `remaining*` fields are `null`.
|
|
41
57
|
* @event lr-camera-request - The `camera` capability was activated. No
|
|
42
58
|
* detail payload — see the class doc's scope note; the host implements the
|
|
43
|
-
* actual capture flow.
|
|
59
|
+
* actual capture flow. Not fired when `camera-capture` opens the system camera instead.
|
|
44
60
|
* @event lr-audio-request - The `audio` capability was activated. No
|
|
45
61
|
* detail payload — same request-only scope as `lr-camera-request`; the
|
|
46
62
|
* host implements the actual recording flow (typically `<lr-push-to-talk>`).
|
|
@@ -84,6 +100,14 @@ accept:string;private hostAccessibleLabel;
|
|
|
84
100
|
* `[part=menu-trigger]` button. Unset (the default): no `title` attribute, unchanged from
|
|
85
101
|
* before this property existed. */
|
|
86
102
|
triggerTitle?:string;
|
|
103
|
+
/** Opt-in system-camera capture for the `camera` capability: `'environment'` (rear camera) or
|
|
104
|
+
* `'user'` (front camera), the native `<input capture>` values. On an engine that supports
|
|
105
|
+
* `capture` (phones and tablets), activating `camera` opens the hidden file input with
|
|
106
|
+
* `accept="image/*"` and this `capture` value inside the same user gesture and reports the photo
|
|
107
|
+
* as `lr-files` with `capability: 'camera'` (non-image picks move to `rejected`). Elsewhere it
|
|
108
|
+
* keeps firing `lr-camera-request`. Unset (the default) or any other value: `camera` only fires
|
|
109
|
+
* `lr-camera-request`, unchanged. */
|
|
110
|
+
cameraCapture?:LyraAttachmentCameraCapture;
|
|
87
111
|
/** Forwarded to the hidden file input's own `multiple` attribute.*/
|
|
88
112
|
multiple:boolean;disabled:boolean;
|
|
89
113
|
/** How the trigger fills itself, from the library's one shared `appearance` vocabulary. The
|
|
@@ -99,4 +123,4 @@ appearance:LyraAppearance;
|
|
|
99
123
|
* tightest tiers resolve below WCAG 2.5.8's minimum, so wiring the target to it would let
|
|
100
124
|
* `size="2xs"` ship an untappable control. Override `--lr-icon-button-size` to make that
|
|
101
125
|
* trade-off explicitly, exactly as on a standalone `<lr-icon-button>`. */
|
|
102
|
-
size:LyraSize;private inputEl?;private dropdownEl?;private composedTriggerEl?;private descriptionSyncGeneration;private get triggerEl();private hasSyncedDescribedByElements;private pendingCapability;private pickerGeneration;private pendingPickerGeneration;private get effectiveCapabilities();private get hasFileCapability();protected willUpdate(changed:PropertyValues<this>):void;protected updated(changed:PropertyValues<this>):void;private syncTriggerDescription;private effectiveAccept;private activateCapability;private onTriggerClick;private onMenuSelect;private onInputChange;disconnectedCallback():void;private onControlFocus;private onControlBlur;private stopInternalEvent;private primaryControl;focus(options?:FocusOptions):void;blur():void;click():void;private renderHiddenInput;private renderSingleTrigger;private renderMenu;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-attachment-trigger':LyraAttachmentTrigger;}}
|
|
126
|
+
size:LyraSize;private inputEl?;private dropdownEl?;private composedTriggerEl?;private descriptionSyncGeneration;private get triggerEl();private hasSyncedDescribedByElements;private pendingCapability;private pickerGeneration;private pendingPickerGeneration;private get effectiveCapabilities();private get hasFileCapability();private get captureSupported();protected willUpdate(changed:PropertyValues<this>):void;protected updated(changed:PropertyValues<this>):void;private syncTriggerDescription;private effectiveAccept;private activateCapability;private onTriggerClick;private onMenuSelect;private onInputChange;disconnectedCallback():void;private onControlFocus;private onControlBlur;private stopInternalEvent;private primaryControl;focus(options?:FocusOptions):void;blur():void;click():void;private renderHiddenInput;private renderSingleTrigger;private renderMenu;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-attachment-trigger':LyraAttachmentTrigger;}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing,svg}from"lit";import{property,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{syncAriaDescribedByElements}from"../../../internal/aria-controls.js";import{chevronIcon}from"../../../internal/icons.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./attachment-trigger.styles.js";import{falseDefaultBooleanConverter}from"../../../internal/converters.js";import{matchesAccept}from"../file-input/accept.js";import{LYRA_DEFAULT_attachmentAdd,LYRA_DEFAULT_attachmentMenuAudio,LYRA_DEFAULT_attachmentMenuCamera,LYRA_DEFAULT_attachmentMenuFiles,LYRA_DEFAULT_attachmentMenuImage,LYRA_DEFAULT_attachmentTriggerAudio,LYRA_DEFAULT_attachmentTriggerCamera,LYRA_DEFAULT_attachmentTriggerFiles,LYRA_DEFAULT_attachmentTriggerImage}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function icon(paths){return svg`
|
|
1
|
+
import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing,svg}from"lit";import{property,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{syncAriaDescribedByElements}from"../../../internal/aria-controls.js";import{chevronIcon}from"../../../internal/icons.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./attachment-trigger.styles.js";import{falseDefaultBooleanConverter}from"../../../internal/converters.js";import{matchesAccept}from"../file-input/accept.js";import{LYRA_DEFAULT_attachmentAdd,LYRA_DEFAULT_attachmentMenuAudio,LYRA_DEFAULT_attachmentMenuCamera,LYRA_DEFAULT_attachmentMenuFiles,LYRA_DEFAULT_attachmentMenuImage,LYRA_DEFAULT_attachmentTriggerAudio,LYRA_DEFAULT_attachmentTriggerCamera,LYRA_DEFAULT_attachmentTriggerFiles,LYRA_DEFAULT_attachmentTriggerImage}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";function isCameraCapture(value){return value==="user"||value==="environment"}const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function icon(paths){return svg`
|
|
2
2
|
<svg
|
|
3
3
|
width="1em"
|
|
4
4
|
height="1em"
|
|
@@ -25,7 +25,7 @@ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/co
|
|
|
25
25
|
<path d="M19 10v2a7 7 0 0 1-14 0v-2"></path>
|
|
26
26
|
<line x1="12" y1="19" x2="12" y2="23"></line>
|
|
27
27
|
<line x1="8" y1="23" x2="16" y2="23"></line>
|
|
28
|
-
`)}const CAPABILITY_META={files:{icon:paperclipIcon,triggerKey:"attachmentTriggerFiles",menuKey:"attachmentMenuFiles"},image:{icon:imageIcon,triggerKey:"attachmentTriggerImage",menuKey:"attachmentMenuImage"},camera:{icon:cameraIcon,triggerKey:"attachmentTriggerCamera",menuKey:"attachmentMenuCamera"},audio:{icon:audioIcon,triggerKey:"attachmentTriggerAudio",menuKey:"attachmentMenuAudio"}},OWNED_CAPABILITY_SNAPSHOTS=new WeakSet;function ownCapabilitySnapshot(values){const snapshot=Object.freeze(values);return OWNED_CAPABILITY_SNAPSHOTS.add(snapshot),snapshot}const DEFAULT_CAPABILITIES=ownCapabilitySnapshot(["files"]),MAX_ATTACHMENT_CAPABILITIES=4,ATTACHMENT_CAPABILITY_SCAN_LIMIT=64;function normalizeCapabilities(value){try{if(!Array.isArray(value))return DEFAULT_CAPABILITIES;if(OWNED_CAPABILITY_SNAPSHOTS.has(value))return value;const normalized=[],length=Math.min(value.length,ATTACHMENT_CAPABILITY_SCAN_LIMIT);for(let index=0;index<length&&normalized.length<MAX_ATTACHMENT_CAPABILITIES;index++){const candidate=value[index];typeof candidate=="string"&&Object.prototype.hasOwnProperty.call(CAPABILITY_META,candidate)&&!normalized.includes(candidate)&&normalized.push(candidate)}return ownCapabilitySnapshot(normalized)}catch{return DEFAULT_CAPABILITIES}}function isCanonicalCapabilitySnapshot(source){try{return typeof source=="object"&&source!==null&&OWNED_CAPABILITY_SNAPSHOTS.has(source)}catch{return!1}}class LyraAttachmentTrigger extends LyraElement{constructor(){super(...arguments),this.capabilities=DEFAULT_CAPABILITIES,this.accept="",this.hostAccessibleLabel=null,this.multiple=!1,this.disabled=!1,this.appearance="plain",this.size="m",this.descriptionSyncGeneration=0,this.hasSyncedDescribedByElements=!1,this.pendingCapability="files",this.pickerGeneration=0,this.pendingPickerGeneration=-1,this.onTriggerClick=()=>{const capability=this.effectiveCapabilities[0];capability!==void 0&&this.activateCapability(capability)},this.onMenuSelect=e=>{e.stopPropagation();const capability=e.detail.item.value;Object.prototype.hasOwnProperty.call(CAPABILITY_META,capability)&&this.effectiveCapabilities.includes(capability)&&this.activateCapability(capability)},this.onInputChange=e=>{e.stopPropagation();const input=e.target,selected=input.files,generation=this.pendingPickerGeneration;if(this.pendingPickerGeneration=-1,this.isConnected&&generation===this.pickerGeneration&&!this.disabled&&selected&&selected.length>0){const accept=this.effectiveAccept(this.pendingCapability),files=Array.from(selected),matching=files.filter(file=>matchesAccept(file,accept)),matchingFiles=new Set(matching);this.emit("lr-files",{capability:this.pendingCapability,files:matching,rejected:files.filter(file=>!matchingFiles.has(file)).map(file=>({file,reason:"type"})),remainingFiles:null,remainingTotalSize:null})}input.value=""},this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)},this.stopInternalEvent=event=>{event.stopPropagation()}}static{this.defaultStrings={...super.defaultStrings,attachmentAdd:LYRA_DEFAULT_attachmentAdd,attachmentMenuAudio:LYRA_DEFAULT_attachmentMenuAudio,attachmentMenuCamera:LYRA_DEFAULT_attachmentMenuCamera,attachmentMenuFiles:LYRA_DEFAULT_attachmentMenuFiles,attachmentMenuImage:LYRA_DEFAULT_attachmentMenuImage,attachmentTriggerAudio:LYRA_DEFAULT_attachmentTriggerAudio,attachmentTriggerCamera:LYRA_DEFAULT_attachmentTriggerCamera,attachmentTriggerFiles:LYRA_DEFAULT_attachmentTriggerFiles,attachmentTriggerImage:LYRA_DEFAULT_attachmentTriggerImage,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["capabilities"])}static{this.styles=[LyraElement.styles,sizes,styles]}static{this.immutableEventDetails=Object.freeze(["lr-files"])}get triggerEl(){return this.composedTriggerEl?.control??this.composedTriggerEl}get effectiveCapabilities(){return normalizeCapabilities(this.capabilities)}get hasFileCapability(){return this.effectiveCapabilities.includes("files")||this.effectiveCapabilities.includes("image")}willUpdate(changed){if(super.willUpdate(changed),changed.has("disabled")&&this.disabled&&this.dropdownEl?.hide(),changed.has("capabilities")){const normalized=normalizeCapabilities(this.capabilities);isCanonicalCapabilitySnapshot(this.capabilities)||(this.capabilities=normalized)}}updated(changed){super.updated(changed),this.syncTriggerDescription();const composed=this.composedTriggerEl;if(!composed||composed.control)return;const generation=++this.descriptionSyncGeneration;composed.updateComplete.then(()=>{generation!==this.descriptionSyncGeneration||!this.isConnected||this.syncTriggerDescription()})}syncTriggerDescription(){const hostDescribedBy=this.getAttribute("aria-describedby");!hostDescribedBy&&!this.hasSyncedDescribedByElements||(this.hasSyncedDescribedByElements=syncAriaDescribedByElements(this,this.triggerEl,hostDescribedBy))}effectiveAccept(capability){return capability==="image"?this.accept||"image/*":this.accept}activateCapability(capability){if(this.disabled)return;if(capability==="camera"){this.emit("lr-camera-request",null);return}if(capability==="audio"){this.emit("lr-audio-request",null);return}this.pendingCapability=capability,this.pendingPickerGeneration=++this.pickerGeneration;const input=this.inputEl;input&&(input.accept=this.effectiveAccept(capability),input.click())}disconnectedCallback(){this.pendingPickerGeneration=-1,this.pickerGeneration++,this.dropdownEl?.hide(),super.disconnectedCallback()}primaryControl(){return this.renderRoot
|
|
28
|
+
`)}const CAPABILITY_META={files:{icon:paperclipIcon,triggerKey:"attachmentTriggerFiles",menuKey:"attachmentMenuFiles"},image:{icon:imageIcon,triggerKey:"attachmentTriggerImage",menuKey:"attachmentMenuImage"},camera:{icon:cameraIcon,triggerKey:"attachmentTriggerCamera",menuKey:"attachmentMenuCamera"},audio:{icon:audioIcon,triggerKey:"attachmentTriggerAudio",menuKey:"attachmentMenuAudio"}},OWNED_CAPABILITY_SNAPSHOTS=new WeakSet;function ownCapabilitySnapshot(values){const snapshot=Object.freeze(values);return OWNED_CAPABILITY_SNAPSHOTS.add(snapshot),snapshot}const DEFAULT_CAPABILITIES=ownCapabilitySnapshot(["files"]),MAX_ATTACHMENT_CAPABILITIES=4,ATTACHMENT_CAPABILITY_SCAN_LIMIT=64;function normalizeCapabilities(value){try{if(!Array.isArray(value))return DEFAULT_CAPABILITIES;if(OWNED_CAPABILITY_SNAPSHOTS.has(value))return value;const normalized=[],length=Math.min(value.length,ATTACHMENT_CAPABILITY_SCAN_LIMIT);for(let index=0;index<length&&normalized.length<MAX_ATTACHMENT_CAPABILITIES;index++){const candidate=value[index];typeof candidate=="string"&&Object.prototype.hasOwnProperty.call(CAPABILITY_META,candidate)&&!normalized.includes(candidate)&&normalized.push(candidate)}return ownCapabilitySnapshot(normalized)}catch{return DEFAULT_CAPABILITIES}}function isCanonicalCapabilitySnapshot(source){try{return typeof source=="object"&&source!==null&&OWNED_CAPABILITY_SNAPSHOTS.has(source)}catch{return!1}}class LyraAttachmentTrigger extends LyraElement{constructor(){super(...arguments),this.capabilities=DEFAULT_CAPABILITIES,this.accept="",this.hostAccessibleLabel=null,this.multiple=!1,this.disabled=!1,this.appearance="plain",this.size="m",this.descriptionSyncGeneration=0,this.hasSyncedDescribedByElements=!1,this.pendingCapability="files",this.pickerGeneration=0,this.pendingPickerGeneration=-1,this.onTriggerClick=()=>{const capability=this.effectiveCapabilities[0];capability!==void 0&&this.activateCapability(capability)},this.onMenuSelect=e=>{e.stopPropagation();const capability=e.detail.item.value;Object.prototype.hasOwnProperty.call(CAPABILITY_META,capability)&&this.effectiveCapabilities.includes(capability)&&this.activateCapability(capability)},this.onInputChange=e=>{e.stopPropagation();const input=e.target,selected=input.files,generation=this.pendingPickerGeneration;if(this.pendingPickerGeneration=-1,this.isConnected&&generation===this.pickerGeneration&&!this.disabled&&selected&&selected.length>0){const accept=this.effectiveAccept(this.pendingCapability),files=Array.from(selected),matching=files.filter(file=>matchesAccept(file,accept)),matchingFiles=new Set(matching);this.emit("lr-files",{capability:this.pendingCapability,files:matching,rejected:files.filter(file=>!matchingFiles.has(file)).map(file=>({file,reason:"type"})),remainingFiles:null,remainingTotalSize:null})}input.value=""},this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)},this.stopInternalEvent=event=>{event.stopPropagation()}}static{this.defaultStrings={...super.defaultStrings,attachmentAdd:LYRA_DEFAULT_attachmentAdd,attachmentMenuAudio:LYRA_DEFAULT_attachmentMenuAudio,attachmentMenuCamera:LYRA_DEFAULT_attachmentMenuCamera,attachmentMenuFiles:LYRA_DEFAULT_attachmentMenuFiles,attachmentMenuImage:LYRA_DEFAULT_attachmentMenuImage,attachmentTriggerAudio:LYRA_DEFAULT_attachmentTriggerAudio,attachmentTriggerCamera:LYRA_DEFAULT_attachmentTriggerCamera,attachmentTriggerFiles:LYRA_DEFAULT_attachmentTriggerFiles,attachmentTriggerImage:LYRA_DEFAULT_attachmentTriggerImage,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["capabilities"])}static{this.styles=[LyraElement.styles,sizes,styles]}static{this.immutableEventDetails=Object.freeze(["lr-files"])}get triggerEl(){return this.composedTriggerEl?.control??this.composedTriggerEl}get effectiveCapabilities(){return normalizeCapabilities(this.capabilities)}get hasFileCapability(){return this.effectiveCapabilities.includes("files")||this.effectiveCapabilities.includes("image")||isCameraCapture(this.cameraCapture)&&this.effectiveCapabilities.includes("camera")}get captureSupported(){const view=this.ownerDocument.defaultView;return!!(view&&"capture"in view.HTMLInputElement.prototype)}willUpdate(changed){if(super.willUpdate(changed),changed.has("disabled")&&this.disabled&&this.dropdownEl?.hide(),changed.has("capabilities")){const normalized=normalizeCapabilities(this.capabilities);isCanonicalCapabilitySnapshot(this.capabilities)||(this.capabilities=normalized)}}updated(changed){super.updated(changed),this.syncTriggerDescription();const composed=this.composedTriggerEl;if(!composed||composed.control)return;const generation=++this.descriptionSyncGeneration;composed.updateComplete.then(()=>{generation!==this.descriptionSyncGeneration||!this.isConnected||this.syncTriggerDescription()})}syncTriggerDescription(){const hostDescribedBy=this.getAttribute("aria-describedby");!hostDescribedBy&&!this.hasSyncedDescribedByElements||(this.hasSyncedDescribedByElements=syncAriaDescribedByElements(this,this.triggerEl,hostDescribedBy))}effectiveAccept(capability){return capability==="camera"?"image/*":capability==="image"?this.accept||"image/*":this.accept}activateCapability(capability){if(this.disabled)return;const capture=this.cameraCapture;if(capability==="camera"&&!(isCameraCapture(capture)&&this.captureSupported)){this.emit("lr-camera-request",null);return}if(capability==="audio"){this.emit("lr-audio-request",null);return}this.pendingCapability=capability,this.pendingPickerGeneration=++this.pickerGeneration;const input=this.inputEl;input&&(input.accept=this.effectiveAccept(capability),capability==="camera"&&isCameraCapture(capture)?input.setAttribute("capture",capture):input.removeAttribute("capture"),input.click())}disconnectedCallback(){this.pendingPickerGeneration=-1,this.pickerGeneration++,this.dropdownEl?.hide(),super.disconnectedCallback()}primaryControl(){return this.renderRoot?.querySelector('[part="trigger"], [part="menu-trigger"]')??void 0}focus(options){this.primaryControl()?.focus(options)}blur(){this.primaryControl()?.blur()}click(){this.primaryControl()?.click()}renderHiddenInput(){return html`
|
|
29
29
|
<input
|
|
30
30
|
part="hidden-input"
|
|
31
31
|
type="file"
|
|
@@ -84,4 +84,4 @@ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/co
|
|
|
84
84
|
${single?this.renderSingleTrigger(capabilities[0]):nothing}
|
|
85
85
|
${multi?this.renderMenu():nothing}
|
|
86
86
|
${this.hasFileCapability?this.renderHiddenInput():nothing}
|
|
87
|
-
`}}__decorate([property({attribute:!1})],LyraAttachmentTrigger.prototype,"capabilities",void 0),__decorate([property()],LyraAttachmentTrigger.prototype,"accept",void 0),__decorate([property({attribute:"aria-label"})],LyraAttachmentTrigger.prototype,"hostAccessibleLabel",void 0),__decorate([property({attribute:"trigger-title"})],LyraAttachmentTrigger.prototype,"triggerTitle",void 0),__decorate([property({type:Boolean,reflect:!0,converter:falseDefaultBooleanConverter})],LyraAttachmentTrigger.prototype,"multiple",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraAttachmentTrigger.prototype,"disabled",void 0),__decorate([property({reflect:!0})],LyraAttachmentTrigger.prototype,"appearance",void 0),__decorate([property({reflect:!0})],LyraAttachmentTrigger.prototype,"size",void 0),__decorate([query('input[type="file"]')],LyraAttachmentTrigger.prototype,"inputEl",void 0),__decorate([query("lr-dropdown")],LyraAttachmentTrigger.prototype,"dropdownEl",void 0),__decorate([query('[part="trigger"], [part="menu-trigger"]')],LyraAttachmentTrigger.prototype,"composedTriggerEl",void 0);export{LyraAttachmentTrigger};
|
|
87
|
+
`}}__decorate([property({attribute:!1})],LyraAttachmentTrigger.prototype,"capabilities",void 0),__decorate([property()],LyraAttachmentTrigger.prototype,"accept",void 0),__decorate([property({attribute:"aria-label"})],LyraAttachmentTrigger.prototype,"hostAccessibleLabel",void 0),__decorate([property({attribute:"trigger-title"})],LyraAttachmentTrigger.prototype,"triggerTitle",void 0),__decorate([property({attribute:"camera-capture"})],LyraAttachmentTrigger.prototype,"cameraCapture",void 0),__decorate([property({type:Boolean,reflect:!0,converter:falseDefaultBooleanConverter})],LyraAttachmentTrigger.prototype,"multiple",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraAttachmentTrigger.prototype,"disabled",void 0),__decorate([property({reflect:!0})],LyraAttachmentTrigger.prototype,"appearance",void 0),__decorate([property({reflect:!0})],LyraAttachmentTrigger.prototype,"size",void 0),__decorate([query('input[type="file"]')],LyraAttachmentTrigger.prototype,"inputEl",void 0),__decorate([query("lr-dropdown")],LyraAttachmentTrigger.prototype,"dropdownEl",void 0),__decorate([query('[part="trigger"], [part="menu-trigger"]')],LyraAttachmentTrigger.prototype,"composedTriggerEl",void 0);export{LyraAttachmentTrigger};
|
|
@@ -20,13 +20,22 @@ export interface LyraDropZoneFilesEvent extends CustomEvent<LyraDropZoneFilesDet
|
|
|
20
20
|
* selected-file list, or any focusable control of its own; wrap `lr-file-input` itself (or any
|
|
21
21
|
* other focusable content) inside it when the region also needs a click-to-browse affordance.
|
|
22
22
|
*
|
|
23
|
+
* **Targeting an existing region.** Instead of wrapping, the zone can sit beside a region that is
|
|
24
|
+
* already in the page: set `for` to the region's id (resolved in the zone's own root, like a
|
|
25
|
+
* label's `for`) or `target` to the element itself. The zone then attaches its drag listeners to
|
|
26
|
+
* that element, lays its overlay over the element's box, adds no box of its own (`display:
|
|
27
|
+
* contents`) and still emits `lr-files` from itself. Static markup keeps its layout tree, and the
|
|
28
|
+
* definition can load after first paint. A `for` id that matches nothing binds nothing and is
|
|
29
|
+
* re-resolved when the root's elements or ids change.
|
|
30
|
+
*
|
|
23
31
|
* The drag-session mechanics (nested-depth tracking, accept/reject preview, legacy File System API
|
|
24
32
|
* folder traversal) are the exact ones `lr-file-input` uses, shared through
|
|
25
33
|
* `internal/drop-session-controller.ts` rather than reimplemented here.
|
|
26
34
|
*
|
|
27
35
|
* @customElement lr-drop-zone
|
|
28
36
|
* @slot - The wrapped region. Rendered as ordinary light DOM content; this element adds only the
|
|
29
|
-
* drag listeners and the overlay layered on top.
|
|
37
|
+
* drag listeners and the overlay layered on top. Not a drop target while `for`/`target` resolves to
|
|
38
|
+
* an element.
|
|
30
39
|
* @slot overlay - Custom drag-over overlay content, overriding the localized accept/reject text.
|
|
31
40
|
* @event lr-files - Frozen `detail: { files, rejected, remainingFiles, remainingTotalSize }` with
|
|
32
41
|
* detached readonly sequences and rejected-file records, fired on drop.
|
|
@@ -35,8 +44,8 @@ export interface LyraDropZoneFilesEvent extends CustomEvent<LyraDropZoneFilesDet
|
|
|
35
44
|
* identity. Typed as {@linkcode LyraDropZoneFilesEvent}, so
|
|
36
45
|
* `event.target`/`event.currentTarget` are `LyraDropZone` without a cast.
|
|
37
46
|
* @csspart base - The wrapping element wrapping the default slot and the overlay.
|
|
38
|
-
* @csspart overlay - The drag-over overlay, layered above the slotted content
|
|
39
|
-
* active drag session.
|
|
47
|
+
* @csspart overlay - The drag-over overlay, layered above the slotted content (or, while targeting,
|
|
48
|
+
* fixed over the target's box). Hidden outside an active drag session.
|
|
40
49
|
* @csspart overlay-icon - The default decorative overlay icon.
|
|
41
50
|
* @csspart overlay-text - Wrapper around the overlay slot/text content.
|
|
42
51
|
* @csspart status - The visually-hidden, `aria-hidden` mirror of the drag accept/reject state and
|
|
@@ -46,6 +55,7 @@ export interface LyraDropZoneFilesEvent extends CustomEvent<LyraDropZoneFilesDet
|
|
|
46
55
|
* @csspart rejection - The visible region listing each currently-rejected file alongside its
|
|
47
56
|
* reason, rendered in addition to the sr-only `status` summary.
|
|
48
57
|
* @cssstate dragging - Matches during an active file drag session.
|
|
58
|
+
* @cssstate targeted - Matches while `for`/`target` resolves to an element the zone is attached to.
|
|
49
59
|
* @cssprop [--lr-drop-zone-radius=var(--lr-radius)] - Corner radius of `[part="overlay"]`.
|
|
50
60
|
* @cssprop [--lr-drop-zone-overlay-border-color=var(--lr-color-brand)] - Dashed border color of
|
|
51
61
|
* `[part="overlay"]` in its neutral drag state, before an accept or reject verdict.
|
|
@@ -113,7 +123,15 @@ heldTotalSize:number;
|
|
|
113
123
|
/** Density tier for the overlay's padding, icon and instructional text -- identical contract and
|
|
114
124
|
* scale to `lr-file-input`'s own `size`, so a small-tier drop-zone can match a neighboring
|
|
115
125
|
* small-tier `lr-file-input` in the same dense layout. */
|
|
116
|
-
size:LyraSize;
|
|
126
|
+
size:LyraSize;
|
|
127
|
+
/** Id of an existing element, in this zone's own root, to attach to instead of the default slot:
|
|
128
|
+
* the zone handles drags over that element and lays its overlay over it, so a server-rendered
|
|
129
|
+
* region becomes a drop target without being wrapped. An id that matches nothing binds nothing;
|
|
130
|
+
* it is re-resolved when elements or ids in the root change. `target` takes precedence. */
|
|
131
|
+
for:string;
|
|
132
|
+
/** An element to attach to directly, taking precedence over `for` while it is connected. Same
|
|
133
|
+
* behavior as `for`; property only. */
|
|
134
|
+
target:Element|null;private overlayEl?;private boundTarget?;private stopObservingRoot?;private dragState;private rejectedFiles;private resultStatus;private readonly internals;private readonly dropSession;private politeSink?;private assertiveSink?;private announcementsArmed;constructor();
|
|
117
135
|
/** Readonly state derived from the current drag session.
|
|
118
136
|
* @default false */
|
|
119
|
-
get dragging():boolean;protected willUpdate(changed:PropertyValues<this>):void;connectedCallback():void;disconnectedCallback():void;protected updated(changed:PropertyValues):void;private classify;private rejectionMessage;private emitFiles;private onDragEnter;private onDragOver;private onDragLeave;private onDrop;private overlayText;private statusText;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-drop-zone':LyraDropZone;}}
|
|
137
|
+
get dragging():boolean;protected willUpdate(changed:PropertyValues<this>):void;private resolveTarget;private syncTarget;private observeRoot;private positionTargetOverlay;connectedCallback():void;disconnectedCallback():void;protected updated(changed:PropertyValues):void;private classify;private rejectionMessage;private emitFiles;private onDragEnter;private onDragOver;private onDragLeave;private onDrop;private onTargetDragEnter;private onTargetDragOver;private onTargetDragLeave;private onTargetDrop;private handleDropEvent;private overlayText;private statusText;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-drop-zone':LyraDropZone;}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{srOnly}from"../../../internal/a11y.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{setCustomState}from"../../../internal/custom-states.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{fileIcon}from"../../../internal/icons.js";import{falseDefaultBooleanConverter}from"../../../internal/converters.js";import{DropSessionController}from"../../../internal/drop-session-controller.js";import{classifyFiles,EMPTY_MIME_TYPES,freezeDetail,handleDrop,mimeTypeFilter,outcomeText,snapshotMimeTypes}from"../file-input/file-intake.js";import{styles}from"./drop-zone.styles.js";import{LYRA_DEFAULT_dropzoneRejectedType,LYRA_DEFAULT_dropzoneReleaseToAdd,LYRA_DEFAULT_fileInputAcceptedMany,LYRA_DEFAULT_fileInputAcceptedOne,LYRA_DEFAULT_fileInputFolderRejected,LYRA_DEFAULT_fileInputRejectedCount,LYRA_DEFAULT_fileInputRejectedLimit,LYRA_DEFAULT_fileInputRejectedMany,LYRA_DEFAULT_fileInputRejectedMaxFiles,LYRA_DEFAULT_fileInputRejectedMaxTotalSize,LYRA_DEFAULT_fileInputRejectedOne,LYRA_DEFAULT_fileInputRejectedRead,LYRA_DEFAULT_fileInputRejectedSize,LYRA_DEFAULT_fileInputRejectedType}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";class LyraDropZone extends LyraElement{static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,dropzoneRejectedType:LYRA_DEFAULT_dropzoneRejectedType,dropzoneReleaseToAdd:LYRA_DEFAULT_dropzoneReleaseToAdd,fileInputAcceptedMany:LYRA_DEFAULT_fileInputAcceptedMany,fileInputAcceptedOne:LYRA_DEFAULT_fileInputAcceptedOne,fileInputFolderRejected:LYRA_DEFAULT_fileInputFolderRejected,fileInputRejectedCount:LYRA_DEFAULT_fileInputRejectedCount,fileInputRejectedLimit:LYRA_DEFAULT_fileInputRejectedLimit,fileInputRejectedMany:LYRA_DEFAULT_fileInputRejectedMany,fileInputRejectedMaxFiles:LYRA_DEFAULT_fileInputRejectedMaxFiles,fileInputRejectedMaxTotalSize:LYRA_DEFAULT_fileInputRejectedMaxTotalSize,fileInputRejectedOne:LYRA_DEFAULT_fileInputRejectedOne,fileInputRejectedRead:LYRA_DEFAULT_fileInputRejectedRead,fileInputRejectedSize:LYRA_DEFAULT_fileInputRejectedSize,fileInputRejectedType:LYRA_DEFAULT_fileInputRejectedType,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-files"])}static{this.styles=[LyraElement.styles,styles,srOnly]}constructor(){super(),this.disabled=!1,this.multiple=!1,this.accept="",this.allowedMimeTypes=EMPTY_MIME_TYPES,this.forbiddenMimeTypes=EMPTY_MIME_TYPES,this.maxFileSize=0,this.maxFiles=0,this.maxTotalSize=0,this.heldFileCount=0,this.heldTotalSize=0,this.size="m",this.dragState="default",this.rejectedFiles=Object.freeze([]),this.resultStatus="",this.announcementsArmed=!1,this.onDragEnter=e=>this.dropSession.onDragEnter(e),this.onDragOver=e=>this.dropSession.onDragOver(e),this.onDragLeave=e=>this.dropSession.onDragLeave(e),this.onDrop=e=>
|
|
1
|
+
import{__decorate}from"tslib";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{srOnly}from"../../../internal/a11y.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{setCustomState}from"../../../internal/custom-states.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{fileIcon}from"../../../internal/icons.js";import{falseDefaultBooleanConverter}from"../../../internal/converters.js";import{subscribeInheritedAttributes}from"../../../internal/inherited-attribute-hub.js";import{DropSessionController}from"../../../internal/drop-session-controller.js";import{classifyFiles,EMPTY_MIME_TYPES,freezeDetail,handleDrop,mimeTypeFilter,outcomeText,snapshotMimeTypes}from"../file-input/file-intake.js";import{styles}from"./drop-zone.styles.js";import{LYRA_DEFAULT_dropzoneRejectedType,LYRA_DEFAULT_dropzoneReleaseToAdd,LYRA_DEFAULT_fileInputAcceptedMany,LYRA_DEFAULT_fileInputAcceptedOne,LYRA_DEFAULT_fileInputFolderRejected,LYRA_DEFAULT_fileInputRejectedCount,LYRA_DEFAULT_fileInputRejectedLimit,LYRA_DEFAULT_fileInputRejectedMany,LYRA_DEFAULT_fileInputRejectedMaxFiles,LYRA_DEFAULT_fileInputRejectedMaxTotalSize,LYRA_DEFAULT_fileInputRejectedOne,LYRA_DEFAULT_fileInputRejectedRead,LYRA_DEFAULT_fileInputRejectedSize,LYRA_DEFAULT_fileInputRejectedType}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";class LyraDropZone extends LyraElement{static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,dropzoneRejectedType:LYRA_DEFAULT_dropzoneRejectedType,dropzoneReleaseToAdd:LYRA_DEFAULT_dropzoneReleaseToAdd,fileInputAcceptedMany:LYRA_DEFAULT_fileInputAcceptedMany,fileInputAcceptedOne:LYRA_DEFAULT_fileInputAcceptedOne,fileInputFolderRejected:LYRA_DEFAULT_fileInputFolderRejected,fileInputRejectedCount:LYRA_DEFAULT_fileInputRejectedCount,fileInputRejectedLimit:LYRA_DEFAULT_fileInputRejectedLimit,fileInputRejectedMany:LYRA_DEFAULT_fileInputRejectedMany,fileInputRejectedMaxFiles:LYRA_DEFAULT_fileInputRejectedMaxFiles,fileInputRejectedMaxTotalSize:LYRA_DEFAULT_fileInputRejectedMaxTotalSize,fileInputRejectedOne:LYRA_DEFAULT_fileInputRejectedOne,fileInputRejectedRead:LYRA_DEFAULT_fileInputRejectedRead,fileInputRejectedSize:LYRA_DEFAULT_fileInputRejectedSize,fileInputRejectedType:LYRA_DEFAULT_fileInputRejectedType,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-files"])}static{this.styles=[LyraElement.styles,styles,srOnly]}constructor(){super(),this.disabled=!1,this.multiple=!1,this.accept="",this.allowedMimeTypes=EMPTY_MIME_TYPES,this.forbiddenMimeTypes=EMPTY_MIME_TYPES,this.maxFileSize=0,this.maxFiles=0,this.maxTotalSize=0,this.heldFileCount=0,this.heldTotalSize=0,this.size="m",this.for="",this.target=null,this.dragState="default",this.rejectedFiles=Object.freeze([]),this.resultStatus="",this.announcementsArmed=!1,this.onDragEnter=e=>{this.boundTarget||this.dropSession.onDragEnter(e)},this.onDragOver=e=>{this.boundTarget||this.dropSession.onDragOver(e)},this.onDragLeave=e=>{this.boundTarget||this.dropSession.onDragLeave(e)},this.onDrop=e=>{this.boundTarget||this.handleDropEvent(e)},this.onTargetDragEnter=e=>this.dropSession.onDragEnter(e),this.onTargetDragOver=e=>{this.dropSession.onDragOver(e),this.positionTargetOverlay()},this.onTargetDragLeave=e=>this.dropSession.onDragLeave(e),this.onTargetDrop=e=>this.handleDropEvent(e),this.internals=attachInternalsSafely(this),this.dropSession=new DropSessionController(this,{isDisabled:()=>this.disabled,previewRejects:items=>this.classify(items,!0).rejected.length>0,onStateChange:()=>{this.dragState=this.dropSession.state,setCustomState(this.internals,"dragging",this.dropSession.dragging)}})}get dragging(){return this.dragState!=="default"}willUpdate(changed){super.willUpdate(changed),changed.has("disabled")&&this.disabled&&this.dropSession.reset(),(changed.has("for")||changed.has("target"))&&(this.syncTarget(),this.observeRoot())}resolveTarget(){return this.isConnected?this.target?.isConnected?this.target:this.for?this.getRootNode().getElementById?.(this.for)??void 0:void 0:void 0}syncTarget(){const next=this.resolveTarget(),previous=this.boundTarget;next!==previous&&(previous&&(previous.removeEventListener("dragenter",this.onTargetDragEnter),previous.removeEventListener("dragover",this.onTargetDragOver),previous.removeEventListener("dragleave",this.onTargetDragLeave),previous.removeEventListener("drop",this.onTargetDrop),this.dropSession.dragging&&this.dropSession.reset()),this.boundTarget=next,next&&(next.addEventListener("dragenter",this.onTargetDragEnter),next.addEventListener("dragover",this.onTargetDragOver),next.addEventListener("dragleave",this.onTargetDragLeave),next.addEventListener("drop",this.onTargetDrop)),setCustomState(this.internals,"targeted",next!==void 0))}observeRoot(){if(this.stopObservingRoot?.(),this.stopObservingRoot=void 0,!this.isConnected||!this.for&&!this.target)return;const root=this.getRootNode();this.stopObservingRoot=subscribeInheritedAttributes(root,this.ownerDocument.defaultView?.MutationObserver,{attributes:["id"],childList:!0,changed:()=>this.syncTarget()})}positionTargetOverlay(){const overlay=this.overlayEl,target=this.boundTarget;if(!overlay||!target||overlay.hidden)return;const rect=target.getBoundingClientRect();overlay.style.left="0px",overlay.style.top="0px";const origin=overlay.getBoundingClientRect();overlay.style.left=`${rect.left-origin.left}px`,overlay.style.top=`${rect.top-origin.top}px`,overlay.style.width=`${rect.width}px`,overlay.style.height=`${rect.height}px`}connectedCallback(){super.connectedCallback(),this.syncTarget(),this.observeRoot(),this.politeSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.assertiveSink??=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this})}disconnectedCallback(){this.stopObservingRoot?.(),this.stopObservingRoot=void 0,this.syncTarget(),this.politeSink?.release(),this.politeSink=void 0,this.assertiveSink?.release(),this.assertiveSink=void 0,this.announcementsArmed=!1,super.disconnectedCallback()}updated(changed){super.updated(changed),changed.has("dragState")&&this.positionTargetOverlay(),this.announcementsArmed&&(changed.has("dragState")&&this.dragState!=="default"&&this.politeSink?.announce(this.overlayText()),changed.has("resultStatus")&&this.resultStatus&&this.politeSink?.announce(this.resultStatus),changed.has("rejectedFiles")&&this.rejectedFiles.length>0&&this.assertiveSink?.announce(this.rejectedFiles.map(rejected=>this.rejectionMessage(rejected)).join(" "))),this.announcementsArmed=!0}classify(fileList,isPreview=!1){return classifyFiles(this,fileList,this.multiple,[],isPreview,mimeTypeFilter(snapshotMimeTypes(this.allowedMimeTypes),snapshotMimeTypes(this.forbiddenMimeTypes)))}rejectionMessage(rejected){const filename=rejected.file.name;switch(rejected.reason){case"type":return this.localize("fileInputRejectedType",void 0,{filename});case"size":return this.localize("fileInputRejectedSize",void 0,{filename});case"count":return this.localize("fileInputRejectedCount",void 0,{filename});case"directory":return this.localize("fileInputFolderRejected",void 0,{filename});case"read":return this.localize("fileInputRejectedRead",void 0,{filename});case"limit":return this.localize("fileInputRejectedLimit",void 0,{filename});case"maxFiles":return this.localize("fileInputRejectedMaxFiles",void 0,{filename});case"maxTotalSize":return this.localize("fileInputRejectedMaxTotalSize",void 0,{filename})}}emitFiles(fileList,additionalRejected=[]){const detail=freezeDetail(this.classify(fileList),additionalRejected),{files,rejected}=detail;this.rejectedFiles=rejected;const messages=[],numberFormat=getNumberFormat(this.effectiveLocale);if(files.length){const count=numberFormat.format(files.length),key=files.length===1?"fileInputAcceptedOne":"fileInputAcceptedMany";messages.push(outcomeText(this.acceptedMessage,()=>this.localize(key,void 0,{count}),count))}if(rejected.length){const count=numberFormat.format(rejected.length),key=rejected.length===1?"fileInputRejectedOne":"fileInputRejectedMany";messages.push(outcomeText(this.rejectedMessage,()=>this.localize(key,void 0,{count}),count))}this.resultStatus=messages.filter(message=>message.length>0).join(" "),this.emit("lr-files",detail)}handleDropEvent(e){handleDrop(this,this.dropSession,e,this.multiple,(files,rejected)=>this.emitFiles(files,rejected))}overlayText(){return this.dragState==="accept"?this.localize("dropzoneReleaseToAdd"):this.dragState==="reject"?this.localize("dropzoneRejectedType"):""}statusText(){return this.dragState==="default"?this.resultStatus:this.overlayText()}render(){return html`
|
|
2
2
|
<div
|
|
3
3
|
part="base"
|
|
4
4
|
@dragenter=${this.onDragEnter}
|
|
@@ -20,4 +20,4 @@ import{__decorate}from"tslib";import{eventCollectionSupport}from"../../../intern
|
|
|
20
20
|
</ul>
|
|
21
21
|
</div>
|
|
22
22
|
`:nothing}
|
|
23
|
-
`}}__decorate([property({type:Boolean,reflect:!0})],LyraDropZone.prototype,"disabled",void 0),__decorate([property({type:Boolean,reflect:!0,converter:falseDefaultBooleanConverter})],LyraDropZone.prototype,"multiple",void 0),__decorate([property()],LyraDropZone.prototype,"accept",void 0),__decorate([property({attribute:!1})],LyraDropZone.prototype,"allowedMimeTypes",void 0),__decorate([property({attribute:!1})],LyraDropZone.prototype,"forbiddenMimeTypes",void 0),__decorate([property({attribute:"accepted-message"})],LyraDropZone.prototype,"acceptedMessage",void 0),__decorate([property({attribute:"rejected-message"})],LyraDropZone.prototype,"rejectedMessage",void 0),__decorate([property({type:Number,attribute:"max-file-size"})],LyraDropZone.prototype,"maxFileSize",void 0),__decorate([property({type:Number,attribute:"max-files"})],LyraDropZone.prototype,"maxFiles",void 0),__decorate([property({type:Number,attribute:"max-total-size"})],LyraDropZone.prototype,"maxTotalSize",void 0),__decorate([property({type:Number,attribute:"held-file-count"})],LyraDropZone.prototype,"heldFileCount",void 0),__decorate([property({type:Number,attribute:"held-total-size"})],LyraDropZone.prototype,"heldTotalSize",void 0),__decorate([property({reflect:!0})],LyraDropZone.prototype,"size",void 0),__decorate([state()],LyraDropZone.prototype,"dragState",void 0),__decorate([state()],LyraDropZone.prototype,"rejectedFiles",void 0),__decorate([state()],LyraDropZone.prototype,"resultStatus",void 0);export{LyraDropZone};
|
|
23
|
+
`}}__decorate([property({type:Boolean,reflect:!0})],LyraDropZone.prototype,"disabled",void 0),__decorate([property({type:Boolean,reflect:!0,converter:falseDefaultBooleanConverter})],LyraDropZone.prototype,"multiple",void 0),__decorate([property()],LyraDropZone.prototype,"accept",void 0),__decorate([property({attribute:!1})],LyraDropZone.prototype,"allowedMimeTypes",void 0),__decorate([property({attribute:!1})],LyraDropZone.prototype,"forbiddenMimeTypes",void 0),__decorate([property({attribute:"accepted-message"})],LyraDropZone.prototype,"acceptedMessage",void 0),__decorate([property({attribute:"rejected-message"})],LyraDropZone.prototype,"rejectedMessage",void 0),__decorate([property({type:Number,attribute:"max-file-size"})],LyraDropZone.prototype,"maxFileSize",void 0),__decorate([property({type:Number,attribute:"max-files"})],LyraDropZone.prototype,"maxFiles",void 0),__decorate([property({type:Number,attribute:"max-total-size"})],LyraDropZone.prototype,"maxTotalSize",void 0),__decorate([property({type:Number,attribute:"held-file-count"})],LyraDropZone.prototype,"heldFileCount",void 0),__decorate([property({type:Number,attribute:"held-total-size"})],LyraDropZone.prototype,"heldTotalSize",void 0),__decorate([property({reflect:!0})],LyraDropZone.prototype,"size",void 0),__decorate([property()],LyraDropZone.prototype,"for",void 0),__decorate([property({attribute:!1})],LyraDropZone.prototype,"target",void 0),__decorate([query('[part="overlay"]')],LyraDropZone.prototype,"overlayEl",void 0),__decorate([state()],LyraDropZone.prototype,"dragState",void 0),__decorate([state()],LyraDropZone.prototype,"rejectedFiles",void 0),__decorate([state()],LyraDropZone.prototype,"resultStatus",void 0);export{LyraDropZone};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css}from"lit";const styles=css`:host{--_lr-drop-zone-overlay-font-size:var(--lr-font-size-md-sm);--_lr-drop-zone-overlay-icon-size:var(--lr-font-size-xl);--_lr-drop-zone-overlay-padding:var(--lr-space-l);min-inline-size:0;display:block;position:relative}:host([size="2xs"]),:host([size=xs]){--_lr-drop-zone-overlay-font-size:var(--lr-font-size-xs);--_lr-drop-zone-overlay-icon-size:var(--lr-font-size-md-sm);--_lr-drop-zone-overlay-padding:var(--lr-space-s)}:host([size=s]),:host([size=small]){--_lr-drop-zone-overlay-font-size:var(--lr-font-size-sm);--_lr-drop-zone-overlay-icon-size:var(--lr-font-size-lg);--_lr-drop-zone-overlay-padding:var(--lr-space-m)}:host([size=l]),:host([size=large]){--_lr-drop-zone-overlay-font-size:var(--lr-font-size-lg);--_lr-drop-zone-overlay-icon-size:var(--lr-font-size-2xl);--_lr-drop-zone-overlay-padding:var(--lr-space-2xl)}:host([size=xl]){--_lr-drop-zone-overlay-font-size:var(--lr-font-size-xl);--_lr-drop-zone-overlay-icon-size:var(--lr-font-size-3xl);--_lr-drop-zone-overlay-padding:var(--lr-space-2xl)}[part=base]{display:contents}[part=overlay]{z-index:var(--lr-layer-content);justify-content:center;align-items:center;gap:var(--lr-drop-zone-overlay-gap,var(--lr-space-xs));box-sizing:border-box;padding:var(--lr-drop-zone-overlay-padding,var(--_lr-drop-zone-overlay-padding));border:var(--lr-border-width-medium) dashed var(--lr-drop-zone-overlay-border-color,var(--lr-color-brand));border-radius:var(--lr-drop-zone-radius,var(--lr-radius));background:var(--lr-drop-zone-overlay-bg,color-mix(in srgb, var(--lr-color-brand) 8%, transparent));color:var(--lr-color-text-quiet);font-size:var(--lr-drop-zone-overlay-font-size,var(--_lr-drop-zone-overlay-font-size));text-align:center;pointer-events:none;transition:border-color var(--lr-transition-fast), background-color var(--lr-transition-fast);flex-direction:column;display:flex;position:absolute;inset:0}[part=overlay][hidden]{display:none}[part=overlay-icon]{font-size:var(--lr-drop-zone-overlay-icon-size,var(--_lr-drop-zone-overlay-icon-size))}[part=overlay][data-drag-state=accept]{border-color:var(--lr-drop-zone-accept-border-color,var(--lr-color-success));background:var(--lr-drop-zone-accept-bg,color-mix(in srgb, var(--lr-color-success) 12%, transparent))}[part=overlay][data-drag-state=reject]{border-color:var(--lr-drop-zone-reject-border-color,var(--lr-color-danger));background:var(--lr-drop-zone-reject-bg,color-mix(in srgb, var(--lr-color-danger) 12%, transparent))}[part=rejection]{color:var(--lr-color-danger);font-size:var(--lr-font-size-sm);margin-block-start:var(--lr-space-xs)}[part=rejection] ul{margin:0;padding-inline-start:var(--lr-space-m)}`;export{styles};
|
|
1
|
+
import{css}from"lit";const styles=css`:host{--_lr-drop-zone-overlay-font-size:var(--lr-font-size-md-sm);--_lr-drop-zone-overlay-icon-size:var(--lr-font-size-xl);--_lr-drop-zone-overlay-padding:var(--lr-space-l);min-inline-size:0;display:block;position:relative}:host([size="2xs"]),:host([size=xs]){--_lr-drop-zone-overlay-font-size:var(--lr-font-size-xs);--_lr-drop-zone-overlay-icon-size:var(--lr-font-size-md-sm);--_lr-drop-zone-overlay-padding:var(--lr-space-s)}:host([size=s]),:host([size=small]){--_lr-drop-zone-overlay-font-size:var(--lr-font-size-sm);--_lr-drop-zone-overlay-icon-size:var(--lr-font-size-lg);--_lr-drop-zone-overlay-padding:var(--lr-space-m)}:host([size=l]),:host([size=large]){--_lr-drop-zone-overlay-font-size:var(--lr-font-size-lg);--_lr-drop-zone-overlay-icon-size:var(--lr-font-size-2xl);--_lr-drop-zone-overlay-padding:var(--lr-space-2xl)}:host([size=xl]){--_lr-drop-zone-overlay-font-size:var(--lr-font-size-xl);--_lr-drop-zone-overlay-icon-size:var(--lr-font-size-3xl);--_lr-drop-zone-overlay-padding:var(--lr-space-2xl)}[part=base]{display:contents}[part=overlay]{z-index:var(--lr-layer-content);justify-content:center;align-items:center;gap:var(--lr-drop-zone-overlay-gap,var(--lr-space-xs));box-sizing:border-box;padding:var(--lr-drop-zone-overlay-padding,var(--_lr-drop-zone-overlay-padding));border:var(--lr-border-width-medium) dashed var(--lr-drop-zone-overlay-border-color,var(--lr-color-brand));border-radius:var(--lr-drop-zone-radius,var(--lr-radius));background:var(--lr-drop-zone-overlay-bg,color-mix(in srgb, var(--lr-color-brand) 8%, transparent));color:var(--lr-color-text-quiet);font-size:var(--lr-drop-zone-overlay-font-size,var(--_lr-drop-zone-overlay-font-size));text-align:center;pointer-events:none;transition:border-color var(--lr-transition-fast), background-color var(--lr-transition-fast);flex-direction:column;display:flex;position:absolute;inset:0}[part=overlay][hidden]{display:none}:host(:state(targeted)){display:contents}:host(:state(targeted)) [part=overlay]{position:fixed;inset:auto}[part=overlay-icon]{font-size:var(--lr-drop-zone-overlay-icon-size,var(--_lr-drop-zone-overlay-icon-size))}[part=overlay][data-drag-state=accept]{border-color:var(--lr-drop-zone-accept-border-color,var(--lr-color-success));background:var(--lr-drop-zone-accept-bg,color-mix(in srgb, var(--lr-color-success) 12%, transparent))}[part=overlay][data-drag-state=reject]{border-color:var(--lr-drop-zone-reject-border-color,var(--lr-color-danger));background:var(--lr-drop-zone-reject-bg,color-mix(in srgb, var(--lr-color-danger) 12%, transparent))}[part=rejection]{color:var(--lr-color-danger);font-size:var(--lr-font-size-sm);margin-block-start:var(--lr-space-xs)}[part=rejection] ul{margin:0;padding-inline-start:var(--lr-space-m)}`;export{styles};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{fileIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{formatFileSize,FILE_SIZE_UNIT_KEYS,localizedNumberLabel}from"../attachment-chip/file-size.js";import{finiteRange}from"../../../internal/numbers.js";import{literalSetConverter}from"../../../internal/converters.js";import{defaultFileTypeMetadataRegistry}from"./file-type-metadata.js";import{usesFileNameFallback}from"./mime-type.js";import{styles}from"./file-icon.styles.js";import{LYRA_DEFAULT_fileTypeArchive,LYRA_DEFAULT_fileTypeAudio,LYRA_DEFAULT_fileTypeCode,LYRA_DEFAULT_fileTypeFile,LYRA_DEFAULT_fileTypeImage,LYRA_DEFAULT_fileTypePdf,LYRA_DEFAULT_fileTypePresentation,LYRA_DEFAULT_fileTypeSpreadsheet,LYRA_DEFAULT_fileTypeText,LYRA_DEFAULT_fileTypeVideo,LYRA_DEFAULT_fileTypeWithSize,LYRA_DEFAULT_fileTypeWord}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_fileSizeUnitB,LYRA_DEFAULT_fileSizeUnitGb,LYRA_DEFAULT_fileSizeUnitKb,LYRA_DEFAULT_fileSizeUnitMb,LYRA_DEFAULT_fileSizeUnitTb,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";const ICON_LABELS={file:"fileTypeFile",pdf:"fileTypePdf",word:"fileTypeWord",spreadsheet:"fileTypeSpreadsheet",presentation:"fileTypePresentation",text:"fileTypeText",code:"fileTypeCode",archive:"fileTypeArchive",image:"fileTypeImage",audio:"fileTypeAudio",video:"fileTypeVideo"},FILE_ICON_MODE=literalSetConverter(["icon","label"],"icon");function qualifyingToken(value){if(typeof value!="string")return"";const token=value.trim().replace(/^\./,"").toLowerCase();return/^(?=[a-z0-9+]*[a-z])[a-z0-9+]{1,4}$/.test(token)?token.toUpperCase():""}function fileNameExtension(value){if(typeof value!="string")return"";const segment=value.trim().split(/[\\/]/).pop()??"",dot=segment.lastIndexOf(".");return dot>0?qualifyingToken(segment.slice(dot+1)):""}function badgeToken(metadata,mimeType,name){const abbreviation=typeof metadata.abbreviation=="string"?metadata.abbreviation.trim():"";if(abbreviation)return abbreviation;const nameExtension=usesFileNameFallback(mimeType)?fileNameExtension(name):"",extensions=Array.isArray(metadata.extensions)?metadata.extensions:[];if(nameExtension&&extensions.some(extension=>qualifyingToken(extension)===nameExtension))return nameExtension;const firstExtension=extensions.map(qualifyingToken).find(Boolean)??"";return firstExtension||nameExtension}function estimatedTokenEm(token){let em=0;for(const char of token)em+=/[MW]/.test(char)?.97:/[DGHNOQU]/.test(char)?.82:/[AV]/.test(char)?.78:/[IJ]/.test(char)?.4:/[A-Z0-9+]/.test(char)?.7:1;return em}class LyraFileIcon extends LyraElement{constructor(){super(...arguments),this.mimeType="",this.name="",this.bytes=0,this.decorative=!1,this._mode="icon",this.registry=defaultFileTypeMetadataRegistry}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,fileSizeUnitB:LYRA_DEFAULT_fileSizeUnitB,fileSizeUnitGb:LYRA_DEFAULT_fileSizeUnitGb,fileSizeUnitKb:LYRA_DEFAULT_fileSizeUnitKb,fileSizeUnitMb:LYRA_DEFAULT_fileSizeUnitMb,fileSizeUnitTb:LYRA_DEFAULT_fileSizeUnitTb,fileTypeArchive:LYRA_DEFAULT_fileTypeArchive,fileTypeAudio:LYRA_DEFAULT_fileTypeAudio,fileTypeCode:LYRA_DEFAULT_fileTypeCode,fileTypeFile:LYRA_DEFAULT_fileTypeFile,fileTypeImage:LYRA_DEFAULT_fileTypeImage,fileTypePdf:LYRA_DEFAULT_fileTypePdf,fileTypePresentation:LYRA_DEFAULT_fileTypePresentation,fileTypeSpreadsheet:LYRA_DEFAULT_fileTypeSpreadsheet,fileTypeText:LYRA_DEFAULT_fileTypeText,fileTypeVideo:LYRA_DEFAULT_fileTypeVideo,fileTypeWithSize:LYRA_DEFAULT_fileTypeWithSize,fileTypeWord:LYRA_DEFAULT_fileTypeWord,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get mode(){return this._mode}set mode(next){const normalized=FILE_ICON_MODE.normalizeReflected(this,"mode",next),old=this._mode;old!==normalized&&(this._mode=normalized,this.requestUpdate("mode",old))}resolveMetadata(){try{
|
|
1
|
+
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{fileIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{formatFileSize,FILE_SIZE_UNIT_KEYS,localizedNumberLabel}from"../attachment-chip/file-size.js";import{finiteRange}from"../../../internal/numbers.js";import{literalSetConverter}from"../../../internal/converters.js";import{defaultFileTypeMetadataRegistry}from"./file-type-metadata.js";import{usesFileNameFallback}from"./mime-type.js";import{styles}from"./file-icon.styles.js";import{LYRA_DEFAULT_fileTypeArchive,LYRA_DEFAULT_fileTypeAudio,LYRA_DEFAULT_fileTypeCode,LYRA_DEFAULT_fileTypeFile,LYRA_DEFAULT_fileTypeImage,LYRA_DEFAULT_fileTypePdf,LYRA_DEFAULT_fileTypePresentation,LYRA_DEFAULT_fileTypeSpreadsheet,LYRA_DEFAULT_fileTypeText,LYRA_DEFAULT_fileTypeVideo,LYRA_DEFAULT_fileTypeWithSize,LYRA_DEFAULT_fileTypeWord}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_fileSizeUnitB,LYRA_DEFAULT_fileSizeUnitGb,LYRA_DEFAULT_fileSizeUnitKb,LYRA_DEFAULT_fileSizeUnitMb,LYRA_DEFAULT_fileSizeUnitTb,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";const ICON_LABELS={file:"fileTypeFile",pdf:"fileTypePdf",word:"fileTypeWord",spreadsheet:"fileTypeSpreadsheet",presentation:"fileTypePresentation",text:"fileTypeText",code:"fileTypeCode",archive:"fileTypeArchive",image:"fileTypeImage",audio:"fileTypeAudio",video:"fileTypeVideo"},FILE_ICON_MODE=literalSetConverter(["icon","label"],"icon");function qualifyingToken(value){if(typeof value!="string")return"";const token=value.trim().replace(/^\./,"").toLowerCase();return/^(?=[a-z0-9+]*[a-z])[a-z0-9+]{1,4}$/.test(token)?token.toUpperCase():""}function fileNameExtension(value){if(typeof value!="string")return"";const segment=value.trim().split(/[\\/]/).pop()??"",dot=segment.lastIndexOf(".");return dot>0?qualifyingToken(segment.slice(dot+1)):""}function badgeToken(metadata,mimeType,name){const abbreviation=typeof metadata.abbreviation=="string"?metadata.abbreviation.trim():"";if(abbreviation)return abbreviation;const nameExtension=usesFileNameFallback(mimeType)?fileNameExtension(name):"",extensions=Array.isArray(metadata.extensions)?metadata.extensions:[];if(nameExtension&&extensions.some(extension=>qualifyingToken(extension)===nameExtension))return nameExtension;const firstExtension=extensions.map(qualifyingToken).find(Boolean)??"";return firstExtension||nameExtension}function estimatedTokenEm(token){let em=0;for(const char of token)em+=/[MW]/.test(char)?.97:/[DGHNOQU]/.test(char)?.82:/[AV]/.test(char)?.78:/[IJ]/.test(char)?.4:/[A-Z0-9+]/.test(char)?.7:1;return em}class LyraFileIcon extends LyraElement{constructor(){super(...arguments),this.mimeType="",this.name="",this.bytes=0,this.decorative=!1,this._mode="icon",this.registry=defaultFileTypeMetadataRegistry}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,fileSizeUnitB:LYRA_DEFAULT_fileSizeUnitB,fileSizeUnitGb:LYRA_DEFAULT_fileSizeUnitGb,fileSizeUnitKb:LYRA_DEFAULT_fileSizeUnitKb,fileSizeUnitMb:LYRA_DEFAULT_fileSizeUnitMb,fileSizeUnitTb:LYRA_DEFAULT_fileSizeUnitTb,fileTypeArchive:LYRA_DEFAULT_fileTypeArchive,fileTypeAudio:LYRA_DEFAULT_fileTypeAudio,fileTypeCode:LYRA_DEFAULT_fileTypeCode,fileTypeFile:LYRA_DEFAULT_fileTypeFile,fileTypeImage:LYRA_DEFAULT_fileTypeImage,fileTypePdf:LYRA_DEFAULT_fileTypePdf,fileTypePresentation:LYRA_DEFAULT_fileTypePresentation,fileTypeSpreadsheet:LYRA_DEFAULT_fileTypeSpreadsheet,fileTypeText:LYRA_DEFAULT_fileTypeText,fileTypeVideo:LYRA_DEFAULT_fileTypeVideo,fileTypeWithSize:LYRA_DEFAULT_fileTypeWithSize,fileTypeWord:LYRA_DEFAULT_fileTypeWord,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get mode(){return this._mode}set mode(next){const normalized=FILE_ICON_MODE.normalizeReflected(this,"mode",next),old=this._mode;old!==normalized&&(this._mode=normalized,this.requestUpdate("mode",old))}resolveMetadata(){try{const registry=this.registry,resolve=registry?.resolve,metadata=typeof resolve=="function"?resolve.call(registry,this.mimeType,this.name):void 0;if(metadata&&typeof metadata=="object"){const{provenance,label,icon,description}=metadata;if((provenance==="builtin"||provenance==="consumer")&&typeof label=="string"&&label.trim().length>0&&label.length<=512&&typeof icon=="string"&&Object.hasOwn(ICON_LABELS,icon)&&(description===void 0||typeof description=="string"&&description.length<=2048)){let token="";try{token=badgeToken(metadata,this.mimeType,this.name)}catch{}return{label:provenance==="consumer"?label:this.localize(ICON_LABELS[icon]),...provenance==="consumer"&&description?{description}:{},token}}}}catch{}return{label:this.localize("fileTypeFile"),token:""}}render(){const metadata=this.resolveMetadata(),metadataLabel=metadata.label,renderedLabel=this.label??metadataLabel,bytes=finiteRange(this.bytes,0,0),sizeText=bytes>0?formatFileSize(bytes,unit=>this.localize(FILE_SIZE_UNIT_KEYS[unit]),localizedNumberLabel(this.effectiveLocale)):"",accessibleNameBase=renderedLabel||metadataLabel,fallbackLabel=sizeText?this.localize("fileTypeWithSize",void 0,{label:accessibleNameBase,size:sizeText}):accessibleNameBase,accessibleLabel=hostAriaLabel(this)??fallbackLabel,token=metadata.token,tokenTier=token===""?"none":estimatedTokenEm(token)<=2.4?"short":"long",descriptionId=this.mode==="label"&&metadata.description?"metadata-description":void 0;return html`
|
|
2
2
|
<span
|
|
3
3
|
part="base"
|
|
4
4
|
role=${this.decorative?"presentation":"img"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devWarn}from"../../../internal/dev-mode-attribute-warning.js";function resolverFromModule(module){try{if(typeof module=="object"&&module!==null||typeof module=="function"){const named=module.flagUrl;if(typeof named=="function")return named;const fallback=module.default??module;if(typeof fallback=="function")return fallback;if(typeof fallback=="object"&&fallback!==null){const defaultNamed=fallback.flagUrl;if(typeof defaultNamed=="function")return defaultNamed}}}catch{}return null}function warnFlagPeerMissing(){console.warn("<lr-flag> needs the optional peer dependency '@aceshooting/lyra-flags' to render flag images — install it with `pnpm add @aceshooting/lyra-flags`.")}function warnFlagPeerIncapable(capability){console.warn(`<lr-flag> loaded '@aceshooting/lyra-flags' but it does not expose \`${capability}\`. The package is installed, so this is a version mismatch rather than a missing dependency: upgrade it to a release that provides that capability, and check the peer range in <lr-flag>'s own package metadata for the floor it expects.`)}async function loadFlagUrl(importFlags){let peerModule;try{peerModule=await importFlags()}catch{return warnFlagPeerMissing(),null}try{const resolver=resolverFromModule(peerModule);if(resolver)return resolver}catch{}return warnFlagPeerIncapable("flagUrl"),null}function resolverFactoryFromModule(module){try{if(typeof module=="object"&&module!==null||typeof module=="function"){const named=module.createFlagUrlResolver;if(typeof named=="function")return named;const fallback=module.default??module;if(typeof fallback=="object"&&fallback!==null){const defaultNamed=fallback.createFlagUrlResolver;if(typeof defaultNamed=="function")return defaultNamed}}}catch{}return null}async function loadBulkFlagUrl(importFlags){let peerModule;try{peerModule=await importFlags()}catch{return warnFlagPeerMissing(),null}const factory=resolverFactoryFromModule(peerModule);if(
|
|
1
|
+
import{devWarn}from"../../../internal/dev-mode-attribute-warning.js";function resolverFromModule(module){try{if(typeof module=="object"&&module!==null||typeof module=="function"){const named=module.flagUrl;if(typeof named=="function")return named;const fallback=module.default??module;if(typeof fallback=="function")return fallback;if(typeof fallback=="object"&&fallback!==null){const defaultNamed=fallback.flagUrl;if(typeof defaultNamed=="function")return defaultNamed}}}catch{}return null}function warnFlagPeerMissing(){console.warn("<lr-flag> needs the optional peer dependency '@aceshooting/lyra-flags' to render flag images — install it with `pnpm add @aceshooting/lyra-flags`.")}function warnFlagPeerIncapable(capability){console.warn(`<lr-flag> loaded '@aceshooting/lyra-flags' but it does not expose \`${capability}\`. The package is installed, so this is a version mismatch rather than a missing dependency: upgrade it to a release that provides that capability, and check the peer range in <lr-flag>'s own package metadata for the floor it expects.`)}async function loadFlagUrl(importFlags){let peerModule;try{peerModule=await importFlags()}catch{return warnFlagPeerMissing(),null}try{const resolver=resolverFromModule(peerModule);if(resolver)return resolver}catch{}return warnFlagPeerIncapable("flagUrl"),null}function resolverFactoryFromModule(module){try{if(typeof module=="object"&&module!==null||typeof module=="function"){const named=module.createFlagUrlResolver;if(typeof named=="function")return named;const fallback=module.default??module;if(typeof fallback=="object"&&fallback!==null){const defaultNamed=fallback.createFlagUrlResolver;if(typeof defaultNamed=="function")return defaultNamed}}}catch{}return null}async function loadBulkFlagUrl(importFlags){let peerModule;try{peerModule=await importFlags()}catch{return warnFlagPeerMissing(),null}const factory=resolverFactoryFromModule(peerModule);try{const resolver=await factory?.();if(typeof resolver=="function")return resolver}catch{}return warnFlagPeerIncapable("createFlagUrlResolver"),null}let flagUrlResolver,flagResolverGeneration=0;const flagResolverSubscribers=new Set;let warnedMissingFlagResolver=!1;function warnMissingFlagResolver(code){warnedMissingFlagResolver||(warnedMissingFlagResolver=!0,devWarn(`<lr-flag> could not resolve the code "${code}" because no flag resolver is registered. Import the optional peer entry once at startup -- import '@aceshooting/lyra-ui/components/media/flag/flag-peer.js' -- and install '@aceshooting/lyra-flags', or pass an already-resolved URL through 'src' instead.`))}function setFlagUrlResolver(value){flagUrlResolver=value===null?Promise.resolve(null):Promise.resolve(value),warnedMissingFlagResolver=!1,flagResolverGeneration++;for(const subscriber of[...flagResolverSubscribers])subscriber(flagResolverGeneration)}function loadFlagUrlResolver(){return flagUrlResolver||(flagUrlResolver=Promise.resolve(null)),flagUrlResolver}function getFlagResolverGeneration(){return flagResolverGeneration}function subscribeFlagResolver(subscriber){return flagResolverSubscribers.add(subscriber),()=>flagResolverSubscribers.delete(subscriber)}export{getFlagResolverGeneration,loadBulkFlagUrl,loadFlagUrl,loadFlagUrlResolver,setFlagUrlResolver,subscribeFlagResolver,warnMissingFlagResolver};
|
|
@@ -114,9 +114,9 @@ export declare class LyraImageViewer extends LyraImageViewer_base{static styles:
|
|
|
114
114
|
/** Flat media by default. Equirectangular rendering also requires engine="webgl".*/
|
|
115
115
|
get projection():LyraMediaProjection;set projection(value:LyraMediaProjection);private _engine;
|
|
116
116
|
/** Preferred panorama renderer; the builtin flat view never downloads a companion.*/
|
|
117
|
-
get engine():Engine3dPreference;set engine(value:Engine3dPreference);private _panoramaCamera;
|
|
117
|
+
get engine():Engine3dPreference;set engine(value:Engine3dPreference);private _panoramaCamera;private panoramaCameraRevision;
|
|
118
118
|
/** Camera yaw/pitch in radians and vertical fieldOfView in degrees (20–100). Authored writes are silent.*/
|
|
119
|
-
get panoramaCamera():LyraPanoramaCamera;set panoramaCamera(value:LyraPanoramaCamera);private _hotspots;private hotspotSource;
|
|
119
|
+
get panoramaCamera():LyraPanoramaCamera;set panoramaCamera(value:LyraPanoramaCamera);private _hotspots;private hotspotSource;private hotspotRevision;
|
|
120
120
|
/** Bounded clone-owned hotspot snapshot. First valid unique ID wins; reassign after changes.
|
|
121
121
|
* Angles are radians, pitch is within ±π/2, and invalid rows are omitted. */
|
|
122
122
|
get hotspots():readonly LyraPanoramaHotspot[];set hotspots(value:readonly LyraPanoramaHotspot[]);private get panoramaEnabled();requestUpdate(name?:PropertyKey,oldValue?:unknown,options?:Parameters<LyraElement['requestUpdate']>[2]):void;
|