UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 11.1 kB
{"version":3,"file":"props.mjs","sources":["../../../../../../../packages/components/time-picker/src/common/props.ts"],"sourcesContent":["import { placements } from '@popperjs/core'\nimport { buildProps, definePropType } from '@element-plus/utils'\nimport {\n useAriaProps,\n useEmptyValuesProps,\n useSizeProp,\n} from '@element-plus/hooks'\nimport { useTooltipContentProps } from '@element-plus/components/tooltip'\nimport { CircleClose } from '@element-plus/icons-vue'\nimport { disabledTimeListsProps } from '../props/shared'\n\nimport type { Component, ExtractPropTypes, ExtractPublicPropTypes } from 'vue'\nimport type { Options } from '@popperjs/core'\nimport type { Dayjs } from 'dayjs'\nimport type { Placement } from '@element-plus/components/popper'\n\nexport type SingleOrRange<T> = T | [T, T]\nexport type DateModelType = number | string | Date\nexport type ModelValueType = DateModelType | number[] | string[] | Date[]\nexport type DayOrDays = SingleOrRange<Dayjs>\nexport type DateOrDates = SingleOrRange<Date>\nexport type UserInput = SingleOrRange<string | null>\nexport type GetDisabledHours = (role: string, comparingDate?: Dayjs) => number[]\nexport type GetDisabledMinutes = (\n hour: number,\n role: string,\n comparingDate?: Dayjs\n) => number[]\nexport type GetDisabledSeconds = (\n hour: number,\n minute: number,\n role: string,\n comparingDate?: Dayjs\n) => number[]\n\nexport const timePickerDefaultProps = buildProps({\n /**\n * @description this prop decides if the date picker panel pops up when the input is focused\n */\n automaticDropdown: {\n type: Boolean,\n default: true,\n },\n /**\n * @description same as `id` in native input\n */\n id: {\n type: definePropType<SingleOrRange<string>>([Array, String]),\n },\n /**\n * @description same as `name` in native input\n */\n name: {\n type: definePropType<SingleOrRange<string>>([Array, String]),\n },\n /**\n * @description custom class name for TimePicker's dropdown\n */\n popperClass: useTooltipContentProps.popperClass,\n /**\n * @description custom style for TimePicker's dropdown\n */\n popperStyle: useTooltipContentProps.popperStyle,\n /**\n * @description format of the displayed value in the input box\n */\n format: String,\n /**\n * @description optional, format of binding value. If not specified, the binding value will be a Date object\n */\n valueFormat: String,\n /**\n * @description optional, format of the date displayed in input's inner panel\n */\n dateFormat: String,\n /**\n * @description optional, format of the time displayed in input's inner panel\n */\n timeFormat: String,\n /**\n * @description type of the picker\n */\n type: {\n type: String,\n default: '',\n },\n /**\n * @description whether to show clear button\n */\n clearable: {\n type: Boolean,\n default: true,\n },\n /**\n * @description Custom clear icon component\n */\n clearIcon: {\n type: definePropType<string | Component>([String, Object]),\n default: CircleClose,\n },\n /**\n * @description whether the input is editable\n */\n editable: {\n type: Boolean,\n default: true,\n },\n /**\n * @description Custom prefix icon component\n */\n prefixIcon: {\n type: definePropType<string | Component>([String, Object]),\n default: '',\n },\n /**\n * @description size of Input\n */\n size: useSizeProp,\n /**\n * @description whether TimePicker is read only\n */\n readonly: Boolean,\n /**\n * @description whether TimePicker is disabled\n */\n disabled: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description placeholder in non-range mode\n */\n placeholder: {\n type: String,\n default: '',\n },\n /**\n * @description [popper.js](https://popper.js.org/docs/v2/) parameters\n */\n popperOptions: {\n type: definePropType<Partial<Options>>(Object),\n default: () => ({}),\n },\n /**\n * @description binding value, if it is an array, the length should be 2\n */\n modelValue: {\n type: definePropType<ModelValueType | null>([Date, Array, String, Number]),\n default: '',\n },\n /**\n * @description range separator\n */\n rangeSeparator: {\n type: String,\n default: '-',\n },\n /**\n * @description placeholder for the start date in range mode\n */\n startPlaceholder: String,\n /**\n * @description placeholder for the end date in range mode\n */\n endPlaceholder: String,\n /**\n * @description optional, default date of the calendar\n */\n defaultValue: {\n type: definePropType<SingleOrRange<Date>>([Date, Array]),\n },\n /**\n * @description optional, the time value to use when selecting date range\n */\n defaultTime: {\n type: definePropType<SingleOrRange<Date>>([Date, Array]),\n },\n /**\n * @description whether to pick a time range\n */\n isRange: Boolean,\n ...disabledTimeListsProps,\n /**\n * @description a function determining if a date is disabled with that date as its parameter. Should return a Boolean\n */\n disabledDate: {\n type: Function,\n },\n /**\n * @description set custom className\n */\n cellClassName: {\n type: Function,\n },\n /**\n * @description an object array to set shortcut options\n */\n shortcuts: {\n type: Array,\n default: () => [],\n },\n /**\n * @description whether to pick time using arrow buttons\n */\n arrowControl: Boolean,\n /**\n * @description input tabindex\n */\n tabindex: {\n type: definePropType<string | number>([String, Number]),\n default: 0,\n },\n /**\n * @description whether to trigger form validation\n */\n validateEvent: {\n type: Boolean,\n default: true,\n },\n /**\n * @description unlink two date-panels in range-picker\n */\n unlinkPanels: Boolean,\n /**\n * @description position of dropdown\n */\n placement: {\n type: definePropType<Placement>(String),\n values: placements,\n default: 'bottom',\n },\n /**\n * @description list of possible positions for dropdown\n */\n fallbackPlacements: {\n type: definePropType<Placement[]>(Array),\n default: ['bottom', 'top', 'right', 'left'],\n },\n ...useEmptyValuesProps,\n ...useAriaProps(['ariaLabel']),\n /**\n * @description whether to show the now button\n */\n showNow: {\n type: Boolean,\n default: true,\n },\n /**\n * @description whether to show footer\n */\n showConfirm: {\n type: Boolean,\n default: true,\n },\n /**\n * @description whether to show footer\n */\n showFooter: {\n type: Boolean,\n default: true,\n },\n /**\n * @description whether to show the number of the calendar week\n */\n showWeekNumber: Boolean,\n} as const)\n\nexport type TimePickerDefaultProps = ExtractPropTypes<\n typeof timePickerDefaultProps\n>\nexport type TimePickerDefaultPropsPublic = ExtractPublicPropTypes<\n typeof timePickerDefaultProps\n>\n\nexport interface PickerOptions {\n isValidValue: (date: DayOrDays) => boolean\n handleKeydownInput: (event: KeyboardEvent) => void\n parseUserInput: (value: UserInput) => DayOrDays\n getRangeAvailableTime: (date: DayOrDays) => DayOrDays\n getDefaultValue: () => DayOrDays\n panelReady: boolean\n handleClear: () => void\n handleFocusPicker?: () => void\n}\n\nexport const timePickerRangeTriggerProps = buildProps({\n id: {\n type: definePropType<string[]>(Array),\n },\n name: {\n type: definePropType<string[]>(Array),\n },\n modelValue: {\n type: definePropType<UserInput>([Array, String]),\n },\n startPlaceholder: String,\n endPlaceholder: String,\n disabled: Boolean,\n} as const)\n\n/**\n * @deprecated Use `timePickerRangeTriggerProps` instead. This will be removed in future versions.\n */\nexport const timePickerRngeTriggerProps = timePickerRangeTriggerProps\n"],"names":[],"mappings":";;;;;;;;;AAmCO,MAAM,yBAAyB,UAAW,CAAA;AAAA,EAI/C,iBAAmB,EAAA;AAAA,IACjB,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EAIA,EAAI,EAAA;AAAA,IACF,IAAM,EAAA,cAAA,CAAsC,CAAC,KAAA,EAAO,MAAM,CAAC,CAAA;AAAA,GAC7D;AAAA,EAIA,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA,cAAA,CAAsC,CAAC,KAAA,EAAO,MAAM,CAAC,CAAA;AAAA,GAC7D;AAAA,EAIA,aAAa,sBAAuB,CAAA,WAAA;AAAA,EAIpC,aAAa,sBAAuB,CAAA,WAAA;AAAA,EAIpC,MAAQ,EAAA,MAAA;AAAA,EAIR,WAAa,EAAA,MAAA;AAAA,EAIb,UAAY,EAAA,MAAA;AAAA,EAIZ,UAAY,EAAA,MAAA;AAAA,EAIZ,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,EAAA;AAAA,GACX;AAAA,EAIA,SAAW,EAAA;AAAA,IACT,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EAIA,SAAW,EAAA;AAAA,IACT,IAAM,EAAA,cAAA,CAAmC,CAAC,MAAA,EAAQ,MAAM,CAAC,CAAA;AAAA,IACzD,OAAS,EAAA,WAAA;AAAA,GACX;AAAA,EAIA,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EAIA,UAAY,EAAA;AAAA,IACV,IAAM,EAAA,cAAA,CAAmC,CAAC,MAAA,EAAQ,MAAM,CAAC,CAAA;AAAA,IACzD,OAAS,EAAA,EAAA;AAAA,GACX;AAAA,EAIA,IAAM,EAAA,WA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