diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index d63416b292..4d6f8db243 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -192,6 +192,22 @@ export default defineConfig({ text: `Time Field ${BadgeHTML('Alpha', true)}`, link: '/docs/components/time-field', }, + { + text: `Month Picker ${BadgeHTML('Alpha', true)}`, + link: '/docs/components/month-picker', + }, + { + text: `Month Range Picker ${BadgeHTML('Alpha', true)}`, + link: '/docs/components/month-range-picker', + }, + { + text: `Year Picker ${BadgeHTML('Alpha', true)}`, + link: '/docs/components/year-picker', + }, + { + text: `Year Range Picker ${BadgeHTML('Alpha', true)}`, + link: '/docs/components/year-range-picker', + }, ], }, { @@ -317,6 +333,10 @@ export default defineConfig({ text: 'Date Picker Selection', link: '/examples/date-picker-selection', }, + { + text: 'Date Picker View Switching', + link: '/examples/date-picker-view-switching', + }, ], }, { diff --git a/docs/components/demo/MonthPicker/css/index.vue b/docs/components/demo/MonthPicker/css/index.vue new file mode 100644 index 0000000000..289c4e07d6 --- /dev/null +++ b/docs/components/demo/MonthPicker/css/index.vue @@ -0,0 +1,55 @@ + + + diff --git a/docs/components/demo/MonthPicker/css/styles.css b/docs/components/demo/MonthPicker/css/styles.css new file mode 100644 index 0000000000..2e65f27643 --- /dev/null +++ b/docs/components/demo/MonthPicker/css/styles.css @@ -0,0 +1,134 @@ +@import '@radix-ui/colors/black-alpha.css'; +@import '@radix-ui/colors/grass.css'; + +.Icon { + width: 1rem; + height: 1rem; +} + +.MonthPicker { + margin-top: 1.5rem; + border-radius: 0.75rem; + border: 1px solid #e5e5e5; + background-color: #ffffff; + box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); + padding: 1rem; +} + +.MonthPickerHeader { + display: flex; + justify-content: space-between; + align-items: center; +} + +.MonthPickerNavButton { + display: inline-flex; + justify-content: center; + align-items: center; + width: 2rem; + height: 2rem; + color: #000000; + background-color: transparent; + cursor: pointer; + border-radius: 0.375rem; +} + +.MonthPickerNavButton:hover { + background-color: #fafaf9; +} + +.MonthPickerNavButton:focus { + box-shadow: 0 0 0 2px #000000; +} + +.MonthPickerHeading { + font-size: 0.875rem; + font-weight: 500; + color: #000000; +} + +.MonthPickerWrapper { + padding-top: 1rem; +} + +.MonthPickerGrid { + width: 100%; + user-select: none; +} + +.MonthPickerGridWrapper { + display: grid; + gap: 0.25rem 0; +} + +.MonthPickerGridRow { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 0.25rem; +} + +.MonthPickerCell { + position: relative; + text-align: center; +} + +.MonthPickerCellTrigger { + position: relative; + display: flex; + justify-content: center; + align-items: center; + width: 3rem; + height: 3rem; + border-radius: 0.5rem; + font-size: 0.875rem; + font-weight: 400; + color: #000000; + background-color: transparent; + outline: none; + cursor: pointer; + border: none; +} + +.MonthPickerCellTrigger:hover { + background-color: var(--grass-5); +} + +.MonthPickerCellTrigger:focus { + box-shadow: 0 0 0 2px #000000; +} + +.MonthPickerCellTrigger[data-disabled] { + color: rgba(0, 0, 0, 0.3); + pointer-events: none; +} + +.MonthPickerCellTrigger[data-selected] { + background-color: var(--grass-10); + color: #ffffff; + font-weight: 500; +} + +.MonthPickerCellTrigger[data-unavailable] { + color: rgba(0, 0, 0, 0.3); + text-decoration: line-through; + pointer-events: none; +} + +.MonthPickerCellTrigger::before { + content: ''; + position: absolute; + top: 0.25rem; + width: 0.25rem; + height: 0.25rem; + border-radius: 9999px; + display: none; +} + +.MonthPickerCellTrigger[data-today]::before { + display: block; + background-color: var(--grass-9); +} + +.MonthPickerCellTrigger[data-selected]::before { + background-color: #ffffff; +} diff --git a/docs/components/demo/MonthPicker/tailwind/index.vue b/docs/components/demo/MonthPicker/tailwind/index.vue new file mode 100644 index 0000000000..79d184f5c2 --- /dev/null +++ b/docs/components/demo/MonthPicker/tailwind/index.vue @@ -0,0 +1,58 @@ + + + diff --git a/docs/components/demo/MonthPicker/tailwind/tailwind.config.js b/docs/components/demo/MonthPicker/tailwind/tailwind.config.js new file mode 100644 index 0000000000..a9c58386b0 --- /dev/null +++ b/docs/components/demo/MonthPicker/tailwind/tailwind.config.js @@ -0,0 +1,16 @@ +const { blackA, grass, green } = require('@radix-ui/colors') + +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: ['./**/*.vue'], + theme: { + extend: { + colors: { + ...blackA, + ...grass, + ...green, + }, + }, + }, + plugins: [], +} diff --git a/docs/components/demo/MonthRangePicker/css/index.vue b/docs/components/demo/MonthRangePicker/css/index.vue new file mode 100644 index 0000000000..0858f6e5be --- /dev/null +++ b/docs/components/demo/MonthRangePicker/css/index.vue @@ -0,0 +1,58 @@ + + + diff --git a/docs/components/demo/MonthRangePicker/css/styles.css b/docs/components/demo/MonthRangePicker/css/styles.css new file mode 100644 index 0000000000..b24b1a737c --- /dev/null +++ b/docs/components/demo/MonthRangePicker/css/styles.css @@ -0,0 +1,138 @@ +@import '@radix-ui/colors/black-alpha.css'; +@import '@radix-ui/colors/grass.css'; + +.Icon { + width: 1rem; + height: 1rem; +} + +.MonthRangePicker { + margin-top: 1.5rem; + border-radius: 0.75rem; + border: 1px solid #e5e5e5; + background-color: #ffffff; + box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); + padding: 1rem; +} + +.MonthRangePickerHeader { + display: flex; + justify-content: space-between; + align-items: center; +} + +.MonthRangePickerNavButton { + display: inline-flex; + justify-content: center; + align-items: center; + width: 2rem; + height: 2rem; + color: #000000; + background-color: transparent; + cursor: pointer; + border-radius: 0.375rem; +} + +.MonthRangePickerNavButton:hover { + background-color: #fafaf9; +} + +.MonthRangePickerNavButton:focus { + box-shadow: 0 0 0 2px #000000; +} + +.MonthRangePickerHeading { + font-size: 0.875rem; + font-weight: 500; + color: #000000; +} + +.MonthRangePickerWrapper { + padding-top: 1rem; +} + +.MonthRangePickerGrid { + width: 100%; + user-select: none; +} + +.MonthRangePickerGridWrapper { + display: grid; + gap: 0.25rem 0; +} + +.MonthRangePickerGridRow { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 0.25rem; +} + +.MonthRangePickerCell { + position: relative; + text-align: center; +} + +.MonthRangePickerCellTrigger { + position: relative; + display: flex; + justify-content: center; + align-items: center; + width: 3rem; + height: 3rem; + border-radius: 0.5rem; + font-size: 0.875rem; + font-weight: 400; + color: #000000; + background-color: transparent; + outline: none; + cursor: pointer; + border: none; +} + +.MonthRangePickerCellTrigger:hover { + background-color: var(--grass-5); +} + +.MonthRangePickerCellTrigger:focus { + box-shadow: 0 0 0 2px #000000; +} + +.MonthRangePickerCellTrigger[data-disabled] { + color: rgba(0, 0, 0, 0.3); + pointer-events: none; +} + +.MonthRangePickerCellTrigger[data-selected] { + background-color: var(--grass-10); + color: #ffffff; + font-weight: 500; +} + +.MonthRangePickerCellTrigger[data-highlighted] { + background-color: var(--grass-5); +} + +.MonthRangePickerCellTrigger[data-unavailable] { + color: rgba(0, 0, 0, 0.3); + text-decoration: line-through; + pointer-events: none; +} + +.MonthRangePickerCellTrigger::before { + content: ''; + position: absolute; + top: 0.25rem; + width: 0.25rem; + height: 0.25rem; + border-radius: 9999px; + display: none; +} + +.MonthRangePickerCellTrigger[data-today]::before { + display: block; + background-color: var(--grass-9); +} + +.MonthRangePickerCellTrigger[data-selected]::before { + background-color: #ffffff; +} diff --git a/docs/components/demo/MonthRangePicker/tailwind/index.vue b/docs/components/demo/MonthRangePicker/tailwind/index.vue new file mode 100644 index 0000000000..7c1888f6cf --- /dev/null +++ b/docs/components/demo/MonthRangePicker/tailwind/index.vue @@ -0,0 +1,61 @@ + + + diff --git a/docs/components/demo/YearPicker/css/index.vue b/docs/components/demo/YearPicker/css/index.vue new file mode 100644 index 0000000000..84d04d67cd --- /dev/null +++ b/docs/components/demo/YearPicker/css/index.vue @@ -0,0 +1,55 @@ + + + diff --git a/docs/components/demo/YearPicker/css/styles.css b/docs/components/demo/YearPicker/css/styles.css new file mode 100644 index 0000000000..eb8edea63a --- /dev/null +++ b/docs/components/demo/YearPicker/css/styles.css @@ -0,0 +1,134 @@ +@import '@radix-ui/colors/black-alpha.css'; +@import '@radix-ui/colors/grass.css'; + +.Icon { + width: 1rem; + height: 1rem; +} + +.YearPicker { + margin-top: 1.5rem; + border-radius: 0.75rem; + border: 1px solid #e5e5e5; + background-color: #ffffff; + box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); + padding: 1rem; +} + +.YearPickerHeader { + display: flex; + justify-content: space-between; + align-items: center; +} + +.YearPickerNavButton { + display: inline-flex; + justify-content: center; + align-items: center; + width: 2rem; + height: 2rem; + color: #000000; + background-color: transparent; + cursor: pointer; + border-radius: 0.375rem; +} + +.YearPickerNavButton:hover { + background-color: #fafaf9; +} + +.YearPickerNavButton:focus { + box-shadow: 0 0 0 2px #000000; +} + +.YearPickerHeading { + font-size: 0.875rem; + font-weight: 500; + color: #000000; +} + +.YearPickerWrapper { + padding-top: 1rem; +} + +.YearPickerGrid { + width: 100%; + user-select: none; +} + +.YearPickerGridWrapper { + display: grid; + gap: 0.25rem 0; +} + +.YearPickerGridRow { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 0.25rem; +} + +.YearPickerCell { + position: relative; + text-align: center; +} + +.YearPickerCellTrigger { + position: relative; + display: flex; + justify-content: center; + align-items: center; + width: 3rem; + height: 3rem; + border-radius: 0.5rem; + font-size: 0.875rem; + font-weight: 400; + color: #000000; + background-color: transparent; + outline: none; + cursor: pointer; + border: none; +} + +.YearPickerCellTrigger:hover { + background-color: var(--grass-5); +} + +.YearPickerCellTrigger:focus { + box-shadow: 0 0 0 2px #000000; +} + +.YearPickerCellTrigger[data-disabled] { + color: rgba(0, 0, 0, 0.3); + pointer-events: none; +} + +.YearPickerCellTrigger[data-selected] { + background-color: var(--grass-10); + color: #ffffff; + font-weight: 500; +} + +.YearPickerCellTrigger[data-unavailable] { + color: rgba(0, 0, 0, 0.3); + text-decoration: line-through; + pointer-events: none; +} + +.YearPickerCellTrigger::before { + content: ''; + position: absolute; + top: 0.25rem; + width: 0.25rem; + height: 0.25rem; + border-radius: 9999px; + display: none; +} + +.YearPickerCellTrigger[data-today]::before { + display: block; + background-color: var(--grass-9); +} + +.YearPickerCellTrigger[data-selected]::before { + background-color: #ffffff; +} diff --git a/docs/components/demo/YearPicker/tailwind/index.vue b/docs/components/demo/YearPicker/tailwind/index.vue new file mode 100644 index 0000000000..619dc2556e --- /dev/null +++ b/docs/components/demo/YearPicker/tailwind/index.vue @@ -0,0 +1,58 @@ + + + diff --git a/docs/components/demo/YearPicker/tailwind/tailwind.config.js b/docs/components/demo/YearPicker/tailwind/tailwind.config.js new file mode 100644 index 0000000000..a9c58386b0 --- /dev/null +++ b/docs/components/demo/YearPicker/tailwind/tailwind.config.js @@ -0,0 +1,16 @@ +const { blackA, grass, green } = require('@radix-ui/colors') + +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: ['./**/*.vue'], + theme: { + extend: { + colors: { + ...blackA, + ...grass, + ...green, + }, + }, + }, + plugins: [], +} diff --git a/docs/components/demo/YearRangePicker/css/index.vue b/docs/components/demo/YearRangePicker/css/index.vue new file mode 100644 index 0000000000..0c2c5706eb --- /dev/null +++ b/docs/components/demo/YearRangePicker/css/index.vue @@ -0,0 +1,58 @@ + + + diff --git a/docs/components/demo/YearRangePicker/css/styles.css b/docs/components/demo/YearRangePicker/css/styles.css new file mode 100644 index 0000000000..e9025b2974 --- /dev/null +++ b/docs/components/demo/YearRangePicker/css/styles.css @@ -0,0 +1,138 @@ +@import '@radix-ui/colors/black-alpha.css'; +@import '@radix-ui/colors/grass.css'; + +.Icon { + width: 1rem; + height: 1rem; +} + +.YearRangePicker { + margin-top: 1.5rem; + border-radius: 0.75rem; + border: 1px solid #e5e5e5; + background-color: #ffffff; + box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); + padding: 1rem; +} + +.YearRangePickerHeader { + display: flex; + justify-content: space-between; + align-items: center; +} + +.YearRangePickerNavButton { + display: inline-flex; + justify-content: center; + align-items: center; + width: 2rem; + height: 2rem; + color: #000000; + background-color: transparent; + cursor: pointer; + border-radius: 0.375rem; +} + +.YearRangePickerNavButton:hover { + background-color: #fafaf9; +} + +.YearRangePickerNavButton:focus { + box-shadow: 0 0 0 2px #000000; +} + +.YearRangePickerHeading { + font-size: 0.875rem; + font-weight: 500; + color: #000000; +} + +.YearRangePickerWrapper { + padding-top: 1rem; +} + +.YearRangePickerGrid { + width: 100%; + user-select: none; +} + +.YearRangePickerGridWrapper { + display: grid; + gap: 0.25rem 0; +} + +.YearRangePickerGridRow { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 0.25rem; +} + +.YearRangePickerCell { + position: relative; + text-align: center; +} + +.YearRangePickerCellTrigger { + position: relative; + display: flex; + justify-content: center; + align-items: center; + width: 3rem; + height: 3rem; + border-radius: 0.5rem; + font-size: 0.875rem; + font-weight: 400; + color: #000000; + background-color: transparent; + outline: none; + cursor: pointer; + border: none; +} + +.YearRangePickerCellTrigger:hover { + background-color: var(--grass-5); +} + +.YearRangePickerCellTrigger:focus { + box-shadow: 0 0 0 2px #000000; +} + +.YearRangePickerCellTrigger[data-disabled] { + color: rgba(0, 0, 0, 0.3); + pointer-events: none; +} + +.YearRangePickerCellTrigger[data-selected] { + background-color: var(--grass-10); + color: #ffffff; + font-weight: 500; +} + +.YearRangePickerCellTrigger[data-highlighted] { + background-color: var(--grass-5); +} + +.YearRangePickerCellTrigger[data-unavailable] { + color: rgba(0, 0, 0, 0.3); + text-decoration: line-through; + pointer-events: none; +} + +.YearRangePickerCellTrigger::before { + content: ''; + position: absolute; + top: 0.25rem; + width: 0.25rem; + height: 0.25rem; + border-radius: 9999px; + display: none; +} + +.YearRangePickerCellTrigger[data-today]::before { + display: block; + background-color: var(--grass-9); +} + +.YearRangePickerCellTrigger[data-selected]::before { + background-color: #ffffff; +} diff --git a/docs/components/demo/YearRangePicker/tailwind/index.vue b/docs/components/demo/YearRangePicker/tailwind/index.vue new file mode 100644 index 0000000000..20c0d9c465 --- /dev/null +++ b/docs/components/demo/YearRangePicker/tailwind/index.vue @@ -0,0 +1,61 @@ + + + diff --git a/docs/components/examples/DatePickerViewSwitching/index.vue b/docs/components/examples/DatePickerViewSwitching/index.vue new file mode 100644 index 0000000000..06e3c6fc7f --- /dev/null +++ b/docs/components/examples/DatePickerViewSwitching/index.vue @@ -0,0 +1,342 @@ + + + diff --git a/docs/content/docs/components/month-picker.md b/docs/content/docs/components/month-picker.md new file mode 100644 index 0000000000..e724f9ff93 --- /dev/null +++ b/docs/content/docs/components/month-picker.md @@ -0,0 +1,285 @@ +--- + +title: MonthPicker +description: Presents a calendar view tailored for selecting months. +name: month-picker +--- + +# Month Picker + +Alpha + + +Presents a calendar view tailored for selecting months. + + + + +## Features + + + +## Preface + +The component depends on the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html) package, which solves a lot of the problems that come with working with dates and times in JavaScript. + +We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components. + +## Installation + +Install the date package. + + + +Install the component from your command line. + + + +## Anatomy + +Import all parts and piece them together. + +```vue + + + +``` + +## API Reference + +### Root + +Contains all the parts of a month picker + + + + + +### Header + +Contains the navigation buttons and the heading segments. + + + +### Prev Button + +Calendar navigation button. It navigates the calendar one year in the past. + + + + + +### Next Button + +Calendar navigation button. It navigates the calendar one year in the future. + + + + + +### Heading + +Heading for displaying the current year. + + + + + +### Grid + +Container for wrapping the month picker grid. + + + + + +### Grid Body + +Container for wrapping the grid body. + + + +### Grid Row + +Container for wrapping the grid row. + + + +### Cell + +Container for wrapping the month picker cells. + + + + + +### Cell Trigger + +Interactable container for displaying the cell months. Clicking it selects the month. + + + + + +## Accessibility + +### Keyboard Interactions + + diff --git a/docs/content/docs/components/month-range-picker.md b/docs/content/docs/components/month-range-picker.md new file mode 100644 index 0000000000..14be445b4c --- /dev/null +++ b/docs/content/docs/components/month-range-picker.md @@ -0,0 +1,309 @@ +--- + +title: MonthRangePicker +description: Presents a calendar view tailored for selecting month ranges. +name: month-range-picker +--- + +# Month Range Picker + +Alpha + + +Presents a calendar view tailored for selecting month ranges. + + + + +## Features + + + +## Preface + +The component depends on the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html) package, which solves a lot of the problems that come with working with dates and times in JavaScript. + +We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components. + +## Installation + +Install the date package. + + + +Install the component from your command line. + + + +## Anatomy + +Import all parts and piece them together. + +```vue + + + +``` + +## API Reference + +### Root + +Contains all the parts of a month range picker + + + + + +### Header + +Contains the navigation buttons and the heading segments. + + + +### Prev Button + +Calendar navigation button. It navigates the calendar one year in the past. + + + + + +### Next Button + +Calendar navigation button. It navigates the calendar one year in the future. + + + + + +### Heading + +Heading for displaying the current year. + + + + + +### Grid + +Container for wrapping the month range picker grid. + + + + + +### Grid Body + +Container for wrapping the grid body. + + + +### Grid Row + +Container for wrapping the grid row. + + + +### Cell + +Container for wrapping the month range picker cells. + + + + + +### Cell Trigger + +Interactable container for displaying the cell months. Clicking it selects the month. + + + + + +## Accessibility + +### Keyboard Interactions + + diff --git a/docs/content/docs/components/year-picker.md b/docs/content/docs/components/year-picker.md new file mode 100644 index 0000000000..c898fd33da --- /dev/null +++ b/docs/content/docs/components/year-picker.md @@ -0,0 +1,286 @@ +--- + +title: YearPicker +description: Presents a calendar view tailored for selecting years. +name: year-picker +--- + +# Year Picker + +Alpha + + +Presents a calendar view tailored for selecting years. + + + + +## Features + + + +## Preface + +The component depends on the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html) package, which solves a lot of the problems that come with working with dates and times in JavaScript. + +We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components. + +## Installation + +Install the date package. + + + +Install the component from your command line. + + + +## Anatomy + +Import all parts and piece them together. + +```vue + + + +``` + +## API Reference + +### Root + +Contains all the parts of a year picker + + + + + +### Header + +Contains the navigation buttons and the heading segments. + + + +### Prev Button + +Calendar navigation button. It navigates the calendar one page (default: 12 years) in the past. + + + + + +### Next Button + +Calendar navigation button. It navigates the calendar one page (default: 12 years) in the future. + + + + + +### Heading + +Heading for displaying the current year range (e.g., "2020 - 2031"). + + + + + +### Grid + +Container for wrapping the year picker grid. + + + + + +### Grid Body + +Container for wrapping the grid body. + + + +### Grid Row + +Container for wrapping the grid row. + + + +### Cell + +Container for wrapping the year picker cells. + + + + + +### Cell Trigger + +Interactable container for displaying the cell years. Clicking it selects the year. + + + + + +## Accessibility + +### Keyboard Interactions + + diff --git a/docs/content/docs/components/year-range-picker.md b/docs/content/docs/components/year-range-picker.md new file mode 100644 index 0000000000..09bf163d01 --- /dev/null +++ b/docs/content/docs/components/year-range-picker.md @@ -0,0 +1,309 @@ +--- + +title: YearRangePicker +description: Presents a calendar view tailored for selecting year ranges. +name: year-range-picker +--- + +# Year Range Picker + +Alpha + + +Presents a calendar view tailored for selecting year ranges. + + + + +## Features + + + +## Preface + +The component depends on the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html) package, which solves a lot of the problems that come with working with dates and times in JavaScript. + +We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components. + +## Installation + +Install the date package. + + + +Install the component from your command line. + + + +## Anatomy + +Import all parts and piece them together. + +```vue + + + +``` + +## API Reference + +### Root + +Contains all the parts of a year range picker + + + + + +### Header + +Contains the navigation buttons and the heading segments. + + + +### Prev Button + +Calendar navigation button. It navigates the calendar one page (12 years by default) in the past. + + + + + +### Next Button + +Calendar navigation button. It navigates the calendar one page (12 years by default) in the future. + + + + + +### Heading + +Heading for displaying the current year range. + + + + + +### Grid + +Container for wrapping the year range picker grid. + + + + + +### Grid Body + +Container for wrapping the grid body. + + + +### Grid Row + +Container for wrapping the grid row. + + + +### Cell + +Container for wrapping the year range picker cells. + + + + + +### Cell Trigger + +Interactable container for displaying the cell years. Clicking it selects the year. + + + + + +## Accessibility + +### Keyboard Interactions + + diff --git a/docs/content/examples/date-picker-view-switching.md b/docs/content/examples/date-picker-view-switching.md new file mode 100644 index 0000000000..b20c2e239c --- /dev/null +++ b/docs/content/examples/date-picker-view-switching.md @@ -0,0 +1,27 @@ +--- +title: Date Picker View Switching +tags: + - Calendar + - Month Picker + - Year Picker +--- + +# Date Picker View Switching + + + +Compose Calendar, MonthPicker, and YearPicker to create a date picker with drill-down view switching. + + + + + + + + + +### View Switching Pattern + +Click the month or year in the header to switch views. Selecting a month returns to day view, selecting a year returns to month view. Common pattern in native OS calendars and libraries like Mantine. + + diff --git a/docs/content/meta/MonthPickerCell.md b/docs/content/meta/MonthPickerCell.md new file mode 100644 index 0000000000..b8649ecb13 --- /dev/null +++ b/docs/content/meta/MonthPickerCell.md @@ -0,0 +1,23 @@ + + + diff --git a/docs/content/meta/MonthPickerCellTrigger.md b/docs/content/meta/MonthPickerCellTrigger.md new file mode 100644 index 0000000000..3faa3e370b --- /dev/null +++ b/docs/content/meta/MonthPickerCellTrigger.md @@ -0,0 +1,51 @@ + + + + + diff --git a/docs/content/meta/MonthPickerGrid.md b/docs/content/meta/MonthPickerGrid.md new file mode 100644 index 0000000000..61391feab0 --- /dev/null +++ b/docs/content/meta/MonthPickerGrid.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/MonthPickerGridBody.md b/docs/content/meta/MonthPickerGridBody.md new file mode 100644 index 0000000000..2500824059 --- /dev/null +++ b/docs/content/meta/MonthPickerGridBody.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/MonthPickerGridRow.md b/docs/content/meta/MonthPickerGridRow.md new file mode 100644 index 0000000000..bfc07e1195 --- /dev/null +++ b/docs/content/meta/MonthPickerGridRow.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/MonthPickerHeader.md b/docs/content/meta/MonthPickerHeader.md new file mode 100644 index 0000000000..5df63e84f6 --- /dev/null +++ b/docs/content/meta/MonthPickerHeader.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/MonthPickerHeading.md b/docs/content/meta/MonthPickerHeading.md new file mode 100644 index 0000000000..c3d2efbd64 --- /dev/null +++ b/docs/content/meta/MonthPickerHeading.md @@ -0,0 +1,25 @@ + + + + + diff --git a/docs/content/meta/MonthPickerNext.md b/docs/content/meta/MonthPickerNext.md new file mode 100644 index 0000000000..07f0c8eacc --- /dev/null +++ b/docs/content/meta/MonthPickerNext.md @@ -0,0 +1,31 @@ + + + + + diff --git a/docs/content/meta/MonthPickerPrev.md b/docs/content/meta/MonthPickerPrev.md new file mode 100644 index 0000000000..ab1b02dceb --- /dev/null +++ b/docs/content/meta/MonthPickerPrev.md @@ -0,0 +1,31 @@ + + + + + diff --git a/docs/content/meta/MonthPickerRoot.md b/docs/content/meta/MonthPickerRoot.md new file mode 100644 index 0000000000..77f242ac7b --- /dev/null +++ b/docs/content/meta/MonthPickerRoot.md @@ -0,0 +1,179 @@ + + + + + + + + + diff --git a/docs/content/meta/MonthRangePickerCell.md b/docs/content/meta/MonthRangePickerCell.md new file mode 100644 index 0000000000..b8649ecb13 --- /dev/null +++ b/docs/content/meta/MonthRangePickerCell.md @@ -0,0 +1,23 @@ + + + diff --git a/docs/content/meta/MonthRangePickerCellTrigger.md b/docs/content/meta/MonthRangePickerCellTrigger.md new file mode 100644 index 0000000000..fd00f57fb9 --- /dev/null +++ b/docs/content/meta/MonthRangePickerCellTrigger.md @@ -0,0 +1,76 @@ + + + + + diff --git a/docs/content/meta/MonthRangePickerGrid.md b/docs/content/meta/MonthRangePickerGrid.md new file mode 100644 index 0000000000..61391feab0 --- /dev/null +++ b/docs/content/meta/MonthRangePickerGrid.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/MonthRangePickerGridBody.md b/docs/content/meta/MonthRangePickerGridBody.md new file mode 100644 index 0000000000..2500824059 --- /dev/null +++ b/docs/content/meta/MonthRangePickerGridBody.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/MonthRangePickerGridRow.md b/docs/content/meta/MonthRangePickerGridRow.md new file mode 100644 index 0000000000..bfc07e1195 --- /dev/null +++ b/docs/content/meta/MonthRangePickerGridRow.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/MonthRangePickerHeader.md b/docs/content/meta/MonthRangePickerHeader.md new file mode 100644 index 0000000000..5df63e84f6 --- /dev/null +++ b/docs/content/meta/MonthRangePickerHeader.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/MonthRangePickerHeading.md b/docs/content/meta/MonthRangePickerHeading.md new file mode 100644 index 0000000000..c3d2efbd64 --- /dev/null +++ b/docs/content/meta/MonthRangePickerHeading.md @@ -0,0 +1,25 @@ + + + + + diff --git a/docs/content/meta/MonthRangePickerNext.md b/docs/content/meta/MonthRangePickerNext.md new file mode 100644 index 0000000000..5838b47ce0 --- /dev/null +++ b/docs/content/meta/MonthRangePickerNext.md @@ -0,0 +1,31 @@ + + + + + diff --git a/docs/content/meta/MonthRangePickerPrev.md b/docs/content/meta/MonthRangePickerPrev.md new file mode 100644 index 0000000000..1cd8ed9dcf --- /dev/null +++ b/docs/content/meta/MonthRangePickerPrev.md @@ -0,0 +1,31 @@ + + + + + diff --git a/docs/content/meta/MonthRangePickerRoot.md b/docs/content/meta/MonthRangePickerRoot.md new file mode 100644 index 0000000000..184e9695fd --- /dev/null +++ b/docs/content/meta/MonthRangePickerRoot.md @@ -0,0 +1,197 @@ + + + + + + + + + diff --git a/docs/content/meta/YearPickerCell.md b/docs/content/meta/YearPickerCell.md new file mode 100644 index 0000000000..b8649ecb13 --- /dev/null +++ b/docs/content/meta/YearPickerCell.md @@ -0,0 +1,23 @@ + + + diff --git a/docs/content/meta/YearPickerCellTrigger.md b/docs/content/meta/YearPickerCellTrigger.md new file mode 100644 index 0000000000..a9c040ae1c --- /dev/null +++ b/docs/content/meta/YearPickerCellTrigger.md @@ -0,0 +1,51 @@ + + + + + diff --git a/docs/content/meta/YearPickerGrid.md b/docs/content/meta/YearPickerGrid.md new file mode 100644 index 0000000000..61391feab0 --- /dev/null +++ b/docs/content/meta/YearPickerGrid.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/YearPickerGridBody.md b/docs/content/meta/YearPickerGridBody.md new file mode 100644 index 0000000000..2500824059 --- /dev/null +++ b/docs/content/meta/YearPickerGridBody.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/YearPickerGridRow.md b/docs/content/meta/YearPickerGridRow.md new file mode 100644 index 0000000000..bfc07e1195 --- /dev/null +++ b/docs/content/meta/YearPickerGridRow.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/YearPickerHeader.md b/docs/content/meta/YearPickerHeader.md new file mode 100644 index 0000000000..5df63e84f6 --- /dev/null +++ b/docs/content/meta/YearPickerHeader.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/YearPickerHeading.md b/docs/content/meta/YearPickerHeading.md new file mode 100644 index 0000000000..6fa583631d --- /dev/null +++ b/docs/content/meta/YearPickerHeading.md @@ -0,0 +1,25 @@ + + + + + diff --git a/docs/content/meta/YearPickerNext.md b/docs/content/meta/YearPickerNext.md new file mode 100644 index 0000000000..16d0a829b7 --- /dev/null +++ b/docs/content/meta/YearPickerNext.md @@ -0,0 +1,31 @@ + + + + + diff --git a/docs/content/meta/YearPickerPrev.md b/docs/content/meta/YearPickerPrev.md new file mode 100644 index 0000000000..5cdff064f9 --- /dev/null +++ b/docs/content/meta/YearPickerPrev.md @@ -0,0 +1,31 @@ + + + + + diff --git a/docs/content/meta/YearPickerRoot.md b/docs/content/meta/YearPickerRoot.md new file mode 100644 index 0000000000..5390c0980b --- /dev/null +++ b/docs/content/meta/YearPickerRoot.md @@ -0,0 +1,186 @@ + + + + + + + + + diff --git a/docs/content/meta/YearRangePickerCell.md b/docs/content/meta/YearRangePickerCell.md new file mode 100644 index 0000000000..b8649ecb13 --- /dev/null +++ b/docs/content/meta/YearRangePickerCell.md @@ -0,0 +1,23 @@ + + + diff --git a/docs/content/meta/YearRangePickerCellTrigger.md b/docs/content/meta/YearRangePickerCellTrigger.md new file mode 100644 index 0000000000..69b50f2180 --- /dev/null +++ b/docs/content/meta/YearRangePickerCellTrigger.md @@ -0,0 +1,76 @@ + + + + + diff --git a/docs/content/meta/YearRangePickerGrid.md b/docs/content/meta/YearRangePickerGrid.md new file mode 100644 index 0000000000..61391feab0 --- /dev/null +++ b/docs/content/meta/YearRangePickerGrid.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/YearRangePickerGridBody.md b/docs/content/meta/YearRangePickerGridBody.md new file mode 100644 index 0000000000..2500824059 --- /dev/null +++ b/docs/content/meta/YearRangePickerGridBody.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/YearRangePickerGridRow.md b/docs/content/meta/YearRangePickerGridRow.md new file mode 100644 index 0000000000..bfc07e1195 --- /dev/null +++ b/docs/content/meta/YearRangePickerGridRow.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/YearRangePickerHeader.md b/docs/content/meta/YearRangePickerHeader.md new file mode 100644 index 0000000000..5df63e84f6 --- /dev/null +++ b/docs/content/meta/YearRangePickerHeader.md @@ -0,0 +1,17 @@ + + + diff --git a/docs/content/meta/YearRangePickerHeading.md b/docs/content/meta/YearRangePickerHeading.md new file mode 100644 index 0000000000..6fa583631d --- /dev/null +++ b/docs/content/meta/YearRangePickerHeading.md @@ -0,0 +1,25 @@ + + + + + diff --git a/docs/content/meta/YearRangePickerNext.md b/docs/content/meta/YearRangePickerNext.md new file mode 100644 index 0000000000..5838b47ce0 --- /dev/null +++ b/docs/content/meta/YearRangePickerNext.md @@ -0,0 +1,31 @@ + + + + + diff --git a/docs/content/meta/YearRangePickerPrev.md b/docs/content/meta/YearRangePickerPrev.md new file mode 100644 index 0000000000..1cd8ed9dcf --- /dev/null +++ b/docs/content/meta/YearRangePickerPrev.md @@ -0,0 +1,31 @@ + + + + + diff --git a/docs/content/meta/YearRangePickerRoot.md b/docs/content/meta/YearRangePickerRoot.md new file mode 100644 index 0000000000..057e606404 --- /dev/null +++ b/docs/content/meta/YearRangePickerRoot.md @@ -0,0 +1,204 @@ + + + + + + + + + diff --git a/docs/scripts/autogen.ts b/docs/scripts/autogen.ts index 3535e903d4..33e19ab75d 100644 --- a/docs/scripts/autogen.ts +++ b/docs/scripts/autogen.ts @@ -31,6 +31,12 @@ const eventDescriptionMap = new Map() const depTree = new Map() let prevDeps: string[] = [] +function toSingleQuotedJson(obj: unknown): string { + return JSON.stringify(obj, null, 2) + .replace(/'/g, '\\\'') + .replace(/"/g, '\'') +} + const allComponents = fg.sync(['src/**/*.vue', '!src/**/story/*.vue', '!src/**/*.story.vue'], { cwd: resolve(__dirname, '../../packages/core'), absolute: true, @@ -62,19 +68,11 @@ primitiveComponents.forEach((componentPath) => { const meta = parseMeta(tsconfigChecker.getComponentMeta(componentPath)) const metaDirPath = resolve(__dirname, '../content/meta') - // if meta dir doesn't exist create mkdirSync(metaDirPath, { recursive: true }) const metaMdFilePath = join(metaDirPath, `${componentName}.md`) - // Convert JSON to single-quoted format safely by escaping existing single quotes first - function toSingleQuotedJson(obj: unknown): string { - return JSON.stringify(obj, null, 2) - .replace(/'/g, '\\\'') // Escape existing single quotes - .replace(/"/g, '\'') // Then convert double quotes to single - } - - let parsedString = '\n\n' + let parsedString = '\n\n' if (meta.props.length) parsedString += `\n` diff --git a/packages/core/constant/components.ts b/packages/core/constant/components.ts index 8a82a11111..baf7c1846d 100644 --- a/packages/core/constant/components.ts +++ b/packages/core/constant/components.ts @@ -232,6 +232,32 @@ export const components = { 'MenubarMenu', ] as const, + monthPicker: [ + 'MonthPickerRoot', + 'MonthPickerHeader', + 'MonthPickerHeading', + 'MonthPickerGrid', + 'MonthPickerCell', + 'MonthPickerNext', + 'MonthPickerPrev', + 'MonthPickerGridBody', + 'MonthPickerGridRow', + 'MonthPickerCellTrigger', + ] as const, + + monthRangePicker: [ + 'MonthRangePickerRoot', + 'MonthRangePickerHeader', + 'MonthRangePickerHeading', + 'MonthRangePickerGrid', + 'MonthRangePickerCell', + 'MonthRangePickerNext', + 'MonthRangePickerPrev', + 'MonthRangePickerGridBody', + 'MonthRangePickerGridRow', + 'MonthRangePickerCellTrigger', + ] as const, + navigationMenu: [ 'NavigationMenuRoot', 'NavigationMenuContent', @@ -432,6 +458,32 @@ export const components = { 'Viewport', ] as const, + yearPicker: [ + 'YearPickerRoot', + 'YearPickerHeader', + 'YearPickerHeading', + 'YearPickerGrid', + 'YearPickerCell', + 'YearPickerNext', + 'YearPickerPrev', + 'YearPickerGridBody', + 'YearPickerGridRow', + 'YearPickerCellTrigger', + ] as const, + + yearRangePicker: [ + 'YearRangePickerRoot', + 'YearRangePickerHeader', + 'YearRangePickerHeading', + 'YearRangePickerGrid', + 'YearRangePickerCell', + 'YearRangePickerNext', + 'YearRangePickerPrev', + 'YearRangePickerGridBody', + 'YearRangePickerGridRow', + 'YearRangePickerCellTrigger', + ] as const, + // Utility component configProvider: [ 'ConfigProvider', diff --git a/packages/core/src/Calendar/CalendarCellTrigger.vue b/packages/core/src/Calendar/CalendarCellTrigger.vue index 492887b77b..11323aaffc 100644 --- a/packages/core/src/Calendar/CalendarCellTrigger.vue +++ b/packages/core/src/Calendar/CalendarCellTrigger.vue @@ -171,7 +171,8 @@ function handleArrowKey(e: KeyboardEvent) {