Skip to content

feat(datepicker): add period-time mode with start/end time selection in 24h format#1158

Open
Copilot wants to merge 13 commits into
mainfrom
copilot/enhance-datepicker-with-time-selection
Open

feat(datepicker): add period-time mode with start/end time selection in 24h format#1158
Copilot wants to merge 13 commits into
mainfrom
copilot/enhance-datepicker-with-time-selection

Conversation

Copilot AI commented Apr 7, 2026

Copy link
Copy Markdown
Contributor
  • Understand all PR review comments
  • Make startTime/endTime non-optional states
  • Fix type cast in onInputStartTimeSelected/onInputEndTimeSelected
  • Add normalizeTime helper and normalize times before emitting concludeDatepicker
  • Fix Storybook useEffect memory leak
  • Add unit tests for formatTimeInput and normalizeTime
  • Standardize bdsStartDate/bdsEndDate event value format to dd/mm/yyyy
  • Fix double-emission: add event.stopPropagation() in selectDate/selectEndDate
  • Add FrameworkReactPeriodTime Storybook story showing all events with React wrapper

Copilot AI and others added 2 commits April 7, 2026 14:49
- Add 'period-time' to the typeDate union type
- Add startTime/endTime state (defaults 00:00 / 23:59)
- Render time inputs (clock icon) below the period calendar
- Include startTime/endTime in concludeDatepicker event payload
- Reset times on clearDate in period-time mode
- Add i18n keys (startTime/endTime) for pt_BR, es_ES, en_US
- Add CSS for .datepicker__menu__time-inputs two-column grid
- Update Storybook with period-time option and PeriodTime story
- Add unit tests for new period-time behaviour

Agent-Logs-Url: https://github.com/takenet/blip-ds/sessions/756881a0-87db-4325-9685-4c69f71a6b96

Co-authored-by: tuliorezende <6129653+tuliorezende@users.noreply.github.com>
…riod class condition

Agent-Logs-Url: https://github.com/takenet/blip-ds/sessions/756881a0-87db-4325-9685-4c69f71a6b96

Co-authored-by: tuliorezende <6129653+tuliorezende@users.noreply.github.com>
Copilot AI changed the title [WIP] Add time selection to datepicker component feat(datepicker): add period-time mode with start/end time selection Apr 7, 2026
Copilot AI requested a review from tuliorezende April 7, 2026 14:53
Copilot AI had a problem deploying to storybook-preview April 7, 2026 14:54 Failure
…hable comparison

- Add 'time' to InputType union in input-interface.ts
- Replace always-true comparison `this.typeOfDate !== 'single'` in else
  branch with literal `true` to silence TS error TS2367"

Agent-Logs-Url: https://github.com/takenet/blip-ds/sessions/4a6cb312-f9c7-479b-b206-ff1380d4db0d

Co-authored-by: tuliorezende <6129653+tuliorezende@users.noreply.github.com>
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://takenet.github.io/blip-ds/pr-preview/pr-1158/

Built to branch gh-pages at 2026-04-10 22:29 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Replace type='time' with type='text' + placeholder/pattern/maxlength
to force 24h format regardless of browser locale. Add formatTimeInput
helper that auto-inserts the colon separator as the user types."

Agent-Logs-Url: https://github.com/takenet/blip-ds/sessions/dade8390-2fd0-4215-a9f5-0858c3450c6a

Co-authored-by: tuliorezende <6129653+tuliorezende@users.noreply.github.com>
@tuliorezende

Copy link
Copy Markdown

@copilot
image

On the generated date fields I can't see the selected hours, only when I click in the box to select again

In period-time mode the 'De'/'Até' trigger inputs now display the
selected time alongside the date (e.g. '08/04/2026 09:00') by:
- switching their type to 'text' and marking them readonly
- computing value as typeDateToStringDate(date) + ' ' + time
so the display reacts whenever startTime/endTime state changes.

Agent-Logs-Url: https://github.com/takenet/blip-ds/sessions/634ad537-9b3a-47e0-8253-10b9401f4fa3

Co-authored-by: tuliorezende <6129653+tuliorezende@users.noreply.github.com>

Copilot AI commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot
image

...

Fixed in commit 3014ea0 (24h format) and now also in the latest commit: the "De"/"Até" trigger inputs for period-time mode now display both the date and the selected time (e.g. 08/04/2026 09:00). The inputs are switched to type="text" + readonly so the combined value is always visible after closing the picker, and it updates reactively as the user changes the time fields inside the popup.

Copilot AI changed the title feat(datepicker): add period-time mode with start/end time selection feat(datepicker): add period-time mode with start/end time selection in 24h format Apr 8, 2026
Copilot AI temporarily deployed to storybook-preview April 8, 2026 14:22 Inactive
@tuliorezende

Copy link
Copy Markdown
image

@copilot before click in the field to insert the periods I can't see the "mask"

The previous issue now is solved: i can see the date and time after select properly

but

to keep the behavior and turn more friendly to user, would be cool to keep the mask in the "period-time" type as well

Add placeholder='dd/mm/aaaa HH:MM' to the De/Até trigger inputs in
period-time mode so users can see the expected format before selecting
a date, matching the UX of the regular period mode's date mask.

Agent-Logs-Url: https://github.com/takenet/blip-ds/sessions/069f41fd-7aeb-4dc1-96ac-ece33d506bf5

Co-authored-by: tuliorezende <6129653+tuliorezende@users.noreply.github.com>
@tuliorezende

Copy link
Copy Markdown

