@spectrum-web-components/base
Advanced tools
Comparing version 0.3.2 to 0.3.3-alpha.33
@@ -6,2 +6,9 @@ # Change Log | ||
## [0.3.3](https://github.com/adobe/spectrum-web-components/compare/@spectrum-web-components/base@0.3.2...@spectrum-web-components/base@0.3.3) (2021-02-11) | ||
### Bug Fixes | ||
- expand sized functionality to support no default and returning to default values ([acf3cfb](https://github.com/adobe/spectrum-web-components/commit/acf3cfb000033d1ef1e22ca571cb8dbbeaadae77)) | ||
- reduce cycles ([8917a5e](https://github.com/adobe/spectrum-web-components/commit/8917a5efb28d2e3fcc68c9e25ae98c3b824d7fe4)) | ||
## [0.3.2](https://github.com/adobe/spectrum-web-components/compare/@spectrum-web-components/base@0.3.1...@spectrum-web-components/base@0.3.2) (2021-02-02) | ||
@@ -8,0 +15,0 @@ |
@@ -21,3 +21,3 @@ { | ||
], | ||
"version": "0.3.2", | ||
"version": "0.3.3-alpha.33+e6dea799", | ||
"description": "", | ||
@@ -30,3 +30,3 @@ "main": "./src/index.js", | ||
".": "./src/index.js", | ||
"./src/": "./src/", | ||
"./src/*": "./src/*", | ||
"./custom-elements.json": "./custom-elements.json", | ||
@@ -49,3 +49,2 @@ "./package.json": "./package.json" | ||
"dependencies": { | ||
"@spectrum-web-components/theme": "^0.7.3", | ||
"lit-element": "^2.4.0", | ||
@@ -55,3 +54,3 @@ "lit-html": "^1.0.0", | ||
}, | ||
"gitHead": "7783ce454deb5a97b3d274ee1b54a24c09065ce4" | ||
"gitHead": "e6dea7995d9fee4918cceb2cea83fcdccd7202ec" | ||
} |
@@ -10,3 +10,6 @@ import { UpdatingElement } from './index.js'; | ||
} | ||
export declare function SizedMixin<T extends Constructor<UpdatingElement>>(constructor: T, validSizes?: Partial<ElementSize>[]): T & Constructor<SizedElementInterface>; | ||
export declare function SizedMixin<T extends Constructor<UpdatingElement>>(constructor: T, { validSizes, noDefaultSize, }?: { | ||
validSizes?: Partial<ElementSize>[]; | ||
noDefaultSize?: boolean; | ||
}): T & Constructor<SizedElementInterface>; | ||
export {}; |
@@ -14,3 +14,3 @@ import { __decorate } from "tslib"; | ||
import { property } from './index.js'; | ||
export function SizedMixin(constructor, validSizes = ['s', 'm', 'l', 'xl']) { | ||
export function SizedMixin(constructor, { validSizes = ['s', 'm', 'l', 'xl'], noDefaultSize, } = {}) { | ||
class SizedElement extends constructor { | ||
@@ -22,14 +22,20 @@ constructor() { | ||
get size() { | ||
return this._size; | ||
return this._size || 'm'; | ||
} | ||
set size(value) { | ||
const size = value.toLocaleLowerCase(); | ||
const defaultSize = noDefaultSize ? null : 'm'; | ||
const size = (value | ||
? value.toLocaleLowerCase() | ||
: value); | ||
const validSize = (validSizes.includes(size) | ||
? size | ||
: 'm'); | ||
if (this._size === validSize) | ||
: defaultSize); | ||
if (validSize) { | ||
this.setAttribute('size', validSize); | ||
} | ||
if (this._size === validSize) { | ||
return; | ||
} | ||
const oldSize = this._size; | ||
this._size = validSize; | ||
this.setAttribute('size', validSize); | ||
this.requestUpdate('size', oldSize); | ||
@@ -39,3 +45,3 @@ } | ||
super.firstUpdated(changes); | ||
if (!this.hasAttribute('size')) { | ||
if (!this.hasAttribute('size') && !noDefaultSize) { | ||
this.setAttribute('size', this.size); | ||
@@ -42,0 +48,0 @@ } |
@@ -28,3 +28,9 @@ /* | ||
constructor: T, | ||
validSizes: Partial<ElementSize>[] = ['s', 'm', 'l', 'xl'] | ||
{ | ||
validSizes = ['s', 'm', 'l', 'xl'], | ||
noDefaultSize, | ||
}: { | ||
validSizes?: Partial<ElementSize>[]; | ||
noDefaultSize?: boolean; | ||
} = {} | ||
): T & Constructor<SizedElementInterface> { | ||
@@ -34,22 +40,29 @@ class SizedElement extends constructor { | ||
public get size(): ElementSize { | ||
return this._size; | ||
return this._size || 'm'; | ||
} | ||
public set size(value: ElementSize) { | ||
const size = value.toLocaleLowerCase() as ElementSize; | ||
const defaultSize = noDefaultSize ? null : 'm'; | ||
const size = (value | ||
? value.toLocaleLowerCase() | ||
: value) as ElementSize; | ||
const validSize = (validSizes.includes(size) | ||
? size | ||
: 'm') as ElementSize; | ||
if (this._size === validSize) return; | ||
: defaultSize) as ElementSize; | ||
if (validSize) { | ||
this.setAttribute('size', validSize); | ||
} | ||
if (this._size === validSize) { | ||
return; | ||
} | ||
const oldSize = this._size; | ||
this._size = validSize; | ||
this.setAttribute('size', validSize); | ||
this.requestUpdate('size', oldSize); | ||
} | ||
private _size: ElementSize = 'm'; | ||
private _size: ElementSize | null = 'm'; | ||
protected firstUpdated(changes: PropertyValues): void { | ||
super.firstUpdated(changes); | ||
if (!this.hasAttribute('size')) { | ||
if (!this.hasAttribute('size') && !noDefaultSize) { | ||
this.setAttribute('size', this.size); | ||
@@ -56,0 +69,0 @@ } |
Sorry, the diff of this file is not supported yet
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
48854
3
387
1
- Removed@spectrum-web-components/base@0.3.3(transitive)
- Removed@spectrum-web-components/styles@0.8.1(transitive)
- Removed@spectrum-web-components/theme@0.7.4(transitive)