Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion easydata.js/bundles/crud/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { fileURLToPath } from 'url';
import noEmit from 'rollup-plugin-no-emit'
import postcss from 'rollup-plugin-postcss'
import autoprefixer from "autoprefixer"
import pkg from './package.json' assert { type: 'json' };
import pkg from './package.json' with { type: 'json' };
import buble from '@rollup/plugin-buble'
import cleanup from 'rollup-plugin-cleanup'

Expand Down
2 changes: 1 addition & 1 deletion easydata.js/bundles/crud/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"typeRoots": ["node_modules/@types"],
"lib": ["es5", "dom"],
"baseUrl": ".",
"outDir": "./dist/types",
"outDir": "./dist",
"noEmitOnError": true
},
"include": [
Expand Down
4 changes: 2 additions & 2 deletions easydata.js/packs/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@easydata/core",
"version": "1.5.5",
"version": "1.5.9-rc01",
"description": "EasyData.JS core functions, classes, and data structures",
"types": "./dist/types/public_api.d.ts",
"main": "./dist/easydata.core.cjs.js",
Expand Down Expand Up @@ -33,4 +33,4 @@
"dependencies": {
"tsx": "^4.19.4"
}
}
}
1 change: 0 additions & 1 deletion easydata.js/packs/core/src/meta/meta_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ValueEditor } from './value_editor';
* Represents a data model
*/
export class MetaData {

/** The ID of the data mode. */
public id: string;

Expand Down
2 changes: 1 addition & 1 deletion easydata.js/packs/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"typeRoots": ["node_modules/@types"],
"lib": ["ESNext", "dom"],
"baseUrl": ".",
"outDir": "./dist/types",
"outDir": "./dist",
"noEmitOnError": true
},
"include": [
Expand Down
7 changes: 3 additions & 4 deletions easydata.js/packs/crud/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"name": "@easydata/crud",
"version": "1.5.5",
"version": "1.5.9-rc01",
"description": "EasyData.JS UI widgets and views for CRUD manipulations",
"types": "./dist/types/public_api.d.ts",
"main": "./dist/easydata.crud.cjs.js",
"module": "./dist/easydata.crud.esm.js",
"scripts": {
"test": "vitest run",
"test": "cross-env NODE_OPTIONS=\"--import tsx\" latte -d -v -t --include=./**/*.test.ts",
"clear": "shx rm -rf dist/* docs/* lib/*",
"build": "npm run clear && rollup -c",
"watch": "rollup -c -w",
"docs": "typedoc src/public_api.ts --out ./docs",
"test": "cross-env NODE_OPTIONS=\"--import tsx\" latte -d -v -t --include=./**/*.test.ts"
"docs": "typedoc src/public_api.ts --out ./docs"
},
"author": "Korzh.com",
"homepage": "https://github.com/KorzhCom/EasyData",
Expand Down
2 changes: 1 addition & 1 deletion easydata.js/packs/crud/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { fileURLToPath } from 'url';
import noEmit from 'rollup-plugin-no-emit'
import postcss from 'rollup-plugin-postcss'
import autoprefixer from "autoprefixer"
import pkg from './package.json' assert { type: 'json' };
import pkg from './package.json' with { type: 'json' };

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand Down
2 changes: 1 addition & 1 deletion easydata.js/packs/crud/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"typeRoots": ["node_modules/@types"],
"lib": ["ESNext", "dom"],
"baseUrl": ".",
"outDir": "./dist/types",
"outDir": "./dist",
"noEmitOnError": true
},
"include": [
Expand Down
5 changes: 5 additions & 0 deletions easydata.js/packs/ui/assets/css/easy-forms/datetimepicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -527,3 +527,8 @@
.kdtp-tp-time-row input[type=range]::-ms-fill-upper {
background:0 0
}

.kdtp-cal-day-disabled {
opacity: 0.5!important;
pointer-events: none!important;
}
2 changes: 1 addition & 1 deletion easydata.js/packs/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@easydata/ui",
"version": "1.5.5",
"version": "1.5.9-rc01",
"description": "EasyData.JS: DOM manipulation functions and UI widgets",
"types": "./dist/types/public_api.d.ts",
"main": "./dist/easydata.ui.cjs.js",
Expand Down
2 changes: 1 addition & 1 deletion easydata.js/packs/ui/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import typescript from '@rollup/plugin-typescript'
import noEmit from 'rollup-plugin-no-emit'
import * as path from "path";
import { fileURLToPath } from 'url';
import pkg from './package.json' assert { type: 'json' };
import pkg from './package.json' with { type: 'json' };

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand Down
54 changes: 50 additions & 4 deletions easydata.js/packs/ui/src/datetimepicker/calendar.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
// null or none, today, [string]date, [Date]date
export type DateLike = null | string | Date;

export interface CalendarOptions {
yearRange?: string;
showDateTimeInput?: boolean;
timePickerIsUsed?: boolean;
oneClickDateSelection?: boolean;
minDate?: DateLike;
maxDate?: DateLike;
onDateChanged?: (date: Date, apply?: boolean) => void;
onDrawDay?: (cell: HTMLElement, date: Date) => void;
}

export abstract class Calendar {
protected currentDate: Date;
private selectedDate: Date;

protected slot: HTMLElement;

Expand All @@ -25,21 +30,62 @@ export abstract class Calendar {
if (!this.options.yearRange) {
this.options.yearRange = 'c-10:c+10';
}

if (!this.options.minDate) {
this.options.minDate = "none";
}

if (!this.options.maxDate) {
this.options.maxDate = "none";
}
}

public abstract render();

public abstract refresh();

public setDate(date: Date) {
this.currentDate = new Date(date);
this.selectedDate = new Date(date);
}

public getDate(): Date {
return new Date(this.currentDate);
return this.selectedDate;
}

protected dateChanged(apply?: boolean) {
if (this.options.onDateChanged) {
this.options.onDateChanged(this.currentDate, apply);
this.options.onDateChanged(this.selectedDate, apply);
}
}
}

export function dateLikeToDate(input: DateLike): Date | null {
let result: Date | null;

if (input == null || input === 'none') {
return null;
}

if (typeof input === 'string') {
if (input === 'today') {
result = new Date();
result.setHours(0, 0, 0, 0);
} else {
result = new Date(input);
result.setHours(0, 0, 0, 0);
}
}
else if (Array.isArray(input)) {
result = new Date(input[0], input[1] - 1, input[2]);
result.setHours(0, 0, 0, 0);
}
else {
if (input instanceof Date) {
result = new Date(input.getFullYear(), input.getMonth(), input.getDate());
result.setHours(0, 0, 0, 0);
} else {
result = null;
}
}
return result;
}
31 changes: 23 additions & 8 deletions easydata.js/packs/ui/src/datetimepicker/date_time_picker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DateTimePickerOptions } from './date_time_picker_options'
import { Calendar, CalendarOptions } from './calendar';
import { Calendar, CalendarOptions, dateLikeToDate } from './calendar';
import { TimePicker, TimePickerOptions } from './time_picker';

