This commit is contained in:
sasha-astiadi
2024-05-03 06:39:20 +02:00
parent 6bf49421d6
commit 324d5960af
1737 changed files with 254531 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
import type { AccordionItem, AccordionOptions } from './types';
import { AccordionInterface } from './interface';
declare class Accordion implements AccordionInterface {
_items: AccordionItem[];
_options: AccordionOptions;
constructor(items?: AccordionItem[], options?: AccordionOptions);
private _init;
getItem(id: string): AccordionItem;
open(id: string): void;
toggle(id: string): void;
close(id: string): void;
}
export declare function initAccordions(): void;
export default Accordion;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/accordion/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAWjD,cAAM,SAAU,YAAW,kBAAkB;IACzC,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,QAAQ,EAAE,gBAAgB,CAAC;gBAGvB,KAAK,GAAE,aAAa,EAAO,EAC3B,OAAO,GAAE,gBAA0B;IAOvC,OAAO,CAAC,KAAK;IAeb,OAAO,CAAC,EAAE,EAAE,MAAM;IAIlB,IAAI,CAAC,EAAE,EAAE,MAAM;IA2Cf,MAAM,CAAC,EAAE,EAAE,MAAM;IAajB,KAAK,CAAC,EAAE,EAAE,MAAM;CAqBnB;AAED,wBAAgB,cAAc,SA2C7B;AAOD,eAAe,SAAS,CAAC"}

View File

@@ -0,0 +1,151 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initAccordions = void 0;
var Default = {
alwaysOpen: false,
activeClasses: 'bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-white',
inactiveClasses: 'text-gray-500 dark:text-gray-400',
onOpen: function () { },
onClose: function () { },
onToggle: function () { },
};
var Accordion = /** @class */ (function () {
function Accordion(items, options) {
if (items === void 0) { items = []; }
if (options === void 0) { options = Default; }
this._items = items;
this._options = __assign(__assign({}, Default), options);
this._init();
}
Accordion.prototype._init = function () {
var _this = this;
if (this._items.length) {
// show accordion item based on click
this._items.map(function (item) {
if (item.active) {
_this.open(item.id);
}
item.triggerEl.addEventListener('click', function () {
_this.toggle(item.id);
});
});
}
};
Accordion.prototype.getItem = function (id) {
return this._items.filter(function (item) { return item.id === id; })[0];
};
Accordion.prototype.open = function (id) {
var _a, _b;
var _this = this;
var item = this.getItem(id);
// don't hide other accordions if always open
if (!this._options.alwaysOpen) {
this._items.map(function (i) {
var _a, _b;
if (i !== item) {
(_a = i.triggerEl.classList).remove.apply(_a, _this._options.activeClasses.split(' '));
(_b = i.triggerEl.classList).add.apply(_b, _this._options.inactiveClasses.split(' '));
i.targetEl.classList.add('hidden');
i.triggerEl.setAttribute('aria-expanded', 'false');
i.active = false;
// rotate icon if set
if (i.iconEl) {
i.iconEl.classList.remove('rotate-180');
}
}
});
}
// show active item
(_a = item.triggerEl.classList).add.apply(_a, this._options.activeClasses.split(' '));
(_b = item.triggerEl.classList).remove.apply(_b, this._options.inactiveClasses.split(' '));
item.triggerEl.setAttribute('aria-expanded', 'true');
item.targetEl.classList.remove('hidden');
item.active = true;
// rotate icon if set
if (item.iconEl) {
item.iconEl.classList.add('rotate-180');
}
// callback function
this._options.onOpen(this, item);
};
Accordion.prototype.toggle = function (id) {
var item = this.getItem(id);
if (item.active) {
this.close(id);
}
else {
this.open(id);
}
// callback function
this._options.onToggle(this, item);
};
Accordion.prototype.close = function (id) {
var _a, _b;
var item = this.getItem(id);
(_a = item.triggerEl.classList).remove.apply(_a, this._options.activeClasses.split(' '));
(_b = item.triggerEl.classList).add.apply(_b, this._options.inactiveClasses.split(' '));
item.targetEl.classList.add('hidden');
item.triggerEl.setAttribute('aria-expanded', 'false');
item.active = false;
// rotate icon if set
if (item.iconEl) {
item.iconEl.classList.remove('rotate-180');
}
// callback function
this._options.onClose(this, item);
};
return Accordion;
}());
function initAccordions() {
document.querySelectorAll('[data-accordion]').forEach(function ($accordionEl) {
var alwaysOpen = $accordionEl.getAttribute('data-accordion');
var activeClasses = $accordionEl.getAttribute('data-active-classes');
var inactiveClasses = $accordionEl.getAttribute('data-inactive-classes');
var items = [];
$accordionEl
.querySelectorAll('[data-accordion-target]')
.forEach(function ($triggerEl) {
// Consider only items that directly belong to $accordionEl
// (to make nested accordions work).
if ($triggerEl.closest('[data-accordion]') === $accordionEl) {
var item = {
id: $triggerEl.getAttribute('data-accordion-target'),
triggerEl: $triggerEl,
targetEl: document.querySelector($triggerEl.getAttribute('data-accordion-target')),
iconEl: $triggerEl.querySelector('[data-accordion-icon]'),
active: $triggerEl.getAttribute('aria-expanded') === 'true'
? true
: false,
};
items.push(item);
}
});
new Accordion(items, {
alwaysOpen: alwaysOpen === 'open' ? true : false,
activeClasses: activeClasses
? activeClasses
: Default.activeClasses,
inactiveClasses: inactiveClasses
? inactiveClasses
: Default.inactiveClasses,
});
});
}
exports.initAccordions = initAccordions;
if (typeof window !== 'undefined') {
window.Accordion = Accordion;
window.initAccordions = initAccordions;
}
exports.default = Accordion;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/accordion/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,IAAM,OAAO,GAAqB;IAC9B,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,4DAA4D;IAC3E,eAAe,EAAE,kCAAkC;IACnD,MAAM,EAAE,cAAO,CAAC;IAChB,OAAO,EAAE,cAAO,CAAC;IACjB,QAAQ,EAAE,cAAO,CAAC;CACrB,CAAC;AAEF;IAII,mBACI,KAA2B,EAC3B,OAAmC;Q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,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACP,CAAC;AA3CD,wCA2CC;AAED,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAC/B,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,MAAM,CAAC,cAAc,GAAG,cAAc,CAAC;CAC1C;AAED,kBAAe,SAAS,CAAC"}

View File

@@ -0,0 +1,10 @@
import { AccordionItem, AccordionOptions } from './types';
export declare interface AccordionInterface {
_items: AccordionItem[];
_options: AccordionOptions;
getItem(id: string): AccordionItem | undefined;
open(id: string): void;
toggle(id: string): void;
close(id: string): void;
}
//# sourceMappingURL=interface.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/components/accordion/interface.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAG1D,MAAM,CAAC,OAAO,WAAW,kBAAkB;IACvC,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,QAAQ,EAAE,gBAAgB,CAAC;IAE3B,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;IAC/C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interface.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../src/components/accordion/interface.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,17 @@
import { AccordionInterface } from './interface';
export declare type AccordionItem = {
id: string;
triggerEl: HTMLElement;
targetEl: HTMLElement;
iconEl?: HTMLElement | null;
active?: boolean;
};
export declare type AccordionOptions = {
alwaysOpen?: boolean;
activeClasses?: string;
inactiveClasses?: string;
onOpen?: (accordion: AccordionInterface, item: AccordionItem) => void;
onClose?: (accordion: AccordionInterface, item: AccordionItem) => void;
onToggle?: (accordion: AccordionInterface, item: AccordionItem) => void;
};
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/accordion/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,WAAW,CAAC;IACvB,QAAQ,EAAE,WAAW,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,gBAAgB,GAAG;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACtE,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACvE,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;CAC3E,CAAC"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/accordion/types.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,54 @@
import type { CarouselOptions, CarouselItem, IndicatorItem, RotationItems } from './types';
import { CarouselInterface } from './interface';
declare class Carousel implements CarouselInterface {
_items: CarouselItem[];
_indicators: IndicatorItem[];
_activeItem: CarouselItem;
_intervalDuration: number;
_intervalInstance: number;
_options: CarouselOptions;
constructor(items?: CarouselItem[], options?: CarouselOptions);
/**
* initialize carousel and items based on active one
*/
_init(): void;
getItem(position: number): CarouselItem;
/**
* Slide to the element based on id
* @param {*} position
*/
slideTo(position: number): void;
/**
* Based on the currently active item it will go to the next position
*/
next(): void;
/**
* Based on the currently active item it will go to the previous position
*/
prev(): void;
/**
* This method applies the transform classes based on the left, middle, and right rotation carousel items
* @param {*} rotationItems
*/
_rotate(rotationItems: RotationItems): void;
/**
* Set an interval to cycle through the carousel items
*/
cycle(): void;
/**
* Clears the cycling interval
*/
pause(): void;
/**
* Get the currently active item
*/
_getActiveItem(): CarouselItem;
/**
* Set the currently active item and data attribute
* @param {*} position
*/
_setActiveItem(item: CarouselItem): void;
}
export declare function initCarousels(): void;
export default Carousel;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/carousel/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,eAAe,EACf,YAAY,EACZ,aAAa,EACb,aAAa,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAgBhD,cAAM,QAAS,YAAW,iBAAiB;IACvC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,WAAW,EAAE,aAAa,EAAE,CAAC;IAC7B,WAAW,EAAE,YAAY,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,eAAe,CAAC;gBAGtB,KAAK,GAAE,YAAY,EAAO,EAC1B,OAAO,GAAE,eAAyB;IAetC;;OAEG;IACH,KAAK;IAwBL,OAAO,CAAC,QAAQ,EAAE,MAAM;IAIxB;;;OAGG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM;IAuBxB;;OAEG;IACH,IAAI;IAiBJ;;OAEG;IACH,IAAI;IAiBJ;;;OAGG;IACH,OAAO,CAAC,aAAa,EAAE,aAAa;IAqCpC;;OAEG;IACH,KAAK;IAQL;;OAEG;IACH,KAAK;IAIL;;OAEG;IACH,cAAc;IAId;;;OAGG;IACH,cAAc,CAAC,IAAI,EAAE,YAAY;CAwBpC;AAED,wBAAgB,aAAa,SA0E5B;AAOD,eAAe,QAAQ,CAAC"}

