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: Calendar and DateTimePicker components #5002

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

mizgaionutalexandru
Copy link
Contributor

@mizgaionutalexandru mizgaionutalexandru commented Dec 24, 2024

Description

Calendar and DateTimePicker components with functionality for the initial release. More about each component can be seen in their documentation and storybook.

These components are currently the main ones that benefit from the Storybook locale picker, apart from NumberField. Therefore, this PR also includes the addition of said locale picker using chromatic globals.

Important

Since this is a fairly large PR, I strongly encourage checking out the internal RFC as well as the previous PR merged into the feature branch (see PR commits) before raising any concerns in the comments here, as not to bloat the PR. Thank you! 🙏

Related issue(s)

Motivation and context

How has this been tested?

  • Functionality is covered by unit tests
  • Layout can be compared with Spectrum CSS(Calendar and DateTimePicker). Multiple PRs along the way allowed VRTs to check the progress/changes

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)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.

paulodetarsofm and others added 18 commits December 13, 2024 13:16
* feat: add calendar

* feat: use first day of the week according to the locale

* feat: add "disabled" property

* feat: handle "Previous" and "Next" month buttons

* feat: add locale for all stories

* feat: add "min" and "max" date

* refactor: add new render methods

* feat: format day using Intl.NumberFormat

* fix: lit-plugin "no-incompatible-property-type"

* The built in converter doesn't handle the property type Date | undefined

* fix: packages version + property type error

* refactor: add to-do list to README

* feat: add event handlers and slots for icons

* refactor(calendar): update dependencies

* refactor(calendar): changing Lit resource import source

* refactor: add comments and use correct formatters

* refactor: convert property `_locale` to a getter

* refactor: remove `_` from private properties and methods

* refactor: remove unnecessary method

* refactor: remove unnecessary template checking

* refactor: add new private properties

* refactor: code improvements, new comments

* refactor: remove reflect from properties they don't need

* fix: add new package to tsconfig.json

* refactor: use same version of `@internationalized/number` used by other components

* refactor(calendar): improvements and new TODOs
* feat: add input segments

* refactor: input segments improvements

* fix(textfield): convert pseudo :read-only to attribute

* feat(time-field): add new time field component

* refactor: remove `_` from private properties and methods and convert property `locale` to a getter

* refactor: add new `@internationalized/number` package

* refactor: reduce cognitive complexity for `handleTypedValue()` method

* "Refactor this function to reduce its Cognitive Complexity from 41 to the 15 allowed." (SonarLint)

* refactor: reduce cognitive complexity for `handleClear()` method

* "Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed." (SonarLint)

* refactor: reduce cognitive complexity for `setNewDateTime()` method

* "Refactor this function to reduce its Cognitive Complexity from 30 to the 15 allowed." (SonarLint)

* refactor: add correct placeholder for year

* refactor: reduce cognitive complexity for `getSegmentValueAndLimits()` method

* "Refactor this function to reduce its Cognitive Complexity from 34 to the 15 allowed." (SonarLint)

* refactor: reduce cognitive complexity for `updateHour()` method

* "Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed." (SonarLint)

* refactor: add missing comments and minor code improvements

* refactor: preserve white spaces inside literal segments

* refactor: add types to variables

* refactor: formatting year

* refactor: increment/decrement year when is `undefined`

* feat: add logic to update day if needed

* fix: improve logic to update the day

* fix: package version

* fix: add missing references

* refactor: maintain alphabetical order

* fix: duplicate identifier 'ClassInfo'

* refactor: upgrade `@internationalized/date` package version used by the calendar

* refactor: minor code improvements and comments

* refactor: add new items to to-do list

* refactor: add missing "time-field" entry

* refactor: update packages version

* refactor: use `import type` when possible

* refactor: remove unnecessary configuration

* refactor: remove unnecessary code

* refactor: code and comments improvements

* refactor: remove unused files

* refactor: update `@spectrum-css/calendar`

* refactor: move `input-segments` from `/packages` to `/tools`

* fix: segment text colour

