Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add Bento Date Picker Component (ampproject#37385)
* Generate initial amp-date-picker 1.0 * Add initial test * Set value from single input in state * Add date parsing and formatting * Add hidden input field for single date * Add hidden start and end date elements * Refactor to fix component length * Add additional range test * Add imports and copy/pasted CSS * Add DayPicker controller imports * Add date-fns and react-day-picker * Test overlay mode error cases * Add DayPicker component (this currently breaks the tests) * Temporarily stub react to fix external module test * Re-add react-dates and add change date tests * Fix createLTR error by importing react-dates/initialize * Add selected dates and initial month * Swap out react-dates for react-day-picker * Fix test babel config * Refactor single input to avoid saving input field in state * Refactor start and end dates * Update calendar state logic * Add basic aria label to date butons * Add basic blocked dates functionality * Add blocked date range rules * Add RRULE blocked date parsing * Add highlighted dates * Refactor date picker into single and range components * Extract test helpers to separate file * Replace children logic * Refactor conditional logic for top-level date picker * Fix rrule tests to include start date * Add min date * Add default min value and test stub * Add max date * Add month formatting and base date picker abstraction * Fix storybook build and test week day formatting * Add initial state hook and refactor single input state * Add basic opening logic * Move state machine to single date picker * Add basic click and focus behavior * Update build-system/compile/bundles.config.extensions.json Add npm flag Co-authored-by: William Johnson <[email protected]> * Change conditional date picker syntax * Remove onErrorRef * Add range input state machine * Extract date picker state hook * Refactor state hook arguments * Remove unused imports * Add imperative clear function * Add single date picker API and types * Update type definitions * Add API methods for date range picker * Add locale * Add locale to base date picker * Fix storybook * Add first disabled date based on maximumNights prop * Add minimum nights prop * Refactor to use DOM input for existing input field * Add event handler for input change * Replace date range children logic with DOM functions * Add provider for accessing selected dates * Add overlay closing logic * Add range event listeners * Refactor state machine to remove unnecessary values * Add controlled month for setting date from input * Add initial typescript configuration * Convert base component to typescript * Convert single date picker to typescript * Convert constants and helper files * Refactor to use shared input functions * Replace locale string prop with object * Update API args * Add generic attribute parser to parse-props.js * Add parsers and base element props * Add openAfterClear attribute (not implemented) * Update extensions config * Move components and helpers into /component directory * Add initial amp test setup * Add packages and config to render AMP storybook * Add numberOfMonths prop * Add initial date picker bento test fixture * Update src/preact exports to export preact types * Add initial e2e test (not working right now) * Impement openAfterClear prop * Remove unnecessary babel package * Remove duplicate extension config * Move component.type * Fix .tsx extension Co-authored-by: Justin Ridgewell <[email protected]> * Undo preact type exports * Fix date picker e2e test (still no calendar) * Add React import resolvers for all external imports * Revert "Add React import resolvers for all external imports" This reverts commit 0e826f0. * Add basic CSS styles to mimic original date picker * Add aliases to unminified babel config * Use local preact file as react alias * Add optional today prop for simulating today's date * Use today as default for initialVisibleMonth * Add shadow dom support to range date picker * Refactor date pickers and context * Add preact types * Move date parsers and formatters into context * Updates function descriptions * WIP Add e2e tests * Tempoariliy fix forwardRef is not defined error * Fix static date range logic * Add non-working overlay range picker test * Fix date picker in overlay mode * Fix single date picker click event * Fix typo * Fix select date range and storybook * Update comments and date picker component return type * Move helpers to reduce base date picker props * Add TODO * Re-add 0.1 component to bundles.config.extensions.json * Move CSS variables * Use optional chaining for invocation.args * Add parseNumber function with radix * Fix type definitions * Get rid of default props object and type complexity * Update base date picker props * Remove pointless input hidden check * Move default props to provider In an attempt to share defaults and make it less confusing which props are coming from the provider and which props are getting passed into the component, this moves all default props to the provider and creates more type safety for the date picker components that get data from this provider. A potential downside of this change is that it makes it more difficult to use the SingleDatePicker component and RangeDatePicker in isolation if that is something we want to do later. * Extract iterateDateRange to helpers * Rename change handlers * Inline initializeStateMachine function * Add JSS stylesheet to for calendar * Hide calendar using display:none instead of unmounting * Add basic overlay styles (no fixed height) * Downgrade chrome driver * Remove extraAliases from config and rename preact alias to react * Remove AMP test files * Fix z-index file * Fix test helper (to trigger CI) Co-authored-by: William Johnson <[email protected]> Co-authored-by: Justin Ridgewell <[email protected]>
- Loading branch information