draft-components 1.13.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/draft-components.css +553 -558
- package/css/draft-components.dark.css +185 -113
- package/dist/components/alert/alert.d.ts +15 -0
- package/dist/components/alert/alert.js +12 -0
- package/dist/components/alert/index.d.ts +1 -0
- package/dist/components/alert/index.js +1 -0
- package/{types → dist}/components/avatar/avatar.d.ts +8 -7
- package/dist/components/avatar/avatar.js +41 -0
- package/dist/components/avatar/index.d.ts +1 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/avatar-group/avatar-group.js +5 -0
- package/dist/components/avatar-group/index.d.ts +1 -0
- package/dist/components/avatar-group/index.js +1 -0
- package/{esm → dist}/components/badge/badge.js +3 -6
- package/dist/components/badge/index.d.ts +1 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/breadcrumbs/breadcrumbs-context.js +13 -0
- package/dist/components/breadcrumbs/breadcrumbs-item.js +16 -0
- package/dist/components/breadcrumbs/breadcrumbs.js +7 -0
- package/dist/components/breadcrumbs/index.d.ts +2 -0
- package/dist/components/breadcrumbs/index.js +2 -0
- package/{types → dist}/components/button/button.d.ts +12 -10
- package/dist/components/button/button.js +22 -0
- package/dist/components/button/icon-button.d.ts +4 -0
- package/dist/components/button/icon-button.js +7 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +2 -0
- package/dist/components/button-group/button-group.js +5 -0
- package/dist/components/button-group/index.d.ts +1 -0
- package/dist/components/button-group/index.js +1 -0
- package/dist/components/caption/caption.d.ts +10 -0
- package/dist/components/caption/caption.js +10 -0
- package/dist/components/caption/index.d.ts +1 -0
- package/dist/components/caption/index.js +1 -0
- package/dist/components/checkbox/checkbox.js +15 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/color-picker/color-picker-button.js +11 -0
- package/{esm → dist}/components/color-picker/color-picker.js +4 -7
- package/dist/components/color-picker/index.d.ts +1 -0
- package/dist/components/color-picker/index.js +1 -0
- package/{esm → dist}/components/date-picker/calendar-day.js +4 -7
- package/{types → dist}/components/date-picker/calendar-grid-head.d.ts +1 -1
- package/dist/components/date-picker/calendar-grid-head.js +11 -0
- package/{types → dist}/components/date-picker/calendar-grid.d.ts +2 -2
- package/{esm → dist}/components/date-picker/calendar-grid.js +7 -10
- package/dist/components/date-picker/calendar-header.js +43 -0
- package/{types → dist}/components/date-picker/calendar.d.ts +3 -3
- package/dist/components/date-picker/calendar.js +19 -0
- package/{esm → dist}/components/date-picker/date-helpers.js +20 -22
- package/{types → dist}/components/date-picker/date-picker.d.ts +2 -2
- package/dist/components/date-picker/date-picker.js +15 -0
- package/{types → dist}/components/date-picker/date-range-picker.d.ts +3 -3
- package/{esm → dist}/components/date-picker/date-range-picker.js +4 -7
- package/{types → dist}/components/date-picker/date-range.d.ts +1 -1
- package/{esm → dist}/components/date-picker/date-range.js +1 -4
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.js +2 -0
- package/{types → dist}/components/date-picker/parse-min-max-props.d.ts +1 -1
- package/{esm → dist}/components/date-picker/parse-min-max-props.js +1 -4
- package/{types → dist}/components/date-picker-popover/date-picker-popover.d.ts +2 -2
- package/dist/components/date-picker-popover/date-picker-popover.js +15 -0
- package/dist/components/date-picker-popover/index.d.ts +1 -0
- package/dist/components/date-picker-popover/index.js +1 -0
- package/dist/components/date-range-picker-popover/date-range-picker-popover-footer.js +5 -0
- package/{types → dist}/components/date-range-picker-popover/date-range-picker-popover-presets.d.ts +1 -1
- package/dist/components/date-range-picker-popover/date-range-picker-popover-presets.js +30 -0
- package/{types → dist}/components/date-range-picker-popover/date-range-picker-popover.d.ts +3 -3
- package/{esm → dist}/components/date-range-picker-popover/date-range-picker-popover.js +7 -14
- package/{types → dist}/components/date-range-picker-popover/helpers.d.ts +1 -1
- package/{esm → dist}/components/date-range-picker-popover/helpers.js +1 -3
- package/dist/components/date-range-picker-popover/index.d.ts +2 -0
- package/dist/components/date-range-picker-popover/index.js +2 -0
- package/{types → dist}/components/date-range-picker-popover/types.d.ts +1 -1
- package/dist/components/date-range-picker-popover/types.js +1 -0
- package/{esm → dist}/components/date-range-picker-popover/use-is-compact-view.js +2 -5
- package/dist/components/dialog/dialog-body.js +7 -0
- package/{esm → dist}/components/dialog/dialog-context.js +4 -7
- package/dist/components/dialog/dialog-footer.js +8 -0
- package/dist/components/dialog/dialog-header.js +15 -0
- package/{esm → dist}/components/dialog/dialog.js +9 -15
- package/dist/components/dialog/index.d.ts +4 -0
- package/dist/components/dialog/index.js +4 -0
- package/dist/components/empty-state/empty-state.d.ts +12 -0
- package/dist/components/empty-state/empty-state.js +17 -0
- package/dist/components/empty-state/index.d.ts +1 -0
- package/dist/components/empty-state/index.js +1 -0
- package/{esm → dist}/components/file-picker/file-picker.js +6 -10
- package/dist/components/file-picker/index.d.ts +1 -0
- package/dist/components/file-picker/index.js +1 -0
- package/dist/components/filter-buttons/filter-button.js +6 -0
- package/{esm → dist}/components/filter-buttons/filter-buttons.js +4 -7
- package/dist/components/filter-buttons/index.d.ts +2 -0
- package/dist/components/filter-buttons/index.js +2 -0
- package/{types → dist}/components/filtered-search/filter-item.d.ts +1 -1
- package/dist/components/filtered-search/filter-item.js +17 -0
- package/dist/components/filtered-search/filter-operator-select.js +12 -0
- package/dist/components/filtered-search/filter-token.js +12 -0
- package/dist/components/filtered-search/filter-value-list.js +15 -0
- package/{types → dist}/components/filtered-search/filtered-search.d.ts +1 -1
- package/{esm → dist}/components/filtered-search/filtered-search.js +11 -16
- package/{types → dist}/components/filtered-search/index.d.ts +4 -4
- package/dist/components/filtered-search/index.js +3 -0
- package/dist/components/filtered-search/model/abstract-filter.js +2 -0
- package/{types → dist}/components/filtered-search/model/string-filter.d.ts +2 -2
- package/{esm → dist}/components/filtered-search/model/string-filter.js +1 -4
- package/{types → dist}/components/filtered-search/model/string-set-filter.d.ts +1 -1
- package/{esm → dist}/components/filtered-search/model/string-set-filter.js +1 -4
- package/dist/components/filtered-search/model/validation-result.js +1 -0
- package/dist/components/filtered-search/string-filter-input.js +15 -0
- package/{types → dist}/components/filtered-search/string-filter-item.d.ts +1 -1
- package/{esm → dist}/components/filtered-search/string-filter-item.js +6 -10
- package/{types → dist}/components/filtered-search/string-set-filter-item.d.ts +1 -1
- package/{esm → dist}/components/filtered-search/string-set-filter-item.js +6 -10
- package/{types → dist}/components/filtered-search/types.d.ts +2 -2
- package/dist/components/filtered-search/types.js +1 -0
- package/{esm → dist}/components/filtered-search/use-combobox-ids.js +2 -5
- package/{esm → dist}/components/filtered-search/use-translations.js +4 -7
- package/{types → dist}/components/form-field/form-field.d.ts +7 -3
- package/dist/components/form-field/form-field.js +37 -0
- package/dist/components/form-field/index.d.ts +1 -0
- package/dist/components/form-field/index.js +1 -0
- package/dist/components/hero-icons/24/outline/arrow-small-down-icon.d.ts +4 -0
- package/dist/components/hero-icons/24/outline/arrow-small-down-icon.js +5 -0
- package/dist/components/hero-icons/24/outline/arrow-small-up-icon.d.ts +4 -0
- package/dist/components/hero-icons/24/outline/arrow-small-up-icon.js +5 -0
- package/dist/components/hero-icons/24/outline/arrows-up-down-icon.d.ts +4 -0
- package/dist/components/hero-icons/24/outline/arrows-up-down-icon.js +5 -0
- package/dist/components/hero-icons/24/outline/chevron-left-icon.d.ts +4 -0
- package/dist/components/hero-icons/24/outline/chevron-left-icon.js +5 -0
- package/dist/components/hero-icons/24/outline/chevron-right-icon.d.ts +4 -0
- package/dist/components/hero-icons/24/outline/chevron-right-icon.js +5 -0
- package/dist/components/hero-icons/24/outline/eye-icon.d.ts +4 -0
- package/dist/components/hero-icons/24/outline/eye-icon.js +5 -0
- package/dist/components/hero-icons/24/outline/eye-slash-icon.d.ts +4 -0
- package/dist/components/hero-icons/24/outline/eye-slash-icon.js +5 -0
- package/dist/components/hero-icons/24/outline/magnifying-glass-icon.d.ts +4 -0
- package/dist/components/hero-icons/24/outline/magnifying-glass-icon.js +5 -0
- package/dist/components/hero-icons/24/outline/trash-icon.d.ts +4 -0
- package/dist/components/hero-icons/24/outline/trash-icon.js +5 -0
- package/dist/components/hero-icons/24/outline/x-mark-icon.d.ts +4 -0
- package/dist/components/hero-icons/24/outline/x-mark-icon.js +5 -0
- package/dist/components/hero-icons/24/solid/exclamation-triangle-icon.d.ts +4 -0
- package/dist/components/hero-icons/24/solid/exclamation-triangle-icon.js +5 -0
- package/dist/components/index.d.ts +42 -0
- package/dist/components/index.js +42 -0
- package/dist/components/label/index.d.ts +1 -0
- package/dist/components/label/index.js +1 -0
- package/dist/components/label/label.js +8 -0
- package/dist/components/menu/index.d.ts +3 -0
- package/dist/components/menu/index.js +3 -0
- package/{types → dist}/components/menu/menu-item.d.ts +4 -6
- package/dist/components/menu/menu-item.js +16 -0
- package/dist/components/menu/menu-separator.js +5 -0
- package/{types → dist}/components/menu/menu.d.ts +6 -5
- package/{esm → dist}/components/menu/menu.js +7 -11
- package/dist/components/nav-list/index.d.ts +3 -0
- package/dist/components/nav-list/index.js +3 -0
- package/dist/components/nav-list/nav-list-item.js +15 -0
- package/dist/components/nav-list/nav-list-title.js +5 -0
- package/dist/components/nav-list/nav-list.js +5 -0
- package/dist/components/password-input/index.d.ts +1 -0
- package/dist/components/password-input/index.js +1 -0
- package/dist/components/password-input/password-input.d.ts +9 -0
- package/dist/components/password-input/password-input.js +17 -0
- package/dist/components/popover/index.d.ts +1 -0
- package/dist/components/popover/index.js +1 -0
- package/{types → dist}/components/popover/popover.d.ts +1 -1
- package/{esm → dist}/components/popover/popover.js +8 -11
- package/{esm → dist}/components/popover/use-page-click.js +2 -5
- package/dist/components/portal/index.d.ts +1 -0
- package/dist/components/portal/index.js +1 -0
- package/{esm → dist}/components/portal/portal-context.js +6 -5
- package/{esm → dist}/components/portal/portal.js +1 -4
- package/{types → dist}/components/positioner/calc-position.d.ts +1 -1
- package/{esm → dist}/components/positioner/calc-position.js +2 -4
- package/dist/components/positioner/index.d.ts +1 -0
- package/dist/components/positioner/index.js +1 -0
- package/{types → dist}/components/positioner/positioner.d.ts +1 -1
- package/{esm → dist}/components/positioner/positioner.js +5 -8
- package/dist/components/positioner/types.js +1 -0
- package/dist/components/radio/index.d.ts +1 -0
- package/dist/components/radio/index.js +1 -0
- package/dist/components/radio/radio.js +23 -0
- package/dist/components/segmented-control/index.d.ts +1 -0
- package/dist/components/segmented-control/index.js +1 -0
- package/dist/components/segmented-control/segmented-button.d.ts +11 -0
- package/dist/components/segmented-control/segmented-button.js +10 -0
- package/{types → dist}/components/segmented-control/segmented-control.d.ts +5 -3
- package/dist/components/segmented-control/segmented-control.js +15 -0
- package/dist/components/select/index.d.ts +1 -0
- package/dist/components/select/index.js +1 -0
- package/{types → dist}/components/select/select.d.ts +9 -9
- package/dist/components/select/select.js +34 -0
- package/dist/components/selection-control/index.d.ts +1 -0
- package/dist/components/selection-control/index.js +1 -0
- package/dist/components/selection-control/selection-control.js +15 -0
- package/{types → dist}/components/slide-over/index.d.ts +4 -4
- package/dist/components/slide-over/index.js +3 -0
- package/dist/components/slide-over/slide-over-body.js +5 -0
- package/{types → dist}/components/slide-over/slide-over-context.d.ts +1 -1
- package/dist/components/slide-over/slide-over-context.js +18 -0
- package/dist/components/slide-over/slide-over-header.js +13 -0
- package/{types → dist}/components/slide-over/slide-over.d.ts +3 -3
- package/{esm → dist}/components/slide-over/slide-over.js +7 -12
- package/dist/components/slide-over/types.js +1 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +2 -0
- package/dist/components/slider/slider-tick-marks.js +12 -0
- package/{types → dist}/components/slider/slider.d.ts +1 -1
- package/{esm → dist}/components/slider/slider.js +5 -8
- package/dist/components/spinner/index.d.ts +1 -0
- package/dist/components/spinner/index.js +1 -0
- package/dist/components/spinner/spinner.js +6 -0
- package/dist/components/switch/index.d.ts +1 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/switch/switch.js +12 -0
- package/dist/components/table/index.d.ts +7 -0
- package/dist/components/table/index.js +7 -0
- package/dist/components/table/table-body.js +6 -0
- package/dist/components/table/table-cell.js +6 -0
- package/{esm → dist}/components/table/table-container.js +3 -6
- package/{types → dist}/components/table/table-head-cell.d.ts +1 -1
- package/dist/components/table/table-head-cell.js +27 -0
- package/dist/components/table/table-head.js +9 -0
- package/dist/components/table/table-row.js +9 -0
- package/{esm → dist}/components/table/table.js +3 -6
- package/dist/components/tabs/index.d.ts +4 -0
- package/dist/components/tabs/index.js +4 -0
- package/{esm → dist}/components/tabs/tab-list.js +3 -6
- package/{types → dist}/components/tabs/tab-panel.d.ts +1 -1
- package/dist/components/tabs/tab-panel.js +11 -0
- package/dist/components/tabs/tab.js +14 -0
- package/{types → dist}/components/tabs/tabs-context.d.ts +1 -1
- package/{esm → dist}/components/tabs/tabs-context.js +5 -8
- package/{types → dist}/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.js +6 -0
- package/dist/components/tabs/types.js +1 -0
- package/dist/components/tag/index.d.ts +1 -0
- package/dist/components/tag/index.js +1 -0
- package/dist/components/tag/tag.d.ts +15 -0
- package/dist/components/tag/tag.js +11 -0
- package/dist/components/text-input/index.d.ts +1 -0
- package/dist/components/text-input/index.js +1 -0
- package/{types → dist}/components/text-input/text-input.d.ts +12 -13
- package/dist/components/text-input/text-input.js +42 -0
- package/dist/components/textarea/index.d.ts +1 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/textarea/textarea.d.ts +12 -0
- package/dist/components/textarea/textarea.js +19 -0
- package/dist/components/toast/index.d.ts +2 -0
- package/dist/components/toast/index.js +2 -0
- package/dist/components/toast/toast-button.js +6 -0
- package/dist/components/toast/toast.js +6 -0
- package/dist/components/toaster/index.d.ts +1 -0
- package/dist/components/toaster/index.js +1 -0
- package/{esm → dist}/components/toaster/toaster.js +9 -13
- package/dist/components/tooltip/index.d.ts +1 -0
- package/dist/components/tooltip/index.js +1 -0
- package/{types → dist}/components/tooltip/tooltip.d.ts +1 -1
- package/{esm → dist}/components/tooltip/tooltip.js +8 -11
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +4 -0
- package/{esm → dist}/hooks/use-disable-body-scroll.js +1 -4
- package/{esm → dist}/hooks/use-esc-key-down.js +2 -5
- package/{esm → dist}/hooks/use-focus-trap.js +1 -4
- package/{esm → dist}/hooks/use-mount-transition.js +2 -5
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/{esm → dist}/lib/helpers.js +3 -5
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.js +3 -0
- package/{esm → dist}/lib/keyboard-keys.js +1 -3
- package/{esm → dist}/lib/react-helpers.js +6 -9
- package/package.json +41 -55
- package/cjs/components/alert/alert.cjs +0 -19
- package/cjs/components/avatar/avatar.cjs +0 -31
- package/cjs/components/avatar-group/avatar-group.cjs +0 -10
- package/cjs/components/badge/badge.cjs +0 -23
- package/cjs/components/breadcrumbs/breadcrumbs-context.cjs +0 -19
- package/cjs/components/breadcrumbs/breadcrumbs-item.cjs +0 -21
- package/cjs/components/breadcrumbs/breadcrumbs.cjs +0 -12
- package/cjs/components/button/button.cjs +0 -41
- package/cjs/components/button/icon-button.cjs +0 -12
- package/cjs/components/button-group/button-group.cjs +0 -10
- package/cjs/components/caption/caption.cjs +0 -27
- package/cjs/components/caption/icons.cjs +0 -21
- package/cjs/components/checkbox/checkbox.cjs +0 -20
- package/cjs/components/color-picker/color-picker-button.cjs +0 -16
- package/cjs/components/color-picker/color-picker.cjs +0 -24
- package/cjs/components/date-picker/calendar-day.cjs +0 -17
- package/cjs/components/date-picker/calendar-grid-head.cjs +0 -16
- package/cjs/components/date-picker/calendar-grid.cjs +0 -106
- package/cjs/components/date-picker/calendar-header.cjs +0 -48
- package/cjs/components/date-picker/calendar.cjs +0 -24
- package/cjs/components/date-picker/date-helpers.cjs +0 -112
- package/cjs/components/date-picker/date-picker.cjs +0 -20
- package/cjs/components/date-picker/date-range-picker.cjs +0 -61
- package/cjs/components/date-picker/date-range.cjs +0 -28
- package/cjs/components/date-picker/icons.cjs +0 -13
- package/cjs/components/date-picker/parse-min-max-props.cjs +0 -20
- package/cjs/components/date-picker-popover/date-picker-popover.cjs +0 -24
- package/cjs/components/date-range-picker-popover/date-range-picker-popover-footer.cjs +0 -11
- package/cjs/components/date-range-picker-popover/date-range-picker-popover-presets.cjs +0 -35
- package/cjs/components/date-range-picker-popover/date-range-picker-popover.cjs +0 -59
- package/cjs/components/date-range-picker-popover/helpers.cjs +0 -15
- package/cjs/components/date-range-picker-popover/use-is-compact-view.cjs +0 -27
- package/cjs/components/dialog/dialog-body.cjs +0 -12
- package/cjs/components/dialog/dialog-context.cjs +0 -24
- package/cjs/components/dialog/dialog-footer.cjs +0 -13
- package/cjs/components/dialog/dialog-header.cjs +0 -21
- package/cjs/components/dialog/dialog.cjs +0 -50
- package/cjs/components/dialog/x-mark-icon.cjs +0 -9
- package/cjs/components/empty-state/empty-state.cjs +0 -10
- package/cjs/components/file-picker/file-picker.cjs +0 -47
- package/cjs/components/filter-buttons/filter-button.cjs +0 -11
- package/cjs/components/filter-buttons/filter-buttons.cjs +0 -27
- package/cjs/components/filtered-search/filter-item.cjs +0 -23
- package/cjs/components/filtered-search/filter-operator-select.cjs +0 -17
- package/cjs/components/filtered-search/filter-token.cjs +0 -17
- package/cjs/components/filtered-search/filter-value-list.cjs +0 -20
- package/cjs/components/filtered-search/filtered-search.cjs +0 -225
- package/cjs/components/filtered-search/icons.cjs +0 -21
- package/cjs/components/filtered-search/model/abstract-filter.cjs +0 -6
- package/cjs/components/filtered-search/model/string-filter.cjs +0 -46
- package/cjs/components/filtered-search/model/string-set-filter.cjs +0 -44
- package/cjs/components/filtered-search/string-filter-input.cjs +0 -17
- package/cjs/components/filtered-search/string-filter-item.cjs +0 -68
- package/cjs/components/filtered-search/string-set-filter-item.cjs +0 -77
- package/cjs/components/filtered-search/use-combobox-ids.cjs +0 -17
- package/cjs/components/filtered-search/use-translations.cjs +0 -24
- package/cjs/components/form-field/form-field.cjs +0 -26
- package/cjs/components/index.cjs +0 -141
- package/cjs/components/label/label.cjs +0 -13
- package/cjs/components/menu/menu-item.cjs +0 -21
- package/cjs/components/menu/menu-separator.cjs +0 -10
- package/cjs/components/menu/menu.cjs +0 -191
- package/cjs/components/nav-list/nav-list-item.cjs +0 -20
- package/cjs/components/nav-list/nav-list-title.cjs +0 -10
- package/cjs/components/nav-list/nav-list.cjs +0 -10
- package/cjs/components/password-input/icons.cjs +0 -13
- package/cjs/components/password-input/password-input.cjs +0 -30
- package/cjs/components/popover/popover.cjs +0 -96
- package/cjs/components/popover/use-page-click.cjs +0 -51
- package/cjs/components/portal/portal-context.cjs +0 -22
- package/cjs/components/portal/portal.cjs +0 -11
- package/cjs/components/positioner/calc-position.cjs +0 -117
- package/cjs/components/positioner/positioner.cjs +0 -64
- package/cjs/components/radio/radio.cjs +0 -28
- package/cjs/components/segmented-control/segmented-control-button.cjs +0 -15
- package/cjs/components/segmented-control/segmented-control.cjs +0 -48
- package/cjs/components/select/select.cjs +0 -39
- package/cjs/components/selection-control/selection-control.cjs +0 -18
- package/cjs/components/slide-over/slide-over-body.cjs +0 -10
- package/cjs/components/slide-over/slide-over-context.cjs +0 -24
- package/cjs/components/slide-over/slide-over-header.cjs +0 -21
- package/cjs/components/slide-over/slide-over.cjs +0 -113
- package/cjs/components/slider/slider-tick-marks.cjs +0 -17
- package/cjs/components/slider/slider.cjs +0 -41
- package/cjs/components/spinner/spinner.cjs +0 -11
- package/cjs/components/switch/switch.cjs +0 -17
- package/cjs/components/table/icons.cjs +0 -17
- package/cjs/components/table/table-body.cjs +0 -11
- package/cjs/components/table/table-cell.cjs +0 -11
- package/cjs/components/table/table-container.cjs +0 -23
- package/cjs/components/table/table-head-cell.cjs +0 -30
- package/cjs/components/table/table-head.cjs +0 -14
- package/cjs/components/table/table-row.cjs +0 -14
- package/cjs/components/table/table.cjs +0 -16
- package/cjs/components/tabs/tab-list.cjs +0 -67
- package/cjs/components/tabs/tab-panel.cjs +0 -16
- package/cjs/components/tabs/tab.cjs +0 -19
- package/cjs/components/tabs/tabs-context.cjs +0 -31
- package/cjs/components/tabs/tabs.cjs +0 -11
- package/cjs/components/tag/tag.cjs +0 -16
- package/cjs/components/text-input/text-input.cjs +0 -42
- package/cjs/components/textarea/textarea.cjs +0 -40
- package/cjs/components/toast/toast-button.cjs +0 -11
- package/cjs/components/toast/toast.cjs +0 -11
- package/cjs/components/toast/x-mark-icon.cjs +0 -9
- package/cjs/components/toaster/toaster.cjs +0 -115
- package/cjs/components/tooltip/tooltip.cjs +0 -75
- package/cjs/hooks/index.cjs +0 -13
- package/cjs/hooks/use-disable-body-scroll.cjs +0 -37
- package/cjs/hooks/use-esc-key-down.cjs +0 -56
- package/cjs/hooks/use-focus-trap.cjs +0 -89
- package/cjs/hooks/use-mount-transition.cjs +0 -41
- package/cjs/index.cjs +0 -161
- package/cjs/lib/helpers.cjs +0 -25
- package/cjs/lib/index.cjs +0 -17
- package/cjs/lib/keyboard-keys.cjs +0 -19
- package/cjs/lib/react-helpers.cjs +0 -58
- package/esm/components/alert/alert.js +0 -17
- package/esm/components/avatar/avatar.js +0 -29
- package/esm/components/avatar-group/avatar-group.js +0 -8
- package/esm/components/breadcrumbs/breadcrumbs-context.js +0 -16
- package/esm/components/breadcrumbs/breadcrumbs-item.js +0 -19
- package/esm/components/breadcrumbs/breadcrumbs.js +0 -10
- package/esm/components/button/button.js +0 -39
- package/esm/components/button/icon-button.js +0 -10
- package/esm/components/button-group/button-group.js +0 -8
- package/esm/components/caption/caption.js +0 -25
- package/esm/components/caption/icons.js +0 -16
- package/esm/components/checkbox/checkbox.js +0 -18
- package/esm/components/color-picker/color-picker-button.js +0 -14
- package/esm/components/date-picker/calendar-grid-head.js +0 -14
- package/esm/components/date-picker/calendar-header.js +0 -46
- package/esm/components/date-picker/calendar.js +0 -22
- package/esm/components/date-picker/date-picker.js +0 -18
- package/esm/components/date-picker/icons.js +0 -10
- package/esm/components/date-picker-popover/date-picker-popover.js +0 -22
- package/esm/components/date-range-picker-popover/date-range-picker-popover-footer.js +0 -9
- package/esm/components/date-range-picker-popover/date-range-picker-popover-presets.js +0 -33
- package/esm/components/dialog/dialog-body.js +0 -10
- package/esm/components/dialog/dialog-footer.js +0 -11
- package/esm/components/dialog/dialog-header.js +0 -19
- package/esm/components/dialog/x-mark-icon.js +0 -7
- package/esm/components/empty-state/empty-state.js +0 -8
- package/esm/components/filter-buttons/filter-button.js +0 -9
- package/esm/components/filtered-search/filter-item.js +0 -21
- package/esm/components/filtered-search/filter-operator-select.js +0 -15
- package/esm/components/filtered-search/filter-token.js +0 -15
- package/esm/components/filtered-search/filter-value-list.js +0 -18
- package/esm/components/filtered-search/icons.js +0 -16
- package/esm/components/filtered-search/model/abstract-filter.js +0 -4
- package/esm/components/filtered-search/string-filter-input.js +0 -15
- package/esm/components/form-field/form-field.js +0 -24
- package/esm/components/index.js +0 -68
- package/esm/components/label/label.js +0 -11
- package/esm/components/menu/menu-item.js +0 -19
- package/esm/components/menu/menu-separator.js +0 -8
- package/esm/components/nav-list/nav-list-item.js +0 -18
- package/esm/components/nav-list/nav-list-title.js +0 -8
- package/esm/components/nav-list/nav-list.js +0 -8
- package/esm/components/password-input/icons.js +0 -10
- package/esm/components/password-input/password-input.js +0 -28
- package/esm/components/radio/radio.js +0 -26
- package/esm/components/segmented-control/segmented-control-button.js +0 -13
- package/esm/components/segmented-control/segmented-control.js +0 -46
- package/esm/components/select/select.js +0 -37
- package/esm/components/selection-control/selection-control.js +0 -16
- package/esm/components/slide-over/slide-over-body.js +0 -8
- package/esm/components/slide-over/slide-over-context.js +0 -21
- package/esm/components/slide-over/slide-over-header.js +0 -19
- package/esm/components/slider/slider-tick-marks.js +0 -15
- package/esm/components/spinner/spinner.js +0 -9
- package/esm/components/switch/switch.js +0 -15
- package/esm/components/table/icons.js +0 -13
- package/esm/components/table/table-body.js +0 -9
- package/esm/components/table/table-cell.js +0 -9
- package/esm/components/table/table-head-cell.js +0 -28
- package/esm/components/table/table-head.js +0 -12
- package/esm/components/table/table-row.js +0 -12
- package/esm/components/tabs/tab-panel.js +0 -14
- package/esm/components/tabs/tab.js +0 -17
- package/esm/components/tabs/tabs.js +0 -9
- package/esm/components/tag/tag.js +0 -14
- package/esm/components/text-input/text-input.js +0 -40
- package/esm/components/textarea/textarea.js +0 -38
- package/esm/components/toast/toast-button.js +0 -9
- package/esm/components/toast/toast.js +0 -9
- package/esm/components/toast/x-mark-icon.js +0 -7
- package/esm/hooks/index.js +0 -4
- package/esm/index.js +0 -75
- package/esm/lib/index.js +0 -3
- package/types/components/alert/alert.d.ts +0 -12
- package/types/components/alert/index.d.ts +0 -1
- package/types/components/avatar/index.d.ts +0 -1
- package/types/components/avatar-group/index.d.ts +0 -1
- package/types/components/badge/index.d.ts +0 -1
- package/types/components/breadcrumbs/index.d.ts +0 -2
- package/types/components/button/icon-button.d.ts +0 -7
- package/types/components/button/index.d.ts +0 -2
- package/types/components/button-group/index.d.ts +0 -1
- package/types/components/caption/caption.d.ts +0 -7
- package/types/components/caption/icons.d.ts +0 -5
- package/types/components/caption/index.d.ts +0 -1
- package/types/components/checkbox/index.d.ts +0 -1
- package/types/components/color-picker/index.d.ts +0 -1
- package/types/components/date-picker/icons.d.ts +0 -3
- package/types/components/date-picker/index.d.ts +0 -2
- package/types/components/date-picker-popover/index.d.ts +0 -1
- package/types/components/date-range-picker-popover/index.d.ts +0 -2
- package/types/components/dialog/index.d.ts +0 -4
- package/types/components/dialog/x-mark-icon.d.ts +0 -2
- package/types/components/empty-state/empty-state.d.ts +0 -11
- package/types/components/empty-state/index.d.ts +0 -1
- package/types/components/file-picker/index.d.ts +0 -1
- package/types/components/filter-buttons/index.d.ts +0 -2
- package/types/components/filtered-search/icons.d.ts +0 -5
- package/types/components/form-field/index.d.ts +0 -1
- package/types/components/index.d.ts +0 -42
- package/types/components/label/index.d.ts +0 -1
- package/types/components/menu/index.d.ts +0 -3
- package/types/components/nav-list/index.d.ts +0 -3
- package/types/components/password-input/icons.d.ts +0 -3
- package/types/components/password-input/index.d.ts +0 -1
- package/types/components/password-input/password-input.d.ts +0 -10
- package/types/components/popover/index.d.ts +0 -1
- package/types/components/portal/index.d.ts +0 -1
- package/types/components/positioner/index.d.ts +0 -1
- package/types/components/radio/index.d.ts +0 -1
- package/types/components/segmented-control/index.d.ts +0 -1
- package/types/components/segmented-control/segmented-control-button.d.ts +0 -10
- package/types/components/select/index.d.ts +0 -1
- package/types/components/selection-control/index.d.ts +0 -1
- package/types/components/slider/index.d.ts +0 -2
- package/types/components/spinner/index.d.ts +0 -1
- package/types/components/switch/index.d.ts +0 -1
- package/types/components/table/icons.d.ts +0 -4
- package/types/components/table/index.d.ts +0 -7
- package/types/components/tabs/index.d.ts +0 -4
- package/types/components/tag/index.d.ts +0 -1
- package/types/components/tag/tag.d.ts +0 -18
- package/types/components/text-input/index.d.ts +0 -1
- package/types/components/textarea/index.d.ts +0 -1
- package/types/components/textarea/textarea.d.ts +0 -20
- package/types/components/toast/index.d.ts +0 -2
- package/types/components/toast/x-mark-icon.d.ts +0 -2
- package/types/components/toaster/index.d.ts +0 -1
- package/types/components/tooltip/index.d.ts +0 -1
- package/types/hooks/index.d.ts +0 -4
- package/types/index.d.ts +0 -3
- package/types/lib/index.d.ts +0 -3
- /package/{types → dist}/components/avatar-group/avatar-group.d.ts +0 -0
- /package/{types → dist}/components/badge/badge.d.ts +0 -0
- /package/{types → dist}/components/breadcrumbs/breadcrumbs-context.d.ts +0 -0
- /package/{types → dist}/components/breadcrumbs/breadcrumbs-item.d.ts +0 -0
- /package/{types → dist}/components/breadcrumbs/breadcrumbs.d.ts +0 -0
- /package/{types → dist}/components/button-group/button-group.d.ts +0 -0
- /package/{types → dist}/components/checkbox/checkbox.d.ts +0 -0
- /package/{types → dist}/components/color-picker/color-picker-button.d.ts +0 -0
- /package/{types → dist}/components/color-picker/color-picker.d.ts +0 -0
- /package/{types → dist}/components/date-picker/calendar-day.d.ts +0 -0
- /package/{types → dist}/components/date-picker/calendar-header.d.ts +0 -0
- /package/{types → dist}/components/date-picker/date-helpers.d.ts +0 -0
- /package/{types → dist}/components/date-range-picker-popover/date-range-picker-popover-footer.d.ts +0 -0
- /package/{types → dist}/components/date-range-picker-popover/use-is-compact-view.d.ts +0 -0
- /package/{types → dist}/components/dialog/dialog-body.d.ts +0 -0
- /package/{types → dist}/components/dialog/dialog-context.d.ts +0 -0
- /package/{types → dist}/components/dialog/dialog-footer.d.ts +0 -0
- /package/{types → dist}/components/dialog/dialog-header.d.ts +0 -0
- /package/{types → dist}/components/dialog/dialog.d.ts +0 -0
- /package/{types → dist}/components/file-picker/file-picker.d.ts +0 -0
- /package/{types → dist}/components/filter-buttons/filter-button.d.ts +0 -0
- /package/{types → dist}/components/filter-buttons/filter-buttons.d.ts +0 -0
- /package/{types → dist}/components/filtered-search/filter-operator-select.d.ts +0 -0
- /package/{types → dist}/components/filtered-search/filter-token.d.ts +0 -0
- /package/{types → dist}/components/filtered-search/filter-value-list.d.ts +0 -0
- /package/{types → dist}/components/filtered-search/model/abstract-filter.d.ts +0 -0
- /package/{types → dist}/components/filtered-search/model/validation-result.d.ts +0 -0
- /package/{types → dist}/components/filtered-search/string-filter-input.d.ts +0 -0
- /package/{types → dist}/components/filtered-search/use-combobox-ids.d.ts +0 -0
- /package/{types → dist}/components/filtered-search/use-translations.d.ts +0 -0
- /package/{types → dist}/components/label/label.d.ts +0 -0
- /package/{types → dist}/components/menu/menu-separator.d.ts +0 -0
- /package/{types → dist}/components/nav-list/nav-list-item.d.ts +0 -0
- /package/{types → dist}/components/nav-list/nav-list-title.d.ts +0 -0
- /package/{types → dist}/components/nav-list/nav-list.d.ts +0 -0
- /package/{types → dist}/components/popover/use-page-click.d.ts +0 -0
- /package/{types → dist}/components/portal/portal-context.d.ts +0 -0
- /package/{types → dist}/components/portal/portal.d.ts +0 -0
- /package/{types → dist}/components/positioner/types.d.ts +0 -0
- /package/{types → dist}/components/radio/radio.d.ts +0 -0
- /package/{types → dist}/components/selection-control/selection-control.d.ts +0 -0
- /package/{types → dist}/components/slide-over/slide-over-body.d.ts +0 -0
- /package/{types → dist}/components/slide-over/slide-over-header.d.ts +0 -0
- /package/{types → dist}/components/slide-over/types.d.ts +0 -0
- /package/{types → dist}/components/slider/slider-tick-marks.d.ts +0 -0
- /package/{types → dist}/components/spinner/spinner.d.ts +0 -0
- /package/{types → dist}/components/switch/switch.d.ts +0 -0
- /package/{types → dist}/components/table/table-body.d.ts +0 -0
- /package/{types → dist}/components/table/table-cell.d.ts +0 -0
- /package/{types → dist}/components/table/table-container.d.ts +0 -0
- /package/{types → dist}/components/table/table-head.d.ts +0 -0
- /package/{types → dist}/components/table/table-row.d.ts +0 -0
- /package/{types → dist}/components/table/table.d.ts +0 -0
- /package/{types → dist}/components/tabs/tab-list.d.ts +0 -0
- /package/{types → dist}/components/tabs/tab.d.ts +0 -0
- /package/{types → dist}/components/tabs/types.d.ts +0 -0
- /package/{types → dist}/components/toast/toast-button.d.ts +0 -0
- /package/{types → dist}/components/toast/toast.d.ts +0 -0
- /package/{types → dist}/components/toaster/toaster.d.ts +0 -0
- /package/{types → dist}/hooks/use-disable-body-scroll.d.ts +0 -0
- /package/{types → dist}/hooks/use-esc-key-down.d.ts +0 -0
- /package/{types → dist}/hooks/use-focus-trap.d.ts +0 -0
- /package/{types → dist}/hooks/use-mount-transition.d.ts +0 -0
- /package/{types → dist}/lib/helpers.d.ts +0 -0
- /package/{types → dist}/lib/keyboard-keys.d.ts +0 -0
- /package/{types → dist}/lib/react-helpers.d.ts +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { classNames } from '../../lib/react-helpers.js';
|
|
4
|
+
import { Spinner } from '../spinner/index.js';
|
|
5
|
+
export const Button = forwardRef(function Button({ fullWidth, disabled, loading, buttonStyle = 'filled', size = 'sm', tint = 'default', iconLeft, iconRight, caption, className, children, type = 'button', renderAs, ...props }, ref) {
|
|
6
|
+
children = (_jsxs(_Fragment, { children: [loading
|
|
7
|
+
? _jsx(Spinner, { "data-testid": "button-spinner", size: "1.15em" })
|
|
8
|
+
: iconLeft, caption ? (_jsxs("div", { className: "dc-button__label", children: [children, _jsx("small", { className: "dc-button__caption", children: caption })] })) : children, iconRight] }));
|
|
9
|
+
className = classNames(className, 'dc-button', {
|
|
10
|
+
[`dc-button_style_${buttonStyle}`]: buttonStyle,
|
|
11
|
+
[`dc-button_tint_${tint}`]: tint,
|
|
12
|
+
[`dc-button_${size}`]: size,
|
|
13
|
+
'dc-button_full-width': fullWidth,
|
|
14
|
+
'dc-button_loading': loading,
|
|
15
|
+
'dc-button_has_icon-left': iconLeft,
|
|
16
|
+
'dc-button_has_icon-right': iconRight,
|
|
17
|
+
});
|
|
18
|
+
if (typeof renderAs === 'function') {
|
|
19
|
+
return renderAs({ className, children });
|
|
20
|
+
}
|
|
21
|
+
return (_jsx("button", { ref: ref, type: type, disabled: disabled || loading, className: className, ...props, children: children }));
|
|
22
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ButtonProps } from './button.js';
|
|
3
|
+
export type IconButtonProps = Omit<ButtonProps, 'caption' | 'iconLeft' | 'iconRight'>;
|
|
4
|
+
export declare const IconButton: import("react").ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { classNames } from '../../lib/react-helpers.js';
|
|
4
|
+
import { Button } from './button.js';
|
|
5
|
+
export const IconButton = forwardRef(function IconButton({ className, children, ...props }, ref) {
|
|
6
|
+
return _jsx(Button, { ...props, ref: ref, className: classNames('dc-button_icon-only', className), iconLeft: children });
|
|
7
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { classNames } from '../../lib/react-helpers.js';
|
|
3
|
+
export function ButtonGroup({ className, children, ...props }) {
|
|
4
|
+
return (_jsx("div", { ...props, className: classNames(className, 'dc-button-group'), children: children }));
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './button-group.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './button-group.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
type CaptionHTMLProps = ComponentPropsWithRef<'div'>;
|
|
3
|
+
type CaptionBaseProps = Omit<CaptionHTMLProps, 'color'>;
|
|
4
|
+
export type CaptionColor = 'gray' | 'blue' | 'green' | 'orange' | 'red';
|
|
5
|
+
export type CaptionProps = {
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
color?: CaptionColor;
|
|
8
|
+
} & CaptionBaseProps;
|
|
9
|
+
export declare const Caption: import("react").ForwardRefExoticComponent<Omit<CaptionProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { classNames } from '../../lib/react-helpers.js';
|
|
4
|
+
export const Caption = forwardRef(function Caption({ color = 'gray', icon, children, className, ...props }, ref) {
|
|
5
|
+
return (_jsxs("div", { ...props, ref: ref, className: classNames(className, 'dc-caption', {
|
|
6
|
+
[`dc-caption_color_${color}`]: color,
|
|
7
|
+
}), children: [icon
|
|
8
|
+
? _jsx("span", { className: "dc-caption__icon", children: icon })
|
|
9
|
+
: null, children] }));
|
|
10
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './caption.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './caption.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { classNames } from '../../lib/react-helpers.js';
|
|
4
|
+
export const Checkbox = forwardRef(function Checkbox({ hasMixedState = false, style, className, onChange, onToggle, ...props }, ref) {
|
|
5
|
+
return (_jsxs("label", { style: style, className: classNames('dc-checkbox', className), children: [_jsx("input", { ...props, ref: ref, type: "checkbox", className: "dc-checkbox__input", onChange: (event) => {
|
|
6
|
+
onChange?.(event);
|
|
7
|
+
onToggle?.(event.target.checked);
|
|
8
|
+
} }), _jsx("span", { className: "dc-checkbox__check", "data-testid": "checkbox-check", "aria-hidden": true, children: hasMixedState ? (_jsx(DashIcon, { className: "dc-checkbox__icon", "data-testid": "checkbox-dash-icon" })) : (_jsx(CheckIcon, { className: "dc-checkbox__icon", "data-testid": "checkbox-check-icon" })) })] }));
|
|
9
|
+
});
|
|
10
|
+
function CheckIcon(props) {
|
|
11
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: 20, height: 20, ...props, children: _jsx("path", { d: "M5 10.4444L9 14L15 6", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
12
|
+
}
|
|
13
|
+
function DashIcon(props) {
|
|
14
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: 20, height: 20, ...props, children: _jsx("path", { d: "M5 10H15", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round" }) }));
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './checkbox.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './checkbox.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { classNames } from '../../lib/react-helpers.js';
|
|
3
|
+
export function ColorPickerButton({ style, className, label, name, color, value, checked, defaultChecked, onChange, onChangeValue, }) {
|
|
4
|
+
const customProperties = {
|
|
5
|
+
'--dc-color-picker-btn-color': color,
|
|
6
|
+
};
|
|
7
|
+
return (_jsxs("label", { style: { ...customProperties, ...style }, className: classNames('dc-color-picker__btn', className), children: [_jsx("input", { type: "radio", name: name, value: value, checked: checked, defaultChecked: defaultChecked, onChange: (event) => {
|
|
8
|
+
onChange?.(event);
|
|
9
|
+
onChangeValue?.(value);
|
|
10
|
+
} }), _jsx("span", { className: "dc-color-picker__btn-check", "aria-hidden": true }), label] }));
|
|
11
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { jsx } from
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { classNames } from '../../lib/react-helpers.js';
|
|
3
3
|
import { ColorPickerButton } from './color-picker-button.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return (jsx("fieldset", { ...props, disabled: disabled, className: classNames(className, {
|
|
4
|
+
export function ColorPicker({ className, name, disabled, options, value, defaultValue, onChange, onChangeValue, ...props }) {
|
|
5
|
+
return (_jsx("fieldset", { ...props, disabled: disabled, className: classNames(className, {
|
|
7
6
|
'dc-color-picker': true,
|
|
8
7
|
'dc-color-picker_disabled': disabled,
|
|
9
8
|
}), children: options.map((option) => {
|
|
@@ -15,8 +14,6 @@ function ColorPicker({ className, name, disabled, options, value, defaultValue,
|
|
|
15
14
|
else if (defaultValue !== undefined) {
|
|
16
15
|
defaultChecked = option.value === defaultValue;
|
|
17
16
|
}
|
|
18
|
-
return (
|
|
17
|
+
return (_jsx(ColorPickerButton, { name: name, label: option.label, color: option.color, value: option.value, checked: checked, defaultChecked: defaultChecked, onChange: onChange, onChangeValue: onChangeValue }, option.value));
|
|
19
18
|
}) }));
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
export { ColorPicker };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './color-picker.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './color-picker.js';
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { jsx } from
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { classNames } from '../../lib/react-helpers.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return (jsx("button", { ...props, className: classNames('dc-calendar-day', {
|
|
3
|
+
export function CalendarDay({ date, dateISO, locale, isSelected, isDisabled, isFocusable, isToday, isWeekend, inRange, isRangeStart, isRangeEnd, ...props }) {
|
|
4
|
+
return (_jsx("button", { ...props, className: classNames('dc-calendar-day', {
|
|
6
5
|
'dc-calendar-day_selected': isSelected,
|
|
7
6
|
'dc-calendar-day_today': isToday,
|
|
8
7
|
'dc-calendar-day_weekend': isWeekend,
|
|
9
8
|
'dc-calendar-day_in-range': inRange,
|
|
10
9
|
'dc-calendar-day_range-start': isRangeStart,
|
|
11
10
|
'dc-calendar-day_range-end': isRangeEnd,
|
|
12
|
-
}), disabled: isDisabled, tabIndex: isFocusable ? 0 : -1, "data-date": dateISO, "aria-label": date.toLocaleString(locale, { dateStyle: 'long' }), children:
|
|
11
|
+
}), disabled: isDisabled, tabIndex: isFocusable ? 0 : -1, "data-date": dateISO, "aria-label": date.toLocaleString(locale, { dateStyle: 'long' }), children: _jsx("span", { className: "dc-calendar-day__body", children: date.getDate() }) }));
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
export { CalendarDay };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DAYS_IN_WEEK, addDays, getStartOfWeek } from './date-helpers.js';
|
|
3
|
+
export function CalendarGridHead({ locale, weekStartsOn, }) {
|
|
4
|
+
const columns = [];
|
|
5
|
+
const monday = getStartOfWeek(new Date(), weekStartsOn);
|
|
6
|
+
for (let weekday = 0; weekday < DAYS_IN_WEEK; weekday += 1) {
|
|
7
|
+
const date = addDays(monday, weekday);
|
|
8
|
+
columns.push(_jsx("th", { role: "columnheader", abbr: date.toLocaleDateString(locale, { weekday: 'long' }), children: date.toLocaleDateString(locale, { weekday: 'short' }) }, weekday));
|
|
9
|
+
}
|
|
10
|
+
return (_jsx("thead", { children: _jsx("tr", { role: "row", children: columns }) }));
|
|
11
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Weekday } from './date-helpers';
|
|
2
|
-
import { CalendarDayProps } from './calendar-day';
|
|
1
|
+
import { type Weekday } from './date-helpers.js';
|
|
2
|
+
import { CalendarDayProps } from './calendar-day.js';
|
|
3
3
|
export type GetCalendarDayProps = (date: Date) => Pick<CalendarDayProps, 'isSelected' | 'inRange' | 'isRangeStart' | 'isRangeEnd'>;
|
|
4
4
|
export type CalendarGridProps = {
|
|
5
5
|
focusDay: Date;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { jsx, jsxs } from
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { KeyboardKeys } from '../../lib/keyboard-keys.js';
|
|
3
|
-
import {
|
|
3
|
+
import { DAYS_IN_WEEK, addDays, addMonths, addYears, getEndOfMonth, getEndOfWeek, getStartOfMonth, getStartOfWeek, isSameDay, isWeekend, toDateISO, } from './date-helpers.js';
|
|
4
4
|
import { CalendarGridHead } from './calendar-grid-head.js';
|
|
5
5
|
import { CalendarDay } from './calendar-day.js';
|
|
6
|
-
|
|
7
|
-
function CalendarGrid({ focusDay, minDate, maxDate, locale, weekStartsOn, getDayProps, onHoverDay, onFocusDay, onSelectDay, onChangeFocusDay, }) {
|
|
6
|
+
export function CalendarGrid({ focusDay, minDate, maxDate, locale, weekStartsOn, getDayProps, onHoverDay, onFocusDay, onSelectDay, onChangeFocusDay, }) {
|
|
8
7
|
const today = new Date();
|
|
9
8
|
const monthStart = getStartOfMonth(focusDay);
|
|
10
9
|
const monthEnd = getEndOfMonth(focusDay);
|
|
@@ -25,13 +24,13 @@ function CalendarGrid({ focusDay, minDate, maxDate, locale, weekStartsOn, getDay
|
|
|
25
24
|
const inDisplayedMonth = date >= monthStart && date <= monthEnd;
|
|
26
25
|
let calendarDay = null;
|
|
27
26
|
if (inDisplayedMonth) {
|
|
28
|
-
calendarDay =
|
|
27
|
+
calendarDay = _jsx(CalendarDay, { ...getDayProps?.(date), date: date, dateISO: dateISO, locale: locale, isToday: isSameDay(date, today), isWeekend: isWeekend(date), isFocusable: isSameDay(date, focusDay), isDisabled: (minDate != null && date < minDate) ||
|
|
29
28
|
(maxDate != null && date > maxDate), onClick: handleSelectDay(date), onMouseEnter: handleHoverDay(date) });
|
|
30
29
|
}
|
|
31
|
-
columns.push(
|
|
30
|
+
columns.push(_jsx("td", { role: "gridcell", children: calendarDay }, dateISO));
|
|
32
31
|
date = addDays(date, 1);
|
|
33
32
|
}
|
|
34
|
-
rows.push(
|
|
33
|
+
rows.push(_jsx("tr", { role: "row", children: columns }, `week-${week}`));
|
|
35
34
|
week += 1;
|
|
36
35
|
}
|
|
37
36
|
function handleSelectDay(date) {
|
|
@@ -98,7 +97,5 @@ function CalendarGrid({ focusDay, minDate, maxDate, locale, weekStartsOn, getDay
|
|
|
98
97
|
}, 0);
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
|
-
return (
|
|
100
|
+
return (_jsxs("table", { className: "dc-calendar__grid", role: "grid", "aria-label": ariaLabel, children: [_jsx(CalendarGridHead, { locale: locale, weekStartsOn: weekStartsOn }), _jsx("tbody", { role: "presentation", onKeyDown: handleKeydown, children: rows })] }));
|
|
102
101
|
}
|
|
103
|
-
|
|
104
|
-
export { CalendarGrid };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MONTHS_IN_YEAR, addMonths, setDateMonth, setDateYear } from './date-helpers.js';
|
|
3
|
+
import { classNames } from '../../lib/react-helpers.js';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
import { IconButton } from '../button/index.js';
|
|
6
|
+
import { Select } from '../select/index.js';
|
|
7
|
+
import { TextInput } from '../text-input/index.js';
|
|
8
|
+
import { ChevronLeftIcon } from '../hero-icons/24/outline/chevron-left-icon.js';
|
|
9
|
+
import { ChevronRightIcon } from '../hero-icons/24/outline/chevron-right-icon.js';
|
|
10
|
+
export function CalendarHeader({ focusDay, onChangeFocusDay, className, locale, nextMonthButtonLabel = 'next month', prevMonthButtonLabel = 'previous month', monthSelectLabel = 'month', yearInputLabel = 'year', }) {
|
|
11
|
+
const selectedYear = focusDay.getFullYear();
|
|
12
|
+
const selectedMonth = focusDay.getMonth();
|
|
13
|
+
const [year, setYear] = useState(formatYear(selectedYear));
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setYear((prevYear) => (parseYear(prevYear) === selectedYear
|
|
16
|
+
? prevYear
|
|
17
|
+
: formatYear(selectedYear)));
|
|
18
|
+
}, [selectedYear]);
|
|
19
|
+
return (_jsxs("div", { className: classNames('dc-calendar__header', className), children: [_jsx(IconButton, { className: "dc-calendar-prev-month", size: "sm", "aria-label": prevMonthButtonLabel, onClick: () => onChangeFocusDay(addMonths(focusDay, -1)), children: _jsx(ChevronLeftIcon, { width: 16, height: 16, strokeWidth: 2 }) }), _jsx(Select, { className: "dc-calendar-month-select", "aria-label": monthSelectLabel, size: "sm", name: "month", value: selectedMonth, onChange: (event) => {
|
|
20
|
+
const month = Number(event.target.value);
|
|
21
|
+
onChangeFocusDay(setDateMonth(focusDay, month));
|
|
22
|
+
}, children: generateMonthOptions(locale) }), _jsx(TextInput, { className: "dc-calendar-year-input", "aria-label": yearInputLabel, size: "sm", sizeInChars: 4, value: year, maxLength: 4, onBlur: () => setYear(formatYear(year)), onChangeValue: (value) => {
|
|
23
|
+
if (value.match(/^\d*$/)) {
|
|
24
|
+
setYear(value);
|
|
25
|
+
onChangeFocusDay(setDateYear(focusDay, parseYear(value)));
|
|
26
|
+
}
|
|
27
|
+
} }), _jsx(IconButton, { className: "dc-calendar-next-month", "aria-label": nextMonthButtonLabel, onClick: () => onChangeFocusDay(addMonths(focusDay, 1)), children: _jsx(ChevronRightIcon, { width: 16, height: 16, strokeWidth: 2 }) })] }));
|
|
28
|
+
}
|
|
29
|
+
function generateMonthOptions(locale = 'en') {
|
|
30
|
+
const options = [];
|
|
31
|
+
const date = new Date();
|
|
32
|
+
for (let month = 0; month < MONTHS_IN_YEAR; month += 1) {
|
|
33
|
+
date.setMonth(month);
|
|
34
|
+
options.push(_jsx("option", { value: month, children: date.toLocaleDateString(locale, { month: 'long' }) }, month));
|
|
35
|
+
}
|
|
36
|
+
return options;
|
|
37
|
+
}
|
|
38
|
+
function formatYear(year) {
|
|
39
|
+
return String(year).padStart(4, '0');
|
|
40
|
+
}
|
|
41
|
+
function parseYear(year) {
|
|
42
|
+
return Number(year);
|
|
43
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Weekday } from './date-helpers';
|
|
2
|
-
import { CalendarHeaderProps } from './calendar-header';
|
|
3
|
-
import { CalendarGridProps } from './calendar-grid';
|
|
1
|
+
import { Weekday } from './date-helpers.js';
|
|
2
|
+
import { CalendarHeaderProps } from './calendar-header.js';
|
|
3
|
+
import { CalendarGridProps } from './calendar-grid.js';
|
|
4
4
|
export type CalendarProps = {
|
|
5
5
|
className?: string;
|
|
6
6
|
defaultFocusDay?: Date | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { classNames } from '../../lib/react-helpers.js';
|
|
4
|
+
import { getStartOfDay } from './date-helpers.js';
|
|
5
|
+
import { CalendarHeader } from './calendar-header.js';
|
|
6
|
+
import { CalendarGrid } from './calendar-grid.js';
|
|
7
|
+
export function Calendar({ className, defaultFocusDay, minDate, maxDate, locale, weekStartsOn, nextMonthButtonLabel, prevMonthButtonLabel, getDayProps, onHoverDay, onFocusDay, onSelectDay, }) {
|
|
8
|
+
const [focusDay, setFocusDay] = useState(() => {
|
|
9
|
+
const focusDate = getStartOfDay(defaultFocusDay ?? new Date());
|
|
10
|
+
if (minDate && focusDate < minDate) {
|
|
11
|
+
return minDate;
|
|
12
|
+
}
|
|
13
|
+
if (maxDate && focusDate > maxDate) {
|
|
14
|
+
return maxDate;
|
|
15
|
+
}
|
|
16
|
+
return focusDate;
|
|
17
|
+
});
|
|
18
|
+
return (_jsxs("div", { className: classNames('dc-calendar', className), children: [_jsx(CalendarHeader, { focusDay: focusDay, onChangeFocusDay: setFocusDay, locale: locale, nextMonthButtonLabel: nextMonthButtonLabel, prevMonthButtonLabel: prevMonthButtonLabel }), _jsx(CalendarGrid, { focusDay: focusDay, minDate: minDate, maxDate: maxDate, locale: locale, weekStartsOn: weekStartsOn, getDayProps: getDayProps, onHoverDay: onHoverDay, onFocusDay: onFocusDay, onSelectDay: onSelectDay, onChangeFocusDay: setFocusDay })] }));
|
|
19
|
+
}
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
const MONTHS_IN_YEAR = 12;
|
|
2
|
-
const DAYS_IN_WEEK = 7;
|
|
3
|
-
const LAST_WEEKDAY = 6;
|
|
4
|
-
const DATE_ISO_REGEX = /^([0-9]{4})-?(1[0-2]|0[1-9])-?(3[0-1]|0[1-9]|[1-2][0-9])$/;
|
|
5
|
-
function addYears(date, amount) {
|
|
1
|
+
export const MONTHS_IN_YEAR = 12;
|
|
2
|
+
export const DAYS_IN_WEEK = 7;
|
|
3
|
+
export const LAST_WEEKDAY = 6;
|
|
4
|
+
export const DATE_ISO_REGEX = /^([0-9]{4})-?(1[0-2]|0[1-9])-?(3[0-1]|0[1-9]|[1-2][0-9])$/;
|
|
5
|
+
export function addYears(date, amount) {
|
|
6
6
|
// Use ISO date string to deal with years less than 100.
|
|
7
7
|
return parseDateISO(formatDateISOComponents(date.getFullYear() + amount, date.getMonth(), date.getDate()));
|
|
8
8
|
}
|
|
9
|
-
function setDateYear(date, year) {
|
|
9
|
+
export function setDateYear(date, year) {
|
|
10
10
|
// Use ISO date string to deal with years less than 100.
|
|
11
11
|
return parseDateISO(formatDateISOComponents(year, date.getMonth(), date.getDate()));
|
|
12
12
|
}
|
|
13
|
-
function addMonths(date, amount) {
|
|
13
|
+
export function addMonths(date, amount) {
|
|
14
14
|
date = new Date(date);
|
|
15
15
|
date.setMonth(date.getMonth() + amount);
|
|
16
16
|
return date;
|
|
17
17
|
}
|
|
18
|
-
function setDateMonth(date, month) {
|
|
18
|
+
export function setDateMonth(date, month) {
|
|
19
19
|
date = new Date(date);
|
|
20
20
|
date.setMonth(month);
|
|
21
21
|
return date;
|
|
22
22
|
}
|
|
23
|
-
function addDays(date, amount) {
|
|
23
|
+
export function addDays(date, amount) {
|
|
24
24
|
date = new Date(date);
|
|
25
25
|
date.setDate(date.getDate() + amount);
|
|
26
26
|
return date;
|
|
27
27
|
}
|
|
28
|
-
function getStartOfMonth(date) {
|
|
28
|
+
export function getStartOfMonth(date) {
|
|
29
29
|
date = new Date(date);
|
|
30
30
|
date.setDate(1);
|
|
31
31
|
return date;
|
|
32
32
|
}
|
|
33
|
-
function getEndOfMonth(date) {
|
|
33
|
+
export function getEndOfMonth(date) {
|
|
34
34
|
date = new Date(date);
|
|
35
35
|
date.setDate(1);
|
|
36
36
|
date.setMonth(date.getMonth() + 1);
|
|
37
37
|
date.setDate(0);
|
|
38
38
|
return date;
|
|
39
39
|
}
|
|
40
|
-
function getWeekday(date, weekStartsOn = 0) {
|
|
40
|
+
export function getWeekday(date, weekStartsOn = 0) {
|
|
41
41
|
let day = date.getDay() - weekStartsOn;
|
|
42
42
|
if (day < 0) {
|
|
43
43
|
day += DAYS_IN_WEEK;
|
|
44
44
|
}
|
|
45
45
|
return day;
|
|
46
46
|
}
|
|
47
|
-
function getStartOfWeek(date, weekStartsOn = 0) {
|
|
47
|
+
export function getStartOfWeek(date, weekStartsOn = 0) {
|
|
48
48
|
const weekday = getWeekday(date, weekStartsOn);
|
|
49
49
|
return addDays(date, -weekday);
|
|
50
50
|
}
|
|
51
|
-
function getEndOfWeek(date, weekStartsOn = 0) {
|
|
51
|
+
export function getEndOfWeek(date, weekStartsOn = 0) {
|
|
52
52
|
const weekday = getWeekday(date, weekStartsOn);
|
|
53
53
|
return addDays(date, LAST_WEEKDAY - weekday);
|
|
54
54
|
}
|
|
55
|
-
function getStartOfDay(date) {
|
|
55
|
+
export function getStartOfDay(date) {
|
|
56
56
|
date = new Date(date);
|
|
57
57
|
date.setHours(0);
|
|
58
58
|
date.setMinutes(0);
|
|
@@ -60,24 +60,24 @@ function getStartOfDay(date) {
|
|
|
60
60
|
date.setMilliseconds(0);
|
|
61
61
|
return date;
|
|
62
62
|
}
|
|
63
|
-
function isValidDateISO(value) {
|
|
63
|
+
export function isValidDateISO(value) {
|
|
64
64
|
return DATE_ISO_REGEX.test(value);
|
|
65
65
|
}
|
|
66
|
-
function isSameDay(a, b) {
|
|
66
|
+
export function isSameDay(a, b) {
|
|
67
67
|
return (a.getFullYear() === b.getFullYear() &&
|
|
68
68
|
a.getMonth() === b.getMonth() &&
|
|
69
69
|
a.getDate() === b.getDate());
|
|
70
70
|
}
|
|
71
|
-
function isWeekend(date) {
|
|
71
|
+
export function isWeekend(date) {
|
|
72
72
|
return date.getDay() === 6 || date.getDay() === 0;
|
|
73
73
|
}
|
|
74
|
-
function parseDateISO(date, error = 'The argument must be a date in the ISO format.') {
|
|
74
|
+
export function parseDateISO(date, error = 'The argument must be a date in the ISO format.') {
|
|
75
75
|
if (!isValidDateISO(date)) {
|
|
76
76
|
throw new RangeError(error);
|
|
77
77
|
}
|
|
78
78
|
return getStartOfDay(new Date(date));
|
|
79
79
|
}
|
|
80
|
-
function toDateISO(date) {
|
|
80
|
+
export function toDateISO(date) {
|
|
81
81
|
return formatDateISOComponents(date.getFullYear(), date.getMonth(), date.getDate());
|
|
82
82
|
}
|
|
83
83
|
function formatDateISOComponents(year, month, day) {
|
|
@@ -87,5 +87,3 @@ function formatDateISOComponents(year, month, day) {
|
|
|
87
87
|
String(day).padStart(2, '0'),
|
|
88
88
|
].join('-');
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
export { DATE_ISO_REGEX, DAYS_IN_WEEK, LAST_WEEKDAY, MONTHS_IN_YEAR, addDays, addMonths, addYears, getEndOfMonth, getEndOfWeek, getStartOfDay, getStartOfMonth, getStartOfWeek, getWeekday, isSameDay, isValidDateISO, isWeekend, parseDateISO, setDateMonth, setDateYear, toDateISO };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DateISO, Weekday } from './date-helpers';
|
|
1
|
+
import { DateISO, Weekday } from './date-helpers.js';
|
|
2
2
|
import { ComponentPropsWithoutRef } from 'react';
|
|
3
|
-
import { CalendarProps } from './calendar';
|
|
3
|
+
import { CalendarProps } from './calendar.js';
|
|
4
4
|
type DatePickerHTMLProps = ComponentPropsWithoutRef<'div'>;
|
|
5
5
|
export type DatePickerProps = {
|
|
6
6
|
value: DateISO | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { isSameDay, isValidDateISO, parseDateISO, toDateISO } from './date-helpers.js';
|
|
3
|
+
import { classNames } from '../../lib/react-helpers.js';
|
|
4
|
+
import { parseMinMaxProps } from './parse-min-max-props.js';
|
|
5
|
+
import { Calendar } from './calendar.js';
|
|
6
|
+
export function DatePicker({ value, onChangeValue, weekStartsOn = 1, min, max, locale, prevMonthButtonLabel, nextMonthButtonLabel, monthSelectLabel, yearInputLabel, className, ...props }) {
|
|
7
|
+
const { minDate, maxDate } = parseMinMaxProps({ min, max });
|
|
8
|
+
const selectedDay = value && isValidDateISO(value)
|
|
9
|
+
? parseDateISO(value)
|
|
10
|
+
: null;
|
|
11
|
+
const getDayProps = (date) => ({
|
|
12
|
+
isSelected: selectedDay != null && isSameDay(selectedDay, date),
|
|
13
|
+
});
|
|
14
|
+
return (_jsx("div", { ...props, className: classNames('dc-datepicker', className), children: _jsx(Calendar, { defaultFocusDay: selectedDay, minDate: minDate, maxDate: maxDate, locale: locale, weekStartsOn: weekStartsOn, prevMonthButtonLabel: prevMonthButtonLabel, nextMonthButtonLabel: nextMonthButtonLabel, monthSelectLabel: monthSelectLabel, yearInputLabel: yearInputLabel, getDayProps: getDayProps, onSelectDay: (date) => onChangeValue(toDateISO(date)) }) }));
|
|
15
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DateISORange } from './date-range';
|
|
2
|
-
import { DateISO, Weekday } from './date-helpers';
|
|
1
|
+
import { DateISORange } from './date-range.js';
|
|
2
|
+
import { DateISO, Weekday } from './date-helpers.js';
|
|
3
3
|
import { ComponentPropsWithoutRef } from 'react';
|
|
4
|
-
import { CalendarProps } from './calendar';
|
|
4
|
+
import { CalendarProps } from './calendar.js';
|
|
5
5
|
type DateRangePickerHTMLProps = ComponentPropsWithoutRef<'div'>;
|
|
6
6
|
export type DateRangePickerProps = {
|
|
7
7
|
value: DateISORange | null;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { jsx } from
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { DateRange } from './date-range.js';
|
|
3
|
-
import { isValidDateISO, parseDateISO
|
|
3
|
+
import { isSameDay, isValidDateISO, parseDateISO } from './date-helpers.js';
|
|
4
4
|
import { classNames } from '../../lib/react-helpers.js';
|
|
5
5
|
import { parseMinMaxProps } from './parse-min-max-props.js';
|
|
6
6
|
import { useState } from 'react';
|
|
7
7
|
import { Calendar } from './calendar.js';
|
|
8
|
-
|
|
9
|
-
function DateRangePicker({ value, onChangeValue, weekStartsOn = 1, min, max, locale, prevMonthButtonLabel, nextMonthButtonLabel, monthSelectLabel, yearInputLabel, className, ...props }) {
|
|
8
|
+
export function DateRangePicker({ value, onChangeValue, weekStartsOn = 1, min, max, locale, prevMonthButtonLabel, nextMonthButtonLabel, monthSelectLabel, yearInputLabel, className, ...props }) {
|
|
10
9
|
const { minDate, maxDate } = parseMinMaxProps({ min, max });
|
|
11
10
|
const selectedRange = parseValue(value);
|
|
12
11
|
const [start, setStart] = useState(null);
|
|
@@ -38,7 +37,7 @@ function DateRangePicker({ value, onChangeValue, weekStartsOn = 1, min, max, loc
|
|
|
38
37
|
setEnd(date);
|
|
39
38
|
}
|
|
40
39
|
};
|
|
41
|
-
return (
|
|
40
|
+
return (_jsx("div", { ...props, className: classNames('dc-datepicker', className), children: _jsx(Calendar, { defaultFocusDay: selectedRange?.start, minDate: minDate, maxDate: maxDate, locale: locale, weekStartsOn: weekStartsOn, prevMonthButtonLabel: prevMonthButtonLabel, nextMonthButtonLabel: nextMonthButtonLabel, monthSelectLabel: monthSelectLabel, yearInputLabel: yearInputLabel, getDayProps: getCalendarDayProps, onHoverDay: updateRange, onFocusDay: updateRange, onSelectDay: (date) => {
|
|
42
41
|
if (start) {
|
|
43
42
|
setStart(null);
|
|
44
43
|
setEnd(null);
|
|
@@ -55,5 +54,3 @@ function parseValue(value) {
|
|
|
55
54
|
}
|
|
56
55
|
return null;
|
|
57
56
|
}
|
|
58
|
-
|
|
59
|
-
export { DateRangePicker };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isSameDay, toDateISO } from './date-helpers.js';
|
|
2
|
-
|
|
3
|
-
class DateRange {
|
|
2
|
+
export class DateRange {
|
|
4
3
|
constructor(start, end) {
|
|
5
4
|
if (start > end) {
|
|
6
5
|
[start, end] = [end, start];
|
|
@@ -22,5 +21,3 @@ class DateRange {
|
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
export { DateRange };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { parseDateISO } from './date-helpers.js';
|
|
2
|
-
|
|
3
|
-
function parseMinMaxProps(props) {
|
|
2
|
+
export function parseMinMaxProps(props) {
|
|
4
3
|
const min = props.min;
|
|
5
4
|
const max = props.max;
|
|
6
5
|
const minDate = min
|
|
@@ -14,5 +13,3 @@ function parseMinMaxProps(props) {
|
|
|
14
13
|
}
|
|
15
14
|
return { minDate, maxDate };
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
export { parseMinMaxProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DateISO } from '../date-picker/date-helpers';
|
|
1
|
+
import { DateISO } from '../date-picker/date-helpers.js';
|
|
2
2
|
import { JSX, ReactNode } from 'react';
|
|
3
|
-
import { DatePickerProps } from '../date-picker';
|
|
3
|
+
import { DatePickerProps } from '../date-picker/index.js';
|
|
4
4
|
export type DatePickerChangeValueFn = (value: DateISO) => void;
|
|
5
5
|
export type DatePickerPopoverProps = {
|
|
6
6
|
className?: string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { classNames } from '../../lib/react-helpers.js';
|
|
3
|
+
import { useRef } from 'react';
|
|
4
|
+
import { Popover } from '../popover/index.js';
|
|
5
|
+
import { DatePicker } from '../date-picker/index.js';
|
|
6
|
+
export function DatePickerPopover({ defaultIsOpen = false, footer, className, children, value, onChangeValue,
|
|
7
|
+
// DatePickerProps
|
|
8
|
+
min, max, locale, weekStartsOn, prevMonthButtonLabel, nextMonthButtonLabel, monthSelectLabel, yearInputLabel, }) {
|
|
9
|
+
const popoverRef = useRef(null);
|
|
10
|
+
const handleChangeValue = (value) => {
|
|
11
|
+
onChangeValue(value);
|
|
12
|
+
popoverRef.current?.close();
|
|
13
|
+
};
|
|
14
|
+
return (_jsxs(Popover, { ref: popoverRef, className: classNames('dc-date-picker-popover', className), defaultIsOpen: defaultIsOpen, anchor: children, children: [_jsx(DatePicker, { min: min, max: max, locale: locale, weekStartsOn: weekStartsOn, prevMonthButtonLabel: prevMonthButtonLabel, nextMonthButtonLabel: nextMonthButtonLabel, monthSelectLabel: monthSelectLabel, yearInputLabel: yearInputLabel, value: value, onChangeValue: handleChangeValue }), footer] }));
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './date-picker-popover.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './date-picker-popover.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '../button/index.js';
|
|
3
|
+
export function DateRangePickerPopoverFooter({ children, cancelButtonLabel, confirmButtonLabel, onClickCancelButton, onClickConfirmButton, }) {
|
|
4
|
+
return (_jsxs("div", { className: "dc-date-range-picker-popover__footer", children: [Boolean(children) && (_jsx("div", { className: "dc-date-range-picker-popover__footer-content", children: children })), _jsx(Button, { className: "dc-date-range-picker-popover__footer-cancel", buttonStyle: "tinted", onClick: onClickCancelButton, children: cancelButtonLabel }), _jsx(Button, { className: "dc-date-range-picker-popover__footer-confirm", tint: "blue", onClick: onClickConfirmButton, children: confirmButtonLabel })] }));
|
|
5
|
+
}
|
package/{types → dist}/components/date-range-picker-popover/date-range-picker-popover-presets.d.ts
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateRangePickerPopoverOption, DateRangePickerPopoverSelection } from './types';
|
|
1
|
+
import { DateRangePickerPopoverOption, DateRangePickerPopoverSelection } from './types.js';
|
|
2
2
|
export type DateRangePickerPopoverPresetsProps = {
|
|
3
3
|
isCompactView: boolean;
|
|
4
4
|
customPresetLabel: string;
|