View File

@@ -0,0 +1,246 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initCarousels = void 0;
var Default = {
defaultPosition: 0,
indicators: {
items: [],
activeClasses: 'bg-white dark:bg-gray-800',
inactiveClasses: 'bg-white/50 dark:bg-gray-800/50 hover:bg-white dark:hover:bg-gray-800',
},
interval: 3000,
onNext: function () { },
onPrev: function () { },
onChange: function () { },
};
var Carousel = /** @class */ (function () {
function Carousel(items, options) {
if (items === void 0) { items = []; }
if (options === void 0) { options = Default; }
this._items = items;
this._options = __assign(__assign(__assign({}, Default), options), { indicators: __assign(__assign({}, Default.indicators), options.indicators) });
this._activeItem = this.getItem(this._options.defaultPosition);
this._indicators = this._options.indicators.items;
this._intervalDuration = this._options.interval;
this._intervalInstance = null;
this._init();
}
/**
* initialize carousel and items based on active one
*/
Carousel.prototype._init = function () {
var _this = this;
this._items.map(function (item) {
item.el.classList.add('absolute', 'inset-0', 'transition-transform', 'transform');
});
// if no active item is set then first position is default
if (this._getActiveItem()) {
this.slideTo(this._getActiveItem().position);
}
else {
this.slideTo(0);
}
this._indicators.map(function (indicator, position) {
indicator.el.addEventListener('click', function () {
_this.slideTo(position);
});
});
};
Carousel.prototype.getItem = function (position) {
return this._items[position];
};
/**
* Slide to the element based on id
* @param {*} position
*/
Carousel.prototype.slideTo = function (position) {
var nextItem = this._items[position];
var rotationItems = {
left: nextItem.position === 0
? this._items[this._items.length - 1]
: this._items[nextItem.position - 1],
middle: nextItem,
right: nextItem.position === this._items.length - 1
? this._items[0]
: this._items[nextItem.position + 1],
};
this._rotate(rotationItems);
this._setActiveItem(nextItem);
if (this._intervalInstance) {
this.pause();
this.cycle();
}
this._options.onChange(this);
};
/**
* Based on the currently active item it will go to the next position
*/
Carousel.prototype.next = function () {
var activeItem = this._getActiveItem();
var nextItem = null;
// check if last item
if (activeItem.position === this._items.length - 1) {
nextItem = this._items[0];
}
else {
nextItem = this._items[activeItem.position + 1];
}
this.slideTo(nextItem.position);
// callback function
this._options.onNext(this);
};
/**
* Based on the currently active item it will go to the previous position
*/
Carousel.prototype.prev = function () {
var activeItem = this._getActiveItem();
var prevItem = null;
// check if first item
if (activeItem.position === 0) {
prevItem = this._items[this._items.length - 1];
}
else {
prevItem = this._items[activeItem.position - 1];
}
this.slideTo(prevItem.position);
// callback function
this._options.onPrev(this);
};
/**
* This method applies the transform classes based on the left, middle, and right rotation carousel items
* @param {*} rotationItems
*/
Carousel.prototype._rotate = function (rotationItems) {
// reset
this._items.map(function (item) {
item.el.classList.add('hidden');
});
// left item (previously active)
rotationItems.left.el.classList.remove('-translate-x-full', 'translate-x-full', 'translate-x-0', 'hidden', 'z-20');
rotationItems.left.el.classList.add('-translate-x-full', 'z-10');
// currently active item
rotationItems.middle.el.classList.remove('-translate-x-full', 'translate-x-full', 'translate-x-0', 'hidden', 'z-10');
rotationItems.middle.el.classList.add('translate-x-0', 'z-20');
// right item (upcoming active)
rotationItems.right.el.classList.remove('-translate-x-full', 'translate-x-full', 'translate-x-0', 'hidden', 'z-20');
rotationItems.right.el.classList.add('translate-x-full', 'z-10');
};
/**
* Set an interval to cycle through the carousel items
*/
Carousel.prototype.cycle = function () {
var _this = this;
if (typeof window !== 'undefined') {
this._intervalInstance = window.setInterval(function () {
_this.next();
}, this._intervalDuration);
}
};
/**
* Clears the cycling interval
*/
Carousel.prototype.pause = function () {
clearInterval(this._intervalInstance);
};
/**
* Get the currently active item
*/
Carousel.prototype._getActiveItem = function () {
return this._activeItem;
};
/**
* Set the currently active item and data attribute
* @param {*} position
*/
Carousel.prototype._setActiveItem = function (item) {
var _a, _b;
var _this = this;
this._activeItem = item;
var position = item.position;
// update the indicators if available
if (this._indicators.length) {
this._indicators.map(function (indicator) {
var _a, _b;
indicator.el.setAttribute('aria-current', 'false');
(_a = indicator.el.classList).remove.apply(_a, _this._options.indicators.activeClasses.split(' '));
(_b = indicator.el.classList).add.apply(_b, _this._options.indicators.inactiveClasses.split(' '));
});
(_a = this._indicators[position].el.classList).add.apply(_a, this._options.indicators.activeClasses.split(' '));
(_b = this._indicators[position].el.classList).remove.apply(_b, this._options.indicators.inactiveClasses.split(' '));
this._indicators[position].el.setAttribute('aria-current', 'true');
}
};
return Carousel;
}());
function initCarousels() {
document.querySelectorAll('[data-carousel]').forEach(function ($carouselEl) {
var interval = $carouselEl.getAttribute('data-carousel-interval');
var slide = $carouselEl.getAttribute('data-carousel') === 'slide'
? true
: false;
var items = [];
var defaultPosition = 0;
if ($carouselEl.querySelectorAll('[data-carousel-item]').length) {
Array.from($carouselEl.querySelectorAll('[data-carousel-item]')).map(function ($carouselItemEl, position) {
items.push({
position: position,
el: $carouselItemEl,
});
if ($carouselItemEl.getAttribute('data-carousel-item') ===
'active') {
defaultPosition = position;
}
});
}
var indicators = [];
if ($carouselEl.querySelectorAll('[data-carousel-slide-to]').length) {
Array.from($carouselEl.querySelectorAll('[data-carousel-slide-to]')).map(function ($indicatorEl) {
indicators.push({
position: parseInt($indicatorEl.getAttribute('data-carousel-slide-to')),
el: $indicatorEl,
});
});
}
var carousel = new Carousel(items, {
defaultPosition: defaultPosition,
indicators: {
items: indicators,
},
interval: interval ? interval : Default.interval,
});
if (slide) {
carousel.cycle();
}
// check for controls
var carouselNextEl = $carouselEl.querySelector('[data-carousel-next]');
var carouselPrevEl = $carouselEl.querySelector('[data-carousel-prev]');
if (carouselNextEl) {
carouselNextEl.addEventListener('click', function () {
carousel.next();
});
}
if (carouselPrevEl) {
carouselPrevEl.addEventListener('click', function () {
carousel.prev();
});
}
});
}
exports.initCarousels = initCarousels;
if (typeof window !== 'undefined') {
window.Carousel = Carousel;
window.initCarousels = initCarousels;
}
exports.default = Carousel;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
import { CarouselOptions, CarouselItem, IndicatorItem, RotationItems } from './types';
export declare interface CarouselInterface {
_items: CarouselItem[];
_indicators: IndicatorItem[];
_activeItem: CarouselItem;
_intervalDuration: number;
_intervalInstance: number;
_options: CarouselOptions;
_init(): void;
getItem(position: number): CarouselItem;
_getActiveItem(): CarouselItem;
_setActiveItem(item: CarouselItem): void;
slideTo(position: number): void;
next(): void;
prev(): void;
_rotate(rotationItems: RotationItems): void;
cycle(): void;
pause(): void;
}
//# sourceMappingURL=interface.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/components/carousel/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EACf,YAAY,EACZ,aAAa,EACb,aAAa,EAChB,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,OAAO,WAAW,iBAAiB;IACtC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,WAAW,EAAE,aAAa,EAAE,CAAC;IAC7B,WAAW,EAAE,YAAY,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,eAAe,CAAC;IAE1B,KAAK,IAAI,IAAI,CAAC;IAEd,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAAC;IAExC,cAAc,IAAI,YAAY,CAAC;IAC/B,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAEzC,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC,IAAI,IAAI,IAAI,CAAC;IACb,IAAI,IAAI,IAAI,CAAC;IAEb,OAAO,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5C,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,IAAI,IAAI,CAAC;CACjB"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interface.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../src/components/carousel/interface.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,27 @@
import { CarouselInterface } from './interface';
export declare type CarouselItem = {
position: number;
el: HTMLElement;
};
export declare type IndicatorItem = {
position: number;
el: HTMLElement;
};
export declare type RotationItems = {
left: CarouselItem;
middle: CarouselItem;
right: CarouselItem;
};
export declare type CarouselOptions = {
defaultPosition?: number;
indicators?: {
items?: IndicatorItem[];
activeClasses?: string;
inactiveClasses?: string;
};
interval?: number;
onNext?: (carousel: CarouselInterface) => void;
onPrev?: (carousel: CarouselInterface) => void;
onChange?: (carousel: CarouselInterface) => void;
};
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/carousel/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,CAAC,OAAO,MAAM,YAAY,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,WAAW,CAAC;CACnB,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,WAAW,CAAC;CACnB,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG;IAChC,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,eAAe,GAAG;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE;QACT,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;QACxB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC/C,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC/C,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;CACpD,CAAC"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/carousel/types.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,16 @@
import type { CollapseOptions } from './types';
import { CollapseInterface } from './interface';
declare class Collapse implements CollapseInterface {
_targetEl: HTMLElement | null;
_triggerEl: HTMLElement | null;
_options: CollapseOptions;
_visible: boolean;
constructor(targetEl?: HTMLElement | null, triggerEl?: HTMLElement | null, options?: CollapseOptions);
_init(): void;
collapse(): void;
expand(): void;
toggle(): void;
}
export declare function initCollapses(): void;
export default Collapse;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/collapse/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQhD,cAAM,QAAS,YAAW,iBAAiB;IACvC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;gBAGd,QAAQ,GAAE,WAAW,GAAG,IAAW,EACnC,SAAS,GAAE,WAAW,GAAG,IAAW,EACpC,OAAO,GAAE,eAAyB;IAStC,KAAK;IAgBL,QAAQ;IAWR,MAAM;IAWN,MAAM;CAST;AAED,wBAAgB,aAAa,SAmB5B;AAOD,eAAe,QAAQ,CAAC"}

