Skip to content

Commit

Permalink
feat: 移除 valueType api
Browse files Browse the repository at this point in the history
  • Loading branch information
honkinglin committed Sep 14, 2022
1 parent ed2234f commit 2e42f4f
Show file tree
Hide file tree
Showing 18 changed files with 110 additions and 275 deletions.
2 changes: 1 addition & 1 deletion src/_common
Submodule _common updated 47 files
+1 −0 .eslintrc.js
+22 −3 develop-install.md
+0 −4 docs/web/_design/上传 Upload.md
+3 −0 docs/web/_design/引导Guide.md
+64 −0 docs/web/_design/水印 Watermark.md
+19 −0 docs/web/api/affix.en-US.md
+31 −0 docs/web/api/alert.en-US.md
+41 −0 docs/web/api/anchor.en-US.md
+42 −0 docs/web/api/avater.en-US.md
+75 −0 docs/web/api/card.en-US.md
+43 −0 docs/web/api/config-provider.en-US.md
+18 −0 docs/web/api/date-picker.md
+50 −0 docs/web/api/dialog.en-US.md
+13 −1 docs/web/api/dropdown.md
+27 −0 docs/web/api/guide.md
+65 −0 docs/web/api/input.en-US.md
+31 −0 docs/web/api/radio.en-US.md
+69 −0 docs/web/api/tabs.en-US.md
+57 −22 docs/web/api/upload.md
+3 −0 docs/web/design/guide.md
+1 −1 docs/web/design/input.md
+1 −12 docs/web/design/tooltip.md
+62 −0 docs/web/design/watermark.md
+76 −5 docs/web/overview.md
+9 −28 js/date-picker/format.ts
+5 −3 js/global-config/locale/zh_CN.ts
+37 −16 js/tree/tree-node.ts
+423 −0 js/upload/main.ts
+113 −3 js/upload/types.ts
+36 −12 js/upload/utils.ts
+58 −13 js/upload/xhr.ts
+2 −1 package.json
+1 −0 style/web/_variables.less
+1 −2 style/web/components/cascader/_index.less
+65 −21 style/web/components/dropdown-new/_index.less
+3 −3 style/web/components/dropdown-new/_var.less
+178 −0 style/web/components/guide/_index.less
+0 −0 style/web/components/guide/_mixin.less
+4 −0 style/web/components/guide/_var.less
+32 −0 style/web/components/guide/index.html
+6 −6 style/web/components/image-viewer/_index.less
+2 −1 style/web/components/input/_index.less
+645 −0 style/web/components/steps/_index.css
+1 −1 style/web/components/steps/_index.less
+44 −6 style/web/components/upload/_index.less
+2 −0 style/web/components/upload/_var.less
+1 −0 tsconfig.json
17 changes: 3 additions & 14 deletions src/date-picker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export default defineComponent({
const formatRef = computed(() => getDefaultFormat({
mode: props.mode,
format: props.format,
valueType: props.valueType,
enableTimePicker: props.enableTimePicker,
}));

Expand All @@ -53,7 +52,6 @@ export default defineComponent({
if (value.value) {
cacheValue.value = formatDate(value.value, {
format: formatRef.value.format,
targetFormat: formatRef.value.format,
});
}
}
Expand All @@ -64,7 +62,6 @@ export default defineComponent({
isHoverCell.value = true;
inputValue.value = formatDate(date, {
format: formatRef.value.format,
targetFormat: formatRef.value.format,
});
}

Expand All @@ -73,7 +70,6 @@ export default defineComponent({
isHoverCell.value = false;
inputValue.value = formatDate(cacheValue.value, {
format: formatRef.value.format,
targetFormat: formatRef.value.format,
});
}

Expand All @@ -88,16 +84,14 @@ export default defineComponent({
if (props.enableTimePicker) {
cacheValue.value = formatDate(date, {
format: formatRef.value.format,
targetFormat: formatRef.value.format,
});
} else {
onChange?.(
formatDate(date, {
format: formatRef.value.format,
targetFormat: formatRef.value.valueType,
}) as DateValue,
{
dayjsValue: dayjs(date),
dayjsValue: parseToDayjs(date, formatRef.value.format),
trigger: 'pick',
},
);
Expand Down Expand Up @@ -156,7 +150,6 @@ export default defineComponent({
.toDate();
inputValue.value = formatDate(nextDate, {
format: formatRef.value.format,
targetFormat: formatRef.value.format,
});

props.onPick?.(nextDate);
Expand All @@ -166,23 +159,20 @@ export default defineComponent({
function onConfirmClick() {
const nextValue = formatDate(inputValue.value, {
format: formatRef.value.format,
targetFormat: formatRef.value.format,
});
if (nextValue) {
onChange?.(
formatDate(inputValue.value, {
format: formatRef.value.format,
targetFormat: formatRef.value.valueType,
}) as DateValue,
{
dayjsValue: dayjs(inputValue.value as string),
dayjsValue: parseToDayjs(inputValue.value as string, formatRef.value.format),
trigger: 'confirm',
},
);
} else {
inputValue.value = formatDate(value.value, {
format: formatRef.value.format,
targetFormat: formatRef.value.format,
});
}
popupVisible.value = false;
Expand All @@ -194,10 +184,9 @@ export default defineComponent({
onChange?.(
formatDate(presetVal, {
format: formatRef.value.format,
targetFormat: formatRef.value.valueType,
}) as DateValue,
{
dayjsValue: dayjs(presetVal),
dayjsValue: parseToDayjs(presetVal, formatRef.value.format),
trigger: 'preset',
},
);
Expand Down
45 changes: 18 additions & 27 deletions src/date-picker/DatePickerPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineComponent, computed } from '@vue/composition-api';
import dayjs from 'dayjs';

import useSingleValue from './hooks/useSingleValue';
import { formatDate, getDefaultFormat } from '../_common/js/date-picker/format';
import { formatDate, getDefaultFormat, parseToDayjs } from '../_common/js/date-picker/format';
import { subtractMonth, addMonth, extractTimeObj } from '../_common/js/date-picker/utils';
import type {
DateValue,
Expand All @@ -21,7 +21,6 @@ export default defineComponent({
props: {
value: datePickerProps.value,
defaultValue: datePickerProps.defaultValue,
valueType: datePickerProps.valueType,
disabled: datePickerProps.disabled,
disableDate: datePickerProps.disableDate,
enableTimePicker: datePickerProps.enableTimePicker,
Expand All @@ -41,7 +40,6 @@ export default defineComponent({
const formatRef = computed(() => getDefaultFormat({
mode: props.mode,
format: props.format,
valueType: props.valueType,
enableTimePicker: props.enableTimePicker,
}));

Expand All @@ -56,15 +54,12 @@ export default defineComponent({
month.value = date.getMonth();
}
if (props.enableTimePicker) {
cacheValue.value = formatDate(date, { format: formatRef.value.format, targetFormat: formatRef.value.format });
cacheValue.value = formatDate(date, { format: formatRef.value.format });
} else {
onChange?.(
formatDate(date, { format: formatRef.value.format, targetFormat: formatRef.value.valueType }) as DateValue,
{
dayjsValue: dayjs(date),
trigger: 'pick',
},
);
onChange?.(formatDate(date, { format: formatRef.value.format }) as DateValue, {
dayjsValue: parseToDayjs(date, formatRef.value.format),
trigger: 'pick',
});
}
}

Expand Down Expand Up @@ -143,16 +138,16 @@ export default defineComponent({
: dayjs(cacheValue.value as string, formatRef.value.format);
const nextDate = currentDate.hour(nextHours).minute(minutes).second(seconds).millisecond(milliseconds)
.toDate();
cacheValue.value = formatDate(nextDate, { format: formatRef.value.format, targetFormat: formatRef.value.format });
cacheValue.value = formatDate(nextDate, { format: formatRef.value.format });

props.onTimeChange?.({
time: val,
date: dayjs(value.value).toDate(),
date: parseToDayjs(value.value, formatRef.value.format).toDate(),
trigger: 'time-hour',
});
emit('time-change', {
time: val,
date: dayjs(value.value).toDate(),
date: parseToDayjs(value.value, formatRef.value.format).toDate(),
trigger: 'time-hour',
});
}
Expand All @@ -162,10 +157,9 @@ export default defineComponent({
onChange?.(
formatDate(cacheValue.value, {
format: formatRef.value.format,
targetFormat: formatRef.value.valueType,
}) as DateValue,
{
dayjsValue: dayjs(cacheValue.value as string),
dayjsValue: parseToDayjs(cacheValue.value as string, formatRef.value.format),
trigger: 'confirm',
},
);
Expand All @@ -176,13 +170,10 @@ export default defineComponent({
// 预设
function onPresetClick(presetValue: DateValue | (() => DateValue), { e, preset }: any) {
const presetVal = typeof presetValue === 'function' ? presetValue() : presetValue;
onChange?.(
formatDate(presetVal, { format: formatRef.value.format, targetFormat: formatRef.value.valueType }) as DateValue,
{
dayjsValue: dayjs(presetVal),
trigger: 'preset',
},
);
onChange?.(formatDate(presetVal, { format: formatRef.value.format }) as DateValue, {
dayjsValue: parseToDayjs(presetVal, formatRef.value.format),
trigger: 'preset',
});
props.onPresetClick?.({ e, preset });
emit('preset-click', { e, preset });
}
Expand All @@ -192,12 +183,12 @@ export default defineComponent({

props.onYearChange?.({
year: year.value,
date: dayjs(value.value).toDate(),
date: parseToDayjs(value.value, formatRef.value.format).toDate(),
trigger: 'year-select',
});
emit('year-change', {
year: year.value,
date: dayjs(value.value).toDate(),
date: parseToDayjs(value.value, formatRef.value.format).toDate(),
trigger: 'year-select',
});
}
Expand All @@ -207,12 +198,12 @@ export default defineComponent({

props.onMonthChange?.({
month: month.value,
date: dayjs(value.value).toDate(),
date: parseToDayjs(value.value, formatRef.value.format).toDate(),
trigger: 'month-select',
});
emit('month-change', {
month: month.value,
date: dayjs(value.value).toDate(),
date: parseToDayjs(value.value, formatRef.value.format).toDate(),
trigger: 'month-select',
});
}
Expand Down
16 changes: 3 additions & 13 deletions src/date-picker/DateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export default defineComponent({
mode: props.mode,
enableTimePicker: props.enableTimePicker,
format: props.format,
valueType: props.valueType,
}));

// 记录面板是否选中过
Expand All @@ -57,7 +56,6 @@ export default defineComponent({
isSelected.value = false;
cacheValue.value = formatDate(value.value || [], {
format: formatRef.value.format,
targetFormat: formatRef.value.format,
}) as string[];
time.value = formatTime(
value.value || [dayjs().format(formatRef.value.timeFormat), dayjs().format(formatRef.value.timeFormat)],
Expand Down Expand Up @@ -89,7 +87,6 @@ export default defineComponent({
isFirstValueSelected.value = false;
inputValue.value = formatDate(value.value, {
format: formatRef.value.format,
targetFormat: formatRef.value.format,
});
}
});
Expand All @@ -104,7 +101,6 @@ export default defineComponent({
const nextValue = [...(inputValue.value as string[])];
nextValue[activeIndex.value] = formatDate(date, {
format: formatRef.value.format,
targetFormat: formatRef.value.format,
}) as string;
inputValue.value = nextValue;
}
Expand All @@ -130,7 +126,6 @@ export default defineComponent({
const nextValue = [...(inputValue.value as string[])];
nextValue[activeIndex.value] = formatDate(date, {
format: formatRef.value.format,
targetFormat: formatRef.value.format,
}) as string;
cacheValue.value = nextValue;
inputValue.value = nextValue;
Expand Down Expand Up @@ -158,10 +153,9 @@ export default defineComponent({
onChange?.(
formatDate(nextValue, {
format: formatRef.value.format,
targetFormat: formatRef.value.valueType,
}) as DateValue[],
{
dayjsValue: nextValue.map((v) => dayjs(v)),
dayjsValue: nextValue.map((v) => parseToDayjs(v, formatRef.value.format)),
trigger: 'pick',
},
);
Expand Down Expand Up @@ -255,11 +249,9 @@ export default defineComponent({
isSelected.value = true;
inputValue.value = formatDate(nextInputValue, {
format: formatRef.value.format,
targetFormat: formatRef.value.format,
});
cacheValue.value = formatDate(nextInputValue, {
format: formatRef.value.format,
targetFormat: formatRef.value.format,
});
}

Expand All @@ -274,10 +266,9 @@ export default defineComponent({
onChange?.(
formatDate(nextValue, {
format: formatRef.value.format,
targetFormat: formatRef.value.valueType,
}) as DateValue[],
{
dayjsValue: nextValue.map((v) => dayjs(v)),
dayjsValue: nextValue.map((v) => parseToDayjs(v, formatRef.value.format)),
trigger: 'confirm',
},
);
Expand Down Expand Up @@ -308,10 +299,9 @@ export default defineComponent({
onChange?.(
formatDate(presetValue, {
format: formatRef.value.format,
targetFormat: formatRef.value.valueType,
}) as DateValue[],
{
dayjsValue: presetValue.map((p) => dayjs(p)),
dayjsValue: presetValue.map((p) => parseToDayjs(p, formatRef.value.format)),
trigger: 'preset',
},
);
Expand Down
Loading

0 comments on commit 2e42f4f

Please sign in to comment.