@vonage/vivid 4.25.0 → 4.27.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/custom-elements.json +3371 -1999
- package/lib/accordion-item/accordion-item.d.ts +2 -2
- package/lib/action-group/action-group.d.ts +1 -1
- package/lib/alert/alert.d.ts +5 -5
- package/lib/audio-player/audio-player.d.ts +3 -3
- package/lib/avatar/avatar.d.ts +393 -1
- package/lib/avatar/avatar.template.d.ts +2 -2
- package/lib/badge/badge.d.ts +2 -2
- package/lib/banner/banner.d.ts +6 -6
- package/lib/breadcrumb/breadcrumb.d.ts +1 -1
- package/lib/breadcrumb-item/breadcrumb-item.d.ts +1 -1
- package/lib/button/button.d.ts +6 -6
- package/lib/calendar/calendar.d.ts +2 -0
- package/lib/calendar-event/calendar-event.d.ts +1 -1
- package/lib/card/card.d.ts +1 -1
- package/lib/checkbox/checkbox.d.ts +10 -10
- package/lib/combobox/combobox.d.ts +11 -11
- package/lib/data-grid/data-grid-cell.d.ts +6 -4
- package/lib/data-grid/data-grid-row.d.ts +1 -0
- package/lib/data-grid/data-grid.d.ts +1 -1
- package/lib/date-picker/date-picker.d.ts +75 -75
- package/lib/date-picker/date-picker.template.d.ts +1 -1
- package/lib/date-range-picker/date-range-picker.d.ts +44 -44
- package/lib/date-range-picker/date-range-picker.template.d.ts +1 -1
- package/lib/date-time-picker/date-time-picker.d.ts +64 -64
- package/lib/date-time-picker/date-time-picker.template.d.ts +1 -1
- package/lib/dial-pad/dial-pad.d.ts +3 -3
- package/lib/dialog/dialog.d.ts +5 -4
- package/lib/divider/divider.d.ts +1 -1
- package/lib/fab/fab.d.ts +2 -2
- package/lib/file-picker/file-picker.d.ts +10 -10
- package/lib/header/header.d.ts +1 -1
- package/lib/menu/menu.d.ts +2 -2
- package/lib/menu-item/menu-item.d.ts +3 -3
- package/lib/nav/nav.d.ts +1 -1
- package/lib/nav-disclosure/nav-disclosure.d.ts +3 -3
- package/lib/nav-item/nav-item.d.ts +3 -3
- package/lib/note/note.d.ts +2 -2
- package/lib/number-field/locale.d.ts +3 -2
- package/lib/number-field/number-field.d.ts +15 -15
- package/lib/option/option.d.ts +3 -3
- package/lib/pagination/locale.d.ts +5 -0
- package/lib/pagination/pagination.d.ts +341 -2
- package/lib/popup/popup.d.ts +1 -0
- package/lib/progress/progress.d.ts +1 -1
- package/lib/progress-ring/progress-ring.d.ts +1 -1
- package/lib/radio/radio.d.ts +3 -3
- package/lib/radio-group/radio-group.d.ts +4 -4
- package/lib/range-slider/range-slider.d.ts +5 -5
- package/lib/rich-text-editor/menubar/menubar.d.ts +3 -3
- package/lib/rich-text-editor/rich-text-editor.d.ts +3 -3
- package/lib/searchable-select/locale.d.ts +1 -1
- package/lib/searchable-select/option-tag.d.ts +3 -3
- package/lib/searchable-select/searchable-select.d.ts +15 -15
- package/lib/select/select.d.ts +12 -12
- package/lib/selectable-box/selectable-box.d.ts +1 -1
- package/lib/slider/slider.d.ts +5 -5
- package/lib/split-button/split-button.d.ts +6 -6
- package/lib/switch/switch.d.ts +2 -2
- package/lib/tab/tab.d.ts +6 -6
- package/lib/tab-panel/tab-panel.d.ts +1 -1
- package/lib/tag/locale.d.ts +3 -0
- package/lib/tag/tag.d.ts +343 -6
- package/lib/tag-group/tag-group.d.ts +1 -1
- package/lib/text-area/text-area.d.ts +14 -14
- package/lib/text-field/text-field.d.ts +16 -16
- package/lib/time-picker/time-picker.d.ts +21 -21
- package/lib/toggletip/toggletip.d.ts +1 -1
- package/lib/tooltip/tooltip.d.ts +1 -1
- package/lib/tree-item/tree-item.d.ts +3 -3
- package/lib/tree-view/tree-view.d.ts +1 -1
- package/lib/video-player/video-player.d.ts +3 -3
- package/locales/de-DE.cjs +40 -5
- package/locales/de-DE.js +40 -5
- package/locales/en-GB.cjs +40 -5
- package/locales/en-GB.js +40 -5
- package/locales/en-US.cjs +40 -5
- package/locales/en-US.js +40 -5
- package/locales/ja-JP.cjs +40 -5
- package/locales/ja-JP.js +40 -5
- package/locales/zh-CN.cjs +40 -5
- package/locales/zh-CN.js +40 -5
- package/package.json +73 -45
- package/shared/aria/delegates-aria.d.ts +1 -1
- package/shared/aria/host-semantics.d.ts +1 -1
- package/shared/calendar-picker.template.cjs +40 -13
- package/shared/calendar-picker.template.js +40 -13
- package/shared/definition.cjs +19 -3
- package/shared/definition.js +20 -4
- package/shared/definition11.cjs +1 -1
- package/shared/definition11.js +1 -1
- package/shared/definition13.cjs +25 -0
- package/shared/definition13.js +26 -1
- package/shared/definition15.cjs +1 -1
- package/shared/definition15.js +1 -1
- package/shared/definition16.cjs +1 -1
- package/shared/definition16.js +1 -1
- package/shared/definition17.cjs +602 -522
- package/shared/definition17.js +600 -520
- package/shared/definition18.cjs +8 -1
- package/shared/definition18.js +8 -1
- package/shared/definition19.cjs +9 -2
- package/shared/definition19.js +9 -2
- package/shared/definition2.cjs +1 -1
- package/shared/definition2.js +1 -1
- package/shared/definition20.cjs +3 -1
- package/shared/definition20.js +3 -1
- package/shared/definition21.cjs +2 -2
- package/shared/definition21.js +2 -2
- package/shared/definition22.cjs +9 -3
- package/shared/definition22.js +9 -3
- package/shared/definition28.cjs +2 -2
- package/shared/definition28.js +2 -2
- package/shared/definition3.cjs +1 -1
- package/shared/definition3.js +1 -1
- package/shared/definition30.cjs +1 -1
- package/shared/definition30.js +1 -1
- package/shared/definition31.cjs +1 -1
- package/shared/definition31.js +1 -1
- package/shared/definition32.cjs +1 -1
- package/shared/definition32.js +1 -1
- package/shared/definition36.cjs +41 -30
- package/shared/definition36.js +34 -23
- package/shared/definition38.cjs +30 -23
- package/shared/definition38.js +30 -23
- package/shared/definition4.cjs +1 -1
- package/shared/definition4.js +1 -1
- package/shared/definition41.cjs +1 -1
- package/shared/definition41.js +1 -1
- package/shared/definition42.cjs +2 -2
- package/shared/definition42.js +2 -2
- package/shared/definition44.cjs +129 -117
- package/shared/definition44.js +130 -118
- package/shared/definition45.cjs +17 -7
- package/shared/definition45.js +17 -7
- package/shared/definition46.cjs +1 -1
- package/shared/definition46.js +1 -1
- package/shared/definition49.cjs +6 -6
- package/shared/definition49.js +6 -6
- package/shared/definition54.cjs +2 -2
- package/shared/definition54.js +2 -2
- package/shared/definition56.cjs +5 -4
- package/shared/definition56.js +5 -4
- package/shared/definition57.cjs +1 -1
- package/shared/definition57.js +1 -1
- package/shared/definition58.cjs +1 -1
- package/shared/definition58.js +1 -1
- package/shared/definition59.cjs +3 -1
- package/shared/definition59.js +3 -1
- package/shared/definition6.cjs +45 -12
- package/shared/definition6.js +45 -12
- package/shared/definition63.cjs +2 -2
- package/shared/definition63.js +2 -2
- package/shared/definition64.cjs +136 -38
- package/shared/definition64.js +136 -38
- package/shared/definition67.cjs +36 -15
- package/shared/definition67.js +37 -16
- package/shared/feedback/feedback-message.d.ts +1 -1
- package/shared/feedback/mixins.d.ts +2 -2
- package/shared/form-associated.cjs +4 -0
- package/shared/form-associated.js +4 -0
- package/shared/foundation/button/button.d.ts +1 -1
- package/shared/foundation/vivid-element/vivid-element.d.ts +2 -0
- package/shared/key-codes.js +1 -1
- package/shared/localization/Locale.d.ts +4 -0
- package/shared/mixins.cjs +4 -1
- package/shared/mixins.js +4 -1
- package/shared/patterns/affix.d.ts +2 -2
- package/shared/patterns/char-count/char-count.d.ts +1 -1
- package/shared/patterns/form-elements/with-success-text.d.ts +1 -1
- package/shared/patterns/linkable.d.ts +1 -1
- package/shared/patterns/localized.d.ts +1 -1
- package/shared/patterns/trapped-focus.d.ts +1 -1
- package/shared/picker-field/mixins/calendar-picker.d.ts +2 -2
- package/shared/picker-field/mixins/calendar-picker.locale.d.ts +5 -0
- package/shared/picker-field/mixins/calendar-picker.template.d.ts +2 -2
- package/shared/picker-field/mixins/calendar-segments/segment.d.ts +1 -0
- package/shared/picker-field/mixins/inline-time-picker/inline-time-picker.d.ts +1 -1
- package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +4 -4
- package/shared/picker-field/mixins/single-date-picker.d.ts +4 -4
- package/shared/picker-field/mixins/single-value-picker.d.ts +1 -1
- package/shared/picker-field/mixins/time-selection-picker.d.ts +2 -2
- package/shared/picker-field/mixins/time-selection-picker.template.d.ts +2 -2
- package/shared/picker-field/picker-field.d.ts +3 -3
- package/shared/picker-field.template.cjs +13 -13
- package/shared/picker-field.template.js +13 -13
- package/shared/vivid-element.cjs +11 -1
- package/shared/vivid-element.js +11 -1
- package/styles/core/all.css +5 -5
- package/styles/core/theme.css +2 -2
- package/styles/core/typography.css +4 -4
- package/styles/fonts/spezia-variable.css +15 -15
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/vivid.api.json +395 -277
package/shared/definition17.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { I as Icon, i as iconDefinition } from './definition28.js';
|
|
2
|
-
import {
|
|
2
|
+
import { h as html, V as VividElement, a as attr, o as observable, D as DOM, O as Observable, d as createRegisterFunction, f as defineVividComponent } from './vivid-element.js';
|
|
3
3
|
import { V as VisuallyHidden, v as visuallyHiddenDefinition } from './definition66.js';
|
|
4
|
+
import { b as keyEscape, j as keyFunction2, k as keyEnter, d as keyEnd, g as keyHome, h as keyArrowRight, i as keyArrowLeft, l as keyPageDown, m as keyPageUp, f as keyArrowDown, e as keyArrowUp, a as keySpace } from './key-codes.js';
|
|
4
5
|
import { R as RepeatDirective } from './repeat.js';
|
|
5
|
-
import { d as keyEnd, g as keyHome, j as keyPageDown, l as keyPageUp, f as keyArrowDown, e as keyArrowUp, h as keyArrowRight, i as keyArrowLeft, b as keyEscape, m as keyFunction2, k as keyEnter, a as keySpace } from './key-codes.js';
|
|
6
6
|
import { c as children } from './children.js';
|
|
7
7
|
import { s as slotted, e as elements } from './slotted.js';
|
|
8
8
|
import { L as Localized } from './localized.js';
|
|
9
|
+
import { c as classNames } from './class-names.js';
|
|
9
10
|
import { w as when } from './when.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -19,9 +20,9 @@ const eventKeyDown = "keydown";
|
|
|
19
20
|
|
|
20
21
|
const dataGridStyles = ":host{display:block}:host([generate-header=sticky]){max-block-size:400px}.base{--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.base{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.base ::-webkit-scrollbar{width:4px}.base ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.base ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-fallback-track-color, var(--scrollbar-thumb-color))}.base{position:relative;overflow:auto;block-size:inherit;inline-size:100%;max-block-size:inherit}";
|
|
21
22
|
|
|
22
|
-
const dataGridRowStyles = ".base.connotation-cta{--_connotation-color-primary: var(--vvd-data-grid-row-cta-primary, var(--vvd-color-cta-500));--_connotation-color-primary-text: var(--vvd-data-grid-row-cta-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-data-grid-row-cta-primary-increment, var(--vvd-color-cta-600));--_connotation-color-firm: var(--vvd-data-grid-row-cta-firm, var(--vvd-color-cta-600));--_connotation-color-faint: var(--vvd-data-grid-row-cta-faint, var(--vvd-color-cta-50));--_connotation-color-soft: var(--vvd-data-grid-row-cta-soft, var(--vvd-color-cta-100));--_connotation-color-pale: var(--vvd-data-grid-row-cta-pale, var(--vvd-color-cta-300));--_connotation-color-dim: var(--vvd-data-grid-row-cta-dim, var(--vvd-color-cta-200))}.base:not(.connotation-cta){--_connotation-color-primary: var(--vvd-data-grid-row-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-data-grid-row-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-data-grid-row-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-firm: var(--vvd-data-grid-row-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-faint: var(--vvd-data-grid-row-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-data-grid-row-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-pale: var(--vvd-data-grid-row-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-dim: var(--vvd-data-grid-row-accent-dim, var(--vvd-color-neutral-200))}.base{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.base:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.base:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-dim);--_appearance-color-outline: transparent}.base{display:grid;width:100%;box-sizing:border-box;color:var(--vvd-color-canvas-text)}:host([row-type=sticky-header]) .base{position:sticky;z-index:9;top:0;background:var(--data-grid-row-background, var(--vvd-color-canvas))}:host([row-type=hidden-header]) .base{display:none}:host(:is([
|
|
23
|
+
const dataGridRowStyles = ".base.connotation-cta{--_connotation-color-primary: var(--vvd-data-grid-row-cta-primary, var(--vvd-color-cta-500));--_connotation-color-primary-text: var(--vvd-data-grid-row-cta-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-data-grid-row-cta-primary-increment, var(--vvd-color-cta-600));--_connotation-color-firm: var(--vvd-data-grid-row-cta-firm, var(--vvd-color-cta-600));--_connotation-color-faint: var(--vvd-data-grid-row-cta-faint, var(--vvd-color-cta-50));--_connotation-color-soft: var(--vvd-data-grid-row-cta-soft, var(--vvd-color-cta-100));--_connotation-color-pale: var(--vvd-data-grid-row-cta-pale, var(--vvd-color-cta-300));--_connotation-color-dim: var(--vvd-data-grid-row-cta-dim, var(--vvd-color-cta-200))}.base:not(.connotation-cta){--_connotation-color-primary: var(--vvd-data-grid-row-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-data-grid-row-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-data-grid-row-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-firm: var(--vvd-data-grid-row-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-faint: var(--vvd-data-grid-row-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-data-grid-row-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-pale: var(--vvd-data-grid-row-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-dim: var(--vvd-data-grid-row-accent-dim, var(--vvd-color-neutral-200))}.base{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.base:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.base:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-dim);--_appearance-color-outline: transparent}.base{display:grid;width:100%;box-sizing:border-box;color:var(--vvd-color-canvas-text)}:host([row-type=sticky-header]) .base{position:sticky;z-index:9;top:0;background:var(--data-grid-row-background, var(--vvd-color-canvas))}:host([row-type=hidden-header]) .base{display:none}:host(:is([selected]):not([row-type*=header])) .base{background-color:var(--_appearance-color-fill)}";
|
|
23
24
|
|
|
24
|
-
const dataGridCellStyles = ":host{block-size:100%;min-inline-size:80px}:host(:focus-visible){outline:none}.base.connotation-cta{--_connotation-color-primary: var(--vvd-data-grid-cell-cta-primary, var(--vvd-color-cta-500));--_connotation-color-primary-text: var(--vvd-data-grid-cell-cta-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-data-grid-cell-cta-primary-increment, var(--vvd-color-cta-600));--_connotation-color-firm: var(--vvd-data-grid-cell-cta-firm, var(--vvd-color-cta-600));--_connotation-color-soft: var(--vvd-data-grid-cell-cta-soft, var(--vvd-color-cta-100));--_connotation-color-faint: var(--vvd-data-grid-cell-cta-faint, var(--vvd-color-cta-50));--_connotation-color-pale: var(--vvd-data-grid-cell-cta-pale, var(--vvd-color-cta-300));--_connotation-color-dim: var(--vvd-data-grid-cell-cta-dim, var(--vvd-color-cta-200))}.base:not(.connotation-cta){--_connotation-color-primary: var(--vvd-data-grid-cell-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-data-grid-cell-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-data-grid-cell-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-firm: var(--vvd-data-grid-cell-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-soft: var(--vvd-data-grid-cell-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-faint: var(--vvd-data-grid-cell-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-pale: var(--vvd-data-grid-cell-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-dim: var(--vvd-data-grid-cell-accent-dim, var(--vvd-color-neutral-200))}.base{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.base:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.base:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-dim);--_appearance-color-outline: transparent}.base{display:flex;box-sizing:border-box;align-items:center;border-bottom:1px solid var(--vvd-color-neutral-300);block-size:var(--data-grid-cell-block-size, var(--_data-grid-cell-default-block-size));color:var(--_appearance-color-text);font:var(--vvd-typography-base);min-block-size:calc(1px*(48 + 4*clamp(-1,var(--vvd-size-density, 0),2)));padding-block:13px 14px;padding-inline:12px}:host(:focus-visible) .base{--focus-stroke-gap-color: transparent;box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px))}:host([cell-type=columnheader]) .base{border-color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base-bold);--_data-grid-cell-default-block-size: calc(1px*(48 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) ;--_data-grid-cell-default-white-space: nowrap}:host(:not([cell-type=columnheader])) .base{--_data-grid-cell-default-block-size: 100%;--_data-grid-cell-default-white-space: normal}:host(:is([
|
|
25
|
+
const dataGridCellStyles = ":host{block-size:100%;min-inline-size:80px}:host(:focus-visible){outline:none}.base.connotation-cta{--_connotation-color-primary: var(--vvd-data-grid-cell-cta-primary, var(--vvd-color-cta-500));--_connotation-color-primary-text: var(--vvd-data-grid-cell-cta-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-data-grid-cell-cta-primary-increment, var(--vvd-color-cta-600));--_connotation-color-firm: var(--vvd-data-grid-cell-cta-firm, var(--vvd-color-cta-600));--_connotation-color-soft: var(--vvd-data-grid-cell-cta-soft, var(--vvd-color-cta-100));--_connotation-color-faint: var(--vvd-data-grid-cell-cta-faint, var(--vvd-color-cta-50));--_connotation-color-pale: var(--vvd-data-grid-cell-cta-pale, var(--vvd-color-cta-300));--_connotation-color-dim: var(--vvd-data-grid-cell-cta-dim, var(--vvd-color-cta-200))}.base:not(.connotation-cta){--_connotation-color-primary: var(--vvd-data-grid-cell-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-data-grid-cell-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-data-grid-cell-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-firm: var(--vvd-data-grid-cell-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-soft: var(--vvd-data-grid-cell-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-faint: var(--vvd-data-grid-cell-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-pale: var(--vvd-data-grid-cell-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-dim: var(--vvd-data-grid-cell-accent-dim, var(--vvd-color-neutral-200))}.base{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.base:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.base:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-dim);--_appearance-color-outline: transparent}.base{display:flex;box-sizing:border-box;align-items:center;border-bottom:1px solid var(--vvd-color-neutral-300);block-size:var(--data-grid-cell-block-size, var(--_data-grid-cell-default-block-size));color:var(--_appearance-color-text);font:var(--vvd-typography-base);min-block-size:calc(1px*(48 + 4*clamp(-1,var(--vvd-size-density, 0),2)));padding-block:13px 14px;padding-inline:12px}:host(:focus-visible) .base{--focus-stroke-gap-color: transparent;box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px))}:host([cell-type=columnheader]) .base{border-color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base-bold);--_data-grid-cell-default-block-size: calc(1px*(48 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) ;--_data-grid-cell-default-white-space: nowrap}:host(:not([cell-type=columnheader])) .base{--_data-grid-cell-default-block-size: 100%;--_data-grid-cell-default-white-space: normal}:host(:is([selected]):not([cell-type=columnheader])) .base{background-color:var(--_appearance-color-fill)}slot{display:block;overflow:hidden;text-overflow:ellipsis;white-space:var(--data-grid-cell-white-space, var(--_data-grid-cell-default-white-space))}:host(:not([cell-type=columnheader][aria-sort])) slot{inline-size:100%}.header-icon{margin-inline-start:16px}";
|
|
25
26
|
|
|
26
27
|
const DataGridCellSortStates = {
|
|
27
28
|
none: "none",
|
|
@@ -59,6 +60,521 @@ var __decorateClass$2 = (decorators, target, key, kind) => {
|
|
|
59
60
|
if (result) __defProp$2(target, key, result);
|
|
60
61
|
return result;
|
|
61
62
|
};
|
|
63
|
+
const defaultCellContentsTemplate = html`
|
|
64
|
+
<template>
|
|
65
|
+
${(x) => x.rowData === null || x.columnDefinition === null || x.columnDefinition.columnDataKey === null ? null : x.rowData[x.columnDefinition.columnDataKey]}
|
|
66
|
+
</template>
|
|
67
|
+
`;
|
|
68
|
+
const defaultHeaderCellContentsTemplate = html`
|
|
69
|
+
<template>
|
|
70
|
+
${(x) => x.columnDefinition.title === void 0 ? x.columnDefinition.columnDataKey : x.columnDefinition.title}
|
|
71
|
+
</template>
|
|
72
|
+
`;
|
|
73
|
+
class DataGridCell extends Localized(VividElement) {
|
|
74
|
+
constructor() {
|
|
75
|
+
super(...arguments);
|
|
76
|
+
// eslint-disable-next-line @repo/repo/no-attribute-default-value
|
|
77
|
+
this.cellType = DataGridCellTypes.default;
|
|
78
|
+
this.rowData = null;
|
|
79
|
+
this.columnDefinition = null;
|
|
80
|
+
this.isActiveCell = false;
|
|
81
|
+
this.customCellView = null;
|
|
82
|
+
this.updateCellStyle = () => {
|
|
83
|
+
if (this.gridColumn && !this.gridColumn.includes("undefined")) {
|
|
84
|
+
this.style.gridColumn = this.gridColumn;
|
|
85
|
+
} else {
|
|
86
|
+
this.style.removeProperty("grid-column");
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
this._selectable = false;
|
|
90
|
+
this.selected = false;
|
|
91
|
+
this.ariaSelected = null;
|
|
92
|
+
this.ariaSort = null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
cellTypeChanged() {
|
|
98
|
+
if (this.$fastController.isConnected) {
|
|
99
|
+
this.updateCellView();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @internal
|
|
104
|
+
*/
|
|
105
|
+
gridColumnChanged() {
|
|
106
|
+
if (this.$fastController.isConnected) {
|
|
107
|
+
this.updateCellStyle();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
columnDefinitionChanged(_oldValue, _newValue) {
|
|
114
|
+
if (this.$fastController.isConnected) {
|
|
115
|
+
this.updateCellView();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
121
|
+
connectedCallback() {
|
|
122
|
+
super.connectedCallback();
|
|
123
|
+
this.addEventListener(eventFocusIn, this.handleFocusin);
|
|
124
|
+
this.addEventListener(eventFocusOut, this.handleFocusout);
|
|
125
|
+
this.addEventListener(eventKeyDown, this.handleKeydown);
|
|
126
|
+
this.style.gridColumn = `${this.columnDefinition?.gridColumn === void 0 ? 0 : this.columnDefinition.gridColumn}`;
|
|
127
|
+
this.updateCellView();
|
|
128
|
+
this.updateCellStyle();
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
disconnectedCallback() {
|
|
134
|
+
super.disconnectedCallback();
|
|
135
|
+
this.removeEventListener(eventFocusIn, this.handleFocusin);
|
|
136
|
+
this.removeEventListener(
|
|
137
|
+
eventFocusOut,
|
|
138
|
+
this.handleFocusout
|
|
139
|
+
);
|
|
140
|
+
this.removeEventListener(eventKeyDown, this.handleKeydown);
|
|
141
|
+
this.disconnectCellView();
|
|
142
|
+
}
|
|
143
|
+
handleFocusin(_) {
|
|
144
|
+
this.shadowRoot.querySelector(".base").classList.add("active");
|
|
145
|
+
if (this.isActiveCell) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.isActiveCell = true;
|
|
149
|
+
switch (this.cellType) {
|
|
150
|
+
case DataGridCellTypes.columnHeader:
|
|
151
|
+
if (this.columnDefinition !== null && this.columnDefinition.headerCellInternalFocusQueue !== true && typeof this.columnDefinition.headerCellFocusTargetCallback === "function") {
|
|
152
|
+
const focusTarget = this.columnDefinition.headerCellFocusTargetCallback(this);
|
|
153
|
+
if (focusTarget !== null) {
|
|
154
|
+
focusTarget.focus();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
default:
|
|
159
|
+
if (this.columnDefinition !== null && this.columnDefinition.cellInternalFocusQueue !== true && typeof this.columnDefinition.cellFocusTargetCallback === "function") {
|
|
160
|
+
const focusTarget = this.columnDefinition.cellFocusTargetCallback(this);
|
|
161
|
+
if (focusTarget !== null) {
|
|
162
|
+
focusTarget.focus();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
this.$emit("cell-focused", this);
|
|
168
|
+
}
|
|
169
|
+
handleFocusout(_) {
|
|
170
|
+
this.shadowRoot.querySelector(".base").classList.remove("active");
|
|
171
|
+
if (this !== document.activeElement && !this.contains(document.activeElement)) {
|
|
172
|
+
this.isActiveCell = false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
handleKeydown(e) {
|
|
176
|
+
if (e.defaultPrevented || this.columnDefinition === null || this.cellType === DataGridCellTypes.default && this.columnDefinition.cellInternalFocusQueue !== true || this.cellType === DataGridCellTypes.columnHeader && this.columnDefinition.headerCellInternalFocusQueue !== true) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
switch (e.key) {
|
|
180
|
+
case keyEnter:
|
|
181
|
+
case keyFunction2:
|
|
182
|
+
if (this.contains(document.activeElement) && document.activeElement !== this) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
switch (this.cellType) {
|
|
186
|
+
case DataGridCellTypes.columnHeader:
|
|
187
|
+
if (this.columnDefinition.headerCellFocusTargetCallback !== void 0) {
|
|
188
|
+
const focusTarget = this.columnDefinition.headerCellFocusTargetCallback(this);
|
|
189
|
+
if (focusTarget !== null) {
|
|
190
|
+
focusTarget.focus();
|
|
191
|
+
}
|
|
192
|
+
e.preventDefault();
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
default:
|
|
196
|
+
if (this.columnDefinition.cellFocusTargetCallback !== void 0) {
|
|
197
|
+
const focusTarget = this.columnDefinition.cellFocusTargetCallback(this);
|
|
198
|
+
if (focusTarget !== null) {
|
|
199
|
+
focusTarget.focus();
|
|
200
|
+
}
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
}
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
break;
|
|
206
|
+
case keyEscape:
|
|
207
|
+
if (this.contains(document.activeElement) && document.activeElement !== this) {
|
|
208
|
+
this.focus();
|
|
209
|
+
e.preventDefault();
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
updateCellView() {
|
|
215
|
+
this.disconnectCellView();
|
|
216
|
+
if (this.columnDefinition === null) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
switch (this.cellType) {
|
|
220
|
+
case DataGridCellTypes.columnHeader:
|
|
221
|
+
if (this.columnDefinition.headerCellTemplate !== void 0) {
|
|
222
|
+
this.customCellView = this.columnDefinition.headerCellTemplate.render(
|
|
223
|
+
this,
|
|
224
|
+
this
|
|
225
|
+
);
|
|
226
|
+
} else {
|
|
227
|
+
this.customCellView = defaultHeaderCellContentsTemplate.render(
|
|
228
|
+
this,
|
|
229
|
+
this
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
case DataGridCellTypes.rowHeader:
|
|
234
|
+
case DataGridCellTypes.default:
|
|
235
|
+
if (this.columnDefinition.cellTemplate !== void 0) {
|
|
236
|
+
this.customCellView = this.columnDefinition.cellTemplate.render(
|
|
237
|
+
this,
|
|
238
|
+
this
|
|
239
|
+
);
|
|
240
|
+
} else {
|
|
241
|
+
this.customCellView = defaultCellContentsTemplate.render(this, this);
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
if (!this.columnDefinition?.sortable) {
|
|
246
|
+
this.sortDirection = void 0;
|
|
247
|
+
} else if (this.columnDefinition.sortDirection) {
|
|
248
|
+
this.sortDirection = this.columnDefinition.sortDirection;
|
|
249
|
+
} else {
|
|
250
|
+
this.sortDirection = DataGridCellSortStates.none;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
disconnectCellView() {
|
|
254
|
+
if (this.customCellView !== null) {
|
|
255
|
+
this.customCellView.dispose();
|
|
256
|
+
this.customCellView = null;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
*
|
|
261
|
+
* @private
|
|
262
|
+
*/
|
|
263
|
+
calculateAriaSelectedValue() {
|
|
264
|
+
if (this._selectable && this.selected) return "true";
|
|
265
|
+
if (this._selectable && !this.selected) return "false";
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* @internal
|
|
270
|
+
*/
|
|
271
|
+
_selectableChanged() {
|
|
272
|
+
this.ariaSelected = this.calculateAriaSelectedValue();
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* @internal
|
|
276
|
+
*/
|
|
277
|
+
selectedChanged() {
|
|
278
|
+
this.ariaSelected = this.calculateAriaSelectedValue();
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* @internal
|
|
282
|
+
*/
|
|
283
|
+
ariaSelectedChanged(_, newValue) {
|
|
284
|
+
this._selectable = newValue !== null;
|
|
285
|
+
this.selected = newValue === "true";
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* @internal
|
|
289
|
+
*/
|
|
290
|
+
ariaSortChanged(_oldValue, newValue) {
|
|
291
|
+
if (newValue === null) {
|
|
292
|
+
this.sortDirection = void 0;
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
this.sortDirection = newValue;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* @internal
|
|
299
|
+
*/
|
|
300
|
+
sortDirectionChanged(_oldValue, newValue) {
|
|
301
|
+
if (newValue === void 0) {
|
|
302
|
+
this.ariaSort = null;
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
this.ariaSort = newValue;
|
|
306
|
+
}
|
|
307
|
+
#getColumnDataKey() {
|
|
308
|
+
return this.columnDefinition && this.columnDefinition.columnDataKey ? this.columnDefinition.columnDataKey : this.textContent.trim();
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* @internal
|
|
312
|
+
*/
|
|
313
|
+
_handleInteraction() {
|
|
314
|
+
const isHeaderCell = this.cellType === "columnheader";
|
|
315
|
+
const isSortable = isHeaderCell && this.sortDirection !== void 0;
|
|
316
|
+
if (isSortable) {
|
|
317
|
+
this.$emit("sort", {
|
|
318
|
+
columnDataKey: this.#getColumnDataKey(),
|
|
319
|
+
sortDirection: this.sortDirection
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
const hasInternalFocusQueue = isHeaderCell ? this.columnDefinition?.headerCellInternalFocusQueue : this.columnDefinition?.cellInternalFocusQueue;
|
|
323
|
+
if (!hasInternalFocusQueue) {
|
|
324
|
+
this.$emit("cell-click", {
|
|
325
|
+
cell: this,
|
|
326
|
+
row: this.parentElement,
|
|
327
|
+
isHeaderCell,
|
|
328
|
+
columnDataKey: this.#getColumnDataKey()
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
__decorateClass$2([
|
|
335
|
+
attr({ attribute: "cell-type" })
|
|
336
|
+
], DataGridCell.prototype, "cellType");
|
|
337
|
+
__decorateClass$2([
|
|
338
|
+
attr({ attribute: "grid-column" })
|
|
339
|
+
], DataGridCell.prototype, "gridColumn");
|
|
340
|
+
__decorateClass$2([
|
|
341
|
+
observable
|
|
342
|
+
], DataGridCell.prototype, "rowData");
|
|
343
|
+
__decorateClass$2([
|
|
344
|
+
observable
|
|
345
|
+
], DataGridCell.prototype, "columnDefinition");
|
|
346
|
+
__decorateClass$2([
|
|
347
|
+
observable
|
|
348
|
+
], DataGridCell.prototype, "_selectable");
|
|
349
|
+
__decorateClass$2([
|
|
350
|
+
attr({ mode: "boolean" })
|
|
351
|
+
], DataGridCell.prototype, "selected");
|
|
352
|
+
__decorateClass$2([
|
|
353
|
+
attr({ attribute: "aria-selected", mode: "fromView" })
|
|
354
|
+
], DataGridCell.prototype, "ariaSelected");
|
|
355
|
+
__decorateClass$2([
|
|
356
|
+
attr({ attribute: "aria-sort" })
|
|
357
|
+
], DataGridCell.prototype, "ariaSort");
|
|
358
|
+
__decorateClass$2([
|
|
359
|
+
attr({ attribute: "sort-direction" })
|
|
360
|
+
], DataGridCell.prototype, "sortDirection");
|
|
361
|
+
|
|
362
|
+
var __defProp$1 = Object.defineProperty;
|
|
363
|
+
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
364
|
+
var result = void 0 ;
|
|
365
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
366
|
+
if (decorator = decorators[i])
|
|
367
|
+
result = (decorator(target, key, result) ) || result;
|
|
368
|
+
if (result) __defProp$1(target, key, result);
|
|
369
|
+
return result;
|
|
370
|
+
};
|
|
371
|
+
class DataGridRow extends VividElement {
|
|
372
|
+
constructor() {
|
|
373
|
+
super(...arguments);
|
|
374
|
+
// eslint-disable-next-line @repo/repo/no-attribute-default-value
|
|
375
|
+
this.rowType = DataGridRowTypes.default;
|
|
376
|
+
this.rowData = null;
|
|
377
|
+
this.columnDefinitions = null;
|
|
378
|
+
this.cellsRepeatBehavior = null;
|
|
379
|
+
this.cellsPlaceholder = null;
|
|
380
|
+
/**
|
|
381
|
+
* @internal
|
|
382
|
+
*/
|
|
383
|
+
this.focusColumnIndex = 0;
|
|
384
|
+
this.updateRowStyle = () => {
|
|
385
|
+
this.style.gridTemplateColumns = this.gridTemplateColumns;
|
|
386
|
+
};
|
|
387
|
+
this.ariaSelected = null;
|
|
388
|
+
this._selectable = false;
|
|
389
|
+
this.selected = false;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* @internal
|
|
393
|
+
*/
|
|
394
|
+
gridTemplateColumnsChanged() {
|
|
395
|
+
if (this.$fastController.isConnected) {
|
|
396
|
+
this.updateRowStyle();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* @internal
|
|
401
|
+
*/
|
|
402
|
+
rowTypeChanged() {
|
|
403
|
+
if (this.$fastController.isConnected) {
|
|
404
|
+
this.updateItemTemplate();
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* @internal
|
|
409
|
+
*/
|
|
410
|
+
cellItemTemplateChanged() {
|
|
411
|
+
this.updateItemTemplate();
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* @internal
|
|
415
|
+
*/
|
|
416
|
+
headerCellItemTemplateChanged() {
|
|
417
|
+
this.updateItemTemplate();
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* @internal
|
|
421
|
+
*/
|
|
422
|
+
connectedCallback() {
|
|
423
|
+
super.connectedCallback();
|
|
424
|
+
if (this.cellsRepeatBehavior === null) {
|
|
425
|
+
this.cellsPlaceholder = document.createComment("");
|
|
426
|
+
this.appendChild(this.cellsPlaceholder);
|
|
427
|
+
this.updateItemTemplate();
|
|
428
|
+
this.cellsRepeatBehavior = new RepeatDirective(
|
|
429
|
+
(x) => x.columnDefinitions,
|
|
430
|
+
(x) => x.activeCellItemTemplate,
|
|
431
|
+
{ positioning: true }
|
|
432
|
+
).createBehavior(this.cellsPlaceholder);
|
|
433
|
+
this.$fastController.addBehaviors([this.cellsRepeatBehavior]);
|
|
434
|
+
}
|
|
435
|
+
this.addEventListener("cell-focused", this.handleCellFocus);
|
|
436
|
+
this.addEventListener(eventFocusOut, this.handleFocusout);
|
|
437
|
+
this.addEventListener(eventKeyDown, this.handleKeydown);
|
|
438
|
+
this.updateRowStyle();
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* @internal
|
|
442
|
+
*/
|
|
443
|
+
disconnectedCallback() {
|
|
444
|
+
super.disconnectedCallback();
|
|
445
|
+
this.removeEventListener("cell-focused", this.handleCellFocus);
|
|
446
|
+
this.removeEventListener(
|
|
447
|
+
eventFocusOut,
|
|
448
|
+
this.handleFocusout
|
|
449
|
+
);
|
|
450
|
+
this.removeEventListener(eventKeyDown, this.handleKeydown);
|
|
451
|
+
}
|
|
452
|
+
handleFocusout(_) {
|
|
453
|
+
if (!this.contains(document.activeElement)) {
|
|
454
|
+
this.focusColumnIndex = 0;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
handleCellFocus(e) {
|
|
458
|
+
this.focusColumnIndex = this.cellElements.indexOf(e.target);
|
|
459
|
+
this.$emit("row-focused", this);
|
|
460
|
+
}
|
|
461
|
+
handleKeydown(e) {
|
|
462
|
+
if (e.defaultPrevented) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
let newFocusColumnIndex = 0;
|
|
466
|
+
switch (e.key) {
|
|
467
|
+
case keyArrowLeft:
|
|
468
|
+
newFocusColumnIndex = Math.max(0, this.focusColumnIndex - 1);
|
|
469
|
+
this.cellElements[newFocusColumnIndex].focus();
|
|
470
|
+
e.preventDefault();
|
|
471
|
+
break;
|
|
472
|
+
case keyArrowRight:
|
|
473
|
+
newFocusColumnIndex = Math.min(
|
|
474
|
+
this.cellElements.length - 1,
|
|
475
|
+
this.focusColumnIndex + 1
|
|
476
|
+
);
|
|
477
|
+
this.cellElements[newFocusColumnIndex].focus();
|
|
478
|
+
e.preventDefault();
|
|
479
|
+
break;
|
|
480
|
+
case keyHome:
|
|
481
|
+
if (!e.ctrlKey) {
|
|
482
|
+
this.cellElements[0].focus();
|
|
483
|
+
e.preventDefault();
|
|
484
|
+
}
|
|
485
|
+
break;
|
|
486
|
+
case keyEnd:
|
|
487
|
+
if (!e.ctrlKey) {
|
|
488
|
+
this.cellElements[this.cellElements.length - 1].focus();
|
|
489
|
+
e.preventDefault();
|
|
490
|
+
}
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
updateItemTemplate() {
|
|
495
|
+
this.activeCellItemTemplate = this.rowType === DataGridRowTypes.default && this.cellItemTemplate !== void 0 ? this.cellItemTemplate : this.rowType === DataGridRowTypes.default && this.cellItemTemplate === void 0 ? this.defaultCellItemTemplate : this.headerCellItemTemplate !== void 0 ? this.headerCellItemTemplate : this.defaultHeaderCellItemTemplate;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* @internal
|
|
499
|
+
*/
|
|
500
|
+
ariaSelectedChanged(_oldValue, newValue) {
|
|
501
|
+
this._selectable = newValue !== null;
|
|
502
|
+
this.selected = newValue === "true";
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* @internal
|
|
506
|
+
*/
|
|
507
|
+
_calculateAriaSelectedValue() {
|
|
508
|
+
if (this._selectable && this.selected) return "true";
|
|
509
|
+
if (this._selectable && !this.selected) return "false";
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* @internal
|
|
514
|
+
*/
|
|
515
|
+
_selectableChanged() {
|
|
516
|
+
this.ariaSelected = this._calculateAriaSelectedValue();
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* @internal
|
|
520
|
+
*/
|
|
521
|
+
selectedChanged() {
|
|
522
|
+
this.ariaSelected = this._calculateAriaSelectedValue();
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
// @ts-expect-error Type is incorrectly non-optional
|
|
526
|
+
__decorateClass$1([
|
|
527
|
+
attr({ attribute: "grid-template-columns" })
|
|
528
|
+
], DataGridRow.prototype, "gridTemplateColumns");
|
|
529
|
+
__decorateClass$1([
|
|
530
|
+
attr({ attribute: "row-type" })
|
|
531
|
+
], DataGridRow.prototype, "rowType");
|
|
532
|
+
__decorateClass$1([
|
|
533
|
+
observable
|
|
534
|
+
], DataGridRow.prototype, "rowData");
|
|
535
|
+
__decorateClass$1([
|
|
536
|
+
observable
|
|
537
|
+
], DataGridRow.prototype, "columnDefinitions");
|
|
538
|
+
__decorateClass$1([
|
|
539
|
+
observable
|
|
540
|
+
], DataGridRow.prototype, "cellItemTemplate");
|
|
541
|
+
__decorateClass$1([
|
|
542
|
+
observable
|
|
543
|
+
], DataGridRow.prototype, "headerCellItemTemplate");
|
|
544
|
+
__decorateClass$1([
|
|
545
|
+
observable
|
|
546
|
+
], DataGridRow.prototype, "rowIndex");
|
|
547
|
+
__decorateClass$1([
|
|
548
|
+
observable
|
|
549
|
+
], DataGridRow.prototype, "activeCellItemTemplate");
|
|
550
|
+
__decorateClass$1([
|
|
551
|
+
observable
|
|
552
|
+
], DataGridRow.prototype, "defaultCellItemTemplate");
|
|
553
|
+
__decorateClass$1([
|
|
554
|
+
observable
|
|
555
|
+
], DataGridRow.prototype, "defaultHeaderCellItemTemplate");
|
|
556
|
+
__decorateClass$1([
|
|
557
|
+
observable
|
|
558
|
+
], DataGridRow.prototype, "cellElements");
|
|
559
|
+
__decorateClass$1([
|
|
560
|
+
attr({ attribute: "aria-selected" })
|
|
561
|
+
], DataGridRow.prototype, "ariaSelected");
|
|
562
|
+
__decorateClass$1([
|
|
563
|
+
observable
|
|
564
|
+
], DataGridRow.prototype, "_selectable");
|
|
565
|
+
__decorateClass$1([
|
|
566
|
+
attr({ mode: "boolean" })
|
|
567
|
+
], DataGridRow.prototype, "selected");
|
|
568
|
+
|
|
569
|
+
var __defProp = Object.defineProperty;
|
|
570
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
571
|
+
var result = void 0 ;
|
|
572
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
573
|
+
if (decorator = decorators[i])
|
|
574
|
+
result = (decorator(target, key, result) ) || result;
|
|
575
|
+
if (result) __defProp(target, key, result);
|
|
576
|
+
return result;
|
|
577
|
+
};
|
|
62
578
|
const DataGridSelectionMode = {
|
|
63
579
|
none: "none",
|
|
64
580
|
singleRow: "single-row",
|
|
@@ -70,7 +586,7 @@ const _DataGrid = class _DataGrid extends VividElement {
|
|
|
70
586
|
constructor() {
|
|
71
587
|
super();
|
|
72
588
|
this.noTabbing = false;
|
|
73
|
-
// eslint-disable-next-line @
|
|
589
|
+
// eslint-disable-next-line @repo/repo/no-attribute-default-value
|
|
74
590
|
this.generateHeader = GenerateHeaderOptions.default;
|
|
75
591
|
this.rowsData = [];
|
|
76
592
|
this.columnDefinitions = null;
|
|
@@ -96,7 +612,7 @@ const _DataGrid = class _DataGrid extends VividElement {
|
|
|
96
612
|
);
|
|
97
613
|
const focusRow = this.rowElements[focusRowIndex];
|
|
98
614
|
const cells = focusRow.querySelectorAll(
|
|
99
|
-
'[role="cell"], [role="gridcell"], [role="columnheader"], [role="rowheader"]'
|
|
615
|
+
'[role="cell"], [role="gridcell"], [role="columnheader"], [role="rowheader"], [cell-type]'
|
|
100
616
|
);
|
|
101
617
|
const focusColumnIndex = Math.max(
|
|
102
618
|
0,
|
|
@@ -171,11 +687,11 @@ const _DataGrid = class _DataGrid extends VividElement {
|
|
|
171
687
|
}) => {
|
|
172
688
|
const cell = target;
|
|
173
689
|
if (this.selectionMode === DataGridSelectionMode.multiCell && (ctrlKey || shiftKey || metaKey)) {
|
|
174
|
-
|
|
690
|
+
cell.selected = !this.#selectedCells.includes(cell);
|
|
175
691
|
} else {
|
|
176
|
-
const cacheTargetSelection = cell.
|
|
177
|
-
this
|
|
178
|
-
|
|
692
|
+
const cacheTargetSelection = cell.selected;
|
|
693
|
+
this._resetSelection(true);
|
|
694
|
+
cell.selected = !cacheTargetSelection;
|
|
179
695
|
}
|
|
180
696
|
};
|
|
181
697
|
this.#handleRowSelection = ({
|
|
@@ -186,11 +702,11 @@ const _DataGrid = class _DataGrid extends VividElement {
|
|
|
186
702
|
}) => {
|
|
187
703
|
const row = target.parentNode;
|
|
188
704
|
if (this.selectionMode === DataGridSelectionMode.multiRow && (ctrlKey || shiftKey || metaKey)) {
|
|
189
|
-
|
|
705
|
+
row.selected = !this.#selectedRows.includes(row);
|
|
190
706
|
} else {
|
|
191
|
-
const cacheTargetSelection = row.
|
|
192
|
-
this
|
|
193
|
-
|
|
707
|
+
const cacheTargetSelection = row.selected;
|
|
708
|
+
this._resetSelection(true);
|
|
709
|
+
row.selected = !cacheTargetSelection;
|
|
194
710
|
}
|
|
195
711
|
};
|
|
196
712
|
this.#changeHandler = {
|
|
@@ -202,59 +718,41 @@ const _DataGrid = class _DataGrid extends VividElement {
|
|
|
202
718
|
}
|
|
203
719
|
}
|
|
204
720
|
};
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
this
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
if (this.selectionMode === DataGridSelectionMode.none) {
|
|
218
|
-
Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
|
|
219
|
-
(cell) => cell.removeAttribute("aria-selected")
|
|
220
|
-
);
|
|
221
|
-
Array.from(this.querySelectorAll('[role="row"]')).forEach(
|
|
222
|
-
(row) => row.removeAttribute("aria-selected")
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
if (this.selectionMode === DataGridSelectionMode.singleRow || this.selectionMode === DataGridSelectionMode.multiRow) {
|
|
226
|
-
Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
|
|
227
|
-
(cell) => cell.removeAttribute("aria-selected")
|
|
228
|
-
);
|
|
229
|
-
Array.from(this.querySelectorAll('[role="row"]')).forEach(
|
|
230
|
-
(row) => row.setAttribute("aria-selected", "false")
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
this.#initSelections = () => {
|
|
721
|
+
/**
|
|
722
|
+
* @internal
|
|
723
|
+
*/
|
|
724
|
+
this._resetSelection = (clear = false) => {
|
|
725
|
+
const cells = Array.from(
|
|
726
|
+
this.querySelectorAll('[role="gridcell"], [cell-type]')
|
|
727
|
+
);
|
|
728
|
+
const rows = Array.from(
|
|
729
|
+
this.querySelectorAll('[role="row"], [row-type]')
|
|
730
|
+
);
|
|
235
731
|
if (this.selectionMode === DataGridSelectionMode.singleCell || this.selectionMode === DataGridSelectionMode.multiCell) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
732
|
+
for (const cell of cells) {
|
|
733
|
+
cell._selectable = true;
|
|
734
|
+
cell.selected = clear ? false : cell.selected || false;
|
|
735
|
+
}
|
|
736
|
+
for (const row of rows) {
|
|
737
|
+
row._selectable = false;
|
|
738
|
+
row.selected = false;
|
|
739
|
+
}
|
|
242
740
|
}
|
|
243
741
|
if (this.selectionMode === DataGridSelectionMode.none) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
(row) => row.removeAttribute("aria-selected")
|
|
249
|
-
);
|
|
742
|
+
for (const element of [...cells, ...rows]) {
|
|
743
|
+
element._selectable = false;
|
|
744
|
+
element.selected = false;
|
|
745
|
+
}
|
|
250
746
|
}
|
|
251
747
|
if (this.selectionMode === DataGridSelectionMode.singleRow || this.selectionMode === DataGridSelectionMode.multiRow) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
748
|
+
for (const cell of cells) {
|
|
749
|
+
cell._selectable = false;
|
|
750
|
+
cell.selected = false;
|
|
751
|
+
}
|
|
752
|
+
for (const row of rows) {
|
|
753
|
+
row._selectable = true;
|
|
754
|
+
row.selected = clear ? false : row.selected || false;
|
|
755
|
+
}
|
|
258
756
|
}
|
|
259
757
|
};
|
|
260
758
|
this.addEventListener("click", this.#handleClick);
|
|
@@ -548,37 +1046,32 @@ const _DataGrid = class _DataGrid extends VividElement {
|
|
|
548
1046
|
* @internal
|
|
549
1047
|
*/
|
|
550
1048
|
slottedRowElementsChanged(_oldValue, _newValue) {
|
|
551
|
-
this
|
|
1049
|
+
this._resetSelection();
|
|
552
1050
|
}
|
|
553
1051
|
get #selectedRows() {
|
|
554
|
-
return this.rowElements.filter(
|
|
555
|
-
(row) => row.getAttribute("aria-selected") === "true"
|
|
556
|
-
);
|
|
1052
|
+
return this.rowElements.filter((row) => row.selected);
|
|
557
1053
|
}
|
|
558
1054
|
get #selectedCells() {
|
|
559
1055
|
return this.rowElements.reduce((acc, row) => {
|
|
560
1056
|
const rowChildren = Array.from(row.children);
|
|
561
1057
|
const selectedCells = rowChildren.filter(
|
|
562
|
-
(cell) => cell.
|
|
1058
|
+
(cell) => cell.selected
|
|
563
1059
|
);
|
|
564
1060
|
return acc.concat(selectedCells);
|
|
565
1061
|
}, []);
|
|
566
1062
|
}
|
|
567
1063
|
selectionModeChanged(oldValue) {
|
|
568
1064
|
if (oldValue === void 0) {
|
|
569
|
-
DOM.queueUpdate(this
|
|
1065
|
+
DOM.queueUpdate(this._resetSelection);
|
|
570
1066
|
return;
|
|
571
1067
|
}
|
|
572
|
-
this
|
|
1068
|
+
this._resetSelection(true);
|
|
573
1069
|
}
|
|
574
1070
|
#handleKeypress;
|
|
575
1071
|
#handleClick;
|
|
576
1072
|
#handleCellSelection;
|
|
577
1073
|
#handleRowSelection;
|
|
578
1074
|
#changeHandler;
|
|
579
|
-
#setSelectedState;
|
|
580
|
-
#resetSelection;
|
|
581
|
-
#initSelections;
|
|
582
1075
|
static generateColumns(rowData) {
|
|
583
1076
|
return Object.keys(rowData).map((property, index) => {
|
|
584
1077
|
return {
|
|
@@ -588,225 +1081,53 @@ const _DataGrid = class _DataGrid extends VividElement {
|
|
|
588
1081
|
});
|
|
589
1082
|
}
|
|
590
1083
|
};
|
|
591
|
-
__decorateClass
|
|
1084
|
+
__decorateClass([
|
|
592
1085
|
attr({ attribute: "no-tabbing", mode: "boolean" })
|
|
593
1086
|
], _DataGrid.prototype, "noTabbing");
|
|
594
|
-
__decorateClass
|
|
1087
|
+
__decorateClass([
|
|
595
1088
|
attr({ attribute: "generate-header" })
|
|
596
1089
|
], _DataGrid.prototype, "generateHeader");
|
|
597
1090
|
// @ts-expect-error Type is incorrectly non-optional
|
|
598
|
-
__decorateClass
|
|
1091
|
+
__decorateClass([
|
|
599
1092
|
attr({ attribute: "grid-template-columns" })
|
|
600
1093
|
], _DataGrid.prototype, "gridTemplateColumns");
|
|
601
|
-
__decorateClass
|
|
1094
|
+
__decorateClass([
|
|
602
1095
|
observable
|
|
603
1096
|
], _DataGrid.prototype, "rowsData");
|
|
604
|
-
__decorateClass
|
|
1097
|
+
__decorateClass([
|
|
605
1098
|
observable
|
|
606
1099
|
], _DataGrid.prototype, "columnDefinitions");
|
|
607
|
-
__decorateClass
|
|
1100
|
+
__decorateClass([
|
|
608
1101
|
observable
|
|
609
1102
|
], _DataGrid.prototype, "rowItemTemplate");
|
|
610
|
-
__decorateClass
|
|
1103
|
+
__decorateClass([
|
|
611
1104
|
observable
|
|
612
1105
|
], _DataGrid.prototype, "cellItemTemplate");
|
|
613
|
-
__decorateClass
|
|
1106
|
+
__decorateClass([
|
|
614
1107
|
observable
|
|
615
1108
|
], _DataGrid.prototype, "headerCellItemTemplate");
|
|
616
|
-
__decorateClass
|
|
1109
|
+
__decorateClass([
|
|
617
1110
|
observable
|
|
618
1111
|
], _DataGrid.prototype, "focusRowIndex");
|
|
619
|
-
__decorateClass
|
|
1112
|
+
__decorateClass([
|
|
620
1113
|
observable
|
|
621
1114
|
], _DataGrid.prototype, "focusColumnIndex");
|
|
622
|
-
__decorateClass
|
|
1115
|
+
__decorateClass([
|
|
623
1116
|
observable
|
|
624
1117
|
], _DataGrid.prototype, "defaultRowItemTemplate");
|
|
625
|
-
__decorateClass
|
|
1118
|
+
__decorateClass([
|
|
626
1119
|
observable
|
|
627
1120
|
], _DataGrid.prototype, "rowElementTag");
|
|
628
|
-
__decorateClass
|
|
1121
|
+
__decorateClass([
|
|
629
1122
|
observable
|
|
630
1123
|
], _DataGrid.prototype, "rowElements");
|
|
631
|
-
__decorateClass
|
|
632
|
-
observable
|
|
633
|
-
], _DataGrid.prototype, "slottedRowElements");
|
|
634
|
-
__decorateClass$2([
|
|
635
|
-
attr({ attribute: "selection-mode" })
|
|
636
|
-
], _DataGrid.prototype, "selectionMode");
|
|
637
|
-
let DataGrid = _DataGrid;
|
|
638
|
-
|
|
639
|
-
var __defProp$1 = Object.defineProperty;
|
|
640
|
-
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
641
|
-
var result = void 0 ;
|
|
642
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
643
|
-
if (decorator = decorators[i])
|
|
644
|
-
result = (decorator(target, key, result) ) || result;
|
|
645
|
-
if (result) __defProp$1(target, key, result);
|
|
646
|
-
return result;
|
|
647
|
-
};
|
|
648
|
-
class DataGridRow extends VividElement {
|
|
649
|
-
constructor() {
|
|
650
|
-
super(...arguments);
|
|
651
|
-
// eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
|
|
652
|
-
this.rowType = DataGridRowTypes.default;
|
|
653
|
-
this.rowData = null;
|
|
654
|
-
this.columnDefinitions = null;
|
|
655
|
-
this.cellsRepeatBehavior = null;
|
|
656
|
-
this.cellsPlaceholder = null;
|
|
657
|
-
/**
|
|
658
|
-
* @internal
|
|
659
|
-
*/
|
|
660
|
-
this.focusColumnIndex = 0;
|
|
661
|
-
this.updateRowStyle = () => {
|
|
662
|
-
this.style.gridTemplateColumns = this.gridTemplateColumns;
|
|
663
|
-
};
|
|
664
|
-
this.ariaSelected = null;
|
|
665
|
-
}
|
|
666
|
-
/**
|
|
667
|
-
* @internal
|
|
668
|
-
*/
|
|
669
|
-
gridTemplateColumnsChanged() {
|
|
670
|
-
if (this.$fastController.isConnected) {
|
|
671
|
-
this.updateRowStyle();
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* @internal
|
|
676
|
-
*/
|
|
677
|
-
rowTypeChanged() {
|
|
678
|
-
if (this.$fastController.isConnected) {
|
|
679
|
-
this.updateItemTemplate();
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* @internal
|
|
684
|
-
*/
|
|
685
|
-
cellItemTemplateChanged() {
|
|
686
|
-
this.updateItemTemplate();
|
|
687
|
-
}
|
|
688
|
-
/**
|
|
689
|
-
* @internal
|
|
690
|
-
*/
|
|
691
|
-
headerCellItemTemplateChanged() {
|
|
692
|
-
this.updateItemTemplate();
|
|
693
|
-
}
|
|
694
|
-
/**
|
|
695
|
-
* @internal
|
|
696
|
-
*/
|
|
697
|
-
connectedCallback() {
|
|
698
|
-
super.connectedCallback();
|
|
699
|
-
if (this.cellsRepeatBehavior === null) {
|
|
700
|
-
this.cellsPlaceholder = document.createComment("");
|
|
701
|
-
this.appendChild(this.cellsPlaceholder);
|
|
702
|
-
this.updateItemTemplate();
|
|
703
|
-
this.cellsRepeatBehavior = new RepeatDirective(
|
|
704
|
-
(x) => x.columnDefinitions,
|
|
705
|
-
(x) => x.activeCellItemTemplate,
|
|
706
|
-
{ positioning: true }
|
|
707
|
-
).createBehavior(this.cellsPlaceholder);
|
|
708
|
-
this.$fastController.addBehaviors([this.cellsRepeatBehavior]);
|
|
709
|
-
}
|
|
710
|
-
this.addEventListener("cell-focused", this.handleCellFocus);
|
|
711
|
-
this.addEventListener(eventFocusOut, this.handleFocusout);
|
|
712
|
-
this.addEventListener(eventKeyDown, this.handleKeydown);
|
|
713
|
-
this.updateRowStyle();
|
|
714
|
-
}
|
|
715
|
-
/**
|
|
716
|
-
* @internal
|
|
717
|
-
*/
|
|
718
|
-
disconnectedCallback() {
|
|
719
|
-
super.disconnectedCallback();
|
|
720
|
-
this.removeEventListener("cell-focused", this.handleCellFocus);
|
|
721
|
-
this.removeEventListener(
|
|
722
|
-
eventFocusOut,
|
|
723
|
-
this.handleFocusout
|
|
724
|
-
);
|
|
725
|
-
this.removeEventListener(eventKeyDown, this.handleKeydown);
|
|
726
|
-
}
|
|
727
|
-
handleFocusout(_) {
|
|
728
|
-
if (!this.contains(document.activeElement)) {
|
|
729
|
-
this.focusColumnIndex = 0;
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
handleCellFocus(e) {
|
|
733
|
-
this.focusColumnIndex = this.cellElements.indexOf(e.target);
|
|
734
|
-
this.$emit("row-focused", this);
|
|
735
|
-
}
|
|
736
|
-
handleKeydown(e) {
|
|
737
|
-
if (e.defaultPrevented) {
|
|
738
|
-
return;
|
|
739
|
-
}
|
|
740
|
-
let newFocusColumnIndex = 0;
|
|
741
|
-
switch (e.key) {
|
|
742
|
-
case keyArrowLeft:
|
|
743
|
-
newFocusColumnIndex = Math.max(0, this.focusColumnIndex - 1);
|
|
744
|
-
this.cellElements[newFocusColumnIndex].focus();
|
|
745
|
-
e.preventDefault();
|
|
746
|
-
break;
|
|
747
|
-
case keyArrowRight:
|
|
748
|
-
newFocusColumnIndex = Math.min(
|
|
749
|
-
this.cellElements.length - 1,
|
|
750
|
-
this.focusColumnIndex + 1
|
|
751
|
-
);
|
|
752
|
-
this.cellElements[newFocusColumnIndex].focus();
|
|
753
|
-
e.preventDefault();
|
|
754
|
-
break;
|
|
755
|
-
case keyHome:
|
|
756
|
-
if (!e.ctrlKey) {
|
|
757
|
-
this.cellElements[0].focus();
|
|
758
|
-
e.preventDefault();
|
|
759
|
-
}
|
|
760
|
-
break;
|
|
761
|
-
case keyEnd:
|
|
762
|
-
if (!e.ctrlKey) {
|
|
763
|
-
this.cellElements[this.cellElements.length - 1].focus();
|
|
764
|
-
e.preventDefault();
|
|
765
|
-
}
|
|
766
|
-
break;
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
updateItemTemplate() {
|
|
770
|
-
this.activeCellItemTemplate = this.rowType === DataGridRowTypes.default && this.cellItemTemplate !== void 0 ? this.cellItemTemplate : this.rowType === DataGridRowTypes.default && this.cellItemTemplate === void 0 ? this.defaultCellItemTemplate : this.headerCellItemTemplate !== void 0 ? this.headerCellItemTemplate : this.defaultHeaderCellItemTemplate;
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
// @ts-expect-error Type is incorrectly non-optional
|
|
774
|
-
__decorateClass$1([
|
|
775
|
-
attr({ attribute: "grid-template-columns" })
|
|
776
|
-
], DataGridRow.prototype, "gridTemplateColumns");
|
|
777
|
-
__decorateClass$1([
|
|
778
|
-
attr({ attribute: "row-type" })
|
|
779
|
-
], DataGridRow.prototype, "rowType");
|
|
780
|
-
__decorateClass$1([
|
|
781
|
-
observable
|
|
782
|
-
], DataGridRow.prototype, "rowData");
|
|
783
|
-
__decorateClass$1([
|
|
784
|
-
observable
|
|
785
|
-
], DataGridRow.prototype, "columnDefinitions");
|
|
786
|
-
__decorateClass$1([
|
|
787
|
-
observable
|
|
788
|
-
], DataGridRow.prototype, "cellItemTemplate");
|
|
789
|
-
__decorateClass$1([
|
|
790
|
-
observable
|
|
791
|
-
], DataGridRow.prototype, "headerCellItemTemplate");
|
|
792
|
-
__decorateClass$1([
|
|
793
|
-
observable
|
|
794
|
-
], DataGridRow.prototype, "rowIndex");
|
|
795
|
-
__decorateClass$1([
|
|
796
|
-
observable
|
|
797
|
-
], DataGridRow.prototype, "activeCellItemTemplate");
|
|
798
|
-
__decorateClass$1([
|
|
799
|
-
observable
|
|
800
|
-
], DataGridRow.prototype, "defaultCellItemTemplate");
|
|
801
|
-
__decorateClass$1([
|
|
802
|
-
observable
|
|
803
|
-
], DataGridRow.prototype, "defaultHeaderCellItemTemplate");
|
|
804
|
-
__decorateClass$1([
|
|
1124
|
+
__decorateClass([
|
|
805
1125
|
observable
|
|
806
|
-
],
|
|
807
|
-
__decorateClass
|
|
808
|
-
attr({ attribute: "
|
|
809
|
-
],
|
|
1126
|
+
], _DataGrid.prototype, "slottedRowElements");
|
|
1127
|
+
__decorateClass([
|
|
1128
|
+
attr({ attribute: "selection-mode" })
|
|
1129
|
+
], _DataGrid.prototype, "selectionMode");
|
|
1130
|
+
let DataGrid = _DataGrid;
|
|
810
1131
|
|
|
811
1132
|
function createRowItemTemplate(context) {
|
|
812
1133
|
const rowTag = context.tagFor(DataGridRow);
|
|
@@ -826,6 +1147,9 @@ function setHeaderRow(x) {
|
|
|
826
1147
|
const headerRow = x.querySelector(
|
|
827
1148
|
'[cell-type="columnheader"]'
|
|
828
1149
|
)?.parentElement;
|
|
1150
|
+
if (x.generateHeader === GenerateHeaderOptions.default && (headerRow?.getAttribute("row-type") === DataGridRowTypes.header || headerRow?.getAttribute("row-type") === DataGridRowTypes.stickyHeader)) {
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
829
1153
|
if (headerRow) {
|
|
830
1154
|
const rowType = x.generateHeader === GenerateHeaderOptions.sticky ? DataGridRowTypes.stickyHeader : DataGridRowTypes.header;
|
|
831
1155
|
headerRow.setAttribute("row-type", rowType);
|
|
@@ -859,255 +1183,6 @@ const DataGridTemplate = (context) => {
|
|
|
859
1183
|
`;
|
|
860
1184
|
};
|
|
861
1185
|
|
|
862
|
-
var __defProp = Object.defineProperty;
|
|
863
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
864
|
-
var result = void 0 ;
|
|
865
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
866
|
-
if (decorator = decorators[i])
|
|
867
|
-
result = (decorator(target, key, result) ) || result;
|
|
868
|
-
if (result) __defProp(target, key, result);
|
|
869
|
-
return result;
|
|
870
|
-
};
|
|
871
|
-
const defaultCellContentsTemplate = html`
|
|
872
|
-
<template>
|
|
873
|
-
${(x) => x.rowData === null || x.columnDefinition === null || x.columnDefinition.columnDataKey === null ? null : x.rowData[x.columnDefinition.columnDataKey]}
|
|
874
|
-
</template>
|
|
875
|
-
`;
|
|
876
|
-
const defaultHeaderCellContentsTemplate = html`
|
|
877
|
-
<template>
|
|
878
|
-
${(x) => x.columnDefinition.title === void 0 ? x.columnDefinition.columnDataKey : x.columnDefinition.title}
|
|
879
|
-
</template>
|
|
880
|
-
`;
|
|
881
|
-
class DataGridCell extends Localized(VividElement) {
|
|
882
|
-
constructor() {
|
|
883
|
-
super(...arguments);
|
|
884
|
-
// eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
|
|
885
|
-
this.cellType = DataGridCellTypes.default;
|
|
886
|
-
this.rowData = null;
|
|
887
|
-
this.columnDefinition = null;
|
|
888
|
-
this.isActiveCell = false;
|
|
889
|
-
this.customCellView = null;
|
|
890
|
-
this.updateCellStyle = () => {
|
|
891
|
-
if (this.gridColumn && !this.gridColumn.includes("undefined")) {
|
|
892
|
-
this.style.gridColumn = this.gridColumn;
|
|
893
|
-
} else {
|
|
894
|
-
this.style.removeProperty("grid-column");
|
|
895
|
-
}
|
|
896
|
-
};
|
|
897
|
-
this.ariaSelected = null;
|
|
898
|
-
this.ariaSort = null;
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* @internal
|
|
902
|
-
*/
|
|
903
|
-
cellTypeChanged() {
|
|
904
|
-
if (this.$fastController.isConnected) {
|
|
905
|
-
this.updateCellView();
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
/**
|
|
909
|
-
* @internal
|
|
910
|
-
*/
|
|
911
|
-
gridColumnChanged() {
|
|
912
|
-
if (this.$fastController.isConnected) {
|
|
913
|
-
this.updateCellStyle();
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
/**
|
|
917
|
-
* @internal
|
|
918
|
-
*/
|
|
919
|
-
columnDefinitionChanged(_oldValue, _newValue) {
|
|
920
|
-
if (this.$fastController.isConnected) {
|
|
921
|
-
this.updateCellView();
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
/**
|
|
925
|
-
* @internal
|
|
926
|
-
*/
|
|
927
|
-
connectedCallback() {
|
|
928
|
-
super.connectedCallback();
|
|
929
|
-
this.addEventListener(eventFocusIn, this.handleFocusin);
|
|
930
|
-
this.addEventListener(eventFocusOut, this.handleFocusout);
|
|
931
|
-
this.addEventListener(eventKeyDown, this.handleKeydown);
|
|
932
|
-
this.style.gridColumn = `${this.columnDefinition?.gridColumn === void 0 ? 0 : this.columnDefinition.gridColumn}`;
|
|
933
|
-
this.updateCellView();
|
|
934
|
-
this.updateCellStyle();
|
|
935
|
-
this.ariaSelectedChanged(null, this.ariaSelected);
|
|
936
|
-
}
|
|
937
|
-
/**
|
|
938
|
-
* @internal
|
|
939
|
-
*/
|
|
940
|
-
disconnectedCallback() {
|
|
941
|
-
super.disconnectedCallback();
|
|
942
|
-
this.removeEventListener(eventFocusIn, this.handleFocusin);
|
|
943
|
-
this.removeEventListener(
|
|
944
|
-
eventFocusOut,
|
|
945
|
-
this.handleFocusout
|
|
946
|
-
);
|
|
947
|
-
this.removeEventListener(eventKeyDown, this.handleKeydown);
|
|
948
|
-
this.disconnectCellView();
|
|
949
|
-
}
|
|
950
|
-
handleFocusin(_) {
|
|
951
|
-
this.shadowRoot.querySelector(".base").classList.add("active");
|
|
952
|
-
if (this.isActiveCell) {
|
|
953
|
-
return;
|
|
954
|
-
}
|
|
955
|
-
this.isActiveCell = true;
|
|
956
|
-
switch (this.cellType) {
|
|
957
|
-
case DataGridCellTypes.columnHeader:
|
|
958
|
-
if (this.columnDefinition !== null && this.columnDefinition.headerCellInternalFocusQueue !== true && typeof this.columnDefinition.headerCellFocusTargetCallback === "function") {
|
|
959
|
-
const focusTarget = this.columnDefinition.headerCellFocusTargetCallback(this);
|
|
960
|
-
if (focusTarget !== null) {
|
|
961
|
-
focusTarget.focus();
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
break;
|
|
965
|
-
default:
|
|
966
|
-
if (this.columnDefinition !== null && this.columnDefinition.cellInternalFocusQueue !== true && typeof this.columnDefinition.cellFocusTargetCallback === "function") {
|
|
967
|
-
const focusTarget = this.columnDefinition.cellFocusTargetCallback(this);
|
|
968
|
-
if (focusTarget !== null) {
|
|
969
|
-
focusTarget.focus();
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
break;
|
|
973
|
-
}
|
|
974
|
-
this.$emit("cell-focused", this);
|
|
975
|
-
}
|
|
976
|
-
handleFocusout(_) {
|
|
977
|
-
this.shadowRoot.querySelector(".base").classList.remove("active");
|
|
978
|
-
if (this !== document.activeElement && !this.contains(document.activeElement)) {
|
|
979
|
-
this.isActiveCell = false;
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
handleKeydown(e) {
|
|
983
|
-
if (e.defaultPrevented || this.columnDefinition === null || this.cellType === DataGridCellTypes.default && this.columnDefinition.cellInternalFocusQueue !== true || this.cellType === DataGridCellTypes.columnHeader && this.columnDefinition.headerCellInternalFocusQueue !== true) {
|
|
984
|
-
return;
|
|
985
|
-
}
|
|
986
|
-
switch (e.key) {
|
|
987
|
-
case keyEnter:
|
|
988
|
-
case keyFunction2:
|
|
989
|
-
if (this.contains(document.activeElement) && document.activeElement !== this) {
|
|
990
|
-
return;
|
|
991
|
-
}
|
|
992
|
-
switch (this.cellType) {
|
|
993
|
-
case DataGridCellTypes.columnHeader:
|
|
994
|
-
if (this.columnDefinition.headerCellFocusTargetCallback !== void 0) {
|
|
995
|
-
const focusTarget = this.columnDefinition.headerCellFocusTargetCallback(this);
|
|
996
|
-
if (focusTarget !== null) {
|
|
997
|
-
focusTarget.focus();
|
|
998
|
-
}
|
|
999
|
-
e.preventDefault();
|
|
1000
|
-
}
|
|
1001
|
-
break;
|
|
1002
|
-
default:
|
|
1003
|
-
if (this.columnDefinition.cellFocusTargetCallback !== void 0) {
|
|
1004
|
-
const focusTarget = this.columnDefinition.cellFocusTargetCallback(this);
|
|
1005
|
-
if (focusTarget !== null) {
|
|
1006
|
-
focusTarget.focus();
|
|
1007
|
-
}
|
|
1008
|
-
e.preventDefault();
|
|
1009
|
-
}
|
|
1010
|
-
break;
|
|
1011
|
-
}
|
|
1012
|
-
break;
|
|
1013
|
-
case keyEscape:
|
|
1014
|
-
if (this.contains(document.activeElement) && document.activeElement !== this) {
|
|
1015
|
-
this.focus();
|
|
1016
|
-
e.preventDefault();
|
|
1017
|
-
}
|
|
1018
|
-
break;
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
updateCellView() {
|
|
1022
|
-
this.disconnectCellView();
|
|
1023
|
-
if (this.columnDefinition === null) {
|
|
1024
|
-
return;
|
|
1025
|
-
}
|
|
1026
|
-
switch (this.cellType) {
|
|
1027
|
-
case DataGridCellTypes.columnHeader:
|
|
1028
|
-
if (this.columnDefinition.headerCellTemplate !== void 0) {
|
|
1029
|
-
this.customCellView = this.columnDefinition.headerCellTemplate.render(
|
|
1030
|
-
this,
|
|
1031
|
-
this
|
|
1032
|
-
);
|
|
1033
|
-
} else {
|
|
1034
|
-
this.customCellView = defaultHeaderCellContentsTemplate.render(
|
|
1035
|
-
this,
|
|
1036
|
-
this
|
|
1037
|
-
);
|
|
1038
|
-
}
|
|
1039
|
-
break;
|
|
1040
|
-
case DataGridCellTypes.rowHeader:
|
|
1041
|
-
case DataGridCellTypes.default:
|
|
1042
|
-
if (this.columnDefinition.cellTemplate !== void 0) {
|
|
1043
|
-
this.customCellView = this.columnDefinition.cellTemplate.render(
|
|
1044
|
-
this,
|
|
1045
|
-
this
|
|
1046
|
-
);
|
|
1047
|
-
} else {
|
|
1048
|
-
this.customCellView = defaultCellContentsTemplate.render(this, this);
|
|
1049
|
-
}
|
|
1050
|
-
break;
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
disconnectCellView() {
|
|
1054
|
-
if (this.customCellView !== null) {
|
|
1055
|
-
this.customCellView.dispose();
|
|
1056
|
-
this.customCellView = null;
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
ariaSelectedChanged(_, selectedState) {
|
|
1060
|
-
this.shadowRoot.querySelector(".base")?.classList.toggle(
|
|
1061
|
-
"selected",
|
|
1062
|
-
selectedState === "true"
|
|
1063
|
-
);
|
|
1064
|
-
}
|
|
1065
|
-
#getColumnDataKey() {
|
|
1066
|
-
return this.columnDefinition && this.columnDefinition.columnDataKey ? this.columnDefinition.columnDataKey : this.textContent.trim();
|
|
1067
|
-
}
|
|
1068
|
-
/**
|
|
1069
|
-
* @internal
|
|
1070
|
-
*/
|
|
1071
|
-
_handleInteraction() {
|
|
1072
|
-
const isHeaderCell = this.cellType === "columnheader";
|
|
1073
|
-
const isSortable = isHeaderCell && this.ariaSort !== null;
|
|
1074
|
-
if (isSortable) {
|
|
1075
|
-
this.$emit("sort", {
|
|
1076
|
-
columnDataKey: this.#getColumnDataKey(),
|
|
1077
|
-
sortDirection: this.ariaSort
|
|
1078
|
-
});
|
|
1079
|
-
}
|
|
1080
|
-
const hasInternalFocusQueue = isHeaderCell ? this.columnDefinition?.headerCellInternalFocusQueue : this.columnDefinition?.cellInternalFocusQueue;
|
|
1081
|
-
if (!hasInternalFocusQueue) {
|
|
1082
|
-
this.$emit("cell-click", {
|
|
1083
|
-
cell: this,
|
|
1084
|
-
row: this.parentElement,
|
|
1085
|
-
isHeaderCell,
|
|
1086
|
-
columnDataKey: this.#getColumnDataKey()
|
|
1087
|
-
});
|
|
1088
|
-
}
|
|
1089
|
-
return true;
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
__decorateClass([
|
|
1093
|
-
attr({ attribute: "cell-type" })
|
|
1094
|
-
], DataGridCell.prototype, "cellType");
|
|
1095
|
-
__decorateClass([
|
|
1096
|
-
attr({ attribute: "grid-column" })
|
|
1097
|
-
], DataGridCell.prototype, "gridColumn");
|
|
1098
|
-
__decorateClass([
|
|
1099
|
-
observable
|
|
1100
|
-
], DataGridCell.prototype, "rowData");
|
|
1101
|
-
__decorateClass([
|
|
1102
|
-
observable
|
|
1103
|
-
], DataGridCell.prototype, "columnDefinition");
|
|
1104
|
-
__decorateClass([
|
|
1105
|
-
attr({ attribute: "aria-selected", mode: "fromView" })
|
|
1106
|
-
], DataGridCell.prototype, "ariaSelected");
|
|
1107
|
-
__decorateClass([
|
|
1108
|
-
attr({ attribute: "aria-sort" })
|
|
1109
|
-
], DataGridCell.prototype, "ariaSort");
|
|
1110
|
-
|
|
1111
1186
|
function createCellItemTemplate(context) {
|
|
1112
1187
|
const cellTag = context.tagFor(DataGridCell);
|
|
1113
1188
|
return html`
|
|
@@ -1133,6 +1208,7 @@ function createHeaderCellItemTemplate(context) {
|
|
|
1133
1208
|
const DataGridRowTemplate = (context) => {
|
|
1134
1209
|
const cellItemTemplate = createCellItemTemplate(context);
|
|
1135
1210
|
const headerCellItemTemplate = createHeaderCellItemTemplate(context);
|
|
1211
|
+
const getBaseClasses = (x) => classNames("base", ["selected", !!x.selected]);
|
|
1136
1212
|
return html`
|
|
1137
1213
|
<template
|
|
1138
1214
|
role="row"
|
|
@@ -1142,12 +1218,12 @@ const DataGridRowTemplate = (context) => {
|
|
|
1142
1218
|
${children({
|
|
1143
1219
|
property: "cellElements",
|
|
1144
1220
|
filter: elements(
|
|
1145
|
-
'[role="cell"],[role="gridcell"],[role="columnheader"],[role="rowheader"]'
|
|
1221
|
+
'[role="cell"],[role="gridcell"],[role="columnheader"],[role="rowheader"],[cell-type]'
|
|
1146
1222
|
)
|
|
1147
1223
|
})}
|
|
1148
1224
|
>
|
|
1149
1225
|
<div
|
|
1150
|
-
class="
|
|
1226
|
+
class="${getBaseClasses}"
|
|
1151
1227
|
style="grid-template-columns: ${(x) => x.gridTemplateColumns};"
|
|
1152
1228
|
>
|
|
1153
1229
|
<slot ${slotted("slottedCellElements")}></slot>
|
|
@@ -1157,13 +1233,16 @@ const DataGridRowTemplate = (context) => {
|
|
|
1157
1233
|
};
|
|
1158
1234
|
|
|
1159
1235
|
function shouldShowSortIcons(x) {
|
|
1160
|
-
|
|
1161
|
-
x.ariaSort = !x.columnDefinition.sortable ? null : x.columnDefinition.sortDirection ? x.columnDefinition.sortDirection : DataGridCellSortStates.none;
|
|
1162
|
-
}
|
|
1163
|
-
return x.cellType === "columnheader" && x.ariaSort !== null && x.ariaSort !== DataGridCellSortStates.other;
|
|
1236
|
+
return x.cellType === "columnheader" && x.sortDirection !== void 0 && x.sortDirection !== DataGridCellSortStates.other;
|
|
1164
1237
|
}
|
|
1165
1238
|
function getSortIcon(x) {
|
|
1166
|
-
|
|
1239
|
+
if (x.sortDirection === DataGridCellSortStates.ascending) {
|
|
1240
|
+
return "sort-asc-solid";
|
|
1241
|
+
}
|
|
1242
|
+
if (x.sortDirection === DataGridCellSortStates.descending) {
|
|
1243
|
+
return "sort-desc-solid";
|
|
1244
|
+
}
|
|
1245
|
+
return "sort-solid";
|
|
1167
1246
|
}
|
|
1168
1247
|
function renderSortIcons(c) {
|
|
1169
1248
|
const iconTag = c.tagFor(Icon);
|
|
@@ -1184,6 +1263,7 @@ function handleKeyDown(x, e) {
|
|
|
1184
1263
|
}
|
|
1185
1264
|
const DataGridCellTemplate = (context) => {
|
|
1186
1265
|
const visuallyHiddenTagName = context.tagFor(VisuallyHidden);
|
|
1266
|
+
const getBaseClasses = (x) => classNames("base", ["selected", !!x.selected]);
|
|
1187
1267
|
return html`
|
|
1188
1268
|
<template
|
|
1189
1269
|
tabindex="-1"
|
|
@@ -1192,7 +1272,7 @@ const DataGridCellTemplate = (context) => {
|
|
|
1192
1272
|
@keydown="${(x, c) => handleKeyDown(x, c.event)}"
|
|
1193
1273
|
>
|
|
1194
1274
|
<div
|
|
1195
|
-
class="
|
|
1275
|
+
class="${getBaseClasses}"
|
|
1196
1276
|
role="${(x) => shouldShowSortIcons(x) ? "button" : void 0}"
|
|
1197
1277
|
>
|
|
1198
1278
|
${(x) => x.ariaSelected === "true" ? html`<${visuallyHiddenTagName}>${(x2) => x2.locale.dataGrid.cell.selected}</${visuallyHiddenTagName}>` : null}
|