View File

@@ -0,0 +1,98 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initCollapses = void 0;
var Default = {
onCollapse: function () { },
onExpand: function () { },
onToggle: function () { },
};
var Collapse = /** @class */ (function () {
function Collapse(targetEl, triggerEl, options) {
if (targetEl === void 0) { targetEl = null; }
if (triggerEl === void 0) { triggerEl = null; }
if (options === void 0) { options = Default; }
this._targetEl = targetEl;
this._triggerEl = triggerEl;
this._options = __assign(__assign({}, Default), options);
this._visible = false;
this._init();
}
Collapse.prototype._init = function () {
var _this = this;
if (this._triggerEl) {
if (this._triggerEl.hasAttribute('aria-expanded')) {
this._visible =
this._triggerEl.getAttribute('aria-expanded') === 'true';
}
else {
// fix until v2 not to break previous single collapses which became dismiss
this._visible = !this._targetEl.classList.contains('hidden');
}
this._triggerEl.addEventListener('click', function () {
_this.toggle();
});
}
};
Collapse.prototype.collapse = function () {
this._targetEl.classList.add('hidden');
if (this._triggerEl) {
this._triggerEl.setAttribute('aria-expanded', 'false');
}
this._visible = false;
// callback function
this._options.onCollapse(this);
};
Collapse.prototype.expand = function () {
this._targetEl.classList.remove('hidden');
if (this._triggerEl) {
this._triggerEl.setAttribute('aria-expanded', 'true');
}
this._visible = true;
// callback function
this._options.onExpand(this);
};
Collapse.prototype.toggle = function () {
if (this._visible) {
this.collapse();
}
else {
this.expand();
}
// callback function
this._options.onToggle(this);
};
return Collapse;
}());
function initCollapses() {
document
.querySelectorAll('[data-collapse-toggle]')
.forEach(function ($triggerEl) {
var targetId = $triggerEl.getAttribute('data-collapse-toggle');
var $targetEl = document.getElementById(targetId);
// check if the target element exists
if ($targetEl) {
new Collapse($targetEl, $triggerEl);
}
else {
console.error("The target element with id \"".concat(targetId, "\" does not exist. Please check the data-collapse-toggle attribute."));
}
});
}
exports.initCollapses = initCollapses;
if (typeof window !== 'undefined') {
window.Collapse = Collapse;
window.initCollapses = initCollapses;
}
exports.default = Collapse;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/collapse/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,IAAM,OAAO,GAAoB;IAC7B,UAAU,EAAE,cAAO,CAAC;IACpB,QAAQ,EAAE,cAAO,CAAC;IAClB,QAAQ,EAAE,cAAO,CAAC;CACrB,CAAC;AAEF;IAMI,kBACI,QAAmC,EACnC,SAAoC,EACpC,OAAkC;QAFlC,yBAAA,EAAA,eAAmC;QACnC,0BAAA,EAAA,gBAAoC;QACpC,wBAAA,EAAA,iBAAkC;QAElC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,yBAAQ,OAAO,GAAK,OAAO,CAAE,CAAC;QAC3C,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAED,wBAAK,GAAL;QAAA,iBAcC;QAbG,IAAI,IAAI,CAAC,UAAU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AI,CAAC,MAAM,EAAE,CAAC;SACjB;QACD,oBAAoB;QACpB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IACL,eAAC;AAAD,CAAC,AAjED,IAiEC;AAED,SAAgB,aAAa;IACzB,QAAQ;SACH,gBAAgB,CAAC,wBAAwB,CAAC;SAC1C,OAAO,CAAC,UAAC,UAAU;QAChB,IAAM,QAAQ,GAAG,UAAU,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC;QACjE,IAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAEpD,qCAAqC;QACrC,IAAI,SAAS,EAAE;YACX,IAAI,QAAQ,CACR,SAAwB,EACxB,UAAyB,CAC5B,CAAC;SACL;aAAM;YACH,OAAO,CAAC,KAAK,CACT,uCAA+B,QAAQ,wEAAoE,CAC9G,CAAC;SACL;IACL,CAAC,CAAC,CAAC;AACX,CAAC;AAnBD,sCAmBC;AAED,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAC/B,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,MAAM,CAAC,aAAa,GAAG,aAAa,CAAC;CACxC;AAED,kBAAe,QAAQ,CAAC"}

View File

@@ -0,0 +1,12 @@
import { CollapseOptions } from './types';
export declare interface CollapseInterface {
_targetEl: HTMLElement | null;
_triggerEl: HTMLElement | null;
_options: CollapseOptions;
_visible: boolean;
_init(): void;
collapse(): void;
expand(): void;
toggle(): void;
}
//# sourceMappingURL=interface.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/components/collapse/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,CAAC,OAAO,WAAW,iBAAiB;IACtC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAElB,KAAK,IAAI,IAAI,CAAC;IACd,QAAQ,IAAI,IAAI,CAAC;IACjB,MAAM,IAAI,IAAI,CAAC;IACf,MAAM,IAAI,IAAI,CAAC;CAClB"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interface.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../src/components/collapse/interface.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,7 @@
import { CollapseInterface } from './interface';
export declare type CollapseOptions = {
onCollapse?: (collapse: CollapseInterface) => void;
onExpand?: (collapse: CollapseInterface) => void;
onToggle?: (collapse: CollapseInterface) => void;
};
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/collapse/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,CAAC,OAAO,MAAM,eAAe,GAAG;IAClC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACnD,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACjD,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;CACpD,CAAC"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/collapse/types.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,23 @@
import type { DialOptions, DialTriggerType } from './types';
import { DialInterface } from './interface';
declare class Dial implements DialInterface {
_parentEl: HTMLElement;
_triggerEl: HTMLElement;
_targetEl: HTMLElement;
_options: DialOptions;
_visible: boolean;
constructor(parentEl?: HTMLElement | null, triggerEl?: HTMLElement | null, targetEl?: HTMLElement | null, options?: DialOptions);
_init(): void;
hide(): void;
show(): void;
toggle(): void;
isHidden(): boolean;
isVisible(): boolean;
_getTriggerEventTypes(triggerType: DialTriggerType): {
showEvents: string[];
hideEvents: string[];
};
}
export declare function initDials(): void;
export default Dial;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/dial/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAS5C,cAAM,IAAK,YAAW,aAAa;IAC/B,SAAS,EAAE,WAAW,CAAC;IACvB,UAAU,EAAE,WAAW,CAAC;IACxB,SAAS,EAAE,WAAW,CAAC;IACvB,QAAQ,EAAE,WAAW,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;gBAGd,QAAQ,GAAE,WAAW,GAAG,IAAW,EACnC,SAAS,GAAE,WAAW,GAAG,IAAW,EACpC,QAAQ,GAAE,WAAW,GAAG,IAAW,EACnC,OAAO,GAAE,WAAqB;IAUlC,KAAK;IAuBL,IAAI;IAWJ,IAAI;IAWJ,MAAM;IAQN,QAAQ;IAIR,SAAS;IAIT,qBAAqB,CAAC,WAAW,EAAE,eAAe;;;;CAwBrD;AAED,wBAAgB,SAAS,SAgCxB;AAOD,eAAe,IAAI,CAAC"}

142
node_modules/flowbite/lib/cjs/components/dial/index.js generated vendored Normal file
View File

