UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

5 lines (4 loc) 6.09 kB
/*! All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://github.com/Esri/calcite-design-system/blob/dev/LICENSE.md for details. v3.2.1 */ import{a as b,b as f}from"./BVJFCLMH.js";import{d as g}from"./CKRTMNFR.js";import{a as p,b as h}from"./5RDOSP2E.js";import{e as u}from"./3ADX47DD.js";import{d as m}from"./HPN2C7M6.js";import"./JOSABGK6.js";import"./NNVH7JUI.js";import{E as a,F as s,K as r,R as d,c,d as o,h as n}from"./BJZTU5BQ.js";var e={contentCell:"content-cell",numberCell:"number-cell",footerCell:"footer-cell",selectionCell:"selection-cell",selectedCell:"selected-cell",assistiveText:"assistive-text",lastCell:"last-cell",staticCell:"static-cell"},C=c`:host([disabled]){cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-opacity-disabled)}:host([disabled]) *,:host([disabled]) ::slotted(*){pointer-events:none}:host{--calcite-internal-table-cell-background: var(--calcite-table-cell-background, transparent);display:contents}:host([alignment=center]) td:not(.selection-cell):not(.number-cell){text-align:center}:host([alignment=end]) td:not(.selection-cell):not(.number-cell){text-align:end}.assistive-text{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}td{white-space:normal;text-align:start;vertical-align:middle;color:var(--calcite-color-text-1);background:var(--calcite-internal-table-cell-background);font-size:var(--calcite-internal-table-cell-font-size);border-inline-end:1px solid var(--calcite-color-border-3);padding:var(--calcite-internal-table-cell-padding)}td:not(.static-cell){outline-color:transparent}td:not(.static-cell):focus{outline:2px solid var(--calcite-color-focus, var(--calcite-ui-focus-color, var(--calcite-color-brand)));outline-offset:calc(-2px*(1 - (2*clamp(0,var(--calcite-offset-invert-focus),1))))}td.start.content-cell{vertical-align:top}td.end.content-cell{vertical-align:bottom}td.last-cell{border-inline-end:0}.number-cell{background-color:var(--calcite-color-foreground-2)}.footer-cell{background-color:var(--calcite-color-background);font-weight:var(--calcite-font-weight-medium);color:var(--calcite-color-text-1);border-block-start:1px solid var(--calcite-color-border-3)}.number-cell,.selection-cell{text-align:center;border-inline-end:1px solid var(--calcite-color-border-3);inline-size:2rem;min-inline-size:2rem}.selection-cell{color:var(--calcite-color-text-3);inset-inline-start:2rem}.selection-cell:not(.footer-cell){cursor:pointer}.selected-cell:not(.number-cell):not(.footer-cell){--calcite-internal-table-cell-background: var(--calcite-color-foreground-current)}.selection-cell.selected-cell{box-shadow:inset .25rem 0 0 0 var(--calcite-color-brand);color:var(--calcite-color-brand)}.selection-cell.selected-cell calcite-icon{color:var(--calcite-color-brand)}.calcite--rtl.selection-cell.selected-cell{box-shadow:inset -.25rem 0 0 0 var(--calcite-color-brand)}.selection-cell{vertical-align:middle}.selection-cell ::slotted(calcite-icon){pointer-events:none;margin-block-start:.25rem}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.interaction-container{display:contents}`,i=class extends a{constructor(){super(...arguments),this.containerEl=p(),this.messages=g(),this.contentsText="",this.focused=!1,this.selectionText="",this.alignment="start",this.interactionMode="interactive",this.parentRowAlignment="start",this.scale="m"}static{this.properties={contentsText:[16,{},{state:!0}],focused:[16,{},{state:!0}],selectionText:[16,{},{state:!0}],alignment:[3,{},{reflect:!0}],colSpan:[11,{},{reflect:!0,type:Number}],disabled:[5,{},{type:Boolean}],interactionMode:1,lastCell:[5,{},{type:Boolean}],messageOverrides:[0,{},{attribute:!1}],numberCell:[5,{},{type:Boolean}],parentRowAlignment:1,parentRowIsSelected:[5,{},{type:Boolean}],parentRowPositionLocalized:1,parentRowType:1,positionInRow:[9,{},{type:Number}],readCellContentsToAT:[5,{},{type:Boolean}],rowSpan:[11,{},{reflect:!0,type:Number}],scale:1,selectionCell:[5,{},{type:Boolean}]}}static{this.styles=C}async setFocus(){await m(this),this.containerEl.value.focus()}async load(){this.updateScreenReaderContentsText(),this.updateScreenReaderSelectionText()}willUpdate(t){t.has("parentRowIsSelected")&&this.updateScreenReaderSelectionText()}updated(){b(this)}updateScreenReaderSelectionText(){let t=`${this.messages?.row} ${this.parentRowPositionLocalized} ${this.messages?.selected} ${this.messages?.keyboardDeselect}`,l=`${this.messages?.row} ${this.parentRowPositionLocalized} ${this.messages?.unselected} ${this.messages?.keyboardSelect}`;this.selectionText=this.parentRowIsSelected?t:l}updateScreenReaderContentsText(){this.contentsText=this.el.textContent}onContainerBlur(){this.focused=!1}onContainerFocus(){this.focused=!0}render(){let t=u(this.el),l=this.disabled||this.interactionMode==="static"&&(!this.selectionCell||this.selectionCell&&this.parentRowType==="foot");return f({disabled:this.disabled,children:o`<td class=${s({[e.footerCell]:this.parentRowType==="foot",[e.contentCell]:!this.numberCell&&!this.selectionCell,[e.numberCell]:this.numberCell,[e.selectionCell]:this.selectionCell,[e.selectedCell]:this.parentRowIsSelected,[e.lastCell]:this.lastCell&&(!this.rowSpan||this.colSpan&&!!this.rowSpan),[r.rtl]:t==="rtl",[e.staticCell]:l,[this.parentRowAlignment]:this.parentRowAlignment==="start"||this.parentRowAlignment==="end"})} colSpan=${this.colSpan??n} @blur=${this.onContainerBlur} @focus=${this.onContainerFocus} .role=${this.interactionMode==="interactive"?"gridcell":"cell"} rowSpan=${this.rowSpan??n} .tabIndex=${l?-1:0} ${h(this.containerEl)}>${(this.selectionCell||this.readCellContentsToAT)&&o`<span .ariaLive=${this.focused?"polite":"off"} class=${s(e.assistiveText)}>${this.selectionCell&&this.selectionText||""}${this.readCellContentsToAT&&!this.selectionCell&&this.contentsText||""}</span>`||""}<slot @slotchange=${this.updateScreenReaderContentsText}></slot></td>`})}};d("calcite-table-cell",i);export{i as TableCell};