Skip to content

Added Date time picker component in react vanilla components#175

Open
armaang1729 wants to merge 1 commit into
mainfrom
dateTimeInput
Open

Added Date time picker component in react vanilla components#175
armaang1729 wants to merge 1 commit into
mainfrom
dateTimeInput

Conversation

@armaang1729

Copy link
Copy Markdown
Collaborator

Description

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@iamsudhanshu iamsudhanshu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for adding this! The component is in good shape overall — value normalization for datetime-local, min/max, disabled, and aria wiring are all handled, with broad test coverage. A few items worth addressing (only #1 is blocking):

1. Test failure — wrong BEM class in the "tooltip and description toggle" test

__tests__/components/DateTimeInput.test.tsx:156

The test looks up cmp-adaptiveform-datetimeinput__questionmark, but the component passes bemBlock='cmp-adaptiveform-datetime', so Label renders cmp-adaptiveform-datetime__questionmark. The lookup returns an empty collection, button[0] is undefined, and userEvent.click(undefined) throws — this test will fail in CI. Change the class to cmp-adaptiveform-datetime__questionmark.

2. DOM diverges from the Core datetime.html — missing __input-wrapper

src/components/DateTimeInput.tsx:72

The Core Date Time component wraps the widget in <div class="cmp-adaptiveform-datetime__input-wrapper">, but here the <input> is a direct child of FieldWrapper. Since the intent is parity with the Core datetime component's BEM/DOM, please wrap the input in __input-wrapper so the headless DOM matches the Core markup/CSS contract.

3. data-cmp-is casing mismatch

src/components/DateTimeInput.tsx:57

It's set to data-cmp-is="adaptiveFormdatetime", but the Core component (datetime.html and the clientlib static IS) uses adaptiveFormDatetime (capital D).

4. Stray demo mapping key

src/utils/mappings.ts:51

'forms-components-examples/components/form/datetime': DateTimeInput maps an examples/demo resourceType rather than the Core resourceType (core/fd/components/form/datetime/v1/datetime). This looks like local-testing leftover — please remove it or replace it with the Core resourceType.

5. Unrelated change in a shared file

src/utils/withRuleEngine.tsx

The enumNames/EnumName typing refactor is behavior-preserving but unrelated to the datetime component, and there's no accompanying af-core version bump in this PR. Consider splitting it into its own PR to keep this change focused and avoid churn in a shared file.

@@ -0,0 +1,98 @@
// *******************************************************************************
// * Copyright 2023 Adobe

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2026

const enumNames = state?.enumNames || [];
return enumNames.map((item: EnumName | string, index: number) => {
const EnumName = typeof item === 'object' ? item.value : item;
return enumNames.map((item: EnumNameItem, index: number) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why was this changed for date time??

'number-input': NumberField,
'date-input': DateInput,
'datetime-input': DateTimeInput,
'forms-components-examples/components/form/datetime': DateTimeInput,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

forms-components-examples/components/form/datetime' will not come. remove it

import sanitizeHTML from 'sanitize-html';
import { FieldViewState } from './type';

/** Legacy rich-text enum option shape; af-core 0.22.175+ types enumNames as string[] only. */

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

incorrect

@sakshi-arora1

Copy link
Copy Markdown

@armaang1729 Kindly incorporate the review comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants