Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(year-picker): adds year-picker component #8959

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 192 additions & 0 deletions packages/calcite-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3232,6 +3232,29 @@ export namespace Components {
*/
"widthScale": Scale;
}
interface CalciteMonthPicker {
/**
* Focused date with indicator (will become selected date if user proceeds)
*/
"activeDate": Date;
"activeMonthIndex": number;
/**
* Specifies the latest allowed date (`"yyyy-mm-dd"`).
*/
"max": Date;
/**
* Specifies the earliest allowed date (`"yyyy-mm-dd"`).
*/
"min": Date;
/**
* Already selected date.
*/
"selectedMonthYear": Date;
}
interface CalciteMonthPickerItem {
"isActive": boolean;
"value": string;
}
interface CalciteNavigation {
/**
* When `navigationAction` is `true`, specifies the label of the `calcite-action`.
Expand Down Expand Up @@ -5440,6 +5463,38 @@ export namespace Components {
*/
"value": any;
}
interface CalciteYearPicker {
/**
* When `true`, disables year's before the earliest allowed year in end year and after the latest year in start year of range.
*/
"disableYearsOutOfRange": boolean;
/**
* When `true`, disables the component
*/
"disabled": boolean;
/**
* Specifies the latest allowed year (`"yyyy"`).
*/
"max": number;
/**
* Specifies the earliest allowed year (`"yyyy"`).
*/
"min": number;
"nextYear": () => Promise<void>;
/**
* Specifies the Unicode numeral system used by the component for localization.
*/
"numberingSystem": NumberingSystem;
"prevYear": () => Promise<void>;
/**
* When `true`, activates the component's range mode to allow a start and end year.
*/
"range": boolean;
/**
* Specifies the selected year as a string (`"yyyy"`), or an array of strings for `range` values (`["yyyy", "yyyy"]`).
*/
"value": number | number[];
}
}
export interface CalciteAccordionCustomEvent<T> extends CustomEvent<T> {
detail: T;
Expand Down Expand Up @@ -5601,6 +5656,14 @@ export interface CalciteModalCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLCalciteModalElement;
}
export interface CalciteMonthPickerCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLCalciteMonthPickerElement;
}
export interface CalciteMonthPickerItemCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLCalciteMonthPickerItemElement;
}
export interface CalciteNavigationCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLCalciteNavigationElement;
Expand Down Expand Up @@ -5753,6 +5816,10 @@ export interface CalciteValueListItemCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLCalciteValueListItemElement;
}
export interface CalciteYearPickerCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLCalciteYearPickerElement;
}
declare global {
interface HTMLCalciteAccordionElementEventMap {
"calciteInternalAccordionChange": RequestedItem;
Expand Down Expand Up @@ -6613,6 +6680,40 @@ declare global {
prototype: HTMLCalciteModalElement;
new (): HTMLCalciteModalElement;
};
interface HTMLCalciteMonthPickerElementEventMap {
"calciteMonthPickerChange": void;
}
interface HTMLCalciteMonthPickerElement extends Components.CalciteMonthPicker, HTMLStencilElement {
addEventListener<K extends keyof HTMLCalciteMonthPickerElementEventMap>(type: K, listener: (this: HTMLCalciteMonthPickerElement, ev: CalciteMonthPickerCustomEvent<HTMLCalciteMonthPickerElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof HTMLCalciteMonthPickerElementEventMap>(type: K, listener: (this: HTMLCalciteMonthPickerElement, ev: CalciteMonthPickerCustomEvent<HTMLCalciteMonthPickerElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
var HTMLCalciteMonthPickerElement: {
prototype: HTMLCalciteMonthPickerElement;
new (): HTMLCalciteMonthPickerElement;
};
interface HTMLCalciteMonthPickerItemElementEventMap {
"calciteInternalMonthPickerItemSelect": string;
}
interface HTMLCalciteMonthPickerItemElement extends Components.CalciteMonthPickerItem, HTMLStencilElement {
addEventListener<K extends keyof HTMLCalciteMonthPickerItemElementEventMap>(type: K, listener: (this: HTMLCalciteMonthPickerItemElement, ev: CalciteMonthPickerItemCustomEvent<HTMLCalciteMonthPickerItemElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof HTMLCalciteMonthPickerItemElementEventMap>(type: K, listener: (this: HTMLCalciteMonthPickerItemElement, ev: CalciteMonthPickerItemCustomEvent<HTMLCalciteMonthPickerItemElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
var HTMLCalciteMonthPickerItemElement: {
prototype: HTMLCalciteMonthPickerItemElement;
new (): HTMLCalciteMonthPickerItemElement;
};
interface HTMLCalciteNavigationElementEventMap {
"calciteNavigationActionSelect": void;
}
Expand Down Expand Up @@ -7425,6 +7526,23 @@ declare global {
prototype: HTMLCalciteValueListItemElement;
new (): HTMLCalciteValueListItemElement;
};
interface HTMLCalciteYearPickerElementEventMap {
"calciteYearPickerChange": void;
}
interface HTMLCalciteYearPickerElement extends Components.CalciteYearPicker, HTMLStencilElement {
addEventListener<K extends keyof HTMLCalciteYearPickerElementEventMap>(type: K, listener: (this: HTMLCalciteYearPickerElement, ev: CalciteYearPickerCustomEvent<HTMLCalciteYearPickerElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof HTMLCalciteYearPickerElementEventMap>(type: K, listener: (this: HTMLCalciteYearPickerElement, ev: CalciteYearPickerCustomEvent<HTMLCalciteYearPickerElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
var HTMLCalciteYearPickerElement: {
prototype: HTMLCalciteYearPickerElement;
new (): HTMLCalciteYearPickerElement;
};
interface HTMLElementTagNameMap {
"calcite-accordion": HTMLCalciteAccordionElement;
"calcite-accordion-item": HTMLCalciteAccordionItemElement;
Expand Down Expand Up @@ -7481,6 +7599,8 @@ declare global {
"calcite-menu-item": HTMLCalciteMenuItemElement;
"calcite-meter": HTMLCalciteMeterElement;
"calcite-modal": HTMLCalciteModalElement;
"calcite-month-picker": HTMLCalciteMonthPickerElement;
"calcite-month-picker-item": HTMLCalciteMonthPickerItemElement;
"calcite-navigation": HTMLCalciteNavigationElement;
"calcite-navigation-logo": HTMLCalciteNavigationLogoElement;
"calcite-navigation-user": HTMLCalciteNavigationUserElement;
Expand Down Expand Up @@ -7534,6 +7654,7 @@ declare global {
"calcite-tree-item": HTMLCalciteTreeItemElement;
"calcite-value-list": HTMLCalciteValueListElement;
"calcite-value-list-item": HTMLCalciteValueListItemElement;
"calcite-year-picker": HTMLCalciteYearPickerElement;
}
}
declare namespace LocalJSX {
Expand Down Expand Up @@ -10782,6 +10903,37 @@ declare namespace LocalJSX {
*/
"widthScale"?: Scale;
}
interface CalciteMonthPicker {
/**
* Focused date with indicator (will become selected date if user proceeds)
*/
"activeDate"?: Date;
"activeMonthIndex"?: number;
/**
* Specifies the latest allowed date (`"yyyy-mm-dd"`).
*/
"max"?: Date;
/**
* Specifies the earliest allowed date (`"yyyy-mm-dd"`).
*/
"min"?: Date;
/**
* Emits whenever the component is selected.
*/
"onCalciteMonthPickerChange"?: (event: CalciteMonthPickerCustomEvent<void>) => void;
/**
* Already selected date.
*/
"selectedMonthYear"?: Date;
}
interface CalciteMonthPickerItem {
"isActive"?: boolean;
/**
* Emits whenever the component is selected.
*/
"onCalciteInternalMonthPickerItemSelect"?: (event: CalciteMonthPickerItemCustomEvent<string>) => void;
"value"?: string;
}
interface CalciteNavigation {
/**
* When `navigationAction` is `true`, specifies the label of the `calcite-action`.
Expand Down Expand Up @@ -13065,6 +13217,40 @@ declare namespace LocalJSX {
*/
"value": any;
}
interface CalciteYearPicker {
/**
* When `true`, disables year's before the earliest allowed year in end year and after the latest year in start year of range.
*/
"disableYearsOutOfRange"?: boolean;
/**
* When `true`, disables the component
*/
"disabled"?: boolean;
/**
* Specifies the latest allowed year (`"yyyy"`).
*/
"max"?: number;
/**
* Specifies the earliest allowed year (`"yyyy"`).
*/
"min"?: number;
/**
* Specifies the Unicode numeral system used by the component for localization.
*/
"numberingSystem"?: NumberingSystem;
/**
* Emits whenever the component is selected.
*/
"onCalciteYearPickerChange"?: (event: CalciteYearPickerCustomEvent<void>) => void;
/**
* When `true`, activates the component's range mode to allow a start and end year.
*/
"range"?: boolean;
/**
* Specifies the selected year as a string (`"yyyy"`), or an array of strings for `range` values (`["yyyy", "yyyy"]`).
*/
"value"?: number | number[];
}
interface IntrinsicElements {
"calcite-accordion": CalciteAccordion;
"calcite-accordion-item": CalciteAccordionItem;
Expand Down Expand Up @@ -13121,6 +13307,8 @@ declare namespace LocalJSX {
"calcite-menu-item": CalciteMenuItem;
"calcite-meter": CalciteMeter;
"calcite-modal": CalciteModal;
"calcite-month-picker": CalciteMonthPicker;
"calcite-month-picker-item": CalciteMonthPickerItem;
"calcite-navigation": CalciteNavigation;
"calcite-navigation-logo": CalciteNavigationLogo;
"calcite-navigation-user": CalciteNavigationUser;
Expand Down Expand Up @@ -13174,6 +13362,7 @@ declare namespace LocalJSX {
"calcite-tree-item": CalciteTreeItem;
"calcite-value-list": CalciteValueList;
"calcite-value-list-item": CalciteValueListItem;
"calcite-year-picker": CalciteYearPicker;
}
}
export { LocalJSX as JSX };
Expand Down Expand Up @@ -13238,6 +13427,8 @@ declare module "@stencil/core" {
"calcite-menu-item": LocalJSX.CalciteMenuItem & JSXBase.HTMLAttributes<HTMLCalciteMenuItemElement>;
"calcite-meter": LocalJSX.CalciteMeter & JSXBase.HTMLAttributes<HTMLCalciteMeterElement>;
"calcite-modal": LocalJSX.CalciteModal & JSXBase.HTMLAttributes<HTMLCalciteModalElement>;
"calcite-month-picker": LocalJSX.CalciteMonthPicker & JSXBase.HTMLAttributes<HTMLCalciteMonthPickerElement>;
"calcite-month-picker-item": LocalJSX.CalciteMonthPickerItem & JSXBase.HTMLAttributes<HTMLCalciteMonthPickerItemElement>;
"calcite-navigation": LocalJSX.CalciteNavigation & JSXBase.HTMLAttributes<HTMLCalciteNavigationElement>;
"calcite-navigation-logo": LocalJSX.CalciteNavigationLogo & JSXBase.HTMLAttributes<HTMLCalciteNavigationLogoElement>;
"calcite-navigation-user": LocalJSX.CalciteNavigationUser & JSXBase.HTMLAttributes<HTMLCalciteNavigationUserElement>;
Expand Down Expand Up @@ -13306,6 +13497,7 @@ declare module "@stencil/core" {
* @deprecated Use the `list` component instead.
*/
"calcite-value-list-item": LocalJSX.CalciteValueListItem & JSXBase.HTMLAttributes<HTMLCalciteValueListItemElement>;
"calcite-year-picker": LocalJSX.CalciteYearPicker & JSXBase.HTMLAttributes<HTMLCalciteYearPickerElement>;
}
}
}
49 changes: 49 additions & 0 deletions packages/calcite-components/src/components/year-picker/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# calcite-year-picker

<!-- Auto Generated Below -->

## Properties

| Property | Attribute | Description | Type | Default |
| ------------------------ | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ------------------------------- | ----------- |
| `disableYearsOutOfRange` | `disable-years-out-of-range` | When `true`, disables year's before the earliest allowed year in end year and after the latest year in start year of range. | `boolean` | `false` |
| `disabled` | `disabled` | When `true`, disables the component | `boolean` | `undefined` |
| `max` | `max` | Specifies the latest allowed year (`"yyyy"`). | `number` | `2100` |
| `min` | `min` | Specifies the earliest allowed year (`"yyyy"`). | `number` | `1900` |
| `numberingSystem` | `numbering-system` | Specifies the Unicode numeral system used by the component for localization. | `"arab" \| "arabext" \| "latn"` | `undefined` |
| `range` | `range` | When `true`, activates the component's range mode to allow a start and end year. | `boolean` | `undefined` |
| `value` | `value` | Specifies the selected year as a string (`"yyyy"`), or an array of strings for `range` values (`["yyyy", "yyyy"]`). | `number \| number[]` | `undefined` |

## Events

| Event | Description | Type |
| ------------------------- | ----------------------------------------- | ------------------- |
| `calciteYearPickerChange` | Emits whenever the component is selected. | `CustomEvent<void>` |

## Methods

### `nextYear() => Promise<void>`

#### Returns

Type: `Promise<void>`

### `prevYear() => Promise<void>`

#### Returns

Type: `Promise<void>`

## Dependencies

### Used by

- [calcite-date-picker-month-header](../date-picker-month-header)
- [calcite-month-picker](../month-picker)

### Depends on

- [calcite-select](../select)
- [calcite-option](../option)

---
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
:host {
display: flex;
flex-direction: row;
inline-size: 100%;
}

.start-year,
.end-year {
inline-size: 50%;
}

.year {
inline-size: 100%;
}
Loading
Loading