@copilot check the pull request comments and adjust if necessary

- Make startTime/endTime non-optional states (remove ?)
- Fix type cast in onInputStartTimeSelected/EndTimeSelected to HTMLBdsInputElement
- Add normalizeTime helper to pad partial HH:MM values before emitting
- Normalize times in clickConcludeDatepicker before adding to payload
- Fix useEffect memory leak in Storybook story (add [] dep + cleanup)
- Add unit tests for formatTimeInput and normalizeTime (17 new tests, 184 total)

Agent-Logs-Url: https://github.com/takenet/blip-ds/sessions/e9d41d66-049e-46c1-a2af-4699282b7174

Co-authored-by: tuliorezende <6129653+tuliorezende@users.noreply.github.com>

Copilot AI commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot check the pull request comments and adjust if necessary

All 5 review points addressed in commit fix(datepicker): address PR review feedback:

  • startTime/endTime non-optional — removed ? from both @State() declarations so they are always string.
  • Type cast fixedonInputStartTimeSelected/onInputEndTimeSelected now cast ev.target to HTMLBdsInputElement | null and use input.value ?? ''.
  • Time normalization before emit — added normalizeTime helper that pads partial values (12:312:03, 909:00); clickConcludeDatepicker normalizes both times and writes back to state before emitting the payload.
  • Storybook useEffect fixed — added [] dependency array and a cleanup that removes all event listeners, preventing duplicate handlers.
  • Unit tests added — 17 new tests covering formatTimeInput (digit stripping, colon insertion, clamping) and normalizeTime (padding, invalid input); all 184 tests pass.

@tuliorezende

Copy link
Copy Markdown
image

@copilot The events when I change the date and I change the hour are resulting in different values. Can you adjust the values on events to standarize the values?

…at to dd/mm/yyyy

The bdsStartDate and bdsEndDate events now emit { value: "dd/mm/yyyy" } (using
dateToString) instead of a raw Date object, matching the format used in the
concludeDatepicker payload and the trigger input display.

Agent-Logs-Url: https://github.com/takenet/blip-ds/sessions/59ab1976-e491-4709-add3-fa7f2b08a602

Co-authored-by: tuliorezende <6129653+tuliorezende@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 9, 2026 17:13

Copilot AI commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author
image

@copilot The events when I change the date and I change the hour a...

Fixed in the latest commit. The bdsStartDate and bdsEndDate events now emit { value: "dd/mm/yyyy" } (using dateToString) instead of a raw JS Date object, matching the format used in the concludeDatepicker payload. All 184 tests pass.

…ing up

The bds-datepicker-period component's bdsStartDate/bdsEndDate events were
bubbling up (composed: true by default in Stencil v2) to the parent
bds-datepicker host element, causing listeners on the parent to receive both
the raw child event (with a Date object) and the parent's own re-emitted event
(with a formatted string).

Added event.stopPropagation() in selectDate/selectEndDate so the child's event
is consumed at the parent handler and does not propagate further.

Agent-Logs-Url: https://github.com/takenet/blip-ds/sessions/40dd355e-9f76-4522-af16-f73dd5a149e1

Co-authored-by: tuliorezende <6129653+tuliorezende@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 9, 2026 18:00
Copilot AI temporarily deployed to storybook-preview April 9, 2026 18:02 Inactive
@tuliorezende

tuliorezende commented Apr 9, 2026

Copy link
Copy Markdown

after the latests updates

@copilot

can you provide some react snippet in this pull request about how can I retrieve the start and end values (with date and times)?

…andlers

Agent-Logs-Url: https://github.com/takenet/blip-ds/sessions/6077fa57-d564-4910-b039-c204e96d2960

Co-authored-by: tuliorezende <6129653+tuliorezende@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 9, 2026 19:08

Copilot AI commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

after the latests updates

@copilot
...

A live working example has been added to Storybook as the FrameworkReactPeriodTime story (commit 07af17d).

Here's how to retrieve all values in React after the latest updates:

import { BdsDatepicker } from 'blip-ds/dist/blip-ds-react';

function MyComponent() {
  const handleConclude = (event: CustomEvent) => {
    const { startDate, startTime, endDate, endTime } = event.detail;
    // startDate / endDate → "dd/mm/yyyy"  (e.g. "01/04/2026")
    // startTime / endTime → "HH:MM"       (e.g. "10:00")
    console.log(`De:  ${startDate} ${startTime}`); // "01/04/2026 10:00"
    console.log(`Até: ${endDate} ${endTime}`);     // "17/04/2026 23:59"
  };

  return (
    <BdsDatepicker
      typeOfDate="period-time"
      startDateLimit="31/12/2022"
      endDateLimit="01/01/2027"
      onConcludeDatepicker={handleConclude}
      onBdsStartDate={(e) => console.log('Data inicial:', e.detail.value)} // "dd/mm/yyyy"
      onBdsEndDate={(e) => console.log('Data final:', e.detail.value)}     // "dd/mm/yyyy"
      onEmptyConcludeDatepicker={() => { /* picker reset — clear state */ }}
    />
  );
}

Event summary:

Event When event.detail
onBdsStartDate Start date clicked { value: "dd/mm/yyyy" }
onBdsEndDate End date clicked { value: "dd/mm/yyyy" }
onConcludeDatepicker "Concluir" with dates { startDate, endDate, startTime, endTime }
onEmptyConcludeDatepicker "Concluir" with no dates (no payload)

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.

feat: Ampliação do Datepicker para ter um modelo que se possa escolher a hora

3 participants