Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Carbon] *-Picker 重构 #7367

Merged
merged 14 commits into from Oct 10, 2017
Merged

Conversation

wacky6
Copy link
Contributor

@wacky6 wacky6 commented Oct 5, 2017

大规模重构 *-Picker

内部实现简化:

default-value 改进 (non breaking change)

  • 具备 reactivity 特性,panel 创建后可修改
  • date-range 新增支持数组形式的 default-value(见远期改进)
  • {date, month, year}-table 高亮改为三种 classname:default, current, today 分别对应 default-value,控件 value,今天(今年、当前月) 。CSS 还没加,呼叫视觉设计师。 怀念 1.0 today 的小三角

[实验性] 新增 value-format (non breaking change)

  • 考虑到众多 issue 中提到对 value 类型的困惑,允许绑定并发射非 Date 类型的组件 value。
  • value-format 指定 value 的格式,不指定则发射 Date
  • 例如:'yyyy-MM-dd',此时 input 事件会发射 '2017-10-01'
  • range 模式下为数组形式:['2017-10-01', '2017-10-02']
  • 无需对 value 再进行格式化
  • 注:format 依然为控件在 DOM 中显示的格式:如2017年10月

breaking change

通过程序修改 picker 绑定值为无效值(disabledDate、selectableRange之外),打开 picker 时不会自动修正

远期改进预留 和 TODO

date-range:左右面板日期 leftDate、rightDate 独立:远期考虑#6935
date-table:重构,解决夏令时/冬令时的问题,#6214

先这样吧。
carbon alpha/beta 众测看看效果(滑稽
下周一大波 deadline 来袭(逃

range: n => Array
modify{Date, Time}: Date => Date
clear{Time, Milliseconds}: Date => Date
limitTimeRange: Date => Date
timeWithinRange: Date, [Date] => Boolean
@wacky6
Copy link
Contributor Author

wacky6 commented Oct 5, 2017

@Leopoldthecoder
Copy link
Contributor

简直棒。似乎可以更新下文档,比如加个 value-format 的例子,更新下组件 API 表格。

@wacky6
Copy link
Contributor Author

wacky6 commented Oct 6, 2017

文档更新了。
修改了一下 change 事件。 squash 在 picker 里面了

非兼容改动 +1 :change 事件发射组件绑定值(同 input 事件),而不是格式化后的值。(可被 value-format 控制)

@QingWei-Li QingWei-Li requested review from Dreamacro and removed request for Dreamacro October 9, 2017 05:51
@Leopoldthecoder Leopoldthecoder merged commit f937984 into ElemeFE:carbon Oct 10, 2017
this.oldHours = this.hours;
this.oldMinutes = this.minutes;
this.oldSeconds = this.seconds;
this.oldValue = this.value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wacky6 发现一个 bug:https://jsfiddle.net/u1056zx4/ ,重现步骤:

  • 打开面板,随便选择一个日期,点击确定
  • 再次打开面板,然后打开时间选择下拉框,点击取消,控制台会报错

点击取消会回到之前的值,即 this.oldValue,这里赋值时 this.value 是空字符串。大概看了一下,this.value 似乎一直都是空字符串。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pr #7442

@Leopoldthecoder
Copy link
Contributor

@wacky6 发现了一个 value-format 的 bug:https://jsfiddle.net/nLjxn1t9/ ,按说应该是 2 月 5 号,但实际被选中的是 5 月 2 号。

我是把 PhantomJS 换成 Chrome 跑测试的时候发现的,PhantomJS 竟然通过了那个用例= =

@wacky6
Copy link
Contributor Author

wacky6 commented Oct 16, 2017

似乎是我当时写测试的时候没有写的非常严格。
assert 是在 picker 打开以后才判的。然而 value 的解析应该在创建的时候就完成。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants