forked from appsmithorg/appsmith
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add wds datepicker widget (appsmithorg#37711)
![CleanShot 2024-11-26 at 15 56 15](https://github.com/user-attachments/assets/d812f475-11e1-4750-9018-bdd39d5a5de3) /ok-to-test tags="@tag.Anvil" <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Introduced the WDS Date Picker Widget, enhancing date selection capabilities within the UI. - Added configuration options for widget size, visibility, and autocomplete behavior. - Implemented comprehensive validation for date input, ensuring accurate user selections. - Expanded widget collection to include the new WDS Date Picker Widget. - Introduced new constants for date format options, facilitating diverse formatting choices. - Added support for a new "Date" input type, enhancing input widget configurability. - **Documentation** - Updated property pane configurations to include detailed settings for date format, validation, and event handling. - **Bug Fixes** - Improved handling of derived properties to ensure proper context during widget interactions. These updates collectively improve user experience and flexibility in date selection within the application. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/12083004714> > Commit: b17348e > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12083004714&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Anvil` > Spec: > <hr>Fri, 29 Nov 2024 10:44:39 UTC <!-- end of auto-generated comment: Cypress test results --> --------- Co-authored-by: Vadim Vaitenko <vadim@appsmith.com>
- Loading branch information
Showing
24 changed files
with
716 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/modules/ui-builder/ui/wds/WDSDatePickerWidget/config/anvilConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
}, | ||
}; |
11 changes: 11 additions & 0 deletions
11
src/modules/ui-builder/ui/wds/WDSDatePickerWidget/config/autocompleteConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}; |
20 changes: 20 additions & 0 deletions
20
src/modules/ui-builder/ui/wds/WDSDatePickerWidget/config/defaultsConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
7 changes: 7 additions & 0 deletions
7
src/modules/ui-builder/ui/wds/WDSDatePickerWidget/config/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
21 changes: 21 additions & 0 deletions
21
src/modules/ui-builder/ui/wds/WDSDatePickerWidget/config/metaConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
"day", | ||
"hour", | ||
"meeting", | ||
"moment", | ||
"schedule", | ||
"time", | ||
"week", | ||
"year", | ||
], | ||
}; |
6 changes: 6 additions & 0 deletions
6
src/modules/ui-builder/ui/wds/WDSDatePickerWidget/config/methodsConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |
191 changes: 191 additions & 0 deletions
191
src/modules/ui-builder/ui/wds/WDSDatePickerWidget/config/propertyPaneConfig/contentConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }, | ||
}, | ||
], | ||
}, | ||
{ | ||
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, | ||
}, | ||
], | ||
}, | ||
] as PropertyPaneConfig[]; |
1 change: 1 addition & 0 deletions
1
src/modules/ui-builder/ui/wds/WDSDatePickerWidget/config/propertyPaneConfig/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { propertyPaneContentConfig } from "./contentConfig"; |
12 changes: 12 additions & 0 deletions
12
src/modules/ui-builder/ui/wds/WDSDatePickerWidget/config/settersConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
}, | ||
}; |
Oops, something went wrong.