Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vaadin/vaadin-element-mixin

Package Overview
Dependencies
Maintainers
18
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vaadin/vaadin-element-mixin - npm Package Compare versions

Comparing version 2.4.2 to 20.0.0-alpha1

36

package.json
{
"name": "@vaadin/vaadin-element-mixin",
"version": "20.0.0-alpha1",
"description": "vaadin-element-mixin",
"main": "vaadin-element-mixin.js",
"module": "vaadin-element-mixin.js",
"repository": "vaadin/vaadin-element-mixin",
"keywords": [

@@ -9,7 +14,2 @@ "Vaadin",

],
"repository": "vaadin/vaadin-element-mixin",
"homepage": "https://vaadin.com/components",
"name": "@vaadin/vaadin-element-mixin",
"version": "2.4.2",
"main": "vaadin-element-mixin.js",
"author": "Vaadin Ltd",

@@ -20,2 +20,3 @@ "license": "Apache-2.0",

},
"homepage": "https://vaadin.com/components",
"files": [

@@ -26,21 +27,16 @@ "custom_typings",

],
"resolutions": {
"inherits": "2.0.3",
"samsam": "1.1.3",
"supports-color": "3.1.2",
"type-detect": "1.0.0"
},
"dependencies": {
"@polymer/polymer": "^3.0.0",
"@vaadin/vaadin-usage-statistics": "^2.1.0",
"@vaadin/vaadin-development-mode-detector": "^2.0.0"
"@vaadin/vaadin-development-mode-detector": "^2.0.0",
"@vaadin/vaadin-usage-statistics": "^2.1.0"
},
"scripts": {
"generate-typings": "gen-typescript-declarations --outDir . --verify"
"devDependencies": {
"@esm-bundle/chai": "^4.1.5",
"@open-wc/testing-helpers": "^1.8.12",
"sinon": "^9.2.4"
},
"devDependencies": {
"@polymer/iron-test-helpers": "^3.0.0",
"@webcomponents/webcomponentsjs": "^2.0.0",
"wct-browser-legacy": "^1.0.1"
}
"publishConfig": {
"access": "public"
},
"gitHead": "93c8e0ec03a178c6d74261261f985bd07f7cc79c"
}
/**
* DO NOT EDIT
*
* This file was automatically generated by
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
*
* To modify these typings, edit the source file(s):
* vaadin-dir-helper.js
*/
// tslint:disable:variable-name Describing an API that's defined elsewhere.
/**
* Helper that provides a set of functions for RTL.
*/
declare class DirHelper {
/**

@@ -33,3 +19,3 @@ * Get the scroll type in the current browser view.

*/
static getNormalizedScrollLeft(scrollType: string, direction: string, element: Element|null): number;
static getNormalizedScrollLeft(scrollType: string, direction: string, element: Element | null): number;

@@ -43,5 +29,10 @@ /**

*/
static setNormalizedScrollLeft(scrollType: string, direction: string, element: Element|null, scrollLeft: number): void;
static setNormalizedScrollLeft(
scrollType: string,
direction: string,
element: Element | null,
scrollLeft: number
): void;
}
export {DirHelper};
export { DirHelper };
/**
@license
Copyright (c) 2020 Vaadin Ltd.
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
* @license
* Copyright (c) 2021 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
/**

@@ -47,5 +48,5 @@ * Helper that provides a set of functions for RTL.

* @return {number} the scrollLeft value.
*/
*/
static getNormalizedScrollLeft(scrollType, direction, element) {
const {scrollLeft} = element;
const { scrollLeft } = element;
if (direction !== 'rtl' || !scrollType) {

@@ -52,0 +53,0 @@ return scrollLeft;

@@ -1,35 +0,18 @@

/**
* DO NOT EDIT
*
* This file was automatically generated by
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
*
* To modify these typings, edit the source file(s):
* vaadin-dir-mixin.js
*/
export { DirMixin };
// tslint:disable:variable-name Describing an API that's defined elsewhere.
// tslint:disable:no-any describes the API as best we are able today
import {DirHelper} from './vaadin-dir-helper.js';
export {DirMixin};
declare function DirMixin<T extends new (...args: any[]) => {}>(base: T): T & DirMixinConstructor;
interface DirMixinConstructor {
new(...args: any[]): DirMixin;
new (...args: any[]): DirMixin;
finalize(): void;
}
export {DirMixinConstructor};
export { DirMixinConstructor };
interface DirMixin {
readonly dir: string|null|undefined;
connectedCallback(): void;
attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
disconnectedCallback(): void;
__getNormalizedScrollLeft(element: Element|null): number;
__setNormalizedScrollLeft(element: Element|null, scrollLeft: number): any;
readonly dir: string | null | undefined;
__getNormalizedScrollLeft(element: Element | null): number;
__setNormalizedScrollLeft(element: Element | null, scrollLeft: number): void;
}

@@ -0,2 +1,8 @@

/**
* @license
* Copyright (c) 2021 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { DirHelper } from './vaadin-dir-helper.js';
/**

@@ -6,5 +12,5 @@ * Array of Vaadin custom element classes that have been subscribed to the dir changes.

const directionSubscribers = [];
const directionUpdater = function() {
const directionUpdater = function () {
const documentDir = getDocumentDir();
directionSubscribers.forEach(element => {
directionSubscribers.forEach((element) => {
alignDirs(element, documentDir);

@@ -17,5 +23,5 @@ });

const directionObserver = new MutationObserver(directionUpdater);
directionObserver.observe(document.documentElement, {attributes: true, attributeFilter: ['dir']});
directionObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['dir'] });
const alignDirs = function(element, documentDir) {
const alignDirs = function (element, documentDir) {
if (documentDir) {

@@ -28,3 +34,3 @@ element.setAttribute('dir', documentDir);

const getDocumentDir = function() {
const getDocumentDir = function () {
return document.documentElement.getAttribute('dir');

@@ -36,91 +42,90 @@ };

*/
export const DirMixin = superClass => class VaadinDirMixin extends superClass {
static get properties() {
return {
/**
* @protected
*/
dir: {
type: String,
readOnly: true
}
};
}
export const DirMixin = (superClass) =>
class VaadinDirMixin extends superClass {
static get properties() {
return {
/**
* @protected
*/
dir: {
type: String,
readOnly: true
}
};
}
/** @protected */
static finalize() {
super.finalize();
/** @protected */
static finalize() {
super.finalize();
if (!scrollType) {
scrollType = DirHelper.detectScrollType();
if (!scrollType) {
scrollType = DirHelper.detectScrollType();
}
}
}
/** @protected */
connectedCallback() {
super.connectedCallback();
/** @protected */
connectedCallback() {
super.connectedCallback();
if (!this.hasAttribute('dir')) {
this.__subscribe();
alignDirs(this, getDocumentDir());
if (!this.hasAttribute('dir')) {
this.__subscribe();
alignDirs(this, getDocumentDir());
}
}
}
/** @protected */
attributeChangedCallback(name, oldValue, newValue) {
super.attributeChangedCallback(name, oldValue, newValue);
if (name !== 'dir') {
return;
/** @protected */
attributeChangedCallback(name, oldValue, newValue) {
super.attributeChangedCallback(name, oldValue, newValue);
if (name !== 'dir') {
return;
}
// New value equals to the document direction and the element is not subscribed to the changes
const newValueEqlDocDir = newValue === getDocumentDir() && directionSubscribers.indexOf(this) === -1;
// Value was emptied and the element is not subscribed to the changes
const newValueEmptied = !newValue && oldValue && directionSubscribers.indexOf(this) === -1;
// New value is different and the old equals to document direction and the element is not subscribed to the changes
const newDiffValue = newValue !== getDocumentDir() && oldValue === getDocumentDir();
if (newValueEqlDocDir || newValueEmptied) {
this.__subscribe();
alignDirs(this, getDocumentDir());
} else if (newDiffValue) {
this.__subscribe(false);
}
}
// New value equals to the document direction and the element is not subscribed to the changes
const newValueEqlDocDir = newValue === getDocumentDir() && directionSubscribers.indexOf(this) === -1;
// Value was emptied and the element is not subscribed to the changes
const newValueEmptied = !newValue && oldValue && directionSubscribers.indexOf(this) === -1;
// New value is different and the old equals to document direction and the element is not subscribed to the changes
const newDiffValue = newValue !== getDocumentDir() && oldValue === getDocumentDir();
if (newValueEqlDocDir || newValueEmptied) {
this.__subscribe();
alignDirs(this, getDocumentDir());
} else if (newDiffValue) {
/** @protected */
disconnectedCallback() {
super.disconnectedCallback();
this.__subscribe(false);
this.removeAttribute('dir');
}
}
/** @protected */
disconnectedCallback() {
super.disconnectedCallback();
this.__subscribe(false);
this.removeAttribute('dir');
}
/** @private */
__subscribe(push = true) {
if (push) {
directionSubscribers.indexOf(this) === -1 && directionSubscribers.push(this);
} else {
directionSubscribers.indexOf(this) > -1 && directionSubscribers.splice(directionSubscribers.indexOf(this), 1);
}
}
/** @private */
__subscribe(push = true) {
if (push) {
directionSubscribers.indexOf(this) === -1 &&
directionSubscribers.push(this);
} else {
directionSubscribers.indexOf(this) > -1 &&
directionSubscribers.splice(directionSubscribers.indexOf(this), 1);
/**
* @param {Element} element
* @return {number}
* @protected
*/
__getNormalizedScrollLeft(element) {
return DirHelper.getNormalizedScrollLeft(scrollType, this.getAttribute('dir') || 'ltr', element);
}
}
/**
* @param {Element} element
* @return {number}
* @protected
*/
__getNormalizedScrollLeft(element) {
return DirHelper.getNormalizedScrollLeft(scrollType, this.getAttribute('dir') || 'ltr', element);
}
/**
* @param {Element} element
* @param {number} scrollLeft
* @protected
*/
__setNormalizedScrollLeft(element, scrollLeft) {
return DirHelper.setNormalizedScrollLeft(scrollType, this.getAttribute('dir') || 'ltr', element, scrollLeft);
}
};
/**
* @param {Element} element
* @param {number} scrollLeft
* @protected
*/
__setNormalizedScrollLeft(element, scrollLeft) {
return DirHelper.setNormalizedScrollLeft(scrollType, this.getAttribute('dir') || 'ltr', element, scrollLeft);
}
};

@@ -1,42 +0,17 @@

/**
* DO NOT EDIT
*
* This file was automatically generated by
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
*
* To modify these typings, edit the source file(s):
* vaadin-element-mixin.js
*/
// tslint:disable:variable-name Describing an API that's defined elsewhere.
// tslint:disable:no-any describes the API as best we are able today
/// <reference path="custom_typings/vaadin-usage-statistics.d.ts" />
/// <reference path="custom_typings/vaadin.d.ts" />
import {idlePeriod} from '@polymer/polymer/lib/utils/async.js';
import { DirMixin, DirMixinConstructor } from './vaadin-dir-mixin.js';
import {Debouncer} from '@polymer/polymer/lib/utils/debounce.js';
declare function ElementMixin<T extends new (...args: any[]) => {}>(
base: T
): T & ElementMixinConstructor & DirMixinConstructor;
import {enqueueDebouncer} from '@polymer/polymer/lib/utils/flush.js';
import {DirMixin} from './vaadin-dir-mixin.js';
import {usageStatistics} from '@vaadin/vaadin-usage-statistics/vaadin-usage-statistics.js';
export {ElementMixin};
declare function ElementMixin<T extends new (...args: any[]) => {}>(base: T): T & ElementMixinConstructor & DirMixinConstructor;
import {DirMixinConstructor} from './vaadin-dir-mixin.js';
interface ElementMixinConstructor {
new(...args: any[]): ElementMixin;
new (...args: any[]): ElementMixin;
finalize(): void;
}
export {ElementMixinConstructor};
interface ElementMixin extends DirMixin {}
interface ElementMixin extends DirMixin {
}
export { ElementMixin, ElementMixinConstructor };

@@ -0,22 +1,22 @@

/**
* @license
* Copyright (c) 2021 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { idlePeriod } from '@polymer/polymer/lib/utils/async.js';
import { Debouncer } from '@polymer/polymer/lib/utils/debounce.js';
import { enqueueDebouncer } from '@polymer/polymer/lib/utils/flush.js';
import { Debouncer, enqueueDebouncer } from '@polymer/polymer/lib/utils/debounce.js';
import { usageStatistics } from '@vaadin/vaadin-usage-statistics/vaadin-usage-statistics.js';
import { DirMixin } from './vaadin-dir-mixin.js';
import { usageStatistics } from '@vaadin/vaadin-usage-statistics/vaadin-usage-statistics.js';
if (!window.Vaadin) {
window['Vaadin'] = {};
}
window.Vaadin = window.Vaadin || {};
/**
* Array of Vaadin custom element classes that have been finalized.
*/
window['Vaadin'].registrations = window.Vaadin.registrations || [];
window.Vaadin.registrations = window.Vaadin.registrations || [];
// Use the hack to prevent polymer-modulizer from converting to exports
window['Vaadin'].developmentModeCallback = window.Vaadin.developmentModeCallback || {};
window['Vaadin'].developmentModeCallback['vaadin-usage-statistics'] = function() {
if (usageStatistics) {
usageStatistics();
}
window.Vaadin.developmentModeCallback = window.Vaadin.developmentModeCallback || {};
window.Vaadin.developmentModeCallback['vaadin-usage-statistics'] = function () {
usageStatistics();
};

@@ -32,33 +32,32 @@

*/
export const ElementMixin = superClass => class VaadinElementMixin extends DirMixin(superClass) {
/** @protected */
static finalize() {
super.finalize();
export const ElementMixin = (superClass) =>
class VaadinElementMixin extends DirMixin(superClass) {
/** @protected */
static finalize() {
super.finalize();
const {is} = this;
const { is } = this;
// Registers a class prototype for telemetry purposes.
if (is && !registered.has(is)) {
window.Vaadin.registrations.push(this);
registered.add(is);
// Registers a class prototype for telemetry purposes.
if (is && !registered.has(is)) {
window.Vaadin.registrations.push(this);
registered.add(is);
if (window.Vaadin.developmentModeCallback) {
statsJob = Debouncer.debounce(statsJob,
idlePeriod, () => {
if (window.Vaadin.developmentModeCallback) {
statsJob = Debouncer.debounce(statsJob, idlePeriod, () => {
window.Vaadin.developmentModeCallback['vaadin-usage-statistics']();
}
);
enqueueDebouncer(statsJob);
});
enqueueDebouncer(statsJob);
}
}
}
}
constructor() {
super();
if (document.doctype === null) {
console.warn(
'Vaadin components require the "standards mode" declaration. Please add <!DOCTYPE html> to the HTML document.'
);
constructor() {
super();
if (document.doctype === null) {
console.warn(
'Vaadin components require the "standards mode" declaration. Please add <!DOCTYPE html> to the HTML document.'
);
}
}
}
};
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc