Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add wds datepicker widget #37711

Merged
merged 6 commits into from
Nov 29, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
}

.calendar tbody [role="button"][data-focus-visible] {
outline: var(--border-width-2) solid var(--color-bd-accent);
outline-offset: var(--border-width-2);
--box-shadow-offset: 2px;

box-shadow:
0 0 0 var(--box-shadow-offset) var(--color-bg),
0 0 0 calc(var(--box-shadow-offset) + var(--border-width-2))
var(--color-bd-focus);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const INPUT_TYPES = {
PASSWORD: "PASSWORD",
PHONE_NUMBER: "PHONE_NUMBER",
MULTI_LINE_TEXT: "MULTI_LINE_TEXT",
DATE: "DATE",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the drop, date picker widget has an empty Data type. Could you please fix this?

Снимок экрана 2024-11-29 в 11 38 37

} as const;

export const INPUT_TYPE_TO_WIDGET_TYPE_MAP = {
Expand All @@ -16,4 +17,5 @@ export const INPUT_TYPE_TO_WIDGET_TYPE_MAP = {
[INPUT_TYPES.MULTI_LINE_TEXT]: "WDS_MULTILINE_INPUT_WIDGET",
[INPUT_TYPES.CURRENCY]: "WDS_CURRENCY_INPUT_WIDGET",
[INPUT_TYPES.PHONE_NUMBER]: "WDS_PHONE_INPUT_WIDGET",
[INPUT_TYPES.DATE]: "WDS_DATEPICKER_WIDGET",
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { WDSBaseInputWidget } from "modules/ui-builder/ui/wds/WDSBaseInputWidget";
import {
INPUT_TYPES,
WDSBaseInputWidget,
} from "modules/ui-builder/ui/wds/WDSBaseInputWidget";
import { ResponsiveBehavior } from "layoutSystems/common/utils/constants";
import type { WidgetDefaultProps } from "WidgetProvider/constants";

Expand All @@ -14,4 +17,5 @@ export const defaultsConfig = {
showStepArrows: false,
label: "Current Price",
responsiveBehavior: ResponsiveBehavior.Fill,
inputType: INPUT_TYPES.CURRENCY,
} as WidgetDefaultProps;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { AnvilConfig } from "WidgetProvider/constants";

export const anvilConfig: AnvilConfig = {
isLargeWidget: false,
widgetSize: {
minWidth: {
base: "100%",
"180px": "sizing-30",
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { DefaultAutocompleteDefinitions } from "widgets/WidgetUtils";

export const autocompleteConfig = {
"!doc":
"Datepicker is used to capture the date and time from a user. It can be used to filter data base on the input date range as well as to capture personal information such as date of birth",
"!url": "https://docs.appsmith.com/widget-reference/datepicker",
isVisible: DefaultAutocompleteDefinitions.isVisible,
selectedDate: "string",
formattedDate: "string",
isDisabled: "bool",
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ResponsiveBehavior } from "layoutSystems/common/utils/constants";
import type { WidgetDefaultProps } from "WidgetProvider/constants";
import { INPUT_TYPES } from "modules/ui-builder/ui/wds/WDSBaseInputWidget";

export const defaultsConfig = {
animateLoading: true,
label: "Label",
dateFormat: "YYYY-MM-DD HH:mm",
defaultOptionValue: "",
isRequired: false,
isDisabled: false,
isVisible: true,
isInline: false,
widgetName: "DatePicker",
widgetType: "WDS_DATE_PICKER",
version: 1,
timePrecision: "day",
responsiveBehavior: ResponsiveBehavior.Fill,
inputType: INPUT_TYPES.DATE,
} as unknown as WidgetDefaultProps;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export * from "./propertyPaneConfig";
export { metaConfig } from "./metaConfig";
export { anvilConfig } from "./anvilConfig";
export { defaultsConfig } from "./defaultsConfig";
export { settersConfig } from "./settersConfig";
export { methodsConfig } from "./methodsConfig";
export { autocompleteConfig } from "./autocompleteConfig";
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { WIDGET_TAGS } from "constants/WidgetConstants";

export const metaConfig = {
name: "DatePicker",
tags: [WIDGET_TAGS.INPUTS],
needsMeta: true,
searchTags: [
"datepicker",
"appointment",
"calendar",
"date",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ichik Could you check this please?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ichik Could you check this please?

@KelvinOm @jsartisan pushed an update to metaconfig.

"day",
"hour",
"meeting",
"moment",
"schedule",
"time",
"week",
"year",
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { DatePickerIcon, DatePickerThumbnail } from "appsmith-icons";

export const methodsConfig = {
IconCmp: DatePickerIcon,
ThumbnailCmp: DatePickerThumbnail,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
import { ValidationTypes } from "constants/WidgetValidation";
import { DATE_FORMAT_OPTIONS } from "../../constants";

import { propertyPaneContentConfig as WdsInputWidgetPropertyPaneContentConfig } from "modules/ui-builder/ui/wds/WDSInputWidget/config/propertyPaneConfig/contentConfig";
import type { PropertyPaneConfig } from "constants/PropertyControlConstants";

const inputTypeSectionConfig = WdsInputWidgetPropertyPaneContentConfig.find(
(config) => config.sectionName === "Type",
);

export const propertyPaneContentConfig = [
inputTypeSectionConfig,
{
sectionName: "Data",
children: [
{
helpText: "Sets the format of the selected date",
propertyName: "dateFormat",
label: "Date format",
controlType: "DROP_DOWN",
isJSConvertible: true,
optionWidth: "340px",
options: DATE_FORMAT_OPTIONS,
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.TEXT },
hideSubText: true,
},
{
propertyName: "defaultDate",
label: "Default Date",
helpText:
"Sets the default date of the widget. The date is updated if the default date changes",
controlType: "DATE_PICKER",
placeholderText: "Enter Default Date",
useValidationMessage: true,
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.DATE_ISO_STRING },
},
{
propertyName: "timePrecision",
label: "Time Precision",
controlType: "DROP_DOWN",
helpText: "Sets the time precision or hides the time picker.",
defaultValue: "day",
options: [
{
label: "Day",
value: "day",
},
{
label: "Hour",
value: "hour",
},
{
label: "Minute",
value: "minute",
},
{
label: "Second",
value: "second",
},
],
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: {
type: ValidationTypes.TEXT,
params: {
allowedValues: ["day", "hour", "minute", "second"],
default: "day",
},
},
},
],
},
{
sectionName: "Label",
children: [
{
helpText: "Sets the label text of the date picker widget",
propertyName: "label",
label: "Text",
controlType: "INPUT_TEXT",
placeholderText: "Label",
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.TEXT },
},
],
},
{
sectionName: "Validations",
children: [
{
propertyName: "isRequired",
label: "Required",
helpText: "Makes input to the widget mandatory",
controlType: "SWITCH",
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.BOOLEAN },
},
{
propertyName: "minDate",
label: "Minimum Date",
helpText: "Sets the minimum date that can be selected",
controlType: "DATE_PICKER",
placeholderText: "Enter Minimum Date",
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.DATE_ISO_STRING },
},
{
propertyName: "maxDate",
label: "Maximum Date",
helpText: "Sets the maximum date that can be selected",
controlType: "DATE_PICKER",
placeholderText: "Enter Maximum Date",
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.DATE_ISO_STRING },
},
],
},
KelvinOm marked this conversation as resolved.
Show resolved Hide resolved
{
sectionName: "General",
children: [
{
helpText: "Shows help text or details about the current input",
propertyName: "labelTooltip",
label: "Tooltip",
controlType: "INPUT_TEXT",
placeholderText: "",
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.TEXT },
},
{
helpText: "Controls the visibility of the widget",
propertyName: "isVisible",
label: "Visible",
controlType: "SWITCH",
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.BOOLEAN },
},
{
propertyName: "isDisabled",
label: "Disabled",
helpText: "Disables input to this widget",
controlType: "SWITCH",
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.BOOLEAN },
},
{
propertyName: "animateLoading",
label: "Animate loading",
controlType: "SWITCH",
helpText: "Controls the loading of the widget",
defaultValue: true,
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.BOOLEAN },
},
],
},
{
sectionName: "Events",
children: [
{
propertyName: "onDateSelected",
label: "onDateSelected",
helpText: "when a date is selected in the calendar",
controlType: "ACTION_SELECTOR",
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: true,
},
KelvinOm marked this conversation as resolved.
Show resolved Hide resolved
],
},
] as PropertyPaneConfig[];
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { propertyPaneContentConfig } from "./contentConfig";
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const settersConfig = {
__setters: {
setVisibility: {
path: "isVisible",
type: "boolean",
},
setDisabled: {
path: "isDisabled",
type: "boolean",
},
},
};
Loading
Loading