@douyinfe/semi-ui 2.35.0 → 2.36.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/dist/css/semi.css +142 -17
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +193 -106
- 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/lib/cjs/anchor/index.d.ts +2 -1
- package/lib/cjs/anchor/link.js +13 -6
- package/lib/cjs/calendar/dayCalendar.d.ts +2 -1
- package/lib/cjs/calendar/dayCalendar.js +7 -2
- package/lib/cjs/calendar/index.d.ts +1 -0
- package/lib/cjs/calendar/index.js +1 -0
- package/lib/cjs/calendar/interface.d.ts +2 -0
- package/lib/cjs/calendar/monthCalendar.d.ts +1 -1
- package/lib/cjs/calendar/monthCalendar.js +12 -4
- package/lib/cjs/calendar/rangeCalendar.d.ts +3 -1
- package/lib/cjs/calendar/rangeCalendar.js +23 -9
- package/lib/cjs/calendar/weekCalendar.d.ts +3 -1
- package/lib/cjs/calendar/weekCalendar.js +23 -9
- package/lib/cjs/datePicker/datePicker.js +12 -4
- package/lib/cjs/datePicker/monthsGrid.js +6 -2
- package/lib/cjs/datePicker/yearAndMonth.d.ts +2 -0
- package/lib/cjs/datePicker/yearAndMonth.js +4 -2
- package/lib/cjs/input/textarea.d.ts +1 -1
- package/lib/cjs/navigation/Footer.d.ts +3 -0
- package/lib/cjs/navigation/Footer.js +19 -9
- package/lib/cjs/navigation/SubNav.d.ts +1 -13
- package/lib/cjs/navigation/SubNav.js +4 -19
- package/lib/cjs/navigation/index.d.ts +4 -1
- package/lib/cjs/navigation/index.js +7 -1
- package/lib/cjs/select/index.d.ts +2 -1
- package/lib/cjs/select/index.js +4 -0
- package/lib/cjs/table/Body/index.d.ts +1 -1
- package/lib/cjs/table/ResizableTable.d.ts +1 -1
- package/lib/cjs/table/TableHeaderRow.js +22 -14
- package/lib/cjs/table/interface.d.ts +5 -1
- package/lib/cjs/typography/base.d.ts +1 -0
- package/lib/cjs/typography/base.js +28 -14
- package/lib/cjs/typography/title.d.ts +2 -0
- package/lib/cjs/typography/title.js +2 -1
- package/lib/es/anchor/index.d.ts +2 -1
- package/lib/es/anchor/link.js +12 -6
- package/lib/es/calendar/dayCalendar.d.ts +2 -1
- package/lib/es/calendar/dayCalendar.js +7 -2
- package/lib/es/calendar/index.d.ts +1 -0
- package/lib/es/calendar/index.js +1 -0
- package/lib/es/calendar/interface.d.ts +2 -0
- package/lib/es/calendar/monthCalendar.d.ts +1 -1
- package/lib/es/calendar/monthCalendar.js +12 -4
- package/lib/es/calendar/rangeCalendar.d.ts +3 -1
- package/lib/es/calendar/rangeCalendar.js +19 -9
- package/lib/es/calendar/weekCalendar.d.ts +3 -1
- package/lib/es/calendar/weekCalendar.js +19 -9
- package/lib/es/datePicker/datePicker.js +12 -4
- package/lib/es/datePicker/monthsGrid.js +6 -2
- package/lib/es/datePicker/yearAndMonth.d.ts +2 -0
- package/lib/es/datePicker/yearAndMonth.js +4 -2
- package/lib/es/input/textarea.d.ts +1 -1
- package/lib/es/navigation/Footer.d.ts +3 -0
- package/lib/es/navigation/Footer.js +16 -7
- package/lib/es/navigation/SubNav.d.ts +1 -13
- package/lib/es/navigation/SubNav.js +5 -20
- package/lib/es/navigation/index.d.ts +4 -1
- package/lib/es/navigation/index.js +7 -1
- package/lib/es/select/index.d.ts +2 -1
- package/lib/es/select/index.js +4 -0
- package/lib/es/table/Body/index.d.ts +1 -1
- package/lib/es/table/ResizableTable.d.ts +1 -1
- package/lib/es/table/TableHeaderRow.js +22 -14
- package/lib/es/table/interface.d.ts +5 -1
- package/lib/es/typography/base.d.ts +1 -0
- package/lib/es/typography/base.js +28 -14
- package/lib/es/typography/title.d.ts +2 -0
- package/lib/es/typography/title.js +2 -1
- package/package.json +8 -9
|
@@ -20,7 +20,9 @@ export default class WeekCalendar extends BaseComponent<WeekCalendarProps, WeekC
|
|
|
20
20
|
markWeekend: PropTypes.Requireable<boolean>;
|
|
21
21
|
scrollTop: PropTypes.Requireable<number>;
|
|
22
22
|
renderTimeDisplay: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
+
renderDateDisplay: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
24
|
dateGridRender: PropTypes.Requireable<(...args: any[]) => any>;
|
|
25
|
+
allDayEventsRender: PropTypes.Requireable<(...args: any[]) => any>;
|
|
24
26
|
width: PropTypes.Requireable<NonNullable<string | number>>;
|
|
25
27
|
height: PropTypes.Requireable<NonNullable<string | number>>;
|
|
26
28
|
style: PropTypes.Requireable<object>;
|
|
@@ -46,7 +48,7 @@ export default class WeekCalendar extends BaseComponent<WeekCalendarProps, WeekC
|
|
|
46
48
|
handleClick: (e: React.MouseEvent, val: [Date, number, number, number]) => void;
|
|
47
49
|
renderDayGrid: () => JSX.Element[];
|
|
48
50
|
renderHeader: (dateFnsLocale: any) => JSX.Element;
|
|
49
|
-
renderAllDayEvents: (events: ParsedRangeEvent[]) => JSX.Element[];
|
|
51
|
+
renderAllDayEvents: (events: ParsedRangeEvent[]) => string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | JSX.Element[];
|
|
50
52
|
renderAllDay: (locale: Locale['Calendar']) => JSX.Element;
|
|
51
53
|
render(): JSX.Element;
|
|
52
54
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _isEqual from "lodash/isEqual";
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { Fragment } from 'react';
|
|
3
3
|
import cls from 'classnames';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import CalendarFoundation from '@douyinfe/semi-foundation/lib/es/calendar/foundation';
|
|
@@ -66,7 +66,8 @@ export default class WeekCalendar extends BaseComponent {
|
|
|
66
66
|
this.renderHeader = dateFnsLocale => {
|
|
67
67
|
const {
|
|
68
68
|
markWeekend,
|
|
69
|
-
displayValue
|
|
69
|
+
displayValue,
|
|
70
|
+
renderDateDisplay
|
|
70
71
|
} = this.props;
|
|
71
72
|
const {
|
|
72
73
|
month,
|
|
@@ -92,16 +93,21 @@ export default class WeekCalendar extends BaseComponent {
|
|
|
92
93
|
[`${cssClasses.PREFIX}-today`]: isToday,
|
|
93
94
|
[`${cssClasses.PREFIX}-weekend`]: markWeekend && day.isWeekend
|
|
94
95
|
});
|
|
96
|
+
const dateContent = renderDateDisplay ? renderDateDisplay(date) : /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
97
|
+
className: `${cssClasses.PREFIX}-today-date`
|
|
98
|
+
}, dayString), /*#__PURE__*/React.createElement("span", null, weekday));
|
|
95
99
|
return /*#__PURE__*/React.createElement("li", {
|
|
96
100
|
key: `${date.toString()}-weekheader`,
|
|
97
101
|
className: listCls
|
|
98
|
-
},
|
|
99
|
-
className: `${cssClasses.PREFIX}-today-date`
|
|
100
|
-
}, dayString), /*#__PURE__*/React.createElement("span", null, weekday));
|
|
102
|
+
}, dateContent);
|
|
101
103
|
}))));
|
|
102
104
|
};
|
|
103
105
|
|
|
104
106
|
this.renderAllDayEvents = events => {
|
|
107
|
+
if (this.props.allDayEventsRender) {
|
|
108
|
+
return this.props.allDayEventsRender(this.props.events);
|
|
109
|
+
}
|
|
110
|
+
|
|
105
111
|
const list = events.map((event, ind) => {
|
|
106
112
|
const {
|
|
107
113
|
leftPos,
|
|
@@ -126,13 +132,15 @@ export default class WeekCalendar extends BaseComponent {
|
|
|
126
132
|
};
|
|
127
133
|
|
|
128
134
|
this.renderAllDay = locale => {
|
|
135
|
+
const {
|
|
136
|
+
allDayEventsRender
|
|
137
|
+
} = this.props;
|
|
129
138
|
const {
|
|
130
139
|
allDay
|
|
131
140
|
} = this.state.parsedEvents;
|
|
132
141
|
const parsed = this.foundation.parseWeeklyAllDayEvents(allDay);
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
height: `${maxRowHeight}em`
|
|
142
|
+
const style = allDayEventsRender ? null : {
|
|
143
|
+
height: `${calcRowHeight(parsed)}em`
|
|
136
144
|
};
|
|
137
145
|
const {
|
|
138
146
|
markWeekend
|
|
@@ -216,7 +224,7 @@ export default class WeekCalendar extends BaseComponent {
|
|
|
216
224
|
const prevEventKeys = prevState.cachedKeys;
|
|
217
225
|
const nowEventKeys = this.props.events.map(event => event.key);
|
|
218
226
|
|
|
219
|
-
if (!_isEqual(prevEventKeys, nowEventKeys)) {
|
|
227
|
+
if (!_isEqual(prevEventKeys, nowEventKeys) || !_isEqual(prevProps.displayValue, this.props.displayValue)) {
|
|
220
228
|
this.foundation.parseWeeklyEvents();
|
|
221
229
|
}
|
|
222
230
|
}
|
|
@@ -268,7 +276,9 @@ WeekCalendar.propTypes = {
|
|
|
268
276
|
markWeekend: PropTypes.bool,
|
|
269
277
|
scrollTop: PropTypes.number,
|
|
270
278
|
renderTimeDisplay: PropTypes.func,
|
|
279
|
+
renderDateDisplay: PropTypes.func,
|
|
271
280
|
dateGridRender: PropTypes.func,
|
|
281
|
+
allDayEventsRender: PropTypes.func,
|
|
272
282
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
273
283
|
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
274
284
|
style: PropTypes.object,
|
|
@@ -170,7 +170,9 @@ export default class DatePicker extends BaseComponent {
|
|
|
170
170
|
density,
|
|
171
171
|
presetPosition,
|
|
172
172
|
yearAndMonthOpts,
|
|
173
|
-
type
|
|
173
|
+
type,
|
|
174
|
+
startYear,
|
|
175
|
+
endYear
|
|
174
176
|
} = this.props;
|
|
175
177
|
const date = this.state.value[0];
|
|
176
178
|
const year = {
|
|
@@ -210,7 +212,9 @@ export default class DatePicker extends BaseComponent {
|
|
|
210
212
|
renderQuickControls: this.renderQuickControls(),
|
|
211
213
|
renderDateInput: this.renderDateInput(),
|
|
212
214
|
type: type,
|
|
213
|
-
yearAndMonthOpts: yearAndMonthOpts
|
|
215
|
+
yearAndMonthOpts: yearAndMonthOpts,
|
|
216
|
+
startYear: startYear,
|
|
217
|
+
endYear: endYear
|
|
214
218
|
});
|
|
215
219
|
};
|
|
216
220
|
|
|
@@ -608,7 +612,9 @@ export default class DatePicker extends BaseComponent {
|
|
|
608
612
|
triggerRender,
|
|
609
613
|
insetInput,
|
|
610
614
|
presetPosition,
|
|
611
|
-
yearAndMonthOpts
|
|
615
|
+
yearAndMonthOpts,
|
|
616
|
+
startYear,
|
|
617
|
+
endYear
|
|
612
618
|
} = this.props;
|
|
613
619
|
const {
|
|
614
620
|
cachedSelectedValue,
|
|
@@ -652,7 +658,9 @@ export default class DatePicker extends BaseComponent {
|
|
|
652
658
|
presetPosition: presetPosition,
|
|
653
659
|
renderQuickControls: this.renderQuickControls(),
|
|
654
660
|
renderDateInput: this.renderDateInput(),
|
|
655
|
-
yearAndMonthOpts: yearAndMonthOpts
|
|
661
|
+
yearAndMonthOpts: yearAndMonthOpts,
|
|
662
|
+
startYear: startYear,
|
|
663
|
+
endYear: endYear
|
|
656
664
|
});
|
|
657
665
|
}
|
|
658
666
|
|
|
@@ -474,7 +474,9 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
474
474
|
locale,
|
|
475
475
|
localeCode,
|
|
476
476
|
density,
|
|
477
|
-
yearAndMonthOpts
|
|
477
|
+
yearAndMonthOpts,
|
|
478
|
+
startYear,
|
|
479
|
+
endYear
|
|
478
480
|
} = this.props;
|
|
479
481
|
const y = pickerDate.getFullYear();
|
|
480
482
|
const m = pickerDate.getMonth() + 1;
|
|
@@ -502,7 +504,9 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
502
504
|
}
|
|
503
505
|
},
|
|
504
506
|
density: density,
|
|
505
|
-
yearAndMonthOpts: yearAndMonthOpts
|
|
507
|
+
yearAndMonthOpts: yearAndMonthOpts,
|
|
508
|
+
startYear: startYear,
|
|
509
|
+
endYear: endYear
|
|
506
510
|
});
|
|
507
511
|
}
|
|
508
512
|
|
|
@@ -25,6 +25,8 @@ declare class YearAndMonth extends BaseComponent<YearAndMonthProps, YearAndMonth
|
|
|
25
25
|
renderQuickControls: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
26
26
|
renderDateInput: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
27
27
|
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "monthRange" | "dateTimeRange">;
|
|
28
|
+
startYear: PropTypes.Requireable<number>;
|
|
29
|
+
endYear: PropTypes.Requireable<number>;
|
|
28
30
|
};
|
|
29
31
|
static defaultProps: {
|
|
30
32
|
disabledDate: {
|
|
@@ -61,7 +61,7 @@ class YearAndMonth extends BaseComponent {
|
|
|
61
61
|
right: currentMonth.right || currentLeftMonth + 1
|
|
62
62
|
};
|
|
63
63
|
this.state = {
|
|
64
|
-
years: getYears().map(year => ({
|
|
64
|
+
years: getYears(props.startYear, props.endYear).map(year => ({
|
|
65
65
|
value: year,
|
|
66
66
|
year
|
|
67
67
|
})),
|
|
@@ -308,7 +308,9 @@ YearAndMonth.propTypes = {
|
|
|
308
308
|
presetPosition: PropTypes.oneOf(strings.PRESET_POSITION_SET),
|
|
309
309
|
renderQuickControls: PropTypes.node,
|
|
310
310
|
renderDateInput: PropTypes.node,
|
|
311
|
-
type: PropTypes.oneOf(strings.TYPE_SET)
|
|
311
|
+
type: PropTypes.oneOf(strings.TYPE_SET),
|
|
312
|
+
startYear: PropTypes.number,
|
|
313
|
+
endYear: PropTypes.number
|
|
312
314
|
};
|
|
313
315
|
YearAndMonth.defaultProps = {
|
|
314
316
|
disabledDate: _stubFalse,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ValidateStatus } from '../_base/baseComponent';
|
|
3
3
|
import '@douyinfe/semi-foundation/lib/es/input/textarea.css';
|
|
4
|
-
declare type OmitTextareaAttr = 'onChange' | 'onInput' | 'prefix' | 'size' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyPress' | 'onKeyUp';
|
|
4
|
+
declare type OmitTextareaAttr = 'onChange' | 'onInput' | 'prefix' | 'size' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyPress' | 'onKeyUp' | 'onResize';
|
|
5
5
|
export interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, OmitTextareaAttr> {
|
|
6
6
|
autosize?: boolean;
|
|
7
7
|
borderless?: boolean;
|
|
@@ -6,6 +6,7 @@ import { BaseProps } from '../_base/baseComponent';
|
|
|
6
6
|
export interface NavFooterProps extends BaseProps {
|
|
7
7
|
collapseButton?: React.ReactNode;
|
|
8
8
|
collapseText?: (collapsed?: boolean) => React.ReactNode;
|
|
9
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
9
10
|
}
|
|
10
11
|
export default class NavFooter extends PureComponent<NavFooterProps> {
|
|
11
12
|
static contextType: React.Context<NavContextType>;
|
|
@@ -15,9 +16,11 @@ export default class NavFooter extends PureComponent<NavFooterProps> {
|
|
|
15
16
|
className: PropTypes.Requireable<string>;
|
|
16
17
|
collapseButton: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
17
18
|
collapseText: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
20
|
};
|
|
19
21
|
static defaultProps: {
|
|
20
22
|
collapseButton: boolean;
|
|
23
|
+
onClick: (...args: any[]) => void;
|
|
21
24
|
};
|
|
22
25
|
context: NavContextType;
|
|
23
26
|
static elementType: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _noop from "lodash/noop";
|
|
1
2
|
import React, { PureComponent } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import cls from 'classnames';
|
|
@@ -39,7 +40,8 @@ export default class NavFooter extends PureComponent {
|
|
|
39
40
|
const {
|
|
40
41
|
style,
|
|
41
42
|
className,
|
|
42
|
-
collapseButton
|
|
43
|
+
collapseButton,
|
|
44
|
+
onClick
|
|
43
45
|
} = this.props;
|
|
44
46
|
let {
|
|
45
47
|
children
|
|
@@ -56,10 +58,15 @@ export default class NavFooter extends PureComponent {
|
|
|
56
58
|
const wrapCls = cls(className, `${cssClasses.PREFIX}-footer`, {
|
|
57
59
|
[`${cssClasses.PREFIX}-footer-collapsed`]: isCollapsed
|
|
58
60
|
});
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
return (
|
|
62
|
+
/*#__PURE__*/
|
|
63
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
64
|
+
React.createElement("div", {
|
|
65
|
+
className: wrapCls,
|
|
66
|
+
style: style,
|
|
67
|
+
onClick: onClick
|
|
68
|
+
}, children)
|
|
69
|
+
);
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
}
|
|
@@ -69,9 +76,11 @@ NavFooter.propTypes = {
|
|
|
69
76
|
style: PropTypes.object,
|
|
70
77
|
className: PropTypes.string,
|
|
71
78
|
collapseButton: PropTypes.oneOfType([PropTypes.node, PropTypes.bool]),
|
|
72
|
-
collapseText: PropTypes.func
|
|
79
|
+
collapseText: PropTypes.func,
|
|
80
|
+
onClick: PropTypes.func
|
|
73
81
|
};
|
|
74
82
|
NavFooter.defaultProps = {
|
|
75
|
-
collapseButton: false
|
|
83
|
+
collapseButton: false,
|
|
84
|
+
onClick: _noop
|
|
76
85
|
};
|
|
77
86
|
NavFooter.elementType = "NavFooter";
|
|
@@ -4,10 +4,6 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import '@douyinfe/semi-foundation/lib/es/navigation/navigation.css';
|
|
5
5
|
import SubNavFoundation, { SubNavAdapter } from '@douyinfe/semi-foundation/lib/es/navigation/subNavFoundation';
|
|
6
6
|
import { NavContextType } from './nav-context';
|
|
7
|
-
export interface ToggleIcon {
|
|
8
|
-
open?: string;
|
|
9
|
-
closed?: string;
|
|
10
|
-
}
|
|
11
7
|
export interface SubNavProps extends BaseProps {
|
|
12
8
|
disabled?: boolean;
|
|
13
9
|
dropdownStyle?: React.CSSProperties;
|
|
@@ -21,7 +17,7 @@ export interface SubNavProps extends BaseProps {
|
|
|
21
17
|
onMouseEnter?: React.MouseEventHandler<HTMLLIElement>;
|
|
22
18
|
onMouseLeave?: React.MouseEventHandler<HTMLLIElement>;
|
|
23
19
|
text?: React.ReactNode;
|
|
24
|
-
|
|
20
|
+
expandIcon?: React.ReactNode;
|
|
25
21
|
}
|
|
26
22
|
export interface SubNavState {
|
|
27
23
|
isHovered: boolean;
|
|
@@ -53,10 +49,6 @@ export default class SubNav extends BaseComponent<SubNavProps, SubNavState> {
|
|
|
53
49
|
* Nested child elements
|
|
54
50
|
*/
|
|
55
51
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
56
|
-
/**
|
|
57
|
-
* The icon name of the right control switch (on and off status)
|
|
58
|
-
*/
|
|
59
|
-
toggleIcon: PropTypes.Requireable<any>;
|
|
60
52
|
style: PropTypes.Requireable<object>;
|
|
61
53
|
/**
|
|
62
54
|
* Icon name on the left
|
|
@@ -77,10 +69,6 @@ export default class SubNav extends BaseComponent<SubNavProps, SubNavState> {
|
|
|
77
69
|
isCollapsed: boolean;
|
|
78
70
|
isOpen: boolean;
|
|
79
71
|
maxHeight: number;
|
|
80
|
-
toggleIcon: {
|
|
81
|
-
open: JSX.Element;
|
|
82
|
-
closed: JSX.Element;
|
|
83
|
-
};
|
|
84
72
|
disabled: boolean;
|
|
85
73
|
};
|
|
86
74
|
titleRef: React.RefObject<HTMLDivElement>;
|
|
@@ -12,7 +12,7 @@ import '@douyinfe/semi-foundation/lib/es/navigation/navigation.css';
|
|
|
12
12
|
import isNullOrUndefined from '@douyinfe/semi-foundation/lib/es/utils/isNullOrUndefined';
|
|
13
13
|
import SubNavFoundation from '@douyinfe/semi-foundation/lib/es/navigation/subNavFoundation';
|
|
14
14
|
import { strings, numbers, cssClasses } from '@douyinfe/semi-foundation/lib/es/navigation/constants';
|
|
15
|
-
import { IconChevronDown,
|
|
15
|
+
import { IconChevronDown, IconChevronRight } from '@douyinfe/semi-icons';
|
|
16
16
|
import NavItem from './Item';
|
|
17
17
|
import Dropdown from '../dropdown';
|
|
18
18
|
import NavContext from './nav-context';
|
|
@@ -156,7 +156,8 @@ export default class SubNav extends BaseComponent {
|
|
|
156
156
|
itemKey,
|
|
157
157
|
indent,
|
|
158
158
|
disabled,
|
|
159
|
-
level
|
|
159
|
+
level,
|
|
160
|
+
expandIcon
|
|
160
161
|
} = this.props;
|
|
161
162
|
const {
|
|
162
163
|
mode,
|
|
@@ -186,7 +187,7 @@ export default class SubNav extends BaseComponent {
|
|
|
186
187
|
"aria-hidden": true
|
|
187
188
|
});
|
|
188
189
|
} else {
|
|
189
|
-
toggleIconType = /*#__PURE__*/React.createElement(IconChevronDown, {
|
|
190
|
+
toggleIconType = expandIcon ? expandIcon : /*#__PURE__*/React.createElement(IconChevronDown, {
|
|
190
191
|
"aria-hidden": true
|
|
191
192
|
}); // Horizontal mode does not require animation fix#1198
|
|
192
193
|
// withTransition = true;
|
|
@@ -196,7 +197,7 @@ export default class SubNav extends BaseComponent {
|
|
|
196
197
|
withTransition = true;
|
|
197
198
|
}
|
|
198
199
|
|
|
199
|
-
toggleIconType = /*#__PURE__*/React.createElement(IconChevronDown, {
|
|
200
|
+
toggleIconType = expandIcon ? expandIcon : /*#__PURE__*/React.createElement(IconChevronDown, {
|
|
200
201
|
"aria-hidden": true
|
|
201
202
|
});
|
|
202
203
|
}
|
|
@@ -380,14 +381,6 @@ SubNav.propTypes = {
|
|
|
380
381
|
* Nested child elements
|
|
381
382
|
*/
|
|
382
383
|
children: PropTypes.node,
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* The icon name of the right control switch (on and off status)
|
|
386
|
-
*/
|
|
387
|
-
toggleIcon: PropTypes.oneOfType([PropTypes.any, PropTypes.shape({
|
|
388
|
-
open: PropTypes.string,
|
|
389
|
-
closed: PropTypes.string
|
|
390
|
-
})]),
|
|
391
384
|
style: PropTypes.object,
|
|
392
385
|
|
|
393
386
|
/**
|
|
@@ -411,13 +404,5 @@ SubNav.defaultProps = {
|
|
|
411
404
|
isCollapsed: false,
|
|
412
405
|
isOpen: false,
|
|
413
406
|
maxHeight: numbers.DEFAULT_SUBNAV_MAX_HEIGHT,
|
|
414
|
-
toggleIcon: {
|
|
415
|
-
open: /*#__PURE__*/React.createElement(IconChevronUp, {
|
|
416
|
-
"aria-hidden": true
|
|
417
|
-
}),
|
|
418
|
-
closed: /*#__PURE__*/React.createElement(IconChevronDown, {
|
|
419
|
-
"aria-hidden": true
|
|
420
|
-
})
|
|
421
|
-
},
|
|
422
407
|
disabled: false
|
|
423
408
|
};
|
|
@@ -11,7 +11,7 @@ export type { CollapseButtonProps } from './CollapseButton';
|
|
|
11
11
|
export type { NavFooterProps } from './Footer';
|
|
12
12
|
export type { NavHeaderProps } from './Header';
|
|
13
13
|
export type { NavItemProps } from './Item';
|
|
14
|
-
export type {
|
|
14
|
+
export type { SubNavProps } from './SubNav';
|
|
15
15
|
export declare type Mode = 'vertical' | 'horizontal';
|
|
16
16
|
export interface OnSelectedData {
|
|
17
17
|
itemKey: React.ReactText;
|
|
@@ -33,6 +33,7 @@ export interface NavProps extends BaseProps {
|
|
|
33
33
|
defaultIsCollapsed?: boolean;
|
|
34
34
|
defaultOpenKeys?: React.ReactText[];
|
|
35
35
|
defaultSelectedKeys?: React.ReactText[];
|
|
36
|
+
expandIcon?: React.ReactNode;
|
|
36
37
|
footer?: React.ReactNode | NavFooterProps;
|
|
37
38
|
header?: React.ReactNode | NavHeaderProps;
|
|
38
39
|
isCollapsed?: boolean;
|
|
@@ -86,9 +87,11 @@ declare class Nav extends BaseComponent<NavProps, NavState> {
|
|
|
86
87
|
static Header: typeof Header;
|
|
87
88
|
static Footer: typeof Footer;
|
|
88
89
|
static propTypes: {
|
|
90
|
+
collapseIcon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
89
91
|
defaultOpenKeys: PropTypes.Requireable<NonNullable<string | number>[]>;
|
|
90
92
|
openKeys: PropTypes.Requireable<NonNullable<string | number>[]>;
|
|
91
93
|
defaultSelectedKeys: PropTypes.Requireable<NonNullable<string | number>[]>;
|
|
94
|
+
expandIcon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
92
95
|
selectedKeys: PropTypes.Requireable<NonNullable<string | number>[]>;
|
|
93
96
|
mode: PropTypes.Requireable<string>;
|
|
94
97
|
onSelect: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -168,12 +168,16 @@ class Nav extends BaseComponent {
|
|
|
168
168
|
renderItems() {
|
|
169
169
|
let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
170
170
|
let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
171
|
+
const {
|
|
172
|
+
expandIcon
|
|
173
|
+
} = this.props;
|
|
171
174
|
const finalDom = /*#__PURE__*/React.createElement(React.Fragment, null, items.map((item, idx) => {
|
|
172
175
|
if (Array.isArray(item.items) && item.items.length) {
|
|
173
176
|
return /*#__PURE__*/React.createElement(SubNav, Object.assign({
|
|
174
177
|
key: item.itemKey || String(level) + idx
|
|
175
178
|
}, item, {
|
|
176
|
-
level: level
|
|
179
|
+
level: level,
|
|
180
|
+
expandIcon: expandIcon
|
|
177
181
|
}), this.renderItems(item.items, level + 1));
|
|
178
182
|
} else {
|
|
179
183
|
return /*#__PURE__*/React.createElement(Item, Object.assign({
|
|
@@ -340,11 +344,13 @@ Nav.Item = Item;
|
|
|
340
344
|
Nav.Header = Header;
|
|
341
345
|
Nav.Footer = Footer;
|
|
342
346
|
Nav.propTypes = {
|
|
347
|
+
collapseIcon: PropTypes.node,
|
|
343
348
|
// Initial expanded SubNav navigation key array
|
|
344
349
|
defaultOpenKeys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
|
|
345
350
|
openKeys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
|
|
346
351
|
// Initial selected navigation key array
|
|
347
352
|
defaultSelectedKeys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
|
|
353
|
+
expandIcon: PropTypes.node,
|
|
348
354
|
selectedKeys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
|
|
349
355
|
// Navigation type, now supports vertical, horizontal
|
|
350
356
|
mode: PropTypes.oneOf([...strings.MODE]),
|
package/lib/es/select/index.d.ts
CHANGED
|
@@ -271,7 +271,7 @@ declare class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
271
271
|
componentDidMount(): void;
|
|
272
272
|
componentWillUnmount(): void;
|
|
273
273
|
componentDidUpdate(prevProps: SelectProps, prevState: SelectState): void;
|
|
274
|
-
handleInputChange: (value: string, event: React.
|
|
274
|
+
handleInputChange: (value: string, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
275
275
|
renderInput(): JSX.Element;
|
|
276
276
|
close(): void;
|
|
277
277
|
open(): void;
|
|
@@ -281,6 +281,7 @@ declare class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
281
281
|
focus(): void;
|
|
282
282
|
onSelect(option: OptionProps, optionIndex: number, e: any): void;
|
|
283
283
|
onClear(e: React.MouseEvent): void;
|
|
284
|
+
search(value: string, event: React.ChangeEvent<HTMLInputElement>): void;
|
|
284
285
|
renderEmpty(): JSX.Element;
|
|
285
286
|
renderLoading(): JSX.Element;
|
|
286
287
|
renderOption(option: OptionProps, optionIndex: number, style?: React.CSSProperties): any;
|
package/lib/es/select/index.js
CHANGED
|
@@ -514,6 +514,10 @@ class Select extends BaseComponent {
|
|
|
514
514
|
this.foundation.handleClearClick(e);
|
|
515
515
|
}
|
|
516
516
|
|
|
517
|
+
search(value, event) {
|
|
518
|
+
this.handleInputChange(value, event);
|
|
519
|
+
}
|
|
520
|
+
|
|
517
521
|
renderEmpty() {
|
|
518
522
|
return /*#__PURE__*/React.createElement(Option, {
|
|
519
523
|
empty: true,
|
|
@@ -2,7 +2,7 @@ import React, { ReactNode } from 'react';
|
|
|
2
2
|
import { FlattenData, GroupFlattenData } from '@douyinfe/semi-foundation/lib/es/table/bodyFoundation';
|
|
3
3
|
import Store from '@douyinfe/semi-foundation/lib/es/utils/Store';
|
|
4
4
|
import { BaseProps } from '../../_base/baseComponent';
|
|
5
|
-
import { ExpandedRowRender, Virtualized, GetVirtualizedListRef, ColumnProps, Size, BodyScrollEvent, Scroll, Fixed, TableComponents, RowExpandable, VirtualizedOnScroll, RowKey } from '../interface';
|
|
5
|
+
import type { ExpandedRowRender, Virtualized, GetVirtualizedListRef, ColumnProps, Size, BodyScrollEvent, Scroll, Fixed, TableComponents, RowExpandable, VirtualizedOnScroll, RowKey } from '../interface';
|
|
6
6
|
export interface BodyProps extends BaseProps {
|
|
7
7
|
tableLayout?: 'fixed' | 'auto';
|
|
8
8
|
anyColumnFixed?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Table from './Table';
|
|
3
|
-
import { TableProps } from './interface';
|
|
3
|
+
import type { TableProps } from './interface';
|
|
4
4
|
declare const _default: React.ForwardRefExoticComponent<TableProps<any> & React.RefAttributes<Table<any>>>;
|
|
5
5
|
export default _default;
|
|
@@ -169,22 +169,30 @@ export default class TableHeaderRow extends BaseComponent {
|
|
|
169
169
|
return null;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
172
|
+
return (
|
|
173
|
+
/*#__PURE__*/
|
|
174
|
+
// @ts-ignore no need to do complex ts type checking and qualification
|
|
175
|
+
React.createElement(HeaderCell, Object.assign({
|
|
176
|
+
role: "columnheader",
|
|
177
|
+
"aria-colindex": cellIndex + 1
|
|
178
|
+
}, props, {
|
|
179
|
+
style: cellStyle,
|
|
180
|
+
key: column.key || column.dataIndex || cellIndex
|
|
181
|
+
}))
|
|
182
|
+
);
|
|
179
183
|
});
|
|
180
184
|
|
|
181
|
-
return
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
return (
|
|
186
|
+
/*#__PURE__*/
|
|
187
|
+
// @ts-ignore no need to do complex ts type checking and qualification
|
|
188
|
+
React.createElement(HeaderRow, Object.assign({
|
|
189
|
+
role: "row",
|
|
190
|
+
"aria-rowindex": index + 1
|
|
191
|
+
}, rowProps, {
|
|
192
|
+
style: style,
|
|
193
|
+
ref: this.cacheRef
|
|
194
|
+
}), cells)
|
|
195
|
+
);
|
|
188
196
|
}
|
|
189
197
|
|
|
190
198
|
}
|
|
@@ -262,8 +262,12 @@ export declare type VirtualizedOnScrollArgs = {
|
|
|
262
262
|
scrollOffset?: number;
|
|
263
263
|
scrollUpdateWasRequested?: boolean;
|
|
264
264
|
};
|
|
265
|
+
export declare type VirtualizeItemSizeRow = {
|
|
266
|
+
sectionRow?: boolean;
|
|
267
|
+
expandedRow?: boolean;
|
|
268
|
+
};
|
|
265
269
|
export declare type VirtualizedMode = 'list' | 'grid';
|
|
266
|
-
export declare type VirtualizedItemSizeFn = (index?: number) => number;
|
|
270
|
+
export declare type VirtualizedItemSizeFn = (index?: number, row?: VirtualizeItemSizeRow) => number;
|
|
267
271
|
export declare type VirtualizedItemSize = number | VirtualizedItemSizeFn;
|
|
268
272
|
export declare type VirtualizedOnScroll = (object: VirtualizedOnScrollArgs) => void;
|
|
269
273
|
export interface VirtualizedProps {
|
|
@@ -76,7 +76,7 @@ export default class Base extends Component {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
this.rafId = window.requestAnimationFrame(this.getEllipsisState.bind(this));
|
|
79
|
-
}; // if
|
|
79
|
+
}; // if it needs to use js overflowed:
|
|
80
80
|
// 1. text is expandable 2. expandText need to be shown 3. has extra operation 4. text need to ellipse from mid
|
|
81
81
|
|
|
82
82
|
|
|
@@ -419,10 +419,7 @@ export default class Base extends Component {
|
|
|
419
419
|
const {
|
|
420
420
|
expanded
|
|
421
421
|
} = this.state;
|
|
422
|
-
const canUseCSSEllipsis = this.canUseCSSEllipsis(); //
|
|
423
|
-
// both css truncation and js truncation should throw a warning
|
|
424
|
-
|
|
425
|
-
warning('children' in this.props && typeof children !== 'string', "[Semi Typography] 'Only children with pure text could be used with ellipsis at this moment."); // If children is null, css/js truncated flag isTruncate is false
|
|
422
|
+
const canUseCSSEllipsis = this.canUseCSSEllipsis(); // If children is null, css/js truncated flag isTruncate is false
|
|
426
423
|
|
|
427
424
|
if (_isNull(children)) {
|
|
428
425
|
this.setState({
|
|
@@ -430,7 +427,11 @@ export default class Base extends Component {
|
|
|
430
427
|
isOverflowed: false
|
|
431
428
|
});
|
|
432
429
|
return undefined;
|
|
433
|
-
}
|
|
430
|
+
} // Currently only text truncation is supported, if there is non-text,
|
|
431
|
+
// both css truncation and js truncation should throw a warning
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
warning('children' in this.props && typeof children !== 'string', "[Semi Typography] Only children with pure text could be used with ellipsis at this moment.");
|
|
434
435
|
|
|
435
436
|
if (!rows || rows < 0 || expanded) {
|
|
436
437
|
return undefined;
|
|
@@ -539,9 +540,10 @@ export default class Base extends Component {
|
|
|
539
540
|
icon,
|
|
540
541
|
size,
|
|
541
542
|
link,
|
|
542
|
-
heading
|
|
543
|
+
heading,
|
|
544
|
+
weight
|
|
543
545
|
} = _a,
|
|
544
|
-
rest = __rest(_a, ["component", "children", "className", "type", "spacing", "disabled", "style", "ellipsis", "icon", "size", "link", "heading"]);
|
|
546
|
+
rest = __rest(_a, ["component", "children", "className", "type", "spacing", "disabled", "style", "ellipsis", "icon", "size", "link", "heading", "weight"]);
|
|
545
547
|
|
|
546
548
|
const textProps = _omit(rest, ['strong', 'editable', 'mark', 'copyable', 'underline', 'code', // 'link',
|
|
547
549
|
'delete']);
|
|
@@ -561,6 +563,7 @@ export default class Base extends Component {
|
|
|
561
563
|
className: linkCls
|
|
562
564
|
}, textNode) : textNode));
|
|
563
565
|
const hTagReg = /^h[1-6]$/;
|
|
566
|
+
const isHeader = _isString(heading) && hTagReg.test(heading);
|
|
564
567
|
const wrapperCls = cls(className, ellipsisCls, {
|
|
565
568
|
// [`${prefixCls}-primary`]: !type || type === 'primary',
|
|
566
569
|
[`${prefixCls}-${type}`]: type && !link,
|
|
@@ -568,11 +571,15 @@ export default class Base extends Component {
|
|
|
568
571
|
[`${prefixCls}-link`]: link,
|
|
569
572
|
[`${prefixCls}-disabled`]: disabled,
|
|
570
573
|
[`${prefixCls}-${spacing}`]: spacing,
|
|
571
|
-
[`${prefixCls}-${heading}`]:
|
|
574
|
+
[`${prefixCls}-${heading}`]: isHeader,
|
|
575
|
+
[`${prefixCls}-${heading}-weight-${weight}`]: isHeader && isNaN(Number(weight))
|
|
572
576
|
});
|
|
577
|
+
const textStyle = Object.assign(Object.assign({}, isNaN(Number(weight)) ? {} : {
|
|
578
|
+
fontWeight: weight
|
|
579
|
+
}), style);
|
|
573
580
|
return /*#__PURE__*/React.createElement(Typography, Object.assign({
|
|
574
581
|
className: wrapperCls,
|
|
575
|
-
style: Object.assign(Object.assign({},
|
|
582
|
+
style: Object.assign(Object.assign({}, textStyle), ellipsisStyle),
|
|
576
583
|
component: component,
|
|
577
584
|
forwardRef: this.wrapperRef
|
|
578
585
|
}, textProps), textNode, this.renderOperations());
|
|
@@ -608,15 +615,22 @@ export default class Base extends Component {
|
|
|
608
615
|
}
|
|
609
616
|
|
|
610
617
|
render() {
|
|
611
|
-
|
|
612
|
-
onResize: this.onResize
|
|
613
|
-
}, /*#__PURE__*/React.createElement(LocaleConsumer, {
|
|
618
|
+
const content = /*#__PURE__*/React.createElement(LocaleConsumer, {
|
|
614
619
|
componentName: "Typography"
|
|
615
620
|
}, locale => {
|
|
616
621
|
this.expandStr = locale.expand;
|
|
617
622
|
this.collapseStr = locale.collapse;
|
|
618
623
|
return this.renderTipWrapper();
|
|
619
|
-
})
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
if (this.props.ellipsis) {
|
|
627
|
+
return /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
628
|
+
onResize: this.onResize,
|
|
629
|
+
observeParent: true
|
|
630
|
+
}, content);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
return content;
|
|
620
634
|
}
|
|
621
635
|
|
|
622
636
|
}
|