import { getElementAbsolutePos } from '../utils/ui-utils';
Expand All @@ -21,11 +21,17 @@ export abstract class DateTimePicker {
constructor(options?: DateTimePickerOptions) {
this.options = options;

const defaultDate = this.options.defaultDate
? dateLikeToDate(this.options.defaultDate)
: new Date();

this.setDateTime(defaultDate);

this.render();
}

public setDateTime(dateTime: Date) {
this.currentDateTime = new Date(dateTime);
this.currentDateTime = dateTime;

if (this.calendar) {
this.calendar.setDate(this.currentDateTime);
Expand All @@ -37,7 +43,7 @@ export abstract class DateTimePicker {
}

public getDateTime(): Date {
return new Date(this.currentDateTime);
return this.currentDateTime;
}

protected render() {
Expand All @@ -46,6 +52,8 @@ export abstract class DateTimePicker {
yearRange: this.options.yearRange,
showDateTimeInput: this.options.showDateTimeInput,
timePickerIsUsed: this.options.showTimePicker,
minDate: this.options.minDate,
maxDate: this.options.maxDate,
oneClickDateSelection: this.options.oneClickDateSelection,
onDateChanged: (date, apply) => {
this.currentDateTime = date;
Expand All @@ -63,8 +71,10 @@ export abstract class DateTimePicker {
}
});

if (this.calendar)
if (this.calendar) {
this.calendar.setDate(this.currentDateTime);
this.calendar.render();
}
}

if (this.options.showTimePicker) {
Expand All @@ -84,8 +94,15 @@ export abstract class DateTimePicker {
if (this.timePicker)
this.timePicker.render();
}
}

this.setDateTime(new Date());
public refresh() {
if (this.calendar) {
this.calendar.refresh();
}
if (this.timePicker) {
this.timePicker.refresh();
}
}

protected createCalendar(options: CalendarOptions): Calendar {
Expand Down Expand Up @@ -123,9 +140,7 @@ export abstract class DateTimePicker {
}

protected destroy() {
if (this.slot && this.slot.parentElement) {
this.slot.parentElement.removeChild(this.slot);
}
this.slot.innerHTML = '';
}

protected dateTimeChanged() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { DateLike } from "./calendar";

export interface DateTimePickerOptions {
yearRange?: string;
showTimePicker?: boolean;
showCalendar?: boolean;
oneClickDateSelection?: boolean;
showDateTimeInput?: boolean;
zIndex?: number;
minDate?: DateLike;
maxDate?: DateLike;
defaultDate?: DateLike;
beforeShow?: () => void;
onApply?: (dateTime: Date) => void;
onCancel?: () => void;
Expand Down
Loading
Loading