@spectrum-web-components/base
Advanced tools
Comparing version 0.5.0 to 0.5.1
{ | ||
"name": "@spectrum-web-components/base", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"publishConfig": { | ||
@@ -59,3 +59,3 @@ "access": "public" | ||
"sideEffects": false, | ||
"gitHead": "7ce77352f6894043bceac9ef92b21e5f85420969" | ||
"gitHead": "df3f333ee26a45f9fc247716b6e8ef051dca630b" | ||
} |
@@ -6,10 +6,12 @@ import { ReactiveElement } from 'lit'; | ||
}; | ||
export declare type ElementSize = 's' | 'm' | 'l' | 'xl' | 'xxl'; | ||
export declare type ElementSize = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'; | ||
export declare type DefaultElementSize = Exclude<ElementSize, 'xxs' | 'xs' | 'xxl'>; | ||
export interface SizedElementInterface { | ||
size: ElementSize; | ||
} | ||
export declare function SizedMixin<T extends Constructor<ReactiveElement>>(constructor: T, { validSizes, noDefaultSize, }?: { | ||
export declare function SizedMixin<T extends Constructor<ReactiveElement>>(constructor: T, { validSizes, noDefaultSize, defaultSize, }?: { | ||
validSizes?: ElementSize[]; | ||
noDefaultSize?: boolean; | ||
defaultSize?: ElementSize; | ||
}): T & Constructor<SizedElementInterface>; | ||
export {}; |
import { __decorate } from "tslib"; | ||
import { property } from 'lit/decorators.js'; | ||
export function SizedMixin(constructor, { validSizes = ['s', 'm', 'l', 'xl'], noDefaultSize, } = {}) { | ||
export function SizedMixin(constructor, { validSizes = ['s', 'm', 'l', 'xl'], noDefaultSize, defaultSize = 'm', } = {}) { | ||
class SizedElement extends constructor { | ||
constructor() { | ||
super(...arguments); | ||
this._size = 'm'; | ||
this._size = defaultSize; | ||
} | ||
get size() { | ||
return this._size || 'm'; | ||
return this._size || defaultSize; | ||
} | ||
set size(value) { | ||
const defaultSize = noDefaultSize ? null : 'm'; | ||
const fallbackSize = noDefaultSize ? null : defaultSize; | ||
const size = (value ? value.toLocaleLowerCase() : value); | ||
const validSize = (validSizes.includes(size) ? size : defaultSize); | ||
const validSize = (validSizes.includes(size) ? size : fallbackSize); | ||
if (validSize) { | ||
@@ -17,0 +17,0 @@ this.setAttribute('size', validSize); |
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
5
60037
24
418