react-antd-admin-panel
Version:
Modern TypeScript-first React admin panel builder with Ant Design 6
133 lines • 3.46 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { DatePicker as AntDatePicker } from 'antd';
import { FormFieldBuilder } from '../base/FormFieldBuilder';
/**
* DatePicker Field Builder
* Wrapper for Ant Design DatePicker component with dayjs
*/
export class DatePicker extends FormFieldBuilder {
/**
* Set date format
*/
format(fmt) {
this._config.format = fmt;
return this;
}
/**
* Enable time selection
*/
showTime(value = true) {
this._config.showTime = value;
return this;
}
/**
* Show today button
*/
showToday(value = true) {
this._config.showToday = value;
return this;
}
/**
* Set picker type (date, week, month, quarter, year)
*/
picker(type) {
this._config.picker = type;
return this;
}
/**
* Set function to disable specific dates
*/
disabledDate(fn) {
this._config.disabledDate = fn;
return this;
}
/**
* Enable clear button
*/
allowClear(value = true) {
this._config.allowClear = value;
return this;
}
/**
* Render the date picker component
*/
render() {
if (this._config.hidden) {
return null;
}
const props = {
placeholder: this._config.placeholder,
disabled: this._config.disabled,
format: this._config.format,
showTime: this._config.showTime,
showToday: this._config.showToday,
picker: this._config.picker,
disabledDate: this._config.disabledDate,
allowClear: this._config.allowClear,
onChange: (date) => this.handleChange(date),
};
return this.wrapWithLabel(_jsx(AntDatePicker, { ...props }));
}
}
/**
* RangePicker Field Builder
* Wrapper for Ant Design RangePicker component
*/
export class RangePicker extends FormFieldBuilder {
/**
* Set date format
*/
format(fmt) {
this._config.format = fmt;
return this;
}
/**
* Enable time selection
*/
showTime(value = true) {
this._config.showTime = value;
return this;
}
/**
* Set picker type (date, week, month, quarter, year)
*/
picker(type) {
this._config.picker = type;
return this;
}
/**
* Set function to disable specific dates
*/
disabledDate(fn) {
this._config.disabledDate = fn;
return this;
}
/**
* Enable clear button
*/
allowClear(value = true) {
this._config.allowClear = value;
return this;
}
/**
* Render the range picker component
*/
render() {
if (this._config.hidden) {
return null;
}
const props = {
placeholder: this._config.placeholder ? [this._config.placeholder, this._config.placeholder] : undefined,
disabled: this._config.disabled,
format: this._config.format,
showTime: this._config.showTime,
picker: this._config.picker,
disabledDate: this._config.disabledDate,
allowClear: this._config.allowClear,
value: this._value,
onChange: (dates) => this.handleChange(dates),
};
return _jsx(AntDatePicker.RangePicker, { ...props }, this._key);
}
}
//# sourceMappingURL=DatePicker.js.map