hongluan-ui
Version:
Hongluan Component Library for Vue 3
1 lines • 3.55 kB
Source Map (JSON)
{"version":3,"file":"time-picker.mjs","sources":["../../../../../../packages/components/time-picker/src/time-picker.tsx"],"sourcesContent":["import { computed, defineComponent, provide, ref } from 'vue'\nimport dayjs from 'dayjs'\nimport customParseFormat from 'dayjs/plugin/customParseFormat.js'\nimport { useConsistentProp } from '@hongluan-ui/hooks'\nimport { DEFAULT_FORMATS_TIME } from './constants'\nimport Picker from './common/picker.vue'\nimport TimePickPanel from './time-picker-com/panel-time-pick.vue'\nimport TimeRangePanel from './time-picker-com/panel-time-range.vue'\nimport { timePickerDefaultProps } from './common/props'\ndayjs.extend(customParseFormat)\n\nexport default defineComponent({\n name: 'TimePicker',\n install: null,\n props: {\n ...timePickerDefaultProps,\n /**\n * @description whether to pick a time range\n */\n isRange: {\n type: Boolean,\n default: false,\n },\n },\n emits: ['update:modelValue'],\n setup(props, ctx) {\n const commonPicker = ref<InstanceType<typeof Picker>>()\n const [type, Panel] = props.isRange\n ? ['timerange', TimeRangePanel]\n : ['time', TimePickPanel]\n\n const modelUpdater = (value: any) => ctx.emit('update:modelValue', value)\n provide('PopperOptions', props.popperOptions)\n ctx.expose({\n /**\n * @description focus the Input component\n */\n focus: (e: FocusEvent | undefined) => {\n commonPicker.value?.handleFocusInput(e)\n },\n /**\n * @description blur the Input component\n */\n blur: (e: FocusEvent | undefined) => {\n commonPicker.value?.handleBlurInput(e)\n },\n /**\n * @description open the TimePicker popper\n */\n handleOpen: () => {\n commonPicker.value?.handleOpen()\n },\n /**\n * @description close the TimePicker popper\n */\n handleClose: () => {\n commonPicker.value?.handleClose()\n },\n popperPaneRef: computed(() => {\n return commonPicker.value?.popperPaneRef\n }),\n })\n\n return () => {\n const format = props.format ?? DEFAULT_FORMATS_TIME\n const { size, disabled, fill } = useConsistentProp()\n return (\n <Picker\n {...props}\n ref={commonPicker}\n type={type}\n format={format}\n size={size.value}\n disabled={disabled.value}\n fill={fill.value}\n onUpdate:modelValue={modelUpdater}\n >\n {{\n default: (props: any) => <Panel {...props} />,\n icon: ctx.slots.icon,\n }}\n </Picker>\n )\n }\n },\n})\n"],"names":["dayjs","extend","customParseFormat","defineComponent","name","install","props","isRange","type","default","emits","setup","provide","ctx","expose","focus","commonPicker","blur","handleOpen","handleClose","popperPaneRef","computed","value","size","disabled","fill"],"mappings":";;;;;;;;;;;AASAA,KAAK,CAACC,MAAN,CAAaC,iBAAb;AAEA,iBAAeC,eAAe,CAAC;AAC7BC,EAAAA,IAAI,EAAE,YADuB;AAE7BC,EAAAA,OAAO,EAAE,IAFoB;AAG7BC,EAAAA,KAAK,EAAE;;AAEL;AACJ;AACA;AACIC;AACEC;AACAC;AAFO;AALJ;AAUPC,UAAQ;;AACRC;AACE;AACA,WAAOH,IAAD;;AAIN,qCAAwC;;AACxCI,YAAQ;AACRC,QAAIC,MAAJ,CAAW;AACT;AACN;AACA;AACMC,cAAO;AACLC,QAAAA,kBAAA,kBAAA;AACD,OANQ;;AAOT;AACN;AACA;AACMC,MAAAA;AACED,QAAAA;AACD;;AACD;AACN;AACA;AACME,MAAAA,YAAY,MAAM;AAChBF;AACD;;AACD;AACN;AACA;AACMG;AACEH,QAAAA,YAAY;AACb;AACDI,qBAAeC;AACb,4BAAoBC;AACrB;AA3BQ;AA8BX;AACE,kBAAY,sCAAZ;AACA,YAAM;AAAEC,QAAAA;AAAMC;AAAUC;AAAlB;;;;"}