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

Feat: Implements #297 request #4004

Merged
merged 9 commits into from
Jan 7, 2024

Conversation

Shubhcoder
Copy link
Contributor

@Shubhcoder Shubhcoder commented Dec 12, 2023

Reasons for making this change

I have added the code (with tests) to implement the feature requested in #297. Also, I have refactored the duplicate (non-React component) based function down into @rjsf/utils under the file name getDateElementProps.ts.

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

Copy link
Member

@heath-freenome heath-freenome left a comment

Choose a reason for hiding this comment

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

@Shubhcoder Thanks for doing this! Can you update the CHANGELOG.md file as well with a description of this feature? I would expect to see sections for @rjsf/antd, @rjsf/chakra-ui, @rjsf/core and a Dev / Docs / Playground section.

value: number | undefined;
};

export default function getDateElementProps(
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add documentation to this function as well as replicating that documentation into the official RJSF online documentation found here packages/docs/docs/api-reference/utility-functions.md

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @heath-freenome

I have updated my PR with the required changes.

@heath-freenome
Copy link
Member

heath-freenome commented Jan 5, 2024

@Shubhcoder Your new tests seem to be failing. Is it because we are in a new year? Can you please investigate?

@rjsf/utils:   ● getDateElementProps › returns date in 'DMY' format with time when format is not specified
@rjsf/utils:     expect(received).toEqual(expected) // deep equality
@rjsf/utils:     - Expected  - 1
@rjsf/utils:     + Received  + 1
@rjsf/utils:     @@ -16,11 +16,11 @@
@rjsf/utils:           "value": 10,
@rjsf/utils:         },
@rjsf/utils:         Object {
@rjsf/utils:           "range": Array [
@rjsf/utils:             1900,
@rjsf/utils:     -       2025,
@rjsf/utils:     +       2026,
@rjsf/utils:           ],
@rjsf/utils:           "type": "year",
@rjsf/utils:           "value": 2003,
@rjsf/utils:         },
@rjsf/utils:         Object {
@rjsf/utils: 
@rjsf/utils:       76 |     const prop = getDateElementProps(date, true, undefined, 'DMY');
@rjsf/utils:       77 |
@rjsf/utils:     > 78 |     expect(prop).toEqual([
@rjsf/utils:          |                  ^
@rjsf/utils:       79 |       { type: 'day', range: dayRange, value: date.day },
@rjsf/utils:       80 |       { type: 'month', range: monthRange, value: date.month },
@rjsf/utils:       81 |       { type: 'year', range: [1900, 2025], value: date.year },
@rjsf/utils: 
@rjsf/utils:       at Object.toEqual (test/getDateElementProps.test.ts:78:18)
@rjsf/utils: Test Suites: 1 failed, 55 passed, 56 total
@rjsf/utils: Tests:       3 failed, 642 passed, 645 total

@Shubhcoder Shubhcoder force-pushed the feature/dateReorder branch from f845385 to c18abc3 Compare January 7, 2024 05:53
@heath-freenome heath-freenome merged commit accbd16 into rjsf-team:main Jan 7, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants