From f692f191f6888cee0b9f0bc53915942d8e23d649 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Sun, 9 Dec 2018 17:34:27 +0800 Subject: [PATCH] feat: update time-picker modal locale-provider --- components/_util/props-util.js | 11 +- components/cascader/index.jsx | 7 +- .../__tests__/__snapshots__/demo.test.js.snap | 32 +- .../__tests__/__snapshots__/demo.test.js.snap | 16 +- .../__tests__/__snapshots__/demo.test.js.snap | 2 +- .../__snapshots__/index.test.js.snap | 449 ++++++++++++++++-- components/modal/ActionButton.jsx | 10 +- components/modal/ConfirmDialog.jsx | 34 +- components/modal/Modal.jsx | 7 + .../__snapshots__/Modal.test.js.snap | 6 +- .../__tests__/__snapshots__/demo.test.js.snap | 12 +- components/modal/__tests__/confirm.test.js | 12 +- components/modal/confirm.js | 22 +- components/modal/demo/async.md | 2 +- components/modal/demo/basic.md | 2 +- components/modal/demo/button-props.md | 2 +- components/modal/demo/confirm.md | 21 + components/modal/demo/footer.md | 2 +- components/modal/demo/manual.md | 26 +- components/modal/demo/position.md | 4 +- components/modal/index.en-US.md | 17 +- components/modal/index.js | 2 +- components/modal/index.zh-CN.md | 15 +- .../__tests__/__snapshots__/demo.test.js.snap | 4 +- .../__tests__/__snapshots__/demo.test.js.snap | 22 +- .../time-picker/__tests__/index.test.js | 2 +- components/time-picker/demo/addon.md | 4 +- components/time-picker/index.en-US.md | 2 +- components/time-picker/index.jsx | 12 +- components/time-picker/index.zh-CN.md | 2 +- components/vc-time-picker/Panel.jsx | 5 +- components/vc-time-picker/TimePicker.jsx | 9 +- 32 files changed, 625 insertions(+), 150 deletions(-) diff --git a/components/_util/props-util.js b/components/_util/props-util.js index 9bb66df42..6dba0f19f 100644 --- a/components/_util/props-util.js +++ b/components/_util/props-util.js @@ -95,19 +95,22 @@ const getOptionProps = (instance) => { return filterProps($props, $options.propsData) } -const getComponentFromProp = (instance, prop, options) => { +const getComponentFromProp = (instance, prop, options = instance, execute = true) => { if (instance.$createElement) { const h = instance.$createElement const temp = instance[prop] if (temp !== undefined) { - return typeof temp === 'function' ? temp(h, options) : temp + return typeof temp === 'function' && execute ? temp(h, options) : temp } - return instance.$slots[prop] || (instance.$scopedSlots[prop] && instance.$scopedSlots[prop](options)) || undefined + return instance.$slots[prop] || + (instance.$scopedSlots[prop] && execute && instance.$scopedSlots[prop](options)) || + (instance.$scopedSlots[prop] && instance.$scopedSlots[prop]) || + undefined } else { const h = instance.context.$createElement const temp = getPropsData(instance)[prop] if (temp !== undefined) { - return typeof temp === 'function' ? temp(h, options) : temp + return typeof temp === 'function' && execute ? temp(h, options) : temp } const slotsProp = [] const componentOptions = instance.componentOptions || {}; diff --git a/components/cascader/index.jsx b/components/cascader/index.jsx index 2cc36d73b..9c7620c40 100644 --- a/components/cascader/index.jsx +++ b/components/cascader/index.jsx @@ -310,7 +310,8 @@ const Cascader = { const { $slots, sPopupVisible, inputValue, $listeners } = this const { sValue: value, inputFocused } = this.$data const props = getOptionProps(this) - const suffixIcon = getComponentFromProp(this, 'suffixIcon') + let suffixIcon = getComponentFromProp(this, 'suffixIcon') + suffixIcon = Array.isArray(suffixIcon) ? suffixIcon[0] : suffixIcon const { prefixCls, inputPrefixCls, placeholder, size, disabled, allowClear, showSearch = false, ...otherProps } = props @@ -408,9 +409,9 @@ const Cascader = { } const children = filterEmpty($slots.default) const inputIcon = suffixIcon && ( - isValidElement(suffixIcon[0]) + isValidElement(suffixIcon) ? cloneElement( - suffixIcon[0], + suffixIcon, { class: { [`${prefixCls}-picker-arrow`]: true, diff --git a/components/form/__tests__/__snapshots__/demo.test.js.snap b/components/form/__tests__/__snapshots__/demo.test.js.snap index a3588a5c1..99969e364 100644 --- a/components/form/__tests__/__snapshots__/demo.test.js.snap +++ b/components/form/__tests__/__snapshots__/demo.test.js.snap @@ -4,7 +4,7 @@ exports[`renders ./components/form/demo/advanced-search.vue correctly 1`] = ` -
~
~ Click to confirm
@@ -3919,7 +3919,7 @@ exports[`Locale Provider should display the text as et 1`] = `
-
~
~ Click to confirm
@@ -4292,7 +4292,7 @@ exports[`Locale Provider should display the text as fa 1`] = `
-
~
~ Click to confirm
@@ -4665,7 +4665,7 @@ exports[`Locale Provider should display the text as fi 1`] = `
-
~
~ Click to confirm
@@ -5038,7 +5038,7 @@ exports[`Locale Provider should display the text as fr 1`] = `
-
~
~ Click to confirm
@@ -5411,7 +5411,7 @@ exports[`Locale Provider should display the text as fr 2`] = `
-
~
~ Click to confirm
@@ -5784,7 +5784,7 @@ exports[`Locale Provider should display the text as is 1`] = `
-
~
~ Click to confirm
@@ -6157,7 +6157,7 @@ exports[`Locale Provider should display the text as it 1`] = `
-
~
~ Click to confirm
@@ -6530,7 +6530,7 @@ exports[`Locale Provider should display the text as ja 1`] = `
-
~
~ Click to confirm
@@ -6903,7 +6903,7 @@ exports[`Locale Provider should display the text as ko 1`] = `
-
~
~ Click to confirm
@@ -7276,7 +7276,7 @@ exports[`Locale Provider should display the text as ku-iq 1`] = `
-
~
~ Click to confirm
@@ -7621,6 +7621,379 @@ exports[`Locale Provider should display the text as ku-iq 1`] = `
`; +exports[`Locale Provider should display the text as mn-mn 1`] = ` +
+
    +
  • +
  • 1
  • +
  • 2
  • +
  • 3
  • +
  • 4
  • +
  • 5
  • +
  • +
  • +
    +
    +
    +
    10 / хуудас
    +
    +
    +
    +
  • +
+
+
+
+ +
+
+
~ Click to confirm +
+
+
0 Зүйл
+ +
+
+
+
0 Зүйл
+ +
+
+
+
+
+
+
+
2017
+
+
+
+
+
+
+
9 сар
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
НяДаМяЛхПүБаБя
+
+
27
+
+
+
+
+
28
+
+
+
+
+
29
+
+
+
+
+
30
+
+
+
+
+
31
+
+
+
+
+
01
+
+
+
+
+
02
+
+
+
+
+
03
+
+
+
+
+
04
+
+
+
+
+
05
+
+
+
+
+
06
+
+
+
+
+
07
+
+
+
+
+
08
+
+
+
+
+
09
+
+
+
+
+
10
+
+
+
+
+
11
+
+
+
+
+
12
+
+
+
+
+
13
+
+
+
+
+
14
+
+
+
+
+
15
+
+
+
+
+
16
+
+
+
+
+
17
+
+
+
+
+
18
+
+
+
+
+
19
+
+
+
+
+
20
+
+
+
+
+
21
+
+
+
+
+
22
+
+
+
+
+
23
+
+
+
+
+
24
+
+
+
+
+
25
+
+
+
+
+
26
+
+
+
+
+
27
+
+
+
+
+
28
+
+
+
+
+
29
+
+
+
+
+
30
+
+
+
+
+
01
+
+
+
+
+
02
+
+
+
+
+
03
+
+
+
+
+
04
+
+
+
+
+
05
+
+
+
+
+
06
+
+
+
+
+
07
+
+
+
+
+
+
+
+ + + + +
NameAge
+
+
Мэдээлэл байхгүй байна
+
+
+
+ +
+`; + exports[`Locale Provider should display the text as nb 1`] = `
    @@ -7649,7 +8022,7 @@ exports[`Locale Provider should display the text as nb 1`] = `
-
~
~ Click to confirm
@@ -8022,7 +8395,7 @@ exports[`Locale Provider should display the text as nl 1`] = `
-
~
~ Click to confirm
@@ -8395,7 +8768,7 @@ exports[`Locale Provider should display the text as nl-be 1`] = `
-
~
~ Click to confirm
@@ -8768,7 +9141,7 @@ exports[`Locale Provider should display the text as pl 1`] = `
-
~
~ Click to confirm
@@ -9141,7 +9514,7 @@ exports[`Locale Provider should display the text as pt 1`] = `
-
~
~ Click to confirm
@@ -9514,7 +9887,7 @@ exports[`Locale Provider should display the text as pt-br 1`] = `
-
~
~ Click to confirm
@@ -9887,7 +10260,7 @@ exports[`Locale Provider should display the text as ru 1`] = `
-
~
~ Click to confirm
@@ -9895,7 +10268,7 @@ exports[`Locale Provider should display the text as ru 1`] = `
0 элем.
@@ -9909,7 +10282,7 @@ exports[`Locale Provider should display the text as ru 1`] = `
0 элем.
@@ -10260,7 +10633,7 @@ exports[`Locale Provider should display the text as sk 1`] = `
-
~
~ Click to confirm
@@ -10633,7 +11006,7 @@ exports[`Locale Provider should display the text as sl 1`] = `
-
~
~ Click to confirm
@@ -11006,7 +11379,7 @@ exports[`Locale Provider should display the text as sr 1`] = `
-
~
~ Click to confirm
@@ -11379,7 +11752,7 @@ exports[`Locale Provider should display the text as sv 1`] = `
-
~
~ Click to confirm
@@ -11752,7 +12125,7 @@ exports[`Locale Provider should display the text as th 1`] = `
-
~
~ Click to confirm
@@ -12125,7 +12498,7 @@ exports[`Locale Provider should display the text as tr 1`] = `
-
~
~ Click to confirm
@@ -12498,7 +12871,7 @@ exports[`Locale Provider should display the text as uk 1`] = `
-
~
~ Click to confirm
@@ -12871,7 +13244,7 @@ exports[`Locale Provider should display the text as vi 1`] = `
-
~
~ Click to confirm
@@ -13244,7 +13617,7 @@ exports[`Locale Provider should display the text as zh-cn 1`] = `
-
~
~ Click to confirm
@@ -13617,7 +13990,7 @@ exports[`Locale Provider should display the text as zh-tw 1`] = `
-
~
~ Click to confirm
diff --git a/components/modal/ActionButton.jsx b/components/modal/ActionButton.jsx index 85df6731a..20981db4e 100644 --- a/components/modal/ActionButton.jsx +++ b/components/modal/ActionButton.jsx @@ -9,6 +9,7 @@ const ActionButtonProps = { actionFn: PropTypes.func, closeModal: PropTypes.func, autoFocus: PropTypes.bool, + buttonProps: PropTypes.object, } export default { @@ -58,9 +59,14 @@ export default { }, render () { - const { type, $slots, loading } = this + const { type, $slots, loading, buttonProps } = this return ( - ) diff --git a/components/modal/ConfirmDialog.jsx b/components/modal/ConfirmDialog.jsx index fae6594c5..15c26064c 100644 --- a/components/modal/ConfirmDialog.jsx +++ b/components/modal/ConfirmDialog.jsx @@ -9,10 +9,12 @@ export default { functional: true, render (h, context) { const { props } = context - const { onCancel, onOk, close, zIndex, afterClose, visible, keyboard, centered } = props + const { onCancel, onOk, close, zIndex, afterClose, visible, + keyboard, centered, getContainer, maskStyle, okButtonProps, cancelButtonProps } = props const iconType = props.iconType || 'question-circle' const okType = props.okType || 'primary' - const prefixCls = props.prefixCls || 'ant-confirm' + const prefixCls = props.prefixCls || 'ant-modal' + const contentPrefixCls = `${prefixCls}-confirm` // 默认为 true,保持向下兼容 const okCancel = ('okCancel' in props) ? props.okCancel : true const width = props.width || 416 @@ -23,22 +25,29 @@ export default { const okText = props.okText || (okCancel ? runtimeLocale.okText : runtimeLocale.justOkText) const cancelText = props.cancelText || runtimeLocale.cancelText + const autoFocusButton = props.autoFocusButton === null ? false : props.autoFocusButton || 'ok' const classString = classNames( - prefixCls, + contentPrefixCls, + `${contentPrefixCls}-${props.type}`, `${prefixCls}-${props.type}`, ) const cancelButton = okCancel && ( - + {cancelText} ) return ( close({ triggerCancel: true }, e)} visible={visible} title='' @@ -46,21 +55,24 @@ export default { footer='' maskTransitionName='fade' maskClosable={maskClosable} + maskStyle={maskStyle} style={style} width={width} zIndex={zIndex} afterClose={afterClose} keyboard={keyboard} + centered={centered} + getContainer={getContainer} > -
-
+
+
- {props.title} -
{props.content}
+ {props.title} +
{props.content}
-
+
{cancelButton} - + {okText}
diff --git a/components/modal/Modal.jsx b/components/modal/Modal.jsx index 1d7128b4d..d79019a8c 100644 --- a/components/modal/Modal.jsx +++ b/components/modal/Modal.jsx @@ -8,6 +8,7 @@ const ButtonType = buttonTypes().type import LocaleReceiver from '../locale-provider/LocaleReceiver' import { getConfirmLocale } from './locale' import { initDefaultProps, getComponentFromProp, getClass, getStyle, mergeProps } from '../_util/props-util' +import Icon from '../icon' let mousePosition = null let mousePositionEventBinded = false @@ -144,6 +145,11 @@ export default { } /> ) + const closeIcon = ( + + + + ) const footer = getComponentFromProp(this, 'footer') const title = getComponentFromProp(this, 'title') const dialogProps = { @@ -155,6 +161,7 @@ export default { footer: footer === undefined ? defaultFooter : footer, visible: visible, mousePosition, + closeIcon, }, on: { ...$listeners, diff --git a/components/modal/__tests__/__snapshots__/Modal.test.js.snap b/components/modal/__tests__/__snapshots__/Modal.test.js.snap index 69281564a..04dd7d230 100644 --- a/components/modal/__tests__/__snapshots__/Modal.test.js.snap +++ b/components/modal/__tests__/__snapshots__/Modal.test.js.snap @@ -9,7 +9,7 @@ exports[`Modal render correctly 1`] = `