@@ -0,0 +1,142 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initDials = void 0;
var Default = {
triggerType: 'hover',
onShow: function () { },
onHide: function () { },
onToggle: function () { },
};
var Dial = /** @class */ (function () {
function Dial(parentEl, triggerEl, targetEl, options) {
if (parentEl === void 0) { parentEl = null; }
if (triggerEl === void 0) { triggerEl = null; }
if (targetEl === void 0) { targetEl = null; }
if (options === void 0) { options = Default; }
this._parentEl = parentEl;
this._triggerEl = triggerEl;
this._targetEl = targetEl;
this._options = __assign(__assign({}, Default), options);
this._visible = false;
this._init();
}
Dial.prototype._init = function () {
var _this = this;
if (this._triggerEl) {
var triggerEventTypes = this._getTriggerEventTypes(this._options.triggerType);
triggerEventTypes.showEvents.forEach(function (ev) {
_this._triggerEl.addEventListener(ev, function () {
_this.show();
});
_this._targetEl.addEventListener(ev, function () {
_this.show();
});
});
triggerEventTypes.hideEvents.forEach(function (ev) {
_this._parentEl.addEventListener(ev, function () {
if (!_this._parentEl.matches(':hover')) {
_this.hide();
}
});
});
}
};
Dial.prototype.hide = function () {
this._targetEl.classList.add('hidden');
if (this._triggerEl) {
this._triggerEl.setAttribute('aria-expanded', 'false');
}
this._visible = false;
// callback function
this._options.onHide(this);
};
Dial.prototype.show = function () {
this._targetEl.classList.remove('hidden');
if (this._triggerEl) {
this._triggerEl.setAttribute('aria-expanded', 'true');
}
this._visible = true;
// callback function
this._options.onShow(this);
};
Dial.prototype.toggle = function () {
if (this._visible) {
this.hide();
}
else {
this.show();
}
};
Dial.prototype.isHidden = function () {
return !this._visible;
};
Dial.prototype.isVisible = function () {
return this._visible;
};
Dial.prototype._getTriggerEventTypes = function (triggerType) {
switch (triggerType) {
case 'hover':
return {
showEvents: ['mouseenter', 'focus'],
hideEvents: ['mouseleave', 'blur'],
};
case 'click':
return {
showEvents: ['click', 'focus'],
hideEvents: ['focusout', 'blur'],
};
case 'none':
return {
showEvents: [],
hideEvents: [],
};
default:
return {
showEvents: ['mouseenter', 'focus'],
hideEvents: ['mouseleave', 'blur'],
};
}
};
return Dial;
}());
function initDials() {
document.querySelectorAll('[data-dial-init]').forEach(function ($parentEl) {
var $triggerEl = $parentEl.querySelector('[data-dial-toggle]');
if ($triggerEl) {
var dialId = $triggerEl.getAttribute('data-dial-toggle');
var $dialEl = document.getElementById(dialId);
if ($dialEl) {
var triggerType = $triggerEl.getAttribute('data-dial-trigger');
new Dial($parentEl, $triggerEl, $dialEl, {
triggerType: triggerType
? triggerType
: Default.triggerType,
});
}
else {
console.error("Dial with id ".concat(dialId, " does not exist. Are you sure that the data-dial-toggle attribute points to the correct modal id?"));
}
}
else {
console.error("Dial with id ".concat($parentEl.id, " does not have a trigger element. Are you sure that the data-dial-toggle attribute exists?"));
}
});
}
exports.initDials = initDials;
if (typeof window !== 'undefined') {
window.Dial = Dial;
window.initDials = initDials;
}
exports.default = Dial;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/dial/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,IAAM,OAAO,GAAgB;IACzB,WAAW,EAAE,OAAO;IACpB,MAAM,EAAE,cAAO,CAAC;IAChB,MAAM,EAAE,cAAO,CAAC;IAChB,QAAQ,EAAE,cAAO,CAAC;CACrB,CAAC;AAEF;IAOI,cACI,QAAmC,EACnC,SAAoC,EACpC,QAAmC,EACnC,OAA8B;QAH9B,yBAAA,EAAA,eAAmC;QACnC,0BAAA,EAAA,gBAAoC;QACpC,yBAAA,EAAA,eAAmC;QACnC,wBAAA,EAAA,iBAA8B;QAE9B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,QAAQ,yBAAQ,OAAO,GAAK,OAAO,CAAE,CAAC;QAC3C,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,KAAK,E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AC,UAAC,SAAS;QAC5D,IAAM,UAAU,GAAG,SAAS,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;QAEjE,IAAI,UAAU,EAAE;YACZ,IAAM,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;YAC3D,IAAM,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YAEhD,IAAI,OAAO,EAAE;gBACT,IAAM,WAAW,GACb,UAAU,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;gBACjD,IAAI,IAAI,CACJ,SAAwB,EACxB,UAAyB,EACzB,OAAsB,EACtB;oBACI,WAAW,EAAE,WAAW;wBACpB,CAAC,CAAC,WAAW;wBACb,CAAC,CAAC,OAAO,CAAC,WAAW;iBACb,CACnB,CAAC;aACL;iBAAM;gBACH,OAAO,CAAC,KAAK,CACT,uBAAgB,MAAM,sGAAmG,CAC5H,CAAC;aACL;SACJ;aAAM;YACH,OAAO,CAAC,KAAK,CACT,uBAAgB,SAAS,CAAC,EAAE,+FAA4F,CAC3H,CAAC;SACL;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAhCD,8BAgCC;AAED,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAC/B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;CAChC;AAED,kBAAe,IAAI,CAAC"}

View File

@@ -0,0 +1,16 @@
import { DialOptions, DialTriggerEventTypes, DialTriggerType } from './types';
export declare interface DialInterface {
_parentEl: HTMLElement;
_triggerEl: HTMLElement;
_targetEl: HTMLElement;
_options: DialOptions;
_visible: boolean;
_init(): void;
isVisible(): boolean;
isHidden(): boolean;
hide(): void;
show(): void;
toggle(): void;
_getTriggerEventTypes(triggerType: DialTriggerType): DialTriggerEventTypes;
}
//# sourceMappingURL=interface.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/components/dial/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE9E,MAAM,CAAC,OAAO,WAAW,aAAa;IAClC,SAAS,EAAE,WAAW,CAAC;IACvB,UAAU,EAAE,WAAW,CAAC;IACxB,SAAS,EAAE,WAAW,CAAC;IACvB,QAAQ,EAAE,WAAW,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAElB,KAAK,IAAI,IAAI,CAAC;IACd,SAAS,IAAI,OAAO,CAAC;IACrB,QAAQ,IAAI,OAAO,CAAC;IACpB,IAAI,IAAI,IAAI,CAAC;IACb,IAAI,IAAI,IAAI,CAAC;IACb,MAAM,IAAI,IAAI,CAAC;IACf,qBAAqB,CAAC,WAAW,EAAE,eAAe,GAAG,qBAAqB,CAAC;CAC9E"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interface.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../src/components/dial/interface.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,13 @@
import { DialInterface } from './interface';
export declare type DialTriggerType = 'click' | 'hover' | 'none';
export declare type DialTriggerEventTypes = {
showEvents: string[];
hideEvents: string[];
};
export declare type DialOptions = {
triggerType?: DialTriggerType;
onShow?: (dial: DialInterface) => void;
onHide?: (dial: DialInterface) => void;
onToggle?: (dial: DialInterface) => void;
};
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/dial/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,OAAO,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjE,MAAM,CAAC,OAAO,MAAM,qBAAqB,GAAG;IACxC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,WAAW,GAAG;IAC9B,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACvC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACvC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;CAC5C,CAAC"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/dial/types.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,13 @@
import type { DismissOptions } from './types';
import { DismissInterface } from './interface';
declare class Dismiss implements DismissInterface {
_targetEl: HTMLElement | null;
_triggerEl: HTMLElement | null;
_options: DismissOptions;
constructor(targetEl?: HTMLElement | null, triggerEl?: HTMLElement | null, options?: DismissOptions);
_init(): void;
hide(): void;
}
export declare function initDismisses(): void;
export default Dismiss;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/dismiss/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAS/C,cAAM,OAAQ,YAAW,gBAAgB;IACrC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,cAAc,CAAC;gBAGrB,QAAQ,GAAE,WAAW,GAAG,IAAW,EACnC,SAAS,GAAE,WAAW,GAAG,IAAW,EACpC,OAAO,GAAE,cAAwB;IAQrC,KAAK;IAQL,IAAI;CAcP;AAED,wBAAgB,aAAa,SAa5B;AAOD,eAAe,OAAO,CAAC"}

View File

@@ -0,0 +1,68 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initDismisses = void 0;
var Default = {
transition: 'transition-opacity',
duration: 300,
timing: 'ease-out',
onHide: function () { },
};
var Dismiss = /** @class */ (function () {
function Dismiss(targetEl, triggerEl, options) {
if (targetEl === void 0) { targetEl = null; }
if (triggerEl === void 0) { triggerEl = null; }
if (options === void 0) { options = Default; }
this._targetEl = targetEl;
this._triggerEl = triggerEl;
this._options = __assign(__assign({}, Default), options);
this._init();
}
Dismiss.prototype._init = function () {
var _this = this;
if (this._triggerEl) {
this._triggerEl.addEventListener('click', function () {
_this.hide();
});
}
};
Dismiss.prototype.hide = function () {
var _this = this;
this._targetEl.classList.add(this._options.transition, "duration-".concat(this._options.duration), this._options.timing, 'opacity-0');
setTimeout(function () {
_this._targetEl.classList.add('hidden');
}, this._options.duration);
// callback function
this._options.onHide(this, this._targetEl);
};
return Dismiss;
}());
function initDismisses() {
document.querySelectorAll('[data-dismiss-target]').forEach(function ($triggerEl) {
var targetId = $triggerEl.getAttribute('data-dismiss-target');
var $dismissEl = document.querySelector(targetId);
if ($dismissEl) {
new Dismiss($dismissEl, $triggerEl);
}
else {
console.error("The dismiss element with id \"".concat(targetId, "\" does not exist. Please check the data-dismiss-target attribute."));
}
});
}
exports.initDismisses = initDismisses;
if (typeof window !== 'undefined') {
window.Dismiss = Dismiss;
window.initDismisses = initDismisses;
}
exports.default = Dismiss;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","source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C,CAAC;IACL,cAAC;AAAD,CAAC,AAtCD,IAsCC;AAED,SAAgB,aAAa;IACzB,QAAQ,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC,UAAC,UAAU;QAClE,IAAM,QAAQ,GAAG,UAAU,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;QAChE,IAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAEpD,IAAI,UAAU,EAAE;YACZ,IAAI,OAAO,CAAC,UAAyB,EAAE,UAAyB,CAAC,CAAC;SACrE;aAAM;YACH,OAAO,CAAC,KAAK,CACT,wCAAgC,QAAQ,uEAAmE,CAC9G,CAAC;SACL;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAbD,sCAaC;AAED,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAC/B,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,MAAM,CAAC,aAAa,GAAG,aAAa,CAAC;CACxC;AAED,kBAAe,OAAO,CAAC"}

View File

