@spectrum-web-components/field-label
Advanced tools
Comparing version 0.5.5-alpha.1 to 0.5.5
@@ -68,2 +68,10 @@ { | ||
"kind": "field", | ||
"name": "slotEl", | ||
"type": { | ||
"text": "HTMLSlotElement" | ||
}, | ||
"privacy": "public" | ||
}, | ||
{ | ||
"kind": "field", | ||
"name": "sideAligned", | ||
@@ -93,3 +101,11 @@ "type": { | ||
} | ||
} | ||
}, | ||
"parameters": [ | ||
{ | ||
"name": "event", | ||
"type": { | ||
"text": "Event" | ||
} | ||
} | ||
] | ||
}, | ||
@@ -105,2 +121,10 @@ { | ||
} | ||
}, | ||
{ | ||
"kind": "field", | ||
"name": "labelText", | ||
"type": { | ||
"text": "string" | ||
}, | ||
"privacy": "private" | ||
} | ||
@@ -230,10 +254,4 @@ ], | ||
] | ||
}, | ||
{ | ||
"kind": "javascript-module", | ||
"path": "test/field-label.test-vrt.ts", | ||
"declarations": [], | ||
"exports": [] | ||
} | ||
] | ||
} |
{ | ||
"name": "@spectrum-web-components/field-label", | ||
"version": "0.5.5-alpha.1+c7dd897f", | ||
"version": "0.5.5", | ||
"publishConfig": { | ||
@@ -47,6 +47,6 @@ "access": "public" | ||
"dependencies": { | ||
"@spectrum-web-components/base": "^0.4.6-alpha.40+c7dd897f", | ||
"@spectrum-web-components/icon": "^0.9.10-alpha.1+c7dd897f", | ||
"@spectrum-web-components/icons-ui": "^0.6.10-alpha.1+c7dd897f", | ||
"@spectrum-web-components/shared": "^0.12.8-alpha.40+c7dd897f", | ||
"@spectrum-web-components/base": "^0.4.5", | ||
"@spectrum-web-components/icon": "^0.9.9", | ||
"@spectrum-web-components/icons-ui": "^0.6.9", | ||
"@spectrum-web-components/shared": "^0.12.7", | ||
"tslib": "^2.0.0" | ||
@@ -62,3 +62,3 @@ }, | ||
], | ||
"gitHead": "c7dd897fd72154e0dd172b15c8b39c13670c7f25" | ||
"gitHead": "e437f5c415e0fbd686258f641077a928b6e589af" | ||
} |
@@ -1,2 +0,2 @@ | ||
declare const styles: import("@spectrum-web-components/base").CSSResultGroup; | ||
declare const styles: import("@spectrum-web-components/base").CSSResult; | ||
export default styles; |
@@ -20,2 +20,3 @@ import { SpectrumElement, CSSResultArray, TemplateResult, PropertyValues } from '@spectrum-web-components/base'; | ||
required: boolean; | ||
slotEl: HTMLSlotElement; | ||
sideAligned?: 'start' | 'end'; | ||
@@ -25,2 +26,3 @@ private target?; | ||
private manageFor; | ||
private get labelText(); | ||
protected render(): TemplateResult; | ||
@@ -27,0 +29,0 @@ protected firstUpdated(changes: PropertyValues): void; |
@@ -13,3 +13,3 @@ /* | ||
import { __decorate } from "tslib"; | ||
import { html, SpectrumElement, property, SizedMixin, } from '@spectrum-web-components/base'; | ||
import { html, SpectrumElement, property, SizedMixin, query, } from '@spectrum-web-components/base'; | ||
import '@spectrum-web-components/icons-ui/icons/sp-icon-asterisk100.js'; | ||
@@ -32,4 +32,4 @@ import asteriskIconStyles from '@spectrum-web-components/icon/src/spectrum-icon-asterisk.css.js'; | ||
} | ||
handleClick() { | ||
if (!this.target || this.disabled) | ||
handleClick(event) { | ||
if (!this.target || this.disabled || event.defaultPrevented) | ||
return; | ||
@@ -57,2 +57,5 @@ this.target.focus(); | ||
} | ||
if (target.localName.search('-') > 0) { | ||
await customElements.whenDefined(target.localName); | ||
} | ||
if (typeof target.updateComplete !== 'undefined') { | ||
@@ -68,3 +71,3 @@ await target.updateComplete; | ||
else { | ||
this.target.setAttribute('aria-label', (this.textContent || /* c8 ignore next */ '').trim()); | ||
this.target.setAttribute('aria-label', this.labelText); | ||
} | ||
@@ -74,6 +77,14 @@ } | ||
} | ||
get labelText() { | ||
const assignedNodes = this.slotEl.assignedNodes({ flatten: true }); | ||
if (!assignedNodes.length) { | ||
return ''; | ||
} | ||
const labelText = assignedNodes.map((node) => (node.textContent || /* c8 ignore next */ '').trim()); | ||
return labelText.join(' '); | ||
} | ||
render() { | ||
return html ` | ||
<label> | ||
<slot></slot> | ||
<slot @slotchange=${this.manageFor}></slot> | ||
${this.required | ||
@@ -120,4 +131,7 @@ ? html ` | ||
__decorate([ | ||
query('slot') | ||
], FieldLabel.prototype, "slotEl", void 0); | ||
__decorate([ | ||
property({ type: String, reflect: true, attribute: 'side-aligned' }) | ||
], FieldLabel.prototype, "sideAligned", void 0); | ||
//# sourceMappingURL=FieldLabel.js.map |
@@ -1,2 +0,2 @@ | ||
declare const styles: import("@spectrum-web-components/base").CSSResultGroup; | ||
declare const styles: import("@spectrum-web-components/base").CSSResult; | ||
export default styles; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
0
95318
22
777