@prof-dev/improved-select
Advanced tools
Comparing version 1.1.7 to 1.1.8
import { EventEmitter } from "@prof-dev/event-emitter"; | ||
import { Placement, Strategy } from "@floating-ui/dom"; | ||
type ImprovedSelectInfo = { | ||
@@ -10,2 +11,6 @@ isActive: boolean; | ||
type SelectEventType = "open" | "close" | "toggle" | "change"; | ||
type SelectOptions = Partial<{ | ||
placement?: Placement; | ||
strategy?: Strategy; | ||
}>; | ||
declare class Select extends EventEmitter<SelectEventType, ImprovedSelect> { | ||
@@ -30,4 +35,5 @@ } | ||
private isHtmlValue; | ||
private options; | ||
private cleanup?; | ||
constructor(element: HTMLElement); | ||
constructor(element: HTMLElement, options?: SelectOptions); | ||
private initChangeStateBehavior; | ||
@@ -52,4 +58,4 @@ private initToggleBehavior; | ||
getSelectedOptions(): HTMLOptionElement[]; | ||
static create(element: HTMLElement): ImprovedSelect; | ||
static initAllAvailableOnPage(): void; | ||
static create(element: HTMLElement, options?: SelectOptions): ImprovedSelect; | ||
static initAllAvailableOnPage(options?: SelectOptions): void; | ||
static getInstance(element: HTMLElement): ImprovedSelect | undefined; | ||
@@ -56,0 +62,0 @@ static blurSimulationHandler(event: MouseEvent | TouchEvent): void; |
@@ -17,2 +17,13 @@ "use strict"; | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -96,3 +107,4 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
__extends(ImprovedSelect, _super); | ||
function ImprovedSelect(element) { | ||
function ImprovedSelect(element, options) { | ||
if (options === void 0) { options = {}; } | ||
var _this = this; | ||
@@ -113,2 +125,3 @@ var _a, _b; | ||
_this.isHtmlValue = false; | ||
_this.options = {}; | ||
_this.update = function () { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -121,2 +134,3 @@ var _a, x, y; | ||
return [4 /*yield*/, (0, dom_1.computePosition)(this.activeToggleElement, this.selectBody, { | ||
strategy: this.options.strategy, | ||
placement: "bottom", | ||
@@ -163,2 +177,3 @@ middleware: [(0, dom_1.offset)(8), (0, dom_1.flip)(), (0, dom_1.shift)({ padding: 12 })], | ||
}; | ||
_this.options = __assign(__assign({}, _this.options), options); | ||
_this.isActive = _this.element.classList.contains("is-active"); | ||
@@ -414,3 +429,4 @@ _this.isHtmlValue = _this.element.hasAttribute("data-select-html-value"); | ||
}; | ||
ImprovedSelect.create = function (element) { | ||
ImprovedSelect.create = function (element, options) { | ||
if (options === void 0) { options = {}; } | ||
var instance = improvedSelectElementsMap.get(element); | ||
@@ -420,9 +436,10 @@ if (instance !== undefined) { | ||
} | ||
return new ImprovedSelect(element); | ||
return new ImprovedSelect(element, options); | ||
}; | ||
ImprovedSelect.initAllAvailableOnPage = function () { | ||
ImprovedSelect.initAllAvailableOnPage = function (options) { | ||
if (options === void 0) { options = {}; } | ||
document | ||
.querySelectorAll("[data-improved-select]:not([data-improved-select=\"initialized\"])") | ||
.forEach(function (element) { | ||
ImprovedSelect.create(element); | ||
ImprovedSelect.create(element, options); | ||
}); | ||
@@ -429,0 +446,0 @@ }; |
{ | ||
"name": "@prof-dev/improved-select", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "Helper for live clicks events management", | ||
@@ -12,2 +12,3 @@ "main": "lib/ImprovedSelect.js", | ||
"build:only": "tsc && npm run sass", | ||
"prepublish": "npm run build", | ||
"publish:patch": "npm version patch && npm run build && npm publish", | ||
@@ -14,0 +15,0 @@ "clean": "rimraf lib/*" |
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
84736
1490