@douyinfe/semi-foundation 2.1.6-alpha.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cascader/cascader.scss +1 -1
- package/cascader/constants.ts +4 -0
- package/cascader/foundation.ts +29 -15
- package/cascader/util.ts +13 -0
- package/datePicker/_utils/parser.ts +4 -3
- package/datePicker/datePicker.scss +29 -0
- package/datePicker/foundation.ts +31 -11
- package/datePicker/inputFoundation.ts +2 -0
- package/datePicker/monthsGridFoundation.ts +101 -8
- package/datePicker/rtl.scss +15 -1
- package/datePicker/variables.scss +2 -0
- package/gulpfile.js +3 -1
- package/lib/cjs/cascader/cascader.css +2 -2
- package/lib/cjs/cascader/cascader.scss +1 -1
- package/lib/cjs/cascader/constants.d.ts +3 -0
- package/lib/cjs/cascader/constants.js +6 -1
- package/lib/cjs/cascader/foundation.d.ts +4 -1
- package/lib/cjs/cascader/foundation.js +24 -11
- package/lib/cjs/cascader/util.d.ts +1 -0
- package/lib/cjs/cascader/util.js +17 -0
- package/lib/cjs/datePicker/_utils/parser.d.ts +6 -1
- package/lib/cjs/datePicker/_utils/parser.js +3 -1
- package/lib/cjs/datePicker/datePicker.css +32 -3
- package/lib/cjs/datePicker/datePicker.scss +29 -0
- package/lib/cjs/datePicker/foundation.d.ts +6 -3
- package/lib/cjs/datePicker/foundation.js +40 -14
- package/lib/cjs/datePicker/inputFoundation.js +3 -0
- package/lib/cjs/datePicker/monthsGridFoundation.d.ts +35 -3
- package/lib/cjs/datePicker/monthsGridFoundation.js +139 -6
- package/lib/cjs/datePicker/rtl.scss +15 -1
- package/lib/cjs/datePicker/variables.scss +2 -0
- package/lib/cjs/navigation/navigation.css +0 -1
- package/lib/cjs/notification/notification.css +8 -4
- package/lib/cjs/notification/notification.scss +9 -5
- package/lib/cjs/notification/variables.scss +1 -0
- package/lib/cjs/select/foundation.d.ts +10 -1
- package/lib/cjs/select/foundation.js +11 -9
- package/lib/cjs/table/table.css +0 -2
- package/lib/cjs/table/table.scss +0 -2
- package/lib/cjs/tree/treeUtil.js +14 -14
- package/lib/cjs/upload/foundation.d.ts +1 -0
- package/lib/cjs/upload/foundation.js +106 -0
- package/lib/cjs/upload/rtl.scss +0 -4
- package/lib/cjs/upload/upload.css +30 -18
- package/lib/cjs/upload/upload.scss +31 -8
- package/lib/cjs/upload/variables.scss +5 -1
- package/lib/es/cascader/cascader.css +2 -2
- package/lib/es/cascader/cascader.scss +1 -1
- package/lib/es/cascader/constants.d.ts +3 -0
- package/lib/es/cascader/constants.js +6 -1
- package/lib/es/cascader/foundation.d.ts +4 -1
- package/lib/es/cascader/foundation.js +24 -12
- package/lib/es/cascader/util.d.ts +1 -0
- package/lib/es/cascader/util.js +14 -0
- package/lib/es/datePicker/_utils/parser.d.ts +6 -1
- package/lib/es/datePicker/_utils/parser.js +3 -1
- package/lib/es/datePicker/datePicker.css +32 -3
- package/lib/es/datePicker/datePicker.scss +29 -0
- package/lib/es/datePicker/foundation.d.ts +6 -3
- package/lib/es/datePicker/foundation.js +40 -14
- package/lib/es/datePicker/inputFoundation.js +3 -0
- package/lib/es/datePicker/monthsGridFoundation.d.ts +35 -3
- package/lib/es/datePicker/monthsGridFoundation.js +139 -6
- package/lib/es/datePicker/rtl.scss +15 -1
- package/lib/es/datePicker/variables.scss +2 -0
- package/lib/es/navigation/navigation.css +0 -1
- package/lib/es/notification/notification.css +8 -4
- package/lib/es/notification/notification.scss +9 -5
- package/lib/es/notification/variables.scss +1 -0
- package/lib/es/select/foundation.d.ts +10 -1
- package/lib/es/select/foundation.js +12 -9
- package/lib/es/table/table.css +0 -2
- package/lib/es/table/table.scss +0 -2
- package/lib/es/tree/treeUtil.js +13 -12
- package/lib/es/upload/foundation.d.ts +1 -0
- package/lib/es/upload/foundation.js +107 -0
- package/lib/es/upload/rtl.scss +0 -4
- package/lib/es/upload/upload.css +30 -18
- package/lib/es/upload/upload.scss +31 -8
- package/lib/es/upload/variables.scss +5 -1
- package/notification/notification.scss +9 -5
- package/notification/variables.scss +1 -0
- package/package.json +4 -4
- package/select/foundation.ts +11 -9
- package/table/table.scss +0 -2
- package/tree/treeUtil.ts +6 -2
- package/upload/foundation.ts +81 -0
- package/upload/rtl.scss +0 -4
- package/upload/upload.scss +31 -8
- package/upload/variables.scss +5 -1
|
@@ -9,6 +9,9 @@ declare const strings: {
|
|
|
9
9
|
readonly IS_VALUE: "isValue";
|
|
10
10
|
readonly SHOW_NEXT_BY_CLICK: "click";
|
|
11
11
|
readonly SHOW_NEXT_BY_HOVER: "hover";
|
|
12
|
+
readonly LEAF_ONLY_MERGE_TYPE: "leafOnly";
|
|
13
|
+
readonly AUTO_MERGE_VALUE_MERGE_TYPE: "autoMergeValue";
|
|
14
|
+
readonly NONE_MERGE_TYPE: "none";
|
|
12
15
|
};
|
|
13
16
|
declare const numbers: {};
|
|
14
17
|
export { cssClasses, strings, numbers };
|
|
@@ -9,7 +9,12 @@ const strings = {
|
|
|
9
9
|
IS_KEY: 'isKey',
|
|
10
10
|
IS_VALUE: 'isValue',
|
|
11
11
|
SHOW_NEXT_BY_CLICK: 'click',
|
|
12
|
-
SHOW_NEXT_BY_HOVER: 'hover'
|
|
12
|
+
SHOW_NEXT_BY_HOVER: 'hover',
|
|
13
|
+
|
|
14
|
+
/* Merge Type */
|
|
15
|
+
LEAF_ONLY_MERGE_TYPE: 'leafOnly',
|
|
16
|
+
AUTO_MERGE_VALUE_MERGE_TYPE: 'autoMergeValue',
|
|
17
|
+
NONE_MERGE_TYPE: 'none'
|
|
13
18
|
};
|
|
14
19
|
const numbers = {};
|
|
15
20
|
export { cssClasses, strings, numbers };
|
|
@@ -57,6 +57,7 @@ export interface BasicScrollPanelProps {
|
|
|
57
57
|
export interface BasicCascaderProps {
|
|
58
58
|
mouseEnterDelay?: number;
|
|
59
59
|
mouseLeaveDelay?: number;
|
|
60
|
+
separator?: string;
|
|
60
61
|
arrowIcon?: any;
|
|
61
62
|
changeOnSelect?: boolean;
|
|
62
63
|
multiple?: boolean;
|
|
@@ -96,6 +97,8 @@ export interface BasicCascaderProps {
|
|
|
96
97
|
topSlot?: any;
|
|
97
98
|
showNext?: ShowNextType;
|
|
98
99
|
disableStrictly?: boolean;
|
|
100
|
+
leafOnly?: boolean;
|
|
101
|
+
enableLeafClick?: boolean;
|
|
99
102
|
onClear?: () => void;
|
|
100
103
|
triggerRender?: (props: BasicTriggerRenderProps) => any;
|
|
101
104
|
onListScroll?: (e: any, panel: BasicScrollPanelProps) => void;
|
|
@@ -125,7 +128,7 @@ export interface BasicCascaderInnerData {
|
|
|
125
128
|
isHovering: boolean;
|
|
126
129
|
checkedKeys: Set<string>;
|
|
127
130
|
halfCheckedKeys: Set<string>;
|
|
128
|
-
|
|
131
|
+
resolvedCheckedKeys: Set<string>;
|
|
129
132
|
loadedKeys: Set<string>;
|
|
130
133
|
loadingKeys: Set<string>;
|
|
131
134
|
loading: boolean;
|
|
@@ -22,7 +22,8 @@ import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instanc
|
|
|
22
22
|
import _parseInt from "@babel/runtime-corejs3/core-js-stable/parse-int";
|
|
23
23
|
import BaseFoundation from '../base/foundation';
|
|
24
24
|
import { filter, findAncestorKeys, calcCheckedKeysForUnchecked, calcCheckedKeysForChecked, calcCheckedKeys, findDescendantKeys, normalizeKeyList } from '../tree/treeUtil';
|
|
25
|
-
import { convertDataToEntities, findKeysForValues, normalizedArr, isValid } from './util';
|
|
25
|
+
import { convertDataToEntities, findKeysForValues, normalizedArr, isValid, calcMergeType } from './util';
|
|
26
|
+
import { strings } from './constants'; // eslint-disable-next-line max-len
|
|
26
27
|
|
|
27
28
|
export default class CascaderFoundation extends BaseFoundation {
|
|
28
29
|
constructor(adapter) {
|
|
@@ -535,10 +536,12 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
535
536
|
}
|
|
536
537
|
|
|
537
538
|
_defaultRenderText(path, displayRender) {
|
|
539
|
+
const separator = this.getProp('separator');
|
|
540
|
+
|
|
538
541
|
if (displayRender && typeof displayRender === 'function') {
|
|
539
542
|
return displayRender(path);
|
|
540
543
|
} else {
|
|
541
|
-
return path.join(
|
|
544
|
+
return path.join(separator);
|
|
542
545
|
}
|
|
543
546
|
}
|
|
544
547
|
|
|
@@ -612,7 +615,8 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
612
615
|
const {
|
|
613
616
|
changeOnSelect: allowChange,
|
|
614
617
|
filterLeafOnly,
|
|
615
|
-
multiple
|
|
618
|
+
multiple,
|
|
619
|
+
enableLeafClick
|
|
616
620
|
} = this.getProps();
|
|
617
621
|
const {
|
|
618
622
|
keyEntities,
|
|
@@ -646,6 +650,10 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
646
650
|
this._adapter.updateStates({
|
|
647
651
|
activeKeys: new _Set(activeKeys)
|
|
648
652
|
});
|
|
653
|
+
|
|
654
|
+
if (isLeaf && enableLeafClick) {
|
|
655
|
+
this.onItemCheckboxClick(item);
|
|
656
|
+
}
|
|
649
657
|
} else {
|
|
650
658
|
this._adapter.notifySelect(data.value);
|
|
651
659
|
|
|
@@ -695,12 +703,13 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
695
703
|
const {
|
|
696
704
|
checkedKeys,
|
|
697
705
|
keyEntities,
|
|
698
|
-
|
|
706
|
+
resolvedCheckedKeys
|
|
699
707
|
} = this.getStates();
|
|
700
708
|
const {
|
|
701
709
|
autoMergeValue,
|
|
702
710
|
max,
|
|
703
|
-
disableStrictly
|
|
711
|
+
disableStrictly,
|
|
712
|
+
leafOnly
|
|
704
713
|
} = this.getProps(); // prev checked status
|
|
705
714
|
|
|
706
715
|
const prevCheckedStatus = checkedKeys.has(key); // next checked status
|
|
@@ -711,16 +720,19 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
711
720
|
checkedKeys: curCheckedKeys,
|
|
712
721
|
halfCheckedKeys: curHalfCheckedKeys
|
|
713
722
|
} = disableStrictly ? this.calcNonDisabedCheckedKeys(key, curCheckedStatus) : this.calcCheckedKeys(key, curCheckedStatus);
|
|
714
|
-
const
|
|
715
|
-
const
|
|
723
|
+
const mergeType = calcMergeType(autoMergeValue, leafOnly);
|
|
724
|
+
const isLeafOnlyMerge = mergeType === strings.LEAF_ONLY_MERGE_TYPE;
|
|
725
|
+
const isNoneMerge = mergeType === strings.NONE_MERGE_TYPE;
|
|
726
|
+
const curResolvedCheckedKeys = new _Set(normalizeKeyList(curCheckedKeys, keyEntities, isLeafOnlyMerge));
|
|
727
|
+
const curRealCheckedKeys = isNoneMerge ? curCheckedKeys : curResolvedCheckedKeys;
|
|
716
728
|
|
|
717
729
|
if (_isNumber(max)) {
|
|
718
|
-
if (
|
|
730
|
+
if (!isNoneMerge) {
|
|
719
731
|
// When it exceeds max, the quantity is allowed to be reduced, and no further increase is allowed
|
|
720
|
-
if (
|
|
732
|
+
if (resolvedCheckedKeys.size < curResolvedCheckedKeys.size && curResolvedCheckedKeys.size > max) {
|
|
721
733
|
const checkedEntities = [];
|
|
722
734
|
|
|
723
|
-
_forEachInstanceProperty(
|
|
735
|
+
_forEachInstanceProperty(curResolvedCheckedKeys).call(curResolvedCheckedKeys, itemKey => {
|
|
724
736
|
checkedEntities.push(keyEntities[itemKey]);
|
|
725
737
|
});
|
|
726
738
|
|
|
@@ -748,7 +760,7 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
748
760
|
this._adapter.updateStates({
|
|
749
761
|
checkedKeys: curCheckedKeys,
|
|
750
762
|
halfCheckedKeys: curHalfCheckedKeys,
|
|
751
|
-
|
|
763
|
+
resolvedCheckedKeys: curResolvedCheckedKeys
|
|
752
764
|
});
|
|
753
765
|
} // The click event during multiple selection will definitely cause the checked state of node to change,
|
|
754
766
|
// so there is no need to judge the value to change.
|
|
@@ -911,7 +923,7 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
911
923
|
newState.halfCheckedKeys = new _Set([]);
|
|
912
924
|
newState.selectedKeys = new _Set([]);
|
|
913
925
|
newState.activeKeys = new _Set([]);
|
|
914
|
-
newState.
|
|
926
|
+
newState.resolvedCheckedKeys = new _Set([]);
|
|
915
927
|
|
|
916
928
|
this._adapter.notifyChange([]);
|
|
917
929
|
} else {
|
|
@@ -2,3 +2,4 @@ export declare function isValid(val: any): boolean;
|
|
|
2
2
|
export declare function normalizedArr(val: any): any[];
|
|
3
3
|
export declare function convertDataToEntities(dataNodes: any): any;
|
|
4
4
|
export declare function findKeysForValues(value: any, keyEntities: any): any[];
|
|
5
|
+
export declare function calcMergeType(autoMergeValue: boolean, leafOnly: boolean): string;
|
package/lib/es/cascader/util.js
CHANGED
|
@@ -8,6 +8,7 @@ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/inst
|
|
|
8
8
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
9
9
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
10
10
|
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
|
11
|
+
import { strings } from './constants';
|
|
11
12
|
|
|
12
13
|
function getPosition(level, index) {
|
|
13
14
|
var _context;
|
|
@@ -88,4 +89,17 @@ export function findKeysForValues(value, keyEntities) {
|
|
|
88
89
|
const res = _mapInstanceProperty(_context2 = _filterInstanceProperty(_context3 = _Object$values(keyEntities)).call(_context3, item => _isEqual(item.valuePath, valuePath))).call(_context2, item => item.key);
|
|
89
90
|
|
|
90
91
|
return res;
|
|
92
|
+
}
|
|
93
|
+
export function calcMergeType(autoMergeValue, leafOnly) {
|
|
94
|
+
let mergeType;
|
|
95
|
+
|
|
96
|
+
if (leafOnly) {
|
|
97
|
+
mergeType = strings.LEAF_ONLY_MERGE_TYPE;
|
|
98
|
+
} else if (autoMergeValue) {
|
|
99
|
+
mergeType = strings.AUTO_MERGE_VALUE_MERGE_TYPE;
|
|
100
|
+
} else {
|
|
101
|
+
mergeType = strings.NONE_MERGE_TYPE;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return mergeType;
|
|
91
105
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* Various date-related analysis methods
|
|
4
|
+
*/
|
|
5
|
+
import { Locale } from 'date-fns';
|
|
1
6
|
/**
|
|
2
7
|
* Parsing value to Date object
|
|
3
8
|
*/
|
|
4
|
-
export declare function compatiableParse(value: string, formatToken?: string, baseDate?: Date, locale?:
|
|
9
|
+
export declare function compatiableParse(value: string, formatToken?: string, baseDate?: Date, locale?: Locale): Date | null;
|
|
@@ -26,7 +26,9 @@ export function compatiableParse(value, formatToken, baseDate, locale) {
|
|
|
26
26
|
result = new Date(Date.parse(value));
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
const yearInvalid = isValid(result) && String(result.getFullYear()).length > 4;
|
|
30
|
+
|
|
31
|
+
if (!isValid(result) || yearInvalid) {
|
|
30
32
|
result = null;
|
|
31
33
|
}
|
|
32
34
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
@charset "UTF-8";
|
|
2
1
|
/* shadow */
|
|
3
2
|
/* sizing */
|
|
4
3
|
/* spacing */
|
|
@@ -72,6 +71,9 @@
|
|
|
72
71
|
font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
73
72
|
min-height: 24px;
|
|
74
73
|
}
|
|
74
|
+
.semi-datepicker-month-grid[x-panel-yearandmonth-open-type=left] .semi-datepicker-weeks, .semi-datepicker-month-grid[x-panel-yearandmonth-open-type=right] .semi-datepicker-weeks {
|
|
75
|
+
min-height: 216px;
|
|
76
|
+
}
|
|
75
77
|
.semi-datepicker-panel-yam {
|
|
76
78
|
max-width: 284px;
|
|
77
79
|
}
|
|
@@ -96,6 +98,12 @@
|
|
|
96
98
|
text-align: right;
|
|
97
99
|
background-color: var(--semi-color-fill-0);
|
|
98
100
|
}
|
|
101
|
+
.semi-datepicker-footer .semi-button:first-of-type {
|
|
102
|
+
margin-right: 12px;
|
|
103
|
+
}
|
|
104
|
+
.semi-datepicker-footer .semi-button:nth-of-type(2) {
|
|
105
|
+
margin-right: 8px;
|
|
106
|
+
}
|
|
99
107
|
.semi-datepicker-yam {
|
|
100
108
|
position: absolute;
|
|
101
109
|
top: 0;
|
|
@@ -561,6 +569,9 @@
|
|
|
561
569
|
.semi-datepicker-compact .semi-datepicker-month-grid .semi-scrolllist-item-wheel .semi-scrolllist-shade-post {
|
|
562
570
|
margin-top: 17px;
|
|
563
571
|
}
|
|
572
|
+
.semi-datepicker-compact .semi-datepicker-month-grid[x-panel-yearandmonth-open-type=left] .semi-datepicker-weeks, .semi-datepicker-compact .semi-datepicker-month-grid[x-panel-yearandmonth-open-type=right] .semi-datepicker-weeks {
|
|
573
|
+
min-height: 168px;
|
|
574
|
+
}
|
|
564
575
|
.semi-datepicker-compact.semi-datepicker-panel-yam .semi-scrolllist {
|
|
565
576
|
font-size: 12px;
|
|
566
577
|
line-height: 16px;
|
|
@@ -700,6 +711,16 @@
|
|
|
700
711
|
padding-left: 8px;
|
|
701
712
|
text-align: left;
|
|
702
713
|
}
|
|
714
|
+
.semi-rtl .semi-datepicker-footer .semi-button:first-of-type,
|
|
715
|
+
.semi-portal-rtl .semi-datepicker-footer .semi-button:first-of-type {
|
|
716
|
+
margin-left: 0;
|
|
717
|
+
margin-right: 0;
|
|
718
|
+
}
|
|
719
|
+
.semi-rtl .semi-datepicker-footer .semi-button:nth-of-type(2),
|
|
720
|
+
.semi-portal-rtl .semi-datepicker-footer .semi-button:nth-of-type(2) {
|
|
721
|
+
margin-right: 12px;
|
|
722
|
+
margin-left: 0;
|
|
723
|
+
}
|
|
703
724
|
.semi-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main,
|
|
704
725
|
.semi-portal-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main {
|
|
705
726
|
border-radius: 0 var(--semi-border-radius-small) var(--semi-border-radius-small) 0;
|
|
@@ -735,12 +756,20 @@
|
|
|
735
756
|
margin-right: 8px;
|
|
736
757
|
}
|
|
737
758
|
.semi-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
|
|
738
|
-
.semi-rtl .semi-datepicker-navigation .semi-icon-chevron_right,
|
|
759
|
+
.semi-rtl .semi-datepicker-navigation .semi-icon-chevron_right,
|
|
760
|
+
.semi-rtl .semi-datepicker-navigation .semi-icon-double_chevron_left,
|
|
761
|
+
.semi-rtl .semi-datepicker-navigation .semi-icon-double_chevron_right, .semi-rtl .semi-datepicker-yam .semi-icon-chevron_left,
|
|
739
762
|
.semi-rtl .semi-datepicker-yam .semi-icon-chevron_right,
|
|
763
|
+
.semi-rtl .semi-datepicker-yam .semi-icon-double_chevron_left,
|
|
764
|
+
.semi-rtl .semi-datepicker-yam .semi-icon-double_chevron_right,
|
|
740
765
|
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
|
|
741
766
|
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-chevron_right,
|
|
767
|
+
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-double_chevron_left,
|
|
768
|
+
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-double_chevron_right,
|
|
742
769
|
.semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_left,
|
|
743
|
-
.semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_right
|
|
770
|
+
.semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_right,
|
|
771
|
+
.semi-portal-rtl .semi-datepicker-yam .semi-icon-double_chevron_left,
|
|
772
|
+
.semi-portal-rtl .semi-datepicker-yam .semi-icon-double_chevron_right {
|
|
744
773
|
transform: scaleX(-1);
|
|
745
774
|
}
|
|
746
775
|
.semi-rtl .semi-datepicker-range-input-prefix,
|
|
@@ -94,6 +94,15 @@ $module: #{$prefix}-datepicker;
|
|
|
94
94
|
min-height: $height-datepicker_timepicker_header_min;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
|
|
98
|
+
// 为了防止 scrollList 因为 weeks 变化高度发生变化导致年月可能发生滚动
|
|
99
|
+
// In order to prevent scrollList from scrolling due to changes in the height of weeks, the year and month may be scrolled
|
|
100
|
+
&[x-panel-yearandmonth-open-type="left"],
|
|
101
|
+
&[x-panel-yearandmonth-open-type="right"] {
|
|
102
|
+
.#{$module}-weeks {
|
|
103
|
+
min-height: 6 * $width-datepicker_day;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
97
106
|
}
|
|
98
107
|
|
|
99
108
|
// 年月选择器
|
|
@@ -131,6 +140,17 @@ $module: #{$prefix}-datepicker;
|
|
|
131
140
|
padding-bottom: $spacing-datepicker_footer-paddingBottom;
|
|
132
141
|
text-align: right;
|
|
133
142
|
background-color: $color-datepicker_footer-bg-default;
|
|
143
|
+
|
|
144
|
+
.#{$prefix}-button {
|
|
145
|
+
// cancel button
|
|
146
|
+
&:first-of-type {
|
|
147
|
+
margin-right: $spacing-datepicker_footer_cancel_button-marginRight;
|
|
148
|
+
}
|
|
149
|
+
// confirm button
|
|
150
|
+
&:nth-of-type(2) {
|
|
151
|
+
margin-right: $spacing-datepicker_footer_confirm_button-marginRight;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
134
154
|
}
|
|
135
155
|
|
|
136
156
|
// 年月选择
|
|
@@ -833,6 +853,15 @@ $module: #{$prefix}-datepicker;
|
|
|
833
853
|
}
|
|
834
854
|
}
|
|
835
855
|
}
|
|
856
|
+
|
|
857
|
+
// 为了防止 scrollList 因为 weeks 变化高度发生变化导致年月可能发生滚动
|
|
858
|
+
// In order to prevent scrollList from scrolling due to changes in the height of weeks, the year and month may be scrolled
|
|
859
|
+
&[x-panel-yearandmonth-open-type="left"],
|
|
860
|
+
&[x-panel-yearandmonth-open-type="right"] {
|
|
861
|
+
.#{$module}-weeks {
|
|
862
|
+
min-height: 6 * $width-datepicker_day_compact;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
836
865
|
}
|
|
837
866
|
|
|
838
867
|
// 年月选择器
|
|
@@ -201,10 +201,13 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
201
201
|
* 2. set cachedSelectedValue using given dates(in needConfirm mode)
|
|
202
202
|
* - directly closePanel without click confirm will set cachedSelectedValue to state value
|
|
203
203
|
* - select one date(which means that the selection value is incomplete) and click confirm also set cachedSelectedValue to state value
|
|
204
|
-
* @param {String} inputValue
|
|
205
|
-
* @param {Date[]} dates
|
|
206
204
|
*/
|
|
207
|
-
rangeTypeSideEffectsWhenClosePanel(inputValue: string,
|
|
205
|
+
rangeTypeSideEffectsWhenClosePanel(inputValue: string, willUpdateDates: Date[]): void;
|
|
206
|
+
/**
|
|
207
|
+
* clear input value when selected date is not confirmed
|
|
208
|
+
*/
|
|
209
|
+
needConfirmSideEffectsWhenClosePanel(willUpdateDates: Date[] | null | undefined): void;
|
|
210
|
+
resetCachedSelectedValue(willUpdateDates?: Date[]): void;
|
|
208
211
|
/**
|
|
209
212
|
* timing to call closePanel
|
|
210
213
|
* 1. click confirm button
|
|
@@ -212,12 +212,10 @@ export default class DatePickerFoundation extends BaseFoundation {
|
|
|
212
212
|
* 2. set cachedSelectedValue using given dates(in needConfirm mode)
|
|
213
213
|
* - directly closePanel without click confirm will set cachedSelectedValue to state value
|
|
214
214
|
* - select one date(which means that the selection value is incomplete) and click confirm also set cachedSelectedValue to state value
|
|
215
|
-
* @param {String} inputValue
|
|
216
|
-
* @param {Date[]} dates
|
|
217
215
|
*/
|
|
218
216
|
|
|
219
217
|
|
|
220
|
-
rangeTypeSideEffectsWhenClosePanel(inputValue,
|
|
218
|
+
rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates) {
|
|
221
219
|
if (this._isRangeType()) {
|
|
222
220
|
this._adapter.setRangeInputFocus(false);
|
|
223
221
|
/**
|
|
@@ -227,17 +225,36 @@ export default class DatePickerFoundation extends BaseFoundation {
|
|
|
227
225
|
|
|
228
226
|
|
|
229
227
|
this.handleInputBlur(inputValue);
|
|
228
|
+
this.resetCachedSelectedValue(willUpdateDates);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* clear input value when selected date is not confirmed
|
|
233
|
+
*/
|
|
230
234
|
|
|
231
|
-
const {
|
|
232
|
-
value,
|
|
233
|
-
cachedSelectedValue
|
|
234
|
-
} = this._adapter.getStates();
|
|
235
235
|
|
|
236
|
-
|
|
236
|
+
needConfirmSideEffectsWhenClosePanel(willUpdateDates) {
|
|
237
|
+
if (this._adapter.needConfirm() && !this._isRangeType()) {
|
|
238
|
+
/**
|
|
239
|
+
* if `null` input element will show `cachedSelectedValue` formatted value(format in DateInput render)
|
|
240
|
+
* if `` input element will show `` directly
|
|
241
|
+
*/
|
|
242
|
+
this._adapter.updateInputValue(null);
|
|
237
243
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
244
|
+
this.resetCachedSelectedValue(willUpdateDates);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
resetCachedSelectedValue(willUpdateDates) {
|
|
249
|
+
const {
|
|
250
|
+
value,
|
|
251
|
+
cachedSelectedValue
|
|
252
|
+
} = this._adapter.getStates();
|
|
253
|
+
|
|
254
|
+
const newCachedSelectedValue = _Array$isArray(willUpdateDates) ? willUpdateDates : value;
|
|
255
|
+
|
|
256
|
+
if (!_isEqual(newCachedSelectedValue, cachedSelectedValue)) {
|
|
257
|
+
this._adapter.updateCachedSelectedValue(newCachedSelectedValue);
|
|
241
258
|
}
|
|
242
259
|
}
|
|
243
260
|
/**
|
|
@@ -256,7 +273,14 @@ export default class DatePickerFoundation extends BaseFoundation {
|
|
|
256
273
|
|
|
257
274
|
closePanel(e) {
|
|
258
275
|
let inputValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
259
|
-
let dates = arguments.length > 2
|
|
276
|
+
let dates = arguments.length > 2 ? arguments[2] : undefined;
|
|
277
|
+
|
|
278
|
+
const {
|
|
279
|
+
value,
|
|
280
|
+
cachedSelectedValue
|
|
281
|
+
} = this._adapter.getStates();
|
|
282
|
+
|
|
283
|
+
const willUpdateDates = isNullOrUndefined(dates) ? this._adapter.needConfirm() ? value : cachedSelectedValue : dates;
|
|
260
284
|
|
|
261
285
|
if (!this._isControlledComponent('open')) {
|
|
262
286
|
this._adapter.togglePanel(false);
|
|
@@ -265,7 +289,8 @@ export default class DatePickerFoundation extends BaseFoundation {
|
|
|
265
289
|
} // range type picker, closing panel requires the following side effects
|
|
266
290
|
|
|
267
291
|
|
|
268
|
-
this.rangeTypeSideEffectsWhenClosePanel(inputValue,
|
|
292
|
+
this.rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates);
|
|
293
|
+
this.needConfirmSideEffectsWhenClosePanel(willUpdateDates);
|
|
269
294
|
|
|
270
295
|
this._adapter.notifyOpenChange(false);
|
|
271
296
|
|
|
@@ -327,7 +352,8 @@ export default class DatePickerFoundation extends BaseFoundation {
|
|
|
327
352
|
if (parsedResult && parsedResult.length) {
|
|
328
353
|
this._updateValueAndInput(parsedResult, input === '');
|
|
329
354
|
} else if (input === '') {
|
|
330
|
-
|
|
355
|
+
// if clear input, set input to `''`
|
|
356
|
+
this._updateValueAndInput('', true, '');
|
|
331
357
|
} else {
|
|
332
358
|
this._updateValueAndInput(stateValue);
|
|
333
359
|
}
|
|
@@ -13,6 +13,7 @@ interface MonthsGridElementProps {
|
|
|
13
13
|
renderFullDate?: () => React.ReactNode;
|
|
14
14
|
}
|
|
15
15
|
export declare type PanelType = 'left' | 'right';
|
|
16
|
+
export declare type YearMonthChangeType = 'prevMonth' | 'nextMonth' | 'prevYear' | 'nextYear';
|
|
16
17
|
export interface MonthsGridFoundationProps extends MonthsGridElementProps {
|
|
17
18
|
type?: Type;
|
|
18
19
|
defaultValue?: ValueType;
|
|
@@ -104,11 +105,34 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
|
|
|
104
105
|
_initDateTimePickerFromValue(values: BaseValueType[]): void;
|
|
105
106
|
_initDateTimeRangePickerFormValue(values: BaseValueType[]): void;
|
|
106
107
|
destroy(): void;
|
|
108
|
+
/**
|
|
109
|
+
* sync change another panel month when change months from the else yam panel
|
|
110
|
+
* call it when
|
|
111
|
+
* - current change panel targe date month is same with another panel date
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* - panelType=right, target=new Date('2022-09-01') and left panel is in '2022-09' => call it, left panel minus one month to '2022-08'
|
|
115
|
+
* - panelType=left, target=new Date('2021-12-01') and right panel is in '2021-12' => call it, right panel add one month to '2021-01'
|
|
116
|
+
*/
|
|
117
|
+
handleSyncChangeMonths(options: {
|
|
118
|
+
panelType: PanelType;
|
|
119
|
+
target: Date;
|
|
120
|
+
}): void;
|
|
121
|
+
/**
|
|
122
|
+
* Get the target date based on the panel type and switch type
|
|
123
|
+
*/
|
|
124
|
+
getTargetChangeDate(options: {
|
|
125
|
+
panelType: PanelType;
|
|
126
|
+
switchType: YearMonthChangeType;
|
|
127
|
+
}): Date;
|
|
128
|
+
/**
|
|
129
|
+
* Change month by yam panel
|
|
130
|
+
*/
|
|
107
131
|
toMonth(panelType: PanelType, target: Date): void;
|
|
108
132
|
toYear(panelType: PanelType, target: Date): void;
|
|
109
133
|
toYearMonth(panelType: PanelType, target: Date): void;
|
|
110
134
|
isRangeType(type?: Type): boolean;
|
|
111
|
-
|
|
135
|
+
handleSwitchMonthOrYear(switchType: YearMonthChangeType, panelType: PanelType): void;
|
|
112
136
|
prevMonth(panelType: PanelType): void;
|
|
113
137
|
nextMonth(panelType: PanelType): void;
|
|
114
138
|
prevYear(panelType: PanelType): void;
|
|
@@ -158,13 +182,13 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
|
|
|
158
182
|
notifyValue: any;
|
|
159
183
|
notifyDate: any;
|
|
160
184
|
};
|
|
161
|
-
handleYearOrMonthChange(type:
|
|
185
|
+
handleYearOrMonthChange(type: YearMonthChangeType, panelType?: PanelType, step?: number, notSeparateInRange?: boolean): void;
|
|
162
186
|
/**
|
|
163
187
|
* You have chosen to switch the year and month in the future to directly update the Date without closing the date panel
|
|
164
188
|
* @param {*} type
|
|
165
189
|
* @param {*} targetDate
|
|
166
190
|
*/
|
|
167
|
-
updateDateAfterChangeYM(type:
|
|
191
|
+
updateDateAfterChangeYM(type: YearMonthChangeType, targetDate: Date): void;
|
|
168
192
|
_isMultiple(): boolean;
|
|
169
193
|
_isRange(): void;
|
|
170
194
|
handleDayClick(day: MonthDayInfo, panelType: PanelType): void;
|
|
@@ -214,5 +238,13 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
|
|
|
214
238
|
showYearPicker(panelType: PanelType): void;
|
|
215
239
|
showTimePicker(panelType: PanelType, opt?: boolean): void;
|
|
216
240
|
showDatePanel(panelType: PanelType): void;
|
|
241
|
+
/**
|
|
242
|
+
* Get year and month panel open type
|
|
243
|
+
*
|
|
244
|
+
* It is useful info to set minHeight of weeks.
|
|
245
|
+
* - When yam open type is 'left' or 'right', weeks minHeight should be set
|
|
246
|
+
* If the minHeight is not set, the change of the number of weeks will cause the scrollList to be unstable
|
|
247
|
+
*/
|
|
248
|
+
getYAMOpenType(): "left" | "right" | "none" | "both";
|
|
217
249
|
}
|
|
218
250
|
export {};
|