@aceshooting/lyra-ui 16.0.0 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +504 -0
- package/custom-elements.json +1 -1
- package/dist/cli/migration-contract.json +1 -1
- package/dist/components/agent-tools/browser-frame/browser-frame.class.d.ts +3 -3
- package/dist/components/agent-tools/browser-frame/browser-frame.class.js +2 -2
- package/dist/components/agent-tools/compare-panel/compare-panel.class.d.ts +2 -2
- package/dist/components/agent-tools/compare-panel/compare-panel.class.js +3 -3
- package/dist/components/agent-tools/confirm-bar/confirm-bar.class.d.ts +37 -13
- package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +2 -2
- package/dist/components/agent-tools/task-list/task-list.class.js +2 -2
- package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.d.ts +4 -0
- package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.js +2 -2
- package/dist/components/agent-tools/tool-param-form/tool-param-form.class.d.ts +3 -3
- package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +1 -1
- package/dist/components/charts/chart/chart.class.d.ts +117 -17
- package/dist/components/charts/chart/chart.class.js +3 -3
- package/dist/components/charts/chart/histogram-bin.d.ts +5 -1
- package/dist/components/charts/chart/histogram-bin.js +1 -1
- package/dist/components/charts/chart/lite-chart.class.d.ts +9 -0
- package/dist/components/conversation/code-block/code-block.styles.js +1 -1
- package/dist/components/conversation/message-actions/message-actions.styles.js +1 -1
- package/dist/components/conversation/model-select/model-select.class.d.ts +13 -4
- package/dist/components/conversation/model-select/model-select.class.js +2 -1
- package/dist/components/conversation/model-select/model-select.styles.js +1 -1
- package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +40 -2
- package/dist/components/conversation/streaming-text/streaming-text-base.class.js +2 -2
- package/dist/components/conversation/streaming-text/streaming-text-core.class.d.ts +5 -3
- package/dist/components/conversation/streaming-text/streaming-text-core.class.js +10 -0
- package/dist/components/conversation/streaming-text/streaming-text.class.d.ts +9 -3
- package/dist/components/conversation/streaming-text/streaming-text.class.js +10 -0
- package/dist/components/conversation/suggestion-chips/suggestion-chips.class.d.ts +30 -2
- package/dist/components/conversation/suggestion-chips/suggestion-chips.class.js +4 -3
- package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +1 -1
- package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
- package/dist/components/conversation/usage-badge/usage-badge-overlay-runtime.js +1 -1
- package/dist/components/conversation/usage-badge/usage-badge.class.d.ts +4 -0
- package/dist/components/conversation/voice-picker/voice-picker.class.d.ts +16 -4
- package/dist/components/conversation/voice-picker/voice-picker.class.js +2 -1
- package/dist/components/conversation/voice-picker/voice-picker.styles.js +1 -1
- package/dist/components/data/context-meter/context-meter.class.d.ts +23 -4
- package/dist/components/data/context-meter/context-meter.class.js +10 -7
- package/dist/components/data/context-meter/context-meter.styles.js +1 -1
- package/dist/components/data/data-grid/data-grid.class.d.ts +5 -2
- package/dist/components/data/data-grid/data-grid.class.js +1 -1
- package/dist/components/data/flow-canvas/flow-canvas.class.d.ts +32 -5
- package/dist/components/data/flow-canvas/flow-canvas.class.js +3 -1
- package/dist/components/data/flow-canvas/flow-canvas.styles.js +1 -1
- package/dist/components/data/flow-canvas/flow-model.js +1 -1
- package/dist/components/data/flow-canvas/flow-types.d.ts +10 -1
- package/dist/components/data/gauge/gauge.class.d.ts +15 -2
- package/dist/components/data/gauge/gauge.class.js +20 -20
- package/dist/components/data/gauge/gauge.styles.js +1 -1
- package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +14 -5
- package/dist/components/data/graph-query-builder/graph-query-builder.class.js +2 -2
- package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +28 -2
- package/dist/components/data/sequence-strip/sequence-strip.class.js +3 -2
- package/dist/components/data/sequence-strip/sequence-strip.styles.js +1 -1
- package/dist/components/data/table/table.class.d.ts +155 -30
- package/dist/components/data/table/table.class.js +6 -4
- package/dist/components/data/table/table.styles.js +1 -1
- package/dist/components/data/timeline/timeline-item.class.d.ts +9 -1
- package/dist/components/data/timeline/timeline-item.class.js +2 -2
- package/dist/components/data/word-cloud/word-cloud.class.js +1 -1
- package/dist/components/data/word-cloud/word-cloud.styles.js +1 -1
- package/dist/components/forms/button/button.class.d.ts +30 -1
- package/dist/components/forms/button/button.class.js +2 -2
- package/dist/components/forms/checkbox/checkbox.class.d.ts +8 -6
- package/dist/components/forms/checkbox/checkbox.class.js +2 -2
- package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +7 -5
- package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
- package/dist/components/forms/color-picker/color-picker.class.d.ts +16 -2
- package/dist/components/forms/color-picker/color-picker.class.js +2 -2
- package/dist/components/forms/color-picker/color-picker.styles.js +1 -1
- package/dist/components/forms/combobox/combobox.class.d.ts +43 -8
- package/dist/components/forms/combobox/combobox.class.js +2 -2
- package/dist/components/forms/date-picker/date-input.class.d.ts +4 -0
- package/dist/components/forms/date-picker/date-input.class.js +1 -1
- package/dist/components/forms/icon-button/icon-button.class.d.ts +20 -3
- package/dist/components/forms/icon-button/icon-button.class.js +1 -1
- package/dist/components/forms/icon-button/icon-button.styles.js +1 -1
- package/dist/components/forms/input/input.class.d.ts +5 -2
- package/dist/components/forms/input/input.class.js +1 -1
- package/dist/components/forms/input/time-input.class.d.ts +4 -0
- package/dist/components/forms/input/time-input.class.js +1 -1
- package/dist/components/forms/locale-picker/locale-picker.class.d.ts +11 -5
- package/dist/components/forms/locale-picker/locale-picker.class.js +1 -1
- package/dist/components/forms/otp-input/otp-input.class.d.ts +7 -2
- package/dist/components/forms/otp-input/otp-input.class.js +2 -2
- package/dist/components/forms/radio/radio-button.class.d.ts +2 -1
- package/dist/components/forms/radio/radio-group.class.d.ts +9 -4
- package/dist/components/forms/radio/radio-group.class.js +1 -1
- package/dist/components/forms/radio/radio.class.d.ts +13 -7
- package/dist/components/forms/radio/radio.class.js +1 -1
- package/dist/components/forms/rubric-form/rubric-form.class.d.ts +16 -6
- package/dist/components/forms/rubric-form/rubric-form.class.js +2 -2
- package/dist/components/forms/select/select.class.d.ts +19 -8
- package/dist/components/forms/select/select.class.js +2 -2
- package/dist/components/forms/slider/slider.class.d.ts +4 -2
- package/dist/components/forms/slider/slider.class.js +1 -1
- package/dist/components/forms/switch/switch.class.d.ts +8 -6
- package/dist/components/forms/switch/switch.class.js +1 -1
- package/dist/components/forms/textarea/textarea.class.d.ts +5 -3
- package/dist/components/forms/textarea/textarea.class.js +1 -1
- package/dist/components/forms/time-range/time-range.class.d.ts +12 -7
- package/dist/components/forms/time-range/time-range.class.js +1 -1
- package/dist/components/forms/time-range/time-range.styles.js +1 -1
- package/dist/components/forms/token-input/token-input.class.d.ts +6 -4
- package/dist/components/forms/token-input/token-input.class.js +1 -1
- package/dist/components/layout/app-rail/app-rail-item.class.d.ts +109 -4
- package/dist/components/layout/app-rail/app-rail-item.class.js +34 -29
- package/dist/components/layout/app-rail/app-rail-item.styles.js +1 -1
- package/dist/components/layout/app-rail/app-rail.class.d.ts +25 -3
- package/dist/components/layout/app-rail/app-rail.styles.js +1 -1
- package/dist/components/layout/app-rail-group/app-rail-group.class.d.ts +2 -2
- package/dist/components/layout/app-rail-group/app-rail-group.class.js +2 -2
- package/dist/components/layout/carousel/carousel.class.d.ts +1 -1
- package/dist/components/layout/carousel/carousel.class.js +1 -1
- package/dist/components/layout/details/accordion.class.d.ts +2 -2
- package/dist/components/layout/details/accordion.class.js +2 -2
- package/dist/components/layout/filter-bar/filter-bar-register.d.ts +1 -0
- package/dist/components/layout/filter-bar/filter-bar-register.js +1 -0
- package/dist/components/layout/filter-bar/filter-bar.class.d.ts +85 -10
- package/dist/components/layout/filter-bar/filter-bar.class.js +7 -4
- package/dist/components/layout/menu/menu-item.class.d.ts +3 -3
- package/dist/components/layout/menu/menu-item.class.js +3 -3
- package/dist/components/layout/menu/menu.class.d.ts +5 -1
- package/dist/components/layout/menu/menu.class.js +2 -2
- package/dist/components/layout/reorder-list/reorder-item.styles.js +1 -1
- package/dist/components/layout/virtual-list/virtual-list.class.js +1 -1
- package/dist/components/media/attachment-trigger/attachment-trigger.styles.js +1 -1
- package/dist/components/media/avatar-group/avatar-group.class.d.ts +12 -1
- package/dist/components/media/avatar-group/avatar-group.class.js +2 -2
- package/dist/components/media/drop-zone/drop-zone.class.d.ts +32 -11
- package/dist/components/media/drop-zone/drop-zone.class.js +2 -2
- package/dist/components/media/file-input/file-input.class.d.ts +40 -19
- package/dist/components/media/file-input/file-input.class.js +2 -2
- package/dist/components/overlays/callout/callout.styles.js +1 -1
- package/dist/components/overlays/dialog/dialog.styles.js +1 -1
- package/dist/components/overlays/overlay/dropdown.class.d.ts +13 -3
- package/dist/components/overlays/overlay/dropdown.class.js +2 -2
- package/dist/components/overlays/overlay/popover.class.d.ts +12 -3
- package/dist/components/overlays/overlay/popover.class.js +2 -2
- package/dist/components/overlays/rating/rating.class.d.ts +9 -7
- package/dist/components/overlays/rating/rating.class.js +1 -1
- package/dist/components/retrieval/citation-badge/citation-badge.class.d.ts +5 -1
- package/dist/components/retrieval/citation-badge/citation-badge.class.js +1 -1
- package/dist/components/retrieval/embedding-explorer/embedding-explorer.styles.js +1 -1
- package/dist/components/retrieval/entity-chip/entity-chip.class.d.ts +5 -1
- package/dist/components/retrieval/entity-chip/entity-chip.class.js +1 -1
- package/dist/components/retrieval/graph-legend/graph-legend.styles.js +1 -1
- package/dist/components/retrieval/retrieval-value-format.js +1 -1
- package/dist/components/retrieval/source-list/source-list.styles.js +1 -1
- package/dist/components/utility/copy-button/copy-button.class.d.ts +23 -11
- package/dist/components/utility/copy-button/copy-button.class.js +2 -2
- package/dist/components/utility/copy-button/copy-button.styles.js +1 -1
- package/dist/components/utility/diff-view/diff-view.styles.js +1 -1
- package/dist/components/utility/export-button/export-button.class.d.ts +4 -0
- package/dist/components/utility/export-button/export-button.class.js +1 -1
- 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.d.ts +38 -3
- package/dist/components/utility/mention-popover/mention-popover.class.js +2 -1
- package/dist/components/utility/mention-popover/mention-popover.styles.js +1 -1
- package/dist/components/utility/poll-status/poll-status.styles.js +1 -1
- package/dist/components/utility/tour/tour.class.d.ts +4 -0
- package/dist/components/utility/tour/tour.class.js +1 -1
- package/dist/components/utility/tour/tour.styles.js +1 -1
- package/dist/components/viewers/document-preview/document-preview.class.js +2 -2
- package/dist/components/viewers/docx-viewer/docx-viewer.class.js +2 -2
- package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +2 -2
- package/dist/components/viewers/highlight-layer/highlight-layer.class.js +2 -2
- package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +2 -2
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +2 -2
- package/dist/components/viewers/pptx-viewer/pptx-viewer.class.js +2 -2
- package/dist/components/viewers/xml-viewer/xml-viewer.class.js +2 -2
- package/dist/custom-elements-jsx.d.ts +2 -2
- package/dist/events.d.ts +13 -12
- package/dist/internal/aggregate-file-limits.d.ts +33 -0
- package/dist/internal/aggregate-file-limits.js +1 -0
- package/dist/internal/catalog-picker.d.ts +15 -2
- package/dist/internal/catalog-picker.js +1 -1
- package/dist/internal/debounce-controller.d.ts +14 -0
- package/dist/internal/debounce-controller.js +1 -1
- package/dist/internal/default-strings.generated.d.ts +1 -1
- package/dist/internal/default-strings.generated.js +2 -2
- package/dist/internal/focus-navigation.d.ts +45 -0
- package/dist/internal/focus-navigation.js +1 -1
- package/dist/internal/form-associated.js +1 -1
- package/dist/internal/initial-slot-collection.d.ts +30 -0
- package/dist/internal/initial-slot-collection.js +1 -0
- package/dist/internal/intl-cache.js +1 -1
- package/dist/internal/invalid-event-alias.d.ts +46 -0
- package/dist/internal/invalid-event-alias.js +1 -1
- package/dist/internal/localization-runtime.d.ts +24 -0
- package/dist/internal/localization-runtime.js +1 -1
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +1 -1
- package/dist/internal/package-metadata.d.ts +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/positioning-strategy.d.ts +3 -1
- package/dist/internal/state-part.d.ts +49 -0
- package/dist/internal/state-part.js +1 -0
- package/dist/internal/variants.styles.js +1 -1
- package/dist/lyra.d.ts +1 -1
- package/dist/svelte.d.ts +2 -2
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/lyra-tag-event-map.d.ts +2 -2
- package/dist/testing/lyra-tag-event-map.js +1 -1
- package/dist/testing/wait-for-mount.d.ts +46 -0
- package/dist/testing/wait-for-mount.js +1 -0
- package/dist/theme/theme-bootstrap.js +1 -1
- package/dist/theme/theme.d.ts +11 -2
- package/dist/theme/theme.js +1 -1
- package/dist/translations/ar/layout.js +1 -1
- package/dist/translations/de/layout.js +1 -1
- package/dist/translations/es/layout.js +1 -1
- package/dist/translations/fa/layout.js +1 -1
- package/dist/translations/fr/layout.js +1 -1
- package/dist/translations/he/layout.js +1 -1
- package/dist/translations/it/layout.js +1 -1
- package/dist/translations/ja/layout.js +1 -1
- package/dist/translations/pt-BR/layout.js +1 -1
- package/dist/translations/ru/layout.js +1 -1
- package/dist/translations/zh-CN/layout.js +1 -1
- package/dist/utilities/format.d.ts +17 -0
- package/dist/utilities/format.js +1 -1
- package/dist/vue.d.ts +2 -2
- package/llms/components/lr-app-rail-group.md +87 -10
- package/llms/components/lr-app-rail-item.md +88 -11
- package/llms/components/lr-app-rail.md +88 -11
- package/llms/components/lr-attachment-trigger.md +21 -0
- package/llms/components/lr-bar-chart.md +3 -2
- package/llms/components/lr-bubble-chart.md +3 -2
- package/llms/components/lr-callout.md +10 -0
- package/llms/components/lr-chart.md +43 -12
- package/llms/components/lr-citation-badge.md +7 -1
- package/llms/components/lr-code-block.md +21 -0
- package/llms/components/lr-color-picker.md +12 -7
- package/llms/components/lr-combobox.md +13 -1
- package/llms/components/lr-confirm-bar.md +36 -7
- package/llms/components/lr-context-meter.md +17 -4
- package/llms/components/lr-date-input.md +7 -1
- package/llms/components/lr-date-picker.md +6 -0
- package/llms/components/lr-dialog.md +21 -0
- package/llms/components/lr-doughnut-chart.md +3 -2
- package/llms/components/lr-drawer.md +10 -0
- package/llms/components/lr-drop-zone.md +16 -7
- package/llms/components/lr-dropdown-item.md +7 -0
- package/llms/components/lr-entity-chip.md +7 -1
- package/llms/components/lr-export-button.md +7 -1
- package/llms/components/lr-file-input.md +21 -10
- package/llms/components/lr-filter-bar.md +91 -15
- package/llms/components/lr-flow-canvas.md +16 -9
- package/llms/components/lr-gauge.md +22 -2
- package/llms/components/lr-histogram.md +7 -2
- package/llms/components/lr-icon-button.md +15 -7
- package/llms/components/lr-input.md +3 -1
- package/llms/components/lr-line-chart.md +3 -2
- package/llms/components/lr-lite-chart.md +13 -0
- package/llms/components/lr-locale-picker.md +7 -1
- package/llms/components/lr-mention-popover.md +16 -3
- package/llms/components/lr-menu-item.md +7 -0
- package/llms/components/lr-menu.md +8 -1
- package/llms/components/lr-message-actions.md +10 -0
- package/llms/components/lr-model-select.md +8 -3
- package/llms/components/lr-native-time-input.md +8 -1
- package/llms/components/lr-number-input.md +8 -1
- package/llms/components/lr-option.md +12 -0
- package/llms/components/lr-otp-input.md +6 -0
- package/llms/components/lr-pie-chart.md +3 -2
- package/llms/components/lr-polar-area-chart.md +3 -2
- package/llms/components/lr-prompt-input.md +2 -2
- package/llms/components/lr-radar-chart.md +3 -2
- package/llms/components/lr-reorder-item.md +12 -0
- package/llms/components/lr-reorder-list.md +12 -0
- package/llms/components/lr-scatter-chart.md +3 -2
- package/llms/components/lr-sequence-strip.md +10 -4
- package/llms/components/lr-streaming-text-core.md +21 -8
- package/llms/components/lr-streaming-text.md +34 -4
- package/llms/components/lr-suggestion-chips.md +8 -4
- package/llms/components/lr-table.md +47 -10
- package/llms/components/lr-textarea.md +1 -1
- package/llms/components/lr-time-input.md +7 -1
- package/llms/components/lr-tool-call-chip.md +7 -1
- package/llms/components/lr-tour.md +7 -1
- package/llms/components/lr-usage-badge.md +7 -1
- package/llms/components/lr-voice-picker.md +7 -3
- package/llms/shared.md +169 -16
- package/llms/tokens.md +17 -1
- package/llms-full.txt +941 -147
- package/package.json +16 -2
- package/registrations.json +1 -1
- package/vscode-css-data.json +1 -1
- package/vscode-html-data.json +1 -1
- package/web-types.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";installFormControlLabelSupport();import{closeIcon}from"../../../internal/icons.js";import{AnchoredValidityController,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{finiteInteger}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{nextId}from"../../../internal/a11y.js";import{activeElementIn,deepActiveElementIn}from"../../../internal/active-element.js";import{styles}from"./graph-query-builder.styles.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{getFormOwner,installCustomErrorProperty,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{installInvalidEventAlias}from"../../../internal/invalid-event-alias.js";import{acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_graphQueryBuilderLabel,LYRA_DEFAULT_graphQueryDeleteWithContext,LYRA_DEFAULT_graphQueryDirectionLabel,LYRA_DEFAULT_graphQueryEndLabel,LYRA_DEFAULT_graphQueryHopRangeInvalid,LYRA_DEFAULT_graphQueryLoadWithContext,LYRA_DEFAULT_graphQueryMaxHopsLabel,LYRA_DEFAULT_graphQueryMinHopsLabel,LYRA_DEFAULT_graphQueryNodeTypeLabel,LYRA_DEFAULT_graphQueryRelationshipTypeLabel,LYRA_DEFAULT_graphQueryRun,LYRA_DEFAULT_graphQuerySaveButton,LYRA_DEFAULT_graphQuerySaveNameLabel,LYRA_DEFAULT_graphQuerySavedQueriesLabel,LYRA_DEFAULT_graphQueryStartLabel,LYRA_DEFAULT_neighborDirectionBoth,LYRA_DEFAULT_neighborDirectionIn,LYRA_DEFAULT_neighborDirectionOut,LYRA_DEFAULT_noData,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";const MAX_TYPES=500,MAX_SAVED_QUERIES=200,MAX_TEXT=256,EMPTY_STRINGS=Object.freeze([]),EMPTY_VALUE=Object.freeze({startId:"",endId:"",relationshipTypes:EMPTY_STRINGS,nodeTypes:EMPTY_STRINGS,direction:"both",minHops:1,maxHops:1}),EMPTY_OPTIONS=Object.freeze([]),EMPTY_SAVED=Object.freeze([]);function ownValue(record,key){try{const descriptor=Object.getOwnPropertyDescriptor(record,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}catch{return}}function boundedString(value){return typeof value=="string"?value.slice(0,MAX_TEXT):""}function stringArray(value){return Array.isArray(value)?Object.freeze([...new Set(value.slice(0,MAX_TYPES).filter(entry=>typeof entry=="string").map(entry=>boundedString(entry)).filter(Boolean))]):EMPTY_STRINGS}function normalizeGraphQuery(value){const record=value!==null&&typeof value=="object"&&!Array.isArray(value)?value:EMPTY_VALUE,direction=ownValue(record,"direction");return Object.freeze({startId:boundedString(ownValue(record,"startId")),endId:boundedString(ownValue(record,"endId")),relationshipTypes:stringArray(ownValue(record,"relationshipTypes")),nodeTypes:stringArray(ownValue(record,"nodeTypes")),direction:direction==="out"||direction==="in"||direction==="both"?direction:"both",minHops:finiteInteger(typeof ownValue(record,"minHops")=="number"?ownValue(record,"minHops"):EMPTY_VALUE.minHops,EMPTY_VALUE.minHops,1,20),maxHops:finiteInteger(typeof ownValue(record,"maxHops")=="number"?ownValue(record,"maxHops"):EMPTY_VALUE.maxHops,EMPTY_VALUE.maxHops,1,20)})}function normalizeTypeOptions(value){if(!Array.isArray(value))return EMPTY_OPTIONS;const values=new Set,result=[];for(const candidate of value.slice(0,MAX_TYPES)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const optionValue=boundedString(ownValue(candidate,"value"));if(optionValue.trim().length===0||values.has(optionValue))continue;values.add(optionValue);const label=boundedString(ownValue(candidate,"label"));result.push(Object.freeze({value:optionValue,...label?{label}:{}}))}return Object.freeze(result)}function normalizeSavedQueries(value){if(!Array.isArray(value))return EMPTY_SAVED;const ids=new Set,result=[];for(const candidate of value.slice(0,MAX_SAVED_QUERIES)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const id=boundedString(ownValue(candidate,"id"));id.trim().length===0||ids.has(id)||(ids.add(id),result.push(Object.freeze({id,name:boundedString(ownValue(candidate,"name")),query:normalizeGraphQuery(ownValue(candidate,"query"))})))}return Object.freeze(result)}class LyraGraphQueryBuilder extends LyraElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,graphQueryBuilderLabel:LYRA_DEFAULT_graphQueryBuilderLabel,graphQueryDeleteWithContext:LYRA_DEFAULT_graphQueryDeleteWithContext,graphQueryDirectionLabel:LYRA_DEFAULT_graphQueryDirectionLabel,graphQueryEndLabel:LYRA_DEFAULT_graphQueryEndLabel,graphQueryHopRangeInvalid:LYRA_DEFAULT_graphQueryHopRangeInvalid,graphQueryLoadWithContext:LYRA_DEFAULT_graphQueryLoadWithContext,graphQueryMaxHopsLabel:LYRA_DEFAULT_graphQueryMaxHopsLabel,graphQueryMinHopsLabel:LYRA_DEFAULT_graphQueryMinHopsLabel,graphQueryNodeTypeLabel:LYRA_DEFAULT_graphQueryNodeTypeLabel,graphQueryRelationshipTypeLabel:LYRA_DEFAULT_graphQueryRelationshipTypeLabel,graphQueryRun:LYRA_DEFAULT_graphQueryRun,graphQuerySaveButton:LYRA_DEFAULT_graphQuerySaveButton,graphQuerySaveNameLabel:LYRA_DEFAULT_graphQuerySaveNameLabel,graphQuerySavedQueriesLabel:LYRA_DEFAULT_graphQuerySavedQueriesLabel,graphQueryStartLabel:LYRA_DEFAULT_graphQueryStartLabel,neighborDirectionBoth:LYRA_DEFAULT_neighborDirectionBoth,neighborDirectionIn:LYRA_DEFAULT_neighborDirectionIn,neighborDirectionOut:LYRA_DEFAULT_neighborDirectionOut,noData:LYRA_DEFAULT_noData,select:LYRA_DEFAULT_select}}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-before-query-run","lr-query-run","lr-before-query-save","lr-query-save","lr-before-query-load","lr-query-load"])}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},value:{attribute:!1,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}get relationshipTypeOptions(){return this._relationshipTypeOptions}set relationshipTypeOptions(value){const previous=this._relationshipTypeOptions;this._relationshipTypeOptions=normalizeTypeOptions(value),this.requestUpdate("relationshipTypeOptions",previous)}get nodeTypeOptions(){return this._nodeTypeOptions}set nodeTypeOptions(value){const previous=this._nodeTypeOptions;this._nodeTypeOptions=normalizeTypeOptions(value),this.requestUpdate("nodeTypeOptions",previous)}get savedQueries(){return this._savedQueries}set savedQueries(value){const previous=this._savedQueries;this._savedQueries=normalizeSavedQueries(value),this.requestUpdate("savedQueries",previous)}constructor(){super(),this._relationshipTypeOptions=EMPTY_OPTIONS,this._nodeTypeOptions=EMPTY_OPTIONS,this._savedQueries=EMPTY_SAVED,this.hopLimit=6,this.label="",this.hint="",this.errorText="",this._errors={},this.touchedFields=new Set,this.saveName="",this.hasHintSlot=!1,this.hasErrorSlot=!1,this.labelId=nextId("graph-query-builder-label"),this.hintId=nextId("graph-query-builder-hint"),this.errorId=nextId("graph-query-builder-error"),this._fieldsetDisabled=!1,this._name="",this._value=EMPTY_VALUE,this.defaultValue=normalizeGraphQuery(EMPTY_VALUE),this.defaultValueCaptured=!1,this._disabled=!1,this.hasInteracted=!1,this.removalFocusGeneration=0,this.onChromeSlotChange=event=>{const slot=event.currentTarget,hasContent=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType===Node.TEXT_NODE?!!node.textContent?.trim():!0);slot.name==="hint"?this.hasHintSlot=hasContent:slot.name==="error"&&(this.hasErrorSlot=hasContent)},this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.validityController.customValidityMessage),installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),this.syncFormState()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncExternalDescription()}disconnectedCallback(){this.removalFocusGeneration++,this.pendingRemovalFocus=void 0,this.releaseExternalDescription(),super.disconnectedCallback()}syncExternalDescription(){const target=this.isConnected?this.renderRoot.querySelector('[part="base"]')??null:null;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby")}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}get value(){return this._value}set value(next){const old=this._value;this._value=normalizeGraphQuery(next),this.syncFormState(),this.requestUpdate("value",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.requestUpdate("name",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.validityController&&this.syncFormState(),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}get errors(){return this.publicValidityErrors()}publicValidityErrors(){const errors={...this._errors};return this.willValidate&&this.validity.customError&&(errors.base=this.validationMessage),Object.freeze(errors)}publishValiditySnapshot(){if(!this.isConnected)return;const valid=!this.willValidate||this.validity.valid,errors=valid?Object.freeze({}):this.publicValidityErrors(),key=JSON.stringify({valid,errors});key!==this.lastValidityKey&&(this.lastValidityKey=key,this.emit("lr-validity-change",Object.freeze({valid,errors})))}[VALIDITY_ANCHOR](){const firstInvalidPart=Object.keys(this._errors)[0];if(!(!firstInvalidPart||!this.renderRoot))return this.renderRoot.querySelector(`[part="${firstInvalidPart}"]`)??void 0}computeValidation(){const errors={},flags={};return this._value.startId.trim()||(errors["start-input"]=this.localize("fieldRequired"),flags.valueMissing=!0),this._value.minHops>this._value.maxHops&&(errors["max-hops"]=this.localize("graphQueryHopRangeInvalid"),flags.rangeUnderflow=!0),{errors,flags}}syncFormState(){const{errors,flags}=this.computeValidation();this._errors=errors;let formValue=null;try{formValue=JSON.stringify(this._value)}catch{formValue=null}if(this.internals.setFormValue(formValue,formValue),this.barredFromValidation||Object.keys(flags).length===0)this.validityController.setValidity({});else{const message=Object.values(errors)[0]??"";this.validityController.setValidity(flags,message)}this.syncValidityCustomStates(),this.publishValiditySnapshot()}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}syncValidityCustomStates(){syncValidityStates(this.internals,{required:!0,hasInteracted:this.hasInteracted,barred:this.barredFromValidation})}checkValidity(){return this.syncFormState(),this.internals.checkValidity()}reportValidity(){return this.hasInteracted=!0,this.syncFormState(),Object.keys(this._errors).length>0&&(this.touchedFields=new Set([...this.touchedFields,...Object.keys(this._errors)])),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncValidityCustomStates(),this.publishValiditySnapshot(),this.requestUpdate()}formResetCallback(){this.hasInteracted=!1,this.captureDefaultValue(),this.value=this.defaultValue,this.touchedFields=new Set,this.saveName=""}captureDefaultValue(){this.defaultValueCaptured||(this.defaultValue=normalizeGraphQuery(this._value),this.defaultValueCaptured=!0)}formStateRestoreCallback(state2,_mode){let restored=EMPTY_VALUE;if(typeof state2=="string")try{const parsed=JSON.parse(state2);parsed!==null&&typeof parsed=="object"&&!Array.isArray(parsed)&&(restored=normalizeGraphQuery(parsed))}catch{}this.value=restored}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.syncFormState(),this.requestUpdate()}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}focusFirstControl(options){if(!this.renderRoot||this.liveDisabled)return;(this.renderRoot.querySelector('[part="start-input"]')||this.renderRoot.querySelector('[part="end-input"]')||this.renderRoot.querySelector('[part="min-hops"]')||this.renderRoot.querySelector('[part="max-hops"]')||this.renderRoot.querySelector('[part="direction"]')||this.renderRoot.querySelector('[part="save-name-input"]'))?.focus(options)}focus(options){this.focusFirstControl(options)}blur(){const active=deepActiveElementIn(this.shadowRoot);active&&typeof active.blur=="function"&&active.blur()}click(){this.focusFirstControl()}setValue(next){this.effectiveDisabled||(this.hasInteracted=!0,this.value=next,this.emit("lr-input",Object.freeze({value:this._value})))}addRelationshipType(type){!type||this._value.relationshipTypes.includes(type)||this.setValue({...this._value,relationshipTypes:[...this._value.relationshipTypes,type]})}removeRelationshipType(type){this.captureChipRemovalFocus("relationship",type,this._value.relationshipTypes),this.setValue({...this._value,relationshipTypes:this._value.relationshipTypes.filter(t=>t!==type)})}addNodeType(type){!type||this._value.nodeTypes.includes(type)||this.setValue({...this._value,nodeTypes:[...this._value.nodeTypes,type]})}removeNodeType(type){this.captureChipRemovalFocus("node-type",type,this._value.nodeTypes),this.setValue({...this._value,nodeTypes:this._value.nodeTypes.filter(t=>t!==type)})}captureChipRemovalFocus(group,value,selected){const active=activeElementIn(this.shadowRoot),expectedPart=group==="relationship"?"relationship-chips":"node-type-chips";if(active?.localName!=="lr-chip"||active.getAttribute("value")!==value||active.closest("lr-chip-group")?.getAttribute("part")!==expectedPart)return;const index=selected.indexOf(value),survivors=selected.filter(candidate=>candidate!==value),targetValue=survivors[Math.min(Math.max(index,0),survivors.length-1)];this.pendingRemovalFocus={kind:"chip",group,targetValue},this.removalFocusGeneration++}markTouched(part){this.hasInteracted=!0,this.syncValidityCustomStates(),!this.touchedFields.has(part)&&(this.touchedFields=new Set(this.touchedFields).add(part))}runQuery(){if(this.effectiveDisabled||!this.reportValidity())return;const detail=()=>Object.freeze({query:normalizeGraphQuery(this._value)});this.emit("lr-before-query-run",detail(),{cancelable:!0}).defaultPrevented||this.emit("lr-query-run",detail())}saveQuery(){if(this.effectiveDisabled)return;const name=this.saveName.trim();if(!name)return;const detail=()=>Object.freeze({name,query:normalizeGraphQuery(this._value)});this.emit("lr-before-query-save",detail(),{cancelable:!0}).defaultPrevented||(this.saveName="",this.emit("lr-query-save",detail()))}loadQuery(item){if(this.effectiveDisabled)return;const detail=()=>Object.freeze({queryId:item.id,query:normalizeGraphQuery(item.query)});this.emit("lr-before-query-load",detail(),{cancelable:!0}).defaultPrevented||(this.setValue({...EMPTY_VALUE,...item.query}),this.emit("lr-query-load",detail()))}deleteQuery(item){if(this.effectiveDisabled)return;const detail=()=>Object.freeze({queryId:item.id});this.emit("lr-before-query-delete",detail(),{cancelable:!0}).defaultPrevented||this.emit("lr-query-delete",detail())}willUpdate(changed){if(super.willUpdate(changed),this.hasUpdated||this.captureDefaultValue(),!changed.has("savedQueries"))return;const active=activeElementIn(this.shadowRoot);if(active?.getAttribute("part")!=="saved-delete-button")return;const focusedId=active.closest("[data-query-id]")?.dataset.queryId;if(!focusedId||this.savedQueries.some(item=>item.id===focusedId))return;const index=(changed.get("savedQueries")??[]).findIndex(item=>item.id===focusedId),target=this.savedQueries[Math.min(Math.max(index,0),this.savedQueries.length-1)];this.pendingRemovalFocus={kind:"saved",targetId:target?.id},this.removalFocusGeneration++}updated(changed){super.updated(changed),this.publishValiditySnapshot(),this.syncExternalDescription();const pending=this.pendingRemovalFocus;if(!pending)return;this.pendingRemovalFocus=void 0;const generation=this.removalFocusGeneration;this.scheduleAfterUpdate(()=>{if(!(generation!==this.removalFocusGeneration||!this.isConnected)){if(pending.kind==="chip"){if(pending.targetValue){const part=pending.group==="relationship"?"relationship-chips":"node-type-chips",chip=[...this.shadowRoot?.querySelectorAll(`[part="${part}"] lr-chip`)??[]].find(candidate=>candidate.getAttribute("value")===pending.targetValue);if(chip){chip.focus();return}}const pickerPart=pending.group==="relationship"?"relationship-picker":"node-type-picker";this.shadowRoot?.querySelector(`[part="${pickerPart}"]`)?.focus();return}if(pending.targetId){const action=[...this.shadowRoot?.querySelectorAll("[data-query-id]")??[]].find(candidate=>candidate.dataset.queryId===pending.targetId)?.querySelector('[part="saved-delete-button"]');if(action){action.focus();return}}this.shadowRoot?.querySelector('[part="save-name-input"]')?.focus()}},"graph-query-removal-focus")}hopOptions(){const limit=finiteInteger(this.hopLimit,6,1,20),options=new Set(Array.from({length:limit},(_,i)=>i+1));return options.add(this._value.minHops),options.add(this._value.maxHops),[...options].sort((a,b)=>a-b)}labelForType(options,value){return options.find(o=>o.value===value)?.label??value}containSelectEvent(event){event.stopPropagation()}renderTypeFilter(kind,options,selected,add,remove,disabled){const pickerPart=kind==="relationship"?"relationship-picker":"node-type-picker",chipsPart=kind==="relationship"?"relationship-chips":"node-type-chips",pickerLabel=kind==="relationship"?this.localize("graphQueryRelationshipTypeLabel"):this.localize("graphQueryNodeTypeLabel"),available=options.filter(o=>!selected.includes(o.value));return html`
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";installFormControlLabelSupport();import{closeIcon}from"../../../internal/icons.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{AnchoredValidityController,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{finiteInteger}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{nextId}from"../../../internal/a11y.js";import{activeElementIn,deepActiveElementIn}from"../../../internal/active-element.js";import{styles}from"./graph-query-builder.styles.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{getFormOwner,installCustomErrorProperty,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{installInteractionOnInvalid,installInvalidEventAlias,withStaticValidityCheck}from"../../../internal/invalid-event-alias.js";import{acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_graphQueryBuilderLabel,LYRA_DEFAULT_graphQueryDeleteWithContext,LYRA_DEFAULT_graphQueryDirectionLabel,LYRA_DEFAULT_graphQueryEndLabel,LYRA_DEFAULT_graphQueryHopRangeInvalid,LYRA_DEFAULT_graphQueryLoadWithContext,LYRA_DEFAULT_graphQueryMaxHopsLabel,LYRA_DEFAULT_graphQueryMinHopsLabel,LYRA_DEFAULT_graphQueryNodeTypeLabel,LYRA_DEFAULT_graphQueryRelationshipTypeLabel,LYRA_DEFAULT_graphQueryRun,LYRA_DEFAULT_graphQuerySaveButton,LYRA_DEFAULT_graphQuerySaveNameLabel,LYRA_DEFAULT_graphQuerySavedQueriesLabel,LYRA_DEFAULT_graphQueryStartLabel,LYRA_DEFAULT_neighborDirectionBoth,LYRA_DEFAULT_neighborDirectionIn,LYRA_DEFAULT_neighborDirectionOut,LYRA_DEFAULT_noData,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";const MAX_TYPES=500,MAX_SAVED_QUERIES=200,MAX_TEXT=256,EMPTY_STRINGS=Object.freeze([]),EMPTY_VALUE=Object.freeze({startId:"",endId:"",relationshipTypes:EMPTY_STRINGS,nodeTypes:EMPTY_STRINGS,direction:"both",minHops:1,maxHops:1}),EMPTY_OPTIONS=Object.freeze([]),EMPTY_SAVED=Object.freeze([]);function ownValue(record,key){try{const descriptor=Object.getOwnPropertyDescriptor(record,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}catch{return}}function boundedString(value){return typeof value=="string"?value.slice(0,MAX_TEXT):""}function stringArray(value){return Array.isArray(value)?Object.freeze([...new Set(value.slice(0,MAX_TYPES).filter(entry=>typeof entry=="string").map(entry=>boundedString(entry)).filter(Boolean))]):EMPTY_STRINGS}function normalizeGraphQuery(value){const record=value!==null&&typeof value=="object"&&!Array.isArray(value)?value:EMPTY_VALUE,direction=ownValue(record,"direction");return Object.freeze({startId:boundedString(ownValue(record,"startId")),endId:boundedString(ownValue(record,"endId")),relationshipTypes:stringArray(ownValue(record,"relationshipTypes")),nodeTypes:stringArray(ownValue(record,"nodeTypes")),direction:direction==="out"||direction==="in"||direction==="both"?direction:"both",minHops:finiteInteger(typeof ownValue(record,"minHops")=="number"?ownValue(record,"minHops"):EMPTY_VALUE.minHops,EMPTY_VALUE.minHops,1,20),maxHops:finiteInteger(typeof ownValue(record,"maxHops")=="number"?ownValue(record,"maxHops"):EMPTY_VALUE.maxHops,EMPTY_VALUE.maxHops,1,20)})}function normalizeTypeOptions(value){if(!Array.isArray(value))return EMPTY_OPTIONS;const values=new Set,result=[];for(const candidate of value.slice(0,MAX_TYPES)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const optionValue=boundedString(ownValue(candidate,"value"));if(optionValue.trim().length===0||values.has(optionValue))continue;values.add(optionValue);const label=boundedString(ownValue(candidate,"label"));result.push(Object.freeze({value:optionValue,...label?{label}:{}}))}return Object.freeze(result)}function normalizeSavedQueries(value){if(!Array.isArray(value))return EMPTY_SAVED;const ids=new Set,result=[];for(const candidate of value.slice(0,MAX_SAVED_QUERIES)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const id=boundedString(ownValue(candidate,"id"));id.trim().length===0||ids.has(id)||(ids.add(id),result.push(Object.freeze({id,name:boundedString(ownValue(candidate,"name")),query:normalizeGraphQuery(ownValue(candidate,"query"))})))}return Object.freeze(result)}class LyraGraphQueryBuilder extends LyraElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,graphQueryBuilderLabel:LYRA_DEFAULT_graphQueryBuilderLabel,graphQueryDeleteWithContext:LYRA_DEFAULT_graphQueryDeleteWithContext,graphQueryDirectionLabel:LYRA_DEFAULT_graphQueryDirectionLabel,graphQueryEndLabel:LYRA_DEFAULT_graphQueryEndLabel,graphQueryHopRangeInvalid:LYRA_DEFAULT_graphQueryHopRangeInvalid,graphQueryLoadWithContext:LYRA_DEFAULT_graphQueryLoadWithContext,graphQueryMaxHopsLabel:LYRA_DEFAULT_graphQueryMaxHopsLabel,graphQueryMinHopsLabel:LYRA_DEFAULT_graphQueryMinHopsLabel,graphQueryNodeTypeLabel:LYRA_DEFAULT_graphQueryNodeTypeLabel,graphQueryRelationshipTypeLabel:LYRA_DEFAULT_graphQueryRelationshipTypeLabel,graphQueryRun:LYRA_DEFAULT_graphQueryRun,graphQuerySaveButton:LYRA_DEFAULT_graphQuerySaveButton,graphQuerySaveNameLabel:LYRA_DEFAULT_graphQuerySaveNameLabel,graphQuerySavedQueriesLabel:LYRA_DEFAULT_graphQuerySavedQueriesLabel,graphQueryStartLabel:LYRA_DEFAULT_graphQueryStartLabel,neighborDirectionBoth:LYRA_DEFAULT_neighborDirectionBoth,neighborDirectionIn:LYRA_DEFAULT_neighborDirectionIn,neighborDirectionOut:LYRA_DEFAULT_neighborDirectionOut,noData:LYRA_DEFAULT_noData,select:LYRA_DEFAULT_select}}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-before-query-run","lr-query-run","lr-before-query-save","lr-query-save","lr-before-query-load","lr-query-load"])}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},value:{attribute:!1,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}get relationshipTypeOptions(){return this._relationshipTypeOptions}set relationshipTypeOptions(value){const previous=this._relationshipTypeOptions;this._relationshipTypeOptions=normalizeTypeOptions(value),this.requestUpdate("relationshipTypeOptions",previous)}get nodeTypeOptions(){return this._nodeTypeOptions}set nodeTypeOptions(value){const previous=this._nodeTypeOptions;this._nodeTypeOptions=normalizeTypeOptions(value),this.requestUpdate("nodeTypeOptions",previous)}get savedQueries(){return this._savedQueries}set savedQueries(value){const previous=this._savedQueries;this._savedQueries=normalizeSavedQueries(value),this.requestUpdate("savedQueries",previous)}constructor(){super(),this._relationshipTypeOptions=EMPTY_OPTIONS,this._nodeTypeOptions=EMPTY_OPTIONS,this._savedQueries=EMPTY_SAVED,this.hopLimit=6,this.label="",this.hint="",this.errorText="",this._errors={},this.touchedFields=new Set,this.saveName="",this.hasHintSlot=!1,this.hasErrorSlot=!1,this.labelId=nextId("graph-query-builder-label"),this.hintId=nextId("graph-query-builder-hint"),this.errorId=nextId("graph-query-builder-error"),this._fieldsetDisabled=!1,this._name="",this._value=EMPTY_VALUE,this.defaultValue=normalizeGraphQuery(EMPTY_VALUE),this.defaultValueCaptured=!1,this._disabled=!1,this.hasInteracted=!1,this.removalFocusGeneration=0,this.markInteracted=()=>{this.hasInteracted||(this.hasInteracted=!0,this.syncValidityCustomStates())},this.onChromeSlotChange=event=>{this.collectChromeSlotAssignment(event.currentTarget)},this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.validityController.customValidityMessage),installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),installInteractionOnInvalid(this,this.markInteracted),this.syncFormState()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncExternalDescription()}disconnectedCallback(){this.removalFocusGeneration++,this.pendingRemovalFocus=void 0,this.releaseExternalDescription(),super.disconnectedCallback()}syncExternalDescription(){const target=this.isConnected?this.renderRoot.querySelector('[part="base"]')??null:null;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby")}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}get value(){return this._value}set value(next){const old=this._value;this._value=normalizeGraphQuery(next),this.syncFormState(),this.requestUpdate("value",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.requestUpdate("name",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.validityController&&this.syncFormState(),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}get errors(){return this.publicValidityErrors()}publicValidityErrors(){const errors={...this._errors};return this.willValidate&&this.validity.customError&&(errors.base=this.validationMessage),Object.freeze(errors)}publishValiditySnapshot(){if(!this.isConnected)return;const valid=!this.willValidate||this.validity.valid,errors=valid?Object.freeze({}):this.publicValidityErrors(),key=JSON.stringify({valid,errors});key!==this.lastValidityKey&&(this.lastValidityKey=key,this.emit("lr-validity-change",Object.freeze({valid,errors})))}[VALIDITY_ANCHOR](){const firstInvalidPart=Object.keys(this._errors)[0];if(!(!firstInvalidPart||!this.renderRoot))return this.renderRoot.querySelector(`[part="${firstInvalidPart}"]`)??void 0}computeValidation(){const errors={},flags={};return this._value.startId.trim()||(errors["start-input"]=this.localize("fieldRequired"),flags.valueMissing=!0),this._value.minHops>this._value.maxHops&&(errors["max-hops"]=this.localize("graphQueryHopRangeInvalid"),flags.rangeUnderflow=!0),{errors,flags}}syncFormState(){const{errors,flags}=this.computeValidation();this._errors=errors;let formValue=null;try{formValue=JSON.stringify(this._value)}catch{formValue=null}if(this.internals.setFormValue(formValue,formValue),this.barredFromValidation||Object.keys(flags).length===0)this.validityController.setValidity({});else{const message=Object.values(errors)[0]??"";this.validityController.setValidity(flags,message)}this.syncValidityCustomStates(),this.publishValiditySnapshot()}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}syncValidityCustomStates(){syncValidityStates(this.internals,{required:!0,hasInteracted:this.hasInteracted,barred:this.barredFromValidation})}checkValidity(){return this.syncFormState(),withStaticValidityCheck(this,()=>this.internals.checkValidity())}reportValidity(){return this.hasInteracted=!0,this.syncFormState(),Object.keys(this._errors).length>0&&(this.touchedFields=new Set([...this.touchedFields,...Object.keys(this._errors)])),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncValidityCustomStates(),this.publishValiditySnapshot(),this.requestUpdate()}formResetCallback(){this.hasInteracted=!1,this.captureDefaultValue(),this.value=this.defaultValue,this.touchedFields=new Set,this.saveName=""}captureDefaultValue(){this.defaultValueCaptured||(this.defaultValue=normalizeGraphQuery(this._value),this.defaultValueCaptured=!0)}formStateRestoreCallback(state2,_mode){let restored=EMPTY_VALUE;if(typeof state2=="string")try{const parsed=JSON.parse(state2);parsed!==null&&typeof parsed=="object"&&!Array.isArray(parsed)&&(restored=normalizeGraphQuery(parsed))}catch{}this.value=restored}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.syncFormState(),this.requestUpdate()}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}focusFirstControl(options){if(!this.renderRoot||this.liveDisabled)return;(this.renderRoot.querySelector('[part="start-input"]')||this.renderRoot.querySelector('[part="end-input"]')||this.renderRoot.querySelector('[part="min-hops"]')||this.renderRoot.querySelector('[part="max-hops"]')||this.renderRoot.querySelector('[part="direction"]')||this.renderRoot.querySelector('[part="save-name-input"]'))?.focus(options)}focus(options){this.focusFirstControl(options)}blur(){const active=deepActiveElementIn(this.shadowRoot);active&&typeof active.blur=="function"&&active.blur()}click(){this.focusFirstControl()}setValue(next){this.effectiveDisabled||(this.hasInteracted=!0,this.value=next,this.emit("lr-input",Object.freeze({value:this._value})))}addRelationshipType(type){!type||this._value.relationshipTypes.includes(type)||this.setValue({...this._value,relationshipTypes:[...this._value.relationshipTypes,type]})}removeRelationshipType(type){this.captureChipRemovalFocus("relationship",type,this._value.relationshipTypes),this.setValue({...this._value,relationshipTypes:this._value.relationshipTypes.filter(t=>t!==type)})}addNodeType(type){!type||this._value.nodeTypes.includes(type)||this.setValue({...this._value,nodeTypes:[...this._value.nodeTypes,type]})}removeNodeType(type){this.captureChipRemovalFocus("node-type",type,this._value.nodeTypes),this.setValue({...this._value,nodeTypes:this._value.nodeTypes.filter(t=>t!==type)})}captureChipRemovalFocus(group,value,selected){const active=activeElementIn(this.shadowRoot),expectedPart=group==="relationship"?"relationship-chips":"node-type-chips";if(active?.localName!=="lr-chip"||active.getAttribute("value")!==value||active.closest("lr-chip-group")?.getAttribute("part")!==expectedPart)return;const index=selected.indexOf(value),survivors=selected.filter(candidate=>candidate!==value),targetValue=survivors[Math.min(Math.max(index,0),survivors.length-1)];this.pendingRemovalFocus={kind:"chip",group,targetValue},this.removalFocusGeneration++}markTouched(part){this.hasInteracted=!0,this.syncValidityCustomStates(),!this.touchedFields.has(part)&&(this.touchedFields=new Set(this.touchedFields).add(part))}runQuery(){if(this.effectiveDisabled||!this.reportValidity())return;const detail=()=>Object.freeze({query:normalizeGraphQuery(this._value)});this.emit("lr-before-query-run",detail(),{cancelable:!0}).defaultPrevented||this.emit("lr-query-run",detail())}saveQuery(){if(this.effectiveDisabled)return;const name=this.saveName.trim();if(!name)return;const detail=()=>Object.freeze({name,query:normalizeGraphQuery(this._value)});this.emit("lr-before-query-save",detail(),{cancelable:!0}).defaultPrevented||(this.saveName="",this.emit("lr-query-save",detail()))}loadQuery(item){if(this.effectiveDisabled)return;const detail=()=>Object.freeze({queryId:item.id,query:normalizeGraphQuery(item.query)});this.emit("lr-before-query-load",detail(),{cancelable:!0}).defaultPrevented||(this.setValue({...EMPTY_VALUE,...item.query}),this.emit("lr-query-load",detail()))}deleteQuery(item){if(this.effectiveDisabled)return;const detail=()=>Object.freeze({queryId:item.id});this.emit("lr-before-query-delete",detail(),{cancelable:!0}).defaultPrevented||this.emit("lr-query-delete",detail())}willUpdate(changed){if(super.willUpdate(changed),this.hasUpdated||this.captureDefaultValue(),!changed.has("savedQueries"))return;const active=activeElementIn(this.shadowRoot);if(active?.getAttribute("part")!=="saved-delete-button")return;const focusedId=active.closest("[data-query-id]")?.dataset.queryId;if(!focusedId||this.savedQueries.some(item=>item.id===focusedId))return;const index=(changed.get("savedQueries")??[]).findIndex(item=>item.id===focusedId),target=this.savedQueries[Math.min(Math.max(index,0),this.savedQueries.length-1)];this.pendingRemovalFocus={kind:"saved",targetId:target?.id},this.removalFocusGeneration++}updated(changed){super.updated(changed),this.publishValiditySnapshot(),this.syncExternalDescription();const pending=this.pendingRemovalFocus;if(!pending)return;this.pendingRemovalFocus=void 0;const generation=this.removalFocusGeneration;this.scheduleAfterUpdate(()=>{if(!(generation!==this.removalFocusGeneration||!this.isConnected)){if(pending.kind==="chip"){if(pending.targetValue){const part=pending.group==="relationship"?"relationship-chips":"node-type-chips",chip=[...this.shadowRoot?.querySelectorAll(`[part="${part}"] lr-chip`)??[]].find(candidate=>candidate.getAttribute("value")===pending.targetValue);if(chip){chip.focus();return}}const pickerPart=pending.group==="relationship"?"relationship-picker":"node-type-picker";this.shadowRoot?.querySelector(`[part="${pickerPart}"]`)?.focus();return}if(pending.targetId){const action=[...this.shadowRoot?.querySelectorAll("[data-query-id]")??[]].find(candidate=>candidate.dataset.queryId===pending.targetId)?.querySelector('[part="saved-delete-button"]');if(action){action.focus();return}}this.shadowRoot?.querySelector('[part="save-name-input"]')?.focus()}},"graph-query-removal-focus")}hopOptions(){const limit=finiteInteger(this.hopLimit,6,1,20),options=new Set(Array.from({length:limit},(_,i)=>i+1));return options.add(this._value.minHops),options.add(this._value.maxHops),[...options].sort((a,b)=>a-b)}collectChromeSlotAssignment(slot){const hasContent=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType===Node.TEXT_NODE?!!node.textContent?.trim():!0);slot.name==="hint"?this.hasHintSlot=hasContent:slot.name==="error"&&(this.hasErrorSlot=hasContent)}firstUpdated(changed){super.firstUpdated(changed);const hintSlot=this.hintSlotEl,errorSlot=this.errorSlotEl;queueMicrotask(()=>{collectInitialSlotAssignment(hintSlot,s=>this.collectChromeSlotAssignment(s)),collectInitialSlotAssignment(errorSlot,s=>this.collectChromeSlotAssignment(s))})}labelForType(options,value){return options.find(o=>o.value===value)?.label??value}containSelectEvent(event){event.stopPropagation()}renderTypeFilter(kind,options,selected,add,remove,disabled){const pickerPart=kind==="relationship"?"relationship-picker":"node-type-picker",chipsPart=kind==="relationship"?"relationship-chips":"node-type-chips",pickerLabel=kind==="relationship"?this.localize("graphQueryRelationshipTypeLabel"):this.localize("graphQueryNodeTypeLabel"),available=options.filter(o=>!selected.includes(o.value));return html`
|
|
2
2
|
<div part="filter-group" data-kind=${kind}>
|
|
3
3
|
<lr-select
|
|
4
4
|
@lr-activate=${this.containSelectEvent}
|
|
@@ -161,4 +161,4 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
161
161
|
</ul>`}
|
|
162
162
|
</div>
|
|
163
163
|
</div>
|
|
164
|
-
`}}__decorate([property({attribute:!1})],LyraGraphQueryBuilder.prototype,"relationshipTypeOptions",null),__decorate([property({attribute:!1})],LyraGraphQueryBuilder.prototype,"nodeTypeOptions",null),__decorate([property({attribute:!1})],LyraGraphQueryBuilder.prototype,"savedQueries",null),__decorate([property({attribute:"hop-limit",type:Number})],LyraGraphQueryBuilder.prototype,"hopLimit",void 0),__decorate([property()],LyraGraphQueryBuilder.prototype,"label",void 0),__decorate([property()],LyraGraphQueryBuilder.prototype,"hint",void 0),__decorate([property({attribute:"error-text"})],LyraGraphQueryBuilder.prototype,"errorText",void 0),__decorate([state()],LyraGraphQueryBuilder.prototype,"_errors",void 0),__decorate([state()],LyraGraphQueryBuilder.prototype,"touchedFields",void 0),__decorate([state()],LyraGraphQueryBuilder.prototype,"saveName",void 0),__decorate([state()],LyraGraphQueryBuilder.prototype,"hasHintSlot",void 0),__decorate([state()],LyraGraphQueryBuilder.prototype,"hasErrorSlot",void 0);export{LyraGraphQueryBuilder};
|
|
164
|
+
`}}__decorate([property({attribute:!1})],LyraGraphQueryBuilder.prototype,"relationshipTypeOptions",null),__decorate([property({attribute:!1})],LyraGraphQueryBuilder.prototype,"nodeTypeOptions",null),__decorate([property({attribute:!1})],LyraGraphQueryBuilder.prototype,"savedQueries",null),__decorate([property({attribute:"hop-limit",type:Number})],LyraGraphQueryBuilder.prototype,"hopLimit",void 0),__decorate([property()],LyraGraphQueryBuilder.prototype,"label",void 0),__decorate([property()],LyraGraphQueryBuilder.prototype,"hint",void 0),__decorate([property({attribute:"error-text"})],LyraGraphQueryBuilder.prototype,"errorText",void 0),__decorate([state()],LyraGraphQueryBuilder.prototype,"_errors",void 0),__decorate([state()],LyraGraphQueryBuilder.prototype,"touchedFields",void 0),__decorate([state()],LyraGraphQueryBuilder.prototype,"saveName",void 0),__decorate([state()],LyraGraphQueryBuilder.prototype,"hasHintSlot",void 0),__decorate([state()],LyraGraphQueryBuilder.prototype,"hasErrorSlot",void 0),__decorate([query('slot[name="hint"]')],LyraGraphQueryBuilder.prototype,"hintSlotEl",void 0),__decorate([query('slot[name="error"]')],LyraGraphQueryBuilder.prototype,"errorSlotEl",void 0);export{LyraGraphQueryBuilder};
|
|
@@ -4,7 +4,17 @@ import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from
|
|
|
4
4
|
readonly marker?:boolean;
|
|
5
5
|
/** Per-item text shown in the hover/focus tooltip and exposed as the item's accessible name
|
|
6
6
|
* (falls back to the category's own `label`, or the localized unnamed-category label). */
|
|
7
|
-
readonly label?:string;
|
|
7
|
+
readonly label?:string;
|
|
8
|
+
/**
|
|
9
|
+
* Marks this item non-actionable: `aria-disabled="true"` replaces the selected/active
|
|
10
|
+
* affordances of the cell that represents it, activating it (click, or Enter/Space while
|
|
11
|
+
* roving-focused) emits nothing, and roving keyboard navigation (arrow keys, Home/End) steps
|
|
12
|
+
* past it instead of landing on it. Above `MAX_RENDERED_CELLS`, one cell paints a whole RANGE of
|
|
13
|
+
* items and activating it always resolves to that range's first item (`cell.start`, see
|
|
14
|
+
* `activateCell()`), so a range cell's disabled state follows that same first item. Omitted or
|
|
15
|
+
* `false` renders the item exactly as before this field existed.
|
|
16
|
+
*/
|
|
17
|
+
readonly disabled?:boolean;}export interface SequenceStripCategory{readonly id:string;
|
|
8
18
|
/** A CSS color. Invalid values and `url()` paint servers render transparently. */
|
|
9
19
|
readonly color:string;
|
|
10
20
|
/** Human-readable name used in the auto-generated `aria-label` summary and as the hover-tooltip
|
|
@@ -38,6 +48,13 @@ export interface LyraSequenceStripActivateDetail{readonly index:number;readonly
|
|
|
38
48
|
* retains at most the first 10,000 items and categories as detached frozen snapshots; reassign a
|
|
39
49
|
* collection after changing it.
|
|
40
50
|
*
|
|
51
|
+
* An item may also set `disabled`, marking it non-actionable: `aria-disabled="true"` replaces the
|
|
52
|
+
* selected/active affordances of the cell that represents it, activating it (click or Enter/Space)
|
|
53
|
+
* emits nothing, and roving Left/Right/Home/End navigation -- including the default resting tab
|
|
54
|
+
* stop -- steps past it instead of landing on it. Above the cell cap, a range cell's disabled state
|
|
55
|
+
* follows its own activated item, the range's first (see `lr-item-activate` above). Omitted or
|
|
56
|
+
* `false` renders the item exactly as before this field existed.
|
|
57
|
+
*
|
|
41
58
|
* @customElement lr-sequence-strip
|
|
42
59
|
* @event lr-item-activate - Fired when a cell is clicked, or activated with Enter/Space on the
|
|
43
60
|
* roving-tabindex focus. `detail: { index, id, item }` identifies the picked item — the range's
|
|
@@ -46,7 +63,8 @@ export interface LyraSequenceStripActivateDetail{readonly index:number;readonly
|
|
|
46
63
|
* so the consumer stays the single source of truth for a playback index this strip does not own.
|
|
47
64
|
* @csspart base - The root strip wrapper (`role="list"`).
|
|
48
65
|
* @csspart cell - Each named, roving-focus cell, background-colored by its category — one item
|
|
49
|
-
* below the render cap, one dominant-coloured item range above it.
|
|
66
|
+
* below the render cap, one dominant-coloured item range above it. Carries `aria-disabled="true"`
|
|
67
|
+
* while the item it activates sets `disabled`.
|
|
50
68
|
* @csspart marker - The small bottom marker on a cell any of whose items sets `marker: true`.
|
|
51
69
|
* @csspart tooltip - The hover/focus tooltip showing the active cell's label, positioned from that
|
|
52
70
|
* active cell.
|
|
@@ -67,6 +85,7 @@ export interface LyraSequenceStripActivateDetail{readonly index:number;readonly
|
|
|
67
85
|
* @cssprop [--lr-sequence-strip-marker-color=var(--lr-color-text)] - Color of the bottom marker on a `marker: true` cell, and of the marker legend row's bar.
|
|
68
86
|
* @cssprop [--lr-sequence-strip-legend-swatch-size=var(--lr-size-0-625rem)] - Inline and block size of a legend swatch (category and marker rows alike).
|
|
69
87
|
* @cssprop [--lr-sequence-strip-legend-marker-bg=var(--lr-color-surface-raised)] - Neutral chip background behind the marker legend row's bar; it stands in for "any cell", so it deliberately matches no category color.
|
|
88
|
+
* @cssprop [--lr-sequence-strip-disabled-opacity=var(--lr-opacity-disabled)] - Opacity of a cell whose activated item sets `disabled`.
|
|
70
89
|
* @status stable
|
|
71
90
|
* @since 4.0.0
|
|
72
91
|
*/
|
|
@@ -113,6 +132,13 @@ private activateItem;
|
|
|
113
132
|
* Reporting the first item keeps a playback consumer's `selectedIndex` on a real sequence
|
|
114
133
|
* position it can scrub from, which a synthesized range midpoint would not be. */
|
|
115
134
|
private activateCell;
|
|
135
|
+
/** A cell's disabled state follows the item it activates -- itself below the cap, its range's
|
|
136
|
+
* first item above it (see `activateCell()`). */
|
|
137
|
+
private cellDisabled;
|
|
138
|
+
/** Returns the nearest enabled cell, preferring forward then backward; `-1` means none exists. */
|
|
139
|
+
private nearestEnabledCellIndex;
|
|
140
|
+
/** Steps by one cell in `direction`, skipping disabled cells without wrapping. */
|
|
141
|
+
private stepEnabledCellIndex;
|
|
116
142
|
/** Renders a static `[part="legend"]` key of every `categories` entry below the strip, so the
|
|
117
143
|
* color-to-category mapping is readable without hovering each cell. Deliberately
|
|
118
144
|
* non-interactive: unlike `<lr-graph-legend>` this toggles nothing and emits nothing — the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{isRtl}from"../../../internal/rtl.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{finiteCount,finiteInteger}from"../../../internal/numbers.js";import{activeElementIn}from"../../../internal/active-element.js";import{styles}from"./sequence-strip.styles.js";import{LYRA_DEFAULT_sequenceStripBucketLabel,LYRA_DEFAULT_sequenceStripBucketSummary,LYRA_DEFAULT_sequenceStripCategoryCount,LYRA_DEFAULT_sequenceStripEmpty,LYRA_DEFAULT_sequenceStripUnnamedCategory}from"../../../internal/default-strings.generated.js";const MAX_RENDERED_CELLS=200,MAX_RENDERED_CATEGORIES=200,MAX_SEQUENCE_COLLECTION_ENTRIES=1e4;function bucketStartIndex(cell,total,cellCount){return Math.ceil(cell*total/cellCount)}function buildSequenceStripCells(items){const total=finiteCount(items.length);if(total===0)return[];const cellCount=Math.min(total,MAX_RENDERED_CELLS);if(cellCount===total)return items.map((item,index)=>({start:index,end:index,categoryId:item.categoryId,marker:item.marker===!0}));const cells=[];for(let cell=0;cell<cellCount;cell++){const start=bucketStartIndex(cell,total,cellCount),end=bucketStartIndex(cell+1,total,cellCount)-1,counts=new Map;let marker=!1;for(let index=start;index<=end;index++){const item=items[index];item&&(item.marker===!0&&(marker=!0),counts.set(item.categoryId,(counts.get(item.categoryId)??0)+1))}let categoryId="",dominantCount=0;for(const[id,count]of counts)count>dominantCount&&(dominantCount=count,categoryId=id);cells.push({start,end,categoryId,marker})}return cells}class LyraSequenceStrip extends LyraElement{constructor(){super(...arguments),this._items=[],this._categories=[],this.selectedIndex=-1,this.showLegend=!1,this.hoverIndex=null,this.keyboardIndex=null,this.cellCache=[],this.restoringOwnedFocus=!1,this.focusRestoreGeneration=0}static{this.defaultStrings={...super.defaultStrings,sequenceStripBucketLabel:LYRA_DEFAULT_sequenceStripBucketLabel,sequenceStripBucketSummary:LYRA_DEFAULT_sequenceStripBucketSummary,sequenceStripCategoryCount:LYRA_DEFAULT_sequenceStripCategoryCount,sequenceStripEmpty:LYRA_DEFAULT_sequenceStripEmpty,sequenceStripUnnamedCategory:LYRA_DEFAULT_sequenceStripUnnamedCategory}}static{this.styles=[LyraElement.styles,styles]}get items(){return this._items}set items(value){const previous=this._items,seen=new Set,next=[];if(Array.isArray(value))for(const item of value.slice(0,MAX_SEQUENCE_COLLECTION_ENTRIES))try{if(!item||typeof item.id!="string"||item.id.trim().length===0||seen.has(item.id))continue;seen.add(item.id),next.push(Object.freeze({id:item.id,categoryId:typeof item.categoryId=="string"?item.categoryId:"",...item.marker===void 0?{}:{marker:!!item.marker},...typeof item.label=="string"?{label:item.label}:{}}))}catch{}this._items=Object.freeze(next),this.requestUpdate("items",previous)}get categories(){return this._categories}set categories(value){const previous=this._categories,seen=new Set,next=[];if(Array.isArray(value))for(const category of value.slice(0,MAX_SEQUENCE_COLLECTION_ENTRIES))try{if(!category||typeof category.id!="string"||category.id.trim().length===0||seen.has(category.id))continue;seen.add(category.id),next.push(Object.freeze({id:category.id,color:typeof category.color=="string"?category.color:"",...typeof category.label=="string"?{label:category.label}:{}}))}catch{}this._categories=Object.freeze(next),this.requestUpdate("categories",previous)}cellIndexForItem(itemIndex){const total=finiteCount(this.items.length);if(total===0)return-1;const index=finiteInteger(itemIndex,-1,-1,total-1);if(index<0)return-1;const cellCount=Math.min(total,MAX_RENDERED_CELLS);return cellCount===total?index:Math.min(cellCount-1,Math.floor(index*cellCount/total))}selectedCellIndex(){if(!Number.isInteger(this.selectedIndex)||this.selectedIndex<0||this.selectedIndex>=this.items.length)return null;const cellIndex=this.cellIndexForItem(this.selectedIndex);return cellIndex>=0?cellIndex:null}activateItem(index){const item=this.items[index];item&&this.emit("lr-item-activate",{index,id:item.id,item})}activateCell(cellIndex){const cell=this.cells()[cellIndex];cell&&this.activateItem(cell.start)}willUpdate(changed){if(super.willUpdate(changed),changed.has("items")){this.focusRestoreGeneration++,this.hoverIndex=null;const focusedCell=activeElementIn(this.shadowRoot),focusedCellIndex=Number(focusedCell?.dataset?.index);if(!Number.isInteger(focusedCellIndex)||focusedCellIndex<0){this.keyboardIndex=null;return}const focusedId=focusedCell?.dataset?.itemId,retainedItemIndex=focusedId===void 0||focusedId===""?-1:this.items.findIndex(item=>item.id===focusedId),cells=this.cells(),nextIndex=retainedItemIndex>=0?this.cellIndexForItem(retainedItemIndex):cells.length?Math.min(focusedCellIndex,cells.length-1):-1;this.keyboardIndex=nextIndex>=0?nextIndex:null,this.pendingFocusTarget=nextIndex>=0?nextIndex:"base",this.restoringOwnedFocus=!0}}updated(changed){super.updated(changed);const pending=this.pendingFocusTarget;if(pending===void 0)return;this.pendingFocusTarget=void 0;const generation=this.focusRestoreGeneration;this.scheduleAfterUpdate(()=>{try{if(generation!==this.focusRestoreGeneration||!this.isConnected)return;if(pending==="base"){this.shadowRoot?.querySelector('[part="base"]')?.focus();return}this.shadowRoot?.querySelector(`[part="cell"][data-index="${pending}"]`)?.focus()}finally{this.restoringOwnedFocus=!1}},"sequence-strip-focus")}disconnectedCallback(){this.focusRestoreGeneration++,this.pendingFocusTarget=void 0,this.restoringOwnedFocus=!1,this.hoverIndex=null,this.keyboardIndex=null,super.disconnectedCallback()}cells(){const items=this._items;return this.cellCacheSource===items?this.cellCache:(this.cellCacheSource=items,this.cellCache=Object.freeze(buildSequenceStripCells(items)),this.cellCache)}categoryMap(){return new Map(this.categories.map(category=>[category.id,category]))}categoryColor(categoryId,categories){return sanitizeCssColor(categories.get(categoryId)?.color)??"transparent"}categoryLabel(categoryId,categories){const label=categories.get(categoryId)?.label;return label!==void 0&&label.trim().length>0?label:this.localize("sequenceStripUnnamedCategory")}autoSummary(){const counts=new Map,categories=this.categoryMap();for(const item of this.items)counts.set(item.categoryId,(counts.get(item.categoryId)??0)+1);if(counts.size===0)return this.localize("sequenceStripEmpty");const clauses=[...counts.entries()].map(([categoryId,count])=>{const label=this.categoryLabel(categoryId,categories);return this.localize("sequenceStripCategoryCount",void 0,{label,count:getNumberFormat(this.effectiveLocale).format(count),pluralCount:count})}),markerCount=this.items.filter(item=>item.marker).length;this.markerLabel&&markerCount>0&&clauses.push(this.localize("sequenceStripCategoryCount",void 0,{label:this.markerLabel,count:getNumberFormat(this.effectiveLocale).format(markerCount),pluralCount:markerCount}));const overview=this.bucketSummary();return overview!==void 0&&clauses.push(overview),getListFormat(this.effectiveLocale,{style:"long",type:"unit"}).format(clauses)}bucketSummary(){const cells=this.cells();if(cells.length===0||cells.length>=this.items.length)return;const number=getNumberFormat(this.effectiveLocale);return this.localize("sequenceStripBucketSummary",void 0,{items:number.format(this.items.length),ranges:number.format(cells.length),pluralCount:this.items.length})}cellLabel(cell,categories=this.categoryMap()){if(cell.end<=cell.start){const item=this.items[cell.start];return item?this.itemLabel(item,categories):this.categoryLabel(cell.categoryId,categories)}const number=getNumberFormat(this.effectiveLocale);return this.localize("sequenceStripBucketLabel",void 0,{label:this.categoryLabel(cell.categoryId,categories),start:number.format(cell.start+1),end:number.format(cell.end+1),pluralCount:cell.end-cell.start+1})}itemLabel(item,categories=this.categoryMap()){return item.label!==void 0&&item.label.trim().length>0?item.label:this.categoryLabel(item.categoryId,categories)}onCellEnter(index){this.hoverIndex=index}onCellLeave(){this.hoverIndex=null}onCellFocus(index){this.restoringOwnedFocus||(this.keyboardIndex=index)}onStripFocusOut(e){if(this.restoringOwnedFocus)return;const next=e.relatedTarget;(!(next instanceof Element)||next.getAttribute("part")!=="cell")&&(this.keyboardIndex=null)}onCellKeyDown(e,index){if(e.key==="Enter"||e.key===" "||e.key==="Spacebar"){e.preventDefault(),this.activateCell(index);return}const cells=this.cells();if(!["ArrowLeft","ArrowRight","Home","End"].includes(e.key)||cells.length===0)return;e.preventDefault();const forwardKey=isRtl(this)?"ArrowLeft":"ArrowRight",backwardKey=isRtl(this)?"ArrowRight":"ArrowLeft";let next=index;e.key==="Home"?next=0:e.key==="End"?next=cells.length-1:e.key===forwardKey?next=Math.min(cells.length-1,index+1):e.key===backwardKey&&(next=Math.max(0,index-1));const items=this.items,targetStart=cells[next]?.start,targetId=targetStart===void 0?void 0:items[targetStart]?.id;if(targetId===void 0)return;const generation=this.focusRestoreGeneration;this.keyboardIndex=next,this.updateComplete.then(()=>{if(generation!==this.focusRestoreGeneration||!this.isConnected||this.items!==items)return;const target=this.shadowRoot?.querySelector(`[part="cell"][data-index="${next}"]`);target?.dataset.itemId===targetId&&target.focus()})}renderLegend(){const renderedCategories=this.categories.slice(0,MAX_RENDERED_CATEGORIES),categoryMap=this.categoryMap(),number=getNumberFormat(this.effectiveLocale);return html`
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{isRtl}from"../../../internal/rtl.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{finiteCount,finiteInteger}from"../../../internal/numbers.js";import{activeElementIn}from"../../../internal/active-element.js";import{styles}from"./sequence-strip.styles.js";import{LYRA_DEFAULT_sequenceStripBucketLabel,LYRA_DEFAULT_sequenceStripBucketSummary,LYRA_DEFAULT_sequenceStripCategoryCount,LYRA_DEFAULT_sequenceStripEmpty,LYRA_DEFAULT_sequenceStripUnnamedCategory}from"../../../internal/default-strings.generated.js";const MAX_RENDERED_CELLS=200,MAX_RENDERED_CATEGORIES=200,MAX_SEQUENCE_COLLECTION_ENTRIES=1e4;function bucketStartIndex(cell,total,cellCount){return Math.ceil(cell*total/cellCount)}function buildSequenceStripCells(items){const total=finiteCount(items.length);if(total===0)return[];const cellCount=Math.min(total,MAX_RENDERED_CELLS);if(cellCount===total)return items.map((item,index)=>({start:index,end:index,categoryId:item.categoryId,marker:item.marker===!0}));const cells=[];for(let cell=0;cell<cellCount;cell++){const start=bucketStartIndex(cell,total,cellCount),end=bucketStartIndex(cell+1,total,cellCount)-1,counts=new Map;let marker=!1;for(let index=start;index<=end;index++){const item=items[index];item&&(item.marker===!0&&(marker=!0),counts.set(item.categoryId,(counts.get(item.categoryId)??0)+1))}let categoryId="",dominantCount=0;for(const[id,count]of counts)count>dominantCount&&(dominantCount=count,categoryId=id);cells.push({start,end,categoryId,marker})}return cells}class LyraSequenceStrip extends LyraElement{constructor(){super(...arguments),this._items=[],this._categories=[],this.selectedIndex=-1,this.showLegend=!1,this.hoverIndex=null,this.keyboardIndex=null,this.cellCache=[],this.restoringOwnedFocus=!1,this.focusRestoreGeneration=0}static{this.defaultStrings={...super.defaultStrings,sequenceStripBucketLabel:LYRA_DEFAULT_sequenceStripBucketLabel,sequenceStripBucketSummary:LYRA_DEFAULT_sequenceStripBucketSummary,sequenceStripCategoryCount:LYRA_DEFAULT_sequenceStripCategoryCount,sequenceStripEmpty:LYRA_DEFAULT_sequenceStripEmpty,sequenceStripUnnamedCategory:LYRA_DEFAULT_sequenceStripUnnamedCategory}}static{this.styles=[LyraElement.styles,styles]}get items(){return this._items}set items(value){const previous=this._items,seen=new Set,next=[];if(Array.isArray(value))for(const item of value.slice(0,MAX_SEQUENCE_COLLECTION_ENTRIES))try{if(!item||typeof item.id!="string"||item.id.trim().length===0||seen.has(item.id))continue;seen.add(item.id),next.push(Object.freeze({id:item.id,categoryId:typeof item.categoryId=="string"?item.categoryId:"",...item.marker===void 0?{}:{marker:!!item.marker},...typeof item.label=="string"?{label:item.label}:{},...item.disabled===void 0?{}:{disabled:!!item.disabled}}))}catch{}this._items=Object.freeze(next),this.requestUpdate("items",previous)}get categories(){return this._categories}set categories(value){const previous=this._categories,seen=new Set,next=[];if(Array.isArray(value))for(const category of value.slice(0,MAX_SEQUENCE_COLLECTION_ENTRIES))try{if(!category||typeof category.id!="string"||category.id.trim().length===0||seen.has(category.id))continue;seen.add(category.id),next.push(Object.freeze({id:category.id,color:typeof category.color=="string"?category.color:"",...typeof category.label=="string"?{label:category.label}:{}}))}catch{}this._categories=Object.freeze(next),this.requestUpdate("categories",previous)}cellIndexForItem(itemIndex){const total=finiteCount(this.items.length);if(total===0)return-1;const index=finiteInteger(itemIndex,-1,-1,total-1);if(index<0)return-1;const cellCount=Math.min(total,MAX_RENDERED_CELLS);return cellCount===total?index:Math.min(cellCount-1,Math.floor(index*cellCount/total))}selectedCellIndex(){if(!Number.isInteger(this.selectedIndex)||this.selectedIndex<0||this.selectedIndex>=this.items.length)return null;const cellIndex=this.cellIndexForItem(this.selectedIndex);return cellIndex>=0?cellIndex:null}activateItem(index){const item=this.items[index];!item||item.disabled||this.emit("lr-item-activate",{index,id:item.id,item})}activateCell(cellIndex){const cell=this.cells()[cellIndex];cell&&this.activateItem(cell.start)}cellDisabled(cell){return this.items[cell.start]?.disabled===!0}nearestEnabledCellIndex(cells,index){const count=cells.length;if(!count)return-1;const clamped=Math.min(Math.max(index,0),count-1);if(!this.cellDisabled(cells[clamped]))return clamped;for(let forward=clamped+1;forward<count;forward+=1)if(!this.cellDisabled(cells[forward]))return forward;for(let backward=clamped-1;backward>=0;backward-=1)if(!this.cellDisabled(cells[backward]))return backward;return-1}stepEnabledCellIndex(cells,from,direction){const count=cells.length;if(!count)return from;let index=Math.min(Math.max(from+direction,0),count-1);for(let steps=0;steps<count;steps+=1){if(!this.cellDisabled(cells[index]))return index;if(index+=direction,index<0||index>=count)break}return from}willUpdate(changed){if(super.willUpdate(changed),changed.has("items")){this.focusRestoreGeneration++,this.hoverIndex=null;const focusedCell=activeElementIn(this.shadowRoot),focusedCellIndex=Number(focusedCell?.dataset?.index);if(!Number.isInteger(focusedCellIndex)||focusedCellIndex<0){this.keyboardIndex=null;return}const focusedId=focusedCell?.dataset?.itemId,retainedItemIndex=focusedId===void 0||focusedId===""?-1:this.items.findIndex(item=>item.id===focusedId),cells=this.cells(),nextIndex=retainedItemIndex>=0?this.cellIndexForItem(retainedItemIndex):cells.length?Math.min(focusedCellIndex,cells.length-1):-1;this.keyboardIndex=nextIndex>=0?nextIndex:null,this.pendingFocusTarget=nextIndex>=0?nextIndex:"base",this.restoringOwnedFocus=!0}}updated(changed){super.updated(changed);const pending=this.pendingFocusTarget;if(pending===void 0)return;this.pendingFocusTarget=void 0;const generation=this.focusRestoreGeneration;this.scheduleAfterUpdate(()=>{try{if(generation!==this.focusRestoreGeneration||!this.isConnected)return;if(pending==="base"){this.shadowRoot?.querySelector('[part="base"]')?.focus();return}this.shadowRoot?.querySelector(`[part="cell"][data-index="${pending}"]`)?.focus()}finally{this.restoringOwnedFocus=!1}},"sequence-strip-focus")}disconnectedCallback(){this.focusRestoreGeneration++,this.pendingFocusTarget=void 0,this.restoringOwnedFocus=!1,this.hoverIndex=null,this.keyboardIndex=null,super.disconnectedCallback()}cells(){const items=this._items;return this.cellCacheSource===items?this.cellCache:(this.cellCacheSource=items,this.cellCache=Object.freeze(buildSequenceStripCells(items)),this.cellCache)}categoryMap(){return new Map(this.categories.map(category=>[category.id,category]))}categoryColor(categoryId,categories){return sanitizeCssColor(categories.get(categoryId)?.color)??"transparent"}categoryLabel(categoryId,categories){const label=categories.get(categoryId)?.label;return label!==void 0&&label.trim().length>0?label:this.localize("sequenceStripUnnamedCategory")}autoSummary(){const counts=new Map,categories=this.categoryMap();for(const item of this.items)counts.set(item.categoryId,(counts.get(item.categoryId)??0)+1);if(counts.size===0)return this.localize("sequenceStripEmpty");const clauses=[...counts.entries()].map(([categoryId,count])=>{const label=this.categoryLabel(categoryId,categories);return this.localize("sequenceStripCategoryCount",void 0,{label,count:getNumberFormat(this.effectiveLocale).format(count),pluralCount:count})}),markerCount=this.items.filter(item=>item.marker).length;this.markerLabel&&markerCount>0&&clauses.push(this.localize("sequenceStripCategoryCount",void 0,{label:this.markerLabel,count:getNumberFormat(this.effectiveLocale).format(markerCount),pluralCount:markerCount}));const overview=this.bucketSummary();return overview!==void 0&&clauses.push(overview),getListFormat(this.effectiveLocale,{style:"long",type:"unit"}).format(clauses)}bucketSummary(){const cells=this.cells();if(cells.length===0||cells.length>=this.items.length)return;const number=getNumberFormat(this.effectiveLocale);return this.localize("sequenceStripBucketSummary",void 0,{items:number.format(this.items.length),ranges:number.format(cells.length),pluralCount:this.items.length})}cellLabel(cell,categories=this.categoryMap()){if(cell.end<=cell.start){const item=this.items[cell.start];return item?this.itemLabel(item,categories):this.categoryLabel(cell.categoryId,categories)}const number=getNumberFormat(this.effectiveLocale);return this.localize("sequenceStripBucketLabel",void 0,{label:this.categoryLabel(cell.categoryId,categories),start:number.format(cell.start+1),end:number.format(cell.end+1),pluralCount:cell.end-cell.start+1})}itemLabel(item,categories=this.categoryMap()){return item.label!==void 0&&item.label.trim().length>0?item.label:this.categoryLabel(item.categoryId,categories)}onCellEnter(index){this.hoverIndex=index}onCellLeave(){this.hoverIndex=null}onCellFocus(index){this.restoringOwnedFocus||(this.keyboardIndex=index)}onStripFocusOut(e){if(this.restoringOwnedFocus)return;const next=e.relatedTarget;(!(next instanceof Element)||next.getAttribute("part")!=="cell")&&(this.keyboardIndex=null)}onCellKeyDown(e,index){if(e.key==="Enter"||e.key===" "||e.key==="Spacebar"){e.preventDefault(),this.activateCell(index);return}const cells=this.cells();if(!["ArrowLeft","ArrowRight","Home","End"].includes(e.key)||cells.length===0)return;e.preventDefault();const forwardKey=isRtl(this)?"ArrowLeft":"ArrowRight",backwardKey=isRtl(this)?"ArrowRight":"ArrowLeft";let next=index;if(e.key==="Home")next=cells.findIndex(cell=>!this.cellDisabled(cell));else if(e.key==="End")for(next=cells.length-1;next>=0&&this.cellDisabled(cells[next]);)next-=1;else e.key===forwardKey?next=this.stepEnabledCellIndex(cells,index,1):e.key===backwardKey&&(next=this.stepEnabledCellIndex(cells,index,-1));if(next<0)return;const items=this.items,targetStart=cells[next]?.start,targetId=targetStart===void 0?void 0:items[targetStart]?.id;if(targetId===void 0)return;const generation=this.focusRestoreGeneration;this.keyboardIndex=next,this.updateComplete.then(()=>{if(generation!==this.focusRestoreGeneration||!this.isConnected||this.items!==items)return;const target=this.shadowRoot?.querySelector(`[part="cell"][data-index="${next}"]`);target?.dataset.itemId===targetId&&target.focus()})}renderLegend(){const renderedCategories=this.categories.slice(0,MAX_RENDERED_CATEGORIES),categoryMap=this.categoryMap(),number=getNumberFormat(this.effectiveLocale);return html`
|
|
2
2
|
<div part="legend" aria-hidden="true">
|
|
3
3
|
${renderedCategories.map(category=>html`
|
|
4
4
|
<span part="legend-item">
|
|
@@ -17,7 +17,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
17
17
|
`:nothing}
|
|
18
18
|
${this.categories.length>renderedCategories.length?html`<span part="legend-limit">${number.format(renderedCategories.length)} / ${number.format(this.categories.length)}</span>`:nothing}
|
|
19
19
|
</div>
|
|
20
|
-
`}render(){const categoryMap=this.categoryMap(),ariaLabel=this.accessibleLabel==null?this.autoSummary():this.accessibleLabel,cells=this.cells(),activeIndex=this.hoverIndex??this.keyboardIndex,active=activeIndex!==null?cells[activeIndex]:void 0,selectedCell=this.selectedCellIndex(),
|
|
20
|
+
`}render(){const categoryMap=this.categoryMap(),ariaLabel=this.accessibleLabel==null?this.autoSummary():this.accessibleLabel,cells=this.cells(),activeIndex=this.hoverIndex??this.keyboardIndex,active=activeIndex!==null?cells[activeIndex]:void 0,selectedCell=this.selectedCellIndex(),requestedTabStop=this.keyboardIndex??selectedCell??0,nearestEnabledTabStop=this.nearestEnabledCellIndex(cells,requestedTabStop),tabStop=nearestEnabledTabStop>=0?nearestEnabledTabStop:requestedTabStop,tooltipIndex=activeIndex??tabStop,overview=this.bucketSummary();return html`
|
|
21
21
|
<div
|
|
22
22
|
part="base"
|
|
23
23
|
role="list"
|
|
@@ -37,6 +37,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
37
37
|
aria-label=${this.cellLabel(cell,categoryMap)}
|
|
38
38
|
aria-posinset=${index+1}
|
|
39
39
|
aria-setsize=${cells.length}
|
|
40
|
+
aria-disabled=${this.cellDisabled(cell)?"true":nothing}
|
|
40
41
|
tabindex=${index===tabStop?"0":"-1"}
|
|
41
42
|
style=${styleMap({backgroundColor:this.categoryColor(cell.categoryId,categoryMap)})}
|
|
42
43
|
@pointerenter=${()=>this.onCellEnter(index)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css}from"lit";const styles=css`:host{display:block}[part=base]{align-items:stretch;gap:var(--lr-size-1px);block-size:var(--lr-sequence-strip-height,var(--lr-size-1-5rem));display:flex;position:relative}[part=base][data-dense]{gap:0}[part=cell]{cursor:pointer;flex:1 1 0;justify-content:center;align-items:flex-end;min-inline-size:0;display:flex;position:relative}[part=cell]:hover,[part=cell]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:calc(-1 * var(--lr-focus-ring-width))}[part=cell]:active,[part=cell][data-selected]{outline:var(--lr-focus-ring-width) solid var(--lr-color-text);outline-offset:calc(-1 * var(--lr-focus-ring-width))}[part=cell][data-selected]:focus-visible{outline-color:var(--lr-focus-ring-color)}[part=cell]:first-child{border-start-start-radius:var(--lr-radius-xs);border-end-start-radius:var(--lr-radius-xs)}[part=cell]:last-child{border-start-end-radius:var(--lr-radius-xs);border-end-end-radius:var(--lr-radius-xs)}[part=marker]{inline-size:100%;block-size:var(--lr-size-2px);background:var(--lr-sequence-strip-marker-color,var(--lr-color-text));display:block}[part=tooltip]{transform:translate(-50%, calc(-1 * var(--lr-size-6px)));padding:var(--lr-size-2px) var(--lr-size-6px);border-radius:var(--lr-radius);background:var(--lr-color-surface);color:var(--lr-color-text);font-size:var(--lr-font-size-xs);white-space:nowrap;box-shadow:var(--lr-shadow-m);pointer-events:none;z-index:var(--lr-layer-content);position:absolute;inset-block-end:100%;inset-inline-start:50%}:host(:dir(rtl)) [part=tooltip]{transform:translate(50%, calc(-1 * var(--lr-size-6px)))}[part=tooltip][hidden]{display:none}[part=legend]{align-items:center;gap:var(--lr-space-2xs) var(--lr-space-s);font-size:var(--lr-font-size-xs);color:var(--lr-color-text-quiet);flex-wrap:wrap;margin-block-start:var(--lr-space-xs);display:flex}[part=bucket-summary],[part=legend-limit]{color:var(--lr-color-text-quiet);font-size:var(--lr-font-size-xs);font-variant-numeric:tabular-nums}[part=bucket-summary]{text-align:end;margin-block-start:var(--lr-space-2xs)}[part=legend-item]{align-items:center;gap:var(--lr-space-2xs);min-inline-size:0;display:inline-flex}[part=legend-swatch],[part=legend-marker-swatch]{inline-size:var(--lr-sequence-strip-legend-swatch-size,var(--lr-size-0-625rem));block-size:var(--lr-sequence-strip-legend-swatch-size,var(--lr-size-0-625rem));border-radius:var(--lr-radius-xs);flex:none}[part=legend-marker-swatch]{background:var(--lr-sequence-strip-legend-marker-bg,var(--lr-color-surface-raised));box-shadow:inset 0 calc(-1 * var(--lr-size-2px)) 0 0 var(--lr-sequence-strip-marker-color,var(--lr-color-text))}[part=legend-label]{overflow-wrap:anywhere;min-inline-size:0}`;export{styles};
|
|
1
|
+
import{css}from"lit";const styles=css`:host{display:block}[part=base]{align-items:stretch;gap:var(--lr-size-1px);block-size:var(--lr-sequence-strip-height,var(--lr-size-1-5rem));display:flex;position:relative}[part=base][data-dense]{gap:0}[part=cell]{cursor:pointer;flex:1 1 0;justify-content:center;align-items:flex-end;min-inline-size:0;display:flex;position:relative}[part=cell]:where(:not([aria-disabled=true])):hover,[part=cell]:where(:not([aria-disabled=true])):focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:calc(-1 * var(--lr-focus-ring-width))}[part=cell]:where(:not([aria-disabled=true])):active{outline:var(--lr-focus-ring-width) solid var(--lr-color-text);outline-offset:calc(-1 * var(--lr-focus-ring-width))}[part=cell][aria-disabled=true]{cursor:default;opacity:var(--lr-sequence-strip-disabled-opacity,var(--lr-opacity-disabled))}[part=cell][data-selected]{outline:var(--lr-focus-ring-width) solid var(--lr-color-text);outline-offset:calc(-1 * var(--lr-focus-ring-width))}[part=cell][data-selected]:focus-visible{outline-color:var(--lr-focus-ring-color)}[part=cell]:first-child{border-start-start-radius:var(--lr-radius-xs);border-end-start-radius:var(--lr-radius-xs)}[part=cell]:last-child{border-start-end-radius:var(--lr-radius-xs);border-end-end-radius:var(--lr-radius-xs)}[part=marker]{inline-size:100%;block-size:var(--lr-size-2px);background:var(--lr-sequence-strip-marker-color,var(--lr-color-text));display:block}[part=tooltip]{transform:translate(-50%, calc(-1 * var(--lr-size-6px)));padding:var(--lr-size-2px) var(--lr-size-6px);border-radius:var(--lr-radius);background:var(--lr-color-surface);color:var(--lr-color-text);font-size:var(--lr-font-size-xs);white-space:nowrap;box-shadow:var(--lr-shadow-m);pointer-events:none;z-index:var(--lr-layer-content);position:absolute;inset-block-end:100%;inset-inline-start:50%}:host(:dir(rtl)) [part=tooltip]{transform:translate(50%, calc(-1 * var(--lr-size-6px)))}[part=tooltip][hidden]{display:none}[part=legend]{align-items:center;gap:var(--lr-space-2xs) var(--lr-space-s);font-size:var(--lr-font-size-xs);color:var(--lr-color-text-quiet);flex-wrap:wrap;margin-block-start:var(--lr-space-xs);display:flex}[part=bucket-summary],[part=legend-limit]{color:var(--lr-color-text-quiet);font-size:var(--lr-font-size-xs);font-variant-numeric:tabular-nums}[part=bucket-summary]{text-align:end;margin-block-start:var(--lr-space-2xs)}[part=legend-item]{align-items:center;gap:var(--lr-space-2xs);min-inline-size:0;display:inline-flex}[part=legend-swatch],[part=legend-marker-swatch]{inline-size:var(--lr-sequence-strip-legend-swatch-size,var(--lr-size-0-625rem));block-size:var(--lr-sequence-strip-legend-swatch-size,var(--lr-size-0-625rem));border-radius:var(--lr-radius-xs);flex:none}[part=legend-marker-swatch]{background:var(--lr-sequence-strip-legend-marker-bg,var(--lr-color-surface-raised));box-shadow:inset 0 calc(-1 * var(--lr-size-2px)) 0 0 var(--lr-sequence-strip-marker-color,var(--lr-color-text))}[part=legend-label]{overflow-wrap:anywhere;min-inline-size:0}`;export{styles};
|
|
@@ -50,7 +50,7 @@ export interface TableSortRequestDetail{readonly phase:'request';readonly sortKe
|
|
|
50
50
|
/** Accepted sort transaction detail. */
|
|
51
51
|
export interface TableSortCommitDetail{readonly phase:'commit';readonly sortKey:string;readonly sortDir:TableSortDirection;}
|
|
52
52
|
/** One discriminated detail vocabulary shared across the sort request and commit phases. */
|
|
53
|
-
export type TableSortDetail=TableSortRequestDetail|TableSortCommitDetail;
|
|
53
|
+
export type TableSortDetail=TableSortRequestDetail|TableSortCommitDetail;interface TableColumnCommon<T>{key:string;label:string;
|
|
54
54
|
/** Renders custom content into this column's <th>, in place of the plain `label` text -- e.g. a
|
|
55
55
|
* drag-to-resize handle or an interactive header affordance. Omit for the default plain-text
|
|
56
56
|
* `label` rendering (unchanged output). Receives the column definition itself -- there is no
|
|
@@ -133,32 +133,57 @@ cellTitle?(row:T):string|undefined;
|
|
|
133
133
|
* that returns `background`/`backgroundColor` silently wins over this tint -- see `cellStyle`'s
|
|
134
134
|
* own doc for why. */
|
|
135
135
|
heatValue?(row:T):number|null|undefined;
|
|
136
|
-
/** Enables inline editing for this cell. `'double-click'` opens an editor on
|
|
137
|
-
* double-click, one cell at a time. `'always'` instead renders a persistent
|
|
138
|
-
* editor in every body cell of this column from first paint -- a
|
|
139
|
-
* settings/rate-style column the user is expected to type straight into.
|
|
140
|
-
* Either way the table emits the proposed value through `lr-cell-edit` and
|
|
141
|
-
* never mutates `row`; apply the change in the consumer and pass the updated
|
|
142
|
-
* `rows` back in.
|
|
143
|
-
*
|
|
144
|
-
* Persistent (`'always'`) editors are plain tab stops outside the roving
|
|
145
|
-
* header/row tabindex model, and bind their `value` as a content attribute,
|
|
146
|
-
* so native dirty-value-flag semantics apply: once the user has typed into
|
|
147
|
-
* one, an out-of-band `rows` update to that same cell no longer replaces
|
|
148
|
-
* what they are still editing. An untouched editor picks up a new `rows`
|
|
149
|
-
* value normally. */
|
|
150
|
-
editTrigger?:TableColumnEditTrigger;
|
|
151
136
|
/** Reads the value shown in the inline editor. When omitted, `row[key]` is
|
|
152
137
|
* used for record-like rows. For `editType: 'select'`, this is the selected option's
|
|
153
138
|
* `value` -- match one entry of `editOptions`, or none of them renders selected. */
|
|
154
139
|
editValue?:(row:T)=>string|number;
|
|
140
|
+
/** Accessible name (`aria-label`) for this row's inline editor, read once per row exactly like
|
|
141
|
+
* `editValue`/`cellTitle`. When omitted, every editor in the column shares the same interpolated
|
|
142
|
+
* `tableEditCell` name (`Edit {column}`) -- indistinguishable from its column siblings, which is
|
|
143
|
+
* harmless for `editTrigger: 'double-click'` (only one editor is ever open at a time) but not for
|
|
144
|
+
* `editTrigger: 'always'`, where each row's editor is a permanent, individually focusable Tab
|
|
145
|
+
* stop: an unset `editLabel` there leaves a keyboard or screen-reader user with no way to tell
|
|
146
|
+
* which row a given editor belongs to (WCAG 2.4.6, 1.3.1). Return the row's own full name (e.g.
|
|
147
|
+
* combining the column label with a row identifier) -- this is consumer-owned text like
|
|
148
|
+
* `cellTitle`/`editValue`, not passed through the table's own localization. */
|
|
149
|
+
editLabel?:(row:T)=>string;
|
|
155
150
|
/** Native editor type used when `editTrigger` is set. `'select'` renders a native `<select>`
|
|
156
151
|
* populated from `editOptions`, one `<option>` per entry in order; a `'select'` column with no
|
|
157
152
|
* `editOptions` renders an empty, valueless `<select>` rather than throwing. */
|
|
158
153
|
editType?:'text'|'number'|'select';
|
|
159
154
|
/** Choices offered by an `editType: 'select'` column's editor. Ignored for every other
|
|
160
155
|
* `editType`. */
|
|
161
|
-
editOptions?:TableColumnEditOption[];
|
|
156
|
+
editOptions?:TableColumnEditOption[];}
|
|
157
|
+
/** One column definition. `cell` is required for every `editTrigger` except `'always'` -- the
|
|
158
|
+
* table's render path calls it to paint that column's plain-text resting state, which an
|
|
159
|
+
* `'always'` column never has (its editor is unconditional from first paint, see `editTrigger`'s
|
|
160
|
+
* own doc). Supplying `cell` on an `'always'` column stays valid; it is simply never required. */
|
|
161
|
+
export type TableColumn<T> =(TableColumnCommon<T> &{
|
|
162
|
+
/** Enables inline editing for this cell, opened by a double-click or, once the cell holds
|
|
163
|
+
* keyboard focus (Tab/arrow into the row, then Right/Left onto the cell -- see the
|
|
164
|
+
* class-level keyboard doc), by `F2` or `Enter`. One editor is open at a time; the table
|
|
165
|
+
* emits the proposed value through `lr-cell-edit` and never mutates `row` -- apply the
|
|
166
|
+
* change in the consumer and pass the updated `rows` back in. Omit for a column with no
|
|
167
|
+
* inline editor at all. */
|
|
168
|
+
editTrigger?:'double-click';
|
|
169
|
+
/** Renders this cell's content. Required whenever the column can be in its plain-text
|
|
170
|
+
* resting state -- i.e. always, for a `'double-click'` or unset `editTrigger`. */
|
|
171
|
+
cell:(row:T)=>unknown;})|(TableColumnCommon<T> &{
|
|
172
|
+
/** `'always'` renders a persistent editor in every body cell of this column from first
|
|
173
|
+
* paint -- a settings/rate-style column the user is expected to type straight into. The
|
|
174
|
+
* table emits the proposed value through `lr-cell-edit` and never mutates `row`.
|
|
175
|
+
*
|
|
176
|
+
* These editors are plain tab stops outside the roving header/row/cell tabindex model, and
|
|
177
|
+
* bind their `value` as a content attribute, so native dirty-value-flag semantics apply:
|
|
178
|
+
* once the user has typed into one, an out-of-band `rows` update to that same cell no
|
|
179
|
+
* longer replaces what they are still editing. An untouched editor picks up a new `rows`
|
|
180
|
+
* value normally. */
|
|
181
|
+
editTrigger:'always';
|
|
182
|
+
/** Omittable for this `editTrigger: 'always'` arm: the persistent editor renders
|
|
183
|
+
* unconditionally, so the table's render path never falls back to this renderer. Still
|
|
184
|
+
* consulted as the `sortValue`-less sort fallback when `sortable` is set -- define
|
|
185
|
+
* `sortValue` on such a column instead of relying on this being present. */
|
|
186
|
+
cell?:(row:T)=>unknown;});
|
|
162
187
|
/** Every event `<lr-table>` emits. `K` is the row-key type the element was parameterized with
|
|
163
188
|
* (`LyraTable<Row, number>` -> `rowKey: number` in every detail below), defaulting to the
|
|
164
189
|
* `string | number` union an unparameterized table has always carried. */
|
|
@@ -201,6 +226,21 @@ export interface LyraTableEventMap<T=unknown,K extends string|number=string|numb
|
|
|
201
226
|
* clamps to the nearest surviving index; an update never reclaims focus once
|
|
202
227
|
* the user has moved it outside the table. Effective locale changes use the same current
|
|
203
228
|
* page identity for activation, editing, and direct row-focus restoration.
|
|
229
|
+
*
|
|
230
|
+
* A column with `editTrigger: 'double-click'` additionally gives its own resting cell a
|
|
231
|
+
* `tabindex="-1"` roving-focus stop — reachable, once the row itself has focus, with ArrowRight
|
|
232
|
+
* (ArrowLeft under RTL) to enter at the first editable cell in the row and step forward, ArrowLeft
|
|
233
|
+
* (ArrowRight under RTL) to step back and, from the first editable cell, return focus to the row —
|
|
234
|
+
* never through Tab, so a table with one or more editable columns gains no new Tab stop, only a
|
|
235
|
+
* new arrow-reachable one, and a table with none renders no `tabindex`/`part='cell'[data-editable]`
|
|
236
|
+
* at all. `F2` or `Enter` on that focused cell opens its editor (`startEditing()`); `editCell()` is
|
|
237
|
+
* the same effect as a public method, for a consumer's own key binding, menu action, or other
|
|
238
|
+
* trigger. `Enter` on the row itself (not a focused cell) still only activates the row, exactly as
|
|
239
|
+
* before — the two coexist because the table tells them apart from which of the two currently has
|
|
240
|
+
* focus, not from the key alone. Escape and Enter inside the open editor keep cancelling/committing
|
|
241
|
+
* as already documented below; either one now also returns focus to the cell that opened it (the
|
|
242
|
+
* editor's own DOM node is what closes), matching a conventional grid's F2/Escape contract and
|
|
243
|
+
* closing the WCAG 2.1.1 (Keyboard) gap a pointer-only `double-click` trigger otherwise leaves.
|
|
204
244
|
* Priority-hidden columns hide their header, body, and footer cells together; revealing
|
|
205
245
|
* priority columns restores all three bands.
|
|
206
246
|
* Blank and later-duplicate column keys are omitted first-wins at assignment. Rows retain their
|
|
@@ -305,7 +345,8 @@ export interface LyraTableEventMap<T=unknown,K extends string|number=string|numb
|
|
|
305
345
|
* loading appearance appends to the shared light-DOM polite sink — including repeated cycles —
|
|
306
346
|
* while every placeholder opts out of `<lr-skeleton>`'s own announcement.
|
|
307
347
|
* Columns with `editTrigger: 'double-click'` open a native text/number/select editor on
|
|
308
|
-
* double-click
|
|
348
|
+
* double-click, `F2`, or `Enter` on the cell's own roving focus stop (see the keyboard paragraph
|
|
349
|
+
* above), and emit `lr-cell-edit`; row mutation remains consumer-owned. `editType: 'select'`
|
|
309
350
|
* renders a native `<select>` populated from `editOptions` (`{ value, label }[]`) instead of an
|
|
310
351
|
* `<input>` -- a column with no `editOptions` renders an empty, valueless `<select>` rather than
|
|
311
352
|
* throwing. `editTrigger: 'always'` instead renders that editor in every body cell of the
|
|
@@ -321,6 +362,12 @@ export interface LyraTableEventMap<T=unknown,K extends string|number=string|numb
|
|
|
321
362
|
* `editType: 'select'` editor has no such native protection -- `<select>`/`<option>` carry no
|
|
322
363
|
* dirty-value flag, so an out-of-band `rows` update to that cell re-applies the selection even
|
|
323
364
|
* after the user has picked a different option.
|
|
365
|
+
* Each editor's accessible name is `columns[].editLabel(row)` when the column defines it, or
|
|
366
|
+
* otherwise the interpolated `tableEditCell` string (`Edit {column}`) -- the same name for every
|
|
367
|
+
* row in that column, since the default carries no row context. Define `editLabel` for any
|
|
368
|
+
* `editTrigger: 'always'` column: its editors are permanent, individually focusable Tab stops, so
|
|
369
|
+
* leaving every one of them identically named (e.g. fifty "Edit Status" controls) fails WCAG 2.4.6
|
|
370
|
+
* and 1.3.1 for keyboard and screen-reader users.
|
|
324
371
|
* Focus is restored across a re-sort that moves the editor's node, and dropped
|
|
325
372
|
* (never re-aimed at an unrelated row) when its row leaves the rendered page.
|
|
326
373
|
* `spellcheck`/`autocapitalize`/`autoCorrect` forward to the filter input and, for a `'text'`
|
|
@@ -433,7 +480,9 @@ export interface LyraTableEventMap<T=unknown,K extends string|number=string|numb
|
|
|
433
480
|
* numeric ARIA range remains in CSS pixels while `aria-valuetext` reports the current value
|
|
434
481
|
* through the effective locale.
|
|
435
482
|
* @csspart row - Each body `<tr>`.
|
|
436
|
-
* @csspart cell - Each body `<td>`.
|
|
483
|
+
* @csspart cell - Each body `<td>`. An `editTrigger: 'double-click'` column's resting (not
|
|
484
|
+
* currently editing) cell additionally carries `[data-editable]` and its own `tabindex="-1"`
|
|
485
|
+
* roving-focus stop -- see the keyboard paragraph above.
|
|
437
486
|
* @csspart row-total-cell - Each body row's trailing `<td>` holding `rowTotal(row)`, rendered only
|
|
438
487
|
* when `rowTotal` is set. The corresponding footer-row cell (holding `grandTotal`) is a
|
|
439
488
|
* `footer-cell` instead, matching every other footer cell.
|
|
@@ -754,6 +803,16 @@ expandedContent?:(row:T)=>unknown;
|
|
|
754
803
|
* alignment) but it renders empty — no button, no `aria-expanded`, no
|
|
755
804
|
* click handler. */
|
|
756
805
|
canExpand?:(row:T)=>boolean;
|
|
806
|
+
/** Accessible name for one row's expand/collapse chevron, read once per render for that row,
|
|
807
|
+
* exactly like a column's `editLabel`/`cellTitle`. Consumer-owned text: it is used verbatim and
|
|
808
|
+
* never passed through the localization runtime.
|
|
809
|
+
*
|
|
810
|
+
* Omit it and every chevron in the table shares the same localized `expand`/`collapse` name,
|
|
811
|
+
* which carries no row context. That is fine for a handful of rows, but each chevron is its own
|
|
812
|
+
* Tab stop, so a long table otherwise announces the same two names over and over with no way to
|
|
813
|
+
* tell the rows apart. There is no default row context to add here: this component has no
|
|
814
|
+
* row-header notion to derive one from (`rowKey` is an opaque identity, not a label). */
|
|
815
|
+
rowExpandLabel?:(row:T,expanded:boolean)=>string;
|
|
757
816
|
/** Open/closed state, bounded to 10,000 keys and keyed the same way as `rowKey`/
|
|
758
817
|
* `selectedRowKeys`. Under the default `expansionMode: 'none'` the table never mutates this
|
|
759
818
|
* itself — it only reads it to decide which rows currently render `expandedContent`, and the
|
|
@@ -932,7 +991,25 @@ private observedTable?;private readonly observedHeaders;
|
|
|
932
991
|
* reconnect's first measurement pass re-hides from a stale-but-still-reasonable cached width
|
|
933
992
|
* sooner than it otherwise could, and a genuinely stale entry self-corrects the next time that
|
|
934
993
|
* tier is visible. */
|
|
935
|
-
private readonly priorityTierNaturalWidth;
|
|
994
|
+
private readonly priorityTierNaturalWidth;
|
|
995
|
+
/** Last-measured natural (unstretched) rendered width of every ALWAYS-visible (no `priority`)
|
|
996
|
+
* header combined, mirroring `priorityTierNaturalWidth` above for the one group that is never
|
|
997
|
+
* itself hidden. It exists for the same reason: once any tier is hidden, `[part='table']`'s own
|
|
998
|
+
* `inline-size: 100%` (table.styles.ts) makes the browser's auto table layout stretch every
|
|
999
|
+
* still-rendered column to fill whatever room the hidden ones vacated, so `[part='base']`'s own
|
|
1000
|
+
* `scrollWidth` stops carrying the always-visible group's true content width and starts tracking
|
|
1001
|
+
* `clientWidth` instead -- reconstructing "how wide would everything be" from that stretched
|
|
1002
|
+
* number silently turns "would the full set fit" into "does the CURRENT container happen to have
|
|
1003
|
+
* spare room", which never re-admits a hidden tier once the remainder alone fits any container.
|
|
1004
|
+
* Refreshed only on a pass where `[part='base']` is genuinely too wide for its container
|
|
1005
|
+
* (`scrollWidth - clientWidth` exceeds the tolerance, computed from whatever the previous pass
|
|
1006
|
+
* left rendered) -- the one condition under which nothing on screen has spare room to stretch
|
|
1007
|
+
* into, so every currently-rendered header's own rect reports its real content width. That
|
|
1008
|
+
* condition necessarily holds on the pass that first decides to hide anything (the hide decision
|
|
1009
|
+
* itself requires it), so this is always populated before `recomputeHiddenPriorityColumns()` ever
|
|
1010
|
+
* needs it for a widening pass, and a stale entry only lingers while nothing overflows -- exactly
|
|
1011
|
+
* when substituting it for a live, potentially-stretched reading is the correction, not a risk. */
|
|
1012
|
+
private alwaysVisibleNaturalWidth;private parsePixelLength;
|
|
936
1013
|
/** The themed floor a column may be dragged/keyed down to, in used pixels. `rem`/`em` resolve
|
|
937
1014
|
* against the live root/own font size through the shared `resolveCssLength()` -- a hardcoded
|
|
938
1015
|
* `* 16` would pick the wrong floor on a page whose root font-size isn't the browser default.
|
|
@@ -961,14 +1038,14 @@ private priorityTierHeaders;
|
|
|
961
1038
|
* its `clientWidth` -- with `syncAutoScrollMode()`'s `scroll-mode="auto"` check, so the two
|
|
962
1039
|
* responsive systems key off the same measurement instead of disagreeing about whether the table
|
|
963
1040
|
* is actually too wide for its container. A tier hides only once hiding it would actually help:
|
|
964
|
-
* `'low'` first (reconstructing the fully-visible width from
|
|
965
|
-
*
|
|
966
|
-
*
|
|
967
|
-
*
|
|
968
|
-
*
|
|
969
|
-
*
|
|
970
|
-
*
|
|
971
|
-
*
|
|
1041
|
+
* `'low'` first (reconstructing the fully-visible width from every group's cached natural width
|
|
1042
|
+
* below), then `'medium'` on top of that if the table would still overflow with just `'low'` gone.
|
|
1043
|
+
* Writing the same decision this function already reached is a no-op `toggleAttribute()` call,
|
|
1044
|
+
* which keeps the `ResizeObserver` round-trip this triggers (hiding a column changes
|
|
1045
|
+
* `[part='base']`'s/`[part='table']`'s own measured size) a fixed point rather than a layout
|
|
1046
|
+
* thrash: the next pass reconstructs the same full width from the same cached natural widths,
|
|
1047
|
+
* reaches the same decision, and writes nothing further -- in either direction, hiding or
|
|
1048
|
+
* restoring. Called from `updated()` (covers a change driven by
|
|
972
1049
|
* `columns`/`rows`/`priorityColumnsVisible` rather than a container resize) and
|
|
973
1050
|
* from the `ResizeObserver` callback (covers a container resize with no
|
|
974
1051
|
* Lit-tracked property change at all). */
|
|
@@ -1153,6 +1230,19 @@ rowElement(rowKey:K):HTMLElement|null;
|
|
|
1153
1230
|
* which is exactly what the cell's public `data-col-key` attribute carries. Same
|
|
1154
1231
|
* `updateComplete` contract as {@link rowElement}. */
|
|
1155
1232
|
cellElement(rowKey:K,columnKey:string):HTMLElement|null;
|
|
1233
|
+
/** Opens the inline editor at one `(rowKey, columnKey)` pair -- the imperative entry point behind
|
|
1234
|
+
* the `F2`/`Enter` keyboard shortcuts (`onRowKeyDown`) and the double-click pointer path
|
|
1235
|
+
* (`onTableDoubleClick`), for a consumer that wants to bind its own key, menu action, or other
|
|
1236
|
+
* trigger to the same effect. A no-op, not a throw, for an unknown row key, an unknown column
|
|
1237
|
+
* key, or a column with no `editTrigger` at all -- exactly `startEditing`'s own guard, so this
|
|
1238
|
+
* never opens a second, competing editor and never targets a column that has no editor to open.
|
|
1239
|
+
*
|
|
1240
|
+
* An `editTrigger: 'always'` column's editor is already open from first paint, so there is
|
|
1241
|
+
* nothing to *start*; this instead moves focus into that column's already-rendered editor,
|
|
1242
|
+
* mirroring what `F2`/`Enter`/double-click do for a `'double-click'` column. Fire-and-forget --
|
|
1243
|
+
* await `table.updateComplete` first if the newly-opened editor needs to be read back
|
|
1244
|
+
* synchronously afterward (e.g. via {@link cellElement}). */
|
|
1245
|
+
editCell(rowKey:K,columnKey:string):void;
|
|
1156
1246
|
/** The rendered `[part='expanded-cell']` holding one row's `expandedContent(row)` output, or
|
|
1157
1247
|
* `null` when that row is not currently rendered, is not expanded, or renders no panel at all.
|
|
1158
1248
|
* {@link rowElement} deliberately cannot reach this: the panel is a *sibling* `<tr>` of the data
|
|
@@ -1172,7 +1262,42 @@ private rowElementForToken;private cellElementForToken;
|
|
|
1172
1262
|
* that `.focus()` would silently no-op on. Scoped to `th` — body `<td>`s
|
|
1173
1263
|
* now carry the same `data-col-key` attribute (for the sticky-offset
|
|
1174
1264
|
* measurement pass) but must never be treated as header cells here. */
|
|
1175
|
-
private visibleHeaders;private focusHeader;private focusRow;private toggleColumns;private onTableClick;private onTableKeyDown;private onHeaderKeyDown;
|
|
1265
|
+
private visibleHeaders;private focusHeader;private focusRow;private toggleColumns;private onTableClick;private onTableKeyDown;private onHeaderKeyDown;
|
|
1266
|
+
/** The editable (`editTrigger: 'double-click'`) `<td>` that owns `target`, if any -- i.e. `target`
|
|
1267
|
+
* itself is that cell, since it is the only body-cell shape that ever carries a `tabindex` (see
|
|
1268
|
+
* the render template). Used to tell "a row's own keydown" apart from "a keydown on the row's
|
|
1269
|
+
* own cell-level focus stop" without a second piece of `@state`: the answer is recomputed from
|
|
1270
|
+
* `e.target` on every keydown instead of tracked. */
|
|
1271
|
+
private editableCellFor;
|
|
1272
|
+
/** This row's own editable cells, in DOM (visual, LTR) order, skipping one a priority-collapse
|
|
1273
|
+
* hid (`offsetParent === null`, matching `visibleHeaders()`) or an inert ancestor would refuse
|
|
1274
|
+
* `focus()` on silently (matching `lr-menu`'s `isNavigable()` shape) -- so ArrowLeft/ArrowRight
|
|
1275
|
+
* below can never strand the cell-level focus stop on a target that cannot actually take it. */
|
|
1276
|
+
private editableCellsInRow;
|
|
1277
|
+
/** `tr` is always the row that owns the keydown -- resolved by the delegated caller via
|
|
1278
|
+
* `closest('[data-row-key]')` -- regardless of whether `e.target` is the row itself or one of
|
|
1279
|
+
* its own editable cells, so every branch below that reads `tr` (the roving ArrowUp/ArrowDown/
|
|
1280
|
+
* Home/End switch) keeps working unchanged from a cell-focused keydown, with zero code of its
|
|
1281
|
+
* own aware that cell-level focus exists. Only Enter/F2 (open an editor) and Space (still always
|
|
1282
|
+
* row activation, on a cell exactly as on the row -- neither key is part of the conventional
|
|
1283
|
+
* grid editing idiom) need to know which of the two actually has focus, via `editableCellFor`. */
|
|
1284
|
+
private onRowKeyDown;
|
|
1285
|
+
/** ArrowLeft/ArrowRight roving between a row's own tab stop and its editable cells -- the
|
|
1286
|
+
* smallest addition that keeps the row's existing ArrowUp/ArrowDown/Home/End roving (above)
|
|
1287
|
+
* fully authoritative: this only ever moves focus sideways, within the current row, and a row
|
|
1288
|
+
* with no editable cell keeps its pre-existing behavior exactly (neither arrow key did anything
|
|
1289
|
+
* at the row level before this method existed, so `cells.length === 0` intentionally leaves the
|
|
1290
|
+
* key unhandled rather than calling `preventDefault()`).
|
|
1291
|
+
*
|
|
1292
|
+
* Direction is visual, not literal, matching `onHeaderKeyDown`'s own `isRtl()` mirroring: under
|
|
1293
|
+
* RTL, ArrowLeft moves toward the visual end (forward) and ArrowRight toward the visual start
|
|
1294
|
+
* (backward). From the row itself (`cell === null`), the forward key enters at the first
|
|
1295
|
+
* editable cell and the backward key enters at the last, so a table with editable columns on
|
|
1296
|
+
* both a left- and right-heavy layout is reachable from either direction. From a cell, the
|
|
1297
|
+
* backward key at the first editable cell returns focus to the row (mirroring the header's own
|
|
1298
|
+
* "ArrowUp from the first body row returns to the header" boundary); the forward key at the last
|
|
1299
|
+
* editable cell simply stays put, matching the header's own clamped ends. */
|
|
1300
|
+
private onRowLateralKeyDown;
|
|
1176
1301
|
/** One body cell's inline editor.
|
|
1177
1302
|
*
|
|
1178
1303
|
* For `editType: 'text'`/`'number'`, the persistent (`editTrigger: 'always'`) and double-click
|
|
@@ -1237,4 +1362,4 @@ private renderErrorContent;
|
|
|
1237
1362
|
* stay visually and structurally consistent, plus the built-in retry affordance -- but unlike
|
|
1238
1363
|
* either data-empty branch in `render()`, the caller keeps `<thead>`, the filter field, and
|
|
1239
1364
|
* pagination mounted around this row instead of replacing them too. */
|
|
1240
|
-
private renderErrorRow;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-table':LyraTable;}}
|
|
1365
|
+
private renderErrorRow;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-table':LyraTable;}}export{};
|