@vaadin/component-base
Advanced tools
Comparing version 23.0.0-alpha2 to 23.0.0-alpha3
{ | ||
"name": "@vaadin/component-base", | ||
"version": "23.0.0-alpha2", | ||
"version": "23.0.0-alpha3", | ||
"publishConfig": { | ||
@@ -44,3 +44,3 @@ "access": "public" | ||
}, | ||
"gitHead": "070f586dead02ca41b66717820c647f48bf1665f" | ||
"gitHead": "490037919a9e054cc002c1b3be0c94a1603e1a44" | ||
} |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
@@ -185,6 +185,9 @@ /** | ||
microtaskScheduled = true; | ||
microtaskNode.textContent = microtaskNodeContent++; | ||
microtaskNode.textContent = microtaskNodeContent; | ||
microtaskNodeContent += 1; | ||
} | ||
microtaskCallbacks.push(callback); | ||
return microtaskCurrHandle++; | ||
const result = microtaskCurrHandle; | ||
microtaskCurrHandle += 1; | ||
return result; | ||
}, | ||
@@ -191,0 +194,0 @@ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -35,3 +35,3 @@ */ | ||
static get version() { | ||
return '23.0.0-alpha2'; | ||
return '23.0.0-alpha3'; | ||
} | ||
@@ -38,0 +38,0 @@ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -11,3 +11,3 @@ */ | ||
*/ | ||
declare class FocusTrapController implements ReactiveController { | ||
export class FocusTrapController implements ReactiveController { | ||
constructor(node: HTMLElement); | ||
@@ -14,0 +14,0 @@ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
@@ -196,3 +196,3 @@ /** | ||
if (this.grid) { | ||
val = val - (val % this._itemsPerRow); | ||
val -= val % this._itemsPerRow; | ||
} | ||
@@ -210,3 +210,3 @@ this._virtualStartVal = val; | ||
set _physicalStart(val) { | ||
val = val % this._physicalCount; | ||
val %= this._physicalCount; | ||
if (val < 0) { | ||
@@ -216,3 +216,3 @@ val = this._physicalCount + val; | ||
if (this.grid) { | ||
val = val - (val % this._itemsPerRow); | ||
val -= val % this._itemsPerRow; | ||
} | ||
@@ -266,3 +266,3 @@ this._physicalStartVal = val; | ||
idx = | ||
this._iterateItems(function (pidx, vidx) { | ||
this._iterateItems((pidx, vidx) => { | ||
physicalOffset += this._getPhysicalSizeIncrement(pidx); | ||
@@ -295,3 +295,3 @@ | ||
var physicalOffset = this._physicalTop + this._scrollOffset; | ||
this._iterateItems(function (pidx, vidx) { | ||
this._iterateItems((pidx, vidx) => { | ||
if (physicalOffset < this._scrollBottom) { | ||
@@ -342,6 +342,6 @@ idx = vidx; | ||
if (Math.abs(delta) > this._physicalSize && this._physicalSize > 0) { | ||
delta = delta - this._scrollOffset; | ||
delta -= this._scrollOffset; | ||
var idxAdjustment = Math.round(delta / this._physicalAverage) * this._itemsPerRow; | ||
this._virtualStart = this._virtualStart + idxAdjustment; | ||
this._physicalStart = this._physicalStart + idxAdjustment; | ||
this._virtualStart += idxAdjustment; | ||
this._physicalStart += idxAdjustment; | ||
// Estimate new physical offset based on the virtual start index. | ||
@@ -362,7 +362,7 @@ // adjusts the physical start position to stay in sync with the clamped | ||
this._physicalTop = reusables.physicalTop; | ||
this._virtualStart = this._virtualStart + reusables.indexes.length; | ||
this._physicalStart = this._physicalStart + reusables.indexes.length; | ||
this._virtualStart += reusables.indexes.length; | ||
this._physicalStart += reusables.indexes.length; | ||
} else { | ||
this._virtualStart = this._virtualStart - reusables.indexes.length; | ||
this._physicalStart = this._physicalStart - reusables.indexes.length; | ||
this._virtualStart -= reusables.indexes.length; | ||
this._physicalStart -= reusables.indexes.length; | ||
} | ||
@@ -406,3 +406,3 @@ this._update(reusables.indexes, isScrollingDown ? null : reusables.indexes); | ||
physicalItemHeight = this._getPhysicalSizeIncrement(ith); | ||
offsetContent = offsetContent - physicalItemHeight; | ||
offsetContent -= physicalItemHeight; | ||
if (idxs.length >= physicalCount || offsetContent <= protectedOffsetContent) { | ||
@@ -421,3 +421,3 @@ break; | ||
idxs.push(ith); | ||
top = top + physicalItemHeight; | ||
top += physicalItemHeight; | ||
ith = (ith + 1) % physicalCount; | ||
@@ -434,3 +434,3 @@ } else { | ||
idxs.push(ith); | ||
top = top - physicalItemHeight; | ||
top -= physicalItemHeight; | ||
ith = ith === 0 ? physicalCount - 1 : ith - 1; | ||
@@ -505,3 +505,3 @@ } | ||
} | ||
this._physicalCount = this._physicalCount + delta; | ||
this._physicalCount += delta; | ||
// Update the physical start if it needs to preserve the model of the | ||
@@ -516,3 +516,3 @@ // focused item. In this situation, the focused item is currently rendered | ||
) { | ||
this._physicalStart = this._physicalStart + delta; | ||
this._physicalStart += delta; | ||
} | ||
@@ -550,4 +550,4 @@ this._update(); | ||
this._physicalTop = reusables.physicalTop; | ||
this._virtualStart = this._virtualStart + reusables.indexes.length; | ||
this._physicalStart = this._physicalStart + reusables.indexes.length; | ||
this._virtualStart += reusables.indexes.length; | ||
this._physicalStart += reusables.indexes.length; | ||
this._update(reusables.indexes); | ||
@@ -684,3 +684,3 @@ this._update(); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
this._iterateItems(function (pidx, vidx) { | ||
this._iterateItems((pidx, vidx) => { | ||
oldPhysicalSize += this._physicalSizes[pidx]; | ||
@@ -729,7 +729,7 @@ this._physicalSizes[pidx] = this._physicalItems[pidx].offsetHeight; | ||
this._iterateItems(function (pidx, vidx) { | ||
this._iterateItems((pidx, vidx) => { | ||
var modulus = vidx % this._itemsPerRow; | ||
var x = Math.floor(modulus * this._itemWidth + rowOffset); | ||
if (this._isRTL) { | ||
x = x * -1; | ||
x *= -1; | ||
} | ||
@@ -744,3 +744,3 @@ this.translate3d(x + 'px', y + 'px', 0, this._physicalItems[pidx]); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
this._iterateItems(function (pidx, vidx) { | ||
this._iterateItems((pidx, vidx) => { | ||
const item = this._physicalItems[pidx]; | ||
@@ -790,3 +790,3 @@ this.translate3d(0, y + 'px', 0, item); | ||
if (deltaHeight !== 0) { | ||
this._physicalTop = this._physicalTop - deltaHeight; | ||
this._physicalTop -= deltaHeight; | ||
// This may be called outside of a scrollHandler, so use last cached position | ||
@@ -867,5 +867,5 @@ var scrollTop = this._scrollPosition; | ||
while (currentVirtualItem < idx && targetOffsetTop <= hiddenContentSize) { | ||
targetOffsetTop = targetOffsetTop + this._getPhysicalSizeIncrement(currentTopItem); | ||
targetOffsetTop += this._getPhysicalSizeIncrement(currentTopItem); | ||
currentTopItem = (currentTopItem + 1) % this._physicalCount; | ||
currentVirtualItem++; | ||
currentVirtualItem += 1; | ||
} | ||
@@ -896,3 +896,3 @@ this._updateScrollerSize(true); | ||
'_render', | ||
function () { | ||
() => { | ||
// clear cached visible index. | ||
@@ -899,0 +899,0 @@ this._firstVisibleIndexVal = null; |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -8,3 +8,3 @@ */ | ||
export class SlotController implements ReactiveController { | ||
export class SlotController extends EventTarget implements ReactiveController { | ||
constructor( | ||
@@ -38,2 +38,8 @@ host: HTMLElement, | ||
protected defaultId: string; | ||
protected attachDefaultNode(): Node | undefined; | ||
protected initNode(node: Node): void; | ||
/** | ||
@@ -40,0 +46,0 @@ * Override to initialize the newly added custom node. |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -11,4 +11,6 @@ */ | ||
*/ | ||
export class SlotController { | ||
export class SlotController extends EventTarget { | ||
constructor(host, slotName, slotFactory, slotInitializer) { | ||
super(); | ||
this.host = host; | ||
@@ -18,34 +20,34 @@ this.slotName = slotName; | ||
this.slotInitializer = slotInitializer; | ||
this.defaultId = SlotController.generateId(slotName, host); | ||
} | ||
/** | ||
* Ensure that every instance has unique ID. | ||
* | ||
* @param {string} slotName | ||
* @param {HTMLElement} host | ||
* @return {string} | ||
* @protected | ||
*/ | ||
static generateId(slotName, host) { | ||
const prefix = slotName || 'default'; | ||
// Maintain the unique ID counter for a given prefix. | ||
this[`${prefix}Id`] = 1 + this[`${prefix}Id`] || 0; | ||
return `${prefix}-${host.localName}-${this[`${prefix}Id`]}`; | ||
} | ||
hostConnected() { | ||
if (!this.initialized) { | ||
const { host, slotName, slotFactory, slotInitializer } = this; | ||
let node = this.getSlotChild(); | ||
const slotted = this.getSlotChild(); | ||
if (!slotted) { | ||
// Slot factory is optional, some slots don't have default content. | ||
if (slotFactory) { | ||
const slotContent = slotFactory(host); | ||
if (slotContent instanceof Element) { | ||
if (slotName !== '') { | ||
slotContent.setAttribute('slot', slotName); | ||
} | ||
host.appendChild(slotContent); | ||
this.node = slotContent; | ||
// Store reference to not pass default node to `initCustomNode`. | ||
this.defaultNode = slotContent; | ||
} | ||
} | ||
if (!node) { | ||
node = this.attachDefaultNode(); | ||
} else { | ||
this.node = slotted; | ||
this.node = node; | ||
this.initCustomNode(node); | ||
} | ||
// Don't try to bind `this` to initializer (normally it's arrow function). | ||
// Instead, pass the host as a first argument to access component's state. | ||
if (slotInitializer) { | ||
slotInitializer(host, this.node); | ||
} | ||
this.initNode(node); | ||
@@ -60,2 +62,32 @@ // TODO: Consider making this behavior opt-in to improve performance. | ||
/** | ||
* Create and attach default node using the slot factory. | ||
* @return {Node | undefined} | ||
* @protected | ||
*/ | ||
attachDefaultNode() { | ||
const { host, slotName, slotFactory } = this; | ||
// Check if the node was created previously and if so, reuse it. | ||
let node = this.defaultNode; | ||
// Slot factory is optional, some slots don't have default content. | ||
if (!node && slotFactory) { | ||
node = slotFactory(host); | ||
if (node instanceof Element) { | ||
if (slotName !== '') { | ||
node.setAttribute('slot', slotName); | ||
} | ||
this.node = node; | ||
this.defaultNode = node; | ||
} | ||
} | ||
if (node) { | ||
host.appendChild(node); | ||
} | ||
return node; | ||
} | ||
/** | ||
* Return a reference to the node managed by the controller. | ||
@@ -76,2 +108,15 @@ * @return {Node} | ||
/** | ||
* @param {Node} node | ||
* @protected | ||
*/ | ||
initNode(node) { | ||
const { slotInitializer } = this; | ||
// Don't try to bind `this` to initializer (normally it's arrow function). | ||
// Instead, pass the host as a first argument to access component's state. | ||
if (slotInitializer) { | ||
slotInitializer(this.host, node); | ||
} | ||
} | ||
/** | ||
* Override to initialize the newly added custom node. | ||
@@ -122,2 +167,4 @@ * | ||
this.initCustomNode(newNode); | ||
this.initNode(newNode); | ||
} | ||
@@ -124,0 +171,0 @@ } |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2021 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
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
158891
46
4466