Skip to content

Commit

Permalink
feat: 日期范围改造完毕
Browse files Browse the repository at this point in the history
  • Loading branch information
shijia.sj committed Oct 30, 2024
1 parent 7257b3f commit f272516
Show file tree
Hide file tree
Showing 52 changed files with 141 additions and 293 deletions.
10 changes: 10 additions & 0 deletions compiled/alipay/demo/pages/ConfigProvider/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
empty-text="暂无数据"
></ant-picker>
</ant-list-item>
<ant-list-item>
日期范围
<ant-range-picker
slot="extra"
default-value="{{defaultDateRange}}"
onPickerChange="handlePickerRangeChange"
onVisibleChange="handleTriggerPicker"
onOk="handleRangeOk"
></ant-range-picker>
</ant-list-item>
</ant-list>
</ant-config-provider>
</ant-container>
Expand Down
8 changes: 8 additions & 0 deletions compiled/alipay/demo/pages/ConfigProvider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Page({
'button-primary-color': 'yellow',
'button-primary-background-color': 'green',
},
defaultDate: new Date('2019/02/02').getTime(),
defaultDateRange: [
new Date('2022/03/21').getTime(),
new Date('2022/05/20').getTime(),
],
},
handleTap() {
my.alert({
Expand All @@ -24,4 +29,7 @@ Page({
handleTriggerPicker(visible, e) {
console.log('onVisibleChange', visible, e);
},
handlePickerRangeChange(type, date, dateStr, e) {
console.log('onPickerRangeChange', type, date, dateStr, e);
},
});
3 changes: 2 additions & 1 deletion compiled/alipay/demo/pages/ConfigProvider/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"ant-list-item": "../../../src/List/ListItem/index",
"ant-config-provider": "../../../src/ConfigProvider/index",
"ant-picker": "../../../src/Picker/index",
"ant-container": "../../../src/Container/index"
"ant-container": "../../../src/Container/index",
"ant-range-picker": "../../../src/DatePicker/RangePicker/index"
}
}
4 changes: 2 additions & 2 deletions compiled/alipay/src/DatePicker/RangePicker/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
>
<template
is="selector"
data="{{ placeholder: startPlaceholder, active: pickerType === 'start', type: 'start', value: currentStartValueStr, precision: precision }}"
data="{{ placeholder: startPlaceholder === undefined ? locale.RangePicker.startPlaceholder : startPlaceholder, active: pickerType === 'start', type: 'start', value: currentStartValueStr, precision: precision }}"
></template>
<view class="ant-range-picker-selector-split">{{splitCharacter}}</view>
<template
is="selector"
data="{{ placeholder: endPlaceholder, active: pickerType === 'end', type: 'end', value: currentEndValueStr, precision: precision }}"
data="{{ placeholder: endPlaceholder === undefined ? locale.RangePicker.endPlaceholder : endPlaceholder, active: pickerType === 'end', type: 'end', value: currentEndValueStr, precision: precision }}"
></template>
</view>
<slot
Expand Down
33 changes: 21 additions & 12 deletions compiled/alipay/src/DatePicker/RangePicker/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
import { effect } from '@preact/signals-core';
import dayjs from 'dayjs';
import equal from 'fast-deep-equal';
import computed from '../../mixins/computed';
import mixinValue from '../../mixins/value';
import { resolveEventValue, resolveEventValues } from '../../_util/platform';
import {
Component,
ComponentWithSignalStoreImpl,
getValueFromProps,
triggerEvent,
triggerEventValues,
triggerEventOnly,
getValueFromProps,
triggerEventValues,
} from '../../_util/simply';
import { resolveEventValue, resolveEventValues } from '../../_util/platform';
import { DateRangePickerDefaultProps } from './props';
import dayjs from 'dayjs';
import equal from 'fast-deep-equal';
import i18nController from '../../_util/store';
import {
getRangeData,
getDateByValue,
getValueByDate,
getRangeData,
getValidValue,
getValueByDate,
} from '../util';
import computed from '../../mixins/computed';
import mixinValue from '../../mixins/value';
import { DateRangePickerDefaultProps } from './props';

Component(
ComponentWithSignalStoreImpl(
{
store: () => i18nController,
updateHook: effect,
mapState: {
locale: ({ store }) => store.currentLocale.value,
},
},
DateRangePickerDefaultProps,
{
// visible受控判断
Expand Down
10 changes: 5 additions & 5 deletions compiled/alipay/src/DatePicker/RangePicker/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ export const DateRangePickerDefaultProps: Partial<IDateRangePickerProps> = {
value: null,
defaultValue: null,
title: '',
okText: '确定',
cancelText: '取消',
placeholder: '请选择',
okText: undefined,
cancelText: undefined,
placeholder: undefined,
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
startPlaceholder: undefined,
endPlaceholder: undefined,
maskClosable: true,
popClassName: '',
popStyle: '',
Expand Down
6 changes: 3 additions & 3 deletions compiled/alipay/src/DatePicker/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ export const DatePickerDefaultProps: IDatePickerProps = {
value: null,
defaultValue: null,
title: '',
okText: '确定',
cancelText: '取消',
placeholder: '请选择',
okText: undefined,
cancelText: undefined,
placeholder: undefined,
precision: 'day',
maskClosable: true,
popClassName: '',
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/ar-SA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ const arSA: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/de-DE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const deDE: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const enUS: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/es-ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const esES: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/fr-FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const frFR: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/id-ID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const idID: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/it-IT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const itIT: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/ja-JP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const jaJP: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/ko-KR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const koKR: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/ms-MY.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const msMY: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const ptBR: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/ru-RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const ruRU: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/th-TH.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const thTH: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/tr-TR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const trTR: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/zh-HK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ const zhHK: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const zhCN: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
6 changes: 0 additions & 6 deletions compiled/alipay/src/_locale/zh_TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ const zhTW: Locale = {
end: '结束',
startAndEnd: '开始/结束',
},
// TODO 部分可以优化成global数据
RangePicker: {
// okText: '确定',
// cancelText: '取消',
// placeholder: '请选择',
precision: 'day',
splitCharacter: '-',
startPlaceholder: '未选择',
endPlaceholder: '未选择',
},
Expand Down
Loading

0 comments on commit f272516

Please sign in to comment.