mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00

We want webpack's uglification to mangle function and class names but that's what the current implementation of the CSS in {N} relys on to get the CSS type for each view when targeted by CSS type selectors. The implementation is changed a little so now the CSS type can be set directly on the prototype of each View class or for TS, through decorator. BREAKING CHANGES: Extending classes requires marking the derived class with @CSSType The root classes are not marked with CSSType and classes derived from ViewBase and View will continue to work as expected. More concrete view classes (Button, Label, etc.) are marked with @CSSType now and store their cssType on the prototype suppressing the previous implementation that looked up the class function name. So clien classes that derive from one of our @CSSType decorated classes will now have to be marked with @CSSType.
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import { DatePicker as DatePickerDefinition } from ".";
|
|
import { View, Property, CSSType } from "../core/view";
|
|
|
|
export * from "../core/view";
|
|
|
|
const defaultDate = new Date();
|
|
const dateComparer = (x: Date, y: Date): boolean => (x <= y && x >= y);
|
|
|
|
@CSSType("DatePicker")
|
|
export class DatePickerBase extends View implements DatePickerDefinition {
|
|
public year: number;
|
|
public month: number;
|
|
public day: number;
|
|
public maxDate: Date;
|
|
public minDate: Date;
|
|
public date: Date;
|
|
}
|
|
|
|
DatePickerBase.prototype.recycleNativeView = "auto";
|
|
|
|
export const yearProperty = new Property<DatePickerBase, number>({
|
|
name: "year",
|
|
defaultValue: defaultDate.getFullYear(),
|
|
valueConverter: v => parseInt(v),
|
|
});
|
|
yearProperty.register(DatePickerBase);
|
|
|
|
export const monthProperty = new Property<DatePickerBase, number>({
|
|
name: "month",
|
|
defaultValue: defaultDate.getMonth() + 1,
|
|
valueConverter: v => parseInt(v),
|
|
});
|
|
monthProperty.register(DatePickerBase);
|
|
|
|
export const dayProperty = new Property<DatePickerBase, number>({
|
|
name: "day",
|
|
defaultValue: defaultDate.getDate(),
|
|
valueConverter: v => parseInt(v),
|
|
});
|
|
dayProperty.register(DatePickerBase);
|
|
|
|
// TODO: Make CoercibleProperties
|
|
export const maxDateProperty = new Property<DatePickerBase, Date>({
|
|
name: "maxDate",
|
|
equalityComparer: dateComparer,
|
|
valueConverter: v => new Date(v),
|
|
});
|
|
maxDateProperty.register(DatePickerBase);
|
|
|
|
export const minDateProperty = new Property<DatePickerBase, Date>({
|
|
name: "minDate",
|
|
equalityComparer: dateComparer,
|
|
valueConverter: v => new Date(v),
|
|
});
|
|
minDateProperty.register(DatePickerBase);
|
|
|
|
export const dateProperty = new Property<DatePickerBase, Date>({
|
|
name: "date",
|
|
defaultValue: defaultDate,
|
|
equalityComparer: dateComparer,
|
|
valueConverter: v => new Date(v),
|
|
});
|
|
dateProperty.register(DatePickerBase);
|