second commit

This commit is contained in:
2024-12-27 22:31:23 +09:00
parent 2353324570
commit 10a0f110ca
8819 changed files with 1307198 additions and 28 deletions

View File

@ -0,0 +1,27 @@
import type { DatepickerOptions } from './types';
import type { InstanceOptions } from '../../dom/types';
import { DatepickerInterface } from './interface';
import { Datepicker as FlowbiteDatepicker, DateRangePicker as FlowbiteDateRangePicker } from 'flowbite-datepicker';
declare class Datepicker implements DatepickerInterface {
_instanceId: string;
_datepickerEl: HTMLElement;
_datepickerInstance: FlowbiteDatepicker | FlowbiteDateRangePicker | null;
_options: DatepickerOptions;
_initialized: boolean;
constructor(datepickerEl?: HTMLElement | null, options?: DatepickerOptions, instanceOptions?: InstanceOptions);
init(): void;
destroy(): void;
removeInstance(): void;
destroyAndRemoveInstance(): void;
getDatepickerInstance(): FlowbiteDatepicker | FlowbiteDateRangePicker;
getDate(): string | string[];
setDate(date: any): void;
show(): void;
hide(): void;
_getDatepickerOptions(options: DatepickerOptions): any;
updateOnShow(callback: () => void): void;
updateOnHide(callback: () => void): void;
}
export declare function initDatepickers(): void;
export default Datepicker;
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/datepicker/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,EACH,UAAU,IAAI,kBAAkB,EAChC,eAAe,IAAI,uBAAuB,EAC7C,MAAM,qBAAqB,CAAC;AAuB7B,cAAM,UAAW,YAAW,mBAAmB;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,WAAW,CAAC;IAC3B,mBAAmB,EAAE,kBAAkB,GAAG,uBAAuB,GAAG,IAAI,CAAC;IACzE,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;gBAGlB,YAAY,GAAE,WAAW,GAAG,IAAW,EACvC,OAAO,GAAE,iBAA2B,EACpC,eAAe,GAAE,eAAwC;IAkB7D,IAAI;IAkBJ,OAAO;IAOP,cAAc;IAKd,wBAAwB;IAKxB,qBAAqB;IAIrB,OAAO;IAgBP,OAAO,CAAC,IAAI,EAAE,GAAG;IAgBjB,IAAI;IAKJ,IAAI;IAKJ,qBAAqB,CAAC,OAAO,EAAE,iBAAiB;IA2ChD,YAAY,CAAC,QAAQ,EAAE,MAAM,IAAI;IAIjC,YAAY,CAAC,QAAQ,EAAE,MAAM,IAAI;CAGpC;AAED,wBAAgB,eAAe,SA0D9B;AAOD,eAAe,UAAU,CAAC"}

View File

