api-viewer-element
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -19,2 +19,8 @@ # Change Log | ||
## [0.3.4] - 2019-12-20 | ||
### Fixed | ||
- Demo: do not throw when property type is empty | ||
## [0.3.3] - 2019-12-19 | ||
@@ -21,0 +27,0 @@ |
@@ -110,3 +110,6 @@ import { __decorate } from "tslib"; | ||
this.addEventListener('focus', () => this._setFocused(true), true); | ||
this.addEventListener('blur', () => this._setFocused(false), true); | ||
this.addEventListener('blur', () => { | ||
this._setFocused(false); | ||
this._setActive(false); | ||
}, true); | ||
this.addEventListener('mousedown', () => { | ||
@@ -128,21 +131,7 @@ this._setActive((this._mousedown = true)); | ||
_setActive(active) { | ||
if (active) { | ||
this.setAttribute('active', ''); | ||
} | ||
else { | ||
this.removeAttribute('active'); | ||
} | ||
this.toggleAttribute('active', active); | ||
} | ||
_setFocused(focused) { | ||
if (focused) { | ||
this.setAttribute('focused', ''); | ||
if (!this._mousedown) { | ||
this.setAttribute('focus-ring', ''); | ||
} | ||
} | ||
else { | ||
this.removeAttribute('focused'); | ||
this.removeAttribute('focus-ring'); | ||
this._setActive(false); | ||
} | ||
this.toggleAttribute('focused', focused); | ||
this.toggleAttribute('focus-ring', focused && !this._mousedown); | ||
} | ||
@@ -149,0 +138,0 @@ }; |
import { directive, NodePart } from 'lit-html'; | ||
import { getHostTemplateNode, getSlotTemplate, hasSlotTemplate } from './utils.js'; | ||
import { getHostTemplateNode, getSlotTemplate, hasSlotTemplate, normalizeType } from './utils.js'; | ||
const caches = new WeakMap(); | ||
const applyKnobs = (component, knobs) => { | ||
Object.keys(knobs).forEach((key) => { | ||
const knob = knobs[key]; | ||
if (knob.type === 'boolean') { | ||
if (knob.value) { | ||
component.setAttribute(key, ''); | ||
} | ||
else { | ||
component.removeAttribute(key); | ||
} | ||
const { type, value } = knobs[key]; | ||
if (normalizeType(type) === 'boolean') { | ||
component.toggleAttribute(key, Boolean(value)); | ||
} | ||
else { | ||
component[key] = knob.value; | ||
component[key] = value; | ||
} | ||
@@ -18,0 +13,0 @@ }); |
@@ -8,3 +8,3 @@ export declare const getSlotTitle: (name: string) => string; | ||
export declare const isEmptyArray: (array: unknown[]) => boolean; | ||
export declare const normalizeType: (type: string) => string; | ||
export declare const normalizeType: (type?: string | undefined) => string; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -28,3 +28,3 @@ export const getSlotTitle = (name) => { | ||
export const isEmptyArray = (array) => array.length === 0; | ||
export const normalizeType = (type) => type.replace(' | undefined', '').replace(' | null', ''); | ||
export const normalizeType = (type = '') => type.replace(' | undefined', '').replace(' | null', ''); | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "api-viewer-element", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Web Components API viewer element", | ||
@@ -5,0 +5,0 @@ "author": "Serhii Kulykov <iamkulykov@gmail.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
191101
2117