@@ -0,0 +1,9 @@
import { DismissOptions } from './types';
export declare interface DismissInterface {
_targetEl: HTMLElement | null;
_triggerEl: HTMLElement | null;
_options: DismissOptions;
_init(): void;
hide(): void;
}
//# sourceMappingURL=interface.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/components/dismiss/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,CAAC,OAAO,WAAW,gBAAgB;IACrC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,cAAc,CAAC;IAEzB,KAAK,IAAI,IAAI,CAAC;IACd,IAAI,IAAI,IAAI,CAAC;CAChB"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interface.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../src/components/dismiss/interface.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,8 @@
import { DismissInterface } from './interface';
export declare type DismissOptions = {
transition?: string;
duration?: number;
timing?: string;
onHide?: (dismiss: DismissInterface, targetEl: HTMLElement) => void;
};
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/dismiss/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,CAAC,OAAO,MAAM,cAAc,GAAG;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,WAAW,KAAK,IAAI,CAAC;CACvE,CAAC"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/dismiss/types.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,21 @@
import type { DrawerOptions, PlacementClasses } from './types';
import { DrawerInterface } from './interface';
declare class Drawer implements DrawerInterface {
_targetEl: HTMLElement;
_triggerEl: HTMLElement;
_options: DrawerOptions;
_visible: boolean;
constructor(targetEl?: HTMLElement | null, options?: DrawerOptions);
_init(): void;
hide(): void;
show(): void;
toggle(): void;
_createBackdrop(): void;
_destroyBackdropEl(): void;
_getPlacementClasses(placement: string): PlacementClasses;
isHidden(): boolean;
isVisible(): boolean;
}
export declare function initDrawers(): void;
export default Drawer;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/drawer/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAe9C,cAAM,MAAO,YAAW,eAAe;IACnC,SAAS,EAAE,WAAW,CAAC;IACvB,UAAU,EAAE,WAAW,CAAC;IACxB,QAAQ,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;gBAGd,QAAQ,GAAE,WAAW,GAAG,IAAW,EACnC,OAAO,GAAE,aAAuB;IAQpC,KAAK;IAwBL,IAAI;IA+CJ,IAAI;IA8CJ,MAAM;IAQN,eAAe;IAcf,kBAAkB;IAMlB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB;IAyCzD,QAAQ;IAIR,SAAS;CAGZ;AAQD,wBAAgB,WAAW,SA+H1B;AAOD,eAAe,MAAM,CAAC"}

View File

@@ -0,0 +1,314 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initDrawers = void 0;
var Default = {
placement: 'left',
bodyScrolling: false,
backdrop: true,
edge: false,
edgeOffset: 'bottom-[60px]',
backdropClasses: 'bg-gray-900 bg-opacity-50 dark:bg-opacity-80 fixed inset-0 z-30',
onShow: function () { },
onHide: function () { },
onToggle: function () { },
};
var Drawer = /** @class */ (function () {
function Drawer(targetEl, options) {
if (targetEl === void 0) { targetEl = null; }
if (options === void 0) { options = Default; }
this._targetEl = targetEl;
this._options = __assign(__assign({}, Default), options);
this._visible = false;
this._init();
}
Drawer.prototype._init = function () {
var _this = this;
// set initial accessibility attributes
if (this._targetEl) {
this._targetEl.setAttribute('aria-hidden', 'true');
this._targetEl.classList.add('transition-transform');
}
// set base placement classes
this._getPlacementClasses(this._options.placement).base.map(function (c) {
_this._targetEl.classList.add(c);
});
// add keyboard event listener to document
document.addEventListener('keydown', function (event) {
if (event.key === 'Escape') {
// if 'Escape' key is pressed
if (_this.isVisible()) {
// if the Drawer is visible
_this.hide(); // hide the Drawer
}
}
});
};
Drawer.prototype.hide = function () {
var _this = this;
// based on the edge option show placement classes
if (this._options.edge) {
this._getPlacementClasses(this._options.placement + '-edge').active.map(function (c) {
_this._targetEl.classList.remove(c);
});
this._getPlacementClasses(this._options.placement + '-edge').inactive.map(function (c) {
_this._targetEl.classList.add(c);
});
}
else {
this._getPlacementClasses(this._options.placement).active.map(function (c) {
_this._targetEl.classList.remove(c);
});
this._getPlacementClasses(this._options.placement).inactive.map(function (c) {
_this._targetEl.classList.add(c);
});
}
// set accessibility attributes
this._targetEl.setAttribute('aria-hidden', 'true');
this._targetEl.removeAttribute('aria-modal');
this._targetEl.removeAttribute('role');
// enable body scroll
if (!this._options.bodyScrolling) {
document.body.classList.remove('overflow-hidden');
}
// destroy backdrop
if (this._options.backdrop) {
this._destroyBackdropEl();
}
this._visible = false;
// callback function
this._options.onHide(this);
};
Drawer.prototype.show = function () {
var _this = this;
if (this._options.edge) {
this._getPlacementClasses(this._options.placement + '-edge').active.map(function (c) {
_this._targetEl.classList.add(c);
});
this._getPlacementClasses(this._options.placement + '-edge').inactive.map(function (c) {
_this._targetEl.classList.remove(c);
});
}
else {
this._getPlacementClasses(this._options.placement).active.map(function (c) {
_this._targetEl.classList.add(c);
});
this._getPlacementClasses(this._options.placement).inactive.map(function (c) {
_this._targetEl.classList.remove(c);
});
}
// set accessibility attributes
this._targetEl.setAttribute('aria-modal', 'true');
this._targetEl.setAttribute('role', 'dialog');
this._targetEl.removeAttribute('aria-hidden');
// disable body scroll
if (!this._options.bodyScrolling) {
document.body.classList.add('overflow-hidden');
}
// show backdrop
if (this._options.backdrop) {
this._createBackdrop();
}
this._visible = true;
// callback function
this._options.onShow(this);
};
Drawer.prototype.toggle = function () {
if (this.isVisible()) {
this.hide();
}
else {
this.show();
}
};
Drawer.prototype._createBackdrop = function () {
var _a;
var _this = this;
if (!this._visible) {
var backdropEl = document.createElement('div');
backdropEl.setAttribute('drawer-backdrop', '');
(_a = backdropEl.classList).add.apply(_a, this._options.backdropClasses.split(' '));
document.querySelector('body').append(backdropEl);
backdropEl.addEventListener('click', function () {
_this.hide();
});
}
};
Drawer.prototype._destroyBackdropEl = function () {
if (this._visible) {
document.querySelector('[drawer-backdrop]').remove();
}
};
Drawer.prototype._getPlacementClasses = function (placement) {
switch (placement) {
case 'top':
return {
base: ['top-0', 'left-0', 'right-0'],
active: ['transform-none'],
inactive: ['-translate-y-full'],
};
case 'right':
return {
base: ['right-0', 'top-0'],
active: ['transform-none'],
inactive: ['translate-x-full'],
};
case 'bottom':
return {
base: ['bottom-0', 'left-0', 'right-0'],
active: ['transform-none'],
inactive: ['translate-y-full'],
};
case 'left':
return {
base: ['left-0', 'top-0'],
active: ['transform-none'],
inactive: ['-translate-x-full'],
};
case 'bottom-edge':
return {
base: ['left-0', 'top-0'],
active: ['transform-none'],
inactive: ['translate-y-full', this._options.edgeOffset],
};
default:
return {
base: ['left-0', 'top-0'],
active: ['transform-none'],
inactive: ['-translate-x-full'],
};
}
};
Drawer.prototype.isHidden = function () {
return !this._visible;
};
Drawer.prototype.isVisible = function () {
return this._visible;
};
return Drawer;
}());
var getDrawerInstance = function (id, instances) {
if (instances.some(function (drawerInstance) { return drawerInstance.id === id; })) {
return instances.find(function (drawerInstance) { return drawerInstance.id === id; });
}
};
function initDrawers() {
var drawerInstances = [];
document.querySelectorAll('[data-drawer-target]').forEach(function ($triggerEl) {
// mandatory
var drawerId = $triggerEl.getAttribute('data-drawer-target');
var $drawerEl = document.getElementById(drawerId);
if ($drawerEl) {
// optional
var placement = $triggerEl.getAttribute('data-drawer-placement');
var bodyScrolling = $triggerEl.getAttribute('data-drawer-body-scrolling');
var backdrop = $triggerEl.getAttribute('data-drawer-backdrop');
var edge = $triggerEl.getAttribute('data-drawer-edge');
var edgeOffset = $triggerEl.getAttribute('data-drawer-edge-offset');
if (!getDrawerInstance(drawerId, drawerInstances)) {
drawerInstances.push({
id: drawerId,
object: new Drawer($drawerEl, {
placement: placement ? placement : Default.placement,
bodyScrolling: bodyScrolling
? bodyScrolling === 'true'
? true
: false
: Default.bodyScrolling,
backdrop: backdrop
? backdrop === 'true'
? true
: false
: Default.backdrop,
edge: edge
? edge === 'true'
? true
: false
: Default.edge,
edgeOffset: edgeOffset
? edgeOffset
: Default.edgeOffset,
}),
});
}
}
else {
console.error("Drawer with id ".concat(drawerId, " not found. Are you sure that the data-drawer-target attribute points to the correct drawer id?"));
}
});
document.querySelectorAll('[data-drawer-toggle]').forEach(function ($triggerEl) {
var drawerId = $triggerEl.getAttribute('data-drawer-toggle');
var $drawerEl = document.getElementById(drawerId);
if ($drawerEl) {
var drawer_1 = getDrawerInstance(drawerId, drawerInstances);
if (drawer_1) {
$triggerEl.addEventListener('click', function () {
drawer_1.object.toggle();
});
}
else {
console.error("Drawer with id ".concat(drawerId, " has not been initialized. Please initialize it using the data-drawer-target attribute."));
}
}
else {
console.error("Drawer with id ".concat(drawerId, " not found. Are you sure that the data-drawer-target attribute points to the correct drawer id?"));
}
});
document
.querySelectorAll('[data-drawer-dismiss], [data-drawer-hide]')
.forEach(function ($triggerEl) {
var drawerId = $triggerEl.getAttribute('data-drawer-dismiss')
? $triggerEl.getAttribute('data-drawer-dismiss')
: $triggerEl.getAttribute('data-drawer-hide');
var $drawerEl = document.getElementById(drawerId);
if ($drawerEl) {
var drawer_2 = getDrawerInstance(drawerId, drawerInstances);
if (drawer_2) {
$triggerEl.addEventListener('click', function () {
drawer_2.object.hide();
});
}
else {
console.error("Drawer with id ".concat(drawerId, " has not been initialized. Please initialize it using the data-drawer-target attribute."));
}
}
else {
console.error("Drawer with id ".concat(drawerId, " not found. Are you sure that the data-drawer-target attribute points to the correct drawer id"));
}
});
document.querySelectorAll('[data-drawer-show]').forEach(function ($triggerEl) {
var drawerId = $triggerEl.getAttribute('data-drawer-show');
var $drawerEl = document.getElementById(drawerId);
if ($drawerEl) {
var drawer_3 = getDrawerInstance(drawerId, drawerInstances);
if (drawer_3) {
$triggerEl.addEventListener('click', function () {
drawer_3.object.show();
});
}
else {
console.error("Drawer with id ".concat(drawerId, " has not been initialized. Please initialize it using the data-drawer-target attribute."));
}
}
else {
console.error("Drawer with id ".concat(drawerId, " not found. Are you sure that the data-drawer-target attribute points to the correct drawer id?"));
}
});
}
exports.initDrawers = initDrawers;
if (typeof window !== 'undefined') {
window.Drawer = Drawer;
window.initDrawers = initDrawers;
}
exports.default = Drawer;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,17 @@
import { DrawerOptions, PlacementClasses } from './types';
export declare interface DrawerInterface {
_targetEl: HTMLElement;
_triggerEl: HTMLElement;
_options: DrawerOptions;
_visible: boolean;
_init(): void;
isVisible(): boolean;
isHidden(): boolean;
hide(): void;
show(): void;
toggle(): void;
_createBackdrop(): void;
_destroyBackdropEl(): void;
_getPlacementClasses(placement: string): PlacementClasses;
}
//# sourceMappingURL=interface.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/components/drawer/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,CAAC,OAAO,WAAW,eAAe;IAEpC,SAAS,EAAE,WAAW,CAAC;IACvB,UAAU,EAAE,WAAW,CAAC;IACxB,QAAQ,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAGlB,KAAK,IAAI,IAAI,CAAC;IACd,SAAS,IAAI,OAAO,CAAC;IACrB,QAAQ,IAAI,OAAO,CAAC;IACpB,IAAI,IAAI,IAAI,CAAC;IACb,IAAI,IAAI,IAAI,CAAC;IACb,MAAM,IAAI,IAAI,CAAC;IACf,eAAe,IAAI,IAAI,CAAC;IACxB,kBAAkB,IAAI,IAAI,CAAC;IAC3B,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAC;CAC7D"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interface.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../src/components/drawer/interface.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,22 @@
import { DrawerInterface } from './interface';
export declare type DrawerOptions = {
placement?: string;
bodyScrolling?: boolean;
backdrop?: boolean;
edge?: boolean;
edgeOffset?: string;
backdropClasses?: string;
onShow?: (drawer: DrawerInterface) => void;
onHide?: (drawer: DrawerInterface) => void;
onToggle?: (drawer: DrawerInterface) => void;
};
export declare type PlacementClasses = {
base: string[];
active: string[];
inactive: string[];
};
export declare type DrawerInstance = {
id: string;
object: DrawerInterface;
};
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/drawer/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,gBAAgB,GAAG;IACnC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,cAAc,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,eAAe,CAAC;CAC3B,CAAC"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/drawer/types.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,29 @@
import type { Instance as PopperInstance } from '@popperjs/core';
import type { DropdownOptions } from './types';
import { DropdownInterface } from './interface';
declare class Dropdown implements DropdownInterface {
_targetEl: HTMLElement;
_triggerEl: HTMLElement;
_options: DropdownOptions;
_visible: boolean;
_popperInstance: PopperInstance;
_clickOutsideEventListener: EventListenerOrEventListenerObject;
constructor(targetElement?: HTMLElement | null, triggerElement?: HTMLElement | null, options?: DropdownOptions);
_init(): void;
_setupEventListeners(): void;
_createPopperInstance(): PopperInstance;
_setupClickOutsideListener(): void;
_removeClickOutsideListener(): void;
_handleClickOutside(ev: Event, targetEl: HTMLElement): void;
_getTriggerEvents(): {
showEvents: string[];
hideEvents: string[];
};
toggle(): void;
isVisible(): boolean;
show(): void;
hide(): void;
}
export declare function initDropdowns(): void;
export default Dropdown;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/dropdown/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAER,QAAQ,IAAI,cAAc,EAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAchD,cAAM,QAAS,YAAW,iBAAiB;IACvC,SAAS,EAAE,WAAW,CAAC;IACvB,UAAU,EAAE,WAAW,CAAC;IACxB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,cAAc,CAAC;IAChC,0BAA0B,EAAE,kCAAkC,CAAC;gBAG3D,aAAa,GAAE,WAAW,GAAG,IAAW,EACxC,cAAc,GAAE,WAAW,GAAG,IAAW,EACzC,OAAO,GAAE,eAAyB;IAUtC,KAAK;IAML,oBAAoB;IA+CpB,qBAAqB;IAiBrB,0BAA0B;IAW1B,2BAA2B;IAQ3B,mBAAmB,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW;IA+BpD,iBAAiB;;;;IAyBjB,MAAM;IASN,SAAS;IAIT,IAAI;IAuBJ,IAAI;CAoBP;AAED,wBAAgB,aAAa,SAmD5B;AAOD,eAAe,QAAQ,CAAC"}

View File

@@ -0,0 +1,254 @@
"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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initDropdowns = void 0;
/* eslint-disable @typescript-eslint/no-empty-function */
var core_1 = require("@popperjs/core");
var Default = {
placement: 'bottom',
triggerType: 'click',
offsetSkidding: 0,
offsetDistance: 10,
delay: 300,
ignoreClickOutsideClass: false,
onShow: function () { },
onHide: function () { },
onToggle: function () { },
};
var Dropdown = /** @class */ (function () {
function Dropdown(targetElement, triggerElement, options) {
if (targetElement === void 0) { targetElement = null; }
if (triggerElement === void 0) { triggerElement = null; }
if (options === void 0) { options = Default; }
this._targetEl = targetElement;
this._triggerEl = triggerElement;
this._options = __assign(__assign({}, Default), options);
this._popperInstance = this._createPopperInstance();
this._visible = false;
this._init();
}
Dropdown.prototype._init = function () {
if (this._triggerEl) {
this._setupEventListeners();
}
};
Dropdown.prototype._setupEventListeners = function () {
var _this = this;
var triggerEvents = this._getTriggerEvents();
// click event handling for trigger element
if (this._options.triggerType === 'click') {
triggerEvents.showEvents.forEach(function (ev) {
_this._triggerEl.addEventListener(ev, function () {
_this.toggle();
});
});
}
// hover event handling for trigger element
if (this._options.triggerType === 'hover') {
triggerEvents.showEvents.forEach(function (ev) {
_this._triggerEl.addEventListener(ev, function () {
if (ev === 'click') {
_this.toggle();
}
else {
setTimeout(function () {
_this.show();
}, _this._options.delay);
}
});
_this._targetEl.addEventListener(ev, function () {
_this.show();
});
});
triggerEvents.hideEvents.forEach(function (ev) {
_this._triggerEl.addEventListener(ev, function () {
setTimeout(function () {
if (!_this._targetEl.matches(':hover')) {
_this.hide();
}
}, _this._options.delay);
});
_this._targetEl.addEventListener(ev, function () {
setTimeout(function () {
if (!_this._triggerEl.matches(':hover')) {
_this.hide();
}
}, _this._options.delay);
});
});
}
};
Dropdown.prototype._createPopperInstance = function () {
return (0, core_1.createPopper)(this._triggerEl, this._targetEl, {
placement: this._options.placement,
modifiers: [
{
name: 'offset',
options: {
offset: [
this._options.offsetSkidding,
this._options.offsetDistance,
],
},
},
],
});
};
Dropdown.prototype._setupClickOutsideListener = function () {
var _this = this;
this._clickOutsideEventListener = function (ev) {
_this._handleClickOutside(ev, _this._targetEl);
};
document.body.addEventListener('click', this._clickOutsideEventListener, true);
};
Dropdown.prototype._removeClickOutsideListener = function () {
document.body.removeEventListener('click', this._clickOutsideEventListener, true);
};
Dropdown.prototype._handleClickOutside = function (ev, targetEl) {
var clickedEl = ev.target;
// Ignore clicks on the trigger element (ie. a datepicker input)
var ignoreClickOutsideClass = this._options.ignoreClickOutsideClass;
var isIgnored = false;
if (ignoreClickOutsideClass) {
var ignoredClickOutsideEls = document.querySelectorAll(".".concat(ignoreClickOutsideClass));
ignoredClickOutsideEls.forEach(function (el) {
if (el.contains(clickedEl)) {
isIgnored = true;
return;
}
});
}
// Ignore clicks on the target element (ie. dropdown itself)
if (clickedEl !== targetEl &&
!targetEl.contains(clickedEl) &&
!this._triggerEl.contains(clickedEl) &&
!isIgnored &&
this.isVisible()) {
this.hide();
}
};
Dropdown.prototype._getTriggerEvents = function () {
switch (this._options.triggerType) {
case 'hover':
return {
showEvents: ['mouseenter', 'click'],
hideEvents: ['mouseleave'],
};
case 'click':
return {
showEvents: ['click'],
hideEvents: [],
};
case 'none':
return {
showEvents: [],
hideEvents: [],
};
default:
return {
showEvents: ['click'],
hideEvents: [],
};
}
};
Dropdown.prototype.toggle = function () {
if (this.isVisible()) {
this.hide();
}
else {
this.show();
}
this._options.onToggle(this);
};
Dropdown.prototype.isVisible = function () {
return this._visible;
};
Dropdown.prototype.show = function () {
this._targetEl.classList.remove('hidden');
this._targetEl.classList.add('block');
// Enable the event listeners
this._popperInstance.setOptions(function (options) { return (__assign(__assign({}, options), { modifiers: __spreadArray(__spreadArray([], options.modifiers, true), [
{ name: 'eventListeners', enabled: true },
], false) })); });
this._setupClickOutsideListener();
// Update its position
this._popperInstance.update();
this._visible = true;
// callback function
this._options.onShow(this);
};
Dropdown.prototype.hide = function () {
this._targetEl.classList.remove('block');
this._targetEl.classList.add('hidden');
// Disable the event listeners
this._popperInstance.setOptions(function (options) { return (__assign(__assign({}, options), { modifiers: __spreadArray(__spreadArray([], options.modifiers, true), [
{ name: 'eventListeners', enabled: false },
], false) })); });
this._visible = false;
this._removeClickOutsideListener();
// callback function
this._options.onHide(this);
};
return Dropdown;
}());
function initDropdowns() {
document
.querySelectorAll('[data-dropdown-toggle]')
.forEach(function ($triggerEl) {
var dropdownId = $triggerEl.getAttribute('data-dropdown-toggle');
var $dropdownEl = document.getElementById(dropdownId);
if ($dropdownEl) {
var placement = $triggerEl.getAttribute('data-dropdown-placement');
var offsetSkidding = $triggerEl.getAttribute('data-dropdown-offset-skidding');
var offsetDistance = $triggerEl.getAttribute('data-dropdown-offset-distance');
var triggerType = $triggerEl.getAttribute('data-dropdown-trigger');
var delay = $triggerEl.getAttribute('data-dropdown-delay');
var ignoreClickOutsideClass = $triggerEl.getAttribute('data-dropdown-ignore-click-outside-class');
new Dropdown($dropdownEl, $triggerEl, {
placement: placement ? placement : Default.placement,
triggerType: triggerType
? triggerType
: Default.triggerType,
offsetSkidding: offsetSkidding
? parseInt(offsetSkidding)
: Default.offsetSkidding,
offsetDistance: offsetDistance
? parseInt(offsetDistance)
: Default.offsetDistance,
delay: delay ? parseInt(delay) : Default.delay,
ignoreClickOutsideClass: ignoreClickOutsideClass
? ignoreClickOutsideClass
: Default.ignoreClickOutsideClass,
});
}
else {
console.error("The dropdown element with id \"".concat(dropdownId, "\" does not exist. Please check the data-dropdown-toggle attribute."));
}
});
}
exports.initDropdowns = initDropdowns;
if (typeof window !== 'undefined') {
window.Dropdown = Dropdown;
window.initDropdowns = initDropdowns;
}
exports.default = Dropdown;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,22 @@
import { DropdownOptions, DropdownTriggerType, DropdownTriggerEventTypes } from './types';
import type { Instance as PopperInstance } from '@popperjs/core';
export declare interface DropdownInterface {
_targetEl: HTMLElement;
_triggerEl: HTMLElement;
_options: DropdownOptions;
_visible: boolean;
_popperInstance: PopperInstance;
_clickOutsideEventListener: EventListenerOrEventListenerObject;
_init(): void;
_createPopperInstance(): PopperInstance;
_setupEventListeners(): void;
_setupClickOutsideListener(): void;
_removeClickOutsideListener(): void;
_handleClickOutside(ev: Event, targetEl: HTMLElement): void;
_getTriggerEvents(triggerType: DropdownTriggerType): DropdownTriggerEventTypes;
isVisible(): boolean;
toggle(): void;
show(): void;
hide(): void;
}
//# sourceMappingURL=interface.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/components/dropdown/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EAC5B,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEjE,MAAM,CAAC,OAAO,WAAW,iBAAiB;IACtC,SAAS,EAAE,WAAW,CAAC;IACvB,UAAU,EAAE,WAAW,CAAC;IACxB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,cAAc,CAAC;IAChC,0BAA0B,EAAE,kCAAkC,CAAC;IAE/D,KAAK,IAAI,IAAI,CAAC;IACd,qBAAqB,IAAI,cAAc,CAAC;IACxC,oBAAoB,IAAI,IAAI,CAAC;IAC7B,0BAA0B,IAAI,IAAI,CAAC;IACnC,2BAA2B,IAAI,IAAI,CAAC;IACpC,mBAAmB,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5D,iBAAiB,CACb,WAAW,EAAE,mBAAmB,GACjC,yBAAyB,CAAC;IAC7B,SAAS,IAAI,OAAO,CAAC;IACrB,MAAM,IAAI,IAAI,CAAC;IACf,IAAI,IAAI,IAAI,CAAC;IACb,IAAI,IAAI,IAAI,CAAC;CAChB"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interface.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../src/components/dropdown/interface.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,19 @@
import { DropdownInterface } from './interface';
import type { Placement } from '@popperjs/core';
export declare type DropdownTriggerType = 'click' | 'hover' | 'none';
export declare type DropdownTriggerEventTypes = {
showEvents: string[];
hideEvents: string[];
};
export declare type DropdownOptions = {
placement?: Placement;
triggerType?: DropdownTriggerType;
offsetSkidding?: number;
offsetDistance?: number;
ignoreClickOutsideClass?: string | boolean;
delay?: number;
onShow?: (tooltip: DropdownInterface) => void;
onHide?: (tooltip: DropdownInterface) => void;
onToggle?: (tooltip: DropdownInterface) => void;
};
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/dropdown/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,CAAC,OAAO,MAAM,mBAAmB,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAErE,MAAM,CAAC,OAAO,MAAM,yBAAyB,GAAG;IAC5C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,eAAe,GAAG;IAClC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uBAAuB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC9C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC9C,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;CACnD,CAAC"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/dropdown/types.ts"],"names":[],"mappings":""}

2
node_modules/flowbite/lib/cjs/components/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare function initFlowbite(): void;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAYA,wBAAgB,YAAY,SAY3B"}

32
node_modules/flowbite/lib/cjs/components/index.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initFlowbite = void 0;
var accordion_1 = require("./accordion");
var carousel_1 = require("./carousel");
var collapse_1 = require("./collapse");
var dial_1 = require("./dial");
var dismiss_1 = require("./dismiss");
var drawer_1 = require("./drawer");
var dropdown_1 = require("./dropdown");
var modal_1 = require("./modal");
var popover_1 = require("./popover");
var tabs_1 = require("./tabs");
var tooltip_1 = require("./tooltip");
function initFlowbite() {
(0, accordion_1.initAccordions)();
(0, collapse_1.initCollapses)();
(0, carousel_1.initCarousels)();
(0, dismiss_1.initDismisses)();
(0, dropdown_1.initDropdowns)();
(0, modal_1.initModals)();
(0, drawer_1.initDrawers)();
(0, tabs_1.initTabs)();
(0, tooltip_1.initTooltips)();
(0, popover_1.initPopovers)();
(0, dial_1.initDials)();
}
exports.initFlowbite = initFlowbite;
if (typeof window !== 'undefined') {
window.initFlowbite = initFlowbite;
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,yCAA6C;AAC7C,uCAA2C;AAC3C,uCAA2C;AAC3C,+BAAmC;AACnC,qCAA0C;AAC1C,mCAAuC;AACvC,uCAA2C;AAC3C,iCAAqC;AACrC,qCAAyC;AACzC,+BAAkC;AAClC,qCAAyC;AAEzC,SAAgB,YAAY;IACxB,IAAA,0BAAc,GAAE,CAAC;IACjB,IAAA,wBAAa,GAAE,CAAC;IAChB,IAAA,wBAAa,GAAE,CAAC;IAChB,IAAA,uBAAa,GAAE,CAAC;IAChB,IAAA,wBAAa,GAAE,CAAC;IAChB,IAAA,kBAAU,GAAE,CAAC;IACb,IAAA,oBAAW,GAAE,CAAC;IACd,IAAA,eAAQ,GAAE,CAAC;IACX,IAAA,sBAAY,GAAE,CAAC;IACf,IAAA,sBAAY,GAAE,CAAC;IACf,IAAA,gBAAS,GAAE,CAAC;AAChB,CAAC;AAZD,oCAYC;AAED,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAC/B,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;CACtC"}

View File

@@ -0,0 +1,26 @@
import type { ModalOptions } from './types';
import { ModalInterface } from './interface';
declare class Modal implements ModalInterface {
_targetEl: HTMLElement | null;
_options: ModalOptions;
_isHidden: boolean;
_backdropEl: HTMLElement | null;
_clickOutsideEventListener: EventListenerOrEventListenerObject;
_keydownEventListener: EventListenerOrEventListenerObject;
constructor(targetEl?: HTMLElement | null, options?: ModalOptions);
_init(): void;
_createBackdrop(): void;
_destroyBackdropEl(): void;
_setupModalCloseEventListeners(): void;
_removeModalCloseEventListeners(): void;
_handleOutsideClick(target: EventTarget): void;
_getPlacementClasses(): string[];
toggle(): void;
show(): void;
hide(): void;
isVisible(): boolean;
isHidden(): boolean;
}
export declare function initModals(): void;
export default Modal;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAa7C,cAAM,KAAM,YAAW,cAAc;IACjC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,0BAA0B,EAAE,kCAAkC,CAAC;IAC/D,qBAAqB,EAAE,kCAAkC,CAAC;gBAGtD,QAAQ,GAAE,WAAW,GAAG,IAAW,EACnC,OAAO,GAAE,YAAsB;IASnC,KAAK;IAQL,eAAe;IAYf,kBAAkB;IAMlB,8BAA8B;IAwB9B,+BAA+B;IAe/B,mBAAmB,CAAC,MAAM,EAAE,WAAW;IASvC,oBAAoB;IA+BpB,MAAM;IAWN,IAAI;IAuBJ,IAAI;IAsBJ,SAAS;IAIT,QAAQ;CAGX;AASD,wBAAgB,UAAU,SAgIzB;AAOD,eAAe,KAAK,CAAC"}

274
node_modules/flowbite/lib/cjs/components/modal/index.js generated vendored Normal file
View File

@@ -0,0 +1,274 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initModals = void 0;
var Default = {
placement: 'center',
backdropClasses: 'bg-gray-900 bg-opacity-50 dark:bg-opacity-80 fixed inset-0 z-40',
backdrop: 'dynamic',
closable: true,
onHide: function () { },
onShow: function () { },
onToggle: function () { },
};
var Modal = /** @class */ (function () {
function Modal(targetEl, options) {
if (targetEl === void 0) { targetEl = null; }
if (options === void 0) { options = Default; }
this._targetEl = targetEl;
this._options = __assign(__assign({}, Default), options);
this._isHidden = true;
this._backdropEl = null;
this._init();
}
Modal.prototype._init = function () {
var _this = this;
if (this._targetEl) {
this._getPlacementClasses().map(function (c) {
_this._targetEl.classList.add(c);
});
}
};
Modal.prototype._createBackdrop = function () {
var _a;
if (this._isHidden) {
var backdropEl = document.createElement('div');
backdropEl.setAttribute('modal-backdrop', '');
(_a = backdropEl.classList).add.apply(_a, this._options.backdropClasses.split(' '));
document.querySelector('body').append(backdropEl);
this._backdropEl = backdropEl;
}
};
Modal.prototype._destroyBackdropEl = function () {
if (!this._isHidden) {
document.querySelector('[modal-backdrop]').remove();
}
};
Modal.prototype._setupModalCloseEventListeners = function () {
var _this = this;
if (this._options.backdrop === 'dynamic') {
this._clickOutsideEventListener = function (ev) {
_this._handleOutsideClick(ev.target);
};
this._targetEl.addEventListener('click', this._clickOutsideEventListener, true);
}
this._keydownEventListener = function (ev) {
if (ev.key === 'Escape') {
_this.hide();
}
};
document.body.addEventListener('keydown', this._keydownEventListener, true);
};
Modal.prototype._removeModalCloseEventListeners = function () {
if (this._options.backdrop === 'dynamic') {
this._targetEl.removeEventListener('click', this._clickOutsideEventListener, true);
}
document.body.removeEventListener('keydown', this._keydownEventListener, true);
};
Modal.prototype._handleOutsideClick = function (target) {
if (target === this._targetEl ||
(target === this._backdropEl && this.isVisible())) {
this.hide();
}
};
Modal.prototype._getPlacementClasses = function () {
switch (this._options.placement) {
// top
case 'top-left':
return ['justify-start', 'items-start'];
case 'top-center':
return ['justify-center', 'items-start'];
case 'top-right':
return ['justify-end', 'items-start'];
// center
case 'center-left':
return ['justify-start', 'items-center'];
case 'center':
return ['justify-center', 'items-center'];
case 'center-right':
return ['justify-end', 'items-center'];
// bottom
case 'bottom-left':
return ['justify-start', 'items-end'];
case 'bottom-center':
return ['justify-center', 'items-end'];
case 'bottom-right':
return ['justify-end', 'items-end'];
default:
return ['justify-center', 'items-center'];
}
};
Modal.prototype.toggle = function () {
if (this._isHidden) {
this.show();
}
else {
this.hide();
}
// callback function
this._options.onToggle(this);
};
Modal.prototype.show = function () {
if (this.isHidden) {
this._targetEl.classList.add('flex');
this._targetEl.classList.remove('hidden');
this._targetEl.setAttribute('aria-modal', 'true');
this._targetEl.setAttribute('role', 'dialog');
this._targetEl.removeAttribute('aria-hidden');
this._createBackdrop();
this._isHidden = false;
// prevent body scroll
document.body.classList.add('overflow-hidden');
// Add keyboard event listener to the document
if (this._options.closable) {
this._setupModalCloseEventListeners();
}
// callback function
this._options.onShow(this);
}
};
Modal.prototype.hide = function () {
if (this.isVisible) {
this._targetEl.classList.add('hidden');
this._targetEl.classList.remove('flex');
this._targetEl.setAttribute('aria-hidden', 'true');
this._targetEl.removeAttribute('aria-modal');
this._targetEl.removeAttribute('role');
this._destroyBackdropEl();
this._isHidden = true;
// re-apply body scroll
document.body.classList.remove('overflow-hidden');
if (this._options.closable) {
this._removeModalCloseEventListeners();
}
// callback function
this._options.onHide(this);
}
};
Modal.prototype.isVisible = function () {
return !this._isHidden;
};
Modal.prototype.isHidden = function () {
return this._isHidden;
};
return Modal;
}());
var getModalInstance = function (id, instances) {
if (instances.some(function (modalInstance) { return modalInstance.id === id; })) {
return instances.find(function (modalInstance) { return modalInstance.id === id; });
}
return null;
};
function initModals() {
var modalInstances = [];
// initiate modal based on data-modal-target
document.querySelectorAll('[data-modal-target]').forEach(function ($triggerEl) {
var modalId = $triggerEl.getAttribute('data-modal-target');
var $modalEl = document.getElementById(modalId);
if ($modalEl) {
var placement = $modalEl.getAttribute('data-modal-placement');
var backdrop = $modalEl.getAttribute('data-modal-backdrop');
if (!getModalInstance(modalId, modalInstances)) {
modalInstances.push({
id: modalId,
object: new Modal($modalEl, {
placement: placement
? placement
: Default.placement,
backdrop: backdrop ? backdrop : Default.backdrop,
}),
});
}
}
else {
console.error("Modal with id ".concat(modalId, " does not exist. Are you sure that the data-modal-target attribute points to the correct modal id?."));
}
});
// support pre v1.6.0 data-modal-toggle initialization
document.querySelectorAll('[data-modal-toggle]').forEach(function ($triggerEl) {
var modalId = $triggerEl.getAttribute('data-modal-toggle');
var $modalEl = document.getElementById(modalId);
if ($modalEl) {
var placement = $modalEl.getAttribute('data-modal-placement');
var backdrop = $modalEl.getAttribute('data-modal-backdrop');
var modal_1 = getModalInstance(modalId, modalInstances);
if (!modal_1) {
modal_1 = {
id: modalId,
object: new Modal($modalEl, {
placement: placement
? placement
: Default.placement,
backdrop: backdrop ? backdrop : Default.backdrop,
}),
};
modalInstances.push(modal_1);
}
$triggerEl.addEventListener('click', function () {
modal_1.object.toggle();
});
}
else {
console.error("Modal with id ".concat(modalId, " does not exist. Are you sure that the data-modal-toggle attribute points to the correct modal id?"));
}
});
// show modal on click if exists based on id
document.querySelectorAll('[data-modal-show]').forEach(function ($triggerEl) {
var modalId = $triggerEl.getAttribute('data-modal-show');
var $modalEl = document.getElementById(modalId);
if ($modalEl) {
var modal_2 = getModalInstance(modalId, modalInstances);
if (modal_2) {
$triggerEl.addEventListener('click', function () {
if (modal_2.object.isHidden) {
modal_2.object.show();
}
});
}
else {
console.error("Modal with id ".concat(modalId, " has not been initialized. Please initialize it using the data-modal-target attribute."));
}
}
else {
console.error("Modal with id ".concat(modalId, " does not exist. Are you sure that the data-modal-show attribute points to the correct modal id?"));
}
});
// hide modal on click if exists based on id
document.querySelectorAll('[data-modal-hide]').forEach(function ($triggerEl) {
var modalId = $triggerEl.getAttribute('data-modal-hide');
var $modalEl = document.getElementById(modalId);
if ($modalEl) {
var modal_3 = getModalInstance(modalId, modalInstances);
if (modal_3) {
$triggerEl.addEventListener('click', function () {
if (modal_3.object.isVisible) {
modal_3.object.hide();
}
});
}
else {
console.error("Modal with id ".concat(modalId, " has not been initialized. Please initialize it using the data-modal-target attribute."));
}
}
else {
console.error("Modal with id ".concat(modalId, " does not exist. Are you sure that the data-modal-hide attribute points to the correct modal id?"));
}
});
}
exports.initModals = initModals;
if (typeof window !== 'undefined') {
window.Modal = Modal;
window.initModals = initModals;
}
exports.default = Modal;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,21 @@
import { ModalOptions } from './types';
export declare interface ModalInterface {
_targetEl: HTMLElement | null;
_options: ModalOptions;
_isHidden: boolean;
_backdropEl: HTMLElement | null;
_clickOutsideEventListener: EventListenerOrEventListenerObject;
_keydownEventListener: EventListenerOrEventListenerObject;
_init(): void;
_createBackdrop(): void;
_destroyBackdropEl(): void;
_setupModalCloseEventListeners(): void;
_handleOutsideClick(target: EventTarget): void;
_getPlacementClasses(): string[];
toggle(): void;
show(): void;
hide(): void;
isHidden(): boolean;
isVisible(): boolean;
}
//# sourceMappingURL=interface.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,CAAC,OAAO,WAAW,cAAc;IAEnC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;IAG9B,QAAQ,EAAE,YAAY,CAAC;IAGvB,SAAS,EAAE,OAAO,CAAC;IAGnB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAEhC,0BAA0B,EAAE,kCAAkC,CAAC;IAE/D,qBAAqB,EAAE,kCAAkC,CAAC;IAG1D,KAAK,IAAI,IAAI,CAAC;IAGd,eAAe,IAAI,IAAI,CAAC;IAGxB,kBAAkB,IAAI,IAAI,CAAC;IAG3B,8BAA8B,IAAI,IAAI,CAAC;IAGvC,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAG/C,oBAAoB,IAAI,MAAM,EAAE,CAAC;IAGjC,MAAM,IAAI,IAAI,CAAC;IAGf,IAAI,IAAI,IAAI,CAAC;IAGb,IAAI,IAAI,IAAI,CAAC;IAGb,QAAQ,IAAI,OAAO,CAAC;IAGpB,SAAS,IAAI,OAAO,CAAC;CACxB"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interface.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../src/components/modal/interface.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,17 @@
import { ModalInterface } from './interface';
export declare type modalBackdrop = 'static' | 'dynamic';
export declare type modalPlacement = 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
export declare type ModalOptions = {
placement?: modalPlacement;
backdropClasses?: string;
backdrop?: modalBackdrop;
closable?: boolean;
onShow?: (modal: ModalInterface) => void;
onHide?: (modal: ModalInterface) => void;
onToggle?: (modal: ModalInterface) => void;
};
export declare type ModalInstance = {
id: string;
object: ModalInterface;
};
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG,QAAQ,GAAG,SAAS,CAAC;AACzD,MAAM,CAAC,OAAO,MAAM,cAAc,GAC5B,UAAU,GACV,YAAY,GACZ,WAAW,GACX,aAAa,GACb,QAAQ,GACR,cAAc,GACd,aAAa,GACb,eAAe,GACf,cAAc,CAAC;AAErB,MAAM,CAAC,OAAO,MAAM,YAAY,GAAG;IAC/B,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,cAAc,CAAC;CAC1B,CAAC"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/modal/types.ts"],"names":[],"mappings":""}

Some files were not shown because too many files have changed in this diff Show More