@ -0,0 +1,188 @@
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);
};
import instances from '../../dom/instances';
import { Datepicker as FlowbiteDatepicker, DateRangePicker as FlowbiteDateRangePicker, } from 'flowbite-datepicker';
var Default = {
defaultDatepickerId: null,
autohide: false,
format: 'mm/dd/yyyy',
maxDate: null,
minDate: null,
orientation: 'bottom',
buttons: false,
autoSelectToday: 0,
title: null,
language: 'en',
rangePicker: false,
onShow: function () { },
onHide: function () { },
};
var DefaultInstanceOptions = {
id: null,
override: true,
};
var Datepicker = /** @class */ (function () {
function Datepicker(datepickerEl, options, instanceOptions) {
if (datepickerEl === void 0) { datepickerEl = null; }
if (options === void 0) { options = Default; }
if (instanceOptions === void 0) { instanceOptions = DefaultInstanceOptions; }
this._instanceId = instanceOptions.id
? instanceOptions.id
: datepickerEl.id;
this._datepickerEl = datepickerEl;
this._datepickerInstance = null;
this._options = __assign(__assign({}, Default), options);
this._initialized = false;
this.init();
instances.addInstance('Datepicker', this, this._instanceId, instanceOptions.override);
}
Datepicker.prototype.init = function () {
if (this._datepickerEl && !this._initialized) {
if (this._options.rangePicker) {
this._datepickerInstance = new FlowbiteDateRangePicker(this._datepickerEl, this._getDatepickerOptions(this._options));
}
else {
this._datepickerInstance = new FlowbiteDatepicker(this._datepickerEl, this._getDatepickerOptions(this._options));
}
this._initialized = true;
}
};
Datepicker.prototype.destroy = function () {
if (this._initialized) {
this._initialized = false;
this._datepickerInstance.destroy();
}
};
Datepicker.prototype.removeInstance = function () {
this.destroy();
instances.removeInstance('Datepicker', this._instanceId);
};
Datepicker.prototype.destroyAndRemoveInstance = function () {
this.destroy();
this.removeInstance();
};
Datepicker.prototype.getDatepickerInstance = function () {
return this._datepickerInstance;
};
Datepicker.prototype.getDate = function () {
if (this._options.rangePicker &&
this._datepickerInstance instanceof FlowbiteDateRangePicker) {
return this._datepickerInstance.getDates();
}
if (!this._options.rangePicker &&
this._datepickerInstance instanceof FlowbiteDatepicker) {
return this._datepickerInstance.getDate();
}
};
Datepicker.prototype.setDate = function (date) {
if (this._options.rangePicker &&
this._datepickerInstance instanceof FlowbiteDateRangePicker) {
return this._datepickerInstance.setDates(date);
}
if (!this._options.rangePicker &&
this._datepickerInstance instanceof FlowbiteDatepicker) {
return this._datepickerInstance.setDate(date);
}
};
Datepicker.prototype.show = function () {
this._datepickerInstance.show();
this._options.onShow(this);
};
Datepicker.prototype.hide = function () {
this._datepickerInstance.hide();
this._options.onHide(this);
};
Datepicker.prototype._getDatepickerOptions = function (options) {
var datepickerOptions = {};
if (options.buttons) {
datepickerOptions.todayBtn = true;
datepickerOptions.clearBtn = true;
if (options.autoSelectToday) {
datepickerOptions.todayBtnMode = 1;
}
}
if (options.autohide) {
datepickerOptions.autohide = true;
}
if (options.format) {
datepickerOptions.format = options.format;
}
if (options.maxDate) {
datepickerOptions.maxDate = options.maxDate;
}
if (options.minDate) {
datepickerOptions.minDate = options.minDate;
}
if (options.orientation) {
datepickerOptions.orientation = options.orientation;
}
if (options.title) {
datepickerOptions.title = options.title;
}
if (options.language) {
datepickerOptions.language = options.language;
}
return datepickerOptions;
};
Datepicker.prototype.updateOnShow = function (callback) {
this._options.onShow = callback;
};
Datepicker.prototype.updateOnHide = function (callback) {
this._options.onHide = callback;
};
return Datepicker;
}());
export function initDatepickers() {
document
.querySelectorAll('[datepicker], [inline-datepicker], [date-rangepicker]')
.forEach(function ($datepickerEl) {
if ($datepickerEl) {
var buttons = $datepickerEl.hasAttribute('datepicker-buttons');
var autoselectToday = $datepickerEl.hasAttribute('datepicker-autoselect-today');
var autohide = $datepickerEl.hasAttribute('datepicker-autohide');
var format = $datepickerEl.getAttribute('datepicker-format');
var maxDate = $datepickerEl.getAttribute('datepicker-max-date');
var minDate = $datepickerEl.getAttribute('datepicker-min-date');
var orientation_1 = $datepickerEl.getAttribute('datepicker-orientation');
var title = $datepickerEl.getAttribute('datepicker-title');
var language = $datepickerEl.getAttribute('datepicker-language');
var rangePicker = $datepickerEl.hasAttribute('date-rangepicker');
new Datepicker($datepickerEl, {
buttons: buttons ? buttons : Default.buttons,
autoSelectToday: autoselectToday
? autoselectToday
: Default.autoSelectToday,
autohide: autohide ? autohide : Default.autohide,
format: format ? format : Default.format,
maxDate: maxDate ? maxDate : Default.maxDate,
minDate: minDate ? minDate : Default.minDate,
orientation: orientation_1
? orientation_1
: Default.orientation,
title: title ? title : Default.title,
language: language ? language : Default.language,
rangePicker: rangePicker
? rangePicker
: Default.rangePicker,
});
}
else {
console.error("The datepicker element does not exist. Please check the datepicker attribute.");
}
});
}
if (typeof window !== 'undefined') {
window.Datepicker = Datepicker;
window.initDatepickers = initDatepickers;
}
export default Datepicker;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,11 @@
import { DatepickerOptions } from './types';
export declare interface DatepickerInterface {
_datepickerEl: HTMLElement;
_datepickerInstance: any | null;
_options: DatepickerOptions;
init(): void;
destroy(): void;
removeInstance(): void;
destroyAndRemoveInstance(): void;
}
//# sourceMappingURL=interface.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/components/datepicker/interface.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,CAAC,OAAO,WAAW,mBAAmB;IACxC,aAAa,EAAE,WAAW,CAAC;IAC3B,mBAAmB,EAAE,GAAG,GAAG,IAAI,CAAC;IAChC,QAAQ,EAAE,iBAAiB,CAAC;IAE5B,IAAI,IAAI,IAAI,CAAC;IAEb,OAAO,IAAI,IAAI,CAAC;IAChB,cAAc,IAAI,IAAI,CAAC;IACvB,wBAAwB,IAAI,IAAI,CAAC;CACpC"}

View File

@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=interface.js.map

View File

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

View File

@ -0,0 +1,20 @@
import { DatepickerInterface } from './interface';
export interface DatepickerOptions {
defaultDatepickerId?: string | null;
autohide?: boolean;
format?: string;
maxDate?: string | null;
minDate?: string | null;
orientation?: string;
buttons?: boolean;
autoSelectToday?: number;
title?: string | null;
language?: string;
locales?: {
[key: string]: any;
};
rangePicker?: boolean | false;
onShow?: (Datepicker: DatepickerInterface) => void;
onHide?: (Datepicker: DatepickerInterface) => void;
}
//# sourceMappingURL=types.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/datepicker/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,WAAW,iBAAiB;IAC9B,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC9B,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACnD,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACtD"}

View File

@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=types.js.map

View File

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