@douyinfe/semi-ui 2.7.1 → 2.8.0-beta.0
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/_utils/index.ts +29 -1
- package/datePicker/_story/v2/FixDefaultPickerValue.jsx +31 -0
- package/datePicker/_story/v2/InsetInput.jsx +1 -1
- package/datePicker/_story/v2/index.js +1 -0
- package/datePicker/monthsGrid.tsx +3 -13
- package/dist/css/semi.css +25 -16
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +604 -282
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/inputNumber/_story/inputNumber.stories.js +4 -0
- package/lib/cjs/_utils/index.d.ts +3 -1
- package/lib/cjs/_utils/index.js +25 -1
- package/lib/cjs/datePicker/monthsGrid.js +11 -19
- package/lib/cjs/notification/useNotification/index.js +1 -1
- package/lib/cjs/popover/index.d.ts +18 -3
- package/lib/cjs/popover/index.js +53 -23
- package/lib/cjs/tooltip/index.d.ts +22 -4
- package/lib/cjs/tooltip/index.js +64 -26
- package/lib/es/_utils/index.d.ts +3 -1
- package/lib/es/_utils/index.js +18 -0
- package/lib/es/datePicker/monthsGrid.js +11 -19
- package/lib/es/notification/useNotification/index.js +2 -1
- package/lib/es/popover/index.d.ts +18 -3
- package/lib/es/popover/index.js +52 -23
- package/lib/es/tooltip/index.d.ts +22 -4
- package/lib/es/tooltip/index.js +64 -26
- package/notification/useNotification/index.tsx +1 -1
- package/package.json +9 -9
- package/popover/_story/popover.stories.js +75 -1
- package/popover/index.tsx +24 -8
- package/tooltip/index.tsx +71 -21
package/_utils/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import { cloneDeepWith, set, get } from 'lodash';
|
|
5
5
|
import warning from '@douyinfe/semi-foundation/utils/warning';
|
|
6
6
|
import { findAll } from '@douyinfe/semi-foundation/utils/getHighlight';
|
|
7
|
+
import { isHTMLElement } from '@douyinfe/semi-foundation/utils/dom';
|
|
7
8
|
/**
|
|
8
9
|
* stop propagation
|
|
9
10
|
*
|
|
@@ -161,6 +162,33 @@ export interface HighLightTextHTMLChunk {
|
|
|
161
162
|
*/
|
|
162
163
|
export const isSemiIcon = (icon: any): boolean => React.isValidElement(icon) && get(icon.type, 'elementType') === 'Icon';
|
|
163
164
|
|
|
164
|
-
export function getActiveElement() {
|
|
165
|
+
export function getActiveElement(): HTMLElement | null {
|
|
165
166
|
return document ? document.activeElement as HTMLElement : null;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function isNodeContainsFocus(node: HTMLElement) {
|
|
170
|
+
const activeElement = getActiveElement();
|
|
171
|
+
return activeElement === node || node.contains(activeElement);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function getFocusableElements(node: HTMLElement) {
|
|
175
|
+
if (!isHTMLElement(node)) {
|
|
176
|
+
return [];
|
|
177
|
+
}
|
|
178
|
+
const focusableSelectorsList = [
|
|
179
|
+
"input:not([disabled]):not([tabindex='-1'])",
|
|
180
|
+
"textarea:not([disabled]):not([tabindex='-1'])",
|
|
181
|
+
"button:not([disabled]):not([tabindex='-1'])",
|
|
182
|
+
"a[href]:not([tabindex='-1'])",
|
|
183
|
+
"select:not([disabled]):not([tabindex='-1'])",
|
|
184
|
+
"area[href]:not([tabindex='-1'])",
|
|
185
|
+
"iframe:not([tabindex='-1'])",
|
|
186
|
+
"object:not([tabindex='-1'])",
|
|
187
|
+
"*[tabindex]:not([tabindex='-1'])",
|
|
188
|
+
"*[contenteditable]:not([tabindex='-1'])",
|
|
189
|
+
];
|
|
190
|
+
const focusableSelectorsStr = focusableSelectorsList.join(',');
|
|
191
|
+
// we are not filtered elements which are invisible
|
|
192
|
+
const focusableElements = Array.from(node.querySelectorAll<HTMLElement>(focusableSelectorsStr));
|
|
193
|
+
return focusableElements;
|
|
166
194
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatePicker, Space } from '../../../index';
|
|
3
|
+
|
|
4
|
+
App.storyName = "fix defaultPickerValue number bug";
|
|
5
|
+
export default function App() {
|
|
6
|
+
const defaultPickerValue = new Date('2021-03-15 00:00:00').valueOf();
|
|
7
|
+
const defaultPickerValueArray = [new Date('2021-03-15 00:00:00').valueOf(), new Date('2021-05-15 23:59:59').valueOf()];
|
|
8
|
+
return (
|
|
9
|
+
<Space>
|
|
10
|
+
<div data-cy="dateTime">
|
|
11
|
+
<DatePicker
|
|
12
|
+
type="dateTime"
|
|
13
|
+
defaultPickerValue={defaultPickerValue}
|
|
14
|
+
/>
|
|
15
|
+
</div>
|
|
16
|
+
<div data-cy="dateTimeRange">
|
|
17
|
+
<DatePicker
|
|
18
|
+
type="dateTimeRange"
|
|
19
|
+
defaultPickerValue={defaultPickerValueArray}
|
|
20
|
+
/>
|
|
21
|
+
</div>
|
|
22
|
+
<div data-cy="before-1970">
|
|
23
|
+
<DatePicker
|
|
24
|
+
type="dateTime"
|
|
25
|
+
defaultPickerValue={new Date('1910-01-01 13:00:00')}
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
28
|
+
</Space>
|
|
29
|
+
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -84,7 +84,7 @@ export default function App() {
|
|
|
84
84
|
</div>
|
|
85
85
|
<Space wrap spacing={spacing}>
|
|
86
86
|
<DatePicker placeholder='选择单个日期' {...props} />
|
|
87
|
-
<DatePicker placeholder='选择月' {...props} type='month' />
|
|
87
|
+
<DatePicker placeholder='选择月' {...props} type='month' defaultOpen={false} />
|
|
88
88
|
<DatePicker placeholder='选择日期时间' {...props} type='dateTime' needConfirm={needConfirm} />
|
|
89
89
|
<DatePicker placeholder='选择日期范围' {...props} type='dateRange' />
|
|
90
90
|
<DatePicker placeholder='选择日期时间范围' {...props} type='dateTimeRange' needConfirm={needConfirm} />
|
|
@@ -3,3 +3,4 @@ export { default as PanelOpen } from './PanelOpen';
|
|
|
3
3
|
export { default as FixInputRangeFocus } from './FixInputRangeFocus';
|
|
4
4
|
export { default as InsetInput } from './InsetInput';
|
|
5
5
|
export { default as InsetInputE2E } from './InsetInputE2E';
|
|
6
|
+
export { default as FixDefaultPickerValue } from './FixDefaultPickerValue';
|
|
@@ -19,6 +19,7 @@ import Combobox from '../timePicker/Combobox';
|
|
|
19
19
|
import YearAndMonth from './yearAndMonth';
|
|
20
20
|
import { IconClock, IconCalendar } from '@douyinfe/semi-icons';
|
|
21
21
|
import { getDefaultFormatTokenByType } from '@douyinfe/semi-foundation/datePicker/_utils/getDefaultFormatToken';
|
|
22
|
+
import getDefaultPickerDate from '@douyinfe/semi-foundation/datePicker/_utils/getDefaultPickerDate';
|
|
22
23
|
|
|
23
24
|
const prefixCls = cssClasses.PREFIX;
|
|
24
25
|
|
|
@@ -90,19 +91,8 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
90
91
|
|
|
91
92
|
constructor(props: MonthsGridProps) {
|
|
92
93
|
super(props);
|
|
93
|
-
let nowDate = Array.isArray(props.defaultPickerValue) ? props.defaultPickerValue[0] : props.defaultPickerValue;
|
|
94
94
|
const validFormat = props.format || getDefaultFormatTokenByType(props.type);
|
|
95
|
-
|
|
96
|
-
nowDate = new Date();
|
|
97
|
-
} else {
|
|
98
|
-
nowDate = compatiableParse(nowDate as string, validFormat, undefined, props.dateFnsLocale);
|
|
99
|
-
}
|
|
100
|
-
let nextDate = Array.isArray(props.defaultPickerValue) ? props.defaultPickerValue[1] : undefined;
|
|
101
|
-
if (!nextDate) {
|
|
102
|
-
nextDate = addMonths(nowDate, 1);
|
|
103
|
-
} else {
|
|
104
|
-
nextDate = compatiableParse(nextDate as string, validFormat, undefined, props.dateFnsLocale);
|
|
105
|
-
}
|
|
95
|
+
const { nowDate, nextDate } = getDefaultPickerDate({ defaultPickerValue: props.defaultPickerValue, format: validFormat, dateFnsLocale: props.dateFnsLocale });
|
|
106
96
|
|
|
107
97
|
const dateState = {
|
|
108
98
|
// Direct use of full date string storage, mainly considering the month rendering comparison to save a conversion
|
|
@@ -636,7 +626,7 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
636
626
|
x-type={type}
|
|
637
627
|
x-panel-yearandmonth-open-type={yearOpenType}
|
|
638
628
|
// FIXME:
|
|
639
|
-
x-
|
|
629
|
+
x-insetinput={insetInput ? "true" : "false"}
|
|
640
630
|
ref={current => this.cacheRefCurrent('monthGrid', current)}
|
|
641
631
|
>
|
|
642
632
|
{content}
|
package/dist/css/semi.css
CHANGED
|
@@ -3473,22 +3473,22 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
3473
3473
|
.semi-datepicker-month-grid[x-type=date] .semi-datepicker-yam-showing {
|
|
3474
3474
|
min-height: 325px;
|
|
3475
3475
|
}
|
|
3476
|
-
.semi-datepicker-month-grid[x-
|
|
3477
|
-
.semi-datepicker-month-grid[x-
|
|
3476
|
+
.semi-datepicker-month-grid[x-insetinput=true] .semi-datepicker-month-grid-left[x-open-type=year],
|
|
3477
|
+
.semi-datepicker-month-grid[x-insetinput=true] .semi-datepicker-month-grid-right[x-open-type=year] {
|
|
3478
3478
|
min-height: 312px;
|
|
3479
3479
|
}
|
|
3480
|
-
.semi-datepicker-month-grid[x-
|
|
3481
|
-
.semi-datepicker-month-grid[x-
|
|
3480
|
+
.semi-datepicker-month-grid[x-insetinput=true] .semi-datepicker-month-grid-left[x-open-type=time],
|
|
3481
|
+
.semi-datepicker-month-grid[x-insetinput=true] .semi-datepicker-month-grid-right[x-open-type=time] {
|
|
3482
3482
|
min-height: 314px;
|
|
3483
3483
|
}
|
|
3484
|
-
.semi-datepicker-month-grid[x-
|
|
3484
|
+
.semi-datepicker-month-grid[x-insetinput=true] .semi-datepicker-navigation {
|
|
3485
3485
|
padding-top: 8px;
|
|
3486
3486
|
padding-bottom: 8px;
|
|
3487
3487
|
}
|
|
3488
|
-
.semi-datepicker-month-grid[x-
|
|
3488
|
+
.semi-datepicker-month-grid[x-insetinput=true] .semi-datepicker-tpk {
|
|
3489
3489
|
min-height: 100%;
|
|
3490
3490
|
}
|
|
3491
|
-
.semi-datepicker-month-grid[x-
|
|
3491
|
+
.semi-datepicker-month-grid[x-insetinput=true][x-type=dateTime] .semi-datepicker-yam, .semi-datepicker-month-grid[x-insetinput=true][x-type=dateTimeRange] .semi-datepicker-yam {
|
|
3492
3492
|
height: 100%;
|
|
3493
3493
|
}
|
|
3494
3494
|
.semi-datepicker-month-grid .semi-datepicker-yearmonth-header {
|
|
@@ -4063,21 +4063,21 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
4063
4063
|
.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 {
|
|
4064
4064
|
min-height: 168px;
|
|
4065
4065
|
}
|
|
4066
|
-
.semi-datepicker-compact .semi-datepicker-month-grid[x-
|
|
4067
|
-
.semi-datepicker-compact .semi-datepicker-month-grid[x-
|
|
4066
|
+
.semi-datepicker-compact .semi-datepicker-month-grid[x-insetinput=true] .semi-datepicker-month-grid-left[x-open-type=year],
|
|
4067
|
+
.semi-datepicker-compact .semi-datepicker-month-grid[x-insetinput=true] .semi-datepicker-month-grid-right[x-open-type=year] {
|
|
4068
4068
|
min-height: 236px;
|
|
4069
4069
|
}
|
|
4070
|
-
.semi-datepicker-compact .semi-datepicker-month-grid[x-
|
|
4071
|
-
.semi-datepicker-compact .semi-datepicker-month-grid[x-
|
|
4070
|
+
.semi-datepicker-compact .semi-datepicker-month-grid[x-insetinput=true] .semi-datepicker-month-grid-left[x-open-type=time],
|
|
4071
|
+
.semi-datepicker-compact .semi-datepicker-month-grid[x-insetinput=true] .semi-datepicker-month-grid-right[x-open-type=time] {
|
|
4072
4072
|
min-height: 236px;
|
|
4073
4073
|
}
|
|
4074
|
-
.semi-datepicker-compact .semi-datepicker-month-grid[x-
|
|
4074
|
+
.semi-datepicker-compact .semi-datepicker-month-grid[x-insetinput=true] .semi-datepicker-yam-showing {
|
|
4075
4075
|
min-height: 236px;
|
|
4076
4076
|
}
|
|
4077
|
-
.semi-datepicker-compact .semi-datepicker-month-grid[x-
|
|
4077
|
+
.semi-datepicker-compact .semi-datepicker-month-grid[x-insetinput=true] .semi-datepicker-tpk {
|
|
4078
4078
|
min-height: 100%;
|
|
4079
4079
|
}
|
|
4080
|
-
.semi-datepicker-compact .semi-datepicker-month-grid[x-
|
|
4080
|
+
.semi-datepicker-compact .semi-datepicker-month-grid[x-insetinput=true][x-type=dateTime] .semi-datepicker-yam, .semi-datepicker-compact .semi-datepicker-month-grid[x-insetinput=true][x-type=dateTimeRange] .semi-datepicker-yam {
|
|
4081
4081
|
height: 100%;
|
|
4082
4082
|
}
|
|
4083
4083
|
.semi-datepicker-compact.semi-datepicker-panel-yam .semi-scrolllist {
|
|
@@ -4792,11 +4792,12 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
4792
4792
|
.semi-form-field-label-disabled {
|
|
4793
4793
|
color: var(--semi-color-disabled-text);
|
|
4794
4794
|
}
|
|
4795
|
-
.semi-form-field-label-with-extra .semi-form-field-label-text
|
|
4796
|
-
.semi-form-field-label-with-extra .semi-form-field-label-extra {
|
|
4795
|
+
.semi-form-field-label-with-extra .semi-form-field-label-text {
|
|
4797
4796
|
display: inline-block;
|
|
4798
4797
|
}
|
|
4799
4798
|
.semi-form-field-label-with-extra .semi-form-field-label-extra {
|
|
4799
|
+
display: flex;
|
|
4800
|
+
align-items: center;
|
|
4800
4801
|
margin-left: 4px;
|
|
4801
4802
|
}
|
|
4802
4803
|
.semi-form-field-label-required .semi-form-field-label-text::after {
|
|
@@ -4837,6 +4838,10 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
4837
4838
|
padding-top: 4px;
|
|
4838
4839
|
padding-bottom: 4px;
|
|
4839
4840
|
}
|
|
4841
|
+
.semi-form-field[x-label-pos=top] .semi-form-field-label-with-extra {
|
|
4842
|
+
display: flex;
|
|
4843
|
+
align-items: center;
|
|
4844
|
+
}
|
|
4840
4845
|
.semi-form-field[x-label-pos=left] {
|
|
4841
4846
|
display: flex;
|
|
4842
4847
|
}
|
|
@@ -4846,6 +4851,10 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
4846
4851
|
padding-top: 6px;
|
|
4847
4852
|
padding-bottom: 6px;
|
|
4848
4853
|
}
|
|
4854
|
+
.semi-form-field[x-label-pos=left] .semi-form-field-label-with-extra {
|
|
4855
|
+
display: flex;
|
|
4856
|
+
align-items: center;
|
|
4857
|
+
}
|
|
4849
4858
|
.semi-form-field[x-label-pos=left] .semi-checkboxGroup,
|
|
4850
4859
|
.semi-form-field[x-label-pos=left] .semi-radioGroup {
|
|
4851
4860
|
padding-top: 6px;
|