* refactor(calendar): remove unnecessary code
* feat: add input segments + time field (#3464)

* feat: add input segments

* refactor: input segments improvements

* refactor: remove `_` from private properties and methods and convert property `locale` to a getter

* refactor: add new `@internationalized/number` package

* refactor: reduce cognitive complexity for `handleTypedValue()` method

* "Refactor this function to reduce its Cognitive Complexity from 41 to the 15 allowed." (SonarLint)

* refactor: reduce cognitive complexity for `handleClear()` method

* "Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed." (SonarLint)

* refactor: reduce cognitive complexity for `setNewDateTime()` method

* "Refactor this function to reduce its Cognitive Complexity from 30 to the 15 allowed." (SonarLint)

* refactor: add correct placeholder for year

* refactor: reduce cognitive complexity for `getSegmentValueAndLimits()` method

* "Refactor this function to reduce its Cognitive Complexity from 34 to the 15 allowed." (SonarLint)

* refactor: reduce cognitive complexity for `updateHour()` method

* "Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed." (SonarLint)

* refactor: add missing comments and minor code improvements

* refactor: preserve white spaces inside literal segments

* refactor: add types to variables

* refactor: formatting year

* refactor: increment/decrement year when is `undefined`

* feat: add logic to update day if needed

* fix: improve logic to update the day

* fix: package version

* fix: add missing references

* refactor: maintain alphabetical order

* fix: duplicate identifier 'ClassInfo'

* refactor: upgrade `@internationalized/date` package version used by the calendar

* refactor: minor code improvements and comments

* refactor: add new items to to-do list

* refactor: add missing "time-field" entry

* refactor: update packages version

* refactor: use `import type` when possible

* refactor: remove unnecessary configuration

* refactor: remove unnecessary code

* refactor: code and comments improvements

* refactor: remove unused files

* refactor: update `@spectrum-css/calendar`

* refactor: move `input-segments` from `/packages` to `/tools`

* fix: segment text colour

* feat: add calendar

* feat: use first day of the week according to the locale

* feat: add "disabled" property

* feat: handle "Previous" and "Next" month buttons

* feat: add locale for all stories

* feat: add "min" and "max" date

* refactor: add new render methods

* feat: format day using Intl.NumberFormat

* fix: lit-plugin "no-incompatible-property-type"

* The built in converter doesn't handle the property type Date | undefined

* fix: packages version + property type error

* refactor: add to-do list to README

* feat: add event handlers and slots for icons

* refactor: add comments and use correct formatters

* refactor: convert property `_locale` to a getter

* refactor: remove `_` from private properties and methods

* refactor: remove unnecessary method

* refactor: remove unnecessary template checking

* refactor: add new private properties

* refactor: code improvements, new comments

* refactor: remove reflect from properties they don't need

* fix: add new package to tsconfig.json

* refactor: use same version of `@internationalized/number` used by other components

* refactor: calendar improvements

* feat: add input segments

* refactor: input segments improvements

* refactor: remove `_` from private properties and methods and convert property `locale` to a getter

* refactor: add new `@internationalized/number` package

* refactor: reduce cognitive complexity for `handleTypedValue()` method

* "Refactor this function to reduce its Cognitive Complexity from 41 to the 15 allowed." (SonarLint)

* refactor: reduce cognitive complexity for `handleClear()` method

* "Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed." (SonarLint)

* refactor: reduce cognitive complexity for `setNewDateTime()` method

* "Refactor this function to reduce its Cognitive Complexity from 30 to the 15 allowed." (SonarLint)

* refactor: add correct placeholder for year

* refactor: reduce cognitive complexity for `getSegmentValueAndLimits()` method

* "Refactor this function to reduce its Cognitive Complexity from 34 to the 15 allowed." (SonarLint)

* refactor: reduce cognitive complexity for `updateHour()` method

* "Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed." (SonarLint)

* refactor: add missing comments and minor code improvements

* refactor: preserve white spaces inside literal segments

* refactor: add types to variables

* refactor: formatting year

* refactor: increment/decrement year when is `undefined`

* feat: add logic to update day if needed

* fix: improve logic to update the day

* fix: package version

* fix: add missing references

* refactor: maintain alphabetical order

* fix: duplicate identifier 'ClassInfo'

* refactor: upgrade `@internationalized/date` package version used by the calendar

* refactor: minor code improvements and comments

* refactor: add new items to to-do list

* refactor: add missing "time-field" entry

* refactor: update packages version

* refactor: use `import type` when possible

* refactor: remove unnecessary configuration

* refactor: remove unnecessary code

* refactor: code and comments improvements

* refactor: remove unused files

* refactor: update `@spectrum-css/calendar`

* refactor: move `input-segments` from `/packages` to `/tools`

* fix: segment text colour

* refactor: remove time field

* refactor: move locales to be used globally

* fix: picker button import

* refactor: use `beforeinput` and `input` events

* feat: add `date-time-picker` component

* fix: use innerText to render segment text

* fix: dealing with days and hours

* fix: fix quiet variant styles

* fix: add calculation to count the width of the date/time picker

* refactor: removes solved TODO's points

* refactor: removes broken unit test

* refactor: adds unit test for default datetime picker

* refactor: unit tests for date-time-picker

* refactor: fixes input line height

* chore: bump packages to 0.41.2

* refactor: feedback implementation v1

* refactor: mock slected date for timeGlanularity story

* refactor: adds unit test to calendar

* refactor: update naming

* refactor: adds unit test for handleDayClick method

* refactor: update TODO list

* fix: create new segments when granularity is changed

* fix: renaming attribute from `locale` to `lang`

* refactor: use "quiet" variant of `sp-picker-button` when input is read-only

* refactor: remove unused imports

* refactor: enable "valid" and "invalid" attributes for all stories

* refactor: italicised placeholders for non-CJK languages

* refactor: date/time picker width definition

* chore: bump packages to 0.41.2

* refactor: add comment about use of `.innerText`

* refactor: reduce cognitive complexity

* refactor: calendar improvements + unit tests

* refactor: invalid picker button styles

* chore: bump packages to 0.41.2

* refactor: small code improvements

* chore: fix test imports

* chore: update golden img hash

* chore: update golden img hash

---------

Co-authored-by: Paulo de Tarso Furtado Machado <[email protected]>
Co-authored-by: Mirek Szot <[email protected]>
Co-authored-by: Mizga Ionut-Alexandru <[email protected]>
* feat(calendar): keyboard navigation

* fix: focus on disabled dates

* refactor: storybook absolute Dates for VRTs

* chore: update golden img hash

* fix(calendar): focusable day management when changing months
…4726)

* feat(calendar): keyboard navigation

* fix: focus on disabled dates

* refactor: storybook absolute Dates for VRTs

* chore: update golden img hash

* fix(calendar): focusable day management when changing months

* feat(calendar): new value API

* fix: story decorator locale picker lang resolver

* perf(calendar): run getDatesInWeek only when needed

* chore: rebase fix

* refactor: remove textfield and inputsegments from DTP inheritance chain

* style(date-time-picker): style fixing

* fix(calendar): weeks in current month number updates

* fix(calendar): preselected value not changing current month dates

* feat(date-time-picker): update value API and granularity

* fix(date-time-picker): value updates controller with precision

* fix(date-time-picker): date type coming from calendar

* test(date-time-picker): added tests structure

* chore(date-time-picker): type changes

* test(date-time-picker): value changes on arrow key up

* test(date-time-picker): value changes on arrow key down

* feat(date-time-picker): clear method

* feat(calendar): clear method

* test(date-time-picker): typed in values partially

* chore: remove LanguageResolution change

* chore: remove lit direct dep

* test: added tests for changing the segments using typed in values

* test: added tests for deleting the segments' value

* fix(calendar): fixed navigation using prev/next month buttons

* fix(calendar): fixed navigation using prev/next month buttons

* fix(date-time-picker): check values compliance

* test(date-time-picker): multiple types management for values

* fix(date-time-picker): fixed storybook precision not applying

* test(date-time-picker): test structure for events

* refactor(date-time-picker): extract helpers

* refactor(date-time-picker): added SegmentsFactory

* refactor(date-time-picker): added SegmentsModifier

* refactor(date-time-picker): added SegmentsFormatter and initial usage

* fix(date-time-picker): fixed 12h hour conversion

* refactor(date-time-picker): moved segment formatting to SegmentsModifier

* refactor(date-time-picker): added Clear and Input segment modifiers

* refactor(date-time-picker): localized support for dayPeriod typed in values

* refactor(date-time-picker): created segments wrapper

* refactor(date-time-picker): cleanup

* refactor(date-time-picker): moved get date from segments to DateTimeSegments

* chore: improved dates compliance check readability

* chore: small improvements

* test(date-time-picker): fix failing tests

---------

Co-authored-by: Mizga Ionut-Alexandru <[email protected]>
* fix(date-time-picker): fixed value clearing

* test(calendar): extracted test helpers

* fix: clear value when interval is changed and value is non compliant

* fix(date-time-picker): zonedDateTime edge-cases

* test(date-time-picker): added calendar management tests

* test(date-time-picker): added tests for value type when segments are set/change

* test: improved readability

* feat(date-time-picker): precision and date value props interactions

* test: fixed mouse coord. float

* style: fix second precision with invalid style

* style: fix large theme

* chore: added clarifying comment
* test(date-time-picker): added tests for input/change events and invalid triggering

* feat(date-time-picker): change and input events

* feat(date-time-picker): invalid triggering

* fix(date-time-picker): no more invalid on fully empty dtp

* refactor: improved readability

* chore: version bump

* test: fixed failing tests

* chore: update golden img hash
* fix(calendar): display the current month when the value is deleted

* fix(date-time-picker): 2-digit year misformatting

* test(date-time-picker): current date independence

* test(calendar): added limits for gregorian AD era

* fix(calendar): gregorian AD limits

* fix(date-time-picker): year deletion on safari

* test(date-time-picker): added localization tests

* fix(date-time-picker): localized formatting

* fix(date-time-picker): multiple small ux fixes

* test(calendar): initial month tests when today doesnt comply

* fix(calendar): initial month displayed

* chore: update golden img hash
* fix: update segment digits overflow

* style: uncomment webkit prefix

* refactor(calendar): extract updateCurrentDate method

* test(date-time-picker): added focus tests

* fix(date-time-picker): focus trap on calendar open

* feat(date-time-picker): change segments focus on empty delete

* test(date-time-picker): created expectFocused helper

* test(date-time-picker): added disabled tests

* test(calendar): added disabled and localized tests

* docs: allow value overrides in storybook

* test(calendar): added clear method test

* test(date-time-picker): added calendar close when disabled changes test

* chore: organize imports

* chore: build

* fix(date-time-picker): mobile text inputMode on dayPeriod segment

* chore: golden img hash update
* refactor(calendar): clarify navigation methods naming

* feat(calendar): screen reader labels

* feat(calendar): labels prop

* test(calendar): query fixes

* feat(date-time-picker): intl segment labels and min-max value aria

* feat(date-time-picker): labels prop

* feat(date-time-picker): selected value/empty announce on focus

* ci: update golden image hash

* fix: update selectedDateLabel

* ci: update golden image hash

* docs(date-time-picker): added labels in stories
#5001)

* docs(calendar): updated docs

* docs(date-time-picker): updated docs

* chore: remove duplicate DateValue declaration

* docs: added clear selected stories

* docs(date-time-picker): custom precision story

* chore: comments cleanup

* chore: import fixes

* docs: addressed comms

* docs: updated chromatic settings to include locale picker

* chore: remove unnecessary types

* test(date-time-picker): update arrow-left test
Copy link

changeset-bot bot commented Dec 24, 2024

⚠️ No Changeset found

Latest commit: 32802e5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

Branch preview

Review the following VRT differences

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

@coveralls
Copy link
Collaborator

coveralls commented Dec 24, 2024

Pull Request Test Coverage Report for Build 12479463131

Details

  • 2878 of 2891 (99.55%) changed or added relevant lines in 26 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 98.259%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/date-time-picker/src/segments/SegmentsFactory.ts 147 148 99.32%
packages/date-time-picker/src/segments/time/DayPeriodSegment.ts 83 84 98.81%
packages/calendar/src/Calendar.ts 753 756 99.6%
packages/date-time-picker/src/segments/modifiers/SegmentsModifier.ts 64 72 88.89%
Totals Coverage Status
Change from base Build 12278981558: 0.05%
Covered Lines: 35918
Relevant Lines: 36355

💛 - Coveralls

Copy link

github-actions bot commented Dec 24, 2024

Lighthouse scores

Category Latest (report) Main (report) Branch (report)
Performance 0.99 0.99 0.99
Accessibility 1 1 1
Best Practices 1 1 1
SEO 1 0.92 0.92
PWA 1 1 1
What is this?

Lighthouse scores comparing the documentation site built from the PR ("Branch") to that of the production documentation site ("Latest") and the build currently on main ("Main"). Higher scores are better, but note that the SEO scores on Netlify URLs are artifically constrained to 0.92.

Transfer Size

Category Latest Main Branch
Total 250.337 kB 236.903 kB 236.786 kB 🏆
Scripts 60.311 kB 54.456 kB 54.224 kB 🏆
Stylesheet 53.86 kB 47.985 kB 🏆 48.043 kB
Document 6.227 kB 5.485 kB 🏆 5.51 kB
Font 126.981 kB 126.624 kB 🏆 126.633 kB

Request Count

Category Latest Main Branch
Total 52 52 52
Scripts 41 41 41
Stylesheet 5 5 5
Document 1 1 1
Font 2 2 2

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.

4 participants