|
| 1 | +import { DarkModeProps } from '@leafygreen-ui/lib'; |
| 2 | +import { BaseFontSize } from '@leafygreen-ui/tokens'; |
| 3 | + |
| 4 | +const Size = { |
| 5 | + xsmall: 'xsmall', |
| 6 | + small: 'small', |
| 7 | + default: 'default', |
| 8 | + large: 'large', |
| 9 | +}; |
| 10 | +type Size = typeof Size[keyof typeof Size]; |
| 11 | + |
| 12 | +export interface BaseDatePickerProps extends DarkModeProps { |
| 13 | + /** |
| 14 | + * A label for the input |
| 15 | + */ |
| 16 | + label: string; |
| 17 | + |
| 18 | + /** |
| 19 | + * Sets the _presentation format_ for the displayed date. |
| 20 | + * Fallback to the user’s browser preference (if supported), otherwise ISO-8601. |
| 21 | + * |
| 22 | + * Currently only the following values are officially supported. |
| 23 | + * Other valid [Locale](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale) |
| 24 | + * strings may work, however no assurances are made. |
| 25 | + * |
| 26 | + * @enum 'en-US' | 'en-UK' | 'iso8601' |
| 27 | + * |
| 28 | + * @default 'iso8601' |
| 29 | + */ |
| 30 | + dateFormat?: string; |
| 31 | + |
| 32 | + /** |
| 33 | + * A valid IANA timezone string, or UTC offset. |
| 34 | + * Sets the _presentation time zone_ for the displayed date. |
| 35 | + * Fallback to the user’s browser preference (if available), otherwise UTC. |
| 36 | + * |
| 37 | + * @default 'utc' |
| 38 | + */ |
| 39 | + timeZone?: string; |
| 40 | + |
| 41 | + /** The earliest date accepted */ |
| 42 | + min?: string | Date; |
| 43 | + |
| 44 | + /** The latest date accepted */ |
| 45 | + max?: string | Date; |
| 46 | + |
| 47 | + /** |
| 48 | + * The base font size of the input. Inherits from the nearest LeafyGreenProvider |
| 49 | + */ |
| 50 | + baseFontSize?: BaseFontSize; |
| 51 | + |
| 52 | + /** |
| 53 | + * Whether the input is disabled. Note: will not set the `disabled` attribute on an input |
| 54 | + */ |
| 55 | + disabled?: boolean; |
| 56 | + |
| 57 | + /** The size of the input */ |
| 58 | + size?: Size; |
| 59 | + |
| 60 | + /** |
| 61 | + * Whether to show an error message |
| 62 | + */ |
| 63 | + state?: 'unset' | 'error'; |
| 64 | + |
| 65 | + /** |
| 66 | + * A message to show in red underneath the input when in an error state |
| 67 | + */ |
| 68 | + errorMessage?: string; |
| 69 | +} |
0 commit comments